diff options
Diffstat (limited to 'oox/source/drawingml/table')
-rw-r--r-- | oox/source/drawingml/table/predefined-table-styles.cxx | 982 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablebackgroundstylecontext.cxx | 74 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablecell.cxx | 473 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablecellcontext.cxx | 103 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablecontext.cxx | 93 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablepartstylecontext.cxx | 60 | ||||
-rw-r--r-- | oox/source/drawingml/table/tableproperties.cxx | 270 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablerow.cxx | 36 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablerowcontext.cxx | 65 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestyle.cxx | 30 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestylecellstylecontext.cxx | 110 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestylecontext.cxx | 89 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestylelist.cxx | 35 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestylelistfragmenthandler.cxx | 63 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestylepart.cxx | 36 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestyletextstylecontext.cxx | 98 |
16 files changed, 2617 insertions, 0 deletions
diff --git a/oox/source/drawingml/table/predefined-table-styles.cxx b/oox/source/drawingml/table/predefined-table-styles.cxx new file mode 100644 index 000000000..4a8aec4ce --- /dev/null +++ b/oox/source/drawingml/table/predefined-table-styles.cxx @@ -0,0 +1,982 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#include <oox/token/tokens.hxx> +#include <drawingml/table/tablestyle.hxx> + +using namespace oox; +using namespace oox::drawingml::table; + +/* tdf#107604 + * There are predefined table styles that have a + * style id (in ppt/slides/slidex.xml) but does not have + * corresponding style definition (ppt/tableStyles.xml). + * So we should create those styles here for this case. + * There are 74 predefined styles and many different + * variables. A style map was created by examining all + * 74 style properties. And table styles were coded according + * to that map. You can see that map in + * oox/documentation/predefined-styles-map.ods. We should + * define all of these variables to keep the code readable + * and change something easily when some styles change. + */ + +std::map<OUString, std::pair<OUString, OUString>> mStyleIdMap; + +// Create style-id map for using similar attributes of the groups. +// (style ids used from here: https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/hh273476(v=office.14)?redirectedfrom=MSDN) +// and checked all of them. + +static void createStyleIdMap() +{ + mStyleIdMap[OUString("{2D5ABB26-0587-4C30-8999-92F81FD0307C}")] + = std::make_pair(OUString("Themed-Style-1"), OUString("")); + mStyleIdMap[OUString("{3C2FFA5D-87B4-456A-9821-1D502468CF0F}")] + = std::make_pair(OUString("Themed-Style-1"), OUString("Accent1")); + mStyleIdMap[OUString("{284E427A-3D55-4303-BF80-6455036E1DE7}")] + = std::make_pair(OUString("Themed-Style-1"), OUString("Accent2")); + mStyleIdMap[OUString("{69C7853C-536D-4A76-A0AE-DD22124D55A5}")] + = std::make_pair(OUString("Themed-Style-1"), OUString("Accent3")); + mStyleIdMap[OUString("{775DCB02-9BB8-47FD-8907-85C794F793BA}")] + = std::make_pair(OUString("Themed-Style-1"), OUString("Accent4")); + mStyleIdMap[OUString("{35758FB7-9AC5-4552-8A53-C91805E547FA}")] + = std::make_pair(OUString("Themed-Style-1"), OUString("Accent5")); + mStyleIdMap[OUString("{08FB837D-C827-4EFA-A057-4D05807E0F7C}")] + = std::make_pair(OUString("Themed-Style-1"), OUString("Accent6")); + + mStyleIdMap[OUString("{5940675A-B579-460E-94D1-54222C63F5DA}")] + = std::make_pair(OUString("Themed-Style-2"), OUString("")); + mStyleIdMap[OUString("{D113A9D2-9D6B-4929-AA2D-F23B5EE8CBE7}")] + = std::make_pair(OUString("Themed-Style-2"), OUString("Accent1")); + mStyleIdMap[OUString("{18603FDC-E32A-4AB5-989C-0864C3EAD2B8}")] + = std::make_pair(OUString("Themed-Style-2"), OUString("Accent2")); + mStyleIdMap[OUString("{306799F8-075E-4A3A-A7F6-7FBC6576F1A4}")] + = std::make_pair(OUString("Themed-Style-2"), OUString("Accent3")); + mStyleIdMap[OUString("{E269D01E-BC32-4049-B463-5C60D7B0CCD2}")] + = std::make_pair(OUString("Themed-Style-2"), OUString("Accent4")); + mStyleIdMap[OUString("{327F97BB-C833-4FB7-BDE5-3F7075034690}")] + = std::make_pair(OUString("Themed-Style-2"), OUString("Accent5")); + mStyleIdMap[OUString("{638B1855-1B75-4FBE-930C-398BA8C253C6}")] + = std::make_pair(OUString("Themed-Style-2"), OUString("Accent6")); + + mStyleIdMap[OUString("{9D7B26C5-4107-4FEC-AEDC-1716B250A1EF}")] + = std::make_pair(OUString("Light-Style-1"), OUString("")); + mStyleIdMap[OUString("{3B4B98B0-60AC-42C2-AFA5-B58CD77FA1E5}")] + = std::make_pair(OUString("Light-Style-1"), OUString("Accent1")); + mStyleIdMap[OUString("{0E3FDE45-AF77-4B5C-9715-49D594BDF05E}")] + = std::make_pair(OUString("Light-Style-1"), OUString("Accent2")); + mStyleIdMap[OUString("{C083E6E3-FA7D-4D7B-A595-EF9225AFEA82}")] + = std::make_pair(OUString("Light-Style-1"), OUString("Accent3")); + mStyleIdMap[OUString("{D27102A9-8310-4765-A935-A1911B00CA55}")] + = std::make_pair(OUString("Light-Style-1"), OUString("Accent4")); + mStyleIdMap[OUString("{5FD0F851-EC5A-4D38-B0AD-8093EC10F338}")] + = std::make_pair(OUString("Light-Style-1"), OUString("Accent5")); + mStyleIdMap[OUString("{68D230F3-CF80-4859-8CE7-A43EE81993B5}")] + = std::make_pair(OUString("Light-Style-1"), OUString("Accent6")); + + mStyleIdMap[OUString("{7E9639D4-E3E2-4D34-9284-5A2195B3D0D7}")] + = std::make_pair(OUString("Light-Style-2"), OUString("")); + mStyleIdMap[OUString("{69012ECD-51FC-41F1-AA8D-1B2483CD663E}")] + = std::make_pair(OUString("Light-Style-2"), OUString("Accent1")); + mStyleIdMap[OUString("{72833802-FEF1-4C79-8D5D-14CF1EAF98D9}")] + = std::make_pair(OUString("Light-Style-2"), OUString("Accent2")); + mStyleIdMap[OUString("{F2DE63D5-997A-4646-A377-4702673A728D}")] + = std::make_pair(OUString("Light-Style-2"), OUString("Accent3")); + mStyleIdMap[OUString("{17292A2E-F333-43FB-9621-5CBBE7FDCDCB}")] + = std::make_pair(OUString("Light-Style-2"), OUString("Accent4")); + mStyleIdMap[OUString("{5A111915-BE36-4E01-A7E5-04B1672EAD32}")] + = std::make_pair(OUString("Light-Style-2"), OUString("Accent5")); + mStyleIdMap[OUString("{912C8C85-51F0-491E-9774-3900AFEF0FD7}")] + = std::make_pair(OUString("Light-Style-2"), OUString("Accent6")); + + mStyleIdMap[OUString("{616DA210-FB5B-4158-B5E0-FEB733F419BA}")] + = std::make_pair(OUString("Light-Style-3"), OUString("")); + mStyleIdMap[OUString("{BC89EF96-8CEA-46FF-86C4-4CE0E7609802}")] + = std::make_pair(OUString("Light-Style-3"), OUString("Accent1")); + mStyleIdMap[OUString("{5DA37D80-6434-44D0-A028-1B22A696006F}")] + = std::make_pair(OUString("Light-Style-3"), OUString("Accent2")); + mStyleIdMap[OUString("{8799B23B-EC83-4686-B30A-512413B5E67A}")] + = std::make_pair(OUString("Light-Style-3"), OUString("Accent3")); + mStyleIdMap[OUString("{ED083AE6-46FA-4A59-8FB0-9F97EB10719F}")] + = std::make_pair(OUString("Light-Style-3"), OUString("Accent4")); + mStyleIdMap[OUString("{BDBED569-4797-4DF1-A0F4-6AAB3CD982D8}")] + = std::make_pair(OUString("Light-Style-3"), OUString("Accent5")); + mStyleIdMap[OUString("{E8B1032C-EA38-4F05-BA0D-38AFFFC7BED3}")] + = std::make_pair(OUString("Light-Style-3"), OUString("Accent6")); + + mStyleIdMap[OUString("{793D81CF-94F2-401A-BA57-92F5A7B2D0C5}")] + = std::make_pair(OUString("Medium-Style-1"), OUString("")); + mStyleIdMap[OUString("{B301B821-A1FF-4177-AEE7-76D212191A09}")] + = std::make_pair(OUString("Medium-Style-1"), OUString("Accent1")); + mStyleIdMap[OUString("{9DCAF9ED-07DC-4A11-8D7F-57B35C25682E}")] + = std::make_pair(OUString("Medium-Style-1"), OUString("Accent2")); + mStyleIdMap[OUString("{1FECB4D8-DB02-4DC6-A0A2-4F2EBAE1DC90}")] + = std::make_pair(OUString("Medium-Style-1"), OUString("Accent3")); + mStyleIdMap[OUString("{1E171933-4619-4E11-9A3F-F7608DF75F80}")] + = std::make_pair(OUString("Medium-Style-1"), OUString("Accent4")); + mStyleIdMap[OUString("{FABFCF23-3B69-468F-B69F-88F6DE6A72F2}")] + = std::make_pair(OUString("Medium-Style-1"), OUString("Accent5")); + mStyleIdMap[OUString("{10A1B5D5-9B99-4C35-A422-299274C87663}")] + = std::make_pair(OUString("Medium-Style-1"), OUString("Accent6")); + + mStyleIdMap[OUString("{073A0DAA-6AF3-43AB-8588-CEC1D06C72B9}")] + = std::make_pair(OUString("Medium-Style-2"), OUString("")); + mStyleIdMap[OUString("{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}")] + = std::make_pair(OUString("Medium-Style-2"), OUString("Accent1")); + mStyleIdMap[OUString("{21E4AEA4-8DFA-4A89-87EB-49C32662AFE0}")] + = std::make_pair(OUString("Medium-Style-2"), OUString("Accent2")); + mStyleIdMap[OUString("{F5AB1C69-6EDB-4FF4-983F-18BD219EF322}")] + = std::make_pair(OUString("Medium-Style-2"), OUString("Accent3")); + mStyleIdMap[OUString("{00A15C55-8517-42AA-B614-E9B94910E393}")] + = std::make_pair(OUString("Medium-Style-2"), OUString("Accent4")); + mStyleIdMap[OUString("{7DF18680-E054-41AD-8BC1-D1AEF772440D}")] + = std::make_pair(OUString("Medium-Style-2"), OUString("Accent5")); + mStyleIdMap[OUString("{93296810-A885-4BE3-A3E7-6D5BEEA58F35}")] + = std::make_pair(OUString("Medium-Style-2"), OUString("Accent6")); + + mStyleIdMap[OUString("{8EC20E35-A176-4012-BC5E-935CFFF8708E}")] + = std::make_pair(OUString("Medium-Style-3"), OUString("")); + mStyleIdMap[OUString("{6E25E649-3F16-4E02-A733-19D2CDBF48F0}")] + = std::make_pair(OUString("Medium-Style-3"), OUString("Accent1")); + mStyleIdMap[OUString("{85BE263C-DBD7-4A20-BB59-AAB30ACAA65A}")] + = std::make_pair(OUString("Medium-Style-3"), OUString("Accent2")); + mStyleIdMap[OUString("{EB344D84-9AFB-497E-A393-DC336BA19D2E}")] + = std::make_pair(OUString("Medium-Style-3"), OUString("Accent3")); + mStyleIdMap[OUString("{EB9631B5-78F2-41C9-869B-9F39066F8104}")] + = std::make_pair(OUString("Medium-Style-3"), OUString("Accent4")); + mStyleIdMap[OUString("{74C1A8A3-306A-4EB7-A6B1-4F7E0EB9C5D6}")] + = std::make_pair(OUString("Medium-Style-3"), OUString("Accent5")); + mStyleIdMap[OUString("{2A488322-F2BA-4B5B-9748-0D474271808F}")] + = std::make_pair(OUString("Medium-Style-3"), OUString("Accent6")); + + mStyleIdMap[OUString("{D7AC3CCA-C797-4891-BE02-D94E43425B78}")] + = std::make_pair(OUString("Medium-Style-4"), OUString("")); + mStyleIdMap[OUString("{69CF1AB2-1976-4502-BF36-3FF5EA218861}")] + = std::make_pair(OUString("Medium-Style-4"), OUString("Accent1")); + mStyleIdMap[OUString("{8A107856-5554-42FB-B03E-39F5DBC370BA}")] + = std::make_pair(OUString("Medium-Style-4"), OUString("Accent2")); + mStyleIdMap[OUString("{0505E3EF-67EA-436B-97B2-0124C06EBD24}")] + = std::make_pair(OUString("Medium-Style-4"), OUString("Accent3")); + mStyleIdMap[OUString("{C4B1156A-380E-4F78-BDF5-A606A8083BF9}")] + = std::make_pair(OUString("Medium-Style-4"), OUString("Accent4")); + mStyleIdMap[OUString("{22838BEF-8BB2-4498-84A7-C5851F593DF1}")] + = std::make_pair(OUString("Medium-Style-4"), OUString("Accent5")); + mStyleIdMap[OUString("{16D9F66E-5EB9-4882-86FB-DCBF35E3C3E4}")] + = std::make_pair(OUString("Medium-Style-4"), OUString("Accent6")); + + mStyleIdMap[OUString("{E8034E78-7F5D-4C2E-B375-FC64B27BC917}")] + = std::make_pair(OUString("Dark-Style-1"), OUString("")); + mStyleIdMap[OUString("{125E5076-3810-47DD-B79F-674D7AD40C01}")] + = std::make_pair(OUString("Dark-Style-1"), OUString("Accent1")); + mStyleIdMap[OUString("{37CE84F3-28C3-443E-9E96-99CF82512B78}")] + = std::make_pair(OUString("Dark-Style-1"), OUString("Accent2")); + mStyleIdMap[OUString("{D03447BB-5D67-496B-8E87-E561075AD55C}")] + = std::make_pair(OUString("Dark-Style-1"), OUString("Accent3")); + mStyleIdMap[OUString("{E929F9F4-4A8F-4326-A1B4-22849713DDAB}")] + = std::make_pair(OUString("Dark-Style-1"), OUString("Accent4")); + mStyleIdMap[OUString("{8FD4443E-F989-4FC4-A0C8-D5A2AF1F390B}")] + = std::make_pair(OUString("Dark-Style-1"), OUString("Accent5")); + mStyleIdMap[OUString("{AF606853-7671-496A-8E4F-DF71F8EC918B}")] + = std::make_pair(OUString("Dark-Style-1"), OUString("Accent6")); + + mStyleIdMap[OUString("{5202B0CA-FC54-4496-8BCA-5EF66A818D29}")] + = std::make_pair(OUString("Dark-Style-2"), OUString("")); + mStyleIdMap[OUString("{0660B408-B3CF-4A94-85FC-2B1E0A45F4A2}")] + = std::make_pair(OUString("Dark-Style-2"), OUString("Accent1")); + mStyleIdMap[OUString("{91EBBBCC-DAD2-459C-BE2E-F6DE35CF9A28}")] + = std::make_pair(OUString("Dark-Style-2"), OUString("Accent3")); + mStyleIdMap[OUString("{46F890A9-2807-4EBB-B81D-B2AA78EC7F39}")] + = std::make_pair(OUString("Dark-Style-2"), OUString("Accent5")); +} + +static std::map<OUString, sal_Int32> tokens = { { "", XML_dk1 }, + { "Accent1", XML_accent1 }, + { "Accent2", XML_accent2 }, + { "Accent3", XML_accent3 }, + { "Accent4", XML_accent4 }, + { "Accent5", XML_accent5 }, + { "Accent6", XML_accent6 } }; + +std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) +{ + createStyleIdMap(); + std::unique_ptr<TableStyle> pTableStyle; + pTableStyle.reset(new TableStyle()); + + // Text Color definitions for table parts + + ::oox::drawingml::Color wholeTblTextColor; + ::oox::drawingml::Color firstRowTextColor; + ::oox::drawingml::Color firstColTextColor; + ::oox::drawingml::Color lastRowTextColor; + ::oox::drawingml::Color lastColTextColor; + ::oox::drawingml::Color band1HTextColor; + ::oox::drawingml::Color band1VTextColor; + ::oox::drawingml::Color band2HTextColor; + ::oox::drawingml::Color band2VTextColor; + + // Fill properties definitions for table parts + + oox::drawingml::FillPropertiesPtr pWholeTblFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + oox::drawingml::FillPropertiesPtr pFirstRowFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + oox::drawingml::FillPropertiesPtr pFirstColFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + oox::drawingml::FillPropertiesPtr pLastRowFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + oox::drawingml::FillPropertiesPtr pLastColFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + oox::drawingml::FillPropertiesPtr pBand1HFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + oox::drawingml::FillPropertiesPtr pBand1VFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + oox::drawingml::FillPropertiesPtr pBand2HFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + oox::drawingml::FillPropertiesPtr pBand2VFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + oox::drawingml::FillPropertiesPtr pTblBgFillProperties + = std::make_shared<oox::drawingml::FillProperties>(); + + // Start table border line properties definitions for table parts + + oox::drawingml::LinePropertiesPtr pWholeTblLeftBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pWholeTblRightBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pWholeTblTopBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pWholeTblBottomBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pWholeTblInsideHBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pWholeTblInsideVBorder + = std::make_shared<oox::drawingml::LineProperties>(); + + oox::drawingml::LinePropertiesPtr pFirstRowLeftBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstRowRightBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstRowTopBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstRowBottomBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstRowInsideHBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstRowInsideVBorder + = std::make_shared<oox::drawingml::LineProperties>(); + + oox::drawingml::LinePropertiesPtr pFirstColLeftBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstColRightBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstColTopBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstColBottomBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstColInsideHBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pFirstColInsideVBorder + = std::make_shared<oox::drawingml::LineProperties>(); + + oox::drawingml::LinePropertiesPtr pLastColLeftBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastColRightBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastColTopBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastColBottomBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastColInsideHBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastColInsideVBorder + = std::make_shared<oox::drawingml::LineProperties>(); + + oox::drawingml::LinePropertiesPtr pLastRowLeftBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastRowRightBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastRowTopBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastRowBottomBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastRowInsideHBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pLastRowInsideVBorder + = std::make_shared<oox::drawingml::LineProperties>(); + + oox::drawingml::LinePropertiesPtr pBand1HLeftBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1HRightBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1HTopBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1HBottomBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1HInsideHBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1HInsideVBorder + = std::make_shared<oox::drawingml::LineProperties>(); + + oox::drawingml::LinePropertiesPtr pBand1VLeftBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1VRightBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1VTopBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1VBottomBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1VInsideHBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand1VInsideVBorder + = std::make_shared<oox::drawingml::LineProperties>(); + + oox::drawingml::LinePropertiesPtr pBand2HLeftBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2HRightBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2HTopBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2HBottomBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2HInsideHBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2HInsideVBorder + = std::make_shared<oox::drawingml::LineProperties>(); + + oox::drawingml::LinePropertiesPtr pBand2VLeftBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2VRightBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2VTopBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2VBottomBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2VInsideHBorder + = std::make_shared<oox::drawingml::LineProperties>(); + oox::drawingml::LinePropertiesPtr pBand2VInsideVBorder + = std::make_shared<oox::drawingml::LineProperties>(); + + // End table border line properties definitions for table parts + + // Start to set fill types. + + pTblBgFillProperties->moFillType.set(XML_solidFill); + pWholeTblFillProperties->moFillType.set(XML_solidFill); + pFirstRowFillProperties->moFillType.set(XML_solidFill); + pFirstColFillProperties->moFillType.set(XML_solidFill); + pLastRowFillProperties->moFillType.set(XML_solidFill); + pLastColFillProperties->moFillType.set(XML_solidFill); + pBand1HFillProperties->moFillType.set(XML_solidFill); + pBand1VFillProperties->moFillType.set(XML_solidFill); + pBand2HFillProperties->moFillType.set(XML_solidFill); + pBand2VFillProperties->moFillType.set(XML_solidFill); + + pWholeTblLeftBorder->maLineFill.moFillType.set(XML_solidFill); + pWholeTblRightBorder->maLineFill.moFillType.set(XML_solidFill); + pWholeTblTopBorder->maLineFill.moFillType.set(XML_solidFill); + pWholeTblBottomBorder->maLineFill.moFillType.set(XML_solidFill); + pWholeTblInsideHBorder->maLineFill.moFillType.set(XML_solidFill); + pWholeTblInsideVBorder->maLineFill.moFillType.set(XML_solidFill); + + pFirstRowLeftBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstRowRightBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstRowTopBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstRowBottomBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstRowInsideHBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstRowInsideVBorder->maLineFill.moFillType.set(XML_solidFill); + + pFirstColLeftBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstColRightBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstColTopBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstColBottomBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstColInsideHBorder->maLineFill.moFillType.set(XML_solidFill); + pFirstColInsideVBorder->maLineFill.moFillType.set(XML_solidFill); + + pLastRowLeftBorder->maLineFill.moFillType.set(XML_solidFill); + pLastRowRightBorder->maLineFill.moFillType.set(XML_solidFill); + pLastRowTopBorder->maLineFill.moFillType.set(XML_solidFill); + pLastRowBottomBorder->maLineFill.moFillType.set(XML_solidFill); + pLastRowInsideHBorder->maLineFill.moFillType.set(XML_solidFill); + pLastRowInsideVBorder->maLineFill.moFillType.set(XML_solidFill); + + pLastColLeftBorder->maLineFill.moFillType.set(XML_solidFill); + pLastColRightBorder->maLineFill.moFillType.set(XML_solidFill); + pLastColTopBorder->maLineFill.moFillType.set(XML_solidFill); + pLastColBottomBorder->maLineFill.moFillType.set(XML_solidFill); + pLastColInsideHBorder->maLineFill.moFillType.set(XML_solidFill); + pLastColInsideVBorder->maLineFill.moFillType.set(XML_solidFill); + + pBand1HLeftBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1HRightBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1HTopBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1HBottomBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1HInsideHBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1HInsideVBorder->maLineFill.moFillType.set(XML_solidFill); + + pBand1VLeftBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1VRightBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1VTopBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1VBottomBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1VInsideHBorder->maLineFill.moFillType.set(XML_solidFill); + pBand1VInsideVBorder->maLineFill.moFillType.set(XML_solidFill); + + pBand2HLeftBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2HRightBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2HTopBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2HBottomBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2HInsideHBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2HInsideVBorder->maLineFill.moFillType.set(XML_solidFill); + + pBand2VLeftBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2VRightBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2VTopBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2VBottomBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2VInsideHBorder->maLineFill.moFillType.set(XML_solidFill); + pBand2VInsideVBorder->maLineFill.moFillType.set(XML_solidFill); + + // End to set fill types. + + // Define common properties. + + pWholeTblLeftBorder->moLineWidth = 12700; + pWholeTblRightBorder->moLineWidth = 12700; + pWholeTblTopBorder->moLineWidth = 12700; + pWholeTblBottomBorder->moLineWidth = 12700; + pWholeTblInsideHBorder->moLineWidth = 12700; + pWholeTblInsideVBorder->moLineWidth = 12700; + + pWholeTblLeftBorder->moPresetDash = XML_solid; + pWholeTblRightBorder->moPresetDash = XML_solid; + pWholeTblTopBorder->moPresetDash = XML_solid; + pWholeTblBottomBorder->moPresetDash = XML_solid; + pWholeTblInsideHBorder->moPresetDash = XML_solid; + pWholeTblInsideVBorder->moPresetDash = XML_solid; + + // Start to handle all style groups. + + OUString style_name = mStyleIdMap[styleId].first; + OUString accent_name = mStyleIdMap[styleId].second; + sal_Int32 accent_val = tokens[mStyleIdMap[styleId].second]; + + if (style_name == "Themed-Style-1") + { + if (!accent_name.isEmpty()) + { + accent_val = tokens[mStyleIdMap[styleId].second]; + + wholeTblTextColor.setSchemeClr(XML_dk1); + firstRowTextColor.setSchemeClr(XML_lt1); + + pWholeTblLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblInsideHBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblInsideVBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pFirstRowLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pFirstRowRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pFirstRowTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pFirstRowBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pFirstRowFillProperties->maFillColor.setSchemeClr(accent_val); + + pLastRowLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pLastRowRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pLastRowBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pFirstColLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pFirstColRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pFirstColTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pFirstColBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pFirstColInsideHBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pLastColLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pLastColRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pLastColTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pLastColBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pLastColInsideHBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pBand1HFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1VFillProperties->maFillColor.setSchemeClr(accent_val); + } + else + { + wholeTblTextColor.setSchemeClr(XML_tx1); + } + + pBand1HFillProperties->maFillColor.addTransformation(XML_alpha, 40000); + pBand1VFillProperties->maFillColor.addTransformation(XML_alpha, 40000); + } + else if (style_name == "Themed-Style-2") + { + wholeTblTextColor.setSchemeClr(XML_lt1); + firstRowTextColor.setSchemeClr(XML_lt1); + + if (!accent_name.isEmpty()) + { + accent_val = tokens[mStyleIdMap[styleId].second]; + + pTblBgFillProperties->maFillColor.setSchemeClr(accent_val); + pFirstRowBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pFirstColRightBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pLastColLeftBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pBand1HFillProperties->maFillColor.setSchemeClr(XML_lt1); + pBand1VFillProperties->maFillColor.setSchemeClr(XML_lt1); + } + else + { + accent_val = XML_tx1; + + pWholeTblInsideVBorder->maLineFill.maFillColor.setSchemeClr(XML_tx1); + pWholeTblInsideHBorder->maLineFill.maFillColor.setSchemeClr(XML_tx1); + } + + pWholeTblLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pBand1HFillProperties->maFillColor.addTransformation(XML_alpha, 20000); + pBand1VFillProperties->maFillColor.addTransformation(XML_alpha, 20000); + pWholeTblLeftBorder->maLineFill.maFillColor.addTransformation(XML_tint, 50000); + pWholeTblRightBorder->maLineFill.maFillColor.addTransformation(XML_tint, 50000); + pWholeTblTopBorder->maLineFill.maFillColor.addTransformation(XML_tint, 50000); + pWholeTblBottomBorder->maLineFill.maFillColor.addTransformation(XML_tint, 50000); + } + else if (style_name == "Light-Style-1") + { + wholeTblTextColor.setSchemeClr(XML_tx1); + + if (!accent_name.isEmpty()) + accent_val = tokens[mStyleIdMap[styleId].second]; + else + accent_val = XML_tx1; + + pWholeTblTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pFirstRowBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + firstRowTextColor.setSchemeClr(accent_val); + + pBand1HFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1VFillProperties->maFillColor.setSchemeClr(accent_val); + + pBand1HFillProperties->maFillColor.addTransformation(XML_alpha, 20000); + pBand1VFillProperties->maFillColor.addTransformation(XML_alpha, 20000); + } + else if (style_name == "Light-Style-2") + { + wholeTblTextColor.setSchemeClr(XML_tx1); + firstRowTextColor.setSchemeClr(XML_bg1); + + if (!accent_name.isEmpty()) + accent_val = tokens[mStyleIdMap[styleId].second]; + else + accent_val = XML_tx1; + + pWholeTblLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pFirstRowFillProperties->maFillColor.setSchemeClr(accent_val); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pBand1HTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pBand1HBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pBand1VLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pBand1VRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pBand2VLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pBand2VRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + } + else if (style_name == "Light-Style-3") + { + wholeTblTextColor.setSchemeClr(XML_tx1); + + if (!accent_name.isEmpty()) + accent_val = tokens[mStyleIdMap[styleId].second]; + else + accent_val = XML_tx1; + + pWholeTblLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblInsideHBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblInsideVBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + firstRowTextColor.setSchemeClr(accent_val); + pFirstRowBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pBand1HFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1VFillProperties->maFillColor.setSchemeClr(accent_val); + + pBand1HFillProperties->maFillColor.addTransformation(XML_alpha, 20000); + pBand1VFillProperties->maFillColor.addTransformation(XML_alpha, 20000); + } + else if (style_name == "Medium-Style-1") + { + wholeTblTextColor.setSchemeClr(XML_dk1); + firstRowTextColor.setSchemeClr(XML_lt1); + pWholeTblFillProperties->maFillColor.setSchemeClr(XML_lt1); + pLastRowFillProperties->maFillColor.setSchemeClr(XML_lt1); + + if (!accent_name.isEmpty()) + accent_val = tokens[mStyleIdMap[styleId].second]; + else + accent_val = XML_dk1; + + pWholeTblLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblInsideHBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pFirstRowFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1HFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1VFillProperties->maFillColor.setSchemeClr(accent_val); + + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + + pBand1HFillProperties->maFillColor.addTransformation(XML_tint, 20000); + pBand1VFillProperties->maFillColor.addTransformation(XML_tint, 20000); + } + else if (style_name == "Medium-Style-2") + { + wholeTblTextColor.setSchemeClr(XML_dk1); + firstRowTextColor.setSchemeClr(XML_lt1); + lastRowTextColor.setSchemeClr(XML_lt1); + firstColTextColor.setSchemeClr(XML_lt1); + lastColTextColor.setSchemeClr(XML_lt1); + pFirstRowBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + + pWholeTblLeftBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pWholeTblRightBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pWholeTblTopBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pWholeTblBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pWholeTblInsideHBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pWholeTblInsideVBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + + if (!accent_name.isEmpty()) + accent_val = tokens[mStyleIdMap[styleId].second]; + else + accent_val = XML_dk1; + + pWholeTblFillProperties->maFillColor.setSchemeClr(accent_val); + pFirstRowFillProperties->maFillColor.setSchemeClr(accent_val); + pLastRowFillProperties->maFillColor.setSchemeClr(accent_val); + pFirstColFillProperties->maFillColor.setSchemeClr(accent_val); + pLastColFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1HFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1VFillProperties->maFillColor.setSchemeClr(accent_val); + + pWholeTblFillProperties->maFillColor.addTransformation(XML_tint, 20000); + pBand1HFillProperties->maFillColor.addTransformation(XML_tint, 40000); + pBand1VFillProperties->maFillColor.addTransformation(XML_tint, 40000); + } + else if (style_name == "Medium-Style-3") + { + wholeTblTextColor.setSchemeClr(XML_dk1); + firstColTextColor.setSchemeClr(XML_lt1); + lastColTextColor.setSchemeClr(XML_lt1); + pWholeTblTopBorder->maLineFill.maFillColor.setSchemeClr(XML_dk1); + pWholeTblBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_dk1); + pWholeTblFillProperties->maFillColor.setSchemeClr(XML_lt1); + pLastRowFillProperties->maFillColor.setSchemeClr(XML_lt1); + pBand1HFillProperties->maFillColor.setSchemeClr(XML_dk1); + pBand1VFillProperties->maFillColor.setSchemeClr(XML_dk1); + + firstRowTextColor.setSchemeClr(XML_lt1); + pFirstRowBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_dk1); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(XML_dk1); + + if (!accent_name.isEmpty()) + accent_val = tokens[mStyleIdMap[styleId].second]; + else + accent_val = XML_dk1; + + pFirstRowFillProperties->maFillColor.setSchemeClr(accent_val); + pFirstColFillProperties->maFillColor.setSchemeClr(accent_val); + pLastColFillProperties->maFillColor.setSchemeClr(accent_val); + + pBand1HFillProperties->maFillColor.addTransformation(XML_tint, 20000); + pBand1VFillProperties->maFillColor.addTransformation(XML_tint, 20000); + } + else if (style_name == "Medium-Style-4") + { + wholeTblTextColor.setSchemeClr(XML_dk1); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(XML_dk1); + pLastRowFillProperties->maFillColor.setSchemeClr(XML_dk1); + + if (!accent_name.isEmpty()) + accent_val = tokens[mStyleIdMap[styleId].second]; + else + accent_val = XML_dk1; + + pWholeTblLeftBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblRightBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblInsideHBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblInsideVBorder->maLineFill.maFillColor.setSchemeClr(accent_val); + pWholeTblFillProperties->maFillColor.setSchemeClr(accent_val); + + firstRowTextColor.setSchemeClr(accent_val); + pFirstRowFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1HFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1VFillProperties->maFillColor.setSchemeClr(accent_val); + + pFirstRowFillProperties->maFillColor.addTransformation(XML_tint, 20000); + pLastRowFillProperties->maFillColor.addTransformation(XML_tint, 20000); + pWholeTblFillProperties->maFillColor.addTransformation(XML_tint, 20000); + pBand1HFillProperties->maFillColor.addTransformation(XML_tint, 40000); + pBand1VFillProperties->maFillColor.addTransformation(XML_tint, 40000); + } + else if (style_name == "Dark-Style-1") + { + sal_Int32 transform_val; + wholeTblTextColor.setSchemeClr(XML_dk1); + firstRowTextColor.setSchemeClr(XML_lt1); + pFirstRowBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pFirstColRightBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pLastColLeftBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + pFirstRowFillProperties->maFillColor.setSchemeClr(XML_dk1); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); + + if (!accent_name.isEmpty()) + { + accent_val = tokens[mStyleIdMap[styleId].second]; + transform_val = XML_shade; + } + else + { + accent_val = XML_dk1; + transform_val = XML_tint; + } + + pWholeTblFillProperties->maFillColor.setSchemeClr(accent_val); + pLastRowFillProperties->maFillColor.setSchemeClr(accent_val); + pFirstColFillProperties->maFillColor.setSchemeClr(accent_val); + pLastColFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1HFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1VFillProperties->maFillColor.setSchemeClr(accent_val); + + pWholeTblFillProperties->maFillColor.addTransformation(transform_val, 20000); + pBand1HFillProperties->maFillColor.addTransformation(transform_val, 40000); + pBand1VFillProperties->maFillColor.addTransformation(transform_val, 40000); + pLastColFillProperties->maFillColor.addTransformation(transform_val, 60000); + pFirstColFillProperties->maFillColor.addTransformation(transform_val, 60000); + } + else if (style_name == "Dark-Style-2") + { + wholeTblTextColor.setSchemeClr(XML_dk1); + firstRowTextColor.setSchemeClr(XML_lt1); + + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(XML_dk1); + + if (accent_name.isEmpty()) + pFirstRowFillProperties->maFillColor.setSchemeClr(XML_dk1); + else if (accent_name == "Accent1") + pFirstRowFillProperties->maFillColor.setSchemeClr(XML_accent2); + else if (accent_name == "Accent3") + pFirstRowFillProperties->maFillColor.setSchemeClr(XML_accent4); + else if (accent_name == "Accent5") + pFirstRowFillProperties->maFillColor.setSchemeClr(XML_accent6); + + if (!accent_name.isEmpty()) + accent_val = tokens[mStyleIdMap[styleId].second]; + else + accent_val = XML_dk1; + + pWholeTblFillProperties->maFillColor.setSchemeClr(accent_val); + pLastRowFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1HFillProperties->maFillColor.setSchemeClr(accent_val); + pBand1VFillProperties->maFillColor.setSchemeClr(accent_val); + + pWholeTblFillProperties->maFillColor.addTransformation(XML_tint, 20000); + pBand1HFillProperties->maFillColor.addTransformation(XML_tint, 40000); + pBand1VFillProperties->maFillColor.addTransformation(XML_tint, 40000); + pLastRowFillProperties->maFillColor.addTransformation(XML_tint, 20000); + } + + // End to handle all style groups. + + // Create a TableStyle from handled properties. + + pTableStyle->getWholeTbl().getTextColor() = wholeTblTextColor; + pTableStyle->getFirstRow().getTextColor() = firstRowTextColor; + pTableStyle->getFirstCol().getTextColor() = firstColTextColor; + pTableStyle->getLastRow().getTextColor() = lastRowTextColor; + pTableStyle->getLastCol().getTextColor() = lastColTextColor; + pTableStyle->getBand1H().getTextColor() = band1HTextColor; + pTableStyle->getBand1V().getTextColor() = band1VTextColor; + pTableStyle->getBand2H().getTextColor() = band2HTextColor; + pTableStyle->getBand2V().getTextColor() = band2VTextColor; + + pTableStyle->getBackgroundFillProperties() = pTblBgFillProperties; + pTableStyle->getWholeTbl().getFillProperties() = pWholeTblFillProperties; + pTableStyle->getFirstRow().getFillProperties() = pFirstRowFillProperties; + pTableStyle->getFirstCol().getFillProperties() = pFirstColFillProperties; + pTableStyle->getLastRow().getFillProperties() = pLastRowFillProperties; + pTableStyle->getLastCol().getFillProperties() = pLastColFillProperties; + pTableStyle->getBand1H().getFillProperties() = pBand1HFillProperties; + pTableStyle->getBand1V().getFillProperties() = pBand1VFillProperties; + pTableStyle->getBand2H().getFillProperties() = pBand2HFillProperties; + pTableStyle->getBand2V().getFillProperties() = pBand2VFillProperties; + + pTableStyle->getWholeTbl().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left, pWholeTblLeftBorder)); + pTableStyle->getWholeTbl().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right, pWholeTblRightBorder)); + pTableStyle->getWholeTbl().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top, pWholeTblTopBorder)); + pTableStyle->getWholeTbl().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom, + pWholeTblBottomBorder)); + pTableStyle->getWholeTbl().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH, + pWholeTblInsideHBorder)); + pTableStyle->getWholeTbl().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV, + pWholeTblInsideVBorder)); + + pTableStyle->getFirstRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left, pFirstRowLeftBorder)); + pTableStyle->getFirstRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right, pFirstRowRightBorder)); + pTableStyle->getFirstRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top, pFirstRowTopBorder)); + pTableStyle->getFirstRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom, + pFirstRowBottomBorder)); + pTableStyle->getFirstRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH, + pFirstRowInsideHBorder)); + pTableStyle->getFirstRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV, + pFirstRowInsideVBorder)); + + pTableStyle->getFirstCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left, pFirstColLeftBorder)); + pTableStyle->getFirstCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right, pFirstColRightBorder)); + pTableStyle->getFirstCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top, pFirstColTopBorder)); + pTableStyle->getFirstCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom, + pFirstColBottomBorder)); + pTableStyle->getFirstCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH, + pFirstColInsideHBorder)); + pTableStyle->getFirstCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV, + pFirstColInsideVBorder)); + + pTableStyle->getLastRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left, pLastRowLeftBorder)); + pTableStyle->getLastRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right, pLastRowRightBorder)); + pTableStyle->getLastRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top, pLastRowTopBorder)); + pTableStyle->getLastRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom, + pLastRowBottomBorder)); + pTableStyle->getLastRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH, + pLastRowInsideHBorder)); + pTableStyle->getLastRow().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV, + pLastRowInsideVBorder)); + + pTableStyle->getLastCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left, pLastColLeftBorder)); + pTableStyle->getLastCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right, pLastColRightBorder)); + pTableStyle->getLastCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top, pLastColTopBorder)); + pTableStyle->getLastCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom, + pLastColBottomBorder)); + pTableStyle->getLastCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH, + pLastColInsideHBorder)); + pTableStyle->getLastCol().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV, + pLastColInsideVBorder)); + + pTableStyle->getBand1H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left, pBand1HLeftBorder)); + pTableStyle->getBand1H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right, pBand1HRightBorder)); + pTableStyle->getBand1H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top, pBand1HTopBorder)); + pTableStyle->getBand1H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom, pBand1HBottomBorder)); + pTableStyle->getBand1H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH, + pBand1HInsideHBorder)); + pTableStyle->getBand1H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV, + pBand1HInsideVBorder)); + + pTableStyle->getBand1V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left, pBand1VLeftBorder)); + pTableStyle->getBand1V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right, pBand1VRightBorder)); + pTableStyle->getBand1V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top, pBand1VTopBorder)); + pTableStyle->getBand1V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom, pBand1VBottomBorder)); + pTableStyle->getBand1V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH, + pBand1VInsideHBorder)); + pTableStyle->getBand1V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV, + pBand1VInsideVBorder)); + + pTableStyle->getBand2H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left, pBand2HLeftBorder)); + pTableStyle->getBand2H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right, pBand2HRightBorder)); + pTableStyle->getBand2H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top, pBand2HTopBorder)); + pTableStyle->getBand2H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom, pBand2HBottomBorder)); + pTableStyle->getBand2H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH, + pBand2HInsideHBorder)); + pTableStyle->getBand2H().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV, + pBand2HInsideVBorder)); + + pTableStyle->getBand2V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left, pBand2VLeftBorder)); + pTableStyle->getBand2V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right, pBand2VRightBorder)); + pTableStyle->getBand2V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top, pBand2VTopBorder)); + pTableStyle->getBand2V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom, pBand2VBottomBorder)); + pTableStyle->getBand2V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH, + pBand2VInsideHBorder)); + pTableStyle->getBand2V().getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV, + pBand2VInsideVBorder)); + + return pTableStyle; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablebackgroundstylecontext.cxx b/oox/source/drawingml/table/tablebackgroundstylecontext.cxx new file mode 100644 index 000000000..ee48a8358 --- /dev/null +++ b/oox/source/drawingml/table/tablebackgroundstylecontext.cxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <drawingml/table/tablebackgroundstylecontext.hxx> +#include <drawingml/misccontexts.hxx> +#include <oox/helper/attributelist.hxx> +#include <oox/token/namespaces.hxx> +#include <oox/token/tokens.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::drawingml::table { + +TableBackgroundStyleContext::TableBackgroundStyleContext( ContextHandler2Helper const & rParent, TableStyle& rTableStyle ) +: ContextHandler2( rParent ) +, mrTableStyle( rTableStyle ) +{ +} + +TableBackgroundStyleContext::~TableBackgroundStyleContext() +{ +} + +ContextHandlerRef +TableBackgroundStyleContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + // EG_ThemeableFillStyle (choice) + case A_TOKEN( fill ): // CT_FillProperties + { + std::shared_ptr< FillProperties >& rxFillProperties = mrTableStyle.getBackgroundFillProperties(); + rxFillProperties = std::make_shared<FillProperties>(); + return new FillPropertiesContext( *this, *rxFillProperties ); + } + case A_TOKEN( fillRef ): // CT_StyleMatrixReference + { + ShapeStyleRef& rStyleRef = mrTableStyle.getBackgroundFillStyleRef(); + rStyleRef.mnThemedIdx = rAttribs.getInteger( XML_idx, 0 ); + return new ColorContext( *this, rStyleRef.maPhClr ); + } + // EG_ThemeableEffectStyle (choice) + case A_TOKEN( effect ): // CT_EffectProperties + break; + case A_TOKEN( effectRef ): // CT_StyleMatrixReference + break; + } + + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx new file mode 100644 index 000000000..e5ab3372d --- /dev/null +++ b/oox/source/drawingml/table/tablecell.cxx @@ -0,0 +1,473 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <drawingml/table/tablecell.hxx> +#include <drawingml/table/tableproperties.hxx> +#include <basegfx/color/bcolor.hxx> +#include <oox/drawingml/shapepropertymap.hxx> +#include <drawingml/textbody.hxx> +#include <oox/drawingml/theme.hxx> +#include <oox/core/xmlfilterbase.hxx> +#include <oox/helper/propertyset.hxx> +#include <oox/token/properties.hxx> +#include <oox/token/tokens.hxx> +#include <tools/color.hxx> +#include <com/sun/star/table/BorderLineStyle.hpp> +#include <com/sun/star/table/BorderLine2.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/text/WritingMode.hpp> + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using ::com::sun::star::table::BorderLine2; + +namespace oox::drawingml::table { + +TableCell::TableCell() +: mpTextBody( std::make_shared<TextBody>() ) +, mnRowSpan ( 1 ) +, mnGridSpan( 1 ) +, mbhMerge( false ) +, mbvMerge( false ) +, mnMarL( 91440 ) +, mnMarR( 91440 ) +, mnMarT( 45720 ) +, mnMarB( 45720 ) +, mnVertToken( XML_horz ) +, mnAnchorToken( XML_t ) +, mbAnchorCtr( false ) +, mnHorzOverflowToken( XML_clip ) +{ +} + +static void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase, + Reference< XPropertySet > const & rxPropSet, oox::drawingml::LineProperties const & rLineProperties, + sal_Int32 nPropId ) +{ + BorderLine2 aBorderLine; + if ( rLineProperties.maLineFill.moFillType.differsFrom( XML_noFill )) + { + Color aColor = rLineProperties.maLineFill.getBestSolidColor(); + aBorderLine.Color = sal_Int32(aColor.getColor( rFilterBase.getGraphicHelper() )); + aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); + aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); + aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 2 ); + aBorderLine.LineDistance = 0; + } + else if ( rLineProperties.moLineWidth.get(0)!=0 ) + { + aBorderLine.Color = sal_Int32( COL_AUTO ); + aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); + aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); + aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 2 ); + aBorderLine.LineDistance = 0; + } + + if ( rLineProperties.moPresetDash.has() ) + { + switch ( rLineProperties.moPresetDash.get() ) + { + case XML_dot: + case XML_sysDot: + aBorderLine.LineStyle = ::table::BorderLineStyle::DOTTED; + break; + case XML_dash: + case XML_lgDash: + case XML_sysDash: + aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED; + break; + case XML_dashDot: + case XML_lgDashDot: + case XML_sysDashDot: + aBorderLine.LineStyle = ::table::BorderLineStyle::DASH_DOT; + break; + case XML_lgDashDotDot: + case XML_sysDashDotDot: + aBorderLine.LineStyle = ::table::BorderLineStyle::DASH_DOT_DOT; + break; + case XML_solid: + aBorderLine.LineStyle = ::table::BorderLineStyle::SOLID; + break; + default: + aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED; + break; + } + } + else if ( !rLineProperties.maCustomDash.empty() ) + { + aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED; + } + else + { + aBorderLine.LineStyle = ::table::BorderLineStyle::NONE; + } + + PropertySet aPropSet( rxPropSet ); + aPropSet.setProperty( nPropId, aBorderLine ); +} + +static void applyBorder( const ::oox::core::XmlFilterBase& rFilterBase, TableStylePart& rTableStylePart, sal_Int32 nLineType, oox::drawingml::LineProperties& rLineProperties ) +{ + std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >& rPartLineBorders( rTableStylePart.getLineBorders() ); + ::oox::drawingml::ShapeStyleRef& rLineStyleRef = rTableStylePart.getStyleRefs()[ nLineType ]; + std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >::const_iterator aIter( rPartLineBorders.find( nLineType ) ); + if ( ( aIter != rPartLineBorders.end() ) && aIter->second ) + rLineProperties.assignUsed( *aIter->second ); + else if (rLineStyleRef.mnThemedIdx != 0) + { + if (const Theme* pTheme = rFilterBase.getCurrentTheme()) + { + rLineProperties.assignUsed( *pTheme->getLineStyle(rLineStyleRef.mnThemedIdx) ); + ::Color nPhClr = rLineStyleRef.maPhClr.getColor( rFilterBase.getGraphicHelper() ); + rLineProperties.maLineFill.maFillColor.setSrgbClr( nPhClr ); + } + } +} + +static void applyTableStylePart( const ::oox::core::XmlFilterBase& rFilterBase, + oox::drawingml::FillProperties& rFillProperties, + TextCharacterProperties& aTextCharProps, + oox::drawingml::LineProperties& rLeftBorder, + oox::drawingml::LineProperties& rRightBorder, + oox::drawingml::LineProperties& rTopBorder, + oox::drawingml::LineProperties& rBottomBorder, + oox::drawingml::LineProperties& rTopLeftToBottomRightBorder, + oox::drawingml::LineProperties& rBottomLeftToTopRightBorder, + TableStylePart& rTableStylePart ) +{ + ::oox::drawingml::FillPropertiesPtr& rPartFillPropertiesPtr( rTableStylePart.getFillProperties() ); + if ( rPartFillPropertiesPtr ) + rFillProperties.assignUsed( *rPartFillPropertiesPtr ); + else + { + ::oox::drawingml::ShapeStyleRef& rFillStyleRef = rTableStylePart.getStyleRefs()[ XML_fillRef ]; + const Theme* pTheme = rFilterBase.getCurrentTheme(); + if (pTheme && rFillStyleRef.mnThemedIdx != 0 ) + { + rFillProperties.assignUsed( *pTheme->getFillStyle( rFillStyleRef.mnThemedIdx ) ); + ::Color nPhClr = rFillStyleRef.maPhClr.getColor( rFilterBase.getGraphicHelper() ); + rFillProperties.maFillColor.setSrgbClr( nPhClr ); + } + } + + applyBorder( rFilterBase, rTableStylePart, XML_left, rLeftBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_right, rRightBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_top, rTopBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_bottom, rBottomBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_tl2br, rTopLeftToBottomRightBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_tr2bl, rBottomLeftToTopRightBorder ); + + aTextCharProps.maLatinFont = rTableStylePart.getLatinFont(); + aTextCharProps.maAsianFont = rTableStylePart.getAsianFont(); + aTextCharProps.maComplexFont = rTableStylePart.getComplexFont(); + aTextCharProps.maSymbolFont = rTableStylePart.getSymbolFont(); + if ( rTableStylePart.getTextColor().isUsed() ) + { + aTextCharProps.maFillProperties.maFillColor = rTableStylePart.getTextColor(); + aTextCharProps.maFillProperties.moFillType.set(XML_solidFill); + } + if( rTableStylePart.getTextBoldStyle() ) + aTextCharProps.moBold = *rTableStylePart.getTextBoldStyle(); + if( rTableStylePart.getTextItalicStyle() ) + aTextCharProps.moItalic = *rTableStylePart.getTextItalicStyle(); +} + +static void applyTableCellProperties( const Reference < css::table::XCell >& rxCell, const TableCell& rTableCell ) +{ + Reference< XPropertySet > xPropSet( rxCell, UNO_QUERY_THROW ); + xPropSet->setPropertyValue( "TextUpperDistance", Any( static_cast< sal_Int32 >( rTableCell.getTopMargin() / 360 ) ) ); + xPropSet->setPropertyValue( "TextRightDistance", Any( static_cast< sal_Int32 >( rTableCell.getRightMargin() / 360 ) ) ); + xPropSet->setPropertyValue( "TextLeftDistance", Any( static_cast< sal_Int32 >( rTableCell.getLeftMargin() / 360 ) ) ); + xPropSet->setPropertyValue( "TextLowerDistance", Any( static_cast< sal_Int32 >( rTableCell.getBottomMargin() / 360 ) ) ); + + drawing::TextVerticalAdjust eVA; + switch( rTableCell.getAnchorToken() ) + { + case XML_ctr: eVA = drawing::TextVerticalAdjust_CENTER; break; + case XML_b: eVA = drawing::TextVerticalAdjust_BOTTOM; break; + case XML_just: + case XML_dist: + default: + case XML_t: eVA = drawing::TextVerticalAdjust_TOP; break; + } + xPropSet->setPropertyValue( "TextVerticalAdjust", Any( eVA ) ); +} + +void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, const ::oox::drawingml::TextListStylePtr& pMasterTextListStyle, + const css::uno::Reference < css::table::XCell >& rxCell, const TableProperties& rTableProperties, + const TableStyle& rTableStyle, sal_Int32 nColumn, sal_Int32 nMaxColumn, sal_Int32 nRow, sal_Int32 nMaxRow ) +{ + TableStyle& rTable( const_cast< TableStyle& >( rTableStyle ) ); + TableProperties& rProperties( const_cast< TableProperties& >( rTableProperties ) ); + + Reference< text::XText > xText( rxCell, UNO_QUERY_THROW ); + Reference< text::XTextCursor > xAt = xText->createTextCursor(); + + applyTableCellProperties( rxCell, *this ); + TextCharacterProperties aTextStyleProps; + xAt->gotoStart( true ); + xAt->gotoEnd( true ); + + Reference< XPropertySet > xPropSet( rxCell, UNO_QUERY_THROW ); + oox::drawingml::FillProperties aFillProperties; + oox::drawingml::LineProperties aLinePropertiesLeft; + oox::drawingml::LineProperties aLinePropertiesRight; + oox::drawingml::LineProperties aLinePropertiesTop; + oox::drawingml::LineProperties aLinePropertiesBottom; + oox::drawingml::LineProperties aLinePropertiesTopLeftToBottomRight; + oox::drawingml::LineProperties aLinePropertiesBottomLeftToTopRight; + + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getWholeTbl() ); + + if ( rProperties.isFirstRow() && ( nRow == 0 ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getFirstRow() ); + } + if ( rProperties.isLastRow() && ( nRow == nMaxRow ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getLastRow() ); + } + if ( rProperties.isFirstCol() && ( nColumn == 0 ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getFirstCol() ); + } + if ( rProperties.isLastCol() && ( nColumn == nMaxColumn ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getLastCol() ); + } + if ( rProperties.isBandRow() ) + { + if ( ( !rProperties.isFirstRow() || ( nRow != 0 ) ) && + ( !rProperties.isLastRow() || ( nRow != nMaxRow ) ) && + ( !rProperties.isFirstCol() || ( nColumn != 0 ) ) && + ( !rProperties.isLastCol() || ( nColumn != nMaxColumn ) ) ) + { + sal_Int32 nBand = nRow; + if ( rProperties.isFirstRow() ) + nBand++; + if ( nBand & 1 ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getBand2H() ); + } + else + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getBand1H() ); + } + } + } + if ( ( nRow == 0 ) && ( nColumn == 0 ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getNwCell() ); + } + if ( ( nRow == nMaxRow ) && ( nColumn == 0 ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getSwCell() ); + } + if ( ( nRow == 0 ) && ( nColumn == nMaxColumn ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getNeCell() ); + } + if ( ( nRow == nMaxRow ) && ( nColumn == nMaxColumn ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getSeCell() ); + } + if ( rProperties.isBandCol() ) + { + if ( ( !rProperties.isFirstRow() || ( nRow != 0 ) ) && + ( !rProperties.isLastRow() || ( nRow != nMaxRow ) ) && + ( !rProperties.isFirstCol() || ( nColumn != 0 ) ) && + ( !rProperties.isLastCol() || ( nColumn != nMaxColumn ) ) ) + { + sal_Int32 nBand = nColumn; + if ( rProperties.isFirstCol() ) + nBand++; + if ( nBand & 1 ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getBand2V() ); + } + else + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getBand1V() ); + } + } + } + aLinePropertiesLeft.assignUsed( maLinePropertiesLeft ); + aLinePropertiesRight.assignUsed( maLinePropertiesRight ); + aLinePropertiesTop.assignUsed( maLinePropertiesTop ); + aLinePropertiesBottom.assignUsed( maLinePropertiesBottom ); + aLinePropertiesTopLeftToBottomRight.assignUsed( maLinePropertiesTopLeftToBottomRight ); + aLinePropertiesBottomLeftToTopRight.assignUsed( maLinePropertiesBottomLeftToTopRight ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesLeft, PROP_LeftBorder ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesRight, PROP_RightBorder ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesTop, PROP_TopBorder ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottom, PROP_BottomBorder ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesTopLeftToBottomRight, PROP_DiagonalTLBR ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottomLeftToTopRight, PROP_DiagonalBLTR ); + + if (rProperties.getBgColor().isUsed() && !maFillProperties.maFillColor.isUsed() && maFillProperties.moFillType.get() == XML_noFill) + { + maFillProperties.moFillType = XML_solidFill; + maFillProperties.maFillColor = rProperties.getBgColor(); + } + + aFillProperties.assignUsed( maFillProperties ); + ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() ); + + Color aBgColor; + ::Color nPhClr = API_RGB_TRANSPARENT; + std::shared_ptr< ::oox::drawingml::FillProperties >& rBackgroundFillPropertiesPtr( rTable.getBackgroundFillProperties() ); + ::oox::drawingml::ShapeStyleRef& rBackgroundFillStyle( rTable.getBackgroundFillStyleRef() ); + if (rBackgroundFillPropertiesPtr) + aBgColor = rBackgroundFillPropertiesPtr->getBestSolidColor(); + else if (rBackgroundFillStyle.mnThemedIdx != 0) + { + if (const Theme* pTheme = rFilterBase.getCurrentTheme()) + { + aBgColor = pTheme->getFillStyle(rBackgroundFillStyle.mnThemedIdx)->getBestSolidColor(); + nPhClr = rBackgroundFillStyle.maPhClr.getColor(rFilterBase.getGraphicHelper()); + } + } + if (aBgColor.isUsed()) + { + const Color& rCellColor = aFillProperties.getBestSolidColor(); + const double fTransparency = rCellColor.isUsed() ? 0.01 * rCellColor.getTransparency() : 1.0; + ::Color nBgColor( aBgColor.getColor(rFilterBase.getGraphicHelper(), nPhClr) ); + ::Color nCellColor( rCellColor.getColor(rFilterBase.getGraphicHelper()) ); + ::Color aResult( basegfx::interpolate(nBgColor.getBColor(), nCellColor.getBColor(), 1.0 - fTransparency) ); + aFillProperties.maFillColor.clearTransformations(); + aFillProperties.maFillColor.setSrgbClr(sal_Int32(aResult.GetRGBColor())); + aFillProperties.moFillType.set(XML_solidFill); + } + if (!aFillProperties.moFillType.has()) + aFillProperties.moFillType.set(XML_noFill); + + // TODO: phClr? + aFillProperties.pushToPropMap( aPropMap, rFilterBase.getGraphicHelper() ); + PropertySet( xPropSet ).setProperties( aPropMap ); + + if ( getVertToken() == XML_eaVert ) + { + xPropSet->setPropertyValue("TextWritingMode", Any(css::text::WritingMode_TB_RL)); + } + + getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, pMasterTextListStyle ); + + if (getVertToken() == XML_vert) + xPropSet->setPropertyValue("RotateAngle", Any(short(27000))); + else if (getVertToken() == XML_vert270) + xPropSet->setPropertyValue("RotateAngle", Any(short(9000))); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablecellcontext.cxx b/oox/source/drawingml/table/tablecellcontext.cxx new file mode 100644 index 000000000..dde824fb7 --- /dev/null +++ b/oox/source/drawingml/table/tablecellcontext.cxx @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <drawingml/table/tablecellcontext.hxx> +#include <drawingml/textbodycontext.hxx> +#include <drawingml/linepropertiescontext.hxx> +#include <drawingml/misccontexts.hxx> +#include <oox/helper/attributelist.hxx> +#include <oox/token/namespaces.hxx> +#include <oox/token/tokens.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; + +namespace oox::drawingml::table { + +TableCellContext::TableCellContext( ContextHandler2Helper const & rParent, const AttributeList& rAttribs, TableCell& rTableCell ) +: ContextHandler2( rParent ) +, mrTableCell( rTableCell ) +{ + if ( rAttribs.hasAttribute( XML_rowSpan ) ) + mrTableCell.setRowSpan( rAttribs.getString( XML_rowSpan ).get().toInt32() ); + if ( rAttribs.hasAttribute( XML_gridSpan ) ) + mrTableCell.setGridSpan( rAttribs.getString( XML_gridSpan ).get().toInt32() ); + + mrTableCell.sethMerge( rAttribs.getBool( XML_hMerge, false ) ); + mrTableCell.setvMerge( rAttribs.getBool( XML_vMerge, false ) ); +} + +TableCellContext::~TableCellContext() +{ +} + +ContextHandlerRef +TableCellContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case A_TOKEN( txBody ): // CT_TextBody + { + oox::drawingml::TextBodyPtr xTextBody = std::make_shared<oox::drawingml::TextBody>(); + mrTableCell.setTextBody( xTextBody ); + return new oox::drawingml::TextBodyContext( *this, *xTextBody ); + } + + case A_TOKEN( tcPr ): // CT_TableCellProperties + { + mrTableCell.setLeftMargin( rAttribs.getInteger( XML_marL, 91440 ) ); + mrTableCell.setRightMargin( rAttribs.getInteger( XML_marR, 91440 ) ); + mrTableCell.setTopMargin( rAttribs.getInteger( XML_marT, 45720 ) ); + mrTableCell.setBottomMargin( rAttribs.getInteger( XML_marB, 45720 ) ); + mrTableCell.setVertToken( rAttribs.getToken( XML_vert, XML_horz ) ); // ST_TextVerticalType + mrTableCell.setAnchorToken( rAttribs.getToken( XML_anchor, XML_t ) ); // ST_TextAnchoringType + mrTableCell.setAnchorCtr( rAttribs.getBool( XML_anchorCtr, false ) ); + mrTableCell.setHorzOverflowToken( rAttribs.getToken( XML_horzOverflow, XML_clip ) ); // ST_TextHorzOverflowType + } + break; + case A_TOKEN( lnL ): + return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesLeft ); + case A_TOKEN( lnR ): + return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesRight ); + case A_TOKEN( lnT ): + return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesTop ); + case A_TOKEN( lnB ): + return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesBottom ); + case A_TOKEN( lnTlToBr ): + return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesTopLeftToBottomRight ); + case A_TOKEN( lnBlToTr ): + return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesBottomLeftToTopRight ); + case A_TOKEN( cell3D ): // CT_Cell3D + break; + + case A_TOKEN( extLst ): // CT_OfficeArtExtensionList + break; + + default: + return FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs, mrTableCell.maFillProperties ); + + } + + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablecontext.cxx b/oox/source/drawingml/table/tablecontext.cxx new file mode 100644 index 000000000..bbfc94845 --- /dev/null +++ b/oox/source/drawingml/table/tablecontext.cxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <oox/helper/attributelist.hxx> +#include <drawingml/colorchoicecontext.hxx> +#include <drawingml/guidcontext.hxx> +#include <drawingml/table/tablecontext.hxx> +#include <drawingml/table/tableproperties.hxx> +#include <drawingml/table/tablestylecontext.hxx> +#include <drawingml/table/tablerowcontext.hxx> +#include <oox/token/namespaces.hxx> +#include <oox/token/tokens.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; + +namespace oox::drawingml::table { + +TableContext::TableContext( ContextHandler2Helper const & rParent, const ShapePtr& pShapePtr ) +: ShapeContext( rParent, ShapePtr(), pShapePtr ) +, mrTableProperties( *pShapePtr->getTableProperties() ) +{ + pShapePtr->setTableType(); +} + +TableContext::~TableContext() +{ +} + +ContextHandlerRef +TableContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case A_TOKEN( tblPr ): // CT_TableProperties + { + mrTableProperties.setFirstRow( rAttribs.getBool( XML_firstRow, false ) ); + mrTableProperties.setFirstCol( rAttribs.getBool( XML_firstCol, false ) ); + mrTableProperties.setLastRow( rAttribs.getBool( XML_lastRow, false ) ); + mrTableProperties.setLastCol( rAttribs.getBool( XML_lastCol, false ) ); + mrTableProperties.setBandRow( rAttribs.getBool( XML_bandRow, false ) ); + mrTableProperties.setBandCol( rAttribs.getBool( XML_bandCol, false ) ); + } + break; + case A_TOKEN(solidFill): + return new ColorContext(*this, mrTableProperties.getBgColor()); + case A_TOKEN( tableStyle ): // CT_TableStyle + { + std::shared_ptr< TableStyle >& rTableStyle = mrTableProperties.getTableStyle(); + rTableStyle = std::make_shared<TableStyle>(); + return new TableStyleContext( *this, rAttribs, *rTableStyle ); + } + case A_TOKEN( tableStyleId ): // ST_Guid + return new oox::drawingml::GuidContext( *this, mrTableProperties.getStyleId() ); + + case A_TOKEN( tblGrid ): // CT_TableGrid + break; + case A_TOKEN( gridCol ): // CT_TableCol + { + std::vector< sal_Int32 >& rvTableGrid( mrTableProperties.getTableGrid() ); + rvTableGrid.push_back( rAttribs.getString( XML_w ).get().toInt32() ); + } + break; + case A_TOKEN( tr ): // CT_TableRow + { + std::vector< TableRow >& rvTableRows( mrTableProperties.getTableRows() ); + rvTableRows.emplace_back(); + return new TableRowContext( *this, rAttribs, rvTableRows.back() ); + } + } + + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablepartstylecontext.cxx b/oox/source/drawingml/table/tablepartstylecontext.cxx new file mode 100644 index 000000000..2d9717322 --- /dev/null +++ b/oox/source/drawingml/table/tablepartstylecontext.cxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <drawingml/table/tablepartstylecontext.hxx> +#include <drawingml/table/tablestyletextstylecontext.hxx> +#include <drawingml/table/tablestylecellstylecontext.hxx> +#include <oox/token/namespaces.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::drawingml::table { + +TablePartStyleContext::TablePartStyleContext( ContextHandler2Helper const & rParent, TableStylePart& rTableStylePart ) +: ContextHandler2( rParent ) +, mrTableStylePart( rTableStylePart ) +{ +} + +TablePartStyleContext::~TablePartStyleContext() +{ +} + +// CT_TablePartStyle +ContextHandlerRef +TablePartStyleContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case A_TOKEN( tcTxStyle ): // CT_TableStyleTextStyle + return new TableStyleTextStyleContext( *this, rAttribs, mrTableStylePart ); + case A_TOKEN( tcStyle ): // CT_TableStyleCellStyle + return new TableStyleCellStyleContext( *this, mrTableStylePart ); + } + + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx new file mode 100644 index 000000000..1c12c10ed --- /dev/null +++ b/oox/source/drawingml/table/tableproperties.cxx @@ -0,0 +1,270 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <drawingml/table/tableproperties.hxx> +#include <drawingml/table/tablestylelist.hxx> +#include <drawingml/textbody.hxx> +#include <drawingml/textparagraph.hxx> +#include <oox/drawingml/drawingmltypes.hxx> +#include <com/sun/star/table/XTable.hpp> +#include <com/sun/star/table/XMergeableCellRange.hpp> +#include <rtl/instance.hxx> +#include <oox/core/xmlfilterbase.hxx> +#include "predefined-table-styles.cxx" + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::table; + +namespace oox::drawingml::table { + +TableProperties::TableProperties() +: mbFirstRow( false ) +, mbFirstCol( false ) +, mbLastRow( false ) +, mbLastCol( false ) +, mbBandRow( false ) +, mbBandCol( false ) +{ + maBgColor.setUnused(); +} + +static void CreateTableRows( const uno::Reference< XTableRows >& xTableRows, const std::vector< TableRow >& rvTableRows ) +{ + if ( rvTableRows.size() > 1 ) + xTableRows->insertByIndex( 0, rvTableRows.size() - 1 ); + std::vector< TableRow >::const_iterator aTableRowIter( rvTableRows.begin() ); + uno::Reference< container::XIndexAccess > xIndexAccess( xTableRows, UNO_QUERY_THROW ); + sal_Int32 nCols = std::min<sal_Int32>(xIndexAccess->getCount(), rvTableRows.size()); + for (sal_Int32 n = 0; n < nCols; ++n) + { + Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW ); + xPropSet->setPropertyValue( "Height", Any( static_cast< sal_Int32 >( aTableRowIter->getHeight() / 360 ) ) ); + ++aTableRowIter; + } +} + +static void CreateTableColumns( const Reference< XTableColumns >& xTableColumns, const std::vector< sal_Int32 >& rvTableGrid ) +{ + if ( rvTableGrid.size() > 1 ) + xTableColumns->insertByIndex( 0, rvTableGrid.size() - 1 ); + std::vector< sal_Int32 >::const_iterator aTableGridIter( rvTableGrid.begin() ); + uno::Reference< container::XIndexAccess > xIndexAccess( xTableColumns, UNO_QUERY_THROW ); + sal_Int32 nCols = std::min<sal_Int32>(xIndexAccess->getCount(), rvTableGrid.size()); + for (sal_Int32 n = 0; n < nCols; ++n) + { + Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW ); + xPropSet->setPropertyValue( "Width", Any( static_cast< sal_Int32 >( *aTableGridIter++ / 360 ) ) ); + } +} + +static void MergeCells( const uno::Reference< XTable >& xTable, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan ) +{ + if( xTable.is() ) try + { + Reference< XMergeableCellRange > xRange( xTable->createCursorByRange( xTable->getCellRangeByPosition( nCol, nRow,nCol + nColSpan - 1, nRow + nRowSpan - 1 ) ), UNO_QUERY_THROW ); + if( xRange->isMergeable() ) + xRange->merge(); + } + catch( Exception& ) + { + } +} + +namespace +{ + struct theDefaultTableStyle : public ::rtl::Static< TableStyle, theDefaultTableStyle > {}; +} + +const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase, std::unique_ptr<TableStyle>& rTableStyleToDelete ) +{ + ::oox::core::XmlFilterBase& rBase( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ) ); + + TableStyle* pTableStyle = nullptr; + if ( mpTableStyle ) + pTableStyle = &*mpTableStyle; + else if ( !getStyleId().isEmpty() && rBase.getTableStyles() ) + { + const std::vector< TableStyle >& rTableStyles( rBase.getTableStyles()->getTableStyles() ); + const OUString aStyleId( getStyleId() ); + + for (auto const& tableStyle : rTableStyles) + { + if ( const_cast< TableStyle& >(tableStyle).getStyleId() == aStyleId ) + { + pTableStyle = &const_cast< TableStyle& >(tableStyle); + break; // we get the correct style + } + } + //if the pptx just has table style id, but no table style content, we will create the table style ourselves + if (!pTableStyle) + { + rTableStyleToDelete = CreateTableStyle(aStyleId); + pTableStyle = rTableStyleToDelete.get(); + } + } + + if ( !pTableStyle ) + return theDefaultTableStyle::get(); + + return *pTableStyle; +} + +void TableProperties::pushToPropSet(const ::oox::core::XmlFilterBase& rFilterBase, + const Reference<XPropertySet>& xPropSet, + const TextListStylePtr& pMasterTextListStyle) +{ + uno::Reference<XColumnRowRange> xColumnRowRange(xPropSet->getPropertyValue("Model"), + uno::UNO_QUERY_THROW); + + CreateTableColumns(xColumnRowRange->getColumns(), mvTableGrid); + CreateTableRows(xColumnRowRange->getRows(), mvTableRows); + + std::unique_ptr<TableStyle> xTableStyleToDelete; + const TableStyle& rTableStyle(getUsedTableStyle(rFilterBase, xTableStyleToDelete)); + sal_Int32 nRow = 0; + + for (auto& tableRow : mvTableRows) + { + sal_Int32 nColumn = 0; + sal_Int32 nColumnSize = mvTableGrid.size(); + sal_Int32 nRemovedColumn = 0; // + + for (sal_Int32 nColIndex = 0; nColIndex < nColumnSize; nColIndex++) + { + TableCell& rTableCell(tableRow.getTableCells().at(nColIndex)); + + if (!rTableCell.getvMerge() && !rTableCell.gethMerge()) + { + uno::Reference<XTable> xTable(xColumnRowRange, uno::UNO_QUERY_THROW); + bool bMerged = false; + + if ((rTableCell.getRowSpan() > 1) || (rTableCell.getGridSpan() > 1)) + { + MergeCells(xTable, nColumn, nRow, rTableCell.getGridSpan(), + rTableCell.getRowSpan()); + + if (rTableCell.getGridSpan() > 1) + { + nRemovedColumn = (rTableCell.getGridSpan() - 1); + // MergeCells removes columns. Our loop does not know about those + // removed columns and we skip handling those removed columns. + nColIndex += nRemovedColumn; + // It will adjust new column number after push current column's + // props with pushToXCell. + bMerged = true; + } + } + + Reference<XCellRange> xCellRange(xTable, UNO_QUERY_THROW); + Reference<XCell> xCell; + + if (nRemovedColumn) + { + try + { + xCell = xCellRange->getCellByPosition(nColumn, nRow); + } + // Exception can come from TableModel::getCellByPosition when a column + // is removed while merging columns. So adjust again here. + catch (Exception&) + { + xCell = xCellRange->getCellByPosition(nColumn - nRemovedColumn, nRow); + } + } + else + xCell = xCellRange->getCellByPosition(nColumn, nRow); + + rTableCell.pushToXCell(rFilterBase, pMasterTextListStyle, xCell, *this, rTableStyle, + nColumn, tableRow.getTableCells().size() - 1, nRow, + mvTableRows.size() - 1); + if (bMerged) + nColumn += nRemovedColumn; + } + ++nColumn; + } + ++nRow; + } + + xTableStyleToDelete.reset(); +} + +void TableProperties::pullFromTextBody(oox::drawingml::TextBodyPtr pTextBody, sal_Int32 nShapeWidth, bool bhasSameSubTypeIndex, bool bMaster) +{ + // Create table grid and a single row. + sal_Int32 nNumCol = pTextBody->getTextProperties().mnNumCol; + std::vector<sal_Int32>& rTableGrid(getTableGrid()); + std::vector<drawingml::table::TableRow>& rTableRows(getTableRows()); + sal_Int32 nColWidth = nShapeWidth / nNumCol; + + if(!bhasSameSubTypeIndex) + { + for (sal_Int32 nCol = 0; nCol < nNumCol; ++nCol) + rTableGrid.push_back(nColWidth); + + rTableRows.emplace_back(); + } + + if(rTableRows.empty()) + rTableRows.emplace_back(); + + oox::drawingml::table::TableRow& rTableRow = rTableRows.back(); + std::vector<oox::drawingml::table::TableCell>& rTableCells = rTableRow.getTableCells(); + + // Create the cells and distribute the paragraphs from pTextBody. + sal_Int32 nNumPara = pTextBody->getParagraphs().size(); + sal_Int32 nParaPerCol = std::ceil(double(nNumPara) / nNumCol); + // Font scale of text body will be applied at a text run level. + sal_Int32 nFontScale = pTextBody->getTextProperties().mnFontScale; + size_t nPara = 0; + for (sal_Int32 nCol = 0; nCol < nNumCol; ++nCol) + { + rTableCells.emplace_back(); + oox::drawingml::table::TableCell& rTableCell = rTableCells.at(nCol); + TextBodyPtr pCellTextBody = std::make_shared<TextBody>(); + rTableCell.setTextBody(pCellTextBody); + + // Copy properties provided by <a:lstStyle>. + pCellTextBody->getTextListStyle() = pTextBody->getTextListStyle(); + + if (bMaster) + continue; + + for (sal_Int32 nParaInCol = 0; nParaInCol < nParaPerCol; ++nParaInCol) + { + if (nPara < pTextBody->getParagraphs().size()) + { + std::shared_ptr<oox::drawingml::TextParagraph> pParagraph + = pTextBody->getParagraphs()[nPara]; + if (nFontScale != 100000) + { + for (auto& pRun : pParagraph->getRuns()) + pRun->getTextCharacterProperties().moFontScale = nFontScale; + } + pCellTextBody->appendParagraph(pParagraph); + } + ++nPara; + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablerow.cxx b/oox/source/drawingml/table/tablerow.cxx new file mode 100644 index 000000000..a45e9a7ac --- /dev/null +++ b/oox/source/drawingml/table/tablerow.cxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <drawingml/table/tablerow.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; + +namespace oox::drawingml::table { + +TableRow::TableRow() +: mnHeight( 0 ) +{ +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablerowcontext.cxx b/oox/source/drawingml/table/tablerowcontext.cxx new file mode 100644 index 000000000..aafd13b00 --- /dev/null +++ b/oox/source/drawingml/table/tablerowcontext.cxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <drawingml/table/tablerowcontext.hxx> +#include <drawingml/table/tablecellcontext.hxx> +#include <drawingml/table/tablerow.hxx> +#include <oox/helper/attributelist.hxx> +#include <oox/token/namespaces.hxx> +#include <oox/token/tokens.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; + +namespace oox::drawingml::table { + +TableRowContext::TableRowContext( ContextHandler2Helper const & rParent, const AttributeList& rAttribs, TableRow& rTableRow ) +: ContextHandler2( rParent ) +, mrTableRow( rTableRow ) +{ + rTableRow.setHeight( rAttribs.getString( XML_h ).get().toInt32() ); +} + +TableRowContext::~TableRowContext() +{ +} + +ContextHandlerRef +TableRowContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case A_TOKEN( tc ): // CT_TableCell + { + std::vector< TableCell >& rvTableCells = mrTableRow.getTableCells(); + rvTableCells.emplace_back(); + return new TableCellContext( *this, rAttribs, rvTableCells.back() ); + } + case A_TOKEN( extLst ): // CT_OfficeArtExtensionList + default: + break; + } + + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestyle.cxx b/oox/source/drawingml/table/tablestyle.cxx new file mode 100644 index 000000000..15ae746ea --- /dev/null +++ b/oox/source/drawingml/table/tablestyle.cxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <drawingml/table/tablestyle.hxx> + +namespace oox::drawingml::table { + +TableStyle::TableStyle() +{ +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylecellstylecontext.cxx b/oox/source/drawingml/table/tablestylecellstylecontext.cxx new file mode 100644 index 000000000..a3c86b238 --- /dev/null +++ b/oox/source/drawingml/table/tablestylecellstylecontext.cxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <drawingml/table/tablestylecellstylecontext.hxx> +#include <drawingml/misccontexts.hxx> +#include <drawingml/lineproperties.hxx> +#include <drawingml/linepropertiescontext.hxx> +#include <oox/helper/attributelist.hxx> +#include <oox/token/namespaces.hxx> +#include <oox/token/tokens.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::drawingml::table { + +TableStyleCellStyleContext::TableStyleCellStyleContext( ContextHandler2Helper const & rParent, TableStylePart& rTableStylePart ) +: ContextHandler2( rParent ) +, mrTableStylePart( rTableStylePart ) +, mnLineType( XML_none ) +{ +} + +TableStyleCellStyleContext::~TableStyleCellStyleContext() +{ +} + +// CT_TableStyleCellStyle +ContextHandlerRef +TableStyleCellStyleContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case A_TOKEN( tcBdr ): // CT_TableCellBorderStyle + break; + case A_TOKEN( left ): // CT_ThemeableLineStyle + case A_TOKEN( right ): + case A_TOKEN( top ): + case A_TOKEN( bottom ): + case A_TOKEN( insideH ): + case A_TOKEN( insideV ): + case A_TOKEN( tl2br ): + case A_TOKEN( tr2bl ): + mnLineType = getBaseToken( aElementToken ); + break; + + case A_TOKEN( ln ): + { + if ( mnLineType != XML_none ) + { + std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >& rLineBorders = mrTableStylePart.getLineBorders(); + ::oox::drawingml::LinePropertiesPtr pLineProperties = std::make_shared<oox::drawingml::LineProperties>(); + rLineBorders[ mnLineType ] = pLineProperties; + return new LinePropertiesContext( *this, rAttribs, *pLineProperties ); + } + } + break; + case A_TOKEN( lnRef ): + { + if ( mnLineType != XML_none ) + { + ShapeStyleRef& rLineStyleRef = mrTableStylePart.getStyleRefs()[ mnLineType ]; + rLineStyleRef.mnThemedIdx = rAttribs.getInteger( XML_idx, 0 ); + return new ColorContext( *this, rLineStyleRef.maPhClr ); + } + } + break; + + // EG_ThemeableFillStyle (choice) + case A_TOKEN( fill ): // CT_FillProperties + { + FillPropertiesPtr& rxFillProperties = mrTableStylePart.getFillProperties(); + rxFillProperties = std::make_shared<FillProperties>(); + return new FillPropertiesContext( *this, *rxFillProperties ); + } + case A_TOKEN( fillRef ): // CT_StyleMatrixReference + { + ShapeStyleRef& rStyleRef = mrTableStylePart.getStyleRefs()[ XML_fillRef ]; + rStyleRef.mnThemedIdx = rAttribs.getInteger( XML_idx, 0 ); + return new ColorContext( *this, rStyleRef.maPhClr ); + } + case A_TOKEN( cell3D ): // CT_Cell3D + break; + } + + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylecontext.cxx b/oox/source/drawingml/table/tablestylecontext.cxx new file mode 100644 index 000000000..7dc4ce468 --- /dev/null +++ b/oox/source/drawingml/table/tablestylecontext.cxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <drawingml/table/tablestylecontext.hxx> +#include <drawingml/table/tablebackgroundstylecontext.hxx> +#include <drawingml/table/tablepartstylecontext.hxx> +#include <oox/helper/attributelist.hxx> +#include <oox/token/namespaces.hxx> +#include <oox/token/tokens.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::drawingml::table { + +TableStyleContext::TableStyleContext( ContextHandler2Helper const & rParent, + const AttributeList& rAttribs, TableStyle& rTableStyle ) +: ContextHandler2( rParent ) +, mrTableStyle( rTableStyle ) +{ + mrTableStyle.getStyleId() = rAttribs.getString( XML_styleId ).get(); + mrTableStyle.getStyleName() = rAttribs.getString( XML_styleName ).get(); +} + +TableStyleContext::~TableStyleContext() +{ +} + +ContextHandlerRef +TableStyleContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& /* rAttribs */ ) +{ + switch( aElementToken ) + { + case A_TOKEN( tblBg ): // CT_TableBackgroundStyle + return new TableBackgroundStyleContext( *this, mrTableStyle ); + case A_TOKEN( wholeTbl ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getWholeTbl() ); + case A_TOKEN( band1H ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getBand1H() ); + case A_TOKEN( band2H ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getBand2H() ); + case A_TOKEN( band1V ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getBand1V() ); + case A_TOKEN( band2V ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getBand2V() ); + case A_TOKEN( lastCol ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getLastCol() ); + case A_TOKEN( firstCol ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getFirstCol() ); + case A_TOKEN( lastRow ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getLastRow() ); + case A_TOKEN( seCell ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getSeCell() ); + case A_TOKEN( swCell ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getSwCell() ); + case A_TOKEN( firstRow ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getFirstRow() ); + case A_TOKEN( neCell ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getNeCell() ); + case A_TOKEN( nwCell ): // CT_TablePartStyle + return new TablePartStyleContext( *this, mrTableStyle.getNwCell() ); + case A_TOKEN( extLst ): // CT_OfficeArtExtensionList + break; + } + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylelist.cxx b/oox/source/drawingml/table/tablestylelist.cxx new file mode 100644 index 000000000..b04ed5188 --- /dev/null +++ b/oox/source/drawingml/table/tablestylelist.cxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <drawingml/table/tablestylelist.hxx> +#include <drawingml/table/tablestyle.hxx> + +namespace oox::drawingml::table { + +TableStyleList::TableStyleList() +{ +} + +TableStyleList::~TableStyleList() +{ +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx new file mode 100644 index 000000000..77dc42677 --- /dev/null +++ b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <drawingml/table/tablestylelistfragmenthandler.hxx> +#include <drawingml/table/tablestylecontext.hxx> +#include <oox/helper/attributelist.hxx> +#include <oox/token/namespaces.hxx> +#include <oox/token/tokens.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::oox::drawingml; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::drawingml::table { + +TableStyleListFragmentHandler::TableStyleListFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, TableStyleList& rTableStyleList ): +FragmentHandler2( rFilter, rFragmentPath ), +mrTableStyleList( rTableStyleList ) +{ +} + +TableStyleListFragmentHandler::~TableStyleListFragmentHandler() +{ +} + +// CT_TableStyleList +ContextHandlerRef TableStyleListFragmentHandler::onCreateContext( + sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case A_TOKEN( tblStyleLst ): // CT_TableStyleList + mrTableStyleList.getDefaultStyleId() = rAttribs.getString( XML_def ).get(); + break; + case A_TOKEN( tblStyle ): // CT_TableStyle + std::vector< TableStyle >& rTableStyles = mrTableStyleList.getTableStyles(); + rTableStyles.emplace_back(); + return new TableStyleContext( *this, rAttribs, rTableStyles.back() ); + } + return this; +} + +} // namespace oox::drawingml::table + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylepart.cxx b/oox/source/drawingml/table/tablestylepart.cxx new file mode 100644 index 000000000..e9fed9460 --- /dev/null +++ b/oox/source/drawingml/table/tablestylepart.cxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <drawingml/table/tablestylepart.hxx> +#include <oox/drawingml/drawingmltypes.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; + +namespace oox::drawingml::table { + +TableStylePart::TableStylePart() +{ +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestyletextstylecontext.cxx b/oox/source/drawingml/table/tablestyletextstylecontext.cxx new file mode 100644 index 000000000..d4206439f --- /dev/null +++ b/oox/source/drawingml/table/tablestyletextstylecontext.cxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <drawingml/table/tablestyletextstylecontext.hxx> +#include <drawingml/colorchoicecontext.hxx> +#include <oox/helper/attributelist.hxx> +#include <oox/token/namespaces.hxx> +#include <oox/token/tokens.hxx> + +using namespace ::oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::drawingml::table { + +TableStyleTextStyleContext::TableStyleTextStyleContext( ContextHandler2Helper const & rParent, + const AttributeList& rAttribs, TableStylePart& rTableStylePart ) +: ContextHandler2( rParent ) +, mrTableStylePart( rTableStylePart ) +{ + if( rAttribs.hasAttribute( XML_b ) ) { + sal_Int32 nB = rAttribs.getToken( XML_b, XML_def ); + if ( nB == XML_on ) + mrTableStylePart.getTextBoldStyle() = true; + else if ( nB == XML_off ) + mrTableStylePart.getTextBoldStyle() = false; + } + + if( rAttribs.hasAttribute( XML_i ) ) { + sal_Int32 nI = rAttribs.getToken( XML_i, XML_def ); + if ( nI == XML_on ) + mrTableStylePart.getTextItalicStyle() = true; + else if ( nI == XML_off ) + mrTableStylePart.getTextItalicStyle() = false; + } +} + +TableStyleTextStyleContext::~TableStyleTextStyleContext() +{ +} + +// CT_TableStyleTextStyle +ContextHandlerRef +TableStyleTextStyleContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + // EG_ThemeableFontStyles (choice) + case A_TOKEN( font ): // CT_FontCollection + return this; + case A_TOKEN( ea ): // CT_TextFont + mrTableStylePart.getAsianFont().setAttributes( rAttribs ); + return nullptr; + case A_TOKEN( cs ): // CT_TextFont + mrTableStylePart.getComplexFont().setAttributes( rAttribs ); + return nullptr; + case A_TOKEN( sym ): // CT_TextFont + mrTableStylePart.getSymbolFont().setAttributes( rAttribs ); + return nullptr; + case A_TOKEN( latin ): // CT_TextFont + mrTableStylePart.getLatinFont().setAttributes( rAttribs ); + return nullptr; + + case A_TOKEN( fontRef ): // CT_FontReference + { + ShapeStyleRef& rFontStyle = mrTableStylePart.getStyleRefs()[ XML_fontRef ]; + rFontStyle.mnThemedIdx = rAttribs.getToken( XML_idx, XML_none ); + return new ColorContext( *this, rFontStyle.maPhClr ); + } + + case A_TOKEN( extLst ): // CT_OfficeArtExtensionList + break; + } + + return new ColorValueContext( *this, mrTableStylePart.getTextColor() ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |