summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-05-07 18:18:43 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-05-23 16:30:51 +0200
commitca9a719169fa444b5d82942ae1d5600fa0114002 (patch)
treedf31f449b817c2cd5ddf9f5572fa20aa6d796a94
parenta97cbe7221c0175a4a2d342e2d1a62b06af4e13a (diff)
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 <michael.stahl@cib.de> (cherry picked from commit 4e98ba4ba5c17ab8ae1170662af645b9d2bfde84) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94587 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--include/xmloff/PageMasterStyleMap.hxx1
-rw-r--r--include/xmloff/XMLDrawingPageStyleContext.hxx44
-rw-r--r--include/xmloff/XMLTextMasterPageContext.hxx6
-rw-r--r--include/xmloff/prstylei.hxx4
-rw-r--r--include/xmloff/txtimp.hxx2
-rw-r--r--include/xmloff/xmlimppr.hxx2
-rw-r--r--sw/qa/extras/odfexport/data/sw_hatch.odtbin0 -> 6560 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx10
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx11
-rw-r--r--xmloff/inc/PageMasterImportContext.hxx4
-rw-r--r--xmloff/inc/PageMasterPropHdlFactory.hxx (renamed from xmloff/source/style/PageMasterPropHdlFactory.hxx)7
-rw-r--r--xmloff/inc/PageMasterPropMapper.hxx (renamed from xmloff/source/style/PageMasterPropMapper.hxx)7
-rw-r--r--xmloff/source/draw/ximpstyl.cxx87
-rw-r--r--xmloff/source/style/PageMasterImportContext.cxx40
-rw-r--r--xmloff/source/style/PageMasterPropHdlFactory.cxx2
-rw-r--r--xmloff/source/style/PageMasterPropMapper.cxx4
-rw-r--r--xmloff/source/style/PageMasterStyleMap.cxx30
-rw-r--r--xmloff/source/style/XMLPageExport.cxx4
-rw-r--r--xmloff/source/style/prstylei.cxx3
-rw-r--r--xmloff/source/style/xmlstyle.cxx2
-rw-r--r--xmloff/source/text/XMLTextMasterPageContext.cxx28
-rw-r--r--xmloff/source/text/txtimp.cxx24
22 files changed, 260 insertions, 62 deletions
diff --git a/include/xmloff/PageMasterStyleMap.hxx b/include/xmloff/PageMasterStyleMap.hxx
index 2b6a1b373768..93ec45b52362 100644
--- a/include/xmloff/PageMasterStyleMap.hxx
+++ b/include/xmloff/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/include/xmloff/XMLDrawingPageStyleContext.hxx b/include/xmloff/XMLDrawingPageStyleContext.hxx
new file mode 100644
index 000000000000..d0593b408976
--- /dev/null
+++ b/include/xmloff/XMLDrawingPageStyleContext.hxx
@@ -0,0 +1,44 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <xmloff/prstylei.hxx>
+#include <xmloff/xmlimppr.hxx>
+#include <xmloff/families.hxx>
+#include <xmloff/dllapi.h>
+
+class XMLOFF_DLLPUBLIC XMLDrawingPageStyleContext : public XMLPropStyleContext
+{
+public:
+ XMLDrawingPageStyleContext(SvXMLImport& rImport, sal_uInt16 nPrefix, OUString const& rLocalName,
+ css::uno::Reference<css::xml::sax::XAttributeList> const& xAttrList,
+ SvXMLStylesContext& rStyles,
+ ContextID_Index_Pair const pContextIDs[],
+ sal_uInt16 const pFamilies[]);
+
+ virtual void
+ FillPropertySet(css::uno::Reference<css::beans::XPropertySet> const& rPropSet) override;
+
+private:
+ std::unique_ptr<ContextID_Index_Pair[]> m_pContextIDs;
+ sal_uInt16 const* const m_pFamilies;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/xmloff/XMLTextMasterPageContext.hxx b/include/xmloff/XMLTextMasterPageContext.hxx
index 70503a5cc631..659ac703ab8f 100644
--- a/include/xmloff/XMLTextMasterPageContext.hxx
+++ b/include/xmloff/XMLTextMasterPageContext.hxx
@@ -33,6 +33,7 @@ class XMLOFF_DLLPUBLIC XMLTextMasterPageContext : public SvXMLStyleContext
{
OUString sFollow;
OUString sPageMasterName;
+ OUString m_sDrawingPageStyle;
css::uno::Reference < css::style::XStyle > xStyle;
@@ -73,6 +74,11 @@ public:
virtual void Finish( bool bOverwrite ) override;
};
+struct ContextID_Index_Pair;
+
+XMLOFF_DLLPUBLIC extern ContextID_Index_Pair const g_MasterPageContextIDs[];
+XMLOFF_DLLPUBLIC extern sal_uInt16 const g_MasterPageFamilies[];
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/xmloff/prstylei.hxx b/include/xmloff/prstylei.hxx
index 9935176b028c..65a2aa2eea6b 100644
--- a/include/xmloff/prstylei.hxx
+++ b/include/xmloff/prstylei.hxx
@@ -47,13 +47,15 @@ private:
XMLPropStyleContext(XMLPropStyleContext const &) = delete;
XMLPropStyleContext& operator =(XMLPropStyleContext const &) = delete;
-protected:
+public:
// Helper to check if the local maProperties contains the given
// FillStyle tag and if the FillStyle there is different from FillStyle_NONE
bool doNewDrawingLayerFillStyleDefinitionsExist(
const OUString& rFillStyleTag) const;
+protected:
+
// Helper which will deactivate all old fill definitions (identified by
// the given OldFillStyleDefinitionSet) in the local maProperties. Deactivation
// is done setting theindex to -1. It returns true when actually old fill
diff --git a/include/xmloff/txtimp.hxx b/include/xmloff/txtimp.hxx
index db79f9c24dbd..6039d73a412c 100644
--- a/include/xmloff/txtimp.hxx
+++ b/include/xmloff/txtimp.hxx
@@ -503,6 +503,7 @@ public:
const OUString& rName ) const;
XMLPropStyleContext* FindPageMaster(
const OUString& rName ) const;
+ XMLPropStyleContext* FindDrawingPage(OUString const& rName) const;
const css::uno::Reference< css::container::XNameContainer> & GetParaStyles() const;
@@ -545,6 +546,7 @@ public:
static SvXMLImportPropertyMapper* CreateTableDefaultExtPropMapper(SvXMLImport&);
static SvXMLImportPropertyMapper* CreateTableRowDefaultExtPropMapper(SvXMLImport&);
static SvXMLImportPropertyMapper* CreateTableCellExtPropMapper(SvXMLImport&);
+ static SvXMLImportPropertyMapper* CreateDrawingPageExtPropMapper(SvXMLImport&);
SvI18NMap& GetRenameMap();
diff --git a/include/xmloff/xmlimppr.hxx b/include/xmloff/xmlimppr.hxx
index d77d434b3ab5..de10dd3b7b10 100644
--- a/include/xmloff/xmlimppr.hxx
+++ b/include/xmloff/xmlimppr.hxx
@@ -53,7 +53,7 @@ class SvXMLImport;
*/
struct ContextID_Index_Pair
{
- sal_Int16 const nContextID;
+ sal_Int16 nContextID;
sal_Int32 nIndex;
};
diff --git a/sw/qa/extras/odfexport/data/sw_hatch.odt b/sw/qa/extras/odfexport/data/sw_hatch.odt
new file mode 100644
index 000000000000..45e36c6ecc00
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/sw_hatch.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 71631603be81..2d38f8828f0c 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -1615,6 +1615,16 @@ DECLARE_ODFEXPORT_TEST(testOdtBorderTypes, "border_types.odt")
} while (xParaEnum->hasMoreElements());
}
+DECLARE_ODFEXPORT_TEST(testMasterPageWithDrawingPage, "sw_hatch.odt")
+{
+ uno::Reference<container::XNameAccess> xStyles(getStyles("PageStyles"));
+ uno::Reference<beans::XPropertySet> xStyle(xStyles->getByName("Standard"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xStyle, "FillStyle"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Blue -45 Degrees"), getProperty<OUString>(xStyle, "FillHatchName"));
+ CPPUNIT_ASSERT(!getProperty<sal_Bool>(xStyle, "FillBackground"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle, "FillTransparence"));
+}
+
DECLARE_ODFEXPORT_TEST(testCellUserDefineAttr, "userdefattr-tablecell.odt")
{
uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index 34ec1dde8ab7..9929975a3b44 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -49,6 +49,8 @@
#include <xmloff/XMLTextMasterStylesContext.hxx>
#include <xmloff/XMLTextShapeStyleContext.hxx>
#include <xmloff/XMLGraphicsDefaultStyle.hxx>
+#include <xmloff/XMLDrawingPageStyleContext.hxx>
+#include <xmloff/XMLTextMasterPageContext.hxx>
#include <xmloff/table/XMLTableImport.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include "xmlimp.hxx"
@@ -828,6 +830,10 @@ SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleStyleChildContext(
pStyle = new XMLTextShapeStyleContext( GetImport(), nPrefix,
rLocalName, xAttrList, *this, nFamily );
break;
+ case XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID:
+ pStyle = new XMLDrawingPageStyleContext(GetImport(), nPrefix, rLocalName,
+ xAttrList, *this, g_MasterPageContextIDs, g_MasterPageFamilies);
+ break;
default:
pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily,
nPrefix,
@@ -927,6 +933,11 @@ rtl::Reference < SvXMLImportPropertyMapper > SwXMLStylesContext_Impl::GetImportP
else if( nFamily == XML_STYLE_FAMILY_TABLE_CELL )
xMapper = XMLTextImportHelper::CreateTableCellExtPropMapper(
const_cast<SwXMLStylesContext_Impl*>( this )->GetImport() );
+ else if (nFamily == XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID)
+ {
+ xMapper = XMLTextImportHelper::CreateDrawingPageExtPropMapper(
+ const_cast<SwXMLStylesContext_Impl*>(this)->GetImport());
+ }
else
xMapper = SvXMLStylesContext::GetImportPropertyMapper( nFamily );
return xMapper;
diff --git a/xmloff/inc/PageMasterImportContext.hxx b/xmloff/inc/PageMasterImportContext.hxx
index ad0e483f7254..5235adb13844 100644
--- a/xmloff/inc/PageMasterImportContext.hxx
+++ b/xmloff/inc/PageMasterImportContext.hxx
@@ -50,8 +50,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/source/style/PageMasterPropHdlFactory.hxx b/xmloff/inc/PageMasterPropHdlFactory.hxx
index b5852e7b9101..e8a4f8c83801 100644
--- a/xmloff/source/style/PageMasterPropHdlFactory.hxx
+++ b/xmloff/inc/PageMasterPropHdlFactory.hxx
@@ -25,11 +25,10 @@
class XMLPageMasterPropHdlFactory : public XMLPropertyHandlerFactory
{
public:
- XMLPageMasterPropHdlFactory();
- virtual ~XMLPageMasterPropHdlFactory() override;
+ XMLPageMasterPropHdlFactory();
+ virtual ~XMLPageMasterPropHdlFactory() override;
- virtual const XMLPropertyHandler*
- GetPropertyHandler( sal_Int32 nType ) const override;
+ virtual const XMLPropertyHandler* GetPropertyHandler(sal_Int32 nType) const override;
};
#endif
diff --git a/xmloff/source/style/PageMasterPropMapper.hxx b/xmloff/inc/PageMasterPropMapper.hxx
index bd1c9ab25f7b..fc054b2f167a 100644
--- a/xmloff/source/style/PageMasterPropMapper.hxx
+++ b/xmloff/inc/PageMasterPropMapper.hxx
@@ -26,10 +26,9 @@ class XMLPageMasterPropSetMapper : public XMLPropertySetMapper
{
public:
explicit XMLPageMasterPropSetMapper();
- XMLPageMasterPropSetMapper(
- const XMLPropertyMapEntry* pEntries,
- const rtl::Reference< XMLPropertyHandlerFactory >& rFactory );
- virtual ~XMLPageMasterPropSetMapper() override;
+ XMLPageMasterPropSetMapper(const XMLPropertyMapEntry* pEntries,
+ const rtl::Reference<XMLPropertyHandlerFactory>& rFactory);
+ virtual ~XMLPageMasterPropSetMapper() override;
};
#endif
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx
index 929fa5b37aa2..528ad043aa2e 100644
--- a/xmloff/source/draw/ximpstyl.cxx
+++ b/xmloff/source/draw/ximpstyl.cxx
@@ -19,6 +19,7 @@
#include "ximpstyl.hxx"
#include <xmloff/maptype.hxx>
+#include <xmloff/XMLDrawingPageStyleContext.hxx>
#include <xmloff/XMLShapeStyleContext.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/xmlprmap.hxx>
@@ -124,7 +125,7 @@ SvXMLImportContextRef SdXMLDrawingPagePropertySetContext::CreateChildContext(
return xContext;
}
-class SdXMLDrawingPageStyleContext : public XMLPropStyleContext
+class SdXMLDrawingPageStyleContext : public XMLDrawingPageStyleContext
{
public:
@@ -133,8 +134,7 @@ public:
sal_uInt16 nPrfx,
const OUString& rLName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
- SvXMLStylesContext& rStyles,
- sal_uInt16 nFamily = XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID);
+ SvXMLStylesContext& rStyles);
SvXMLImportContextRef CreateChildContext(
sal_uInt16 nPrefix,
@@ -142,20 +142,57 @@ 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 sal_uInt16 const g_Families[MAX_SPECIAL_DRAW_STYLES] =
+{
+ XML_STYLE_FAMILY_SD_STROKE_DASH_ID,
+ XML_STYLE_FAMILY_SD_MARKER_ID,
+ XML_STYLE_FAMILY_SD_MARKER_ID,
+ XML_STYLE_FAMILY_SD_GRADIENT_ID,
+ XML_STYLE_FAMILY_SD_GRADIENT_ID,
+ XML_STYLE_FAMILY_SD_HATCH_ID,
+ XML_STYLE_FAMILY_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[],
+ sal_uInt16 const pFamilies[])
+ : XMLPropStyleContext(rImport, nPrefix, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_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,
- sal_uInt16 nFamily)
-: XMLPropStyleContext(rImport, nPrfx, rLName, xAttrList, rStyles, nFamily )
+ SvXMLStylesContext& rStyles)
+ : XMLDrawingPageStyleContext(rImport, nPrfx, rLName, xAttrList, rStyles,
+ g_ContextIDs, g_Families)
{
}
@@ -223,49 +260,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 sal_uInt16 aFamilies[MAX_SPECIAL_DRAW_STYLES] =
- {
- XML_STYLE_FAMILY_SD_STROKE_DASH_ID,
- XML_STYLE_FAMILY_SD_MARKER_ID,
- XML_STYLE_FAMILY_SD_MARKER_ID,
- XML_STYLE_FAMILY_SD_GRADIENT_ID,
- XML_STYLE_FAMILY_SD_GRADIENT_ID,
- XML_STYLE_FAMILY_SD_HATCH_ID,
- XML_STYLE_FAMILY_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<MAX_SPECIAL_DRAW_STYLES; i++ )
+ for (size_t i=0; m_pContextIDs[i].nContextID != -1; ++i)
{
- sal_Int32 nIndex = aContextIDs[i].nIndex;
+ sal_Int32 nIndex = m_pContextIDs[i].nIndex;
if( nIndex != -1 )
{
struct XMLPropertyState& rState = GetProperties()[nIndex];
OUString sStyleName;
rState.maValue >>= sStyleName;
- sStyleName = GetImport().GetStyleDisplayName( aFamilies[i],
+ sStyleName = GetImport().GetStyleDisplayName( m_pFamilies[i],
sStyleName );
// get property set mapper
rtl::Reference<XMLPropertySetMapper> rPropMapper =
diff --git a/xmloff/source/style/PageMasterImportContext.cxx b/xmloff/source/style/PageMasterImportContext.cxx
index 1634f1457117..136711093d7c 100644
--- a/xmloff/source/style/PageMasterImportContext.cxx
+++ b/xmloff/source/style/PageMasterImportContext.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <xmloff/xmlerror.hxx>
+#include <xmloff/XMLTextMasterPageContext.hxx>
using namespace ::com::sun::star;
using namespace ::xmloff::token;
@@ -157,7 +158,14 @@ SvXMLImportContextRef PageStyleContext::CreateChildContext(
return XMLPropStyleContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
}
-void PageStyleContext::FillPropertySet(const uno::Reference<beans::XPropertySet > & rPropSet)
+void PageStyleContext::FillPropertySet(const uno::Reference<beans::XPropertySet > &)
+{
+ assert(false); // dont call this virtual, call function below
+}
+
+void PageStyleContext::FillPropertySet_PageStyle(
+ const uno::Reference<beans::XPropertySet> & 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
@@ -167,7 +175,9 @@ void PageStyleContext::FillPropertySet(const uno::Reference<beans::XPropertySet
static OUString s_HeaderFillStyle("HeaderFillStyle");
static OUString s_FooterFillStyle("FooterFillStyle");
- if(doNewDrawingLayerFillStyleDefinitionsExist(s_FillStyle))
+ // note: the function must only check by property name, not any id/flag!
+ if (doNewDrawingLayerFillStyleDefinitionsExist(s_FillStyle)
+ || (pDrawingPageStyle && pDrawingPageStyle->doNewDrawingLayerFillStyleDefinitionsExist(s_FillStyle)))
{
deactivateOldFillStyleDefinitions(getStandardSet());
}
@@ -295,6 +305,12 @@ void PageStyleContext::FillPropertySet(const uno::Reference<beans::XPropertySet
OSL_ENSURE(xImpPrMap.is(), "Got no SvXMLImportPropertyMapper (!)");
}
+ // pDrawingPageStyle overrides this
+ if (pDrawingPageStyle)
+ {
+ pDrawingPageStyle->FillPropertySet(rPropSet);
+ }
+
// old code, replaced by above stuff
// XMLPropStyleContext::FillPropertySet(rPropSet);
@@ -307,6 +323,24 @@ void PageStyleContext::FillPropertySet(const uno::Reference<beans::XPropertySet
}
}
+extern ContextID_Index_Pair const g_MasterPageContextIDs[] =
+{
+ { CTF_PM_FILLGRADIENTNAME, -1 },
+ { CTF_PM_FILLTRANSNAME, -1 },
+ { CTF_PM_FILLHATCHNAME, -1 },
+ { CTF_PM_FILLBITMAPNAME, -1 },
+
+ {-1, -1}
+};
+
+extern sal_uInt16 const g_MasterPageFamilies[] =
+{
+ XML_STYLE_FAMILY_SD_GRADIENT_ID,
+ XML_STYLE_FAMILY_SD_GRADIENT_ID,
+ XML_STYLE_FAMILY_SD_HATCH_ID,
+ XML_STYLE_FAMILY_SD_FILL_IMAGE_ID
+};
+
// text grid enhancement for better CJK support
//set default page layout style
void PageStyleContext::SetDefaults( )
@@ -317,7 +351,7 @@ void PageStyleContext::SetDefaults( )
Reference < XInterface > 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 9aabc961a445..fc7fde3d9494 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 <PageMasterPropHdlFactory.hxx>
#include <enummaps.hxx>
#include <xmloff/xmlement.hxx>
#include <xmloff/xmltypes.hxx>
diff --git a/xmloff/source/style/PageMasterPropMapper.cxx b/xmloff/source/style/PageMasterPropMapper.cxx
index 3134ef8e1533..41725fd8b013 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 <PageMasterPropMapper.hxx>
#include <rtl/ref.hxx>
#include <xmloff/PageMasterStyleMap.hxx>
-#include "PageMasterPropHdlFactory.hxx"
+#include <PageMasterPropHdlFactory.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
diff --git a/xmloff/source/style/PageMasterStyleMap.cxx b/xmloff/source/style/PageMasterStyleMap.cxx
index 963b905d4eec..0faabe8264b2 100644
--- a/xmloff/source/style/PageMasterStyleMap.cxx
+++ b/xmloff/source/style/PageMasterStyleMap.cxx
@@ -25,6 +25,7 @@ using namespace ::xmloff::token;
#define MAP(name,prefix,token,type,context,version) { name, sizeof(name)-1, prefix, token, type, context, version, false }
#define MAP_IMPORT(name,prefix,token,type,context,version) { name, sizeof(name)-1, prefix, token, type, context, version, true }
+#define DPMAP_IMPORT(name,prefix,token,type,context) MAP_IMPORT(name, prefix, token, type|XML_TYPE_PROP_DRAWING_PAGE, context, SvtSaveOptions::ODFVER_010)
#define PLMAP(name,prefix,token,type,context) \
MAP(name,prefix,token,type|XML_TYPE_PROP_PAGE_LAYOUT,context, SvtSaveOptions::ODFVER_010)
#define PLMAP_12(name,prefix,token,type,context) \
@@ -123,6 +124,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 XML_STYLE_FAMILY_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 ),
@@ -269,4 +271,32 @@ const XMLPropertyMapEntry aXMLPageMasterStyleMap[] =
{ nullptr, 0, 0, XML_EMPTY, 0, 0, SvtSaveOptions::ODFVER_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_IMPORT("FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SW_TYPE_FILLSTYLE, 0),
+ DPMAP_IMPORT("FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, 0),
+ DPMAP_IMPORT("FillColor2", XML_NAMESPACE_DRAW, XML_SECONDARY_FILL_COLOR, XML_TYPE_COLOR, 0),
+ DPMAP_IMPORT("FillGradientName", XML_NAMESPACE_DRAW, XML_FILL_GRADIENT_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_PM_FILLGRADIENTNAME),
+ DPMAP_IMPORT("FillGradientStepCount", XML_NAMESPACE_DRAW, XML_GRADIENT_STEP_COUNT, XML_TYPE_NUMBER16, 0),
+ DPMAP_IMPORT("FillHatchName", XML_NAMESPACE_DRAW, XML_FILL_HATCH_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_PM_FILLHATCHNAME),
+ DPMAP_IMPORT("FillBackground", XML_NAMESPACE_DRAW, XML_FILL_HATCH_SOLID, XML_TYPE_BOOL, 0),
+ DPMAP_IMPORT("FillBitmapName", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_PM_FILLBITMAPNAME),
+ DPMAP_IMPORT("FillTransparence", XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16|MID_FLAG_MULTI_PROPERTY, 0), /* exists in SW, too */
+ DPMAP_IMPORT("FillTransparenceGradientName", XML_NAMESPACE_DRAW, XML_OPACITY_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_PM_FILLTRANSNAME),
+ DPMAP_IMPORT("FillBitmapSizeX", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_WIDTH, XML_SW_TYPE_FILLBITMAPSIZE|MID_FLAG_MULTI_PROPERTY, 0),
+ DPMAP_IMPORT("FillBitmapLogicalSize", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_WIDTH, XML_SW_TYPE_LOGICAL_SIZE|MID_FLAG_MULTI_PROPERTY, 0),
+ DPMAP_IMPORT("FillBitmapSizeY", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_HEIGHT, XML_SW_TYPE_FILLBITMAPSIZE|MID_FLAG_MULTI_PROPERTY, 0),
+ DPMAP_IMPORT("FillBitmapLogicalSize", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_HEIGHT, XML_SW_TYPE_LOGICAL_SIZE|MID_FLAG_MULTI_PROPERTY, 0),
+ DPMAP_IMPORT("FillBitmapMode", XML_NAMESPACE_STYLE, XML_REPEAT, XML_SW_TYPE_BITMAP_MODE|MID_FLAG_MULTI_PROPERTY, CTF_PM_FILLBITMAPMODE),
+ DPMAP_IMPORT("FillBitmapPositionOffsetX", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_REF_POINT_X, XML_TYPE_PERCENT, 0),
+ DPMAP_IMPORT("FillBitmapPositionOffsetY", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_REF_POINT_Y, XML_TYPE_PERCENT, 0),
+ DPMAP_IMPORT("FillBitmapRectanglePoint", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_REF_POINT, XML_SW_TYPE_BITMAP_REFPOINT, 0),
+ DPMAP_IMPORT("FillBitmapOffsetX", XML_NAMESPACE_DRAW, XML_TILE_REPEAT_OFFSET, XML_SW_TYPE_BITMAPREPOFFSETX|MID_FLAG_MULTI_PROPERTY, CTF_PM_REPEAT_OFFSET_X),
+ DPMAP_IMPORT("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::ODFVER_010, false }
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/style/XMLPageExport.cxx b/xmloff/source/style/XMLPageExport.cxx
index 4f78e273c8b5..a9ec047d8f29 100644
--- a/xmloff/source/style/XMLPageExport.cxx
+++ b/xmloff/source/style/XMLPageExport.cxx
@@ -28,9 +28,9 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <xmloff/families.hxx>
#include <xmloff/xmlexp.hxx>
-#include "PageMasterPropHdlFactory.hxx"
+#include <PageMasterPropHdlFactory.hxx>
#include <xmloff/PageMasterStyleMap.hxx>
-#include "PageMasterPropMapper.hxx"
+#include <PageMasterPropMapper.hxx>
#include "PageMasterExportPropMapper.hxx"
using namespace ::com::sun::star;
diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx
index abe719c7c7fe..bc4f0c4600fa 100644
--- a/xmloff/source/style/prstylei.cxx
+++ b/xmloff/source/style/prstylei.cxx
@@ -536,7 +536,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<XMLPropertySetMapper> rMapper = GetStyles()->GetImportPropertyMapper(GetFamily())->getPropertySetMapper();
if(rMapper.is())
{
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx
index 5c4c12f667cf..7583ca5f7faa 100644
--- a/xmloff/source/style/xmlstyle.cxx
+++ b/xmloff/source/style/xmlstyle.cxx
@@ -22,7 +22,7 @@
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/style/XAutoStylesSupplier.hpp>
#include <com/sun/star/style/XAutoStyleFamily.hpp>
-#include "PageMasterPropMapper.hxx"
+#include <PageMasterPropMapper.hxx>
#include <sal/log.hxx>
#include <svl/style.hxx>
#include <xmloff/nmspmap.hxx>
diff --git a/xmloff/source/text/XMLTextMasterPageContext.cxx b/xmloff/source/text/XMLTextMasterPageContext.cxx
index f417df1f29d7..5d5ab75f1a52 100644
--- a/xmloff/source/text/XMLTextMasterPageContext.cxx
+++ b/xmloff/source/text/XMLTextMasterPageContext.cxx
@@ -30,6 +30,7 @@
#include <xmloff/xmltoken.hxx>
#include <xmloff/XMLTextMasterPageContext.hxx>
#include <XMLTextHeaderFooterContext.hxx>
+#include <PageMasterImportContext.hxx>
#include <xmloff/xmlimp.hxx>
@@ -102,6 +103,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() )
@@ -256,14 +262,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<PageStyleContext *>(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 ab1500fc76e5..ef739d273c6d 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -61,6 +61,9 @@
#include "XMLCalculationSettingsContext.hxx"
#include <XMLNumberStylesImport.hxx>
+#include <xmloff/PageMasterStyleMap.hxx>
+#include <PageMasterPropHdlFactory.hxx>
+#include <PageMasterPropMapper.hxx>
// XML import: reconstrution of assignment of paragraph style to outline levels (#i69629#)
#include <com/sun/star/beans/XPropertyState.hpp>
#include <txtlists.hxx>
@@ -1097,6 +1100,15 @@ SvXMLImportPropertyMapper*
return new XMLTextImportPropertyMapper( pPropMapper, rImport );
}
+SvXMLImportPropertyMapper*
+XMLTextImportHelper::CreateDrawingPageExtPropMapper(SvXMLImport& rImport)
+{
+ rtl::Reference<XMLPropertyHandlerFactory> 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);
@@ -2528,6 +2540,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<SvXMLStylesContext *>(m_xImpl->m_xAutoStyles.get())->FindStyleChildContext(
+ XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, rName, true));
+ assert(pStyle == nullptr || dynamic_cast<XMLPropStyleContext const*>(pStyle) != nullptr);
+ return const_cast<XMLPropStyleContext*>(static_cast<XMLPropStyleContext const*>(pStyle));
+}
void XMLTextImportHelper::PushListContext()
{