Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "XMLSectionFootnoteConfigImport.hxx"
30 : :
31 : : #include <rtl/ustring.hxx>
32 : : #include <com/sun/star/uno/Reference.h>
33 : : #include <com/sun/star/xml/sax/XAttributeList.hpp>
34 : : #include <com/sun/star/style/NumberingType.hpp>
35 : : #include <sax/tools/converter.hxx>
36 : : #include <xmloff/xmlimp.hxx>
37 : : #include <xmloff/xmltoken.hxx>
38 : : #include <xmloff/xmluconv.hxx>
39 : : #include <xmloff/xmlprmap.hxx>
40 : : #include "xmloff/xmlnmspe.hxx"
41 : : #include <xmloff/nmspmap.hxx>
42 : : #include <xmloff/maptype.hxx>
43 : : #include <xmloff/xmlnumi.hxx>
44 : : #include <xmloff/txtprmap.hxx>
45 : :
46 : : #include <vector>
47 : :
48 : :
49 : : using namespace ::xmloff::token;
50 : : using namespace ::com::sun::star::style;
51 : :
52 : : using ::rtl::OUString;
53 : : using ::std::vector;
54 : : using ::com::sun::star::uno::Any;
55 : : using ::com::sun::star::uno::Reference;
56 : : using ::com::sun::star::xml::sax::XAttributeList;
57 : :
58 : :
59 [ # # ][ # # ]: 0 : TYPEINIT1(XMLSectionFootnoteConfigImport, SvXMLImportContext);
60 : :
61 : :
62 : 0 : XMLSectionFootnoteConfigImport::XMLSectionFootnoteConfigImport(
63 : : SvXMLImport& rImport,
64 : : sal_uInt16 nPrefix,
65 : : const OUString& rLocalName,
66 : : vector<XMLPropertyState> & rProps,
67 : : const UniReference<XMLPropertySetMapper> & rMapperRef) :
68 : : SvXMLImportContext(rImport, nPrefix, rLocalName),
69 : : rProperties(rProps),
70 [ # # ]: 0 : rMapper(rMapperRef)
71 : : {
72 : 0 : }
73 : :
74 [ # # ]: 0 : XMLSectionFootnoteConfigImport::~XMLSectionFootnoteConfigImport()
75 : : {
76 [ # # ]: 0 : }
77 : :
78 : 0 : void XMLSectionFootnoteConfigImport::StartElement(
79 : : const Reference<XAttributeList> & xAttrList)
80 : : {
81 : 0 : sal_Bool bEnd = sal_True; // we're inside the element, so this is true
82 : 0 : sal_Bool bNumOwn = sal_False;
83 : 0 : sal_Bool bNumRestart = sal_False;
84 : 0 : sal_Bool bEndnote = sal_False;
85 : 0 : sal_Int16 nNumRestartAt = 0;
86 : 0 : OUString sNumPrefix;
87 : 0 : OUString sNumSuffix;
88 : 0 : OUString sNumFormat;
89 : 0 : OUString sNumLetterSync;
90 : :
91 : : // iterate over xattribute list and fill values
92 [ # # ][ # # ]: 0 : sal_Int16 nLength = xAttrList->getLength();
93 [ # # ]: 0 : for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
94 : : {
95 : 0 : OUString sLocalName;
96 : 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
97 [ # # ]: 0 : GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
98 [ # # # # ]: 0 : &sLocalName );
99 [ # # ][ # # ]: 0 : OUString sAttrValue = xAttrList->getValueByIndex(nAttr);
100 : :
101 [ # # ]: 0 : if (XML_NAMESPACE_TEXT == nPrefix)
102 : : {
103 [ # # ][ # # ]: 0 : if (IsXMLToken(sLocalName, XML_START_VALUE))
104 : : {
105 : : sal_Int32 nTmp;
106 [ # # ][ # # ]: 0 : if (::sax::Converter::convertNumber(nTmp, sAttrValue))
107 : : {
108 : 0 : nNumRestartAt = static_cast< sal_Int16 >( nTmp ) - 1;
109 : 0 : bNumRestart = sal_True;
110 : : }
111 : : }
112 [ # # ][ # # ]: 0 : else if( IsXMLToken( sLocalName, XML_NOTE_CLASS ) )
113 : : {
114 [ # # ][ # # ]: 0 : if( IsXMLToken( sAttrValue, XML_ENDNOTE ) )
115 : 0 : bEndnote = sal_True;
116 : : }
117 : : }
118 [ # # ]: 0 : else if (XML_NAMESPACE_STYLE == nPrefix)
119 : : {
120 [ # # ][ # # ]: 0 : if (IsXMLToken(sLocalName, XML_NUM_PREFIX))
121 : : {
122 : 0 : sNumPrefix = sAttrValue;
123 : 0 : bNumOwn = sal_True;
124 : : }
125 [ # # ][ # # ]: 0 : else if (IsXMLToken(sLocalName, XML_NUM_SUFFIX))
126 : : {
127 : 0 : sNumSuffix = sAttrValue;
128 : 0 : bNumOwn = sal_True;
129 : : }
130 [ # # ][ # # ]: 0 : else if (IsXMLToken(sLocalName, XML_NUM_FORMAT))
131 : : {
132 : 0 : sNumFormat = sAttrValue;
133 : 0 : bNumOwn = sal_True;
134 : : }
135 [ # # ][ # # ]: 0 : else if (IsXMLToken(sLocalName, XML_NUM_LETTER_SYNC))
136 : : {
137 : 0 : sNumLetterSync = sAttrValue;
138 : 0 : bNumOwn = sal_True;
139 : : }
140 : : }
141 : 0 : }
142 : :
143 : : // OK, now we have all values and can fill the XMLPropertyState vector
144 : 0 : Any aAny;
145 : :
146 [ # # ]: 0 : aAny.setValue( &bNumOwn, ::getBooleanCppuType() );
147 : : sal_Int32 nIndex = rMapper->FindEntryIndex( bEndnote ?
148 [ # # ][ # # ]: 0 : CTF_SECTION_ENDNOTE_NUM_OWN : CTF_SECTION_FOOTNOTE_NUM_OWN );
[ # # ]
149 : 0 : XMLPropertyState aNumOwn( nIndex, aAny );
150 [ # # ]: 0 : rProperties.push_back( aNumOwn );
151 : :
152 [ # # ]: 0 : aAny.setValue( &bNumRestart, ::getBooleanCppuType() );
153 : : nIndex = rMapper->FindEntryIndex( bEndnote ?
154 [ # # ][ # # ]: 0 : CTF_SECTION_ENDNOTE_NUM_RESTART : CTF_SECTION_FOOTNOTE_NUM_RESTART );
[ # # ]
155 : 0 : XMLPropertyState aNumRestart( nIndex, aAny );
156 [ # # ]: 0 : rProperties.push_back( aNumRestart );
157 : :
158 [ # # ]: 0 : aAny <<= nNumRestartAt;
159 : : nIndex = rMapper->FindEntryIndex( bEndnote ?
160 : : CTF_SECTION_ENDNOTE_NUM_RESTART_AT :
161 [ # # ][ # # ]: 0 : CTF_SECTION_FOOTNOTE_NUM_RESTART_AT );
[ # # ]
162 : 0 : XMLPropertyState aNumRestartAtState( nIndex, aAny );
163 [ # # ]: 0 : rProperties.push_back( aNumRestartAtState );
164 : :
165 : 0 : sal_Int16 nNumType = NumberingType::ARABIC;
166 : 0 : GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
167 : : sNumFormat,
168 [ # # ]: 0 : sNumLetterSync );
169 [ # # ]: 0 : aAny <<= nNumType;
170 : : nIndex = rMapper->FindEntryIndex( bEndnote ?
171 [ # # ][ # # ]: 0 : CTF_SECTION_ENDNOTE_NUM_TYPE : CTF_SECTION_FOOTNOTE_NUM_TYPE );
[ # # ]
172 : 0 : XMLPropertyState aNumFormatState( nIndex, aAny );
173 [ # # ]: 0 : rProperties.push_back( aNumFormatState );
174 : :
175 [ # # ]: 0 : aAny <<= sNumPrefix;
176 : : nIndex = rMapper->FindEntryIndex( bEndnote ?
177 [ # # ][ # # ]: 0 : CTF_SECTION_ENDNOTE_NUM_PREFIX : CTF_SECTION_FOOTNOTE_NUM_PREFIX );
[ # # ]
178 : 0 : XMLPropertyState aPrefixState( nIndex, aAny );
179 [ # # ]: 0 : rProperties.push_back( aPrefixState );
180 : :
181 [ # # ]: 0 : aAny <<= sNumSuffix;
182 : : nIndex = rMapper->FindEntryIndex( bEndnote ?
183 [ # # ][ # # ]: 0 : CTF_SECTION_ENDNOTE_NUM_SUFFIX : CTF_SECTION_FOOTNOTE_NUM_SUFFIX );
[ # # ]
184 : 0 : XMLPropertyState aSuffixState( nIndex, aAny );
185 [ # # ]: 0 : rProperties.push_back( aSuffixState );
186 : :
187 [ # # ]: 0 : aAny.setValue( &bEnd, ::getBooleanCppuType() );
188 : : nIndex = rMapper->FindEntryIndex( bEndnote ?
189 [ # # ][ # # ]: 0 : CTF_SECTION_ENDNOTE_END : CTF_SECTION_FOOTNOTE_END );
[ # # ]
190 : 0 : XMLPropertyState aEndState( nIndex, aAny );
191 [ # # ]: 0 : rProperties.push_back( aEndState );
192 : 0 : }
193 : :
194 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|