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 "XMLSectionFootnoteConfigImport.hxx"
22 #include <rtl/ustring.hxx>
23 #include <com/sun/star/uno/Reference.h>
24 #include <com/sun/star/xml/sax/XAttributeList.hpp>
25 #include <com/sun/star/style/NumberingType.hpp>
26 #include <sal/log.hxx>
27 #include <sax/tools/converter.hxx>
28 #include <xmloff/xmlimp.hxx>
29 #include <xmloff/xmltoken.hxx>
30 #include <xmloff/xmluconv.hxx>
31 #include <xmloff/xmlprmap.hxx>
32 #include <xmloff/xmlnamespace.hxx>
33 #include <xmloff/namespacemap.hxx>
34 #include <xmloff/maptype.hxx>
35 #include <xmloff/txtprmap.hxx>
40 using namespace ::xmloff::token
;
41 using namespace ::com::sun::star::style
;
44 using ::com::sun::star::uno::Any
;
45 using ::com::sun::star::uno::Reference
;
46 using ::com::sun::star::xml::sax::XAttributeList
;
49 XMLSectionFootnoteConfigImport::XMLSectionFootnoteConfigImport(
51 sal_Int32
/*nElement*/,
52 vector
<XMLPropertyState
> & rProps
,
53 const rtl::Reference
<XMLPropertySetMapper
> & rMapperRef
) :
54 SvXMLImportContext(rImport
),
60 XMLSectionFootnoteConfigImport::~XMLSectionFootnoteConfigImport()
64 void XMLSectionFootnoteConfigImport::startFastElement(
65 sal_Int32
/*nElement*/,
66 const Reference
<css::xml::sax::XFastAttributeList
> & xAttrList
)
69 bool bNumRestart
= false;
70 bool bEndnote
= false;
71 sal_Int16 nNumRestartAt
= 0;
75 OUString sNumLetterSync
;
77 // iterate over xattribute list and fill values
78 for (auto &aIter
: sax_fastparser::castToFastAttributeList(xAttrList
))
80 OUString sAttrValue
= aIter
.toString();
82 switch(aIter
.getToken())
84 case XML_ELEMENT(TEXT
, XML_START_VALUE
):
87 if (::sax::Converter::convertNumber(nTmp
, sAttrValue
))
89 nNumRestartAt
= static_cast< sal_Int16
>( nTmp
) - 1;
94 case XML_ELEMENT(TEXT
, XML_NOTE_CLASS
):
96 if( IsXMLToken( sAttrValue
, XML_ENDNOTE
) )
100 case XML_ELEMENT(STYLE
, XML_NUM_PREFIX
):
102 sNumPrefix
= sAttrValue
;
106 case XML_ELEMENT(TEXT
, XML_NUM_SUFFIX
):
108 sNumSuffix
= sAttrValue
;
112 case XML_ELEMENT(TEXT
, XML_NUM_FORMAT
):
114 sNumFormat
= sAttrValue
;
118 case XML_ELEMENT(TEXT
, XML_NUM_LETTER_SYNC
):
120 sNumLetterSync
= sAttrValue
;
125 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
129 // OK, now we have all values and can fill the XMLPropertyState vector
131 sal_Int32 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
132 CTF_SECTION_ENDNOTE_NUM_OWN
: CTF_SECTION_FOOTNOTE_NUM_OWN
);
133 XMLPropertyState
aNumOwn( nIndex
, css::uno::Any(bNumOwn
) );
134 rProperties
.push_back( aNumOwn
);
136 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
137 CTF_SECTION_ENDNOTE_NUM_RESTART
: CTF_SECTION_FOOTNOTE_NUM_RESTART
);
138 XMLPropertyState
aNumRestart( nIndex
, css::uno::Any(bNumRestart
) );
139 rProperties
.push_back( aNumRestart
);
141 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
142 CTF_SECTION_ENDNOTE_NUM_RESTART_AT
:
143 CTF_SECTION_FOOTNOTE_NUM_RESTART_AT
);
144 XMLPropertyState
aNumRestartAtState( nIndex
, css::uno::Any(nNumRestartAt
) );
145 rProperties
.push_back( aNumRestartAtState
);
147 sal_Int16 nNumType
= NumberingType::ARABIC
;
148 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
151 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
152 CTF_SECTION_ENDNOTE_NUM_TYPE
: CTF_SECTION_FOOTNOTE_NUM_TYPE
);
153 XMLPropertyState
aNumFormatState( nIndex
, css::uno::Any(nNumType
) );
154 rProperties
.push_back( aNumFormatState
);
156 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
157 CTF_SECTION_ENDNOTE_NUM_PREFIX
: CTF_SECTION_FOOTNOTE_NUM_PREFIX
);
158 XMLPropertyState
aPrefixState( nIndex
, css::uno::Any(sNumPrefix
) );
159 rProperties
.push_back( aPrefixState
);
161 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
162 CTF_SECTION_ENDNOTE_NUM_SUFFIX
: CTF_SECTION_FOOTNOTE_NUM_SUFFIX
);
163 XMLPropertyState
aSuffixState( nIndex
, css::uno::Any(sNumSuffix
) );
164 rProperties
.push_back( aSuffixState
);
166 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
167 CTF_SECTION_ENDNOTE_END
: CTF_SECTION_FOOTNOTE_END
);
168 XMLPropertyState
aEndState( nIndex
, css::uno::Any(true) ); // we're inside the element, so this is true
169 rProperties
.push_back( aEndState
);
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */