1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
28 using namespace ::com::sun::star
;
30 SwXMLItemSetContext::SwXMLItemSetContext( SvXMLImport
& rImp
, sal_Int32
/*nElement*/,
31 const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
,
33 SvXMLImportItemMapper
& rIMap
,
34 const SvXMLUnitConverter
& rUnitConverter
):
35 SvXMLImportContext( rImp
),
38 m_rUnitConv( rUnitConverter
)
40 rIMap
.importXML( m_rItemSet
, xAttrList
, m_rUnitConv
,
41 GetImport().GetNamespaceMap() );
44 SwXMLItemSetContext::~SwXMLItemSetContext()
46 if( m_xBackground
.is() )
48 const SvxBrushItem
& rItem
=
49 static_cast<SwXMLBrushItemImportContext
*>(m_xBackground
.get())->GetItem();
50 m_rItemSet
.Put( rItem
);
54 css::uno::Reference
< css::xml::sax::XFastContextHandler
> SwXMLItemSetContext::createFastChildContext(
56 const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
58 SvXMLItemMapEntriesRef xMapEntries
= m_rIMapper
.getMapEntries();
59 SvXMLItemMapEntry
const * pEntry
= xMapEntries
->getByName( nElement
);
61 if( pEntry
&& 0 != (pEntry
->nMemberId
& MID_SW_FLAG_ELEMENT_ITEM_IMPORT
) )
63 return createFastChildContext( nElement
, xAttrList
, *pEntry
);
66 XMLOFF_WARN_UNKNOWN_ELEMENT("sw", nElement
);
70 /** This method is called from this instance implementation of
71 CreateChildContext if the element matches an entry in the
72 SvXMLImportItemMapper with the mid flag MID_SW_FLAG_ELEMENT
74 SvXMLImportContextRef
SwXMLItemSetContext::createFastChildContext( sal_Int32 nElement
,
75 const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
,
76 const SvXMLItemMapEntry
& rEntry
)
78 SvXMLImportContextRef xContext
;
80 switch( rEntry
.nWhichId
)
84 if( const SvxBrushItem
* pItem
= m_rItemSet
.GetItemIfSet( RES_BACKGROUND
,
87 xContext
= new SwXMLBrushItemImportContext(
88 GetImport(), nElement
, xAttrList
,
89 m_rUnitConv
, *pItem
);
93 xContext
= new SwXMLBrushItemImportContext(
94 GetImport(), nElement
, xAttrList
,
95 m_rUnitConv
, RES_BACKGROUND
);
97 m_xBackground
= xContext
;
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */