diff options
Diffstat (limited to 'oox/source/drawingml/table')
-rw-r--r-- | oox/source/drawingml/table/predefined-table-styles.cxx | 975 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablebackgroundstylecontext.cxx | 74 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablecell.cxx | 578 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablecellcontext.cxx | 103 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablecontext.cxx | 98 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablepartstylecontext.cxx | 60 | ||||
-rw-r--r-- | oox/source/drawingml/table/tableproperties.cxx | 216 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablerow.cxx | 35 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablerowcontext.cxx | 65 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestyle.cxx | 27 | ||||
-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 | 30 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestylelistfragmenthandler.cxx | 63 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestylepart.cxx | 33 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablestyletextstylecontext.cxx | 98 |
16 files changed, 2654 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..91eccdfc8 --- /dev/null +++ b/oox/source/drawingml/table/predefined-table-styles.cxx @@ -0,0 +1,975 @@ +/* -*- 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 } }; + +void setBorderLineType(const oox::drawingml::LinePropertiesPtr& pLineProp, sal_Int32 nToken) +{ + pLineProp->maLineFill.moFillType.set(nToken); +} + +void insertBorderLine(TableStylePart& aTableStylePart, sal_Int32 nToken, + oox::drawingml::LinePropertiesPtr pLineProp) +{ + if (pLineProp->maLineFill.moFillType.has()) + { + aTableStylePart.getLineBorders().insert( + std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(nToken, pLineProp)); + } +} + +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); + + // 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; + + if (style_name == "Themed-Style-1") + { + if (!accent_name.isEmpty()) + { + setBorderLineType(pWholeTblLeftBorder, XML_solidFill); + setBorderLineType(pWholeTblRightBorder, XML_solidFill); + setBorderLineType(pWholeTblTopBorder, XML_solidFill); + setBorderLineType(pWholeTblBottomBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideHBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideVBorder, XML_solidFill); + setBorderLineType(pFirstRowLeftBorder, XML_solidFill); + setBorderLineType(pFirstRowRightBorder, XML_solidFill); + setBorderLineType(pFirstRowTopBorder, XML_solidFill); + setBorderLineType(pFirstRowBottomBorder, XML_solidFill); + setBorderLineType(pLastRowLeftBorder, XML_solidFill); + setBorderLineType(pLastRowRightBorder, XML_solidFill); + setBorderLineType(pLastRowTopBorder, XML_solidFill); + setBorderLineType(pLastRowBottomBorder, XML_solidFill); + setBorderLineType(pFirstColLeftBorder, XML_solidFill); + setBorderLineType(pFirstColRightBorder, XML_solidFill); + setBorderLineType(pFirstColTopBorder, XML_solidFill); + setBorderLineType(pFirstColBottomBorder, XML_solidFill); + setBorderLineType(pFirstColInsideHBorder, XML_solidFill); + setBorderLineType(pLastColLeftBorder, XML_solidFill); + setBorderLineType(pLastColRightBorder, XML_solidFill); + setBorderLineType(pLastColTopBorder, XML_solidFill); + setBorderLineType(pLastColBottomBorder, XML_solidFill); + setBorderLineType(pLastColInsideHBorder, XML_solidFill); + + sal_Int32 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") + { + setBorderLineType(pWholeTblLeftBorder, XML_solidFill); + setBorderLineType(pWholeTblRightBorder, XML_solidFill); + setBorderLineType(pWholeTblTopBorder, XML_solidFill); + setBorderLineType(pWholeTblBottomBorder, XML_solidFill); + + sal_Int32 accent_val; + + if (!accent_name.isEmpty()) + { + setBorderLineType(pFirstRowBottomBorder, XML_solidFill); + setBorderLineType(pLastRowTopBorder, XML_solidFill); + setBorderLineType(pFirstColRightBorder, XML_solidFill); + setBorderLineType(pLastColLeftBorder, XML_solidFill); + + wholeTblTextColor.setSchemeClr(XML_lt1); + firstRowTextColor.setSchemeClr(XML_lt1); + + 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 + { + setBorderLineType(pWholeTblInsideVBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideHBorder, XML_solidFill); + + 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") + { + setBorderLineType(pWholeTblTopBorder, XML_solidFill); + setBorderLineType(pWholeTblBottomBorder, XML_solidFill); + setBorderLineType(pFirstRowBottomBorder, XML_solidFill); + setBorderLineType(pLastRowTopBorder, XML_solidFill); + + wholeTblTextColor.setSchemeClr(XML_tx1); + + sal_Int32 accent_val; + + 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") + { + setBorderLineType(pWholeTblLeftBorder, XML_solidFill); + setBorderLineType(pWholeTblRightBorder, XML_solidFill); + setBorderLineType(pWholeTblTopBorder, XML_solidFill); + setBorderLineType(pWholeTblBottomBorder, XML_solidFill); + setBorderLineType(pLastRowTopBorder, XML_solidFill); + setBorderLineType(pBand1HTopBorder, XML_solidFill); + setBorderLineType(pBand1HBottomBorder, XML_solidFill); + setBorderLineType(pBand1VLeftBorder, XML_solidFill); + setBorderLineType(pBand1VRightBorder, XML_solidFill); + setBorderLineType(pBand2VLeftBorder, XML_solidFill); + setBorderLineType(pBand2VRightBorder, XML_solidFill); + + wholeTblTextColor.setSchemeClr(XML_tx1); + firstRowTextColor.setSchemeClr(XML_bg1); + + sal_Int32 accent_val; + + 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") + { + setBorderLineType(pWholeTblLeftBorder, XML_solidFill); + setBorderLineType(pWholeTblRightBorder, XML_solidFill); + setBorderLineType(pWholeTblTopBorder, XML_solidFill); + setBorderLineType(pWholeTblBottomBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideHBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideVBorder, XML_solidFill); + setBorderLineType(pFirstRowBottomBorder, XML_solidFill); + setBorderLineType(pLastRowTopBorder, XML_solidFill); + + wholeTblTextColor.setSchemeClr(XML_tx1); + + sal_Int32 accent_val; + + 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") + { + setBorderLineType(pWholeTblLeftBorder, XML_solidFill); + setBorderLineType(pWholeTblRightBorder, XML_solidFill); + setBorderLineType(pWholeTblTopBorder, XML_solidFill); + setBorderLineType(pWholeTblBottomBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideHBorder, XML_solidFill); + setBorderLineType(pLastRowTopBorder, XML_solidFill); + + wholeTblTextColor.setSchemeClr(XML_dk1); + firstRowTextColor.setSchemeClr(XML_lt1); + pWholeTblFillProperties->maFillColor.setSchemeClr(XML_lt1); + pLastRowFillProperties->maFillColor.setSchemeClr(XML_lt1); + + sal_Int32 accent_val; + + 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") + { + setBorderLineType(pFirstRowBottomBorder, XML_solidFill); + setBorderLineType(pLastRowTopBorder, XML_solidFill); + setBorderLineType(pWholeTblLeftBorder, XML_solidFill); + setBorderLineType(pWholeTblRightBorder, XML_solidFill); + setBorderLineType(pWholeTblTopBorder, XML_solidFill); + setBorderLineType(pWholeTblBottomBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideHBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideVBorder, XML_solidFill); + + 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); + + sal_Int32 accent_val; + + 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") + { + setBorderLineType(pWholeTblTopBorder, XML_solidFill); + setBorderLineType(pWholeTblBottomBorder, XML_solidFill); + setBorderLineType(pFirstRowBottomBorder, XML_solidFill); + setBorderLineType(pLastRowTopBorder, XML_solidFill); + + 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); + + sal_Int32 accent_val; + + 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") + { + setBorderLineType(pWholeTblLeftBorder, XML_solidFill); + setBorderLineType(pWholeTblRightBorder, XML_solidFill); + setBorderLineType(pWholeTblTopBorder, XML_solidFill); + setBorderLineType(pWholeTblBottomBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideHBorder, XML_solidFill); + setBorderLineType(pWholeTblInsideVBorder, XML_solidFill); + + wholeTblTextColor.setSchemeClr(XML_dk1); + pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(XML_dk1); + pLastRowFillProperties->maFillColor.setSchemeClr(XML_dk1); + + sal_Int32 accent_val; + + 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") + { + setBorderLineType(pFirstRowBottomBorder, XML_solidFill); + setBorderLineType(pFirstColRightBorder, XML_solidFill); + setBorderLineType(pLastColLeftBorder, XML_solidFill); + setBorderLineType(pLastRowTopBorder, XML_solidFill); + + 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); + + sal_Int32 accent_val; + + 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") + { + setBorderLineType(pLastRowTopBorder, XML_solidFill); + + 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); + + sal_Int32 accent_val; + + 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; + + insertBorderLine(pTableStyle->getWholeTbl(), XML_left, pWholeTblLeftBorder); + insertBorderLine(pTableStyle->getWholeTbl(), XML_right, pWholeTblRightBorder); + insertBorderLine(pTableStyle->getWholeTbl(), XML_top, pWholeTblTopBorder); + insertBorderLine(pTableStyle->getWholeTbl(), XML_bottom, pWholeTblBottomBorder); + insertBorderLine(pTableStyle->getWholeTbl(), XML_insideV, pWholeTblInsideVBorder); + insertBorderLine(pTableStyle->getWholeTbl(), XML_insideH, pWholeTblInsideHBorder); + + insertBorderLine(pTableStyle->getFirstRow(), XML_left, pFirstRowLeftBorder); + insertBorderLine(pTableStyle->getFirstRow(), XML_right, pFirstRowRightBorder); + insertBorderLine(pTableStyle->getFirstRow(), XML_top, pFirstRowTopBorder); + insertBorderLine(pTableStyle->getFirstRow(), XML_bottom, pFirstRowBottomBorder); + insertBorderLine(pTableStyle->getFirstRow(), XML_insideV, pFirstRowInsideVBorder); + insertBorderLine(pTableStyle->getFirstRow(), XML_insideH, pFirstRowInsideHBorder); + + insertBorderLine(pTableStyle->getFirstCol(), XML_left, pFirstColLeftBorder); + insertBorderLine(pTableStyle->getFirstCol(), XML_right, pFirstColRightBorder); + insertBorderLine(pTableStyle->getFirstCol(), XML_top, pFirstColTopBorder); + insertBorderLine(pTableStyle->getFirstCol(), XML_bottom, pFirstColBottomBorder); + insertBorderLine(pTableStyle->getFirstCol(), XML_insideV, pFirstColInsideVBorder); + insertBorderLine(pTableStyle->getFirstCol(), XML_insideH, pFirstColInsideHBorder); + + insertBorderLine(pTableStyle->getLastRow(), XML_left, pLastRowLeftBorder); + insertBorderLine(pTableStyle->getLastRow(), XML_right, pLastRowRightBorder); + insertBorderLine(pTableStyle->getLastRow(), XML_top, pLastRowTopBorder); + insertBorderLine(pTableStyle->getLastRow(), XML_bottom, pLastRowBottomBorder); + insertBorderLine(pTableStyle->getLastRow(), XML_insideV, pLastRowInsideVBorder); + insertBorderLine(pTableStyle->getLastRow(), XML_insideH, pLastRowInsideHBorder); + + insertBorderLine(pTableStyle->getLastCol(), XML_left, pLastColLeftBorder); + insertBorderLine(pTableStyle->getLastCol(), XML_right, pLastColRightBorder); + insertBorderLine(pTableStyle->getLastCol(), XML_top, pLastColTopBorder); + insertBorderLine(pTableStyle->getLastCol(), XML_bottom, pLastColBottomBorder); + insertBorderLine(pTableStyle->getLastCol(), XML_insideV, pLastColInsideVBorder); + insertBorderLine(pTableStyle->getLastCol(), XML_insideH, pLastColInsideHBorder); + + insertBorderLine(pTableStyle->getBand1H(), XML_left, pBand1HLeftBorder); + insertBorderLine(pTableStyle->getBand1H(), XML_right, pBand1HRightBorder); + insertBorderLine(pTableStyle->getBand1H(), XML_top, pBand1HTopBorder); + insertBorderLine(pTableStyle->getBand1H(), XML_bottom, pBand1HBottomBorder); + insertBorderLine(pTableStyle->getBand1H(), XML_insideV, pBand1HInsideVBorder); + insertBorderLine(pTableStyle->getBand1H(), XML_insideH, pBand1HInsideHBorder); + + insertBorderLine(pTableStyle->getBand1V(), XML_left, pBand1VLeftBorder); + insertBorderLine(pTableStyle->getBand1V(), XML_right, pBand1VRightBorder); + insertBorderLine(pTableStyle->getBand1V(), XML_top, pBand1VTopBorder); + insertBorderLine(pTableStyle->getBand1V(), XML_bottom, pBand1VBottomBorder); + insertBorderLine(pTableStyle->getBand1V(), XML_insideV, pBand1VInsideVBorder); + insertBorderLine(pTableStyle->getBand1V(), XML_insideH, pBand1VInsideHBorder); + + insertBorderLine(pTableStyle->getBand2H(), XML_left, pBand2HLeftBorder); + insertBorderLine(pTableStyle->getBand2H(), XML_right, pBand2HRightBorder); + insertBorderLine(pTableStyle->getBand2H(), XML_top, pBand2HTopBorder); + insertBorderLine(pTableStyle->getBand2H(), XML_bottom, pBand2HBottomBorder); + insertBorderLine(pTableStyle->getBand2H(), XML_insideV, pBand2HInsideVBorder); + insertBorderLine(pTableStyle->getBand2H(), XML_insideH, pBand2HInsideHBorder); + + insertBorderLine(pTableStyle->getBand2V(), XML_left, pBand2VLeftBorder); + insertBorderLine(pTableStyle->getBand2V(), XML_right, pBand2VRightBorder); + insertBorderLine(pTableStyle->getBand2V(), XML_top, pBand2VTopBorder); + insertBorderLine(pTableStyle->getBand2V(), XML_bottom, pBand2VBottomBorder); + insertBorderLine(pTableStyle->getBand2V(), XML_insideV, pBand2VInsideVBorder); + insertBorderLine(pTableStyle->getBand2V(), XML_insideH, pBand2VInsideHBorder); + + 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..19347db21 --- /dev/null +++ b/oox/source/drawingml/table/tablecell.cxx @@ -0,0 +1,578 @@ +/* -*- 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 <drawingml/textcharacterproperties.hxx> +#include <drawingml/textparagraph.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 + { + 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& rInsideHBorder, + oox::drawingml::LineProperties& rInsideVBorder, + oox::drawingml::LineProperties& rTopLeftToBottomRightBorder, + oox::drawingml::LineProperties& rBottomLeftToTopRightBorder, + TableStylePart& rTableStylePart, + bool bIsWholeTable = false, + sal_Int32 nCol = 0, + sal_Int32 nMaxCol = 0, + sal_Int32 nRow = 0, + sal_Int32 nMaxRow = 0) +{ + ::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 ); + } + } + + // Left, right, top and bottom side of the whole table should be mean outer frame of the whole table. + // Without this check it means left top right and bottom of whole cells of whole table. + if (bIsWholeTable) + { + if (nCol == 0) + applyBorder( rFilterBase, rTableStylePart, XML_left, rLeftBorder ); + if (nCol == nMaxCol) + applyBorder( rFilterBase, rTableStylePart, XML_right, rRightBorder ); + if (nRow == 0) + applyBorder( rFilterBase, rTableStylePart, XML_top, rTopBorder ); + if (nRow == nMaxRow) + applyBorder( rFilterBase, rTableStylePart, XML_bottom, rBottomBorder ); + + applyBorder( rFilterBase, rTableStylePart, XML_insideH, rInsideHBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_insideV, rInsideVBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_tl2br, rTopLeftToBottomRightBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_tr2bl, rBottomLeftToTopRightBorder ); + } + else + { + 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 ); + applyBorder( rFilterBase, rTableStylePart, XML_insideH, rInsideHBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_insideV, rInsideVBorder ); + } + + 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 aLinePropertiesInsideH; + oox::drawingml::LineProperties aLinePropertiesInsideV; + oox::drawingml::LineProperties aLinePropertiesTopLeftToBottomRight; + oox::drawingml::LineProperties aLinePropertiesBottomLeftToTopRight; + + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getWholeTbl(), + true, + nColumn, + nMaxColumn, + nRow, + nMaxRow ); + + if ( rProperties.isFirstRow() && ( nRow == 0 ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getFirstRow() ); + } + if ( rProperties.isLastRow() && ( nRow == nMaxRow ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getLastRow() ); + } + if ( rProperties.isFirstCol() && ( nColumn == 0 ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getFirstCol() ); + } + if ( rProperties.isLastCol() && ( nColumn == nMaxColumn ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + 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, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getBand2H() ); + } + else + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getBand1H() ); + } + } + } + if ( ( nRow == 0 ) && ( nColumn == 0 ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getNwCell() ); + } + if ( ( nRow == nMaxRow ) && ( nColumn == 0 ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getSwCell() ); + } + if ( ( nRow == 0 ) && ( nColumn == nMaxColumn ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getNeCell() ); + } + if ( ( nRow == nMaxRow ) && ( nColumn == nMaxColumn ) ) + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + 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, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getBand2V() ); + } + else + { + applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps, + aLinePropertiesLeft, + aLinePropertiesRight, + aLinePropertiesTop, + aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, + aLinePropertiesTopLeftToBottomRight, + aLinePropertiesBottomLeftToTopRight, + rTable.getBand1V() ); + } + } + } + aLinePropertiesLeft.assignUsed( maLinePropertiesLeft ); + aLinePropertiesRight.assignUsed( maLinePropertiesRight ); + aLinePropertiesTop.assignUsed( maLinePropertiesTop ); + aLinePropertiesBottom.assignUsed( maLinePropertiesBottom ); + aLinePropertiesInsideH.assignUsed( maLinePropertiesInsideH ); + aLinePropertiesInsideV.assignUsed( maLinePropertiesInsideV ); + 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 ); + + // Convert insideH to Top and Bottom, InsideV to Left and Right. Exclude the outer borders. + if(nRow != 0) + { + aLinePropertiesInsideH.assignUsed( aLinePropertiesTop ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideH, PROP_TopBorder ); + } + if(nRow != nMaxRow) + { + aLinePropertiesInsideH.assignUsed( aLinePropertiesBottom ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideH, PROP_BottomBorder ); + } + if(nColumn != 0) + { + aLinePropertiesInsideV.assignUsed( aLinePropertiesLeft ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideV, PROP_LeftBorder ); + } + if(nColumn != nMaxColumn) + { + aLinePropertiesInsideV.assignUsed( aLinePropertiesRight ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideV, PROP_RightBorder ); + } + + 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 aPropSet{xPropSet}; + aPropSet.setProperties( aPropMap ); + + if ( getVertToken() == XML_eaVert ) + { + xPropSet->setPropertyValue("TextWritingMode", Any(css::text::WritingMode_TB_RL)); + } + + getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, pMasterTextListStyle ); + + // tdf#144092 For empty cells push character styles & endParaRPr to the Cell's properties + const TextParagraphVector& rParagraphs = getTextBody()->getParagraphs(); + if (rParagraphs.size() == 1) + { + const auto pFirstParagraph = rParagraphs.at(0); + if (pFirstParagraph->getRuns().empty()) + { + TextCharacterProperties aTextCharacterProps{ pFirstParagraph->getCharacterStyle( + aTextStyleProps, *pMasterTextListStyle, getTextBody()->getTextListStyle()) }; + aTextCharacterProps.assignUsed(pFirstParagraph->getEndProperties()); + aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase); + } + } + + 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..84e80dccd --- /dev/null +++ b/oox/source/drawingml/table/tablecontext.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 <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 <drawingml/effectpropertiescontext.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( effectLst ): // CT_EffectList + { + return new EffectPropertiesContext(*this, mpShapePtr->getEffectProperties()); + } + 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..38f655af1 --- /dev/null +++ b/oox/source/drawingml/table/tableproperties.cxx @@ -0,0 +1,216 @@ +/* -*- 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 <oox/drawingml/drawingmltypes.hxx> +#include <com/sun/star/table/XTable.hpp> +#include <com/sun/star/table/XMergeableCellRange.hpp> +#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& ) + { + } +} + +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 ) + { + static TableStyle theDefaultTableStyle; + return theDefaultTableStyle; + } + + 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 = tableRow.getTableCells().size(); + sal_Int32 nRemovedColumn = 0; + sal_Int32 nRemovedRow = 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; + } + + if (rTableCell.getRowSpan() > 1) + nRemovedRow = (rTableCell.getRowSpan() - 1); + } + + 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); + + + sal_Int32 nMaxCol = tableRow.getTableCells().size() - nRemovedColumn - 1; + sal_Int32 nMaxRow = mvTableRows.size() - nRemovedRow - 1; + + rTableCell.pushToXCell(rFilterBase, pMasterTextListStyle, xCell, *this, rTableStyle, + nColumn, nMaxCol, nRow, nMaxRow); + + if (bMerged) + nColumn += nRemovedColumn; + + nRemovedRow = 0; + } + ++nColumn; + } + ++nRow; + } + + xTableStyleToDelete.reset(); +} +} + +/* 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..3284c7c84 --- /dev/null +++ b/oox/source/drawingml/table/tablerow.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/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..e0ae76e9a --- /dev/null +++ b/oox/source/drawingml/table/tablestyle.cxx @@ -0,0 +1,27 @@ +/* -*- 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..57a0ba489 --- /dev/null +++ b/oox/source/drawingml/table/tablestylelist.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/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..729604f26 --- /dev/null +++ b/oox/source/drawingml/table/tablestylepart.cxx @@ -0,0 +1,33 @@ +/* -*- 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: */ |