From 4e98ba4ba5c17ab8ae1170662af645b9d2bfde84 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 7 May 2020 18:18:43 +0200 Subject: tdf#103602 xmloff,sw: ODF 1.3 import: PageStyle with drawing-page style Associate a style of family "drawing-page" with a style:master-page. This fixes the small part of the draw:fill attribute problem that is covered by OFFICE-3937 in ODF 1.3. This is the import part. Change-Id: I4c86fa24c36407b64ce33f0890e5da8c26c5292a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93670 Tested-by: Jenkins Reviewed-by: Michael Stahl --- xmloff/inc/PageMasterImportContext.hxx | 4 ++ xmloff/inc/PageMasterPropHdlFactory.hxx | 36 ++++++++++ xmloff/inc/PageMasterPropMapper.hxx | 36 ++++++++++ xmloff/inc/PageMasterStyleMap.hxx | 1 + xmloff/source/draw/ximpstyl.cxx | 88 ++++++++++++++---------- xmloff/source/style/PageMasterImportContext.cxx | 40 ++++++++++- xmloff/source/style/PageMasterPropHdlFactory.cxx | 2 +- xmloff/source/style/PageMasterPropHdlFactory.hxx | 37 ---------- xmloff/source/style/PageMasterPropMapper.cxx | 4 +- xmloff/source/style/PageMasterPropMapper.hxx | 37 ---------- xmloff/source/style/PageMasterStyleMap.cxx | 30 ++++++++ xmloff/source/style/XMLPageExport.cxx | 4 +- xmloff/source/style/prstylei.cxx | 3 +- xmloff/source/style/xmlstyle.cxx | 2 +- xmloff/source/text/XMLTextMasterPageContext.cxx | 28 ++++++-- xmloff/source/text/txtimp.cxx | 24 +++++++ 16 files changed, 250 insertions(+), 126 deletions(-) create mode 100644 xmloff/inc/PageMasterPropHdlFactory.hxx create mode 100644 xmloff/inc/PageMasterPropMapper.hxx delete mode 100644 xmloff/source/style/PageMasterPropHdlFactory.hxx delete mode 100644 xmloff/source/style/PageMasterPropMapper.hxx (limited to 'xmloff') diff --git a/xmloff/inc/PageMasterImportContext.hxx b/xmloff/inc/PageMasterImportContext.hxx index caeb2769c726..66933da8c172 100644 --- a/xmloff/inc/PageMasterImportContext.hxx +++ b/xmloff/inc/PageMasterImportContext.hxx @@ -48,8 +48,12 @@ public: const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + // don't call this virtual void FillPropertySet( const css::uno::Reference< css::beans::XPropertySet > & rPropSet ) override; + void FillPropertySet_PageStyle( + const css::uno::Reference< css::beans::XPropertySet > & rPropSet, + XMLPropStyleContext * pDrawingPageStyle); //text grid enhancement virtual void SetDefaults() override; diff --git a/xmloff/inc/PageMasterPropHdlFactory.hxx b/xmloff/inc/PageMasterPropHdlFactory.hxx new file mode 100644 index 000000000000..e8a4f8c83801 --- /dev/null +++ b/xmloff/inc/PageMasterPropHdlFactory.hxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_XMLOFF_SOURCE_STYLE_PAGEMASTERPROPHDLFACTORY_HXX +#define INCLUDED_XMLOFF_SOURCE_STYLE_PAGEMASTERPROPHDLFACTORY_HXX + +#include + +class XMLPageMasterPropHdlFactory : public XMLPropertyHandlerFactory +{ +public: + XMLPageMasterPropHdlFactory(); + virtual ~XMLPageMasterPropHdlFactory() override; + + virtual const XMLPropertyHandler* GetPropertyHandler(sal_Int32 nType) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/inc/PageMasterPropMapper.hxx b/xmloff/inc/PageMasterPropMapper.hxx new file mode 100644 index 000000000000..fc054b2f167a --- /dev/null +++ b/xmloff/inc/PageMasterPropMapper.hxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_XMLOFF_SOURCE_STYLE_PAGEMASTERPROPMAPPER_HXX +#define INCLUDED_XMLOFF_SOURCE_STYLE_PAGEMASTERPROPMAPPER_HXX + +#include + +class XMLPageMasterPropSetMapper : public XMLPropertySetMapper +{ +public: + explicit XMLPageMasterPropSetMapper(); + XMLPageMasterPropSetMapper(const XMLPropertyMapEntry* pEntries, + const rtl::Reference& rFactory); + virtual ~XMLPageMasterPropSetMapper() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/inc/PageMasterStyleMap.hxx b/xmloff/inc/PageMasterStyleMap.hxx index 2230cfacb7d9..a57acded8f9d 100644 --- a/xmloff/inc/PageMasterStyleMap.hxx +++ b/xmloff/inc/PageMasterStyleMap.hxx @@ -187,6 +187,7 @@ #define CTF_PM_FTN_LINE_STYLE (XML_PM_CTF_START + 0x0067) extern const XMLPropertyMapEntry aXMLPageMasterStyleMap[]; +extern const XMLPropertyMapEntry g_XMLPageMasterDrawingPageStyleMap[]; extern const XMLPropertyMapEntry aXMLPageMasterHeaderImportStyleMap[]; extern const XMLPropertyMapEntry aXMLPageMasterFooterImportStyleMap[]; diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index e43639752d70..b0968f1b6612 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -19,6 +19,7 @@ #include "ximpstyl.hxx" #include +#include #include #include #include @@ -129,7 +130,8 @@ SvXMLImportContextRef SdXMLDrawingPagePropertySetContext::CreateChildContext( namespace { -class SdXMLDrawingPageStyleContext : public XMLPropStyleContext + +class SdXMLDrawingPageStyleContext : public XMLDrawingPageStyleContext { public: @@ -138,8 +140,7 @@ public: sal_uInt16 nPrfx, const OUString& rLName, const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList, - SvXMLStylesContext& rStyles, - XmlStyleFamily nFamily = XmlStyleFamily::SD_DRAWINGPAGE_ID); + SvXMLStylesContext& rStyles); SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, @@ -147,21 +148,58 @@ public: const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; virtual void Finish( bool bOverwrite ) override; +}; - // #i35918# - virtual void FillPropertySet( const css::uno::Reference< css::beans::XPropertySet > & rPropSet ) override; +static const sal_uInt16 MAX_SPECIAL_DRAW_STYLES = 7; +static ContextID_Index_Pair const g_ContextIDs[MAX_SPECIAL_DRAW_STYLES+1] = +{ + { CTF_DASHNAME , -1 }, + { CTF_LINESTARTNAME , -1 }, + { CTF_LINEENDNAME , -1 }, + { CTF_FILLGRADIENTNAME, -1 }, + { CTF_FILLTRANSNAME , -1 }, + { CTF_FILLHATCHNAME , -1 }, + { CTF_FILLBITMAPNAME , -1 }, + { -1, -1 } +}; +static XmlStyleFamily const g_Families[MAX_SPECIAL_DRAW_STYLES] = +{ + XmlStyleFamily::SD_STROKE_DASH_ID, + XmlStyleFamily::SD_MARKER_ID, + XmlStyleFamily::SD_MARKER_ID, + XmlStyleFamily::SD_GRADIENT_ID, + XmlStyleFamily::SD_GRADIENT_ID, + XmlStyleFamily::SD_HATCH_ID, + XmlStyleFamily::SD_FILL_IMAGE_ID }; } +XMLDrawingPageStyleContext::XMLDrawingPageStyleContext( + SvXMLImport& rImport, + sal_uInt16 const nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + SvXMLStylesContext& rStyles, + ContextID_Index_Pair const pContextIDs[], + XmlStyleFamily const pFamilies[]) + : XMLPropStyleContext(rImport, nPrefix, rLName, xAttrList, rStyles, XmlStyleFamily::SD_DRAWINGPAGE_ID) + , m_pFamilies(pFamilies) +{ + size_t size(1); // for the -1 entry + for (ContextID_Index_Pair const* pTemp(pContextIDs); pTemp->nContextID != -1; ++size, ++pTemp); + m_pContextIDs.reset(new ContextID_Index_Pair[size]); + std::memcpy(m_pContextIDs.get(), pContextIDs, size * sizeof(ContextID_Index_Pair)); +} + SdXMLDrawingPageStyleContext::SdXMLDrawingPageStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const uno::Reference< xml::sax::XAttributeList >& xAttrList, - SvXMLStylesContext& rStyles, - XmlStyleFamily nFamily) -: XMLPropStyleContext(rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ) + SvXMLStylesContext& rStyles) + : XMLDrawingPageStyleContext(rImport, nPrfx, rLName, xAttrList, rStyles, + g_ContextIDs, g_Families) { } @@ -229,49 +267,27 @@ void SdXMLDrawingPageStyleContext::Finish( bool bOverwrite ) } + // #i35918# -void SdXMLDrawingPageStyleContext::FillPropertySet( +void XMLDrawingPageStyleContext::FillPropertySet( const Reference< beans::XPropertySet > & rPropSet ) { - static const sal_uInt16 MAX_SPECIAL_DRAW_STYLES = 7; - struct ContextID_Index_Pair aContextIDs[MAX_SPECIAL_DRAW_STYLES+1] = - { - { CTF_DASHNAME , -1 }, - { CTF_LINESTARTNAME , -1 }, - { CTF_LINEENDNAME , -1 }, - { CTF_FILLGRADIENTNAME, -1 }, - { CTF_FILLTRANSNAME , -1 }, - { CTF_FILLHATCHNAME , -1 }, - { CTF_FILLBITMAPNAME , -1 }, - { -1, -1 } - }; - static const XmlStyleFamily aFamilies[MAX_SPECIAL_DRAW_STYLES] = - { - XmlStyleFamily::SD_STROKE_DASH_ID, - XmlStyleFamily::SD_MARKER_ID, - XmlStyleFamily::SD_MARKER_ID, - XmlStyleFamily::SD_GRADIENT_ID, - XmlStyleFamily::SD_GRADIENT_ID, - XmlStyleFamily::SD_HATCH_ID, - XmlStyleFamily::SD_FILL_IMAGE_ID - }; - rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() ); SAL_WARN_IF( !xImpPrMap.is(), "xmloff", "There is the import prop mapper" ); if( xImpPrMap.is() ) - xImpPrMap->FillPropertySet( GetProperties(), rPropSet, aContextIDs ); + xImpPrMap->FillPropertySet(GetProperties(), rPropSet, m_pContextIDs.get()); Reference< beans::XPropertySetInfo > xInfo; - for( sal_uInt16 i=0; i>= sStyleName; - sStyleName = GetImport().GetStyleDisplayName( aFamilies[i], + sStyleName = GetImport().GetStyleDisplayName( m_pFamilies[i], sStyleName ); // get property set mapper rtl::Reference rPropMapper = diff --git a/xmloff/source/style/PageMasterImportContext.cxx b/xmloff/source/style/PageMasterImportContext.cxx index 0e622258977b..a30fafb712a5 100644 --- a/xmloff/source/style/PageMasterImportContext.cxx +++ b/xmloff/source/style/PageMasterImportContext.cxx @@ -34,6 +34,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::xmloff::token; @@ -158,7 +159,14 @@ SvXMLImportContextRef PageStyleContext::CreateChildContext( return XMLPropStyleContext::CreateChildContext(nPrefix, rLocalName, xAttrList); } -void PageStyleContext::FillPropertySet(const uno::Reference & rPropSet) +void PageStyleContext::FillPropertySet(const uno::Reference &) +{ + assert(false); // dont call this virtual, call function below +} + +void PageStyleContext::FillPropertySet_PageStyle( + const uno::Reference & rPropSet, + XMLPropStyleContext *const pDrawingPageStyle) { // need to filter out old fill definitions when the new ones are used. The new // ones are used when a FillStyle is defined @@ -168,7 +176,9 @@ void PageStyleContext::FillPropertySet(const uno::ReferencedoNewDrawingLayerFillStyleDefinitionsExist(s_FillStyle))) { deactivateOldFillStyleDefinitions(getStandardSet()); } @@ -296,6 +306,12 @@ void PageStyleContext::FillPropertySet(const uno::ReferenceFillPropertySet(rPropSet); + } + // old code, replaced by above stuff // XMLPropStyleContext::FillPropertySet(rPropSet); @@ -308,6 +324,24 @@ void PageStyleContext::FillPropertySet(const uno::Reference xInt = xFactory->createInstance( "com.sun.star.text.Defaults" ); Reference < beans::XPropertySet > xProperties ( xInt, UNO_QUERY ); if ( xProperties.is() ) - FillPropertySet ( xProperties ); + FillPropertySet_PageStyle(xProperties, nullptr); } } diff --git a/xmloff/source/style/PageMasterPropHdlFactory.cxx b/xmloff/source/style/PageMasterPropHdlFactory.cxx index 6f40f439307a..ae61a3026874 100644 --- a/xmloff/source/style/PageMasterPropHdlFactory.cxx +++ b/xmloff/source/style/PageMasterPropHdlFactory.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "PageMasterPropHdlFactory.hxx" +#include #include #include #include diff --git a/xmloff/source/style/PageMasterPropHdlFactory.hxx b/xmloff/source/style/PageMasterPropHdlFactory.hxx deleted file mode 100644 index b5852e7b9101..000000000000 --- a/xmloff/source/style/PageMasterPropHdlFactory.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- 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 . - */ - -#ifndef INCLUDED_XMLOFF_SOURCE_STYLE_PAGEMASTERPROPHDLFACTORY_HXX -#define INCLUDED_XMLOFF_SOURCE_STYLE_PAGEMASTERPROPHDLFACTORY_HXX - -#include - -class XMLPageMasterPropHdlFactory : public XMLPropertyHandlerFactory -{ -public: - XMLPageMasterPropHdlFactory(); - virtual ~XMLPageMasterPropHdlFactory() override; - - virtual const XMLPropertyHandler* - GetPropertyHandler( sal_Int32 nType ) const override; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/PageMasterPropMapper.cxx b/xmloff/source/style/PageMasterPropMapper.cxx index c741632ad9dd..c792ff0a0eb0 100644 --- a/xmloff/source/style/PageMasterPropMapper.cxx +++ b/xmloff/source/style/PageMasterPropMapper.cxx @@ -17,11 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "PageMasterPropMapper.hxx" +#include #include #include -#include "PageMasterPropHdlFactory.hxx" +#include #include diff --git a/xmloff/source/style/PageMasterPropMapper.hxx b/xmloff/source/style/PageMasterPropMapper.hxx deleted file mode 100644 index bd1c9ab25f7b..000000000000 --- a/xmloff/source/style/PageMasterPropMapper.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- 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 . - */ - -#ifndef INCLUDED_XMLOFF_SOURCE_STYLE_PAGEMASTERPROPMAPPER_HXX -#define INCLUDED_XMLOFF_SOURCE_STYLE_PAGEMASTERPROPMAPPER_HXX - -#include - -class XMLPageMasterPropSetMapper : public XMLPropertySetMapper -{ -public: - explicit XMLPageMasterPropSetMapper(); - XMLPageMasterPropSetMapper( - const XMLPropertyMapEntry* pEntries, - const rtl::Reference< XMLPropertyHandlerFactory >& rFactory ); - virtual ~XMLPageMasterPropSetMapper() override; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/PageMasterStyleMap.cxx b/xmloff/source/style/PageMasterStyleMap.cxx index 9229b38de7df..7ab1b46f9d2b 100644 --- a/xmloff/source/style/PageMasterStyleMap.cxx +++ b/xmloff/source/style/PageMasterStyleMap.cxx @@ -24,6 +24,7 @@ using namespace ::xmloff::token; #define MAP(name,prefix,token,type,context,version) { name, sizeof(name)-1, prefix, token, type, context, version, false } +#define DPMAP(name,prefix,token,type,context) MAP(name, prefix, token, type|XML_TYPE_PROP_DRAWING_PAGE, context, SvtSaveOptions::ODFSVER_013) #define PLMAP(name,prefix,token,type,context) \ MAP(name, prefix, token, type|XML_TYPE_PROP_PAGE_LAYOUT, context, SvtSaveOptions::ODFSVER_010) #define PLMAP_12(name,prefix,token,type,context) \ @@ -121,6 +122,7 @@ const XMLPropertyMapEntry aXMLPageMasterStyleMap[] = // Also need own defines for the used context flags (e.g. CTF_PM_FILLGRADIENTNAME instead of // CTF_FILLGRADIENTNAME) since these are used to *filter* up to which entry the attributes belong to the // 'page-layout-properties' section (!), see SvXMLAutoStylePoolP_Impl::exportXML, look for XmlStyleFamily::PAGE_MASTER + // note: these are duplicated below, in g_XMLPageMasterDrawingPageStyleMap PLMAP( "FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SW_TYPE_FILLSTYLE, 0 ), PLMAP( "FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, 0 ), PLMAP( "FillColor2", XML_NAMESPACE_DRAW, XML_SECONDARY_FILL_COLOR, XML_TYPE_COLOR, 0 ), @@ -267,4 +269,32 @@ const XMLPropertyMapEntry aXMLPageMasterStyleMap[] = { nullptr, 0, 0, XML_EMPTY, 0, 0, SvtSaveOptions::ODFSVER_010, false } // index 190 }; +XMLPropertyMapEntry const g_XMLPageMasterDrawingPageStyleMap[] = +{ + // ODF 1.3 OFFICE-3937 style of family "drawing-page" referenced from style:master-page + // duplication of relevant part of aXMLPageMasterStyleMap but as DP type + DPMAP("FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SW_TYPE_FILLSTYLE, 0), + DPMAP("FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, 0), + DPMAP("FillColor2", XML_NAMESPACE_DRAW, XML_SECONDARY_FILL_COLOR, XML_TYPE_COLOR, 0), + DPMAP("FillGradientName", XML_NAMESPACE_DRAW, XML_FILL_GRADIENT_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_PM_FILLGRADIENTNAME), + DPMAP("FillGradientStepCount", XML_NAMESPACE_DRAW, XML_GRADIENT_STEP_COUNT, XML_TYPE_NUMBER16, 0), + DPMAP("FillHatchName", XML_NAMESPACE_DRAW, XML_FILL_HATCH_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_PM_FILLHATCHNAME), + DPMAP("FillBackground", XML_NAMESPACE_DRAW, XML_FILL_HATCH_SOLID, XML_TYPE_BOOL, 0), + DPMAP("FillBitmapName", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_PM_FILLBITMAPNAME), + DPMAP("FillTransparence", XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16|MID_FLAG_MULTI_PROPERTY, 0), /* exists in SW, too */ + DPMAP("FillTransparenceGradientName", XML_NAMESPACE_DRAW, XML_OPACITY_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_PM_FILLTRANSNAME), + DPMAP("FillBitmapSizeX", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_WIDTH, XML_SW_TYPE_FILLBITMAPSIZE|MID_FLAG_MULTI_PROPERTY, 0), + DPMAP("FillBitmapLogicalSize", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_WIDTH, XML_SW_TYPE_LOGICAL_SIZE|MID_FLAG_MULTI_PROPERTY, 0), + DPMAP("FillBitmapSizeY", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_HEIGHT, XML_SW_TYPE_FILLBITMAPSIZE|MID_FLAG_MULTI_PROPERTY, 0), + DPMAP("FillBitmapLogicalSize", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_HEIGHT, XML_SW_TYPE_LOGICAL_SIZE|MID_FLAG_MULTI_PROPERTY, 0), + DPMAP("FillBitmapMode", XML_NAMESPACE_STYLE, XML_REPEAT, XML_SW_TYPE_BITMAP_MODE|MID_FLAG_MULTI_PROPERTY, CTF_PM_FILLBITMAPMODE), + DPMAP("FillBitmapPositionOffsetX", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_REF_POINT_X, XML_TYPE_PERCENT, 0), + DPMAP("FillBitmapPositionOffsetY", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_REF_POINT_Y, XML_TYPE_PERCENT, 0), + DPMAP("FillBitmapRectanglePoint", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_REF_POINT, XML_SW_TYPE_BITMAP_REFPOINT, 0), + DPMAP("FillBitmapOffsetX", XML_NAMESPACE_DRAW, XML_TILE_REPEAT_OFFSET, XML_SW_TYPE_BITMAPREPOFFSETX|MID_FLAG_MULTI_PROPERTY, CTF_PM_REPEAT_OFFSET_X), + DPMAP("FillBitmapOffsetY", XML_NAMESPACE_DRAW, XML_TILE_REPEAT_OFFSET, XML_SW_TYPE_BITMAPREPOFFSETY|MID_FLAG_MULTI_PROPERTY, CTF_PM_REPEAT_OFFSET_Y), + + { nullptr, 0, 0, XML_EMPTY, 0, 0, SvtSaveOptions::ODFSVER_010, false } +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/XMLPageExport.cxx b/xmloff/source/style/XMLPageExport.cxx index f3b27b7d88f5..56f7bf7dae22 100644 --- a/xmloff/source/style/XMLPageExport.cxx +++ b/xmloff/source/style/XMLPageExport.cxx @@ -29,9 +29,9 @@ #include #include #include -#include "PageMasterPropHdlFactory.hxx" +#include #include -#include "PageMasterPropMapper.hxx" +#include #include "PageMasterExportPropMapper.hxx" using namespace ::com::sun::star; diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx index ce40f755e8c9..c005a38873f4 100644 --- a/xmloff/source/style/prstylei.cxx +++ b/xmloff/source/style/prstylei.cxx @@ -537,7 +537,8 @@ bool XMLPropStyleContext::doNewDrawingLayerFillStyleDefinitionsExist( { if(!maProperties.empty() && rFillStyleTag.getLength()) { - const rtl::Reference< XMLPropertySetMapper >& rMapper = GetStyles()->GetImportPropertyMapper(GetFamily())->getPropertySetMapper(); + // no & to avoid non-obvious UAF due to the 2nd temp Reference + const rtl::Reference rMapper = GetStyles()->GetImportPropertyMapper(GetFamily())->getPropertySetMapper(); if(rMapper.is()) { diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 2c4fe5f01912..d020280cb173 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -25,7 +25,7 @@ #include #include #include -#include "PageMasterPropMapper.hxx" +#include #include #include #include diff --git a/xmloff/source/text/XMLTextMasterPageContext.cxx b/xmloff/source/text/XMLTextMasterPageContext.cxx index cec7788ea1b0..13cb28ba98e6 100644 --- a/xmloff/source/text/XMLTextMasterPageContext.cxx +++ b/xmloff/source/text/XMLTextMasterPageContext.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -105,6 +106,11 @@ XMLTextMasterPageContext::XMLTextMasterPageContext( SvXMLImport& rImport, sPageMasterName = xAttrList->getValueByIndex( i ); } } + else if (XML_NAMESPACE_DRAW == nPrefix + && IsXMLToken(aLocalName, XML_STYLE_NAME)) + { + m_sDrawingPageStyle = xAttrList->getValueByIndex(i); + } } if( !sDisplayName.isEmpty() ) @@ -259,14 +265,24 @@ void XMLTextMasterPageContext::Finish( bool bOverwrite ) if( xStyle.is() && (IsNew() || bOverwrite) ) { Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY ); + XMLPropStyleContext * pDrawingPageStyle(nullptr); + if (!m_sDrawingPageStyle.isEmpty()) + { + pDrawingPageStyle = GetImport().GetTextImport()->FindDrawingPage(m_sDrawingPageStyle); + } + PageStyleContext * pPageLayout(nullptr); if( !sPageMasterName.isEmpty() ) { - XMLPropStyleContext* pStyle = - GetImport().GetTextImport()->FindPageMaster( sPageMasterName ); - if (pStyle) - { - pStyle->FillPropertySet(xPropSet); - } + pPageLayout = static_cast(GetImport().GetTextImport()->FindPageMaster(sPageMasterName)); + } + if (pPageLayout) + { + pPageLayout->FillPropertySet_PageStyle(xPropSet, pDrawingPageStyle); + } + else if (pDrawingPageStyle) + { + // don't need to care about old background attributes in this case + pDrawingPageStyle->FillPropertySet(xPropSet); } Reference < XNameContainer > xPageStyles = diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 99548a92887b..d59918c8a6e6 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -62,6 +62,9 @@ #include "XMLCalculationSettingsContext.hxx" #include +#include +#include +#include // XML import: reconstrution of assignment of paragraph style to outline levels (#i69629#) #include #include @@ -1098,6 +1101,15 @@ SvXMLImportPropertyMapper* return new XMLTextImportPropertyMapper( pPropMapper, rImport ); } +SvXMLImportPropertyMapper* +XMLTextImportHelper::CreateDrawingPageExtPropMapper(SvXMLImport& rImport) +{ + rtl::Reference const pFactory(new XMLPageMasterPropHdlFactory); + XMLPropertySetMapper *const pPropMapper( + new XMLPropertySetMapper(g_XMLPageMasterDrawingPageStyleMap, pFactory, false)); + return new SvXMLImportPropertyMapper(pPropMapper, rImport); +} + void XMLTextImportHelper::SetCursor( const Reference < XTextCursor > & rCursor ) { m_xImpl->m_xCursor.set(rCursor); @@ -2529,6 +2541,18 @@ XMLPropStyleContext* XMLTextImportHelper::FindPageMaster( return pStyle; } +XMLPropStyleContext * XMLTextImportHelper::FindDrawingPage(OUString const& rName) const +{ + if (!m_xImpl->m_xAutoStyles.is()) + { + return nullptr; + } + SvXMLStyleContext const* pStyle( + static_cast(m_xImpl->m_xAutoStyles.get())->FindStyleChildContext( + XmlStyleFamily::SD_DRAWINGPAGE_ID, rName, true)); + assert(pStyle == nullptr || dynamic_cast(pStyle) != nullptr); + return const_cast(static_cast(pStyle)); +} void XMLTextImportHelper::PushListContext() { -- cgit