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
28using namespace ::com::sun::star;
29
30SwXMLItemSetContext::SwXMLItemSetContext( SvXMLImport& rImp, sal_Int32 /*nElement*/,
31 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
32 SfxItemSet& rISet,
34 const SvXMLUnitConverter& rUnitConverter ):
35 SvXMLImportContext( rImp ),
36 m_rItemSet( rISet ),
37 m_rIMapper( rIMap ),
38 m_rUnitConv( rUnitConverter )
39{
40 rIMap.importXML( m_rItemSet, xAttrList, m_rUnitConv,
41 GetImport().GetNamespaceMap() );
42}
43
45{
46 if( m_xBackground.is() )
47 {
48 const SvxBrushItem& rItem =
50 m_rItemSet.Put( rItem );
51 }
52}
53
54css::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 );
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 {
85 false ) )
86 {
87 xContext = new SwXMLBrushItemImportContext(
88 GetImport(), nElement, xAttrList,
89 m_rUnitConv, *pItem );
90 }
91 else
92 {
93 xContext = new SwXMLBrushItemImportContext(
94 GetImport(), nElement, xAttrList,
96 }
97 m_xBackground = xContext;
98 }
99 break;
100 }
101
102 return xContext;
103}
104
105/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SvXMLImport & GetImport()
const SvXMLItemMapEntriesRef & getMapEntries() const
Definition: xmlimpit.hxx:86
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
const SvXMLUnitConverter & m_rUnitConv
Definition: xmlitem.hxx:36
SvXMLImportContextRef m_xBackground
Definition: xmlitem.hxx:37
SfxItemSet & m_rItemSet
Definition: xmlitem.hxx:34
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual ~SwXMLItemSetContext() override
Definition: xmlitem.cxx:44
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
const SvXMLImportItemMapper & m_rIMapper
Definition: xmlitem.hxx:35
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
Extracts pool item of type nWhich from rAttr.
Definition: atrstck.cxx:157
sal_uInt16 nWhichId
Definition: xmlitmap.hxx:44
sal_uInt32 nMemberId
Definition: xmlitmap.hxx:49
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
#define MID_SW_FLAG_ELEMENT_ITEM_IMPORT
Definition: xmlitmap.hxx:36