xref: /AOO42X/main/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
30*cdf0e10cSrcweir #include "XMLFootnoteConfigurationImportContext.hxx"
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #ifndef _RTL_USTRING
33*cdf0e10cSrcweir #include <rtl/ustring.hxx>
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
36*cdf0e10cSrcweir #include <tools/debug.hxx>
37*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
38*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
39*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #ifndef _XMLOFF_FAMILIES_HXX
42*cdf0e10cSrcweir #include <xmloff/families.hxx>
43*cdf0e10cSrcweir #endif
44*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
45*cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
46*cdf0e10cSrcweir #include <xmloff/xmlnumi.hxx>
47*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/text/XFootnote.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/text/XFootnotesSupplier.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/text/XEndnotesSupplier.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/text/FootnoteNumbering.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/style/NumberingType.hpp>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir using ::rtl::OUString;
57*cdf0e10cSrcweir using ::rtl::OUStringBuffer;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir using namespace ::com::sun::star::text;
60*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
61*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
62*cdf0e10cSrcweir using namespace ::com::sun::star::style;
63*cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
64*cdf0e10cSrcweir using namespace ::xmloff::token;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir //
67*cdf0e10cSrcweir //  XMLFootnoteConfigHelper
68*cdf0e10cSrcweir //
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir /// local helper class for import of quo-vadis and ergo-sum elements
71*cdf0e10cSrcweir class XMLFootnoteConfigHelper : public SvXMLImportContext
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir     OUStringBuffer sBuffer;
74*cdf0e10cSrcweir     XMLFootnoteConfigurationImportContext& rConfig;
75*cdf0e10cSrcweir     sal_Bool bIsBegin;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir public:
78*cdf0e10cSrcweir     TYPEINFO();
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     XMLFootnoteConfigHelper(
81*cdf0e10cSrcweir         SvXMLImport& rImport,
82*cdf0e10cSrcweir         sal_uInt16 nPrfx,
83*cdf0e10cSrcweir         const OUString& rLName,
84*cdf0e10cSrcweir         XMLFootnoteConfigurationImportContext& rConfigImport,
85*cdf0e10cSrcweir         sal_Bool bBegin);
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     virtual void EndElement();
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     virtual void Characters( const OUString& rChars );
90*cdf0e10cSrcweir };
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir TYPEINIT1( XMLFootnoteConfigHelper, SvXMLImportContext );
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir XMLFootnoteConfigHelper::XMLFootnoteConfigHelper(
95*cdf0e10cSrcweir     SvXMLImport& rImport,
96*cdf0e10cSrcweir     sal_uInt16 nPrfx,
97*cdf0e10cSrcweir     const OUString& rLName,
98*cdf0e10cSrcweir     XMLFootnoteConfigurationImportContext& rConfigImport,
99*cdf0e10cSrcweir     sal_Bool bBegin)
100*cdf0e10cSrcweir :   SvXMLImportContext(rImport, nPrfx, rLName)
101*cdf0e10cSrcweir ,   sBuffer()
102*cdf0e10cSrcweir ,   rConfig(rConfigImport)
103*cdf0e10cSrcweir ,   bIsBegin(bBegin)
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir }
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir void XMLFootnoteConfigHelper::EndElement()
108*cdf0e10cSrcweir {
109*cdf0e10cSrcweir     if (bIsBegin)
110*cdf0e10cSrcweir     {
111*cdf0e10cSrcweir         rConfig.SetBeginNotice(sBuffer.makeStringAndClear());
112*cdf0e10cSrcweir     }
113*cdf0e10cSrcweir     else
114*cdf0e10cSrcweir     {
115*cdf0e10cSrcweir         rConfig.SetEndNotice(sBuffer.makeStringAndClear());
116*cdf0e10cSrcweir     }
117*cdf0e10cSrcweir //  rConfig = NULL; // import contexts are ref-counted
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir void XMLFootnoteConfigHelper::Characters( const OUString& rChars )
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir     sBuffer.append(rChars);
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir //
127*cdf0e10cSrcweir // XMLFootnoteConfigurationImportContext
128*cdf0e10cSrcweir //
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir TYPEINIT1( XMLFootnoteConfigurationImportContext, SvXMLStyleContext );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir XMLFootnoteConfigurationImportContext::XMLFootnoteConfigurationImportContext(
134*cdf0e10cSrcweir     SvXMLImport& rImport,
135*cdf0e10cSrcweir     sal_uInt16 nPrfx,
136*cdf0e10cSrcweir     const OUString& rLocalName,
137*cdf0e10cSrcweir     const Reference<XAttributeList> & xAttrList)
138*cdf0e10cSrcweir :   SvXMLStyleContext(rImport, nPrfx, rLocalName, xAttrList, XML_STYLE_FAMILY_TEXT_FOOTNOTECONFIG)
139*cdf0e10cSrcweir ,   sPropertyAnchorCharStyleName(RTL_CONSTASCII_USTRINGPARAM("AnchorCharStyleName"))
140*cdf0e10cSrcweir ,   sPropertyCharStyleName(RTL_CONSTASCII_USTRINGPARAM("CharStyleName"))
141*cdf0e10cSrcweir ,   sPropertyNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType"))
142*cdf0e10cSrcweir ,   sPropertyPageStyleName(RTL_CONSTASCII_USTRINGPARAM("PageStyleName"))
143*cdf0e10cSrcweir ,   sPropertyParagraphStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaStyleName"))
144*cdf0e10cSrcweir ,   sPropertyPrefix(RTL_CONSTASCII_USTRINGPARAM("Prefix"))
145*cdf0e10cSrcweir ,   sPropertyStartAt(RTL_CONSTASCII_USTRINGPARAM("StartAt"))
146*cdf0e10cSrcweir ,   sPropertySuffix(RTL_CONSTASCII_USTRINGPARAM("Suffix"))
147*cdf0e10cSrcweir ,   sPropertyPositionEndOfDoc(RTL_CONSTASCII_USTRINGPARAM("PositionEndOfDoc"))
148*cdf0e10cSrcweir ,   sPropertyFootnoteCounting(RTL_CONSTASCII_USTRINGPARAM("FootnoteCounting"))
149*cdf0e10cSrcweir ,   sPropertyEndNotice(RTL_CONSTASCII_USTRINGPARAM("EndNotice"))
150*cdf0e10cSrcweir ,   sPropertyBeginNotice(RTL_CONSTASCII_USTRINGPARAM("BeginNotice"))
151*cdf0e10cSrcweir ,   sNumFormat(RTL_CONSTASCII_USTRINGPARAM("1"))
152*cdf0e10cSrcweir ,   sNumSync(RTL_CONSTASCII_USTRINGPARAM("false"))
153*cdf0e10cSrcweir ,   pAttrTokenMap(NULL)
154*cdf0e10cSrcweir ,   nOffset(0)
155*cdf0e10cSrcweir ,   nNumbering(FootnoteNumbering::PER_PAGE)
156*cdf0e10cSrcweir ,   bPosition(sal_False)
157*cdf0e10cSrcweir ,   bIsEndnote(sal_False)
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir     sal_Int16 nLength = xAttrList->getLength();
160*cdf0e10cSrcweir     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
161*cdf0e10cSrcweir     {
162*cdf0e10cSrcweir         OUString sLocalName;
163*cdf0e10cSrcweir         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
164*cdf0e10cSrcweir             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
165*cdf0e10cSrcweir                               &sLocalName );
166*cdf0e10cSrcweir         if( XML_NAMESPACE_TEXT == nPrefix && IsXMLToken( sLocalName,
167*cdf0e10cSrcweir                                                         XML_NOTE_CLASS ) )
168*cdf0e10cSrcweir         {
169*cdf0e10cSrcweir             const OUString& rValue = xAttrList->getValueByIndex( nAttr );
170*cdf0e10cSrcweir             if( IsXMLToken( rValue, XML_ENDNOTE ) )
171*cdf0e10cSrcweir             {
172*cdf0e10cSrcweir                 bIsEndnote = sal_True;
173*cdf0e10cSrcweir                 SetFamily( XML_STYLE_FAMILY_TEXT_FOOTNOTECONFIG );
174*cdf0e10cSrcweir             }
175*cdf0e10cSrcweir             break;
176*cdf0e10cSrcweir         }
177*cdf0e10cSrcweir     }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir XMLFootnoteConfigurationImportContext::~XMLFootnoteConfigurationImportContext()
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir     delete pAttrTokenMap;
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir enum XMLFtnConfigToken
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_CITATION_STYLENAME,
188*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_ANCHOR_STYLENAME,
189*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_DEFAULT_STYLENAME,
190*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_PAGE_STYLENAME,
191*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_OFFSET,
192*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_NUM_PREFIX,
193*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_NUM_SUFFIX,
194*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_NUM_FORMAT,
195*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_NUM_SYNC,
196*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_START_AT,
197*cdf0e10cSrcweir     XML_TOK_FTNCONFIG_POSITION
198*cdf0e10cSrcweir };
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aTextFieldAttrTokenMap[] =
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_CITATION_STYLE_NAME,      XML_TOK_FTNCONFIG_CITATION_STYLENAME },
203*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_CITATION_BODY_STYLE_NAME, XML_TOK_FTNCONFIG_ANCHOR_STYLENAME },
204*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_DEFAULT_STYLE_NAME,       XML_TOK_FTNCONFIG_DEFAULT_STYLENAME },
205*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_MASTER_PAGE_NAME,         XML_TOK_FTNCONFIG_PAGE_STYLENAME },
206*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_START_VALUE, XML_TOK_FTNCONFIG_OFFSET },
207*cdf0e10cSrcweir     { XML_NAMESPACE_STYLE, XML_NUM_PREFIX, XML_TOK_FTNCONFIG_NUM_PREFIX },
208*cdf0e10cSrcweir     { XML_NAMESPACE_STYLE, XML_NUM_SUFFIX, XML_TOK_FTNCONFIG_NUM_SUFFIX },
209*cdf0e10cSrcweir     { XML_NAMESPACE_STYLE, XML_NUM_FORMAT, XML_TOK_FTNCONFIG_NUM_FORMAT },
210*cdf0e10cSrcweir     { XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC, XML_TOK_FTNCONFIG_NUM_SYNC },
211*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_START_NUMBERING_AT, XML_TOK_FTNCONFIG_START_AT},
212*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_FOOTNOTES_POSITION, XML_TOK_FTNCONFIG_POSITION},
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     // for backwards compatibility with SRC630 & earlier
215*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_NUM_PREFIX, XML_TOK_FTNCONFIG_NUM_PREFIX },
216*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_NUM_SUFFIX, XML_TOK_FTNCONFIG_NUM_SUFFIX },
217*cdf0e10cSrcweir     { XML_NAMESPACE_TEXT, XML_OFFSET, XML_TOK_FTNCONFIG_OFFSET },
218*cdf0e10cSrcweir     XML_TOKEN_MAP_END
219*cdf0e10cSrcweir };
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir const SvXMLTokenMap&
222*cdf0e10cSrcweir     XMLFootnoteConfigurationImportContext::GetFtnConfigAttrTokenMap()
223*cdf0e10cSrcweir {
224*cdf0e10cSrcweir     if (NULL == pAttrTokenMap)
225*cdf0e10cSrcweir     {
226*cdf0e10cSrcweir         pAttrTokenMap = new SvXMLTokenMap(aTextFieldAttrTokenMap);
227*cdf0e10cSrcweir     }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     return *pAttrTokenMap;
230*cdf0e10cSrcweir }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir static SvXMLEnumMapEntry __READONLY_DATA aFootnoteNumberingMap[] =
233*cdf0e10cSrcweir {
234*cdf0e10cSrcweir     { XML_PAGE,             FootnoteNumbering::PER_PAGE },
235*cdf0e10cSrcweir     { XML_CHAPTER,          FootnoteNumbering::PER_CHAPTER },
236*cdf0e10cSrcweir     { XML_DOCUMENT,         FootnoteNumbering::PER_DOCUMENT },
237*cdf0e10cSrcweir     { XML_TOKEN_INVALID,    0 },
238*cdf0e10cSrcweir };
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir void XMLFootnoteConfigurationImportContext::StartElement(
241*cdf0e10cSrcweir     const Reference<XAttributeList> & xAttrList )
242*cdf0e10cSrcweir {
243*cdf0e10cSrcweir     sal_Int16 nLength = xAttrList->getLength();
244*cdf0e10cSrcweir     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
245*cdf0e10cSrcweir     {
246*cdf0e10cSrcweir         OUString sLocalName;
247*cdf0e10cSrcweir         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
248*cdf0e10cSrcweir             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
249*cdf0e10cSrcweir                               &sLocalName );
250*cdf0e10cSrcweir         OUString sValue = xAttrList->getValueByIndex(nAttr);
251*cdf0e10cSrcweir         switch (GetFtnConfigAttrTokenMap().Get(nPrefix, sLocalName))
252*cdf0e10cSrcweir         {
253*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_CITATION_STYLENAME:
254*cdf0e10cSrcweir                 sCitationStyle = sValue;
255*cdf0e10cSrcweir                 break;
256*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_ANCHOR_STYLENAME:
257*cdf0e10cSrcweir                 sAnchorStyle = sValue;
258*cdf0e10cSrcweir                 break;
259*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_DEFAULT_STYLENAME:
260*cdf0e10cSrcweir                 sDefaultStyle = sValue;
261*cdf0e10cSrcweir                 break;
262*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_PAGE_STYLENAME:
263*cdf0e10cSrcweir                 sPageStyle = sValue;
264*cdf0e10cSrcweir                 break;
265*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_OFFSET:
266*cdf0e10cSrcweir             {
267*cdf0e10cSrcweir                 sal_Int32 nTmp;
268*cdf0e10cSrcweir                 if (SvXMLUnitConverter::convertNumber(nTmp, sValue))
269*cdf0e10cSrcweir                 {
270*cdf0e10cSrcweir                     nOffset = (sal_uInt16)nTmp;
271*cdf0e10cSrcweir                 }
272*cdf0e10cSrcweir                 break;
273*cdf0e10cSrcweir             }
274*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_NUM_PREFIX:
275*cdf0e10cSrcweir                 sPrefix = sValue;
276*cdf0e10cSrcweir                 break;
277*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_NUM_SUFFIX:
278*cdf0e10cSrcweir                 sSuffix = sValue;
279*cdf0e10cSrcweir                 break;
280*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_NUM_FORMAT:
281*cdf0e10cSrcweir                 sNumFormat = sValue;
282*cdf0e10cSrcweir                 break;
283*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_NUM_SYNC:
284*cdf0e10cSrcweir                 sNumSync = sValue;
285*cdf0e10cSrcweir                 break;
286*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_START_AT:
287*cdf0e10cSrcweir             {
288*cdf0e10cSrcweir                 sal_uInt16 nTmp;
289*cdf0e10cSrcweir                 if (SvXMLUnitConverter::convertEnum(nTmp, sValue,
290*cdf0e10cSrcweir                                                     aFootnoteNumberingMap))
291*cdf0e10cSrcweir                 {
292*cdf0e10cSrcweir                     nNumbering = nTmp;
293*cdf0e10cSrcweir                 }
294*cdf0e10cSrcweir                 break;
295*cdf0e10cSrcweir             }
296*cdf0e10cSrcweir             case XML_TOK_FTNCONFIG_POSITION:
297*cdf0e10cSrcweir                 bPosition = IsXMLToken( sValue, XML_DOCUMENT );
298*cdf0e10cSrcweir                 break;
299*cdf0e10cSrcweir             default:
300*cdf0e10cSrcweir                 ; // ignore
301*cdf0e10cSrcweir         }
302*cdf0e10cSrcweir     }
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir SvXMLImportContext *XMLFootnoteConfigurationImportContext::CreateChildContext(
306*cdf0e10cSrcweir     sal_uInt16 nPrefix,
307*cdf0e10cSrcweir     const OUString& rLocalName,
308*cdf0e10cSrcweir     const Reference<XAttributeList> & xAttrList )
309*cdf0e10cSrcweir {
310*cdf0e10cSrcweir     SvXMLImportContext* pContext = NULL;
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir     if (!bIsEndnote)
313*cdf0e10cSrcweir     {
314*cdf0e10cSrcweir         if (XML_NAMESPACE_TEXT == nPrefix)
315*cdf0e10cSrcweir         {
316*cdf0e10cSrcweir             if ( IsXMLToken( rLocalName,
317*cdf0e10cSrcweir                              XML_FOOTNOTE_CONTINUATION_NOTICE_FORWARD ) )
318*cdf0e10cSrcweir             {
319*cdf0e10cSrcweir                 pContext = new XMLFootnoteConfigHelper(GetImport(),
320*cdf0e10cSrcweir                                                        nPrefix, rLocalName,
321*cdf0e10cSrcweir                                                        *this, sal_False);
322*cdf0e10cSrcweir             }
323*cdf0e10cSrcweir             else if ( IsXMLToken( rLocalName,
324*cdf0e10cSrcweir                                   XML_FOOTNOTE_CONTINUATION_NOTICE_BACKWARD ) )
325*cdf0e10cSrcweir             {
326*cdf0e10cSrcweir                 pContext = new XMLFootnoteConfigHelper(GetImport(),
327*cdf0e10cSrcweir                                                        nPrefix, rLocalName,
328*cdf0e10cSrcweir                                                        *this, sal_True);
329*cdf0e10cSrcweir             }
330*cdf0e10cSrcweir             // else: default context
331*cdf0e10cSrcweir         }
332*cdf0e10cSrcweir         // else: unknown namespace -> default context
333*cdf0e10cSrcweir     }
334*cdf0e10cSrcweir     // else: endnote -> default context
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir     if (pContext == NULL)
337*cdf0e10cSrcweir     {
338*cdf0e10cSrcweir         // default: delegate to super class
339*cdf0e10cSrcweir         pContext = SvXMLStyleContext::CreateChildContext(nPrefix,
340*cdf0e10cSrcweir                                                          rLocalName,
341*cdf0e10cSrcweir                                                          xAttrList);
342*cdf0e10cSrcweir     }
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir     return pContext;
345*cdf0e10cSrcweir }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir // --> OD 2005-01-31 #i40597# - rename method <CreateAndInsertLate(..)> to
349*cdf0e10cSrcweir // <Finish(..)>
350*cdf0e10cSrcweir void XMLFootnoteConfigurationImportContext::Finish( sal_Bool bOverwrite )
351*cdf0e10cSrcweir // <--
352*cdf0e10cSrcweir {
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir     if (bOverwrite)
355*cdf0e10cSrcweir     {
356*cdf0e10cSrcweir         if (bIsEndnote)
357*cdf0e10cSrcweir         {
358*cdf0e10cSrcweir             Reference<XEndnotesSupplier> xSupplier(
359*cdf0e10cSrcweir                 GetImport().GetModel(), UNO_QUERY);
360*cdf0e10cSrcweir             if (xSupplier.is())
361*cdf0e10cSrcweir             {
362*cdf0e10cSrcweir                 ProcessSettings(xSupplier->getEndnoteSettings());
363*cdf0e10cSrcweir             }
364*cdf0e10cSrcweir         }
365*cdf0e10cSrcweir         else
366*cdf0e10cSrcweir         {
367*cdf0e10cSrcweir             Reference<XFootnotesSupplier> xSupplier(
368*cdf0e10cSrcweir                 GetImport().GetModel(), UNO_QUERY);
369*cdf0e10cSrcweir             if (xSupplier.is())
370*cdf0e10cSrcweir             {
371*cdf0e10cSrcweir                 ProcessSettings(xSupplier->getFootnoteSettings());
372*cdf0e10cSrcweir             }
373*cdf0e10cSrcweir         }
374*cdf0e10cSrcweir     }
375*cdf0e10cSrcweir     // else: ignore (there's only one configuration, so we can only overwrite)
376*cdf0e10cSrcweir }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir void XMLFootnoteConfigurationImportContext::ProcessSettings(
379*cdf0e10cSrcweir     const Reference<XPropertySet> & rConfig)
380*cdf0e10cSrcweir {
381*cdf0e10cSrcweir     Any aAny;
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir     if (sCitationStyle.getLength() > 0)
384*cdf0e10cSrcweir     {
385*cdf0e10cSrcweir         aAny <<= GetImport().GetStyleDisplayName(
386*cdf0e10cSrcweir                         XML_STYLE_FAMILY_TEXT_TEXT, sCitationStyle );
387*cdf0e10cSrcweir         rConfig->setPropertyValue(sPropertyCharStyleName, aAny);
388*cdf0e10cSrcweir     }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir     if (sAnchorStyle.getLength() > 0)
391*cdf0e10cSrcweir     {
392*cdf0e10cSrcweir         aAny <<= GetImport().GetStyleDisplayName(
393*cdf0e10cSrcweir                         XML_STYLE_FAMILY_TEXT_TEXT, sAnchorStyle );
394*cdf0e10cSrcweir         rConfig->setPropertyValue(sPropertyAnchorCharStyleName, aAny);
395*cdf0e10cSrcweir     }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir     if (sPageStyle.getLength() > 0)
398*cdf0e10cSrcweir     {
399*cdf0e10cSrcweir         aAny <<= GetImport().GetStyleDisplayName(
400*cdf0e10cSrcweir                         XML_STYLE_FAMILY_MASTER_PAGE, sPageStyle );
401*cdf0e10cSrcweir         rConfig->setPropertyValue(sPropertyPageStyleName, aAny);
402*cdf0e10cSrcweir     }
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir     if (sDefaultStyle.getLength() > 0)
405*cdf0e10cSrcweir     {
406*cdf0e10cSrcweir         aAny <<= GetImport().GetStyleDisplayName(
407*cdf0e10cSrcweir                         XML_STYLE_FAMILY_TEXT_PARAGRAPH, sDefaultStyle );
408*cdf0e10cSrcweir         rConfig->setPropertyValue(sPropertyParagraphStyleName, aAny);
409*cdf0e10cSrcweir     }
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir     aAny <<= sPrefix;
412*cdf0e10cSrcweir     rConfig->setPropertyValue(sPropertyPrefix, aAny);
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir     aAny <<= sSuffix;
415*cdf0e10cSrcweir     rConfig->setPropertyValue(sPropertySuffix, aAny);
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir     sal_Int16 nNumType = NumberingType::ARABIC;
418*cdf0e10cSrcweir     GetImport().GetMM100UnitConverter().convertNumFormat( nNumType, sNumFormat,
419*cdf0e10cSrcweir                                                      sNumSync );
420*cdf0e10cSrcweir     // #i61399: Corrupt file? It contains "Bullet" as numbering style for footnotes.
421*cdf0e10cSrcweir     // Okay, even it seems to be corrupt, we will oversee this and set the style to ARABIC
422*cdf0e10cSrcweir     if( NumberingType::CHAR_SPECIAL == nNumType )
423*cdf0e10cSrcweir         nNumType = NumberingType::ARABIC;
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir     aAny <<=  nNumType;
426*cdf0e10cSrcweir     rConfig->setPropertyValue(sPropertyNumberingType, aAny);
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir     aAny <<= nOffset;
429*cdf0e10cSrcweir     rConfig->setPropertyValue(sPropertyStartAt, aAny);
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir     if (!bIsEndnote)
432*cdf0e10cSrcweir     {
433*cdf0e10cSrcweir         aAny.setValue(&bPosition, ::getBooleanCppuType());
434*cdf0e10cSrcweir         rConfig->setPropertyValue(sPropertyPositionEndOfDoc, aAny);
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir         aAny <<= nNumbering;
437*cdf0e10cSrcweir         rConfig->setPropertyValue(sPropertyFootnoteCounting, aAny);
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir         aAny <<= sEndNotice;
440*cdf0e10cSrcweir         rConfig->setPropertyValue(sPropertyEndNotice, aAny);
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir         aAny <<= sBeginNotice;
443*cdf0e10cSrcweir         rConfig->setPropertyValue(sPropertyBeginNotice, aAny);
444*cdf0e10cSrcweir     }
445*cdf0e10cSrcweir }
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir void XMLFootnoteConfigurationImportContext::SetBeginNotice(
448*cdf0e10cSrcweir     OUString sText)
449*cdf0e10cSrcweir {
450*cdf0e10cSrcweir     sBeginNotice = sText;
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir void XMLFootnoteConfigurationImportContext::SetEndNotice(
454*cdf0e10cSrcweir     OUString sText)
455*cdf0e10cSrcweir {
456*cdf0e10cSrcweir     sEndNotice = sText;
457*cdf0e10cSrcweir }
458