LibreOffice Module sw (master)  1
xmlitem.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <editeng/brushitem.hxx>
21 #include <sal/log.hxx>
22 #include <xmloff/xmlimp.hxx>
23 #include "xmlimpit.hxx"
24 #include "xmlitem.hxx"
25 #include "xmlbrshi.hxx"
26 #include <hintids.hxx>
27 
28 using namespace ::com::sun::star;
29 
31  const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
32  SfxItemSet& rISet,
33  SvXMLImportItemMapper& rIMap,
34  const SvXMLUnitConverter& rUnitConverter ):
35  SvXMLImportContext( rImp ),
36  rItemSet( rISet ),
37  rIMapper( rIMap ),
38  rUnitConv( rUnitConverter )
39 {
40  rIMap.importXML( rItemSet, xAttrList, rUnitConv,
41  GetImport().GetNamespaceMap() );
42 }
43 
45 {
46  if( xBackground.is() )
47  {
48  const SvxBrushItem& rItem =
49  static_cast<SwXMLBrushItemImportContext*>(xBackground.get())->GetItem();
50  rItemSet.Put( rItem );
51  }
52 }
53 
54 css::uno::Reference< css::xml::sax::XFastContextHandler > SwXMLItemSetContext::createFastChildContext(
55  sal_Int32 nElement,
56  const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
57 {
59  SvXMLItemMapEntry const * pEntry = xMapEntries->getByName( nElement );
60 
61  if( pEntry && 0 != (pEntry->nMemberId & MID_SW_FLAG_ELEMENT_ITEM_IMPORT) )
62  {
63  return createFastChildContext( nElement, xAttrList, *pEntry ).get();
64  }
65  else
66  XMLOFF_WARN_UNKNOWN_ELEMENT("sw", nElement);
67  return nullptr;
68 }
69 
75  const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
76  const SvXMLItemMapEntry& rEntry )
77 {
78  SvXMLImportContextRef xContext;
79 
80  switch( rEntry.nWhichId )
81  {
82  case RES_BACKGROUND:
83  {
84  const SfxPoolItem *pItem;
85  if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND,
86  false, &pItem ) )
87  {
88  xContext = new SwXMLBrushItemImportContext(
89  GetImport(), nElement, xAttrList,
90  rUnitConv, *static_cast<const SvxBrushItem *>(pItem) );
91  }
92  else
93  {
94  xContext = new SwXMLBrushItemImportContext(
95  GetImport(), nElement, xAttrList,
97  }
98  xBackground = xContext;
99  }
100  break;
101  }
102 
103  return xContext;
104 }
105 
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SvXMLItemMapEntriesRef & getMapEntries() const
Definition: xmlimpit.hxx:87
SvXMLItemMapEntry const * getByName(sal_Int32 nElement) const
Definition: xmlitmpr.cxx:51
sal_uInt16 nWhichId
Definition: xmlitmap.hxx:43
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
Extracts pool item of type nWhich from rAttr.
Definition: atrstck.cxx:156
SvXMLImport & GetImport()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
virtual ~SwXMLItemSetContext() override
Definition: xmlitem.cxx:44
const SvXMLImportItemMapper & rIMapper
Definition: xmlitem.hxx:35
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
SwXMLItemSetContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, SfxItemSet &rItemSet, SvXMLImportItemMapper &rIMap, const SvXMLUnitConverter &rUnitConv)
Definition: xmlitem.cxx:30
sal_uInt32 nMemberId
Definition: xmlitmap.hxx:48
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SvXMLUnitConverter & rUnitConv
Definition: xmlitem.hxx:36
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
void importXML(SfxItemSet &rSet, css::uno::Reference< css::xml::sax::XFastAttributeList > const &xAttrList, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap)
fills the given itemset with the attributes in the given list
Definition: xmlimpit.cxx:81
SvXMLImportContextRef xBackground
Definition: xmlitem.hxx:37
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
SfxItemSet & rItemSet
Definition: xmlitem.hxx:34
#define MID_SW_FLAG_ELEMENT_ITEM_IMPORT
Definition: xmlitmap.hxx:35