summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-25 18:23:32 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-26 09:43:22 +0200
commitbbd5be1dc5ecfe38c66739daeea8e2e6fa1164d3 (patch)
tree9a886f18391e30ae1d34731269b3b898950d5297 /sw
parent0f00c7f42403ad037a5c64adf777be7da87732f1 (diff)
merge SwXMLItemSetContext_Impl and SvXMLItemSetContext
Change-Id: I8a9dba020e7189d31040e8cb742d105390b242e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101349 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/xml/xmlitem.cxx54
-rw-r--r--sw/source/filter/xml/xmlitem.hxx17
-rw-r--r--sw/source/filter/xml/xmlitemi.cxx92
3 files changed, 52 insertions, 111 deletions
diff --git a/sw/source/filter/xml/xmlitem.cxx b/sw/source/filter/xml/xmlitem.cxx
index 4d12335a1d44..4b22cd5044d8 100644
--- a/sw/source/filter/xml/xmlitem.cxx
+++ b/sw/source/filter/xml/xmlitem.cxx
@@ -17,13 +17,16 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <editeng/brushitem.hxx>
#include <xmloff/xmlimp.hxx>
#include "xmlimpit.hxx"
#include "xmlitem.hxx"
+#include "xmlbrshi.hxx"
+#include <hintids.hxx>
using namespace ::com::sun::star;
-SvXMLItemSetContext::SvXMLItemSetContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
+SwXMLItemSetContext::SwXMLItemSetContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
const OUString& rLName,
const uno::Reference< xml::sax::XAttributeList >& xAttrList,
SfxItemSet& rISet,
@@ -38,11 +41,17 @@ SvXMLItemSetContext::SvXMLItemSetContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
GetImport().GetNamespaceMap() );
}
-SvXMLItemSetContext::~SvXMLItemSetContext()
+SwXMLItemSetContext::~SwXMLItemSetContext()
{
+ if( xBackground.is() )
+ {
+ const SvxBrushItem& rItem =
+ static_cast<SwXMLBrushItemImportContext*>(xBackground.get())->GetItem();
+ rItemSet.Put( rItem );
+ }
}
-SvXMLImportContextRef SvXMLItemSetContext::CreateChildContext( sal_uInt16 nPrefix,
+SvXMLImportContextRef SwXMLItemSetContext::CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList >& xAttrList )
{
@@ -52,7 +61,7 @@ SvXMLImportContextRef SvXMLItemSetContext::CreateChildContext( sal_uInt16 nPrefi
if( pEntry && 0 != (pEntry->nMemberId & MID_SW_FLAG_ELEMENT_ITEM_IMPORT) )
{
return CreateChildContext( nPrefix, rLocalName, xAttrList,
- rItemSet, *pEntry, rUnitConv );
+ *pEntry );
}
return nullptr;
}
@@ -61,14 +70,37 @@ SvXMLImportContextRef SvXMLItemSetContext::CreateChildContext( sal_uInt16 nPrefi
CreateChildContext if the element matches an entry in the
SvXMLImportItemMapper with the mid flag MID_SW_FLAG_ELEMENT
*/
-SvXMLImportContextRef SvXMLItemSetContext::CreateChildContext( sal_uInt16 /*nPrefix*/,
- const OUString& /*rLocalName*/,
- const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/,
- SfxItemSet& /*rItemSet*/,
- const SvXMLItemMapEntry& /*rEntry*/,
- const SvXMLUnitConverter& /*rUnitConv*/ )
+SvXMLImportContextRef SwXMLItemSetContext::CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& xAttrList,
+ const SvXMLItemMapEntry& rEntry )
{
- return nullptr;
+ SvXMLImportContextRef xContext;
+
+ switch( rEntry.nWhichId )
+ {
+ case RES_BACKGROUND:
+ {
+ const SfxPoolItem *pItem;
+ if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND,
+ false, &pItem ) )
+ {
+ xContext = new SwXMLBrushItemImportContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ rUnitConv, *static_cast<const SvxBrushItem *>(pItem) );
+ }
+ else
+ {
+ xContext = new SwXMLBrushItemImportContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ rUnitConv, RES_BACKGROUND );
+ }
+ xBackground = xContext;
+ }
+ break;
+ }
+
+ return xContext;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmlitem.hxx b/sw/source/filter/xml/xmlitem.hxx
index 4f06cfc94d9c..b8678ebe1a68 100644
--- a/sw/source/filter/xml/xmlitem.hxx
+++ b/sw/source/filter/xml/xmlitem.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_SW_SOURCE_FILTER_XML_XMLITEM_HXX
#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#include <svl/itemset.hxx>
#include <xmloff/xmlictxt.hxx>
class SfxItemSet;
@@ -28,38 +29,36 @@ class SvXMLImportItemMapper;
class SvXMLUnitConverter;
struct SvXMLItemMapEntry;
-class SvXMLItemSetContext : public SvXMLImportContext
+class SwXMLItemSetContext final : public SvXMLImportContext
{
-protected:
SfxItemSet &rItemSet;
const SvXMLImportItemMapper &rIMapper;
const SvXMLUnitConverter &rUnitConv;
+ SvXMLImportContextRef xBackground;
public:
- SvXMLItemSetContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
+ SwXMLItemSetContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
const OUString& rLName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
SfxItemSet& rItemSet,
SvXMLImportItemMapper& rIMap,
const SvXMLUnitConverter& rUnitConv );
- virtual ~SvXMLItemSetContext() override;
+ virtual ~SwXMLItemSetContext() override;
virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
+private:
// This method is called from this instance implementation of
// CreateChildContext if the element matches an entry in the
// SvXMLImportItemMapper with the mid flag MID_SW_FLAG_ELEMENT_ITEM_IMPORT
- virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
+ SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
- SfxItemSet& rItemSet,
- const SvXMLItemMapEntry& rEntry,
- const SvXMLUnitConverter& rUnitConv );
-
+ const SvXMLItemMapEntry& rEntry );
};
#endif // INCLUDED_SW_SOURCE_FILTER_XML_XMLITEM_HXX
diff --git a/sw/source/filter/xml/xmlitemi.cxx b/sw/source/filter/xml/xmlitemi.cxx
index 37e0b304f4de..7c9ffcc2c3d6 100644
--- a/sw/source/filter/xml/xmlitemi.cxx
+++ b/sw/source/filter/xml/xmlitemi.cxx
@@ -224,96 +224,6 @@ void SwXMLImportTableItemMapper_Impl::finished(
}
}
-namespace {
-
-class SwXMLItemSetContext_Impl : public SvXMLItemSetContext
-{
- SvXMLImportContextRef xBackground;
-
- using SvXMLItemSetContext::CreateChildContext;
-
-public:
- SwXMLItemSetContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
- const OUString& rLName,
- const Reference< xml::sax::XAttributeList > & xAttrList,
- SfxItemSet& rItemSet,
- SvXMLImportItemMapper & rIMapper,
- const SvXMLUnitConverter& rUnitConv );
- virtual ~SwXMLItemSetContext_Impl() override;
-
- virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const ::uno::Reference< xml::sax::XAttributeList > & xAttrList,
- SfxItemSet& rItemSet,
- const SvXMLItemMapEntry& rEntry,
- const SvXMLUnitConverter& rUnitConv ) override;
-};
-
-}
-
-SwXMLItemSetContext_Impl::SwXMLItemSetContext_Impl(
- SwXMLImport& rImport, sal_uInt16 nPrfx,
- const OUString& rLName,
- const Reference< xml::sax::XAttributeList > & xAttrList,
- SfxItemSet& _rItemSet,
- SvXMLImportItemMapper & _rIMapper,
- const SvXMLUnitConverter& _rUnitConv ) :
- SvXMLItemSetContext( rImport, nPrfx, rLName, xAttrList,
- _rItemSet, _rIMapper, _rUnitConv )
-{
-}
-
-SwXMLItemSetContext_Impl::~SwXMLItemSetContext_Impl()
-{
- if( xBackground.is() )
- {
- const SvxBrushItem& rItem =
- static_cast<SwXMLBrushItemImportContext*>(xBackground.get())->GetItem();
- rItemSet.Put( rItem );
- }
-}
-
-SvXMLImportContextRef SwXMLItemSetContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference< xml::sax::XAttributeList > & xAttrList,
- SfxItemSet& _rItemSet,
- const SvXMLItemMapEntry& rEntry,
- const SvXMLUnitConverter& _rUnitConv )
-{
- SvXMLImportContextRef xContext;
-
- switch( rEntry.nWhichId )
- {
- case RES_BACKGROUND:
- {
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == _rItemSet.GetItemState( RES_BACKGROUND,
- false, &pItem ) )
- {
- xContext = new SwXMLBrushItemImportContext(
- GetImport(), nPrefix, rLocalName, xAttrList,
- _rUnitConv, *static_cast<const SvxBrushItem *>(pItem) );
- }
- else
- {
- xContext = new SwXMLBrushItemImportContext(
- GetImport(), nPrefix, rLocalName, xAttrList,
- _rUnitConv, RES_BACKGROUND );
- }
- xBackground = xContext;
- }
- break;
- }
-
- if (!xContext)
- xContext = SvXMLItemSetContext::CreateChildContext( nPrefix, rLocalName,
- xAttrList, _rItemSet,
- rEntry, _rUnitConv );
-
- return xContext;
-}
-
void SwXMLImport::InitItemImport()
{
m_pTwipUnitConv.reset( new SvXMLUnitConverter( GetComponentContext(),
@@ -361,7 +271,7 @@ SvXMLImportContext *SwXMLImport::CreateTableItemImportContext(
m_pTableItemMapper->setMapEntries( xItemMap );
- return new SwXMLItemSetContext_Impl( *this, nPrefix, rLocalName,
+ return new SwXMLItemSetContext( *this, nPrefix, rLocalName,
xAttrList, rItemSet,
GetTableItemMapper(),
*m_pTwipUnitConv );