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>
29 #include <xmloff/xmlimp.hxx>
30 #include <xmloff/xmltoken.hxx>
31 #include <xmloff/xmluconv.hxx>
32 #include <xmloff/xmlprmap.hxx>
33 #include <xmloff/xmlnamespace.hxx>
34 #include <xmloff/namespacemap.hxx>
35 #include <xmloff/maptype.hxx>
36 #include <xmloff/txtprmap.hxx>
41 using namespace ::xmloff::token
;
42 using namespace ::com::sun::star::style
;
45 using ::com::sun::star::uno::Any
;
46 using ::com::sun::star::uno::Reference
;
49 XMLSectionFootnoteConfigImport::XMLSectionFootnoteConfigImport(
51 sal_Int32
/*nElement*/,
52 vector
<XMLPropertyState
> & rProps
,
53 rtl::Reference
<XMLPropertySetMapper
> xMapperRef
) :
54 SvXMLImportContext(rImport
),
56 rMapper(std::move(xMapperRef
))
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 switch(aIter
.getToken())
82 case XML_ELEMENT(TEXT
, XML_START_VALUE
):
85 if (::sax::Converter::convertNumber(nTmp
, aIter
.toView()))
87 nNumRestartAt
= static_cast< sal_Int16
>( nTmp
) - 1;
92 case XML_ELEMENT(TEXT
, XML_NOTE_CLASS
):
94 if( IsXMLToken( aIter
, XML_ENDNOTE
) )
98 case XML_ELEMENT(STYLE
, XML_NUM_PREFIX
):
100 sNumPrefix
= aIter
.toString();
104 case XML_ELEMENT(STYLE
, XML_NUM_SUFFIX
):
106 sNumSuffix
= aIter
.toString();
110 case XML_ELEMENT(STYLE
, XML_NUM_FORMAT
):
112 sNumFormat
= aIter
.toString();
116 case XML_ELEMENT(STYLE
, XML_NUM_LETTER_SYNC
):
118 sNumLetterSync
= aIter
.toString();
123 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
127 // OK, now we have all values and can fill the XMLPropertyState vector
129 sal_Int32 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
130 CTF_SECTION_ENDNOTE_NUM_OWN
: CTF_SECTION_FOOTNOTE_NUM_OWN
);
131 XMLPropertyState
aNumOwn( nIndex
, css::uno::Any(bNumOwn
) );
132 rProperties
.push_back( aNumOwn
);
134 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
135 CTF_SECTION_ENDNOTE_NUM_RESTART
: CTF_SECTION_FOOTNOTE_NUM_RESTART
);
136 XMLPropertyState
aNumRestart( nIndex
, css::uno::Any(bNumRestart
) );
137 rProperties
.push_back( aNumRestart
);
139 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
140 CTF_SECTION_ENDNOTE_NUM_RESTART_AT
:
141 CTF_SECTION_FOOTNOTE_NUM_RESTART_AT
);
142 XMLPropertyState
aNumRestartAtState( nIndex
, css::uno::Any(nNumRestartAt
) );
143 rProperties
.push_back( aNumRestartAtState
);
145 sal_Int16 nNumType
= NumberingType::ARABIC
;
146 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
149 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
150 CTF_SECTION_ENDNOTE_NUM_TYPE
: CTF_SECTION_FOOTNOTE_NUM_TYPE
);
151 XMLPropertyState
aNumFormatState( nIndex
, css::uno::Any(nNumType
) );
152 rProperties
.push_back( aNumFormatState
);
154 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
155 CTF_SECTION_ENDNOTE_NUM_PREFIX
: CTF_SECTION_FOOTNOTE_NUM_PREFIX
);
156 XMLPropertyState
aPrefixState( nIndex
, css::uno::Any(sNumPrefix
) );
157 rProperties
.push_back( aPrefixState
);
159 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
160 CTF_SECTION_ENDNOTE_NUM_SUFFIX
: CTF_SECTION_FOOTNOTE_NUM_SUFFIX
);
161 XMLPropertyState
aSuffixState( nIndex
, css::uno::Any(sNumSuffix
) );
162 rProperties
.push_back( aSuffixState
);
164 nIndex
= rMapper
->FindEntryIndex( bEndnote
?
165 CTF_SECTION_ENDNOTE_END
: CTF_SECTION_FOOTNOTE_END
);
166 XMLPropertyState
aEndState( nIndex
, css::uno::Any(true) ); // we're inside the element, so this is true
167 rProperties
.push_back( aEndState
);
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */