1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLSectionFootnoteConfigImport.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "XMLSectionFootnoteConfigImport.hxx"
36 #include <rtl/ustring.hxx>
38 #include <com/sun/star/uno/Reference.h>
39 #include <com/sun/star/xml/sax/XAttributeList.hpp>
40 #include <com/sun/star/style/NumberingType.hpp>
41 #include <xmloff/xmlimp.hxx>
42 #include <xmloff/xmltoken.hxx>
43 #include <xmloff/xmluconv.hxx>
44 #include <xmloff/xmlprmap.hxx>
45 #include "xmlnmspe.hxx"
46 #include <xmloff/nmspmap.hxx>
47 #include <xmloff/maptype.hxx>
48 #include <xmloff/xmlnumi.hxx>
49 #include <xmloff/txtprmap.hxx>
50 #include <tools/debug.hxx>
55 using namespace ::xmloff::token
;
56 using namespace ::com::sun::star::style
;
58 using ::rtl::OUString
;
60 using ::com::sun::star::uno::Any
;
61 using ::com::sun::star::uno::Reference
;
62 using ::com::sun::star::xml::sax::XAttributeList
;
65 TYPEINIT1(XMLSectionFootnoteConfigImport
, SvXMLImportContext
);
68 XMLSectionFootnoteConfigImport::XMLSectionFootnoteConfigImport(
71 const OUString
& rLocalName
,
72 vector
<XMLPropertyState
> & rProps
,
73 const UniReference
<XMLPropertySetMapper
> & rMapperRef
) :
74 SvXMLImportContext(rImport
, nPrefix
, rLocalName
),
80 XMLSectionFootnoteConfigImport::~XMLSectionFootnoteConfigImport()
84 void XMLSectionFootnoteConfigImport::StartElement(
85 const Reference
<XAttributeList
> & xAttrList
)
87 sal_Bool bEnd
= sal_True
; // we're inside the element, so this is true
88 sal_Bool bNumOwn
= sal_False
;
89 sal_Bool bNumRestart
= sal_False
;
90 sal_Bool bEndnote
= sal_False
;
91 sal_Int16 nNumRestartAt
= 0;
95 OUString sNumLetterSync
;
97 // iterate over xattribute list and fill values
98 sal_Int16 nLength
= xAttrList
->getLength();
99 for(sal_Int16 nAttr
= 0; nAttr
< nLength
; nAttr
++)
102 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
103 GetKeyByAttrName( xAttrList
->getNameByIndex(nAttr
),
105 OUString sAttrValue
= xAttrList
->getValueByIndex(nAttr
);
107 if (XML_NAMESPACE_TEXT
== nPrefix
)
109 if (IsXMLToken(sLocalName
, XML_START_VALUE
))
112 if (SvXMLUnitConverter::convertNumber(nTmp
, sAttrValue
))
114 nNumRestartAt
= static_cast< sal_Int16
>( nTmp
) - 1;
115 bNumRestart
= sal_True
;
118 else if( IsXMLToken( sLocalName
, XML_NOTE_CLASS
) )
120 if( IsXMLToken( sAttrValue
, XML_ENDNOTE
) )
124 else if (XML_NAMESPACE_STYLE
== nPrefix
)
126 if (IsXMLToken(sLocalName
, XML_NUM_PREFIX
))
128 sNumPrefix
= sAttrValue
;
131 else if (IsXMLToken(sLocalName
, XML_NUM_SUFFIX
))
133 sNumSuffix
= sAttrValue
;
136 else if (IsXMLToken(sLocalName
, XML_NUM_FORMAT
))
138 sNumFormat
= sAttrValue
;
141 else if (IsXMLToken(sLocalName
, XML_NUM_LETTER_SYNC
))
143 sNumLetterSync
= sAttrValue
;
149 // OK, now we have all values and can fill the XMLPropertyState vector
152 aAny
.setValue( &bNumOwn
, ::getBooleanCppuType() );
153 sal_Int32 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
154 CTF_SECTION_ENDNOTE_NUM_OWN
: CTF_SECTION_FOOTNOTE_NUM_OWN
);
155 XMLPropertyState
aNumOwn( nIndex
, aAny
);
156 rProperties
.push_back( aNumOwn
);
158 aAny
.setValue( &bNumRestart
, ::getBooleanCppuType() );
159 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
160 CTF_SECTION_ENDNOTE_NUM_RESTART
: CTF_SECTION_FOOTNOTE_NUM_RESTART
);
161 XMLPropertyState
aNumRestart( nIndex
, aAny
);
162 rProperties
.push_back( aNumRestart
);
164 aAny
<<= nNumRestartAt
;
165 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
166 CTF_SECTION_ENDNOTE_NUM_RESTART_AT
:
167 CTF_SECTION_FOOTNOTE_NUM_RESTART_AT
);
168 XMLPropertyState
aNumRestartAtState( nIndex
, aAny
);
169 rProperties
.push_back( aNumRestartAtState
);
171 sal_Int16 nNumType
= NumberingType::ARABIC
;
172 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
176 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
177 CTF_SECTION_ENDNOTE_NUM_TYPE
: CTF_SECTION_FOOTNOTE_NUM_TYPE
);
178 XMLPropertyState
aNumFormatState( nIndex
, aAny
);
179 rProperties
.push_back( aNumFormatState
);
182 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
183 CTF_SECTION_ENDNOTE_NUM_PREFIX
: CTF_SECTION_FOOTNOTE_NUM_PREFIX
);
184 XMLPropertyState
aPrefixState( nIndex
, aAny
);
185 rProperties
.push_back( aPrefixState
);
188 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
189 CTF_SECTION_ENDNOTE_NUM_SUFFIX
: CTF_SECTION_FOOTNOTE_NUM_SUFFIX
);
190 XMLPropertyState
aSuffixState( nIndex
, aAny
);
191 rProperties
.push_back( aSuffixState
);
193 aAny
.setValue( &bEnd
, ::getBooleanCppuType() );
194 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
195 CTF_SECTION_ENDNOTE_END
: CTF_SECTION_FOOTNOTE_END
);
196 XMLPropertyState
aEndState( nIndex
, aAny
);
197 rProperties
.push_back( aEndState
);