From daab698b346e5e40b67f1e15c796c4e399ccaf8a Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Tue, 22 Nov 2022 14:07:12 +0200 Subject: [PATCH] sd: replace hardcoded table styles with xml file Including a new set of default styles, provided by Rafael Lima. Some ui tests had to be modified, because the new borders are thicker. If you intend to edit the xml file, please keep in mind the following requirements: 1) There should be a table template called "default". It's applied to newly inserted tables. 2) There should be a cell style called "default". It's used for new table styles. 3) Please make all cell styles inherit from "default" (directly or indirectly), unless you intend to specify font names in them. "default" has its font names filled programmatically based on officecfg/registry/data/org/openoffice/VCL.xcu. 4) Whenever possible please use for cell properties, instead of the incorrect and we currently use for export. See tdf#72238 and tdf#72239. Change-Id: I73dd4492fefb65b1870238aec7dc64f8076f6e95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141825 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky --- include/xmloff/table/XMLTableImport.hxx | 5 +- sd/Package_xml.mk | 1 + sd/inc/app.hrc | 7 - sd/inc/strings.hrc | 5 - sd/qa/uitest/impress_tests2/tdf139511.py | 10 +- sd/qa/uitest/impress_tests2/tdf91762.py | 7 +- sd/source/core/drawdoc4.cxx | 221 +++++------------------ sd/source/core/stlpool.cxx | 7 - sd/xml/styles.xml | 196 ++++++++++++++++++++ svx/source/table/tabledesign.cxx | 6 +- xmloff/source/draw/sdxmlimp.cxx | 21 ++- xmloff/source/table/XMLTableImport.cxx | 8 +- 12 files changed, 284 insertions(+), 210 deletions(-) create mode 100644 sd/xml/styles.xml diff --git a/include/xmloff/table/XMLTableImport.hxx b/include/xmloff/table/XMLTableImport.hxx index c0f702b5caaa..0889637f2e23 100644 --- a/include/xmloff/table/XMLTableImport.hxx +++ b/include/xmloff/table/XMLTableImport.hxx @@ -36,7 +36,10 @@ class SvXMLStyleContext; typedef std::map< OUString, OUString > XMLTableTemplate; -typedef std::map < OUString, std::shared_ptr< XMLTableTemplate > > XMLTableTemplateMap; +// Not using a map here, as we want the templates to be +// inserted in the same order they were defined in the +// xml (at least for sd built in templates): +typedef std::vector< std::pair< OUString, std::shared_ptr< XMLTableTemplate > > > XMLTableTemplateMap; class XMLOFF_DLLPUBLIC XMLTableImport final : public salhelper::SimpleReferenceObject { diff --git a/sd/Package_xml.mk b/sd/Package_xml.mk index fa227b72823c..555d46021bb7 100644 --- a/sd/Package_xml.mk +++ b/sd/Package_xml.mk @@ -14,6 +14,7 @@ $(eval $(call gb_Package_add_files,sd_xml,$(LIBO_SHARE_FOLDER)/config/soffice.cf transitions.xml \ layoutlist.xml \ objectlist.xml \ + styles.xml \ )) # vim: set noet sw=4 ts=4: diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc index 875dc0cc3e75..dcd09a8c7e46 100644 --- a/sd/inc/app.hrc +++ b/sd/inc/app.hrc @@ -67,13 +67,6 @@ #define HID_PSEUDOSHEET_NOTES (HID_SD_START + 98) #define HID_PSEUDOSHEET_SUBTITLE (HID_SD_START + 101) -#define HID_SD_CELL_STYLE_DEFAULT (HID_SD_START + 194) -#define HID_SD_CELL_STYLE_BANDED (HID_SD_START + 195) -#define HID_SD_CELL_STYLE_HEADER (HID_SD_START + 196) -#define HID_SD_CELL_STYLE_TOTAL (HID_SD_START + 197) -#define HID_SD_CELL_STYLE_FIRST_COLUMN (HID_SD_START + 198) -#define HID_SD_CELL_STYLE_LAST_COLUMN (HID_SD_START + 199) - #define SID_PAGESETUP (SID_SD_START+2) // FREE #define SID_COPYOBJECTS (SID_SD_START+4) diff --git a/sd/inc/strings.hrc b/sd/inc/strings.hrc index 662acd59db12..c9a48bfe3574 100644 --- a/sd/inc/strings.hrc +++ b/sd/inc/strings.hrc @@ -360,11 +360,6 @@ #define STR_PSEUDOSHEET_NOTES NC_("STR_PSEUDOSHEET_NOTES", "Notes" ) #define STR_POWERPOINT_IMPORT NC_("STR_POWERPOINT_IMPORT", "PowerPoint Import") #define STR_SAVE_DOC NC_("STR_SAVE_DOC", "Save Document" ) -#define STR_POOLSHEET_BANDED_CELL NC_("STR_POOLSHEET_BANDED_CELL", "Banding cell" ) -#define STR_POOLSHEET_HEADER NC_("STR_POOLSHEET_HEADER", "Header" ) -#define STR_POOLSHEET_TOTAL NC_("STR_POOLSHEET_TOTAL", "Total line" ) -#define STR_POOLSHEET_FIRST_COLUMN NC_("STR_POOLSHEET_FIRST_COLUMN", "First column" ) -#define STR_POOLSHEET_LAST_COLUMN NC_("STR_POOLSHEET_LAST_COLUMN", "Last column" ) #define STR_SHRINK_FONT_SIZE NC_("STR_SHRINK_FONT_SIZE", "Shrink font size") #define STR_GROW_FONT_SIZE NC_("STR_GROW_FONT_SIZE", "Grow font size") diff --git a/sd/qa/uitest/impress_tests2/tdf139511.py b/sd/qa/uitest/impress_tests2/tdf139511.py index 4ff7a67090a1..c20fbc84c666 100644 --- a/sd/qa/uitest/impress_tests2/tdf139511.py +++ b/sd/qa/uitest/impress_tests2/tdf139511.py @@ -23,8 +23,8 @@ class tdf139511(UITestCase): self.xUITest.executeCommand(".uno:InsertTable?Columns:short=4&Rows:short=4") - self.assertEqual(8004, document.DrawPages[0].getByIndex(2).BoundRect.Height) - self.assertEqual(14104, document.DrawPages[0].getByIndex(2).BoundRect.Width) + self.assertEqual(8036, document.DrawPages[0].getByIndex(2).BoundRect.Height) + self.assertEqual(14136, document.DrawPages[0].getByIndex(2).BoundRect.Width) with self.ui_test.execute_dialog_through_command(".uno:TransformDialog") as xDialog: @@ -43,9 +43,9 @@ class tdf139511(UITestCase): # Without the fix in place, this test would have failed with - # AssertionError: 5005 != 8004 - self.assertEqual(5005, document.DrawPages[0].getByIndex(2).BoundRect.Height) - self.assertEqual(10005, document.DrawPages[0].getByIndex(2).BoundRect.Width) + # AssertionError: 5037 != 8036 + self.assertEqual(5037, document.DrawPages[0].getByIndex(2).BoundRect.Height) + self.assertEqual(10037, document.DrawPages[0].getByIndex(2).BoundRect.Width) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests2/tdf91762.py b/sd/qa/uitest/impress_tests2/tdf91762.py index 2b3282413e15..e36baec62094 100644 --- a/sd/qa/uitest/impress_tests2/tdf91762.py +++ b/sd/qa/uitest/impress_tests2/tdf91762.py @@ -25,7 +25,7 @@ class tdf91762(UITestCase): self.assertEqual('5', get_state_as_dict(xDialog.getChild('columns'))['Text']) self.assertEqual('2', get_state_as_dict(xDialog.getChild('rows'))['Text']) - self.assertEqual(1929, document.DrawPages[0].getByIndex(1).BoundRect.Height) + self.assertEqual(1961, document.DrawPages[0].getByIndex(1).BoundRect.Height) self.assertEqual(25198, document.DrawPages[0].getByIndex(1).Size.Width) self.assertEqual(1923, document.DrawPages[0].getByIndex(1).Size.Height) @@ -38,9 +38,8 @@ class tdf91762(UITestCase): xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - # tdf#138011: Without the fix in place, this test would have failed with - # AssertionError: 5504 != 3559 - self.assertEqual(5504, document.DrawPages[0].getByIndex(1).BoundRect.Height) + # tdf#138011: Without the fix in place, it will be much lower + self.assertEqual(5466, document.DrawPages[0].getByIndex(1).BoundRect.Height) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 0b8898e3095b..6791f4c64878 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -18,10 +18,14 @@ */ #include +#include #include #include #include +#include +#include +#include #include #include #include @@ -31,6 +35,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include @@ -593,63 +602,28 @@ void SdDrawDocument::CreateLayoutTemplates() pSSPool->CreateLayoutStyleSheets(aPrefix); } -static Any implMakeSolidCellStyle( SdStyleSheetPool* pSSPool, const OUString& rName, const OUString& rParent, const Color& rColor ) -{ - SfxStyleSheetBase* pSheet = &(pSSPool->Make(rName, SfxStyleFamily::Frame, SfxStyleSearchBits::Auto)); - pSheet->SetParent(rParent); - SfxItemSet* pISet = &pSheet->GetItemSet(); - pISet->Put(XFillStyleItem(drawing::FillStyle_SOLID)); - pISet->Put(XFillColorItem(OUString(), rColor)); - - return Any( Reference< XStyle >( static_cast< XWeak* >( pSheet ), UNO_QUERY ) ); -} - -static void implCreateTableTemplate( const Reference< XNameContainer >& xTableFamily, const OUString& rName, const Any& rBody, const Any& rHeading, const Any& rBanding ) -{ - if( !xTableFamily.is() ) - return; - - try - { - if( !xTableFamily->hasByName( rName ) ) - { - Reference< XSingleServiceFactory > xFactory( xTableFamily, UNO_QUERY_THROW ); - Reference< XNameReplace > xDefaultTableStyle( xFactory->createInstance(), UNO_QUERY_THROW ); - xTableFamily->insertByName( rName, Any( xDefaultTableStyle ) ); - - xDefaultTableStyle->replaceByName( "body", rBody ); - xDefaultTableStyle->replaceByName( "odd-rows" , rBanding ); - xDefaultTableStyle->replaceByName( "odd-columns" , rBanding ); - xDefaultTableStyle->replaceByName( "first-row" , rHeading ); - xDefaultTableStyle->replaceByName( "first-column" , rHeading ); - xDefaultTableStyle->replaceByName( "last-row" , rHeading ); - xDefaultTableStyle->replaceByName( "last-column" , rHeading ); - } - } - catch( Exception& ) - { - TOOLS_WARN_EXCEPTION( "sd", "sd::implCreateTableTemplate()"); - } -} - void SdDrawDocument::CreateDefaultCellStyles() { - SdStyleSheetPool* pSSPool = static_cast< SdStyleSheetPool* >(GetStyleSheetPool()); - SfxStyleSheetBase* pSheet = nullptr; + Reference xContext(comphelper::getProcessComponentContext()); + Reference xImporter(xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.comp.Draw.XMLOasisStylesImporter", + { Any(comphelper::makePropertyValue("OrganizerMode", true)) }, xContext), UNO_QUERY); + if (xImporter) + xImporter->setTargetDocument(mpDocSh->GetModel()); - Reference< XNameContainer > xTableFamily( pSSPool->getByName( "table" ), UNO_QUERY ); + OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/config/soffice.cfg/simpress/styles.xml"); + rtl::Bootstrap::expandMacros(aURL); + SvFileStream aFile(aURL, StreamMode::READ); + Reference xInputStream(new utl::OInputStreamWrapper(aFile)); - // ---- Default ----------------------------------------------- - - OUString aDefaultCellStyleName( "default" ); - - pSheet = &(pSSPool->Make(aDefaultCellStyleName, SfxStyleFamily::Frame, SfxStyleSearchBits::Auto)); - pSheet->SetHelpId( OUString(), HID_SD_CELL_STYLE_DEFAULT ); - SfxItemSet& rISet = pSheet->GetItemSet(); - - rISet.Put(XFillStyleItem(drawing::FillStyle_SOLID)); - rISet.Put(XFillColorItem(OUString(), Color(0x00ccccff))); + css::xml::sax::InputSource aParserInput; + aParserInput.sPublicId = aURL; + aParserInput.aInputStream = xInputStream; + Reference xFastParser(xImporter, UNO_QUERY); + if (xFastParser) + xFastParser->parseStream(aParserInput); + // Set default fonts, if they were not defined in the xml. vcl::Font aLatinFont, aCJKFont, aCTLFont; getDefaultFonts( aLatinFont, aCJKFont, aCTLFont ); @@ -663,131 +637,28 @@ void SdDrawDocument::CreateDefaultCellStyles() SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamilyType(), aCTLFont.GetFamilyName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(), aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL ); - rISet.Put( aSvxFontItem ); - rISet.Put( aSvxFontItemCJK ); - rISet.Put( aSvxFontItemCTL ); + SdStyleSheetPool* pSSPool = static_cast(GetStyleSheetPool()); + SfxStyleSheetBase* pDefaultStyle = pSSPool->Find("default", SfxStyleFamily::Frame); + if (pDefaultStyle) + { + SfxItemSet& rSet(pDefaultStyle->GetItemSet()); + if (!rSet.HasItem(EE_CHAR_FONTINFO)) + rSet.Put(aSvxFontItem); + if (!rSet.HasItem(EE_CHAR_FONTINFO_CJK)) + rSet.Put(aSvxFontItemCJK); + if (!rSet.HasItem(EE_CHAR_FONTINFO_CTL)) + rSet.Put(aSvxFontItemCTL); + } - rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT ) ); // sj: (i33745) changed default from 24 to 18 pt - rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 18 pt - rISet.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 18 pt + // Reset the user defined flag. + SfxStyleSheetBase* pSheet = pSSPool->First(SfxStyleFamily::Frame); + while (pSheet) + { + pSheet->SetMask(SfxStyleSearchBits::Auto); + pSheet = pSSPool->Next(); + } - rISet.Put(SvxColorItem(COL_AUTO, EE_CHAR_COLOR )); - - // Paragraph attributes (Edit Engine) - rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE)); - rISet.Put(SvxULSpaceItem(EE_PARA_ULSPACE)); - - rISet.Put( makeSdrTextLeftDistItem( 250 ) ); - rISet.Put( makeSdrTextRightDistItem( 250 ) ); - rISet.Put( makeSdrTextUpperDistItem( 130 ) ); - rISet.Put( makeSdrTextLowerDistItem( 130 ) ); - - rISet.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL ) ); - rISet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); - rISet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) ); - rISet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT) ); - - Color aWhite( COL_WHITE ); - ::editeng::SvxBorderLine aBorderLine( - &aWhite, 1, SvxBorderLineStyle::SOLID); - - SvxBoxItem aBoxItem( SDRATTR_TABLE_BORDER ); - aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::TOP ); - aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::BOTTOM ); - aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::LEFT ); - aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::RIGHT ); - - rISet.Put( aBoxItem ); - - // ---- default -------------------------------------------------- - - Any aGray1( implMakeSolidCellStyle( pSSPool, "gray1" , aDefaultCellStyleName, Color(230,230,230))); - Any aGray2( implMakeSolidCellStyle( pSSPool, "gray2" , aDefaultCellStyleName, Color(204,204,204))); - Any aGray3( implMakeSolidCellStyle( pSSPool, "gray3" , aDefaultCellStyleName, Color(179,179,179))); - - implCreateTableTemplate( xTableFamily, "default" , aGray1, aGray3, aGray2 ); - - // ---- BW ------------------------------------------------ - - Any aBW1( implMakeSolidCellStyle( pSSPool, "bw1" , aDefaultCellStyleName, Color(255,255,255))); - Any aBW2( implMakeSolidCellStyle( pSSPool, "bw2" , aDefaultCellStyleName, Color(230,230,230))); - Any aBW3( implMakeSolidCellStyle( pSSPool, "bw3" , aDefaultCellStyleName, Color(0,0,0))); - - implCreateTableTemplate( xTableFamily, "bw" , aBW1, aBW3, aBW2 ); - - // ---- Orange -------------------------------------------------- - - Any aOrange1( implMakeSolidCellStyle( pSSPool, "orange1" , aDefaultCellStyleName, Color(255,204,153))); - Any aOrange2( implMakeSolidCellStyle( pSSPool, "orange2" , aDefaultCellStyleName, Color(255,153,102))); - Any aOrange3( implMakeSolidCellStyle( pSSPool, "orange3" , aDefaultCellStyleName, Color(255,102,51))); - - implCreateTableTemplate( xTableFamily, "orange" , aOrange1, aOrange3, aOrange2 ); - - // ---- Turquoise -------------------------------------------------- - - Any aTurquoise1( implMakeSolidCellStyle( pSSPool, "turquoise1" , aDefaultCellStyleName, Color(71,184,184))); - Any aTurquoise2( implMakeSolidCellStyle( pSSPool, "turquoise2" , aDefaultCellStyleName, Color(51,163,163))); - Any aTurquoise3( implMakeSolidCellStyle( pSSPool, "turquoise3" , aDefaultCellStyleName, Color(25,138,138))); - - implCreateTableTemplate( xTableFamily, "turquoise" , aTurquoise1, aTurquoise3, aTurquoise2 ); - - // ---- Gray ------------------------------------------------ - - Any aBlue1( implMakeSolidCellStyle( pSSPool, "blue1" , aDefaultCellStyleName, Color(153,204,255))); - Any aBlue2( implMakeSolidCellStyle( pSSPool, "blue2" , aDefaultCellStyleName, Color(0,153,255))); - Any aBlue3( implMakeSolidCellStyle( pSSPool, "blue3" , aDefaultCellStyleName, Color(0,102,204))); - - implCreateTableTemplate( xTableFamily, "blue" , aBlue1, aBlue3, aBlue2 ); - - // ---- Sun ------------------------------------------------ - - Any aSun1( implMakeSolidCellStyle( pSSPool, "sun1" , aDefaultCellStyleName, Color(230,230,255))); - Any aSun2( implMakeSolidCellStyle( pSSPool, "sun2" , aDefaultCellStyleName, Color(204,204,255))); - Any aSun3( implMakeSolidCellStyle( pSSPool, "sun3" , aDefaultCellStyleName, Color(153,153,255))); - - implCreateTableTemplate( xTableFamily, "sun" , aSun1, aSun3, aSun2 ); - - // ---- Earth ---------------------------------------------- - - Any aEarth1( implMakeSolidCellStyle( pSSPool, "earth1" , aDefaultCellStyleName, Color(255,255,204))); - Any aEarth2( implMakeSolidCellStyle( pSSPool, "earth2" , aDefaultCellStyleName, Color(255,204,153))); - Any aEarth3( implMakeSolidCellStyle( pSSPool, "earth3" , aDefaultCellStyleName, Color(204,102,51))); - - implCreateTableTemplate( xTableFamily, "earth" , aEarth1, aEarth3, aEarth2 ); - - // ---- Green ---------------------------------------------- - - Any aGreen1( implMakeSolidCellStyle( pSSPool, "green1" , aDefaultCellStyleName, Color(255,255,204))); - Any aGreen2( implMakeSolidCellStyle( pSSPool, "green2" , aDefaultCellStyleName, Color(148,189,94))); - Any aGreen3( implMakeSolidCellStyle( pSSPool, "green3" , aDefaultCellStyleName, Color(92,133,38))); - - implCreateTableTemplate( xTableFamily, "green" , aGreen1, aGreen3, aGreen2 ); - - // ---- Seaweed ---------------------------------------------- - - Any aSeetang1( implMakeSolidCellStyle( pSSPool, "seetang1" , aDefaultCellStyleName, Color(204,255,255))); - Any aSeetang2( implMakeSolidCellStyle( pSSPool, "seetang2" , aDefaultCellStyleName, Color(71,184,184))); - Any aSeetang3( implMakeSolidCellStyle( pSSPool, "seetang3" , aDefaultCellStyleName, Color(51,163,163))); - - implCreateTableTemplate( xTableFamily, "seetang" , aSeetang1, aSeetang3, aSeetang2 ); - - // ---- LightBlue ---------------------------------------------- - - Any aLightBlue1( implMakeSolidCellStyle( pSSPool, "lightblue1" , aDefaultCellStyleName, Color(255,255,255))); - Any aLightBlue2( implMakeSolidCellStyle( pSSPool, "lightblue2" , aDefaultCellStyleName, Color(230,230,255))); - Any aLightBlue3( implMakeSolidCellStyle( pSSPool, "lightblue3" , aDefaultCellStyleName, Color(153,153,204))); - - implCreateTableTemplate( xTableFamily, "lightblue" , aLightBlue1, aLightBlue3, aLightBlue2 ); - - // ---- Yellow ---------------------------------------------- - - Any aYellow1( implMakeSolidCellStyle( pSSPool, "yellow1" , aDefaultCellStyleName, Color(255,255,204))); - Any aYellow2( implMakeSolidCellStyle( pSSPool, "yellow2" , aDefaultCellStyleName, Color(255,255,153))); - Any aYellow3( implMakeSolidCellStyle( pSSPool, "yellow3" , aDefaultCellStyleName, Color(255,204,153))); - - implCreateTableTemplate( xTableFamily, "yellow" , aYellow1, aYellow3, aYellow2 ); - - Reference xReset(xTableFamily, UNO_QUERY); + Reference xReset(pSSPool->getByName("table"), UNO_QUERY); if (xReset) xReset->reset(); } diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index 82cb59228958..79f07b0b614a 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -973,13 +973,6 @@ void SdStyleSheetPool::UpdateStdNames() case HID_PSEUDOSHEET_BACKGROUND: pNameId = STR_PSEUDOSHEET_BACKGROUND; break; case HID_PSEUDOSHEET_NOTES: pNameId = STR_PSEUDOSHEET_NOTES; break; - case HID_SD_CELL_STYLE_DEFAULT: pNameId = STR_STANDARD_STYLESHEET_NAME; break; - case HID_SD_CELL_STYLE_BANDED: pNameId = STR_POOLSHEET_BANDED_CELL; break; - case HID_SD_CELL_STYLE_HEADER: pNameId = STR_POOLSHEET_HEADER; break; - case HID_SD_CELL_STYLE_TOTAL: pNameId = STR_POOLSHEET_TOTAL; break; - case HID_SD_CELL_STYLE_FIRST_COLUMN: pNameId = STR_POOLSHEET_FIRST_COLUMN; break; - case HID_SD_CELL_STYLE_LAST_COLUMN: pNameId = STR_POOLSHEET_LAST_COLUMN; break; - default: // 0 or wrong (old) HelpId bHelpKnown = false; diff --git a/sd/xml/styles.xml b/sd/xml/styles.xml new file mode 100644 index 000000000000..3b16d5ec7b2f --- /dev/null +++ b/sd/xml/styles.xml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/svx/source/table/tabledesign.cxx b/svx/source/table/tabledesign.cxx index 7c097199f9e9..d7ac0a474310 100644 --- a/svx/source/table/tabledesign.cxx +++ b/svx/source/table/tabledesign.cxx @@ -813,7 +813,11 @@ void TableDesignFamily::removeVetoableChangeListener( const OUString& , const Re void TableDesignFamily::reset() { for (const auto& aDesign : maDesigns) - static_cast(aDesign.get())->resetUserDefined(); + { + auto aStyle = static_cast(aDesign.get()); + aStyle->resetUserDefined(); + aStyle->setModified(false); + } } void TableDesignFamily::addResetListener( const Reference& ) diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 6ffc7140531e..6e556ac84a31 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -333,6 +333,9 @@ void SAL_CALL SdXMLImport::setTargetDocument( const uno::Reference< lang::XCompo if(xFamSup.is()) mxDocStyleFamilies = xFamSup->getStyleFamilies(); + if (!mbLoadDoc) + return; + // prepare access to master pages uno::Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), uno::UNO_QUERY); if(xMasterPagesSupplier.is()) @@ -372,6 +375,16 @@ void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen { SvXMLImport::initialize( aArguments ); + OUString const sOrganizerMode("OrganizerMode"); + bool bStyleOnly(false); + + css::beans::PropertyValue aPropValue; + if (aArguments.hasElements() && (aArguments[0] >>= aPropValue) && aPropValue.Name == sOrganizerMode) + { + aPropValue.Value >>= bStyleOnly; + mbLoadDoc = !bStyleOnly; + } + uno::Reference< beans::XPropertySet > xInfoSet( getImportInfo() ); if( !xInfoSet.is() ) return; @@ -384,11 +397,8 @@ void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen if( xInfoSetInfo->hasPropertyByName( gsPreview ) ) xInfoSet->getPropertyValue( gsPreview ) >>= mbPreview; - OUString const sOrganizerMode( - "OrganizerMode"); if (xInfoSetInfo->hasPropertyByName(sOrganizerMode)) { - bool bStyleOnly(false); if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly) { mbLoadDoc = !bStyleOnly; @@ -419,6 +429,11 @@ SvXMLImportContext *SdXMLImport::CreateFastContext( sal_Int32 nElement, pContext = new SdXMLFlatDocContext_Impl( *this, xDPS->getDocumentProperties()); } break; + case XML_ELEMENT( OFFICE, XML_STYLES ): + // internal xml file for built in styles + if (!mbLoadDoc) + pContext = CreateStylesContext(); + break; } return pContext; } diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx index 86b19e768e16..afc86cf4000c 100644 --- a/xmloff/source/table/XMLTableImport.cxx +++ b/xmloff/source/table/XMLTableImport.cxx @@ -285,12 +285,16 @@ void XMLTableImport::addTableTemplate( const OUString& rsStyleName, XMLTableTemp { auto xPtr = std::make_shared(); xPtr->swap( xTableTemplate ); - maTableTemplates[rsStyleName] = xPtr; + maTableTemplates.emplace_back(rsStyleName, xPtr); } void XMLTableImport::insertTabletemplate(const OUString& rsStyleName, bool bOverwrite) { - XMLTableTemplateMap::iterator it = maTableTemplates.find(rsStyleName); + // FIXME: All templates will be inserted eventually, but + // instead of simply iterating them, like in finishStyles(), + // we search here by name again and again. + auto it = std::find_if(maTableTemplates.begin(), maTableTemplates.end(), + [&rsStyleName](const auto& item) { return rsStyleName == item.first; }); if (it == maTableTemplates.end()) return;