xref: /AOO41X/main/xmloff/source/text/txtparai.cxx (revision ff0525f24f03981d56b7579b645949f111420994)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "unointerfacetouniqueidentifiermapper.hxx"
27 #include <rtl/ustring.hxx>
28 #include <rtl/ustrbuf.hxx>
29 #include <tools/debug.hxx>
30 
31 #include <tools/string.hxx>
32 #include <svl/svarray.hxx>
33 #include <com/sun/star/text/XTextFrame.hpp>
34 #include <com/sun/star/text/XTextCursor.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/beans/XPropertySetInfo.hpp>
37 #include <com/sun/star/text/ControlCharacter.hpp>
38 #include <com/sun/star/container/XIndexReplace.hpp>
39 #include <com/sun/star/drawing/XShapes.hpp>
40 #include <com/sun/star/container/XEnumerationAccess.hpp>
41 #include <com/sun/star/rdf/XMetadatable.hpp>
42 
43 
44 #include <xmloff/xmlictxt.hxx>
45 #include <xmloff/xmlimp.hxx>
46 #include <xmloff/xmltoken.hxx>
47 #include <xmloff/nmspmap.hxx>
48 #include "xmloff/xmlnmspe.hxx"
49 #include <xmloff/txtimp.hxx>
50 #include "txtparai.hxx"
51 #include "txtfldi.hxx"
52 #include <xmloff/xmluconv.hxx>
53 #include "XMLFootnoteImportContext.hxx"
54 #include "XMLTextMarkImportContext.hxx"
55 #include "XMLTextFrameContext.hxx"
56 #include <xmloff/XMLCharContext.hxx>
57 #include "XMLTextFrameHyperlinkContext.hxx"
58 #include <xmloff/XMLEventsImportContext.hxx>
59 #include "XMLChangeImportContext.hxx"
60 #include "txtlists.hxx"
61 
62 
63 // OD 2004-04-21 #i26791#
64 #include <txtparaimphint.hxx>
65 typedef XMLHint_Impl *XMLHint_ImplPtr;
66 SV_DECL_PTRARR_DEL( XMLHints_Impl, XMLHint_ImplPtr, 5, 5 )
67 SV_IMPL_PTRARR( XMLHints_Impl, XMLHint_ImplPtr )
68 // OD 2004-04-21 #i26791#
69 #include <com/sun/star/beans/XPropertySet.hpp>
70 
71 using ::rtl::OUString;
72 using ::rtl::OUStringBuffer;
73 
74 using namespace ::com::sun::star;
75 using namespace ::com::sun::star::uno;
76 using namespace ::com::sun::star::text;
77 using namespace ::com::sun::star::drawing;
78 using namespace ::com::sun::star::beans;
79 using namespace ::xmloff::token;
80 using ::com::sun::star::container::XEnumerationAccess;
81 using ::com::sun::star::container::XEnumeration;
82 
83 
84 TYPEINIT1( XMLCharContext, SvXMLImportContext );
85 
86 XMLCharContext::XMLCharContext(
87         SvXMLImport& rImport,
88         sal_uInt16 nPrfx,
89         const OUString& rLName,
90         const Reference< xml::sax::XAttributeList > & xAttrList,
91         sal_Unicode c,
92         sal_Bool bCount ) :
93     SvXMLImportContext( rImport, nPrfx, rLName )
94     ,m_nControl(0)
95     ,m_nCount(1)
96     ,m_c(c)
97 {
98     if( bCount )
99     {
100         const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
101         sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
102         for( sal_Int16 i=0; i < nAttrCount; i++ )
103         {
104             const OUString& rAttrName = xAttrList->getNameByIndex( i );
105 
106             OUString aLocalName;
107             sal_uInt16 nPrefix =rMap.GetKeyByAttrName( rAttrName,&aLocalName );
108             if( XML_NAMESPACE_TEXT == nPrefix &&
109                 IsXMLToken( aLocalName, XML_C ) )
110             {
111                 sal_Int32 nTmp = xAttrList->getValueByIndex(i).toInt32();
112                 if( nTmp > 0L )
113                 {
114                     if( nTmp > USHRT_MAX )
115                         m_nCount = USHRT_MAX;
116                     else
117                         m_nCount = (sal_uInt16)nTmp;
118                 }
119             }
120         }
121     }
122 }
123 
124 XMLCharContext::XMLCharContext(
125         SvXMLImport& rImp,
126         sal_uInt16 nPrfx,
127         const OUString& rLName,
128         const Reference< xml::sax::XAttributeList > &,
129         sal_Int16 nControl ) :
130     SvXMLImportContext( rImp, nPrfx, rLName )
131     ,m_nControl(nControl)
132     ,m_nCount(0)
133 {
134 }
135 
136 XMLCharContext::~XMLCharContext()
137 {
138 }
139 // -----------------------------------------------------------------------------
140 void XMLCharContext::EndElement()
141 {
142     if ( !m_nCount )
143         InsertControlCharacter( m_nControl );
144     else
145     {
146         if( 1U == m_nCount )
147         {
148             OUString sBuff( &m_c, 1 );
149             InsertString(sBuff);
150         }
151         else
152         {
153             OUStringBuffer sBuff( m_nCount );
154             while( m_nCount-- )
155                 sBuff.append( &m_c, 1 );
156 
157             InsertString(sBuff.makeStringAndClear() );
158         }
159     }
160 }
161 // -----------------------------------------------------------------------------
162 void XMLCharContext::InsertControlCharacter(sal_Int16   _nControl)
163 {
164     GetImport().GetTextImport()->InsertControlCharacter( _nControl );
165 }
166 void XMLCharContext::InsertString(const ::rtl::OUString& _sString)
167 {
168     GetImport().GetTextImport()->InsertString( _sString );
169 }
170 
171 // ---------------------------------------------------------------------
172 
173 /** import start of reference (<text:reference-start>) */
174 class XMLStartReferenceContext_Impl : public SvXMLImportContext
175 {
176 public:
177     TYPEINFO();
178 
179     // Do everything in constructor. Well ...
180     XMLStartReferenceContext_Impl (
181         SvXMLImport& rImport,
182         sal_uInt16 nPrefix,
183         const OUString& rLocalName,
184         XMLHints_Impl& rHnts,
185         const Reference<xml::sax::XAttributeList> & xAttrList);
186 
187     static sal_Bool FindName(
188         SvXMLImport& rImport,
189         const Reference<xml::sax::XAttributeList> & xAttrList,
190         OUString& rName);
191 };
192 
193 TYPEINIT1( XMLStartReferenceContext_Impl, SvXMLImportContext );
194 
195 XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl(
196     SvXMLImport& rImport,
197     sal_uInt16 nPrefix,
198     const OUString& rLocalName,
199     XMLHints_Impl& rHints,
200     const Reference<xml::sax::XAttributeList> & xAttrList) :
201         SvXMLImportContext(rImport, nPrefix, rLocalName)
202 {
203     OUString sName;
204 
205     if (FindName(GetImport(), xAttrList, sName))
206     {
207         XMLHint_Impl* pHint = new XMLReferenceHint_Impl(
208             sName, rImport.GetTextImport()->GetCursor()->getStart() );
209 
210         // degenerates to point reference, if no end is found!
211         pHint->SetEnd(rImport.GetTextImport()->GetCursor()->getStart() );
212 
213         rHints.Insert(pHint, rHints.Count());
214     }
215 }
216 
217 sal_Bool XMLStartReferenceContext_Impl::FindName(
218     SvXMLImport& rImport,
219     const Reference<xml::sax::XAttributeList> & xAttrList,
220     OUString& rName)
221 {
222     sal_Bool bNameOK( sal_False );
223 
224     // find name attribute first
225     const sal_Int16 nLength( xAttrList->getLength() );
226     for (sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
227     {
228         OUString sLocalName;
229         const sal_uInt16 nPrefix = rImport.GetNamespaceMap().
230             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
231                               &sLocalName );
232 
233         if ( (XML_NAMESPACE_TEXT == nPrefix) &&
234              IsXMLToken(sLocalName, XML_NAME)   )
235         {
236             rName = xAttrList->getValueByIndex(nAttr);
237             bNameOK = sal_True;
238         }
239     }
240 
241     return bNameOK;
242 }
243 
244 // ---------------------------------------------------------------------
245 
246 /** import end of reference (<text:reference-end>) */
247 class XMLEndReferenceContext_Impl : public SvXMLImportContext
248 {
249 public:
250     TYPEINFO();
251 
252     // Do everything in constructor. Well ...
253     XMLEndReferenceContext_Impl(
254         SvXMLImport& rImport,
255         sal_uInt16 nPrefix,
256         const OUString& rLocalName,
257         XMLHints_Impl& rHnts,
258         const Reference<xml::sax::XAttributeList> & xAttrList);
259 };
260 
261 TYPEINIT1( XMLEndReferenceContext_Impl, SvXMLImportContext );
262 
263 XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl(
264     SvXMLImport& rImport,
265     sal_uInt16 nPrefix,
266     const OUString& rLocalName,
267     XMLHints_Impl& rHints,
268     const Reference<xml::sax::XAttributeList> & xAttrList) :
269         SvXMLImportContext(rImport, nPrefix, rLocalName)
270 {
271     OUString sName;
272 
273     // borrow from XMLStartReferenceContext_Impl
274     if (XMLStartReferenceContext_Impl::FindName(GetImport(), xAttrList, sName))
275     {
276         // search for reference start
277         sal_uInt16 nCount = rHints.Count();
278         for(sal_uInt16 nPos = 0; nPos < nCount; nPos++)
279         {
280             XMLHint_Impl *pHint = rHints[nPos];
281             if ( pHint->IsReference() &&
282                  sName.equals( ((XMLReferenceHint_Impl *)pHint)->GetRefName()) )
283             {
284                 // set end and stop searching
285                 pHint->SetEnd(GetImport().GetTextImport()->
286                                      GetCursor()->getStart() );
287                 break;
288             }
289         }
290         // else: no start (in this paragraph) -> ignore
291     }
292 }
293 
294 // ---------------------------------------------------------------------
295 
296 class XMLImpSpanContext_Impl : public SvXMLImportContext
297 {
298     const OUString sTextFrame;
299 
300     XMLHints_Impl&  rHints;
301     XMLStyleHint_Impl   *pHint;
302 
303     sal_Bool&       rIgnoreLeadingSpace;
304 
305     sal_uInt8               nStarFontsConvFlags;
306 
307 public:
308 
309     TYPEINFO();
310 
311     XMLImpSpanContext_Impl(
312             SvXMLImport& rImport,
313             sal_uInt16 nPrfx,
314             const OUString& rLName,
315             const Reference< xml::sax::XAttributeList > & xAttrList,
316             XMLHints_Impl& rHnts,
317             sal_Bool& rIgnLeadSpace
318     ,sal_uInt8              nSFConvFlags
319                           );
320 
321     virtual ~XMLImpSpanContext_Impl();
322 
323     static SvXMLImportContext *CreateChildContext(
324             SvXMLImport& rImport,
325             sal_uInt16 nPrefix, const OUString& rLocalName,
326             const Reference< xml::sax::XAttributeList > & xAttrList,
327             sal_uInt16 nToken, XMLHints_Impl& rHnts,
328             sal_Bool& rIgnLeadSpace
329     ,sal_uInt8              nStarFontsConvFlags = 0
330              );
331     virtual SvXMLImportContext *CreateChildContext(
332             sal_uInt16 nPrefix, const OUString& rLocalName,
333             const Reference< xml::sax::XAttributeList > & xAttrList );
334 
335     virtual void Characters( const OUString& rChars );
336 };
337 // ---------------------------------------------------------------------
338 
339 class XMLImpHyperlinkContext_Impl : public SvXMLImportContext
340 {
341     XMLHints_Impl&  rHints;
342     XMLHyperlinkHint_Impl   *pHint;
343 
344     sal_Bool&       rIgnoreLeadingSpace;
345 
346 public:
347 
348     TYPEINFO();
349 
350     XMLImpHyperlinkContext_Impl(
351             SvXMLImport& rImport,
352             sal_uInt16 nPrfx,
353             const OUString& rLName,
354             const Reference< xml::sax::XAttributeList > & xAttrList,
355             XMLHints_Impl& rHnts,
356             sal_Bool& rIgnLeadSpace );
357 
358     virtual ~XMLImpHyperlinkContext_Impl();
359 
360     virtual SvXMLImportContext *CreateChildContext(
361             sal_uInt16 nPrefix, const OUString& rLocalName,
362             const Reference< xml::sax::XAttributeList > & xAttrList );
363 
364     virtual void Characters( const OUString& rChars );
365 };
366 
367 TYPEINIT1( XMLImpHyperlinkContext_Impl, SvXMLImportContext );
368 
369 XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl(
370         SvXMLImport& rImport,
371         sal_uInt16 nPrfx,
372         const OUString& rLName,
373         const Reference< xml::sax::XAttributeList > & xAttrList,
374         XMLHints_Impl& rHnts,
375         sal_Bool& rIgnLeadSpace ) :
376     SvXMLImportContext( rImport, nPrfx, rLName ),
377     rHints( rHnts ),
378     pHint( new XMLHyperlinkHint_Impl(
379               GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) ),
380     rIgnoreLeadingSpace( rIgnLeadSpace )
381 {
382     OUString sShow;
383     const SvXMLTokenMap& rTokenMap =
384         GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap();
385 
386     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
387     for( sal_Int16 i=0; i < nAttrCount; i++ )
388     {
389         const OUString& rAttrName = xAttrList->getNameByIndex( i );
390         const OUString& rValue = xAttrList->getValueByIndex( i );
391 
392         OUString aLocalName;
393         sal_uInt16 nPrefix =
394             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
395                                                             &aLocalName );
396         switch( rTokenMap.Get( nPrefix, aLocalName ) )
397         {
398         case XML_TOK_TEXT_HYPERLINK_HREF:
399             pHint->SetHRef( GetImport().GetAbsoluteReference( rValue ) );
400             break;
401         case XML_TOK_TEXT_HYPERLINK_NAME:
402             pHint->SetName( rValue );
403             break;
404         case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME:
405             pHint->SetTargetFrameName( rValue );
406             break;
407         case XML_TOK_TEXT_HYPERLINK_SHOW:
408             sShow = rValue;
409             break;
410         case XML_TOK_TEXT_HYPERLINK_STYLE_NAME:
411             pHint->SetStyleName( rValue );
412             break;
413         case XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME:
414             pHint->SetVisitedStyleName( rValue );
415             break;
416         }
417     }
418 
419     if( sShow.getLength() && !pHint->GetTargetFrameName().getLength() )
420     {
421         if( IsXMLToken( sShow, XML_NEW ) )
422             pHint->SetTargetFrameName(
423                     OUString( RTL_CONSTASCII_USTRINGPARAM("_blank" ) ) );
424         else if( IsXMLToken( sShow, XML_REPLACE ) )
425             pHint->SetTargetFrameName(
426                     OUString( RTL_CONSTASCII_USTRINGPARAM("_self" ) ) );
427     }
428     rHints.Insert( pHint, rHints.Count() );
429 }
430 
431 XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl()
432 {
433     if( pHint )
434         pHint->SetEnd( GetImport().GetTextImport()
435                             ->GetCursorAsRange()->getStart() );
436 }
437 
438 SvXMLImportContext *XMLImpHyperlinkContext_Impl::CreateChildContext(
439         sal_uInt16 nPrefix, const OUString& rLocalName,
440         const Reference< xml::sax::XAttributeList > & xAttrList )
441 {
442     if ( (nPrefix == XML_NAMESPACE_OFFICE) &&
443          IsXMLToken(rLocalName, XML_EVENT_LISTENERS) )
444     {
445         XMLEventsImportContext* pCtxt = new XMLEventsImportContext(
446             GetImport(), nPrefix, rLocalName);
447         pHint->SetEventsContext(pCtxt);
448         return pCtxt;
449     }
450     else
451     {
452         const SvXMLTokenMap& rTokenMap =
453             GetImport().GetTextImport()->GetTextPElemTokenMap();
454         sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
455 
456         return XMLImpSpanContext_Impl::CreateChildContext(
457             GetImport(), nPrefix, rLocalName, xAttrList,
458             nToken, rHints, rIgnoreLeadingSpace );
459     }
460 }
461 
462 void XMLImpHyperlinkContext_Impl::Characters( const OUString& rChars )
463 {
464     GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace );
465 }
466 
467 // ---------------------------------------------------------------------
468 
469 class XMLImpRubyBaseContext_Impl : public SvXMLImportContext
470 {
471     XMLHints_Impl&  rHints;
472 
473     sal_Bool&       rIgnoreLeadingSpace;
474 
475 public:
476 
477     TYPEINFO();
478 
479     XMLImpRubyBaseContext_Impl(
480             SvXMLImport& rImport,
481             sal_uInt16 nPrfx,
482             const OUString& rLName,
483             const Reference< xml::sax::XAttributeList > & xAttrList,
484             XMLHints_Impl& rHnts,
485             sal_Bool& rIgnLeadSpace );
486 
487     virtual ~XMLImpRubyBaseContext_Impl();
488 
489     virtual SvXMLImportContext *CreateChildContext(
490             sal_uInt16 nPrefix, const OUString& rLocalName,
491             const Reference< xml::sax::XAttributeList > & xAttrList );
492 
493     virtual void Characters( const OUString& rChars );
494 };
495 
496 TYPEINIT1( XMLImpRubyBaseContext_Impl, SvXMLImportContext );
497 
498 XMLImpRubyBaseContext_Impl::XMLImpRubyBaseContext_Impl(
499         SvXMLImport& rImport,
500         sal_uInt16 nPrfx,
501         const OUString& rLName,
502         const Reference< xml::sax::XAttributeList > &,
503         XMLHints_Impl& rHnts,
504         sal_Bool& rIgnLeadSpace ) :
505     SvXMLImportContext( rImport, nPrfx, rLName ),
506     rHints( rHnts ),
507     rIgnoreLeadingSpace( rIgnLeadSpace )
508 {
509 }
510 
511 XMLImpRubyBaseContext_Impl::~XMLImpRubyBaseContext_Impl()
512 {
513 }
514 
515 SvXMLImportContext *XMLImpRubyBaseContext_Impl::CreateChildContext(
516         sal_uInt16 nPrefix, const OUString& rLocalName,
517         const Reference< xml::sax::XAttributeList > & xAttrList )
518 {
519     const SvXMLTokenMap& rTokenMap =
520         GetImport().GetTextImport()->GetTextPElemTokenMap();
521     sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
522 
523     return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), nPrefix,
524                                                        rLocalName, xAttrList,
525                                nToken, rHints, rIgnoreLeadingSpace );
526 }
527 
528 void XMLImpRubyBaseContext_Impl::Characters( const OUString& rChars )
529 {
530     GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace );
531 }
532 
533 // ---------------------------------------------------------------------
534 
535 class XMLImpRubyContext_Impl : public SvXMLImportContext
536 {
537     XMLHints_Impl&  rHints;
538 
539     sal_Bool&       rIgnoreLeadingSpace;
540 
541     Reference < XTextRange > m_xStart;
542     OUString        m_sStyleName;
543     OUString        m_sTextStyleName;
544     OUString        m_sText;
545 
546 public:
547 
548     TYPEINFO();
549 
550     XMLImpRubyContext_Impl(
551             SvXMLImport& rImport,
552             sal_uInt16 nPrfx,
553             const OUString& rLName,
554             const Reference< xml::sax::XAttributeList > & xAttrList,
555             XMLHints_Impl& rHnts,
556             sal_Bool& rIgnLeadSpace );
557 
558     virtual ~XMLImpRubyContext_Impl();
559 
560     virtual SvXMLImportContext *CreateChildContext(
561             sal_uInt16 nPrefix, const OUString& rLocalName,
562             const Reference< xml::sax::XAttributeList > & xAttrList );
563 
564     void SetTextStyleName( const OUString& s ) { m_sTextStyleName = s; }
565     void AppendText( const OUString& s ) { m_sText += s; }
566 };
567 
568 // ---------------------------------------------------------------------
569 
570 class XMLImpRubyTextContext_Impl : public SvXMLImportContext
571 {
572     XMLImpRubyContext_Impl & m_rRubyContext;
573 
574 public:
575 
576     TYPEINFO();
577 
578     XMLImpRubyTextContext_Impl(
579             SvXMLImport& rImport,
580             sal_uInt16 nPrfx,
581             const OUString& rLName,
582             const Reference< xml::sax::XAttributeList > & xAttrList,
583             XMLImpRubyContext_Impl & rParent );
584 
585     virtual ~XMLImpRubyTextContext_Impl();
586 
587     virtual void Characters( const OUString& rChars );
588 };
589 
590 TYPEINIT1( XMLImpRubyTextContext_Impl, SvXMLImportContext );
591 
592 XMLImpRubyTextContext_Impl::XMLImpRubyTextContext_Impl(
593         SvXMLImport& rImport,
594         sal_uInt16 nPrfx,
595         const OUString& rLName,
596         const Reference< xml::sax::XAttributeList > & xAttrList,
597         XMLImpRubyContext_Impl & rParent )
598     : SvXMLImportContext( rImport, nPrfx, rLName )
599     , m_rRubyContext( rParent )
600 {
601     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
602     for( sal_Int16 i=0; i < nAttrCount; i++ )
603     {
604         const OUString& rAttrName = xAttrList->getNameByIndex( i );
605         const OUString& rValue = xAttrList->getValueByIndex( i );
606 
607         OUString aLocalName;
608         sal_uInt16 nPrefix =
609             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
610                                                             &aLocalName );
611         if( XML_NAMESPACE_TEXT == nPrefix &&
612             IsXMLToken( aLocalName, XML_STYLE_NAME ) )
613         {
614             m_rRubyContext.SetTextStyleName( rValue );
615             break;
616         }
617     }
618 }
619 
620 XMLImpRubyTextContext_Impl::~XMLImpRubyTextContext_Impl()
621 {
622 }
623 
624 void XMLImpRubyTextContext_Impl::Characters( const OUString& rChars )
625 {
626     m_rRubyContext.AppendText( rChars );
627 }
628 
629 // ---------------------------------------------------------------------
630 
631 TYPEINIT1( XMLImpRubyContext_Impl, SvXMLImportContext );
632 
633 XMLImpRubyContext_Impl::XMLImpRubyContext_Impl(
634         SvXMLImport& rImport,
635         sal_uInt16 nPrfx,
636         const OUString& rLName,
637         const Reference< xml::sax::XAttributeList > & xAttrList,
638         XMLHints_Impl& rHnts,
639         sal_Bool& rIgnLeadSpace ) :
640     SvXMLImportContext( rImport, nPrfx, rLName ),
641     rHints( rHnts ),
642     rIgnoreLeadingSpace( rIgnLeadSpace )
643     , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
644 {
645     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
646     for( sal_Int16 i=0; i < nAttrCount; i++ )
647     {
648         const OUString& rAttrName = xAttrList->getNameByIndex( i );
649         const OUString& rValue = xAttrList->getValueByIndex( i );
650 
651         OUString aLocalName;
652         sal_uInt16 nPrefix =
653             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
654                                                             &aLocalName );
655         if( XML_NAMESPACE_TEXT == nPrefix &&
656             IsXMLToken( aLocalName, XML_STYLE_NAME ) )
657         {
658             m_sStyleName = rValue;
659             break;
660         }
661     }
662 }
663 
664 XMLImpRubyContext_Impl::~XMLImpRubyContext_Impl()
665 {
666     const UniReference < XMLTextImportHelper > xTextImport(
667         GetImport().GetTextImport());
668     const Reference < XTextCursor > xAttrCursor(
669         xTextImport->GetText()->createTextCursorByRange( m_xStart ));
670     xAttrCursor->gotoRange(xTextImport->GetCursorAsRange()->getStart(),
671             sal_True);
672     xTextImport->SetRuby( GetImport(), xAttrCursor,
673          m_sStyleName, m_sTextStyleName, m_sText );
674 }
675 
676 SvXMLImportContext *XMLImpRubyContext_Impl::CreateChildContext(
677         sal_uInt16 nPrefix, const OUString& rLocalName,
678         const Reference< xml::sax::XAttributeList > & xAttrList )
679 {
680     SvXMLImportContext *pContext;
681     if( XML_NAMESPACE_TEXT == nPrefix )
682     {
683         if( IsXMLToken( rLocalName, XML_RUBY_BASE ) )
684             pContext = new XMLImpRubyBaseContext_Impl( GetImport(), nPrefix,
685                                                        rLocalName,
686                                                        xAttrList,
687                                                        rHints,
688                                                        rIgnoreLeadingSpace );
689         else if( IsXMLToken( rLocalName, XML_RUBY_TEXT ) )
690             pContext = new XMLImpRubyTextContext_Impl( GetImport(), nPrefix,
691                                                        rLocalName,
692                                                        xAttrList,
693                                                        *this );
694         else
695             pContext = new SvXMLImportContext(
696                 GetImport(), nPrefix, rLocalName );
697     }
698     else
699         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName,
700                                                             xAttrList );
701 
702     return pContext;
703 }
704 
705 // ---------------------------------------------------------------------
706 
707 /** for text:meta and text:meta-field
708  */
709 class XMLMetaImportContextBase : public SvXMLImportContext
710 {
711     XMLHints_Impl&    m_rHints;
712 
713     sal_Bool& m_rIgnoreLeadingSpace;
714 
715     /// start position
716     Reference<XTextRange> m_xStart;
717 
718 protected:
719     OUString m_XmlId;
720 
721 public:
722     TYPEINFO();
723 
724     XMLMetaImportContextBase(
725         SvXMLImport& i_rImport,
726         const sal_uInt16 i_nPrefix,
727         const OUString& i_rLocalName,
728         XMLHints_Impl& i_rHints,
729         sal_Bool & i_rIgnoreLeadingSpace );
730 
731     virtual ~XMLMetaImportContextBase();
732 
733     virtual void StartElement(
734             const Reference<xml::sax::XAttributeList> & i_xAttrList);
735 
736     virtual void EndElement();
737 
738     virtual SvXMLImportContext *CreateChildContext(
739             sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
740             const Reference< xml::sax::XAttributeList > & i_xAttrList);
741 
742     virtual void Characters( const OUString& i_rChars );
743 
744     virtual void ProcessAttribute(sal_uInt16 const i_nPrefix,
745         OUString const & i_rLocalName, OUString const & i_rValue);
746 
747     virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange)
748         = 0;
749 };
750 
751 TYPEINIT1( XMLMetaImportContextBase, SvXMLImportContext );
752 
753 XMLMetaImportContextBase::XMLMetaImportContextBase(
754         SvXMLImport& i_rImport,
755         const sal_uInt16 i_nPrefix,
756         const OUString& i_rLocalName,
757         XMLHints_Impl& i_rHints,
758         sal_Bool & i_rIgnoreLeadingSpace )
759     : SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName )
760     , m_rHints( i_rHints )
761     , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace )
762     , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
763 {
764 }
765 
766 XMLMetaImportContextBase::~XMLMetaImportContextBase()
767 {
768 }
769 
770 void XMLMetaImportContextBase::StartElement(
771         const Reference<xml::sax::XAttributeList> & i_xAttrList)
772 {
773     const sal_Int16 nAttrCount(i_xAttrList.is() ? i_xAttrList->getLength() : 0);
774     for ( sal_Int16 i = 0; i < nAttrCount; ++i )
775     {
776         const OUString& rAttrName( i_xAttrList->getNameByIndex( i ) );
777         const OUString& rValue( i_xAttrList->getValueByIndex( i ) );
778 
779         OUString sLocalName;
780         const sal_uInt16 nPrefix(
781             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
782                                                             &sLocalName ));
783         ProcessAttribute(nPrefix, sLocalName, rValue);
784     }
785 }
786 
787 void XMLMetaImportContextBase::EndElement()
788 {
789     OSL_ENSURE(m_xStart.is(), "no mxStart?");
790     if (!m_xStart.is()) return;
791 
792     const Reference<XTextRange> xEndRange(
793         GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
794 
795     // create range for insertion
796     const Reference<XTextCursor> xInsertionCursor(
797         GetImport().GetTextImport()->GetText()->createTextCursorByRange(
798             xEndRange) );
799     xInsertionCursor->gotoRange(m_xStart, sal_True);
800 
801     const Reference<XTextRange> xInsertionRange(xInsertionCursor, UNO_QUERY);
802 
803     InsertMeta(xInsertionRange);
804 }
805 
806 SvXMLImportContext * XMLMetaImportContextBase::CreateChildContext(
807             sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
808             const Reference< xml::sax::XAttributeList > & i_xAttrList )
809 {
810     const SvXMLTokenMap& rTokenMap(
811         GetImport().GetTextImport()->GetTextPElemTokenMap() );
812     const sal_uInt16 nToken( rTokenMap.Get( i_nPrefix, i_rLocalName ) );
813 
814     return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), i_nPrefix,
815         i_rLocalName, i_xAttrList, nToken, m_rHints, m_rIgnoreLeadingSpace );
816 }
817 
818 void XMLMetaImportContextBase::Characters( const OUString& i_rChars )
819 {
820     GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace);
821 }
822 
823 void XMLMetaImportContextBase::ProcessAttribute(sal_uInt16 const i_nPrefix,
824     OUString const & i_rLocalName, OUString const & i_rValue)
825 {
826     if ( (XML_NAMESPACE_XML == i_nPrefix) && IsXMLToken(i_rLocalName, XML_ID) )
827     {
828         m_XmlId = i_rValue;
829     }
830 }
831 
832 
833 // ---------------------------------------------------------------------
834 
835 /** text:meta */
836 class XMLMetaImportContext : public XMLMetaImportContextBase
837 {
838     // RDFa
839     bool m_bHaveAbout;
840     ::rtl::OUString m_sAbout;
841     ::rtl::OUString m_sProperty;
842     ::rtl::OUString m_sContent;
843     ::rtl::OUString m_sDatatype;
844 
845 public:
846     TYPEINFO();
847 
848     XMLMetaImportContext(
849         SvXMLImport& i_rImport,
850         const sal_uInt16 i_nPrefix,
851         const OUString& i_rLocalName,
852         XMLHints_Impl& i_rHints,
853         sal_Bool & i_rIgnoreLeadingSpace );
854 
855     virtual void ProcessAttribute(sal_uInt16 const i_nPrefix,
856         OUString const & i_rLocalName, OUString const & i_rValue);
857 
858     virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange);
859 };
860 
861 TYPEINIT1( XMLMetaImportContext, XMLMetaImportContextBase );
862 
863 XMLMetaImportContext::XMLMetaImportContext(
864         SvXMLImport& i_rImport,
865         const sal_uInt16 i_nPrefix,
866         const OUString& i_rLocalName,
867         XMLHints_Impl& i_rHints,
868         sal_Bool & i_rIgnoreLeadingSpace )
869     : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName,
870             i_rHints, i_rIgnoreLeadingSpace )
871     , m_bHaveAbout(false)
872 {
873 }
874 
875 void XMLMetaImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix,
876     OUString const & i_rLocalName, OUString const & i_rValue)
877 {
878     if ( XML_NAMESPACE_XHTML == i_nPrefix )
879     {
880         // RDFa
881         if ( IsXMLToken( i_rLocalName, XML_ABOUT) )
882         {
883             m_sAbout = i_rValue;
884             m_bHaveAbout = true;
885         }
886         else if ( IsXMLToken( i_rLocalName, XML_PROPERTY) )
887         {
888             m_sProperty = i_rValue;
889         }
890         else if ( IsXMLToken( i_rLocalName, XML_CONTENT) )
891         {
892             m_sContent = i_rValue;
893         }
894         else if ( IsXMLToken( i_rLocalName, XML_DATATYPE) )
895         {
896             m_sDatatype = i_rValue;
897         }
898     }
899     else
900     {
901         XMLMetaImportContextBase::ProcessAttribute(
902             i_nPrefix, i_rLocalName, i_rValue);
903     }
904 }
905 
906 void XMLMetaImportContext::InsertMeta(
907     const Reference<XTextRange> & i_xInsertionRange)
908 {
909     OSL_ENSURE(!m_bHaveAbout == !m_sProperty.getLength(),
910         "XMLMetaImportContext::InsertMeta: invalid RDFa?");
911     if (m_XmlId.getLength() || (m_bHaveAbout && m_sProperty.getLength()))
912     {
913         // insert mark
914         const uno::Reference<rdf::XMetadatable> xMeta(
915             XMLTextMarkImportContext::CreateAndInsertMark(
916                 GetImport(),
917                 OUString::createFromAscii(
918                     "com.sun.star.text.InContentMetadata"),
919                 OUString(),
920                 i_xInsertionRange, m_XmlId),
921             uno::UNO_QUERY);
922         OSL_ENSURE(xMeta.is(), "cannot insert Meta?");
923 
924         if (xMeta.is() && m_bHaveAbout)
925         {
926             GetImport().AddRDFa(xMeta,
927                 m_sAbout, m_sProperty, m_sContent, m_sDatatype);
928         }
929     }
930     else
931     {
932         OSL_TRACE("invalid <text:meta>: no xml:id, no valid RDFa");
933     }
934 }
935 
936 // ---------------------------------------------------------------------
937 
938 /** text:meta-field */
939 class XMLMetaFieldImportContext : public XMLMetaImportContextBase
940 {
941     OUString m_DataStyleName;
942 
943 public:
944     TYPEINFO();
945 
946     XMLMetaFieldImportContext(
947         SvXMLImport& i_rImport,
948         const sal_uInt16 i_nPrefix,
949         const OUString& i_rLocalName,
950         XMLHints_Impl& i_rHints,
951         sal_Bool & i_rIgnoreLeadingSpace );
952 
953     virtual void ProcessAttribute(sal_uInt16 const i_nPrefix,
954         OUString const & i_rLocalName, OUString const & i_rValue);
955 
956     virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange);
957 };
958 
959 TYPEINIT1( XMLMetaFieldImportContext, XMLMetaImportContextBase );
960 
961 XMLMetaFieldImportContext::XMLMetaFieldImportContext(
962         SvXMLImport& i_rImport,
963         const sal_uInt16 i_nPrefix,
964         const OUString& i_rLocalName,
965         XMLHints_Impl& i_rHints,
966         sal_Bool & i_rIgnoreLeadingSpace )
967     : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName,
968             i_rHints, i_rIgnoreLeadingSpace )
969 {
970 }
971 
972 void XMLMetaFieldImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix,
973     OUString const & i_rLocalName, OUString const & i_rValue)
974 {
975     if ( XML_NAMESPACE_STYLE == i_nPrefix &&
976          IsXMLToken( i_rLocalName, XML_DATA_STYLE_NAME ) )
977     {
978         m_DataStyleName = i_rValue;
979     }
980     else
981     {
982         XMLMetaImportContextBase::ProcessAttribute(
983             i_nPrefix, i_rLocalName, i_rValue);
984     }
985 }
986 
987 void XMLMetaFieldImportContext::InsertMeta(
988     const Reference<XTextRange> & i_xInsertionRange)
989 {
990     if (m_XmlId.getLength()) // valid?
991     {
992         // insert mark
993         const Reference<XPropertySet> xPropertySet(
994             XMLTextMarkImportContext::CreateAndInsertMark(
995                 GetImport(),
996                 OUString::createFromAscii(
997                     "com.sun.star.text.textfield.MetadataField"),
998                 OUString(),
999                 i_xInsertionRange, m_XmlId),
1000             UNO_QUERY);
1001         OSL_ENSURE(xPropertySet.is(), "cannot insert MetaField?");
1002         if (!xPropertySet.is()) return;
1003 
1004         if (m_DataStyleName.getLength())
1005         {
1006             sal_Bool isDefaultLanguage(sal_True);
1007 
1008             const sal_Int32 nKey( GetImport().GetTextImport()->GetDataStyleKey(
1009                                    m_DataStyleName, & isDefaultLanguage) );
1010 
1011             if (-1 != nKey)
1012             {
1013                 static ::rtl::OUString sPropertyIsFixedLanguage(
1014                     ::rtl::OUString::createFromAscii("IsFixedLanguage") );
1015                 Any any;
1016                 any <<= nKey;
1017                 xPropertySet->setPropertyValue(
1018                     OUString::createFromAscii("NumberFormat"), any);
1019                 if ( xPropertySet->getPropertySetInfo()->
1020                         hasPropertyByName( sPropertyIsFixedLanguage ) )
1021                 {
1022                     any <<= static_cast<bool>(!isDefaultLanguage);
1023                     xPropertySet->setPropertyValue( sPropertyIsFixedLanguage,
1024                         any );
1025                 }
1026             }
1027         }
1028     }
1029     else
1030     {
1031         OSL_TRACE("invalid <text:meta-field>: no xml:id");
1032     }
1033 }
1034 
1035 
1036 // ---------------------------------------------------------------------
1037 
1038 
1039 /**
1040  * Process index marks.
1041  *
1042  * All *-mark-end index marks should instantiate *this* class (because
1043  * it doesn't process attributes other than ID), while the *-mark and
1044  * *-mark-start classes should instantiate the apporpiate subclasses.
1045  */
1046 class XMLIndexMarkImportContext_Impl : public SvXMLImportContext
1047 {
1048     const OUString sAlternativeText;
1049 
1050     XMLHints_Impl& rHints;
1051     const enum XMLTextPElemTokens eToken;
1052     OUString sID;
1053 
1054 public:
1055     TYPEINFO();
1056 
1057     XMLIndexMarkImportContext_Impl(
1058         SvXMLImport& rImport,
1059         sal_uInt16 nPrefix,
1060         const OUString& rLocalName,
1061         enum XMLTextPElemTokens nTok,
1062         XMLHints_Impl& rHnts);
1063 
1064     void StartElement(const Reference<xml::sax::XAttributeList> & xAttrList);
1065 
1066 protected:
1067 
1068     /// process all attributes
1069     void ProcessAttributes(const Reference<xml::sax::XAttributeList> & xAttrList,
1070                            Reference<beans::XPropertySet>& rPropSet);
1071 
1072     /**
1073      * All marks can be created immediatly. Since we don't care about
1074      * the element content, ProcessAttribute should set the properties
1075      * immediatly.
1076      *
1077      * This method tolerates an empty PropertySet; subclasses however
1078      * are not expected to.
1079      */
1080     virtual void ProcessAttribute(sal_uInt16 nNamespace,
1081                                   OUString sLocalName,
1082                                   OUString sValue,
1083                                   Reference<beans::XPropertySet>& rPropSet);
1084 
1085     static void GetServiceName(OUString& sServiceName,
1086                                enum XMLTextPElemTokens nToken);
1087 
1088     sal_Bool CreateMark(Reference<beans::XPropertySet>& rPropSet,
1089                         const OUString& rServiceName);
1090 };
1091 
1092 
1093 TYPEINIT1( XMLIndexMarkImportContext_Impl, SvXMLImportContext );
1094 
1095 XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl(
1096     SvXMLImport& rImport,
1097     sal_uInt16 nPrefix,
1098     const OUString& rLocalName,
1099     enum XMLTextPElemTokens eTok,
1100     XMLHints_Impl& rHnts) :
1101         SvXMLImportContext(rImport, nPrefix, rLocalName),
1102         sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")),
1103         rHints(rHnts),
1104         eToken(eTok)
1105 {
1106 }
1107 
1108 void XMLIndexMarkImportContext_Impl::StartElement(
1109     const Reference<xml::sax::XAttributeList> & xAttrList)
1110 {
1111     // get Cursor position (needed for all cases)
1112     Reference<XTextRange> xPos(
1113         GetImport().GetTextImport()->GetCursor()->getStart());
1114     Reference<beans::XPropertySet> xMark;
1115 
1116     switch (eToken)
1117     {
1118         case XML_TOK_TEXT_TOC_MARK:
1119         case XML_TOK_TEXT_USER_INDEX_MARK:
1120         case XML_TOK_TEXT_ALPHA_INDEX_MARK:
1121         {
1122             // single mark: create mark and insert
1123             OUString sService;
1124             GetServiceName(sService, eToken);
1125             if (CreateMark(xMark, sService))
1126             {
1127                 ProcessAttributes(xAttrList, xMark);
1128                 XMLHint_Impl* pHint = new XMLIndexMarkHint_Impl(xMark, xPos);
1129                 rHints.Insert(pHint, rHints.Count());
1130             }
1131             // else: can't create mark -> ignore
1132             break;
1133         }
1134 
1135         case XML_TOK_TEXT_TOC_MARK_START:
1136         case XML_TOK_TEXT_USER_INDEX_MARK_START:
1137         case XML_TOK_TEXT_ALPHA_INDEX_MARK_START:
1138         {
1139             // start: create mark and insert (if ID is found)
1140             OUString sService;
1141             GetServiceName(sService, eToken);
1142             if (CreateMark(xMark, sService))
1143             {
1144                 ProcessAttributes(xAttrList, xMark);
1145                 if (sID.getLength() > 0)
1146                 {
1147                     // process only if we find an ID
1148                     XMLHint_Impl* pHint =
1149                         new XMLIndexMarkHint_Impl(xMark, xPos, sID);
1150                     rHints.Insert(pHint, rHints.Count());
1151                 }
1152                 // else: no ID -> we'll never find the end -> ignore
1153             }
1154             // else: can't create mark -> ignore
1155             break;
1156         }
1157 
1158         case XML_TOK_TEXT_TOC_MARK_END:
1159         case XML_TOK_TEXT_USER_INDEX_MARK_END:
1160         case XML_TOK_TEXT_ALPHA_INDEX_MARK_END:
1161         {
1162             // end: search for ID and set end of mark
1163 
1164             // call process attributes with empty XPropertySet:
1165             ProcessAttributes(xAttrList, xMark);
1166             if (sID.getLength() > 0)
1167             {
1168                 // if we have an ID, find the hint and set the end position
1169                 sal_uInt16 nCount = rHints.Count();
1170                 for(sal_uInt16 nPos = 0; nPos < nCount; nPos++)
1171                 {
1172                     XMLHint_Impl *pHint = rHints[nPos];
1173                     if ( pHint->IsIndexMark() &&
1174                          sID.equals(
1175                              ((XMLIndexMarkHint_Impl *)pHint)->GetID()) )
1176                     {
1177                         // set end and stop searching
1178                         pHint->SetEnd(xPos);
1179                         break;
1180                     }
1181                 }
1182             }
1183             // else: no ID -> ignore
1184             break;
1185         }
1186 
1187         default:
1188             DBG_ERROR("unknown index mark type!");
1189             break;
1190     }
1191 }
1192 
1193 void XMLIndexMarkImportContext_Impl::ProcessAttributes(
1194     const Reference<xml::sax::XAttributeList> & xAttrList,
1195     Reference<beans::XPropertySet>& rPropSet)
1196 {
1197     // process attributes
1198     sal_Int16 nLength = xAttrList->getLength();
1199     for(sal_Int16 i=0; i<nLength; i++)
1200     {
1201         OUString sLocalName;
1202         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1203             GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
1204 
1205         ProcessAttribute(nPrefix, sLocalName,
1206                          xAttrList->getValueByIndex(i),
1207                          rPropSet);
1208     }
1209 }
1210 
1211 void XMLIndexMarkImportContext_Impl::ProcessAttribute(
1212     sal_uInt16 nNamespace,
1213     OUString sLocalName,
1214     OUString sValue,
1215     Reference<beans::XPropertySet>& rPropSet)
1216 {
1217     // we only know ID + string-value attribute;
1218     // (former: marks, latter: -start + -end-marks)
1219     // the remainder is handled in sub-classes
1220     switch (eToken)
1221     {
1222         case XML_TOK_TEXT_TOC_MARK:
1223         case XML_TOK_TEXT_USER_INDEX_MARK:
1224         case XML_TOK_TEXT_ALPHA_INDEX_MARK:
1225             if ( (XML_NAMESPACE_TEXT == nNamespace) &&
1226                  IsXMLToken( sLocalName, XML_STRING_VALUE ) )
1227             {
1228                 rPropSet->setPropertyValue(sAlternativeText, uno::makeAny(sValue));
1229             }
1230             // else: ignore!
1231             break;
1232 
1233         case XML_TOK_TEXT_TOC_MARK_START:
1234         case XML_TOK_TEXT_USER_INDEX_MARK_START:
1235         case XML_TOK_TEXT_ALPHA_INDEX_MARK_START:
1236         case XML_TOK_TEXT_TOC_MARK_END:
1237         case XML_TOK_TEXT_USER_INDEX_MARK_END:
1238         case XML_TOK_TEXT_ALPHA_INDEX_MARK_END:
1239             if ( (XML_NAMESPACE_TEXT == nNamespace) &&
1240                  IsXMLToken( sLocalName, XML_ID ) )
1241             {
1242                 sID = sValue;
1243             }
1244             // else: ignore
1245             break;
1246 
1247         default:
1248             DBG_ERROR("unknown index mark type!");
1249             break;
1250     }
1251 }
1252 
1253 static const sal_Char sAPI_com_sun_star_text_ContentIndexMark[] =
1254         "com.sun.star.text.ContentIndexMark";
1255 static const sal_Char sAPI_com_sun_star_text_UserIndexMark[] =
1256         "com.sun.star.text.UserIndexMark";
1257 static const sal_Char sAPI_com_sun_star_text_DocumentIndexMark[] =
1258         "com.sun.star.text.DocumentIndexMark";
1259 
1260 
1261 void XMLIndexMarkImportContext_Impl::GetServiceName(
1262     OUString& sServiceName,
1263     enum XMLTextPElemTokens eToken)
1264 {
1265     switch (eToken)
1266     {
1267         case XML_TOK_TEXT_TOC_MARK:
1268         case XML_TOK_TEXT_TOC_MARK_START:
1269         case XML_TOK_TEXT_TOC_MARK_END:
1270         {
1271             OUString sTmp(RTL_CONSTASCII_USTRINGPARAM(
1272                 sAPI_com_sun_star_text_ContentIndexMark));
1273             sServiceName = sTmp;
1274             break;
1275         }
1276 
1277         case XML_TOK_TEXT_USER_INDEX_MARK:
1278         case XML_TOK_TEXT_USER_INDEX_MARK_START:
1279         case XML_TOK_TEXT_USER_INDEX_MARK_END:
1280         {
1281             OUString sTmp(RTL_CONSTASCII_USTRINGPARAM(
1282                 sAPI_com_sun_star_text_UserIndexMark));
1283             sServiceName = sTmp;
1284             break;
1285         }
1286 
1287         case XML_TOK_TEXT_ALPHA_INDEX_MARK:
1288         case XML_TOK_TEXT_ALPHA_INDEX_MARK_START:
1289         case XML_TOK_TEXT_ALPHA_INDEX_MARK_END:
1290         {
1291             OUString sTmp(RTL_CONSTASCII_USTRINGPARAM(
1292                 sAPI_com_sun_star_text_DocumentIndexMark));
1293             sServiceName = sTmp;
1294             break;
1295         }
1296 
1297         default:
1298         {
1299             DBG_ERROR("unknown index mark type!");
1300             OUString sTmp;
1301             sServiceName = sTmp;
1302             break;
1303         }
1304     }
1305 }
1306 
1307 
1308 sal_Bool XMLIndexMarkImportContext_Impl::CreateMark(
1309     Reference<beans::XPropertySet>& rPropSet,
1310     const OUString& rServiceName)
1311 {
1312     Reference<lang::XMultiServiceFactory>
1313         xFactory(GetImport().GetModel(), UNO_QUERY);
1314 
1315     if( xFactory.is() )
1316     {
1317         Reference<beans::XPropertySet> xPropSet( xFactory->createInstance(rServiceName), UNO_QUERY );
1318         if (xPropSet.is())
1319             rPropSet = xPropSet;
1320         return sal_True;
1321     }
1322 
1323     return sal_False;
1324 }
1325 
1326 
1327 class XMLTOCMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1328 {
1329     const OUString sLevel;
1330 
1331 public:
1332     TYPEINFO();
1333 
1334     XMLTOCMarkImportContext_Impl(
1335         SvXMLImport& rImport,
1336         sal_uInt16 nPrefix,
1337         const OUString& rLocalName,
1338         enum XMLTextPElemTokens nTok,
1339         XMLHints_Impl& rHnts);
1340 
1341 protected:
1342 
1343     /** process outline level */
1344     virtual void ProcessAttribute(sal_uInt16 nNamespace,
1345                                   OUString sLocalName,
1346                                   OUString sValue,
1347                                   Reference<beans::XPropertySet>& rPropSet);
1348 };
1349 
1350 TYPEINIT1( XMLTOCMarkImportContext_Impl, XMLIndexMarkImportContext_Impl );
1351 
1352 
1353 XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl(
1354     SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
1355     enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) :
1356         XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName,
1357                                        nTok, rHnts),
1358         sLevel(RTL_CONSTASCII_USTRINGPARAM("Level"))
1359 {
1360 }
1361 
1362 void XMLTOCMarkImportContext_Impl::ProcessAttribute(
1363     sal_uInt16 nNamespace,
1364     OUString sLocalName,
1365     OUString sValue,
1366     Reference<beans::XPropertySet>& rPropSet)
1367 {
1368     DBG_ASSERT(rPropSet.is(), "need PropertySet");
1369 
1370     if ((XML_NAMESPACE_TEXT == nNamespace) &&
1371         IsXMLToken( sLocalName, XML_OUTLINE_LEVEL ) )
1372     {
1373         // ouline level: set Level property
1374         sal_Int32 nTmp;
1375         if ( SvXMLUnitConverter::convertNumber( nTmp, sValue )
1376              && nTmp >= 1
1377              && nTmp < GetImport().GetTextImport()->
1378                               GetChapterNumbering()->getCount() )
1379         {
1380             rPropSet->setPropertyValue(sLevel, uno::makeAny((sal_Int16)(nTmp - 1)));
1381         }
1382         // else: value out of range -> ignore
1383     }
1384     else
1385     {
1386         // else: delegate to superclass
1387         XMLIndexMarkImportContext_Impl::ProcessAttribute(
1388             nNamespace, sLocalName, sValue, rPropSet);
1389     }
1390 }
1391 
1392 class XMLUserIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1393 {
1394     const OUString sUserIndexName;
1395     const OUString sLevel;
1396 
1397 public:
1398     TYPEINFO();
1399 
1400     XMLUserIndexMarkImportContext_Impl(
1401         SvXMLImport& rImport,
1402         sal_uInt16 nPrefix,
1403         const OUString& rLocalName,
1404         enum XMLTextPElemTokens nTok,
1405         XMLHints_Impl& rHnts);
1406 
1407 protected:
1408 
1409     /** process index name */
1410     virtual void ProcessAttribute(sal_uInt16 nNamespace,
1411                                   OUString sLocalName,
1412                                   OUString sValue,
1413                                   Reference<beans::XPropertySet>& rPropSet);
1414 };
1415 
1416 TYPEINIT1( XMLUserIndexMarkImportContext_Impl, XMLIndexMarkImportContext_Impl);
1417 
1418 XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl(
1419     SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
1420     enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) :
1421         XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName,
1422                                        nTok, rHnts),
1423         sUserIndexName(RTL_CONSTASCII_USTRINGPARAM("UserIndexName")),
1424         sLevel(RTL_CONSTASCII_USTRINGPARAM("Level"))
1425 {
1426 }
1427 
1428 void XMLUserIndexMarkImportContext_Impl::ProcessAttribute(
1429     sal_uInt16 nNamespace, OUString sLocalName, OUString sValue,
1430     Reference<beans::XPropertySet>& rPropSet)
1431 {
1432     if ( XML_NAMESPACE_TEXT == nNamespace )
1433     {
1434         if ( IsXMLToken( sLocalName, XML_INDEX_NAME ) )
1435         {
1436             rPropSet->setPropertyValue(sUserIndexName, uno::makeAny(sValue));
1437         }
1438         else if ( IsXMLToken( sLocalName, XML_OUTLINE_LEVEL ) )
1439         {
1440             // ouline level: set Level property
1441             sal_Int32 nTmp;
1442             if (SvXMLUnitConverter::convertNumber(
1443                 nTmp, sValue, 0,
1444                GetImport().GetTextImport()->GetChapterNumbering()->getCount()))
1445             {
1446                 rPropSet->setPropertyValue(sLevel, uno::makeAny(static_cast<sal_Int16>(nTmp - 1)));
1447             }
1448             // else: value out of range -> ignore
1449         }
1450         else
1451         {
1452             // else: unknown text property: delegate to super class
1453             XMLIndexMarkImportContext_Impl::ProcessAttribute(
1454                 nNamespace, sLocalName, sValue, rPropSet);
1455         }
1456     }
1457     else
1458     {
1459         // else: unknown namespace: delegate to super class
1460         XMLIndexMarkImportContext_Impl::ProcessAttribute(
1461             nNamespace, sLocalName, sValue, rPropSet);
1462     }
1463 }
1464 
1465 
1466 class XMLAlphaIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1467 {
1468     const OUString sPrimaryKey;
1469     const OUString sSecondaryKey;
1470     const OUString sTextReading;
1471     const OUString sPrimaryKeyReading;
1472     const OUString sSecondaryKeyReading;
1473     const OUString sMainEntry;
1474 
1475 public:
1476     TYPEINFO();
1477 
1478     XMLAlphaIndexMarkImportContext_Impl(
1479         SvXMLImport& rImport,
1480         sal_uInt16 nPrefix,
1481         const OUString& rLocalName,
1482         enum XMLTextPElemTokens nTok,
1483         XMLHints_Impl& rHnts);
1484 
1485 protected:
1486 
1487     /** process primary + secondary keys */
1488     virtual void ProcessAttribute(sal_uInt16 nNamespace,
1489                                   OUString sLocalName,
1490                                   OUString sValue,
1491                                   Reference<beans::XPropertySet>& rPropSet);
1492 };
1493 
1494 TYPEINIT1( XMLAlphaIndexMarkImportContext_Impl,
1495            XMLIndexMarkImportContext_Impl );
1496 
1497 XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl(
1498     SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
1499     enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) :
1500         XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName,
1501                                        nTok, rHnts),
1502         sPrimaryKey(RTL_CONSTASCII_USTRINGPARAM("PrimaryKey")),
1503         sSecondaryKey(RTL_CONSTASCII_USTRINGPARAM("SecondaryKey")),
1504         sTextReading(RTL_CONSTASCII_USTRINGPARAM("TextReading")),
1505         sPrimaryKeyReading(RTL_CONSTASCII_USTRINGPARAM("PrimaryKeyReading")),
1506         sSecondaryKeyReading(RTL_CONSTASCII_USTRINGPARAM("SecondaryKeyReading")),
1507         sMainEntry(RTL_CONSTASCII_USTRINGPARAM("IsMainEntry"))
1508 {
1509 }
1510 
1511 void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute(
1512     sal_uInt16 nNamespace, OUString sLocalName, OUString sValue,
1513     Reference<beans::XPropertySet>& rPropSet)
1514 {
1515     if (XML_NAMESPACE_TEXT == nNamespace)
1516     {
1517         if ( IsXMLToken( sLocalName, XML_KEY1 ) )
1518         {
1519             rPropSet->setPropertyValue(sPrimaryKey, uno::makeAny(sValue));
1520         }
1521         else if ( IsXMLToken( sLocalName, XML_KEY2 ) )
1522         {
1523             rPropSet->setPropertyValue(sSecondaryKey, uno::makeAny(sValue));
1524         }
1525         else if ( IsXMLToken( sLocalName, XML_KEY1_PHONETIC ) )
1526         {
1527             rPropSet->setPropertyValue(sPrimaryKeyReading, uno::makeAny(sValue));
1528         }
1529         else if ( IsXMLToken( sLocalName, XML_KEY2_PHONETIC ) )
1530         {
1531             rPropSet->setPropertyValue(sSecondaryKeyReading, uno::makeAny(sValue));
1532         }
1533         else if ( IsXMLToken( sLocalName, XML_STRING_VALUE_PHONETIC ) )
1534         {
1535             rPropSet->setPropertyValue(sTextReading, uno::makeAny(sValue));
1536         }
1537         else if ( IsXMLToken( sLocalName, XML_MAIN_ENTRY ) )
1538         {
1539             sal_Bool bMainEntry = sal_False, bTmp;
1540 
1541             if (SvXMLUnitConverter::convertBool(bTmp, sValue))
1542                 bMainEntry = bTmp;
1543 
1544             rPropSet->setPropertyValue(sMainEntry, uno::makeAny(bMainEntry));
1545         }
1546         else
1547         {
1548             XMLIndexMarkImportContext_Impl::ProcessAttribute(
1549                 nNamespace, sLocalName, sValue, rPropSet);
1550         }
1551     }
1552     else
1553     {
1554         XMLIndexMarkImportContext_Impl::ProcessAttribute(
1555             nNamespace, sLocalName, sValue, rPropSet);
1556     }
1557 }
1558 
1559 
1560 // ---------------------------------------------------------------------
1561 
1562 TYPEINIT1( XMLImpSpanContext_Impl, SvXMLImportContext );
1563 
1564 XMLImpSpanContext_Impl::XMLImpSpanContext_Impl(
1565         SvXMLImport& rImport,
1566         sal_uInt16 nPrfx,
1567         const OUString& rLName,
1568         const Reference< xml::sax::XAttributeList > & xAttrList,
1569         XMLHints_Impl& rHnts,
1570         sal_Bool& rIgnLeadSpace
1571     ,sal_uInt8              nSFConvFlags
1572                                               )
1573 :   SvXMLImportContext( rImport, nPrfx, rLName )
1574 ,   sTextFrame(RTL_CONSTASCII_USTRINGPARAM("TextFrame"))
1575 ,   rHints( rHnts )
1576 ,   pHint( 0  )
1577 ,   rIgnoreLeadingSpace( rIgnLeadSpace )
1578 ,   nStarFontsConvFlags( nSFConvFlags & (CONV_FROM_STAR_BATS|CONV_FROM_STAR_MATH) )
1579 {
1580     OUString aStyleName;
1581 
1582     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1583     for( sal_Int16 i=0; i < nAttrCount; i++ )
1584     {
1585         const OUString& rAttrName = xAttrList->getNameByIndex( i );
1586 
1587         OUString aLocalName;
1588         sal_uInt16 nPrefix =
1589             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
1590                                                             &aLocalName );
1591         if( XML_NAMESPACE_TEXT == nPrefix &&
1592             IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1593             aStyleName = xAttrList->getValueByIndex( i );
1594     }
1595 
1596     if( aStyleName.getLength() )
1597     {
1598         pHint = new XMLStyleHint_Impl( aStyleName,
1599                   GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
1600             rHints.Insert( pHint, rHints.Count() );
1601     }
1602 }
1603 
1604 XMLImpSpanContext_Impl::~XMLImpSpanContext_Impl()
1605 {
1606     if( pHint )
1607         pHint->SetEnd( GetImport().GetTextImport()
1608                             ->GetCursorAsRange()->getStart() );
1609 }
1610 
1611 SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
1612         SvXMLImport& rImport,
1613         sal_uInt16 nPrefix, const OUString& rLocalName,
1614         const Reference< xml::sax::XAttributeList > & xAttrList,
1615         sal_uInt16 nToken,
1616         XMLHints_Impl& rHints,
1617         sal_Bool& rIgnoreLeadingSpace
1618     ,sal_uInt8              nStarFontsConvFlags
1619      )
1620 {
1621     SvXMLImportContext *pContext = 0;
1622 
1623     switch( nToken )
1624     {
1625     case XML_TOK_TEXT_SPAN:
1626         pContext = new XMLImpSpanContext_Impl( rImport, nPrefix,
1627                                                rLocalName, xAttrList,
1628                                                rHints,
1629                                                rIgnoreLeadingSpace
1630                                                ,nStarFontsConvFlags
1631                                              );
1632         break;
1633 
1634     case XML_TOK_TEXT_TAB_STOP:
1635         pContext = new XMLCharContext( rImport, nPrefix,
1636                                                rLocalName, xAttrList,
1637                                                0x0009, sal_False );
1638         rIgnoreLeadingSpace = sal_False;
1639         break;
1640 
1641     case XML_TOK_TEXT_LINE_BREAK:
1642         pContext = new XMLCharContext( rImport, nPrefix,
1643                                                rLocalName, xAttrList,
1644                                                ControlCharacter::LINE_BREAK );
1645         rIgnoreLeadingSpace = sal_False;
1646         break;
1647 
1648     case XML_TOK_TEXT_S:
1649         pContext = new XMLCharContext( rImport, nPrefix,
1650                                                rLocalName, xAttrList,
1651                                                0x0020, sal_True );
1652         break;
1653 
1654     case XML_TOK_TEXT_HYPERLINK:
1655     {
1656         // test for HyperLinkURL property. If present, insert link as
1657         // text property (StarWriter), else try to insert as text
1658         // field (StarCalc, StarDraw, ...)
1659         Reference<beans::XPropertySet> xPropSet(
1660             rImport.GetTextImport()->GetCursor(),
1661             UNO_QUERY );
1662 
1663         const OUString sHyperLinkURL(
1664             RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL"));
1665 
1666         if (xPropSet->getPropertySetInfo()->hasPropertyByName(sHyperLinkURL))
1667         {
1668             pContext = new XMLImpHyperlinkContext_Impl( rImport, nPrefix,
1669                                                         rLocalName, xAttrList,
1670                                                         rHints,
1671                                                         rIgnoreLeadingSpace );
1672         }
1673         else
1674         {
1675             pContext = new XMLUrlFieldImportContext( rImport,
1676                                               *rImport.GetTextImport().get(),
1677                                                      nPrefix, rLocalName);
1678             //whitespace handling like other fields
1679             rIgnoreLeadingSpace = sal_False;
1680 
1681         }
1682         break;
1683     }
1684 
1685     case XML_TOK_TEXT_RUBY:
1686         pContext = new XMLImpRubyContext_Impl( rImport, nPrefix,
1687                                                rLocalName, xAttrList,
1688                                                rHints,
1689                                                rIgnoreLeadingSpace );
1690         break;
1691 
1692     case XML_TOK_TEXT_NOTE:
1693 #ifndef SVX_LIGHT
1694         if (rImport.GetTextImport()->IsInFrame())
1695         {
1696             // we must not insert footnotes into text frames
1697             pContext = new SvXMLImportContext( rImport, nPrefix,
1698                                                rLocalName );
1699         }
1700         else
1701         {
1702             pContext = new XMLFootnoteImportContext( rImport,
1703                                                      *rImport.GetTextImport().get(),
1704                                                      nPrefix, rLocalName );
1705         }
1706 #else
1707         // create default context to skip content
1708         pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
1709 #endif // #ifndef SVX_LIGHT
1710         rIgnoreLeadingSpace = sal_False;
1711         break;
1712 
1713     case XML_TOK_TEXT_REFERENCE:
1714     case XML_TOK_TEXT_BOOKMARK:
1715     case XML_TOK_TEXT_BOOKMARK_START:
1716     case XML_TOK_TEXT_BOOKMARK_END:
1717         pContext = new XMLTextMarkImportContext( rImport,
1718                                                  *rImport.GetTextImport().get(),
1719                                                  nPrefix, rLocalName );
1720         break;
1721 
1722     case XML_TOK_TEXT_FIELDMARK:
1723     case XML_TOK_TEXT_FIELDMARK_START:
1724     case XML_TOK_TEXT_FIELDMARK_END:
1725         pContext = new XMLTextMarkImportContext( rImport,
1726                                                  *rImport.GetTextImport().get(),
1727                                                  nPrefix, rLocalName );
1728         break;
1729 
1730     case XML_TOK_TEXT_REFERENCE_START:
1731         pContext = new XMLStartReferenceContext_Impl( rImport,
1732                                                       nPrefix, rLocalName,
1733                                                       rHints, xAttrList );
1734         break;
1735 
1736     case XML_TOK_TEXT_REFERENCE_END:
1737         pContext = new XMLEndReferenceContext_Impl( rImport,
1738                                                     nPrefix, rLocalName,
1739                                                     rHints, xAttrList );
1740         break;
1741 
1742     case XML_TOK_TEXT_FRAME:
1743         {
1744             Reference < XTextRange > xAnchorPos =
1745                 rImport.GetTextImport()->GetCursor()->getStart();
1746             XMLTextFrameContext *pTextFrameContext =
1747                 new XMLTextFrameContext( rImport, nPrefix,
1748                                          rLocalName, xAttrList,
1749                                          TextContentAnchorType_AS_CHARACTER );
1750             // --> OD 2004-08-24 #i33242# - remove check for text content.
1751             // Check for text content is done on the processing of the hint
1752             if( TextContentAnchorType_AT_CHARACTER ==
1753                                             pTextFrameContext->GetAnchorType() )
1754             // <--
1755             {
1756                 rHints.Insert( new XMLTextFrameHint_Impl(
1757                     pTextFrameContext, xAnchorPos ),
1758                     rHints.Count() );
1759             }
1760             pContext = pTextFrameContext;
1761             rIgnoreLeadingSpace = sal_False;
1762         }
1763         break;
1764     case XML_TOK_DRAW_A:
1765         {
1766             Reference < XTextRange > xAnchorPos(rImport.GetTextImport()->GetCursor()->getStart());
1767             pContext =
1768                 new XMLTextFrameHyperlinkContext( rImport, nPrefix,
1769                                         rLocalName, xAttrList,
1770                                         TextContentAnchorType_AS_CHARACTER );
1771             XMLTextFrameHint_Impl *pHint =
1772                 new XMLTextFrameHint_Impl( pContext, xAnchorPos);
1773             rHints.Insert( pHint, rHints.Count() );
1774         }
1775         break;
1776 
1777     case XML_TOK_TEXT_TOC_MARK:
1778     case XML_TOK_TEXT_TOC_MARK_START:
1779         pContext = new XMLTOCMarkImportContext_Impl(
1780             rImport, nPrefix, rLocalName,
1781             (enum XMLTextPElemTokens)nToken, rHints);
1782         break;
1783 
1784     case XML_TOK_TEXT_USER_INDEX_MARK:
1785     case XML_TOK_TEXT_USER_INDEX_MARK_START:
1786         pContext = new XMLUserIndexMarkImportContext_Impl(
1787             rImport, nPrefix, rLocalName,
1788             (enum XMLTextPElemTokens)nToken, rHints);
1789         break;
1790 
1791     case XML_TOK_TEXT_ALPHA_INDEX_MARK:
1792     case XML_TOK_TEXT_ALPHA_INDEX_MARK_START:
1793         pContext = new XMLAlphaIndexMarkImportContext_Impl(
1794             rImport, nPrefix, rLocalName,
1795             (enum XMLTextPElemTokens)nToken, rHints);
1796         break;
1797 
1798     case XML_TOK_TEXT_TOC_MARK_END:
1799     case XML_TOK_TEXT_USER_INDEX_MARK_END:
1800     case XML_TOK_TEXT_ALPHA_INDEX_MARK_END:
1801         pContext = new XMLIndexMarkImportContext_Impl(
1802             rImport, nPrefix, rLocalName, (enum XMLTextPElemTokens)nToken,
1803             rHints);
1804         break;
1805 
1806     case XML_TOK_TEXTP_CHANGE_START:
1807     case XML_TOK_TEXTP_CHANGE_END:
1808     case XML_TOK_TEXTP_CHANGE:
1809         pContext = new XMLChangeImportContext(
1810             rImport, nPrefix, rLocalName,
1811             (nToken != XML_TOK_TEXTP_CHANGE_END),
1812             (nToken != XML_TOK_TEXTP_CHANGE_START),
1813             sal_False);
1814         break;
1815 
1816     case XML_TOK_TEXT_META:
1817         pContext = new XMLMetaImportContext(rImport, nPrefix, rLocalName,
1818             rHints, rIgnoreLeadingSpace );
1819         break;
1820 
1821     case XML_TOK_TEXT_META_FIELD:
1822         pContext = new XMLMetaFieldImportContext(rImport, nPrefix, rLocalName,
1823             rHints, rIgnoreLeadingSpace );
1824         break;
1825 
1826     default:
1827         // none of the above? then it's probably  a text field!
1828         pContext =
1829             XMLTextFieldImportContext::CreateTextFieldImportContext(
1830                 rImport, *rImport.GetTextImport().get(), nPrefix, rLocalName,
1831                 nToken);
1832         // #108784# import draw elements (except control shapes in headers)
1833         if( pContext == NULL &&
1834             !( rImport.GetTextImport()->IsInHeaderFooter() &&
1835                nPrefix == XML_NAMESPACE_DRAW &&
1836                IsXMLToken( rLocalName, XML_CONTROL ) ) )
1837         {
1838             Reference < XShapes > xShapes;
1839             SvXMLShapeContext* pShapeContext = rImport.GetShapeImport()->CreateGroupChildContext(
1840                 rImport, nPrefix, rLocalName, xAttrList, xShapes );
1841             pContext = pShapeContext;
1842             // OD 2004-04-20 #i26791# - keep shape in a text frame hint to
1843             // adjust its anchor position, if its at-character anchored
1844             Reference < XTextRange > xAnchorPos =
1845                 rImport.GetTextImport()->GetCursor()->getStart();
1846             rHints.Insert( new XMLDrawHint_Impl( pShapeContext, xAnchorPos ),
1847                            rHints.Count() );
1848         }
1849         if( !pContext )
1850         {
1851             // ignore unknown content
1852             pContext =
1853                 new SvXMLImportContext( rImport, nPrefix, rLocalName );
1854         }
1855         // Behind fields, shapes and any unknown content blanks aren't ignored
1856         rIgnoreLeadingSpace = sal_False;
1857     }
1858 
1859     return pContext;
1860 }
1861 
1862 SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
1863         sal_uInt16 nPrefix, const OUString& rLocalName,
1864         const Reference< xml::sax::XAttributeList > & xAttrList )
1865 {
1866     const SvXMLTokenMap& rTokenMap =
1867         GetImport().GetTextImport()->GetTextPElemTokenMap();
1868     sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
1869 
1870     return CreateChildContext( GetImport(), nPrefix, rLocalName, xAttrList,
1871                                nToken, rHints, rIgnoreLeadingSpace
1872                                ,nStarFontsConvFlags
1873                              );
1874 }
1875 
1876 void XMLImpSpanContext_Impl::Characters( const OUString& rChars )
1877 {
1878     OUString sStyleName;
1879     if( pHint )
1880         sStyleName = pHint->GetStyleName();
1881     OUString sChars =
1882         GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
1883                                                        nStarFontsConvFlags,
1884                                                        sal_False, GetImport() );
1885     GetImport().GetTextImport()->InsertString( sChars, rIgnoreLeadingSpace );
1886 }
1887 
1888 // ---------------------------------------------------------------------
1889 
1890 TYPEINIT1( XMLParaContext, SvXMLImportContext );
1891 
1892 XMLParaContext::XMLParaContext(
1893         SvXMLImport& rImport,
1894         sal_uInt16 nPrfx,
1895         const OUString& rLName,
1896         const Reference< xml::sax::XAttributeList > & xAttrList,
1897         sal_Bool bHead ) :
1898     SvXMLImportContext( rImport, nPrfx, rLName ),
1899     xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ),
1900     m_bHaveAbout(false),
1901     nOutlineLevel( IsXMLToken( rLName, XML_H ) ? 1 : -1 ),
1902     pHints( 0 ),
1903     // --> OD 2007-07-25 #i73509#
1904     mbOutlineLevelAttrFound( sal_False ),
1905     // <--
1906     bIgnoreLeadingSpace( sal_True ),
1907     bHeading( bHead ),
1908     bIsListHeader( false ),
1909     bIsRestart (false),
1910     nStartValue(0)
1911     ,nStarFontsConvFlags( 0 )
1912 {
1913     const SvXMLTokenMap& rTokenMap =
1914         GetImport().GetTextImport()->GetTextPAttrTokenMap();
1915 
1916     bool bHaveXmlId( false );
1917     OUString aCondStyleName, sClassNames;
1918 
1919     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1920     for( sal_Int16 i=0; i < nAttrCount; i++ )
1921     {
1922         const OUString& rAttrName = xAttrList->getNameByIndex( i );
1923         const OUString& rValue = xAttrList->getValueByIndex( i );
1924 
1925         OUString aLocalName;
1926         sal_uInt16 nPrefix =
1927             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
1928                                                             &aLocalName );
1929         switch( rTokenMap.Get( nPrefix, aLocalName ) )
1930         {
1931         case XML_TOK_TEXT_P_XMLID:
1932             m_sXmlId = rValue;
1933             bHaveXmlId = true;
1934             break;
1935         case XML_TOK_TEXT_P_ABOUT:
1936             m_sAbout = rValue;
1937             m_bHaveAbout = true;
1938             break;
1939         case XML_TOK_TEXT_P_PROPERTY:
1940             m_sProperty = rValue;
1941             break;
1942         case XML_TOK_TEXT_P_CONTENT:
1943             m_sContent = rValue;
1944             break;
1945         case XML_TOK_TEXT_P_DATATYPE:
1946             m_sDatatype = rValue;
1947             break;
1948         case XML_TOK_TEXT_P_TEXTID:
1949             if (!bHaveXmlId) { m_sXmlId = rValue; }
1950             break;
1951         case XML_TOK_TEXT_P_STYLE_NAME:
1952             sStyleName = rValue;
1953             break;
1954         case XML_TOK_TEXT_P_CLASS_NAMES:
1955             sClassNames = rValue;
1956             break;
1957         case XML_TOK_TEXT_P_COND_STYLE_NAME:
1958             aCondStyleName = rValue;
1959             break;
1960         case XML_TOK_TEXT_P_LEVEL:
1961             {
1962                 sal_Int32 nTmp = rValue.toInt32();
1963                 if( nTmp > 0L )
1964                 {
1965                     if( nTmp > 127 )
1966                         nTmp = 127;
1967                     nOutlineLevel = (sal_Int8)nTmp;
1968                 }
1969                 // --> OD 2007-07-25 #i73509#
1970                 mbOutlineLevelAttrFound = sal_True;
1971                 // <--
1972             }
1973             break;
1974         case XML_TOK_TEXT_P_IS_LIST_HEADER:
1975             {
1976                 sal_Bool bBool;
1977                 if( SvXMLUnitConverter::convertBool( bBool, rValue ) )
1978                 {
1979                     bIsListHeader = bBool;
1980                 }
1981             }
1982             break;
1983         case XML_TOK_TEXT_P_RESTART_NUMBERING:
1984             {
1985                 sal_Bool bBool;
1986                 if (SvXMLUnitConverter::convertBool(bBool, rValue))
1987                 {
1988                     bIsRestart = bBool;
1989                 }
1990             }
1991             break;
1992         case XML_TOK_TEXT_P_START_VALUE:
1993             {
1994                 nStartValue = sal::static_int_cast< sal_Int16 >(
1995                     rValue.toInt32());
1996             }
1997             break;
1998         }
1999     }
2000 
2001     if( aCondStyleName.getLength() )
2002         sStyleName = aCondStyleName;
2003     else if( sClassNames.getLength() )
2004     {
2005         sal_Int32 nDummy = 0;
2006         sStyleName = sClassNames.getToken( 0, ' ', nDummy );
2007     }
2008 }
2009 
2010 XMLParaContext::~XMLParaContext()
2011 {
2012     UniReference < XMLTextImportHelper > xTxtImport(
2013         GetImport().GetTextImport());
2014     Reference < XTextRange > xCrsrRange( xTxtImport->GetCursorAsRange() );
2015     if( !xCrsrRange.is() )
2016         return; // Robust (defect file)
2017     Reference < XTextRange > xEnd(xCrsrRange->getStart());
2018 
2019     // if we have an id set for this paragraph, get a cursor for this
2020     // paragraph and register it with the given identifier
2021     // FIXME: this is just temporary, and should be removed when
2022     // EditEngine paragraphs implement XMetadatable!
2023     if (m_sXmlId.getLength())
2024     {
2025         Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange( xStart ) );
2026         if( xIdCursor.is() )
2027         {
2028             xIdCursor->gotoRange( xEnd, sal_True );
2029             Reference< XInterface > xRef( xIdCursor, UNO_QUERY );
2030             GetImport().getInterfaceToIdentifierMapper().registerReference(
2031                 m_sXmlId, xRef);
2032         }
2033     }
2034 
2035     // insert a paragraph break
2036     xTxtImport->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH );
2037 
2038     // create a cursor that select the whole last paragraph
2039     Reference < XTextCursor > xAttrCursor(
2040         xTxtImport->GetText()->createTextCursorByRange( xStart ));
2041     if( !xAttrCursor.is() )
2042         return; // Robust (defect file)
2043     xAttrCursor->gotoRange( xEnd, sal_True );
2044 
2045     // xml:id for RDF metadata
2046     if (m_sXmlId.getLength() || m_bHaveAbout || m_sProperty.getLength())
2047     {
2048         try {
2049             const uno::Reference<container::XEnumerationAccess> xEA
2050                 (xAttrCursor, uno::UNO_QUERY_THROW);
2051             const uno::Reference<container::XEnumeration> xEnum(
2052                 xEA->createEnumeration(), uno::UNO_QUERY_THROW);
2053             OSL_ENSURE(xEnum->hasMoreElements(), "xml:id: no paragraph?");
2054             if (xEnum->hasMoreElements()) {
2055                 uno::Reference<rdf::XMetadatable> xMeta;
2056                 xEnum->nextElement() >>= xMeta;
2057                 OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
2058                 GetImport().SetXmlId(xMeta, m_sXmlId);
2059                 if (m_bHaveAbout)
2060                 {
2061                     GetImport().AddRDFa(xMeta,
2062                         m_sAbout, m_sProperty, m_sContent, m_sDatatype);
2063                 }
2064                 OSL_ENSURE(!xEnum->hasMoreElements(), "xml:id: > 1 paragraph?");
2065             }
2066         } catch (uno::Exception &) {
2067             OSL_TRACE("XMLParaContext::~XMLParaContext: exception");
2068         }
2069     }
2070 
2071     OUString const sCellParaStyleName(xTxtImport->GetCellParaStyleDefault());
2072     if( sCellParaStyleName.getLength() > 0 )
2073     {
2074         // --> OD 2007-08-16 #i80724#
2075         // suppress handling of outline and list attributes,
2076         // because of side effects of method <SetStyleAndAttrs(..)>
2077         xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor,
2078                                       sCellParaStyleName,
2079                                       sal_True,
2080                                       sal_False, -1, // suppress outline handling
2081                                       sal_False );   // suppress list attributes handling
2082         // <--
2083     }
2084 
2085     // #103445# for headings without style name, find the proper style
2086     if( bHeading && (sStyleName.getLength() == 0) )
2087         xTxtImport->FindOutlineStyleName( sStyleName, nOutlineLevel );
2088 
2089     // set style and hard attributes at the previous paragraph
2090     // --> OD 2007-07-25 #i73509# - add paramter <mbOutlineLevelAttrFound>
2091     sStyleName = xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor,
2092                                                sStyleName,
2093                                                sal_True,
2094                                                mbOutlineLevelAttrFound,
2095                                                bHeading ? nOutlineLevel : -1 );
2096     // <--
2097 
2098     // handle list style header
2099     if (bHeading && (bIsListHeader || bIsRestart))
2100     {
2101         Reference<XPropertySet> xPropSet( xAttrCursor, UNO_QUERY );
2102 
2103         if (xPropSet.is())
2104         {
2105             if (bIsListHeader)
2106             {
2107                 OUString sNumberingIsNumber
2108                     (RTL_CONSTASCII_USTRINGPARAM("NumberingIsNumber"));
2109                 if(xPropSet->getPropertySetInfo()->
2110                    hasPropertyByName(sNumberingIsNumber))
2111                 {
2112                     xPropSet->setPropertyValue
2113                         (sNumberingIsNumber, makeAny( false ) );
2114                 }
2115             }
2116             if (bIsRestart)
2117             {
2118                 OUString sParaIsNumberingRestart
2119                     (RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart"));
2120                 OUString sNumberingStartValue
2121                     (RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue"));
2122                 if (xPropSet->getPropertySetInfo()->
2123                     hasPropertyByName(sParaIsNumberingRestart))
2124                 {
2125                     xPropSet->setPropertyValue
2126                         (sParaIsNumberingRestart, makeAny(true));
2127                 }
2128 
2129                 if (xPropSet->getPropertySetInfo()->
2130                     hasPropertyByName(sNumberingStartValue))
2131                 {
2132                     xPropSet->setPropertyValue
2133                         (sNumberingStartValue, makeAny(nStartValue));
2134                 }
2135             }
2136 
2137         }
2138     }
2139 
2140     if( pHints && pHints->Count() )
2141     {
2142         for( sal_uInt16 i=0; i<pHints->Count(); i++ )
2143         {
2144             XMLHint_Impl *pHint = (*pHints)[i];
2145             xAttrCursor->gotoRange( pHint->GetStart(), sal_False );
2146             xAttrCursor->gotoRange( pHint->GetEnd(), sal_True );
2147             switch( pHint->GetType() )
2148             {
2149             case XML_HINT_STYLE:
2150                 {
2151                     const OUString& rStyleName =
2152                             ((XMLStyleHint_Impl *)pHint)->GetStyleName();
2153                     if( rStyleName.getLength() )
2154                         xTxtImport->SetStyleAndAttrs( GetImport(),
2155                                                       xAttrCursor, rStyleName,
2156                                                       sal_False );
2157                 }
2158                 break;
2159             case XML_HINT_REFERENCE:
2160                 {
2161                     const OUString& rRefName =
2162                             ((XMLReferenceHint_Impl *)pHint)->GetRefName();
2163                     if( rRefName.getLength() )
2164                     {
2165                         if( !pHint->GetEnd().is() )
2166                             pHint->SetEnd(xEnd);
2167 
2168                         // convert XCursor to XTextRange
2169                         Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2170 
2171                         // reference name uses rStyleName member
2172                         // borrow from XMLTextMarkImportContext
2173                         XMLTextMarkImportContext::CreateAndInsertMark(
2174                             GetImport(),
2175                             OUString(
2176                                 RTL_CONSTASCII_USTRINGPARAM(
2177                                     "com.sun.star.text.ReferenceMark")),
2178                             rRefName,
2179                             xRange);
2180                     }
2181                 }
2182                 break;
2183             case XML_HINT_HYPERLINK:
2184                 {
2185                     const XMLHyperlinkHint_Impl *pHHint =
2186                         (const XMLHyperlinkHint_Impl *)pHint;
2187                     xTxtImport->SetHyperlink( GetImport(),
2188                                               xAttrCursor,
2189                                               pHHint->GetHRef(),
2190                                               pHHint->GetName(),
2191                                               pHHint->GetTargetFrameName(),
2192                                               pHHint->GetStyleName(),
2193                                               pHHint->GetVisitedStyleName(),
2194                                               pHHint->GetEventsContext() );
2195                 }
2196                 break;
2197             case XML_HINT_INDEX_MARK:
2198                 {
2199                     Reference<beans::XPropertySet> xMark(
2200                         ((const XMLIndexMarkHint_Impl *)pHint)->GetMark());
2201                     Reference<XTextContent> xContent(xMark, UNO_QUERY);
2202                     Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2203                     xTxtImport->GetText()->insertTextContent(
2204                         xRange, xContent, sal_True );
2205                 }
2206                 break;
2207             case XML_HINT_TEXT_FRAME:
2208                 {
2209                     const XMLTextFrameHint_Impl *pFHint =
2210                         (const XMLTextFrameHint_Impl *)pHint;
2211                     // --> OD 2004-08-24 #i33242# - check for text content
2212                     Reference < XTextContent > xTextContent =
2213                                                     pFHint->GetTextContent();
2214                     if ( xTextContent.is() )
2215                     {
2216                         // OD 2004-04-20 #i26791#
2217                         Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2218                         if ( pFHint->IsBoundAtChar() )
2219                         {
2220                             xTextContent->attach( xRange );
2221                         }
2222                     }
2223                     // <--
2224                     // --> OD 2004-08-24 #i33242# - consider, that hint can
2225                     // also contain a shape - e.g. drawing object of type 'Text'.
2226                     else
2227                     {
2228                         Reference < XShape > xShape = pFHint->GetShape();
2229                         if ( xShape.is() )
2230                         {
2231                             // determine anchor type
2232                             Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
2233                             TextContentAnchorType eAnchorType =
2234                                             TextContentAnchorType_AT_PARAGRAPH;
2235                             {
2236                                 OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2237                                 Any aAny = xPropSet->getPropertyValue( sAnchorType );
2238                                 aAny >>= eAnchorType;
2239                             }
2240                             if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
2241                             {
2242                                 // set anchor position for at-character anchored objects
2243                                 Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2244                                 Any aPos;
2245                                 aPos <<= xRange;
2246                                 OUString sTextRange( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) );
2247                                 xPropSet->setPropertyValue(sTextRange, aPos);
2248                             }
2249                         }
2250                     }
2251                     // <--
2252                 }
2253                 break;
2254             // --> DVO, OD 2004-07-14 #i26791#
2255             case XML_HINT_DRAW:
2256                 {
2257                     const XMLDrawHint_Impl *pDHint =
2258                         static_cast<const XMLDrawHint_Impl*>(pHint);
2259                     // --> OD 2004-08-24 #i33242# - improvement: hint directly
2260                     // provides the shape.
2261                     Reference < XShape > xShape = pDHint->GetShape();
2262                     if ( xShape.is() )
2263                     {
2264                         // determine anchor type
2265                         Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
2266                         TextContentAnchorType eAnchorType = TextContentAnchorType_AT_PARAGRAPH;
2267                         {
2268                             OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2269                             Any aAny = xPropSet->getPropertyValue( sAnchorType );
2270                             aAny >>= eAnchorType;
2271                         }
2272                         if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
2273                         {
2274                             // set anchor position for at-character anchored objects
2275                             Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2276                             Any aPos;
2277                             aPos <<= xRange;
2278                             OUString sTextRange( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) );
2279                             xPropSet->setPropertyValue(sTextRange, aPos);
2280                         }
2281                     }
2282                     // <--
2283                 }
2284                 break;
2285             // <--
2286 
2287             default:
2288                 DBG_ASSERT( !this, "What's this" );
2289                 break;
2290             }
2291         }
2292     }
2293     delete pHints;
2294 }
2295 
2296 SvXMLImportContext *XMLParaContext::CreateChildContext(
2297         sal_uInt16 nPrefix, const OUString& rLocalName,
2298         const Reference< xml::sax::XAttributeList > & xAttrList )
2299 {
2300     const SvXMLTokenMap& rTokenMap =
2301         GetImport().GetTextImport()->GetTextPElemTokenMap();
2302     sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
2303     if( !pHints )
2304         pHints = new XMLHints_Impl;
2305     return XMLImpSpanContext_Impl::CreateChildContext(
2306                                 GetImport(), nPrefix, rLocalName, xAttrList,
2307                                 nToken, *pHints, bIgnoreLeadingSpace
2308                                 , nStarFontsConvFlags
2309                                                      );
2310 }
2311 
2312 void XMLParaContext::Characters( const OUString& rChars )
2313 {
2314     OUString sChars =
2315         GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
2316                                                        nStarFontsConvFlags,
2317                                                        sal_True, GetImport() );
2318     GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace );
2319 }
2320 
2321 
2322 
2323 TYPEINIT1( XMLNumberedParaContext, SvXMLImportContext );
2324 
2325 XMLNumberedParaContext::XMLNumberedParaContext(
2326         SvXMLImport& i_rImport,
2327         sal_uInt16 i_nPrefix,
2328         const OUString& i_rLocalName,
2329         const Reference< xml::sax::XAttributeList > & i_xAttrList ) :
2330     SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ),
2331     m_Level(0),
2332     m_StartValue(-1),
2333     m_ListId(),
2334     m_xNumRules()
2335 {
2336     ::rtl::OUString StyleName;
2337 
2338     const SvXMLTokenMap& rTokenMap(
2339         i_rImport.GetTextImport()->GetTextNumberedParagraphAttrTokenMap() );
2340 
2341     const sal_Int16 nAttrCount( i_xAttrList.is() ?
2342         i_xAttrList->getLength() : 0 );
2343     for ( sal_Int16 i=0; i < nAttrCount; i++ )
2344     {
2345         const ::rtl::OUString& rAttrName( i_xAttrList->getNameByIndex( i )  );
2346         const ::rtl::OUString& rValue   ( i_xAttrList->getValueByIndex( i ) );
2347 
2348         ::rtl::OUString aLocalName;
2349         const sal_uInt16 nPrefix(
2350             GetImport().GetNamespaceMap().GetKeyByAttrName(
2351                 rAttrName, &aLocalName ) );
2352         switch( rTokenMap.Get( nPrefix, aLocalName ) )
2353         {
2354             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_XMLID:
2355                 m_XmlId = rValue;
2356 //FIXME: there is no UNO API for lists
2357                 break;
2358             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_LIST_ID:
2359                 m_ListId = rValue;
2360                 break;
2361             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_LEVEL:
2362                 {
2363                     sal_Int32 nTmp = rValue.toInt32();
2364                     if ( nTmp >= 1 && nTmp <= SHRT_MAX ) {
2365                         m_Level = static_cast<sal_uInt16>(nTmp) - 1;
2366                     }
2367                 }
2368                 break;
2369             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_STYLE_NAME:
2370                 StyleName = rValue;
2371                 break;
2372             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_CONTINUE_NUMBERING:
2373                 // this attribute is deprecated
2374 //                ContinuteNumbering = IsXMLToken(rValue, XML_TRUE);
2375                 break;
2376             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_START_VALUE:
2377                 {
2378                     sal_Int32 nTmp = rValue.toInt32();
2379                     if ( nTmp >= 0 && nTmp <= SHRT_MAX ) {
2380                         m_StartValue = static_cast<sal_Int16>(nTmp);
2381                     }
2382                 }
2383                 break;
2384         }
2385     }
2386 
2387     XMLTextListsHelper& rTextListsHelper(
2388         i_rImport.GetTextImport()->GetTextListHelper() );
2389     if (!m_ListId.getLength()) {
2390         OSL_ENSURE( ! i_rImport.GetODFVersion().equalsAsciiL(
2391                         RTL_CONSTASCII_STRINGPARAM("1.2") ),
2392             "invalid numbered-paragraph: no list-id (1.2)");
2393         m_ListId = rTextListsHelper.GetNumberedParagraphListId(m_Level,
2394             StyleName);
2395         OSL_ENSURE(m_ListId.getLength(), "numbered-paragraph: no ListId");
2396         if (!m_ListId.getLength()) {
2397             return;
2398         }
2399     }
2400     m_xNumRules = rTextListsHelper.EnsureNumberedParagraph( i_rImport,
2401         m_ListId, m_Level, StyleName);
2402 
2403     OSL_ENSURE(m_xNumRules.is(), "numbered-paragraph: no NumRules");
2404 
2405     i_rImport.GetTextImport()->GetTextListHelper().PushListContext( this );
2406 }
2407 
2408 XMLNumberedParaContext::~XMLNumberedParaContext()
2409 {
2410 }
2411 
2412 void XMLNumberedParaContext::EndElement()
2413 {
2414     if (m_ListId.getLength()) {
2415         GetImport().GetTextImport()->PopListContext();
2416     }
2417 }
2418 
2419 SvXMLImportContext *XMLNumberedParaContext::CreateChildContext(
2420     sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
2421     const Reference< xml::sax::XAttributeList > & i_xAttrList )
2422 {
2423     SvXMLImportContext *pContext( 0 );
2424 
2425     if ( XML_NAMESPACE_TEXT == i_nPrefix )
2426     {
2427         bool bIsHeader( IsXMLToken( i_rLocalName, XML_H ) );
2428         if ( bIsHeader || IsXMLToken( i_rLocalName, XML_P ) )
2429         {
2430             pContext = new XMLParaContext( GetImport(),
2431                 i_nPrefix, i_rLocalName, i_xAttrList, bIsHeader );
2432 // ignore text:number       } else if (IsXMLToken( i_rLocalName, XML_NUMBER )) {
2433         }
2434     }
2435 
2436     if (!pContext) {
2437         pContext = SvXMLImportContext::CreateChildContext(
2438             i_nPrefix, i_rLocalName, i_xAttrList );
2439     }
2440 
2441     return pContext;
2442 }
2443