1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23 #ifndef _XMLIMPIT_HXX
24 #define _XMLIMPIT_HXX
25
26 #include <limits.h>
27 #include <tools/solar.h>
28 #include <tools/ref.hxx>
29
30
31 #include <com/sun/star/xml/sax/XAttributeList.hpp>
32 #include "xmlitmap.hxx"
33
34 namespace rtl { class OUString; }
35
36 class SvXMLUnitConverter;
37 class SfxPoolItem;
38 class SfxItemSet;
39 class SvXMLNamespaceMap;
40 struct SvXMLItemMapEntry;
41
42 class SvXMLImportItemMapper
43 {
44 protected:
45 SvXMLItemMapEntriesRef mrMapEntries;
46 sal_uInt16 nUnknownWhich;
47
48 public:
49 SvXMLImportItemMapper( SvXMLItemMapEntriesRef rMapEntries ,
50 sal_uInt16 nUnknWhich=USHRT_MAX );
51 virtual ~SvXMLImportItemMapper();
52
53 /** fills the given itemset with the attributes in the given list */
54 void importXML( SfxItemSet& rSet,
55 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > xAttrList,
56 const SvXMLUnitConverter& rUnitConverter,
57 const SvXMLNamespaceMap& rNamespaceMap );
58
59 /** this method is called for every item that has the
60 MID_SW_FLAG_SPECIAL_ITEM_IMPORT flag set */
61 virtual sal_Bool handleSpecialItem( const SvXMLItemMapEntry& rEntry,
62 SfxPoolItem& rItem,
63 SfxItemSet& rSet,
64 const ::rtl::OUString& rValue,
65 const SvXMLUnitConverter& rUnitConverter,
66 const SvXMLNamespaceMap& rNamespaceMap );
67
68 /** this method is called for every item that has the
69 MID_SW_FLAG_NO_ITEM_IMPORT flag set */
70 virtual sal_Bool handleNoItem( const SvXMLItemMapEntry& rEntry,
71 SfxItemSet& rSet,
72 const ::rtl::OUString& rValue,
73 const SvXMLUnitConverter& rUnitConverter,
74 const SvXMLNamespaceMap& rNamespaceMap );
75
76 /** This method is called when all attributes have benn processed. It
77 * may be used to remove items that are incomplete */
78 virtual void finished(SfxItemSet & rSet,
79 SvXMLUnitConverter const& rUnitConverter) const;
80
81 virtual void setMapEntries( SvXMLItemMapEntriesRef rMapEntries );
82 inline SvXMLItemMapEntriesRef getMapEntries() const;
83
84
85 /** This method is called for every item that should be set based
86 upon an XML attribute value. */
87 static sal_Bool PutXMLValue(
88 SfxPoolItem& rItem,
89 const ::rtl::OUString& rValue,
90 sal_uInt16 nMemberId,
91 const SvXMLUnitConverter& rUnitConverter );
92 };
93
94 inline SvXMLItemMapEntriesRef
getMapEntries() const95 SvXMLImportItemMapper::getMapEntries() const
96 {
97 return mrMapEntries;
98 }
99
100
101 #endif // _XMLIMPIT_HXX
102