xref: /trunk/main/xmloff/source/text/txtparae.cxx (revision d8dff77764cb74143fabc617dc8ee25d946bae78)
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 <tools/debug.hxx>
28 #ifndef _SVSTDARR_LONGS_DECL
29 #define _SVSTDARR_LONGS
30 #include <svl/svstdarr.hxx>
31 #endif
32 #include <svl/svarray.hxx>
33 #include <rtl/ustrbuf.hxx>
34 #include <sal/types.h>
35 #include <vector>
36 #include <list>
37 #include <hash_map>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/container/XEnumerationAccess.hpp>
40 #include <com/sun/star/container/XEnumeration.hpp>
41 #include <com/sun/star/container/XIndexReplace.hpp>
42 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <com/sun/star/beans/XMultiPropertySet.hpp>
44 #include <com/sun/star/beans/XPropertyState.hpp>
45 #include <com/sun/star/text/XTextDocument.hpp>
46 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
47 #include <com/sun/star/text/XTextTablesSupplier.hpp>
48 #include <com/sun/star/text/XNumberingRulesSupplier.hpp>
49 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>//#outline level,add by zhaojianwei
50 #include <com/sun/star/text/XTextTable.hpp>
51 #include <com/sun/star/text/XText.hpp>
52 #include <com/sun/star/text/XTextContent.hpp>
53 #include <com/sun/star/text/XTextRange.hpp>
54 #include <com/sun/star/text/XTextField.hpp>
55 #include <com/sun/star/text/XFootnote.hpp>
56 #include <com/sun/star/container/XNamed.hpp>
57 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
58 #include <com/sun/star/text/XTextFrame.hpp>
59 #include <com/sun/star/container/XNameAccess.hpp>
60 #include <com/sun/star/text/SizeType.hpp>
61 #include <com/sun/star/text/HoriOrientation.hpp>
62 #include <com/sun/star/text/VertOrientation.hpp>
63 #include <com/sun/star/text/TextContentAnchorType.hpp>
64 #include <com/sun/star/text/XTextFramesSupplier.hpp>
65 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
66 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
67 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
68 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
69 #include <com/sun/star/document/XEventsSupplier.hpp>
70 #include <com/sun/star/document/XRedlinesSupplier.hpp>
71 #include <com/sun/star/text/XBookmarksSupplier.hpp>
72 #include <com/sun/star/text/XFormField.hpp>
73 #include <com/sun/star/text/XTextSection.hpp>
74 #include <com/sun/star/text/SectionFileLink.hpp>
75 #include <com/sun/star/drawing/XShape.hpp>
76 #include <com/sun/star/text/XTextShapesSupplier.hpp>
77 #include <com/sun/star/style/XAutoStylesSupplier.hpp>
78 #include <com/sun/star/style/XAutoStyleFamily.hpp>
79 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
80 #include <com/sun/star/text/XFootnotesSupplier.hpp>
81 #include <com/sun/star/text/XEndnotesSupplier.hpp>
82 #include <com/sun/star/drawing/XControlShape.hpp>
83 #include <com/sun/star/util/DateTime.hpp>
84 #include "xmloff/xmlnmspe.hxx"
85 #include <xmloff/xmlaustp.hxx>
86 #include <xmloff/families.hxx>
87 #include "txtexppr.hxx"
88 #include <xmloff/xmlnumfe.hxx>
89 #include <xmloff/xmlnume.hxx>
90 #include <xmloff/xmluconv.hxx>
91 #include "XMLAnchorTypePropHdl.hxx"
92 #include "xexptran.hxx"
93 #include <xmloff/ProgressBarHelper.hxx>
94 #include <xmloff/nmspmap.hxx>
95 #include <xmloff/xmlexp.hxx>
96 #include "txtflde.hxx"
97 #include <xmloff/txtprmap.hxx>
98 #include "XMLImageMapExport.hxx"
99 #include "XMLTextNumRuleInfo.hxx"
100 #include "xmloff/XMLTextListAutoStylePool.hxx"
101 #include <xmloff/txtparae.hxx>
102 #include "XMLSectionExport.hxx"
103 #include "XMLIndexMarkExport.hxx"
104 #include <xmloff/XMLEventExport.hxx>
105 #include "XMLRedlineExport.hxx"
106 #include "MultiPropertySetHelper.hxx"
107 #include <xmloff/formlayerexport.hxx>
108 #include "XMLTextCharStyleNamesElementExport.hxx"
109 #include <comphelper/stlunosequence.hxx>
110 #include <txtlists.hxx>
111 #include <com/sun/star/rdf/XMetadatable.hpp>
112 #include <basegfx/polygon/b2dpolypolygon.hxx>
113 #include <basegfx/polygon/b2dpolypolygontools.hxx>
114 #include <basegfx/polygon/b2dpolygontools.hxx>
115 
116 using ::rtl::OUString;
117 using ::rtl::OUStringBuffer;
118 
119 using namespace ::std;
120 using namespace ::com::sun::star;
121 using namespace ::com::sun::star::uno;
122 using namespace ::com::sun::star::lang;
123 using namespace ::com::sun::star::beans;
124 using namespace ::com::sun::star::container;
125 using namespace ::com::sun::star::text;
126 using namespace ::com::sun::star::style;
127 using namespace ::com::sun::star::util;
128 using namespace ::com::sun::star::drawing;
129 using namespace ::com::sun::star::document;
130 using namespace ::com::sun::star::frame;
131 using namespace ::xmloff;
132 using namespace ::xmloff::token;
133 
134 namespace
135 {
136     class TextContentSet
137     {
138         public:
139             typedef Reference<XTextContent> text_content_ref_t;
140             typedef list<text_content_ref_t> contents_t;
141             typedef back_insert_iterator<contents_t> inserter_t;
142             typedef contents_t::const_iterator const_iterator_t;
143 
144             inserter_t getInserter()
145                 { return back_insert_iterator<contents_t>(m_vTextContents); };
146             const_iterator_t getBegin() const
147                 { return m_vTextContents.begin(); };
148             const_iterator_t getEnd() const
149                 { return m_vTextContents.end(); };
150 
151         private:
152             contents_t m_vTextContents;
153     };
154 
155     struct FrameRefHash
156         : public unary_function<Reference<XTextFrame>, size_t>
157     {
158         size_t operator()(const Reference<XTextFrame> xFrame) const
159             { return sal::static_int_cast<size_t>(reinterpret_cast<sal_uIntPtr>(xFrame.get())); }
160     };
161 
162     static bool lcl_TextContentsUnfiltered(const Reference<XTextContent>&)
163         { return true; };
164 
165     static bool lcl_ShapeFilter(const Reference<XTextContent>& xTxtContent)
166     {
167         static const OUString sTextFrameService = OUString::createFromAscii("com.sun.star.text.TextFrame");
168         static const OUString sTextGraphicService = OUString::createFromAscii("com.sun.star.text.TextGraphicObject");
169         static const OUString sTextEmbeddedService = OUString::createFromAscii("com.sun.star.text.TextEmbeddedObject");
170         Reference<XShape> xShape(xTxtContent, UNO_QUERY);
171         if(!xShape.is())
172             return false;
173         Reference<XServiceInfo> xServiceInfo(xTxtContent, UNO_QUERY);
174         if(xServiceInfo->supportsService(sTextFrameService) ||
175             xServiceInfo->supportsService(sTextGraphicService) ||
176             xServiceInfo->supportsService(sTextEmbeddedService) )
177             return false;
178         return true;
179     };
180 
181     class BoundFrames
182     {
183         public:
184             typedef bool (*filter_t)(const Reference<XTextContent>&);
185             BoundFrames(
186                 const Reference<XEnumerationAccess> xEnumAccess,
187                 const filter_t& rFilter)
188                 : m_xEnumAccess(xEnumAccess)
189             {
190                 Fill(rFilter);
191             };
192             BoundFrames()
193                 {};
194             const TextContentSet* GetPageBoundContents() const
195                 { return &m_vPageBounds; };
196             const TextContentSet* GetFrameBoundContents(const Reference<XTextFrame>& rParentFrame) const
197             {
198                 framebound_map_t::const_iterator it = m_vFrameBoundsOf.find(rParentFrame);
199                 if(it == m_vFrameBoundsOf.end())
200                     return NULL;
201                 return &(it->second);
202             };
203             Reference<XEnumeration> createEnumeration() const
204             {
205                 if(!m_xEnumAccess.is())
206                     return Reference<XEnumeration>();
207                 return m_xEnumAccess->createEnumeration();
208             };
209 
210         private:
211             typedef hash_map<
212                 Reference<XTextFrame>,
213                 TextContentSet,
214                 FrameRefHash> framebound_map_t;
215             TextContentSet m_vPageBounds;
216             framebound_map_t m_vFrameBoundsOf;
217             const Reference<XEnumerationAccess> m_xEnumAccess;
218             void Fill(const filter_t& rFilter);
219             static const OUString our_sAnchorType;
220             static const OUString our_sAnchorFrame;
221     };
222     const OUString BoundFrames::our_sAnchorType = OUString::createFromAscii("AnchorType");
223     const OUString BoundFrames::our_sAnchorFrame = OUString::createFromAscii("AnchorFrame");
224 
225     class FieldParamExporter
226     {
227         public:
228             FieldParamExporter(SvXMLExport* const pExport, Reference<XNameContainer> xFieldParams)
229                 : m_pExport(pExport)
230                 , m_xFieldParams(xFieldParams)
231                 { };
232             void Export();
233 
234         private:
235             SvXMLExport* const m_pExport;
236             const Reference<XNameContainer> m_xFieldParams;
237 
238             void ExportParameter(const OUString& sKey, const OUString& sValue);
239     };
240 }
241 
242 namespace xmloff
243 {
244     class BoundFrameSets
245     {
246         public:
247             BoundFrameSets(const Reference<XInterface> xModel);
248             const BoundFrames* GetTexts() const
249                 { return m_pTexts.get(); };
250             const BoundFrames* GetGraphics() const
251                 { return m_pGraphics.get(); };
252             const BoundFrames* GetEmbeddeds() const
253                 { return m_pEmbeddeds.get(); };
254             const BoundFrames* GetShapes() const
255                 { return m_pShapes.get(); };
256         private:
257             auto_ptr<BoundFrames> m_pTexts;
258             auto_ptr<BoundFrames> m_pGraphics;
259             auto_ptr<BoundFrames> m_pEmbeddeds;
260             auto_ptr<BoundFrames> m_pShapes;
261     };
262 }
263 
264 typedef OUString *OUStringPtr;
265 SV_DECL_PTRARR_DEL( OUStrings_Impl, OUStringPtr, 20, 10 )
266 SV_IMPL_PTRARR( OUStrings_Impl, OUStringPtr )
267 
268 SV_DECL_PTRARR_SORT_DEL( OUStringsSort_Impl, OUStringPtr, 20, 10 )
269 SV_IMPL_OP_PTRARR_SORT( OUStringsSort_Impl, OUStringPtr )
270 
271 #ifdef DBG_UTIL
272 static int txtparae_bContainsIllegalCharacters = sal_False;
273 #endif
274 
275 // The following map shows which property values are required:
276 //
277 // property                     auto style pass     export
278 // --------------------------------------------------------
279 // ParaStyleName                if style exists     always
280 // ParaConditionalStyleName     if style exists     always
281 // NumberingRules               if style exists     always
282 // TextSection                  always              always
283 // ParaChapterNumberingLevel    never               always
284 // NumberingIsNumber            never               always
285 
286 // The conclusion is that for auto styles the first three properties
287 // should be queried using a multi property set if, and only if, an
288 // auto style needs to be exported. TextSection should be queried by
289 // an individual call to getPropertyvalue, because this seems to be
290 // less expensive than querying the first three properties if they aren't
291 // required.
292 
293 // For the export pass all properties can be queried using a multi property
294 // set.
295 
296 static const sal_Char* aParagraphPropertyNamesAuto[] =
297 {
298     "NumberingRules",
299     "ParaConditionalStyleName",
300     "ParaStyleName",
301     NULL
302 };
303 
304 enum eParagraphPropertyNamesEnumAuto
305 {
306     NUMBERING_RULES_AUTO = 0,
307     PARA_CONDITIONAL_STYLE_NAME_AUTO = 1,
308     PARA_STYLE_NAME_AUTO = 2
309 };
310 
311 static const sal_Char* aParagraphPropertyNames[] =
312 {
313     "NumberingIsNumber",
314     "NumberingStyleName",           //#outline level,add by zhaojianwei
315 
316     //"ParaChapterNumberingLevel",  //#outline level,remove by zhaojianwei
317     "OutlineLevel",                 //<-end,add by zhaojianwei
318     "ParaConditionalStyleName",
319     "ParaStyleName",
320     "TextSection",
321     NULL
322 };
323 
324 enum eParagraphPropertyNamesEnum
325 {
326     NUMBERING_IS_NUMBER = 0,
327     PARA_NUMBERING_STYLENAME = 1,       //#outline level,add by zhaojianwei
328     //PARA_CHAPTER_NUMERBING_LEVEL = 1, //#outline level,remove by zhaojianwei
329     PARA_OUTLINE_LEVEL = 2,             //<-end.add by zhaojianwei
330     PARA_CONDITIONAL_STYLE_NAME = 3,
331     PARA_STYLE_NAME = 4,
332     TEXT_SECTION = 5
333 };
334 
335 void BoundFrames::Fill(const filter_t& rFilter)
336 {
337     if(!m_xEnumAccess.is())
338         return;
339     const Reference< XEnumeration > xEnum = m_xEnumAccess->createEnumeration();
340     if(!xEnum.is())
341         return;
342     while(xEnum->hasMoreElements())
343     {
344         Reference<XPropertySet> xPropSet(xEnum->nextElement(), UNO_QUERY);
345         Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY);
346         if(!xPropSet.is() || !xTextContent.is())
347             continue;
348         TextContentAnchorType eAnchor;
349         xPropSet->getPropertyValue(our_sAnchorType) >>= eAnchor;
350         if(TextContentAnchorType_AT_PAGE != eAnchor && TextContentAnchorType_AT_FRAME != eAnchor)
351             continue;
352         if(!rFilter(xTextContent))
353             continue;
354 
355         TextContentSet::inserter_t pInserter = m_vPageBounds.getInserter();
356         if(TextContentAnchorType_AT_FRAME == eAnchor)
357         {
358             Reference<XTextFrame> xAnchorTxtFrame(
359                 xPropSet->getPropertyValue(our_sAnchorFrame),
360                 uno::UNO_QUERY);
361             pInserter = m_vFrameBoundsOf[xAnchorTxtFrame].getInserter();
362         }
363         *pInserter++ = xTextContent;
364     }
365 }
366 
367 BoundFrameSets::BoundFrameSets(const Reference<XInterface> xModel)
368     : m_pTexts(new BoundFrames())
369     , m_pGraphics(new BoundFrames())
370     , m_pEmbeddeds(new BoundFrames())
371     , m_pShapes(new BoundFrames())
372 {
373     const Reference<XTextFramesSupplier> xTFS(xModel, UNO_QUERY);
374     const Reference<XTextGraphicObjectsSupplier> xGOS(xModel, UNO_QUERY);
375     const Reference<XTextEmbeddedObjectsSupplier> xEOS(xModel, UNO_QUERY);
376     const Reference<XDrawPageSupplier> xDPS(xModel, UNO_QUERY);
377     if(xTFS.is())
378         m_pTexts = auto_ptr<BoundFrames>(new BoundFrames(
379             Reference<XEnumerationAccess>(xTFS->getTextFrames(), UNO_QUERY),
380             &lcl_TextContentsUnfiltered));
381     if(xGOS.is())
382         m_pGraphics = auto_ptr<BoundFrames>(new BoundFrames(
383             Reference<XEnumerationAccess>(xGOS->getGraphicObjects(), UNO_QUERY),
384             &lcl_TextContentsUnfiltered));
385     if(xEOS.is())
386         m_pEmbeddeds = auto_ptr<BoundFrames>(new BoundFrames(
387             Reference<XEnumerationAccess>(xEOS->getEmbeddedObjects(), UNO_QUERY),
388             &lcl_TextContentsUnfiltered));
389     if(xDPS.is())
390         m_pShapes = auto_ptr<BoundFrames>(new BoundFrames(
391             Reference<XEnumerationAccess>(xDPS->getDrawPage(), UNO_QUERY),
392             &lcl_ShapeFilter));
393 };
394 
395 void FieldParamExporter::Export()
396 {
397     static const Type aStringType = ::getCppuType((OUString*)0);
398     static const Type aBoolType = ::getCppuType((sal_Bool*)0);
399     static const Type aSeqType = ::getCppuType((Sequence<OUString>*)0);
400     static const Type aIntType = ::getCppuType((sal_Int32*)0);
401     Sequence<OUString> vParameters(m_xFieldParams->getElementNames());
402     for(const OUString* pCurrent=::comphelper::stl_begin(vParameters); pCurrent!=::comphelper::stl_end(vParameters); ++pCurrent)
403     {
404         const Any aValue = m_xFieldParams->getByName(*pCurrent);
405         const Type aValueType = aValue.getValueType();
406         if(aValueType == aStringType)
407         {
408             OUString sValue;
409             aValue >>= sValue;
410             ExportParameter(*pCurrent,sValue);
411         }
412         else if(aValueType == aBoolType)
413         {
414             sal_Bool bValue = false;
415             aValue >>= bValue;
416             ExportParameter(*pCurrent,OUString::createFromAscii(bValue ? "true" : "false"));
417         }
418         else if(aValueType == aSeqType)
419         {
420             Sequence<OUString> vValue;
421             aValue >>= vValue;
422             for(OUString* pSeqCurrent = ::comphelper::stl_begin(vValue); pSeqCurrent != ::comphelper::stl_end(vValue); ++pSeqCurrent)
423             {
424                 ExportParameter(*pCurrent, *pSeqCurrent);
425             }
426         }
427         else if(aValueType == aIntType)
428         {
429             sal_Int32 nValue = 0;
430             aValue >>= nValue;
431             ExportParameter(*pCurrent, OUStringBuffer().append(nValue).makeStringAndClear());
432         }
433     }
434 }
435 
436 void FieldParamExporter::ExportParameter(const OUString& sKey, const OUString& sValue)
437 {
438     m_pExport->AddAttribute(XML_NAMESPACE_FIELD, XML_NAME, sKey);
439     m_pExport->AddAttribute(XML_NAMESPACE_FIELD, XML_VALUE, sValue);
440     m_pExport->StartElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
441     m_pExport->EndElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
442 }
443 
444 void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
445                                   const Reference < XPropertySet > & rPropSet,
446                                   const XMLPropertyState** ppAddStates, bool bDontSeek )
447 {
448     UniReference < SvXMLExportPropertyMapper > xPropMapper;
449     switch( nFamily )
450     {
451     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
452         xPropMapper = GetParaPropMapper();
453         break;
454     case XML_STYLE_FAMILY_TEXT_TEXT:
455         xPropMapper = GetTextPropMapper();
456         break;
457     case XML_STYLE_FAMILY_TEXT_FRAME:
458         xPropMapper = GetAutoFramePropMapper();
459         break;
460     case XML_STYLE_FAMILY_TEXT_SECTION:
461         xPropMapper = GetSectionPropMapper();
462         break;
463     case XML_STYLE_FAMILY_TEXT_RUBY:
464         xPropMapper = GetRubyPropMapper();
465         break;
466     }
467     DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
468 
469     vector< XMLPropertyState > xPropStates =
470             xPropMapper->Filter( rPropSet );
471 
472     if( ppAddStates )
473     {
474         while( *ppAddStates )
475         {
476             xPropStates.push_back( **ppAddStates );
477             ppAddStates++;
478         }
479     }
480 
481     if( !xPropStates.empty() )
482     {
483         Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo());
484         OUString sParent, sCondParent;
485         sal_uInt16 nIgnoreProps = 0;
486         switch( nFamily )
487         {
488         case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
489             if( xPropSetInfo->hasPropertyByName( sParaStyleName ) )
490             {
491                 rPropSet->getPropertyValue( sParaStyleName ) >>= sParent;
492             }
493             if( xPropSetInfo->hasPropertyByName( sParaConditionalStyleName ) )
494             {
495                 rPropSet->getPropertyValue( sParaConditionalStyleName ) >>= sCondParent;
496             }
497             if( xPropSetInfo->hasPropertyByName( sNumberingRules ) )
498             {
499                 Reference < XIndexReplace > xNumRule(rPropSet->getPropertyValue( sNumberingRules ), uno::UNO_QUERY);
500                 if( xNumRule.is() && xNumRule->getCount() )
501                 {
502                     Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
503                     OUString sName;
504                     if( xNamed.is() )
505                         sName = xNamed->getName();
506                     sal_Bool bAdd = !sName.getLength();
507                     if( !bAdd )
508                     {
509                         Reference < XPropertySet > xNumPropSet( xNumRule,
510                                                                 UNO_QUERY );
511                         const OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
512                         if( xNumPropSet.is() &&
513                             xNumPropSet->getPropertySetInfo()
514                                        ->hasPropertyByName( sIsAutomatic ) )
515                         {
516                             bAdd = *(sal_Bool *)xNumPropSet->getPropertyValue( sIsAutomatic ).getValue();
517                             // --> OD 2007-01-12 #i73361# - check on outline style
518                             const OUString sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) );
519                             if ( bAdd &&
520                                  xNumPropSet->getPropertySetInfo()
521                                            ->hasPropertyByName( sNumberingIsOutline ) )
522                             {
523                                 bAdd = !(*(sal_Bool *)xNumPropSet->getPropertyValue( sNumberingIsOutline ).getValue());
524                             }
525                             // <--
526                         }
527                         else
528                         {
529                             bAdd = sal_True;
530                         }
531                     }
532                     if( bAdd )
533                         pListAutoPool->Add( xNumRule );
534                 }
535             }
536             break;
537         case XML_STYLE_FAMILY_TEXT_TEXT:
538             {
539                 // Get parent and remove hyperlinks (they aren't of interest)
540                 UniReference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper());
541                 for( ::std::vector< XMLPropertyState >::iterator i(xPropStates.begin());
542                      nIgnoreProps < 2 && i != xPropStates.end(); )
543                 {
544                     if( i->mnIndex == -1 )
545                     {
546                         ++i;
547                         continue;
548                     }
549 
550                     switch( xPM->GetEntryContextId(i->mnIndex) )
551                     {
552                     case CTF_CHAR_STYLE_NAME:
553                     case CTF_HYPERLINK_URL:
554                         i->mnIndex = -1;
555                         nIgnoreProps++;
556                         i = xPropStates.erase( i );
557                         break;
558                     default:
559                         ++i;
560                         break;
561                     }
562                 }
563             }
564             break;
565         case XML_STYLE_FAMILY_TEXT_FRAME:
566             if( xPropSetInfo->hasPropertyByName( sFrameStyleName ) )
567             {
568                 rPropSet->getPropertyValue( sFrameStyleName ) >>= sParent;
569             }
570             break;
571         case XML_STYLE_FAMILY_TEXT_SECTION:
572         case XML_STYLE_FAMILY_TEXT_RUBY:
573             ; // section styles have no parents
574             break;
575         }
576         if( (xPropStates.size() - nIgnoreProps) > 0 )
577         {
578             GetAutoStylePool().Add( nFamily, sParent, xPropStates, bDontSeek );
579             if( sCondParent.getLength() && sParent != sCondParent )
580                 GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
581         }
582     }
583 }
584 
585 bool lcl_validPropState( const XMLPropertyState& rState )
586 {
587     return rState.mnIndex != -1;
588 }
589 
590 void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
591                                   MultiPropertySetHelper& rPropSetHelper,
592                                   const Reference < XPropertySet > & rPropSet,
593                                   const XMLPropertyState** ppAddStates)
594 {
595     UniReference < SvXMLExportPropertyMapper > xPropMapper;
596     switch( nFamily )
597     {
598     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
599         xPropMapper = GetParaPropMapper();
600         break;
601     }
602     DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
603 
604     vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet ));
605     if( ppAddStates )
606     {
607         while( *ppAddStates )
608         {
609             xPropStates.push_back( **ppAddStates );
610             ++ppAddStates;
611         }
612     }
613 
614     if( rPropSetHelper.hasProperty( NUMBERING_RULES_AUTO ) )
615     {
616         Reference < XIndexReplace > xNumRule(rPropSetHelper.getValue( NUMBERING_RULES_AUTO,
617             rPropSet, sal_True ), uno::UNO_QUERY);
618         if( xNumRule.is() && xNumRule->getCount() )
619         {
620             Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
621             OUString sName;
622             if( xNamed.is() )
623                 sName = xNamed->getName();
624             sal_Bool bAdd = !sName.getLength();
625             if( !bAdd )
626             {
627                 Reference < XPropertySet > xNumPropSet( xNumRule,
628                                                         UNO_QUERY );
629                 const OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
630                 if( xNumPropSet.is() &&
631                     xNumPropSet->getPropertySetInfo()
632                                ->hasPropertyByName( sIsAutomatic ) )
633                 {
634                     bAdd = *(sal_Bool *)xNumPropSet->getPropertyValue( sIsAutomatic ).getValue();
635                     // --> OD 2007-01-12 #i73361# - check on outline style
636                     const OUString sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) );
637                     if ( bAdd &&
638                          xNumPropSet->getPropertySetInfo()
639                                    ->hasPropertyByName( sNumberingIsOutline ) )
640                     {
641                         bAdd = !(*(sal_Bool *)xNumPropSet->getPropertyValue( sNumberingIsOutline ).getValue());
642                     }
643                     // <--
644                 }
645                 else
646                 {
647                     bAdd = sal_True;
648                 }
649             }
650             if( bAdd )
651                 pListAutoPool->Add( xNumRule );
652         }
653     }
654 
655     if( !xPropStates.empty() )
656     {
657         OUString sParent, sCondParent;
658         switch( nFamily )
659         {
660         case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
661             if( rPropSetHelper.hasProperty( PARA_STYLE_NAME_AUTO ) )
662             {
663                 rPropSetHelper.getValue( PARA_STYLE_NAME_AUTO, rPropSet,
664                                                 sal_True ) >>= sParent;
665             }
666             if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO ) )
667             {
668                 rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO,
669                                                 rPropSet, sal_True ) >>= sCondParent;
670             }
671 
672             break;
673         }
674 
675         if( find_if( xPropStates.begin(), xPropStates.end(), lcl_validPropState ) != xPropStates.end() )
676         {
677             GetAutoStylePool().Add( nFamily, sParent, xPropStates );
678             if( sCondParent.getLength() && sParent != sCondParent )
679                 GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
680         }
681     }
682 }
683 
684 OUString XMLTextParagraphExport::Find(
685         sal_uInt16 nFamily,
686         const Reference < XPropertySet > & rPropSet,
687         const OUString& rParent,
688         const XMLPropertyState** ppAddStates) const
689 {
690     OUString sName( rParent );
691     UniReference < SvXMLExportPropertyMapper > xPropMapper;
692     switch( nFamily )
693     {
694     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
695         xPropMapper = GetParaPropMapper();
696         break;
697     case XML_STYLE_FAMILY_TEXT_FRAME:
698         xPropMapper = GetAutoFramePropMapper();
699         break;
700     case XML_STYLE_FAMILY_TEXT_SECTION:
701         xPropMapper = GetSectionPropMapper();
702         break;
703     case XML_STYLE_FAMILY_TEXT_RUBY:
704         xPropMapper = GetRubyPropMapper();
705         break;
706     }
707     DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
708     if( !xPropMapper.is() )
709         return sName;
710     vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet ));
711     if( ppAddStates )
712     {
713         while( *ppAddStates )
714         {
715             xPropStates.push_back( **ppAddStates );
716             ++ppAddStates;
717         }
718     }
719     if( find_if( xPropStates.begin(), xPropStates.end(), lcl_validPropState ) != xPropStates.end() )
720         sName = GetAutoStylePool().Find( nFamily, sName, xPropStates );
721 
722     return sName;
723 }
724 
725 OUString XMLTextParagraphExport::FindTextStyleAndHyperlink(
726         const Reference < XPropertySet > & rPropSet,
727         sal_Bool& rbHyperlink,
728         sal_Bool& rbHasCharStyle,
729         sal_Bool& rbHasAutoStyle,
730         const XMLPropertyState** ppAddStates ) const
731 {
732     UniReference < SvXMLExportPropertyMapper > xPropMapper(GetTextPropMapper());
733     vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet ));
734 
735     // Get parent and remove hyperlinks (they aren't of interest)
736     OUString sName;
737     rbHyperlink = rbHasCharStyle = rbHasAutoStyle = sal_False;
738     sal_uInt16 nIgnoreProps = 0;
739     UniReference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper());
740     ::std::vector< XMLPropertyState >::iterator aFirstDel = xPropStates.end();
741     ::std::vector< XMLPropertyState >::iterator aSecondDel = xPropStates.end();
742 
743     for( ::std::vector< XMLPropertyState >::iterator
744             i = xPropStates.begin();
745          nIgnoreProps < 2 && i != xPropStates.end();
746          i++ )
747     {
748         if( i->mnIndex == -1 )
749             continue;
750 
751         switch( xPM->GetEntryContextId(i->mnIndex) )
752         {
753         case CTF_CHAR_STYLE_NAME:
754             i->maValue >>= sName;
755             i->mnIndex = -1;
756             rbHasCharStyle = sName.getLength() > 0;
757             if( nIgnoreProps )
758                 aSecondDel = i;
759             else
760                 aFirstDel = i;
761             nIgnoreProps++;
762             break;
763         case CTF_HYPERLINK_URL:
764             rbHyperlink = sal_True;
765             i->mnIndex = -1;
766             if( nIgnoreProps )
767                 aSecondDel = i;
768             else
769                 aFirstDel = i;
770             nIgnoreProps++;
771             break;
772         }
773     }
774     if( ppAddStates )
775     {
776         while( *ppAddStates )
777         {
778             xPropStates.push_back( **ppAddStates );
779             ppAddStates++;
780         }
781     }
782     if( (xPropStates.size() - nIgnoreProps) > 0L )
783     {
784         // erase the character style, otherwise the autostyle cannot be found!
785         // erase the hyperlink, otherwise the autostyle cannot be found!
786         if ( nIgnoreProps )
787         {
788             // If two elements of a vector have to be deleted,
789             // we should delete the second one first.
790             if( --nIgnoreProps )
791                 xPropStates.erase( aSecondDel );
792             xPropStates.erase( aFirstDel );
793         }
794         OUString sParent; // AutoStyles should not have parents!
795         sName = GetAutoStylePool().Find( XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates );
796         DBG_ASSERT( sName.getLength(), "AutoStyle could not be found" );
797         rbHasAutoStyle = sal_True;
798     }
799 
800     return sName;
801 }
802 
803 OUString XMLTextParagraphExport::FindTextStyle(
804         const Reference < XPropertySet > & rPropSet,
805         sal_Bool& rHasCharStyle ) const
806 {
807     sal_Bool bDummy;
808     sal_Bool bDummy2;
809     return FindTextStyleAndHyperlink( rPropSet, bDummy, rHasCharStyle, bDummy2 );
810 }
811 
812 
813 // --> OD 2008-04-25 #refactorlists#
814 // adjustments to support lists independent from list style
815 void XMLTextParagraphExport::exportListChange(
816         const XMLTextNumRuleInfo& rPrevInfo,
817         const XMLTextNumRuleInfo& rNextInfo )
818 {
819     // end a list
820     if ( rPrevInfo.GetLevel() > 0 )
821     {
822         bool bRootListToBeClosed = false;
823         sal_Int16 nListLevelsToBeClosed = 0;
824         if ( !rNextInfo.BelongsToSameList( rPrevInfo ) ||
825              rNextInfo.GetLevel() <= 0 )
826         {
827             // close complete previous list
828             bRootListToBeClosed = true;
829             nListLevelsToBeClosed = rPrevInfo.GetLevel();
830         }
831         else if ( rPrevInfo.GetLevel() > rNextInfo.GetLevel() )
832         {
833             // close corresponding sub lists
834             DBG_ASSERT( rNextInfo.GetLevel() > 0,
835                         "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
836             nListLevelsToBeClosed = rPrevInfo.GetLevel() - rNextInfo.GetLevel();
837         }
838 
839         if ( nListLevelsToBeClosed > 0 &&
840              pListElements &&
841              pListElements->Count() >= ( 2 * nListLevelsToBeClosed ) )
842         {
843             do {
844                 for( sal_uInt16 j = 0; j < 2; ++j )
845                 {
846                     OUString *pElem = (*pListElements)[pListElements->Count()-1];
847                     pListElements->Remove( pListElements->Count()-1 );
848 
849                     GetExport().EndElement( *pElem, sal_True );
850 
851                     delete pElem;
852                 }
853 
854                 // remove closed list from list stack
855                 mpTextListsHelper->PopListFromStack();
856 
857                 --nListLevelsToBeClosed;
858             } while ( nListLevelsToBeClosed > 0 );
859         }
860     }
861 
862     const bool bExportODF =
863                 ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0;
864     const SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion =
865                                     GetExport().getDefaultVersion();
866 
867     // start a new list
868     if ( rNextInfo.GetLevel() > 0 )
869     {
870         bool bRootListToBeStarted = false;
871         sal_Int16 nListLevelsToBeOpened = 0;
872         if ( !rPrevInfo.BelongsToSameList( rNextInfo ) ||
873              rPrevInfo.GetLevel() <= 0 )
874         {
875             // new root list
876             bRootListToBeStarted = true;
877             nListLevelsToBeOpened = rNextInfo.GetLevel();
878         }
879         else if ( rNextInfo.GetLevel() > rPrevInfo.GetLevel() )
880         {
881             // open corresponding sub lists
882             DBG_ASSERT( rPrevInfo.GetLevel() > 0,
883                         "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
884             nListLevelsToBeOpened = rNextInfo.GetLevel() - rPrevInfo.GetLevel();
885         }
886 
887         if ( nListLevelsToBeOpened > 0 )
888         {
889             const ::rtl::OUString sListStyleName( rNextInfo.GetNumRulesName() );
890             // Currently only the text documents support <ListId>.
891             // Thus, for other document types <sListId> is empty.
892             const ::rtl::OUString sListId( rNextInfo.GetListId() );
893             bool bExportListStyle( true );
894             bool bRestartNumberingAtContinuedRootList( false );
895             sal_Int16 nRestartValueForContinuedRootList( -1 );
896             // --> OD 2008-11-26 #158694#
897             bool bContinuingPreviousSubList = !bRootListToBeStarted &&
898                                               rNextInfo.IsContinuingPreviousSubTree();
899             // <--
900             do {
901                 GetExport().CheckAttrList();
902 
903                 if ( bRootListToBeStarted )
904                 {
905                     if ( !mpTextListsHelper->IsListProcessed( sListId ) )
906                     {
907                         if ( bExportODF &&
908                              eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 &&
909                              sListId.getLength() > 0 )
910                         {
911                             // --> OD 2008-07-31 #i92221#
912                             GetExport().AddAttribute( XML_NAMESPACE_XML,
913                                                       XML_ID,
914                                                       sListId );
915                             // <--
916                         }
917                         mpTextListsHelper->KeepListAsProcessed( sListId,
918                                                                 sListStyleName,
919                                                                 ::rtl::OUString() );
920                     }
921                     else
922                     {
923                         const ::rtl::OUString sNewListId(
924                                         mpTextListsHelper->GenerateNewListId() );
925                         if ( bExportODF &&
926                              eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 &&
927                              sListId.getLength() > 0 )
928                         {
929                             // --> OD 2008-07-31 #i92221#
930                             GetExport().AddAttribute( XML_NAMESPACE_XML,
931                                                       XML_ID,
932                                                       sNewListId );
933                             // <--
934                         }
935 
936                         const ::rtl::OUString sContinueListId =
937                             mpTextListsHelper->GetLastContinuingListId( sListId );
938                         // store that list with list id <sNewListId> is last list,
939                         // which has continued list with list id <sListId>
940                         mpTextListsHelper->StoreLastContinuingList( sListId,
941                                                                     sNewListId );
942                         if ( sListStyleName ==
943                                 mpTextListsHelper->GetListStyleOfLastProcessedList() &&
944                              // --> OD 2008-08-15 #i92811#
945                              sContinueListId ==
946                                 mpTextListsHelper->GetLastProcessedListId() &&
947                              // <--
948                              !rNextInfo.IsRestart() )
949                         {
950                             GetExport().AddAttribute( XML_NAMESPACE_TEXT,
951                                                       XML_CONTINUE_NUMBERING,
952                                                       XML_TRUE );
953                         }
954                         else
955                         {
956                             if ( bExportODF &&
957                                  eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 &&
958                                  sListId.getLength() > 0 )
959                             {
960                                 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
961                                                           XML_CONTINUE_LIST,
962                                                           sContinueListId );
963                             }
964 
965                             if ( rNextInfo.IsRestart() &&
966                                  ( nListLevelsToBeOpened != 1 ||
967                                    !rNextInfo.HasStartValue() ) )
968                             {
969                                 bRestartNumberingAtContinuedRootList = true;
970                                 nRestartValueForContinuedRootList =
971                                                 rNextInfo.GetListLevelStartValue();
972                             }
973                         }
974 
975                         mpTextListsHelper->KeepListAsProcessed( sNewListId,
976                                                                 sListStyleName,
977                                                                 sContinueListId );
978                     }
979 
980                     GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
981                             GetExport().EncodeStyleName( sListStyleName ) );
982                     bExportListStyle = false;
983 
984                     bRootListToBeStarted = false;
985                 }
986                 else if ( bExportListStyle &&
987                           !mpTextListsHelper->EqualsToTopListStyleOnStack( sListStyleName ) )
988                 {
989                     GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
990                             GetExport().EncodeStyleName( sListStyleName ) );
991                     bExportListStyle = false;
992                 }
993 
994                 // --> OD 2008-11-26 #158694#
995                 if ( bContinuingPreviousSubList )
996                 {
997                     GetExport().AddAttribute( XML_NAMESPACE_TEXT,
998                                               XML_CONTINUE_NUMBERING, XML_TRUE );
999                     bContinuingPreviousSubList = false;
1000                 }
1001                 // <--
1002 
1003                 enum XMLTokenEnum eLName = XML_LIST;
1004 
1005                 OUString *pElem = new OUString(
1006                         GetExport().GetNamespaceMap().GetQNameByKey(
1007                                             XML_NAMESPACE_TEXT,
1008                                             GetXMLToken(eLName) ) );
1009                 GetExport().IgnorableWhitespace();
1010                 GetExport().StartElement( *pElem, sal_False );
1011 
1012                 if( !pListElements )
1013                     pListElements = new OUStrings_Impl;
1014                 pListElements->Insert( pElem, pListElements->Count() );
1015 
1016                 mpTextListsHelper->PushListOnStack( sListId,
1017                                                     sListStyleName );
1018 
1019                 // <text:list-header> or <text:list-item>
1020                 GetExport().CheckAttrList();
1021 
1022                 // --> OD 2009-06-24 #i97309#
1023                 // export start value in case of <bRestartNumberingAtContinuedRootList>
1024                 // at correct list item
1025                 if ( nListLevelsToBeOpened == 1 )
1026                 {
1027                     if ( rNextInfo.HasStartValue() )
1028                     {
1029                         OUStringBuffer aBuffer;
1030                         aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
1031                         GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
1032                                       aBuffer.makeStringAndClear() );
1033                     }
1034                     else if ( bRestartNumberingAtContinuedRootList )
1035                     {
1036                         OUStringBuffer aBuffer;
1037                         aBuffer.append( (sal_Int32)nRestartValueForContinuedRootList );
1038                         GetExport().AddAttribute( XML_NAMESPACE_TEXT,
1039                                                   XML_START_VALUE,
1040                                                   aBuffer.makeStringAndClear() );
1041                         bRestartNumberingAtContinuedRootList = false;
1042                     }
1043                 }
1044                 // <--
1045 
1046                 eLName = ( rNextInfo.IsNumbered() || nListLevelsToBeOpened > 1 )
1047                          ? XML_LIST_ITEM
1048                          : XML_LIST_HEADER;
1049                 pElem = new OUString(  GetExport().GetNamespaceMap().GetQNameByKey(
1050                                             XML_NAMESPACE_TEXT,
1051                                             GetXMLToken(eLName) ) );
1052                 GetExport().IgnorableWhitespace();
1053                 GetExport().StartElement( *pElem, sal_False );
1054 
1055                 pListElements->Insert( pElem, pListElements->Count() );
1056 
1057                 // --> OD 2008-11-26 #158694#
1058                 // export of <text:number> element for last opened <text:list-item>, if requested
1059                 if ( GetExport().exportTextNumberElement() &&
1060                      eLName == XML_LIST_ITEM && nListLevelsToBeOpened == 1 && // last iteration --> last opened <text:list-item>
1061                      rNextInfo.ListLabelString().getLength() > 0 )
1062                 {
1063                     const ::rtl::OUString aTextNumberElem =
1064                             OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1065                                       XML_NAMESPACE_TEXT,
1066                                       GetXMLToken(XML_NUMBER) ) );
1067                     GetExport().IgnorableWhitespace();
1068                     GetExport().StartElement( aTextNumberElem, sal_False );
1069                     GetExport().Characters( rNextInfo.ListLabelString() );
1070                     GetExport().EndElement( aTextNumberElem, sal_True );
1071                 }
1072                 // <--
1073 
1074                 --nListLevelsToBeOpened;
1075             } while ( nListLevelsToBeOpened > 0 );
1076         }
1077     }
1078 
1079     if ( rNextInfo.GetLevel() > 0 &&
1080          rNextInfo.IsNumbered() &&
1081          rPrevInfo.BelongsToSameList( rNextInfo ) &&
1082          rPrevInfo.GetLevel() >= rNextInfo.GetLevel() )
1083     {
1084         // close previous list-item
1085         DBG_ASSERT( pListElements && pListElements->Count() >= 2,
1086                 "SwXMLExport::ExportListChange: list elements missing" );
1087 
1088         OUString *pElem = (*pListElements)[pListElements->Count()-1];
1089         GetExport().EndElement( *pElem, sal_True );
1090 
1091         pListElements->Remove( pListElements->Count()-1 );
1092         delete pElem;
1093 
1094         // --> OD 2009-11-12 #i103745# - only for sub lists
1095         if ( rNextInfo.IsRestart() && !rNextInfo.HasStartValue() &&
1096              rNextInfo.GetLevel() != 1 )
1097         // <--
1098         {
1099             // start new sub list respectively list on same list level
1100             pElem = (*pListElements)[pListElements->Count()-1];
1101             GetExport().EndElement( *pElem, sal_True );
1102             GetExport().IgnorableWhitespace();
1103             GetExport().StartElement( *pElem, sal_False );
1104         }
1105 
1106         // open new list-item
1107         GetExport().CheckAttrList();
1108         if( rNextInfo.HasStartValue() )
1109         {
1110             OUStringBuffer aBuffer;
1111             aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
1112             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
1113                                       aBuffer.makeStringAndClear() );
1114         }
1115         // --> OD 2009-11-12 #i103745# - handle restart without start value on list level 1
1116         else if ( rNextInfo.IsRestart() && /*!rNextInfo.HasStartValue() &&*/
1117                   rNextInfo.GetLevel() == 1 )
1118         {
1119             OUStringBuffer aBuffer;
1120             aBuffer.append( (sal_Int32)rNextInfo.GetListLevelStartValue() );
1121             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
1122                                       aBuffer.makeStringAndClear() );
1123         }
1124         // <--
1125         if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0 &&
1126              GetExport().getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
1127         {
1128             const ::rtl::OUString sListStyleName( rNextInfo.GetNumRulesName() );
1129             if ( !mpTextListsHelper->EqualsToTopListStyleOnStack( sListStyleName ) )
1130             {
1131                 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
1132                                           XML_STYLE_OVERRIDE,
1133                                           GetExport().EncodeStyleName( sListStyleName ) );
1134             }
1135         }
1136         pElem = new OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1137                                 XML_NAMESPACE_TEXT,
1138                                 GetXMLToken(XML_LIST_ITEM) ) );
1139         GetExport().IgnorableWhitespace();
1140         GetExport().StartElement( *pElem, sal_False );
1141 
1142         pListElements->Insert( pElem, pListElements->Count() );
1143 
1144         // --> OD 2008-11-26 #158694#
1145         // export of <text:number> element for <text:list-item>, if requested
1146         if ( GetExport().exportTextNumberElement() &&
1147              rNextInfo.ListLabelString().getLength() > 0 )
1148         {
1149             const ::rtl::OUString aTextNumberElem =
1150                     OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1151                               XML_NAMESPACE_TEXT,
1152                               GetXMLToken(XML_NUMBER) ) );
1153             GetExport().IgnorableWhitespace();
1154             GetExport().StartElement( aTextNumberElem, sal_False );
1155             GetExport().Characters( rNextInfo.ListLabelString() );
1156             GetExport().EndElement( aTextNumberElem, sal_True );
1157         }
1158         // <--
1159     }
1160 }
1161 // <--
1162 
1163 XMLTextParagraphExport::XMLTextParagraphExport(
1164         SvXMLExport& rExp,
1165         SvXMLAutoStylePoolP & rASP
1166         ) :
1167     XMLStyleExport( rExp, OUString(), &rASP ),
1168     rAutoStylePool( rASP ),
1169     pBoundFrameSets(new BoundFrameSets(GetExport().GetModel())),
1170     pFieldExport( 0 ),
1171     pListElements( 0 ),
1172     // --> OD 2008-05-07 #refactorlists# - no longer needed
1173 //    pExportedLists( 0 ),
1174     // <--
1175     pListAutoPool( new XMLTextListAutoStylePool( this->GetExport() ) ),
1176     pSectionExport( NULL ),
1177     pIndexMarkExport( NULL ),
1178 
1179     pRedlineExport( NULL ),
1180     pHeadingStyles( NULL ),
1181 
1182     bProgress( sal_False ),
1183     bBlock( sal_False ),
1184 
1185     bOpenRuby( sal_False ),
1186     // --> OD 2008-04-25 #refactorlists#
1187     mpTextListsHelper( 0 ),
1188     maTextListsHelperStack(),
1189     // <--
1190 
1191     sActualSize(RTL_CONSTASCII_USTRINGPARAM("ActualSize")),
1192     // --> OD 2009-07-22 #i73249#
1193 //    sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")),
1194     sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")),
1195     sDescription(RTL_CONSTASCII_USTRINGPARAM("Description")),
1196     // <--
1197     sAnchorCharStyleName(RTL_CONSTASCII_USTRINGPARAM("AnchorCharStyleName")),
1198     sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")),
1199     sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")),
1200     sBeginNotice(RTL_CONSTASCII_USTRINGPARAM("BeginNotice")),
1201     sBookmark(RTL_CONSTASCII_USTRINGPARAM("Bookmark")),
1202     sCategory(RTL_CONSTASCII_USTRINGPARAM("Category")),
1203     sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName")),
1204     sCharStyleName(RTL_CONSTASCII_USTRINGPARAM("CharStyleName")),
1205     sCharStyleNames(RTL_CONSTASCII_USTRINGPARAM("CharStyleNames")),
1206     sContourPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon")),
1207     sDocumentIndex(RTL_CONSTASCII_USTRINGPARAM("DocumentIndex")),
1208     sDocumentIndexMark(RTL_CONSTASCII_USTRINGPARAM("DocumentIndexMark")),
1209     sEndNotice(RTL_CONSTASCII_USTRINGPARAM("EndNotice")),
1210     sFootnote(RTL_CONSTASCII_USTRINGPARAM("Footnote")),
1211     sFootnoteCounting(RTL_CONSTASCII_USTRINGPARAM("FootnoteCounting")),
1212     sFrame(RTL_CONSTASCII_USTRINGPARAM("Frame")),
1213     sFrameHeightAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameHeightAbsolute")),
1214     sFrameHeightPercent(RTL_CONSTASCII_USTRINGPARAM("FrameHeightPercent")),
1215     sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName")),
1216     sFrameWidthAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameWidthAbsolute")),
1217     sFrameWidthPercent(RTL_CONSTASCII_USTRINGPARAM("FrameWidthPercent")),
1218     sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter")),
1219     sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")),
1220     sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")),
1221     sReplacementGraphicURL(RTL_CONSTASCII_USTRINGPARAM("ReplacementGraphicURL")),
1222     sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")),
1223     sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")),
1224     sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")),
1225     sHyperLinkName(RTL_CONSTASCII_USTRINGPARAM("HyperLinkName")),
1226     sHyperLinkTarget(RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget")),
1227     sHyperLinkURL(RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")),
1228     sIsAutomaticContour(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour")),
1229     sIsCollapsed(RTL_CONSTASCII_USTRINGPARAM("IsCollapsed")),
1230     sIsPixelContour(RTL_CONSTASCII_USTRINGPARAM("IsPixelContour")),
1231     sIsStart(RTL_CONSTASCII_USTRINGPARAM("IsStart")),
1232     sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth")),
1233     sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight")),
1234     sNumberingRules(RTL_CONSTASCII_USTRINGPARAM("NumberingRules")),
1235     sNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType")),
1236     sPageDescName(RTL_CONSTASCII_USTRINGPARAM("PageDescName")),
1237     sPageStyleName(RTL_CONSTASCII_USTRINGPARAM("PageStyleName")),
1238     sParaChapterNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("ParaChapterNumberingLevel")),
1239     sParaConditionalStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaConditionalStyleName")),
1240     sParagraphService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Paragraph")),
1241     sParaStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaStyleName")),
1242     sPositionEndOfDoc(RTL_CONSTASCII_USTRINGPARAM("PositionEndOfDoc")),
1243     sPrefix(RTL_CONSTASCII_USTRINGPARAM("Prefix")),
1244     sRedline(RTL_CONSTASCII_USTRINGPARAM("Redline")),
1245     sReferenceId(RTL_CONSTASCII_USTRINGPARAM("ReferenceId")),
1246     sReferenceMark(RTL_CONSTASCII_USTRINGPARAM("ReferenceMark")),
1247     sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight")),
1248     sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")),
1249     sRuby(RTL_CONSTASCII_USTRINGPARAM("Ruby")),
1250     sRubyAdjust(RTL_CONSTASCII_USTRINGPARAM("RubyAdjust")),
1251     sRubyCharStyleName(RTL_CONSTASCII_USTRINGPARAM("RubyCharStyleName")),
1252     sRubyText(RTL_CONSTASCII_USTRINGPARAM("RubyText")),
1253     sServerMap(RTL_CONSTASCII_USTRINGPARAM("ServerMap")),
1254     sShapeService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape")),
1255     sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType")),
1256     sSoftPageBreak( RTL_CONSTASCII_USTRINGPARAM( "SoftPageBreak" ) ),
1257     sStartAt(RTL_CONSTASCII_USTRINGPARAM("StartAt")),
1258     sSuffix(RTL_CONSTASCII_USTRINGPARAM("Suffix")),
1259     sTableService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextTable")),
1260     sText(RTL_CONSTASCII_USTRINGPARAM("Text")),
1261     sTextContentService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextContent")),
1262     sTextEmbeddedService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextEmbeddedObject")),
1263     sTextEndnoteService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote")),
1264     sTextField(RTL_CONSTASCII_USTRINGPARAM("TextField")),
1265     sTextFieldService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField")),
1266     sTextFrameService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")),
1267     sTextGraphicService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextGraphicObject")),
1268     sTextPortionType(RTL_CONSTASCII_USTRINGPARAM("TextPortionType")),
1269     sTextSection(RTL_CONSTASCII_USTRINGPARAM("TextSection")),
1270     sUnvisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("UnvisitedCharStyleName")),
1271     sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient")),
1272     sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")),
1273     sVisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("VisitedCharStyleName")),
1274     sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")),
1275     sWidthType( RTL_CONSTASCII_USTRINGPARAM( "WidthType" ) ),
1276     sTextFieldStart( RTL_CONSTASCII_USTRINGPARAM( "TextFieldStart" ) ),
1277     sTextFieldEnd( RTL_CONSTASCII_USTRINGPARAM( "TextFieldEnd" ) ),
1278     sTextFieldStartEnd( RTL_CONSTASCII_USTRINGPARAM( "TextFieldStartEnd" ) ),
1279     aCharStyleNamesPropInfoCache( sCharStyleNames )
1280 {
1281     UniReference < XMLPropertySetMapper > xPropMapper(new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA ));
1282     xParaPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1283                                                           GetExport() );
1284 
1285     OUString sFamily( GetXMLToken(XML_PARAGRAPH) );
1286     OUString aPrefix( String( 'P' ) );
1287     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH, sFamily,
1288                               xParaPropMapper, aPrefix );
1289 
1290     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
1291     xTextPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1292                                                           GetExport() );
1293     sFamily = OUString( GetXMLToken(XML_TEXT) );
1294     aPrefix = OUString( String( 'T' ) );
1295     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_TEXT, sFamily,
1296                               xTextPropMapper, aPrefix );
1297 
1298     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_AUTO_FRAME );
1299     xAutoFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1300                                                                GetExport() );
1301     sFamily = OUString( RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME) );
1302     aPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "fr" ) );
1303     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_FRAME, sFamily,
1304                               xAutoFramePropMapper, aPrefix );
1305 
1306     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION );
1307     xSectionPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1308                                                              GetExport() );
1309     sFamily = OUString( GetXMLToken( XML_SECTION ) );
1310     aPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "Sect" ) );
1311     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_SECTION, sFamily,
1312                               xSectionPropMapper, aPrefix );
1313 
1314     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY );
1315     xRubyPropMapper = new SvXMLExportPropertyMapper( xPropMapper );
1316     sFamily = OUString( GetXMLToken( XML_RUBY ) );
1317     aPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "Ru" ) );
1318     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_RUBY, sFamily,
1319                               xRubyPropMapper, aPrefix );
1320 
1321     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
1322     xFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1323                                                            GetExport() );
1324 
1325     pSectionExport = new XMLSectionExport( rExp, *this );
1326     pIndexMarkExport = new XMLIndexMarkExport( rExp, *this );
1327 
1328     if( ! IsBlockMode() &&
1329         Reference<XRedlinesSupplier>( GetExport().GetModel(), UNO_QUERY ).is())
1330         pRedlineExport = new XMLRedlineExport( rExp );
1331 
1332     // The text field helper needs a pre-constructed XMLPropertyState
1333     // to export the combined characters field. We construct that
1334     // here, because we need the text property mapper to do it.
1335 
1336     // construct Any value, then find index
1337     sal_Int32 nIndex = xTextPropMapper->getPropertySetMapper()->FindEntryIndex(
1338                                 "", XML_NAMESPACE_STYLE,
1339                                 GetXMLToken(XML_TEXT_COMBINE));
1340     pFieldExport = new XMLTextFieldExport( rExp, new XMLPropertyState( nIndex, uno::makeAny(sal_True) ) );
1341 
1342     // --> OD 2008-05-08 #refactorlists#
1343     PushNewTextListsHelper();
1344     // <--
1345 }
1346 
1347 XMLTextParagraphExport::~XMLTextParagraphExport()
1348 {
1349     delete pHeadingStyles;
1350     delete pRedlineExport;
1351     delete pIndexMarkExport;
1352     delete pSectionExport;
1353     delete pFieldExport;
1354     delete pListElements;
1355     // --> OD 2008-05-07 #refactorlists# - no longer needed
1356 //    delete pExportedLists;
1357     // <--
1358     delete pListAutoPool;
1359 #ifdef DBG_UTIL
1360     txtparae_bContainsIllegalCharacters = sal_False;
1361 #endif
1362     // --> OD 2008-04-25 #refactorlists#
1363     // also deletes <mpTextListsHelper>
1364     PopTextListsHelper();
1365     DBG_ASSERT( maTextListsHelperStack.size() == 0,
1366                 "misusage of text lists helper stack - it is not empty. Serious defect - please inform OD" );
1367     // <--
1368 }
1369 
1370 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateShapeExtPropMapper(
1371         SvXMLExport& rExport )
1372 {
1373     UniReference < XMLPropertySetMapper > xPropMapper =
1374         new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE );
1375     return new XMLTextExportPropertySetMapper( xPropMapper, rExport );
1376 }
1377 
1378 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateCharExtPropMapper(
1379         SvXMLExport& rExport)
1380 {
1381     XMLPropertySetMapper *pPropMapper =
1382         new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
1383     return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
1384 }
1385 
1386 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaExtPropMapper(
1387         SvXMLExport& rExport)
1388 {
1389     XMLPropertySetMapper *pPropMapper =
1390         new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
1391     return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
1392 }
1393 
1394 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaDefaultExtPropMapper(
1395         SvXMLExport& rExport)
1396 {
1397     XMLPropertySetMapper *pPropMapper =
1398         new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT_ADDITIONAL_DEFAULTS );
1399     return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
1400 }
1401 
1402 void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles,
1403                                                sal_Bool bIsProgress )
1404 {
1405     const TextContentSet* const pTexts = pBoundFrameSets->GetTexts()->GetPageBoundContents();
1406     const TextContentSet* const pGraphics = pBoundFrameSets->GetGraphics()->GetPageBoundContents();
1407     const TextContentSet* const pEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetPageBoundContents();
1408     const TextContentSet* const pShapes = pBoundFrameSets->GetShapes()->GetPageBoundContents();
1409     for(TextContentSet::const_iterator_t it = pTexts->getBegin();
1410         it != pTexts->getEnd();
1411         ++it)
1412         exportTextFrame(*it, bAutoStyles, bIsProgress, sal_True);
1413     for(TextContentSet::const_iterator_t it = pGraphics->getBegin();
1414         it != pGraphics->getEnd();
1415         ++it)
1416         exportTextGraphic(*it, bAutoStyles);
1417     for(TextContentSet::const_iterator_t it = pEmbeddeds->getBegin();
1418         it != pEmbeddeds->getEnd();
1419         ++it)
1420         exportTextEmbedded(*it, bAutoStyles);
1421     for(TextContentSet::const_iterator_t it = pShapes->getBegin();
1422         it != pShapes->getEnd();
1423         ++it)
1424         exportShape(*it, bAutoStyles);
1425 }
1426 
1427 void XMLTextParagraphExport::exportFrameFrames(
1428         sal_Bool bAutoStyles,
1429         sal_Bool bIsProgress,
1430         const Reference < XTextFrame > *pParentTxtFrame )
1431 {
1432     const TextContentSet* const pTexts = pBoundFrameSets->GetTexts()->GetFrameBoundContents(*pParentTxtFrame);
1433     if(pTexts)
1434         for(TextContentSet::const_iterator_t it = pTexts->getBegin();
1435             it != pTexts->getEnd();
1436             ++it)
1437             exportTextFrame(*it, bAutoStyles, bIsProgress, sal_True);
1438     const TextContentSet* const pGraphics = pBoundFrameSets->GetGraphics()->GetFrameBoundContents(*pParentTxtFrame);
1439     if(pGraphics)
1440         for(TextContentSet::const_iterator_t it = pGraphics->getBegin();
1441             it != pGraphics->getEnd();
1442             ++it)
1443             exportTextGraphic(*it, bAutoStyles);
1444     const TextContentSet* const pEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetFrameBoundContents(*pParentTxtFrame);
1445     if(pEmbeddeds)
1446         for(TextContentSet::const_iterator_t it = pEmbeddeds->getBegin();
1447             it != pEmbeddeds->getEnd();
1448             ++it)
1449             exportTextEmbedded(*it, bAutoStyles);
1450     const TextContentSet* const pShapes = pBoundFrameSets->GetShapes()->GetFrameBoundContents(*pParentTxtFrame);
1451     if(pShapes)
1452         for(TextContentSet::const_iterator_t it = pShapes->getBegin();
1453             it != pShapes->getEnd();
1454             ++it)
1455             exportShape(*it, bAutoStyles);
1456 }
1457 
1458 // bookmarks, reference marks (and TOC marks) are the same except for the
1459 // element names. We use the same method for export and it an array with
1460 // the proper element names
1461 static const enum XMLTokenEnum lcl_XmlReferenceElements[] = {
1462     XML_REFERENCE_MARK, XML_REFERENCE_MARK_START, XML_REFERENCE_MARK_END };
1463 static const enum XMLTokenEnum lcl_XmlBookmarkElements[] = {
1464     XML_BOOKMARK, XML_BOOKMARK_START, XML_BOOKMARK_END };
1465 
1466 // This function replaces the text portion iteration during auto style
1467 // collection.
1468 bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgress )
1469 {
1470     GetExport().GetShapeExport(); // make sure the graphics styles family is added
1471 
1472     const sal_Bool bAutoStyles = sal_True;
1473     const sal_Bool bExportContent = sal_False;
1474 
1475     // Export AutoStyles:
1476     Reference< XAutoStylesSupplier > xAutoStylesSupp( GetExport().GetModel(), UNO_QUERY );
1477     if ( xAutoStylesSupp.is() )
1478     {
1479         Reference< XAutoStyles > xAutoStyleFamilies = xAutoStylesSupp->getAutoStyles();
1480         OUString sName;
1481         sal_uInt16 nFamily;
1482 
1483         for ( int i = 0; i < 3; ++i )
1484         {
1485             if ( 0 == i )
1486             {
1487                 sName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharacterStyles" ) );
1488                 nFamily = XML_STYLE_FAMILY_TEXT_TEXT;
1489             }
1490             else if ( 1 == i )
1491             {
1492                 sName = OUString( RTL_CONSTASCII_USTRINGPARAM( "RubyStyles" ) );
1493                 nFamily = XML_STYLE_FAMILY_TEXT_RUBY;
1494             }
1495             else
1496             {
1497                 sName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) );
1498                 nFamily = XML_STYLE_FAMILY_TEXT_PARAGRAPH;
1499             }
1500 
1501             Any aAny = xAutoStyleFamilies->getByName( sName );
1502             Reference< XAutoStyleFamily > xAutoStyles = *(Reference<XAutoStyleFamily>*)aAny.getValue();
1503             Reference < XEnumeration > xAutoStylesEnum( xAutoStyles->createEnumeration() );
1504 
1505             while ( xAutoStylesEnum->hasMoreElements() )
1506             {
1507                 aAny = xAutoStylesEnum->nextElement();
1508                 Reference< XAutoStyle > xAutoStyle = *(Reference<XAutoStyle>*)aAny.getValue();
1509                 Reference < XPropertySet > xPSet( xAutoStyle, uno::UNO_QUERY );
1510                 Add( nFamily, xPSet, 0, true );
1511             }
1512         }
1513     }
1514 
1515     // Export Field AutoStyles:
1516     Reference< XTextFieldsSupplier > xTextFieldsSupp( GetExport().GetModel(), UNO_QUERY );
1517     if ( xTextFieldsSupp.is() )
1518     {
1519         Reference< XEnumerationAccess > xTextFields = xTextFieldsSupp->getTextFields();
1520         Reference < XEnumeration > xTextFieldsEnum( xTextFields->createEnumeration() );
1521 
1522         while ( xTextFieldsEnum->hasMoreElements() )
1523         {
1524             Any aAny = xTextFieldsEnum->nextElement();
1525             Reference< XTextField > xTextField = *(Reference<XTextField>*)aAny.getValue();
1526             exportTextField( xTextField, bAutoStyles, bIsProgress,
1527                 !xAutoStylesSupp.is() );
1528             try
1529             {
1530                 Reference < XPropertySet > xSet( xTextField, UNO_QUERY );
1531                 Reference < XText > xText;
1532                 Any a = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("TextRange") );
1533                 a >>= xText;
1534                 if ( xText.is() )
1535                 {
1536                     exportText( xText, sal_True, bIsProgress, bExportContent );
1537                     GetExport().GetTextParagraphExport()
1538                         ->collectTextAutoStyles( xText );
1539                 }
1540             }
1541             catch (Exception&)
1542             {
1543             }
1544         }
1545     }
1546 
1547     // Export text frames:
1548     Reference<XEnumeration> xTextFramesEnum = pBoundFrameSets->GetTexts()->createEnumeration();
1549     if(xTextFramesEnum.is())
1550         while(xTextFramesEnum->hasMoreElements())
1551         {
1552             Reference<XTextContent> xTxtCntnt(xTextFramesEnum->nextElement(), UNO_QUERY);
1553             if(xTxtCntnt.is())
1554                 exportTextFrame(xTxtCntnt, bAutoStyles, bIsProgress, bExportContent, 0);
1555         }
1556 
1557     // Export graphic objects:
1558     Reference<XEnumeration> xGraphicsEnum = pBoundFrameSets->GetGraphics()->createEnumeration();
1559     if(xGraphicsEnum.is())
1560         while(xGraphicsEnum->hasMoreElements())
1561         {
1562             Reference<XTextContent> xTxtCntnt(xGraphicsEnum->nextElement(), UNO_QUERY);
1563             if(xTxtCntnt.is())
1564                 exportTextGraphic(xTxtCntnt, true, 0);
1565         }
1566 
1567     // Export embedded objects:
1568     Reference<XEnumeration> xEmbeddedsEnum = pBoundFrameSets->GetEmbeddeds()->createEnumeration();
1569     if(xEmbeddedsEnum.is())
1570         while(xEmbeddedsEnum->hasMoreElements())
1571         {
1572             Reference<XTextContent> xTxtCntnt(xEmbeddedsEnum->nextElement(), UNO_QUERY);
1573             if(xTxtCntnt.is())
1574                 exportTextEmbedded(xTxtCntnt, true, 0);
1575         }
1576 
1577     // Export shapes:
1578     Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration();
1579     if(xShapesEnum.is())
1580         while(xShapesEnum->hasMoreElements())
1581         {
1582             Reference<XTextContent> xTxtCntnt(xShapesEnum->nextElement(), UNO_QUERY);
1583             if(xTxtCntnt.is())
1584             {
1585                 Reference<XServiceInfo> xServiceInfo(xTxtCntnt, UNO_QUERY);
1586                 if( xServiceInfo->supportsService(sShapeService))
1587                     exportShape(xTxtCntnt, true, 0);
1588             }
1589         }
1590 
1591     sal_Int32 nCount;
1592     // AutoStyles for sections
1593     Reference< XTextSectionsSupplier > xSectionsSupp( GetExport().GetModel(), UNO_QUERY );
1594     if ( xSectionsSupp.is() )
1595     {
1596         Reference< XIndexAccess > xSections( xSectionsSupp->getTextSections(), UNO_QUERY );
1597         if ( xSections.is() )
1598         {
1599             nCount = xSections->getCount();
1600             for( sal_Int32 i = 0; i < nCount; ++i )
1601             {
1602                 Any aAny = xSections->getByIndex( i );
1603                 Reference< XTextSection > xSection = *(Reference<XTextSection>*)aAny.getValue();
1604                 Reference < XPropertySet > xPSet( xSection, uno::UNO_QUERY );
1605                 Add( XML_STYLE_FAMILY_TEXT_SECTION, xPSet );
1606             }
1607         }
1608     }
1609 
1610     // AutoStyles for tables (Note: suppress autostyle collection for paragraphs in exportTable)
1611     Reference< XTextTablesSupplier > xTablesSupp( GetExport().GetModel(), UNO_QUERY );
1612     if ( xTablesSupp.is() )
1613     {
1614         Reference< XIndexAccess > xTables( xTablesSupp->getTextTables(), UNO_QUERY );
1615         if ( xTables.is() )
1616         {
1617             nCount = xTables->getCount();
1618             for( sal_Int32 i = 0; i < nCount; ++i )
1619             {
1620                 Any aAny = xTables->getByIndex( i );
1621                 Reference< XTextTable > xTable = *(Reference<XTextTable>*)aAny.getValue();
1622                 Reference < XTextContent > xTextContent( xTable, uno::UNO_QUERY );
1623                 exportTable( xTextContent, sal_True, sal_True );
1624             }
1625         }
1626     }
1627 
1628     Reference< XNumberingRulesSupplier > xNumberingRulesSupp( GetExport().GetModel(), UNO_QUERY );
1629     if ( xNumberingRulesSupp.is() )
1630     {
1631         Reference< XIndexAccess > xNumberingRules = xNumberingRulesSupp->getNumberingRules();
1632         nCount = xNumberingRules->getCount();
1633         // --> OD 2007-01-12 #i73361#
1634         const OUString sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) );
1635         // <--
1636         for( sal_Int32 i = 0; i < nCount; ++i )
1637         {
1638             Reference< XIndexReplace > xNumRule( xNumberingRules->getByIndex( i ), UNO_QUERY );
1639             if( xNumRule.is() && xNumRule->getCount() )
1640             {
1641                 Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
1642                 OUString sName;
1643                 if( xNamed.is() )
1644                     sName = xNamed->getName();
1645                 sal_Bool bAdd = !sName.getLength();
1646                 if( !bAdd )
1647                 {
1648                     Reference < XPropertySet > xNumPropSet( xNumRule,
1649                                                             UNO_QUERY );
1650                     const OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
1651                     if( xNumPropSet.is() &&
1652                         xNumPropSet->getPropertySetInfo()
1653                                    ->hasPropertyByName( sIsAutomatic ) )
1654                     {
1655                         bAdd = *(sal_Bool *)xNumPropSet->getPropertyValue( sIsAutomatic ).getValue();
1656                         // --> OD 2007-01-12 #i73361# - check on outline style
1657                         if ( bAdd &&
1658                              xNumPropSet->getPropertySetInfo()
1659                                        ->hasPropertyByName( sNumberingIsOutline ) )
1660                         {
1661                             bAdd = !(*(sal_Bool *)xNumPropSet->getPropertyValue( sNumberingIsOutline ).getValue());
1662                         }
1663                         // <--
1664                     }
1665                     else
1666                     {
1667                         bAdd = sal_True;
1668                     }
1669                 }
1670                 if( bAdd )
1671                     pListAutoPool->Add( xNumRule );
1672             }
1673         }
1674     }
1675 
1676     return true;
1677 }
1678 
1679 void XMLTextParagraphExport::exportText(
1680         const Reference < XText > & rText,
1681         sal_Bool bAutoStyles,
1682         sal_Bool bIsProgress,
1683         sal_Bool bExportParagraph )
1684 {
1685     if( bAutoStyles )
1686         GetExport().GetShapeExport(); // make sure the graphics styles family
1687                                       // is added
1688     Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
1689     Reference < XEnumeration > xParaEnum(xEA->createEnumeration());
1690     Reference < XPropertySet > xPropertySet( rText, UNO_QUERY );
1691     Reference < XTextSection > xBaseSection;
1692 
1693     // #97718# footnotes don't supply paragraph enumerations in some cases
1694     // This is always a bug, but at least we don't want to crash.
1695     DBG_ASSERT( xParaEnum.is(), "We need a paragraph enumeration" );
1696     if( ! xParaEnum.is() )
1697         return;
1698 
1699     sal_Bool bExportLevels = sal_True;
1700 
1701     if (xPropertySet.is())
1702     {
1703         Reference < XPropertySetInfo > xInfo ( xPropertySet->getPropertySetInfo() );
1704 
1705         if( xInfo.is() )
1706         {
1707             if (xInfo->hasPropertyByName( sTextSection ))
1708             {
1709                 xPropertySet->getPropertyValue(sTextSection) >>= xBaseSection ;
1710             }
1711 
1712 /* #i35937#
1713             // for applications that use the outliner we need to check if
1714             // the current text object needs the level information exported
1715             if( !bAutoStyles )
1716             {
1717                 // fixme: move string to class member, couldn't do now because
1718                 //        of no incompatible build
1719                 OUString sHasLevels( RTL_CONSTASCII_USTRINGPARAM("HasLevels") );
1720                 if (xInfo->hasPropertyByName( sHasLevels ) )
1721                 {
1722                     xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels;
1723                 }
1724             }
1725 */
1726         }
1727     }
1728 
1729     // #96530# Export redlines at start & end of XText before & after
1730     // exporting the text content enumeration
1731     if( !bAutoStyles && (pRedlineExport != NULL) )
1732         pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True );
1733     exportTextContentEnumeration( xParaEnum, bAutoStyles, xBaseSection,
1734                                   bIsProgress, bExportParagraph, 0, bExportLevels );
1735     if( !bAutoStyles && (pRedlineExport != NULL) )
1736         pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_False );
1737 }
1738 
1739 void XMLTextParagraphExport::exportText(
1740         const Reference < XText > & rText,
1741         const Reference < XTextSection > & rBaseSection,
1742         sal_Bool bAutoStyles,
1743         sal_Bool bIsProgress,
1744         sal_Bool bExportParagraph )
1745 {
1746     if( bAutoStyles )
1747         GetExport().GetShapeExport(); // make sure the graphics styles family
1748                                       // is added
1749     Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
1750     Reference < XEnumeration > xParaEnum(xEA->createEnumeration());
1751 
1752     // #98165# don't continue without a paragraph enumeration
1753     if( ! xParaEnum.is() )
1754         return;
1755 
1756     // #96530# Export redlines at start & end of XText before & after
1757     // exporting the text content enumeration
1758     Reference<XPropertySet> xPropertySet;
1759     if( !bAutoStyles && (pRedlineExport != NULL) )
1760     {
1761         xPropertySet.set(rText, uno::UNO_QUERY );
1762         pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True );
1763     }
1764     exportTextContentEnumeration( xParaEnum, bAutoStyles, rBaseSection,
1765                                   bIsProgress, bExportParagraph );
1766     if( !bAutoStyles && (pRedlineExport != NULL) )
1767         pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_False );
1768 }
1769 
1770 sal_Bool XMLTextParagraphExport::exportTextContentEnumeration(
1771         const Reference < XEnumeration > & rContEnum,
1772         sal_Bool bAutoStyles,
1773         const Reference < XTextSection > & rBaseSection,
1774         sal_Bool bIsProgress,
1775         sal_Bool bExportParagraph,
1776         const Reference < XPropertySet > *pRangePropSet,
1777         sal_Bool bExportLevels )
1778 {
1779     DBG_ASSERT( rContEnum.is(), "No enumeration to export!" );
1780     sal_Bool bHasMoreElements = rContEnum->hasMoreElements();
1781     if( !bHasMoreElements )
1782         return sal_False;
1783 
1784     XMLTextNumRuleInfo aPrevNumInfo;
1785     XMLTextNumRuleInfo aNextNumInfo;
1786 
1787     sal_Bool bHasContent = sal_False;
1788     Reference<XTextSection> xCurrentTextSection(rBaseSection);
1789 
1790     MultiPropertySetHelper aPropSetHelper(
1791                             bAutoStyles ? aParagraphPropertyNamesAuto :
1792                                           aParagraphPropertyNames );
1793 
1794     sal_Bool bHoldElement = sal_False;
1795     Reference < XTextContent > xTxtCntnt;
1796     while( bHoldElement || bHasMoreElements )
1797     {
1798         if (bHoldElement)
1799         {
1800             bHoldElement = sal_False;
1801         }
1802         else
1803         {
1804             xTxtCntnt.set(rContEnum->nextElement(), uno::UNO_QUERY);
1805 
1806             aPropSetHelper.resetValues();
1807 
1808         }
1809 
1810         Reference<XServiceInfo> xServiceInfo( xTxtCntnt, UNO_QUERY );
1811         if( xServiceInfo->supportsService( sParagraphService ) )
1812         {
1813             if( bExportLevels )
1814             {
1815                 if( bAutoStyles )
1816                 {
1817                     exportListAndSectionChange( xCurrentTextSection, xTxtCntnt,
1818                                                 aPrevNumInfo, aNextNumInfo,
1819                                                 bAutoStyles );
1820                 }
1821                 else
1822                 {
1823                     // --> OD 2006-09-27 #i69627#
1824                     // --> OD 2008-04-24 #refactorlists#
1825                     // pass list auto style pool to <XMLTextNumRuleInfo> instance
1826                     // --> OD 2008-11-26 #158694#
1827                     // pass info about request to export <text:number> element
1828                     // to <XMLTextNumRuleInfo> instance
1829                     aNextNumInfo.Set( xTxtCntnt,
1830                                       GetExport().writeOutlineStyleAsNormalListStyle(),
1831                                       GetListAutoStylePool(),
1832                                       GetExport().exportTextNumberElement() );
1833                     // <--
1834 
1835                     exportListAndSectionChange( xCurrentTextSection, aPropSetHelper,
1836                                                 TEXT_SECTION, xTxtCntnt,
1837                                                 aPrevNumInfo, aNextNumInfo,
1838                                                 bAutoStyles );
1839                 }
1840             }
1841 
1842             // if we found a mute section: skip all section content
1843             if (pSectionExport->IsMuteSection(xCurrentTextSection))
1844             {
1845                 // Make sure headings are exported anyway.
1846                 if( !bAutoStyles )
1847                     pSectionExport->ExportMasterDocHeadingDummies();
1848 
1849                 while (rContEnum->hasMoreElements() &&
1850                        pSectionExport->IsInSection( xCurrentTextSection,
1851                                                     xTxtCntnt, sal_True ))
1852                 {
1853                     xTxtCntnt.set(rContEnum->nextElement(), uno::UNO_QUERY);
1854                     aPropSetHelper.resetValues();
1855                     aNextNumInfo.Reset();
1856                 }
1857                 // the first non-mute element still needs to be processed
1858                 bHoldElement =
1859                     ! pSectionExport->IsInSection( xCurrentTextSection,
1860                                                    xTxtCntnt, sal_False );
1861             }
1862             else
1863                 exportParagraph( xTxtCntnt, bAutoStyles, bIsProgress,
1864                                  bExportParagraph, aPropSetHelper );
1865             bHasContent = sal_True;
1866         }
1867         else if( xServiceInfo->supportsService( sTableService ) )
1868         {
1869             if( !bAutoStyles )
1870             {
1871                 aNextNumInfo.Reset();
1872             }
1873 
1874             exportListAndSectionChange( xCurrentTextSection, xTxtCntnt,
1875                                         aPrevNumInfo, aNextNumInfo,
1876                                         bAutoStyles );
1877 
1878             if (! pSectionExport->IsMuteSection(xCurrentTextSection))
1879             {
1880                 // export start + end redlines (for wholly redlined tables)
1881                 if ((! bAutoStyles) && (NULL != pRedlineExport))
1882                     pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_True);
1883 
1884                 exportTable( xTxtCntnt, bAutoStyles, bIsProgress );
1885 
1886                 if ((! bAutoStyles) && (NULL != pRedlineExport))
1887                     pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_False);
1888             }
1889             else if( !bAutoStyles )
1890             {
1891                 // Make sure headings are exported anyway.
1892                 pSectionExport->ExportMasterDocHeadingDummies();
1893             }
1894 
1895             bHasContent = sal_True;
1896         }
1897         else if( xServiceInfo->supportsService( sTextFrameService ) )
1898         {
1899             exportTextFrame( xTxtCntnt, bAutoStyles, bIsProgress, sal_True, pRangePropSet );
1900         }
1901         else if( xServiceInfo->supportsService( sTextGraphicService ) )
1902         {
1903             exportTextGraphic( xTxtCntnt, bAutoStyles, pRangePropSet );
1904         }
1905         else if( xServiceInfo->supportsService( sTextEmbeddedService ) )
1906         {
1907             exportTextEmbedded( xTxtCntnt, bAutoStyles, pRangePropSet );
1908         }
1909         else if( xServiceInfo->supportsService( sShapeService ) )
1910         {
1911             exportShape( xTxtCntnt, bAutoStyles, pRangePropSet );
1912         }
1913         else
1914         {
1915             DBG_ASSERT( !xTxtCntnt.is(), "unknown text content" );
1916         }
1917 
1918         if( !bAutoStyles )
1919         {
1920             aPrevNumInfo = aNextNumInfo;
1921         }
1922 
1923         bHasMoreElements = rContEnum->hasMoreElements();
1924     }
1925 
1926     if( bExportLevels && bHasContent && !bAutoStyles )
1927     {
1928         aNextNumInfo.Reset();
1929 
1930         // close open lists and sections; no new styles
1931         exportListAndSectionChange( xCurrentTextSection, rBaseSection,
1932                                     aPrevNumInfo, aNextNumInfo,
1933                                     bAutoStyles );
1934     }
1935 
1936     return sal_True;
1937 }
1938 
1939 void XMLTextParagraphExport::exportParagraph(
1940         const Reference < XTextContent > & rTextContent,
1941         sal_Bool bAutoStyles, sal_Bool bIsProgress, sal_Bool bExportParagraph,
1942         MultiPropertySetHelper& rPropSetHelper)
1943 {
1944     sal_Int16 nOutlineLevel = -1;
1945 
1946     if( bIsProgress )
1947     {
1948         ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
1949         pProgress->SetValue( pProgress->GetValue()+1 );
1950     }
1951 
1952     // get property set or multi property set and initialize helper
1953     Reference<XMultiPropertySet> xMultiPropSet( rTextContent, UNO_QUERY );
1954     Reference<XPropertySet> xPropSet( rTextContent, UNO_QUERY );
1955 
1956     // check for supported properties
1957     if( !rPropSetHelper.checkedProperties() )
1958         rPropSetHelper.hasProperties( xPropSet->getPropertySetInfo() );
1959 
1960 //  if( xMultiPropSet.is() )
1961 //      rPropSetHelper.getValues( xMultiPropSet );
1962 //  else
1963 //      rPropSetHelper.getValues( xPropSet );
1964 
1965     if( bExportParagraph )
1966     {
1967         if( bAutoStyles )
1968         {
1969             Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, rPropSetHelper, xPropSet );
1970         }
1971         else
1972         {
1973             // xml:id for RDF metadata
1974             GetExport().AddAttributeXmlId(rTextContent);
1975             GetExport().AddAttributesRDFa(rTextContent);
1976 
1977             OUString sStyle;
1978             if( rPropSetHelper.hasProperty( PARA_STYLE_NAME ) )
1979             {
1980                 if( xMultiPropSet.is() )
1981                     rPropSetHelper.getValue( PARA_STYLE_NAME,
1982                                                     xMultiPropSet ) >>= sStyle;
1983                 else
1984                     rPropSetHelper.getValue( PARA_STYLE_NAME,
1985                                                     xPropSet ) >>= sStyle;
1986             }
1987 
1988             Reference< XInterface > xRef( rTextContent, UNO_QUERY );
1989             if( xRef.is() )
1990             {
1991                 const OUString& rIdentifier = GetExport().getInterfaceToIdentifierMapper().getIdentifier( xRef );
1992                 if( rIdentifier.getLength() )
1993                 {
1994                     // FIXME: this is just temporary until EditEngine
1995                     // paragraphs implement XMetadatable.
1996                     // then that must be used and not the mapper, because
1997                     // when both can be used we get two xml:id!
1998                     uno::Reference<rdf::XMetadatable> const xMeta(xRef,
1999                         uno::UNO_QUERY);
2000                     OSL_ENSURE(!xMeta.is(), "paragraph that implements "
2001                         "XMetadatable used in interfaceToIdentifierMapper?");
2002                     GetExport().AddAttributeIdLegacy(XML_NAMESPACE_TEXT,
2003                         rIdentifier);
2004                 }
2005             }
2006 
2007             OUString sAutoStyle( sStyle );
2008             sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle );
2009             if( sAutoStyle.getLength() )
2010                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
2011                               GetExport().EncodeStyleName( sAutoStyle ) );
2012 
2013             if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME ) )
2014             {
2015                 OUString sCondStyle;
2016                 if( xMultiPropSet.is() )
2017                     rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME,
2018                                                     xMultiPropSet ) >>= sCondStyle;
2019                 else
2020                     rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME,
2021                                                     xPropSet ) >>= sCondStyle;
2022                 if( sCondStyle != sStyle )
2023                 {
2024                     sCondStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet,
2025                                        sCondStyle );
2026                     if( sCondStyle.getLength() )
2027                         GetExport().AddAttribute( XML_NAMESPACE_TEXT,
2028                                                   XML_COND_STYLE_NAME,
2029                               GetExport().EncodeStyleName( sCondStyle ) );
2030                 }
2031             }
2032 
2033             //if( rPropSetHelper.hasProperty( PARA_CHAPTER_NUMERBING_LEVEL ) )  //#outline level,zhaojianwei
2034             if( rPropSetHelper.hasProperty( PARA_OUTLINE_LEVEL ) )              //<-end
2035             {
2036                 if( xMultiPropSet.is() )
2037                     //rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL,    //#outline level,zhaojianwei
2038                     rPropSetHelper.getValue( PARA_OUTLINE_LEVEL,                //<-end
2039                                                     xMultiPropSet ) >>= nOutlineLevel;
2040                 else
2041                     //rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL,    //#outline level,zhaojianwei
2042                     rPropSetHelper.getValue( PARA_OUTLINE_LEVEL,                //<-end
2043                                                     xPropSet ) >>= nOutlineLevel;
2044 
2045                 //if( -1 != nOutlineLevel ) //#outline level,zhaojianwei
2046                 if( 0 < nOutlineLevel ) //<-end,zhaojianwei
2047                 {
2048                     OUStringBuffer sTmp;
2049                     //sTmp.append( sal_Int32( nOutlineLevel + 1 ) );    //#outline level,zhaojianwei
2050                     sTmp.append( sal_Int32( nOutlineLevel) );       //<-end,zhaojianwei
2051                     GetExport().AddAttribute( XML_NAMESPACE_TEXT,
2052                                               XML_OUTLINE_LEVEL,
2053                                   sTmp.makeStringAndClear() );
2054 
2055                     if( rPropSetHelper.hasProperty( NUMBERING_IS_NUMBER ) )
2056                     {
2057                         bool bIsNumber = false;
2058                         if( xMultiPropSet.is() )
2059                             rPropSetHelper.getValue(
2060                                        NUMBERING_IS_NUMBER, xMultiPropSet ) >>= bIsNumber;
2061                         else
2062                             rPropSetHelper.getValue(
2063                                        NUMBERING_IS_NUMBER, xPropSet ) >>= bIsNumber;
2064 
2065                         OUString sListStyleName;
2066                         if( xMultiPropSet.is() )
2067                             rPropSetHelper.getValue(
2068                                        PARA_NUMBERING_STYLENAME, xMultiPropSet ) >>= sListStyleName;
2069                         else
2070                             rPropSetHelper.getValue(
2071                                        PARA_NUMBERING_STYLENAME, xPropSet ) >>= sListStyleName;
2072 
2073 
2074 
2075                         bool bAssignedtoOutlineStyle = false;//#outline level,add by zhaojianwei
2076                         {
2077                             Reference< XChapterNumberingSupplier > xCNSupplier( GetExport().GetModel(), UNO_QUERY );
2078 
2079                             OUString sOutlineName;
2080                             if (xCNSupplier.is())
2081                             {
2082                                 Reference< XIndexReplace > xNumRule ( xCNSupplier->getChapterNumberingRules() );
2083                                 DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" );
2084 
2085                                 if (xNumRule.is())
2086                                 {
2087                                     Reference< XPropertySet > xNumRulePropSet( xNumRule, UNO_QUERY );
2088                                     xNumRulePropSet->getPropertyValue(
2089                                         OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) ) >>= sOutlineName;
2090                                     bAssignedtoOutlineStyle = ( sListStyleName == sOutlineName );
2091                                 }
2092                             }
2093 
2094                         }   //<end,zhaojianwei
2095 
2096                         //if( ! bIsNumber )         //#outline level,removed by zhaojianwei
2097                         if( ! bIsNumber && bAssignedtoOutlineStyle )    //#outline level,add by zhaojianwei
2098                             GetExport().AddAttribute( XML_NAMESPACE_TEXT,
2099                                                       XML_IS_LIST_HEADER,
2100                                                       XML_TRUE );
2101                     }
2102 
2103                     {
2104                         String sParaIsNumberingRestart
2105                             (RTL_CONSTASCII_USTRINGPARAM
2106                              ("ParaIsNumberingRestart"));
2107                         bool bIsRestartNumbering = false;
2108 
2109                         Reference< XPropertySetInfo >
2110                         xPropSetInfo(xMultiPropSet.is() ?
2111                                      xMultiPropSet->getPropertySetInfo():
2112                                      xPropSet->getPropertySetInfo());
2113 
2114                         if (xPropSetInfo->
2115                             hasPropertyByName(sParaIsNumberingRestart))
2116                         {
2117                             xPropSet->getPropertyValue(sParaIsNumberingRestart)
2118                                 >>= bIsRestartNumbering;
2119                         }
2120 
2121                         if (bIsRestartNumbering)
2122                         {
2123                             GetExport().AddAttribute(XML_NAMESPACE_TEXT,
2124                                                      XML_RESTART_NUMBERING,
2125                                                      XML_TRUE);
2126 
2127                             String sNumberingStartValue
2128                                 (RTL_CONSTASCII_USTRINGPARAM
2129                                  ("NumberingStartValue"));
2130 
2131 
2132                             sal_Int32 nStartValue = 0;
2133 
2134                             if (xPropSetInfo->
2135                                 hasPropertyByName(sNumberingStartValue))
2136                             {
2137                                 xPropSet->getPropertyValue(sNumberingStartValue)
2138                                     >>= nStartValue;
2139 
2140                                 OUStringBuffer sTmpStartValue;
2141 
2142                                 sTmpStartValue.append(nStartValue);
2143 
2144                                 GetExport().
2145                                     AddAttribute(XML_NAMESPACE_TEXT,
2146                                                  XML_START_VALUE,
2147                                                  sTmpStartValue.
2148                                                  makeStringAndClear());
2149                             }
2150                         }
2151                     }
2152                 }
2153             }
2154         }
2155     }
2156 
2157     Reference < XEnumerationAccess > xEA( rTextContent, UNO_QUERY );
2158     Reference < XEnumeration > xTextEnum;
2159     xTextEnum = xEA->createEnumeration();
2160     const sal_Bool bHasPortions = xTextEnum.is();
2161 
2162     Reference < XEnumeration> xContentEnum;
2163     Reference < XContentEnumerationAccess > xCEA( rTextContent, UNO_QUERY );
2164     if( xCEA.is() )
2165         xContentEnum.set(xCEA->createContentEnumeration( sTextContentService ));
2166     const sal_Bool bHasContentEnum = xContentEnum.is() &&
2167                                      xContentEnum->hasMoreElements();
2168 
2169     Reference < XTextSection > xSection;
2170     if( bHasContentEnum )
2171     {
2172         // For the auto styles, the multi property set helper is only used
2173         // if hard attributes are existing. Therefor, it seems to be a better
2174         // strategy to have the TextSection property separate, because otherwise
2175         // we always retrieve the style names even if they are not required.
2176         if( bAutoStyles )
2177         {
2178             if( xPropSet->getPropertySetInfo()->hasPropertyByName( sTextSection ) )
2179             {
2180                 xSection.set(xPropSet->getPropertyValue( sTextSection ), uno::UNO_QUERY);
2181             }
2182         }
2183         else
2184         {
2185             if( rPropSetHelper.hasProperty( TEXT_SECTION ) )
2186             {
2187                 xSection.set(rPropSetHelper.getValue( TEXT_SECTION ), uno::UNO_QUERY);
2188             }
2189         }
2190     }
2191 
2192     if( bAutoStyles )
2193     {
2194         sal_Bool bPrevCharIsSpace = sal_True;
2195         if( bHasContentEnum )
2196             bPrevCharIsSpace = !exportTextContentEnumeration(
2197                                     xContentEnum, bAutoStyles, xSection,
2198                                     bIsProgress, sal_True, 0, sal_True );
2199         if ( bHasPortions )
2200             exportTextRangeEnumeration( xTextEnum, bAutoStyles, bIsProgress );
2201     }
2202     else
2203     {
2204         sal_Bool bPrevCharIsSpace = sal_True;
2205         enum XMLTokenEnum eElem =
2206             //-1 == nOutlineLevel ? XML_P : XML_H;  //#outline level,zhaojianwei
2207             0 < nOutlineLevel ? XML_H : XML_P;  //<-end,zhaojianwei
2208         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, eElem,
2209                                   sal_True, sal_False );
2210         if( bHasContentEnum )
2211             bPrevCharIsSpace = !exportTextContentEnumeration(
2212                                     xContentEnum, bAutoStyles, xSection,
2213                                     bIsProgress );
2214         exportTextRangeEnumeration( xTextEnum, bAutoStyles, bIsProgress,
2215                                     bPrevCharIsSpace );
2216     }
2217 }
2218 
2219 void XMLTextParagraphExport::exportTextRangeEnumeration(
2220     const Reference < XEnumeration > & rTextEnum,
2221     sal_Bool bAutoStyles,
2222     sal_Bool bIsProgress,
2223     sal_Bool bPrvChrIsSpc )
2224 {
2225     static OUString sMeta(RTL_CONSTASCII_USTRINGPARAM("InContentMetadata"));
2226     static OUString sAnnotation(RTL_CONSTASCII_USTRINGPARAM("Annotation"));
2227     static OUString sAnnotationEnd(RTL_CONSTASCII_USTRINGPARAM("AnnotationEnd"));
2228 
2229     sal_Bool bPrevCharIsSpace = bPrvChrIsSpc;
2230 
2231     while( rTextEnum->hasMoreElements() )
2232     {
2233         Reference<XPropertySet> xPropSet(rTextEnum->nextElement(), UNO_QUERY);
2234         Reference < XTextRange > xTxtRange(xPropSet, uno::UNO_QUERY);
2235         Reference<XPropertySetInfo> xPropInfo(xPropSet->getPropertySetInfo());
2236 
2237         if (xPropInfo->hasPropertyByName(sTextPortionType))
2238         {
2239             rtl::OUString sType;
2240             xPropSet->getPropertyValue(sTextPortionType) >>= sType;
2241 
2242             if( sType.equals(sText))
2243             {
2244                 exportTextRange( xTxtRange, bAutoStyles, bPrevCharIsSpace );
2245             }
2246             else if( sType.equals(sTextField))
2247             {
2248                 exportTextField( xTxtRange, bAutoStyles, bIsProgress );
2249                 bPrevCharIsSpace = false;
2250             }
2251             else if ( sType.equals( sAnnotation ) )
2252             {
2253                 exportTextField( xTxtRange, bAutoStyles, bIsProgress );
2254                 bPrevCharIsSpace = false;
2255             }
2256             else if ( sType.equals( sAnnotationEnd ) )
2257             {
2258                 if (!bAutoStyles) {
2259                     Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2260                     const OUString& rName = xBookmark->getName();
2261                     if ( rName.getLength() > 0 )
2262                     {
2263                         GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, rName);
2264                     }
2265                     SvXMLElementExport aElem( GetExport(), true, XML_NAMESPACE_OFFICE, XML_ANNOTATION_END, sal_False, sal_False );
2266                 } // else: there is nothing to do for automatic styles here
2267             }
2268             else if( sType.equals( sFrame ) )
2269             {
2270                 Reference < XEnumeration> xContentEnum;
2271                 Reference < XContentEnumerationAccess > xCEA( xTxtRange, UNO_QUERY );
2272                 if( xCEA.is() )
2273                     xContentEnum.set(xCEA->createContentEnumeration( sTextContentService ));
2274                 // frames are never in sections
2275                 Reference<XTextSection> xSection;
2276                 if( xContentEnum.is() )
2277                     exportTextContentEnumeration(
2278                     xContentEnum,
2279                     bAutoStyles,
2280                     xSection,
2281                     bIsProgress,
2282                     sal_True,
2283                     &xPropSet );
2284 
2285                 bPrevCharIsSpace = sal_False;
2286             }
2287             else if (sType.equals(sFootnote))
2288             {
2289                 exportTextFootnote( xPropSet, xTxtRange->getString(), bAutoStyles, bIsProgress );
2290                 bPrevCharIsSpace = sal_False;
2291             }
2292             else if (sType.equals(sBookmark))
2293             {
2294                 exportTextMark( xPropSet, sBookmark, lcl_XmlBookmarkElements, bAutoStyles );
2295             }
2296             else if (sType.equals(sReferenceMark))
2297             {
2298                 exportTextMark( xPropSet, sReferenceMark, lcl_XmlReferenceElements, bAutoStyles);
2299             }
2300             else if (sType.equals(sDocumentIndexMark))
2301             {
2302                 pIndexMarkExport->ExportIndexMark( xPropSet, bAutoStyles);
2303             }
2304             else if (sType.equals(sRedline))
2305             {
2306                 if (NULL != pRedlineExport)
2307                     pRedlineExport->ExportChange( xPropSet, bAutoStyles );
2308             }
2309             else if (sType.equals(sRuby))
2310             {
2311                 exportRuby( xPropSet, bAutoStyles );
2312             }
2313             else if (sType.equals(sMeta))
2314             {
2315                 exportMeta( xPropSet, bAutoStyles, bIsProgress );
2316             }
2317             else if (sType.equals(sTextFieldStart))
2318             {
2319                 Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2320                 if (xBookmark.is())
2321                 {
2322                     GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
2323                 }
2324 
2325                 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2326                 if (xFormField.is())
2327                 {
2328                     GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
2329                 }
2330 
2331                 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
2332                 if (xFormField.is())
2333                 {
2334                     FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
2335                 }
2336                 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
2337             }
2338             else if (sType.equals(sTextFieldEnd))
2339             {
2340                 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_END, sal_False);
2341                 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_END, sal_False);
2342             }
2343             else if (sType.equals(sTextFieldStartEnd))
2344             {
2345                 Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2346                 if (xBookmark.is())
2347                 {
2348                     GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
2349                 }
2350                 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2351                 if (xFormField.is())
2352                 {
2353                     GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
2354                 }
2355                 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);
2356                 if (xFormField.is())
2357                 {
2358                     FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
2359                 }
2360                 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);
2361             }
2362             else if (sType.equals(sSoftPageBreak))
2363             {
2364                 exportSoftPageBreak(xPropSet,   bAutoStyles);
2365             }
2366             else {
2367                 DBG_ERROR("unknown text portion type");
2368             }
2369         }
2370         else
2371         {
2372             Reference<XServiceInfo> xServiceInfo( xTxtRange, UNO_QUERY );
2373             if( xServiceInfo->supportsService( sTextFieldService ) )
2374             {
2375                 exportTextField( xTxtRange, bAutoStyles, bIsProgress );
2376                 bPrevCharIsSpace = sal_False;
2377             }
2378             else
2379             {
2380                 // no TextPortionType property -> non-Writer app -> text
2381                 exportTextRange( xTxtRange, bAutoStyles, bPrevCharIsSpace );
2382             }
2383         }
2384     }
2385 
2386 // now that there are nested enumerations for meta(-field), this may be valid!
2387 //  DBG_ASSERT( !bOpenRuby, "Red Alert: Ruby still open!" );
2388 }
2389 
2390 void XMLTextParagraphExport::exportTable(
2391         const Reference < XTextContent > &,
2392         sal_Bool /*bAutoStyles*/, sal_Bool /*bIsProgress*/ )
2393 {
2394 }
2395 
2396 void XMLTextParagraphExport::exportTextField(
2397         const Reference < XTextRange > & rTextRange,
2398         sal_Bool bAutoStyles, sal_Bool bIsProgress )
2399 {
2400     Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY );
2401     // non-Writer apps need not support Property TextField, so test first
2402     if (xPropSet->getPropertySetInfo()->hasPropertyByName( sTextField ))
2403     {
2404         Reference < XTextField > xTxtFld(xPropSet->getPropertyValue( sTextField ), uno::UNO_QUERY);
2405         DBG_ASSERT( xTxtFld.is(), "text field missing" );
2406         if( xTxtFld.is() )
2407         {
2408             exportTextField(xTxtFld, bAutoStyles, bIsProgress, sal_True);
2409         }
2410         else
2411         {
2412             // write only characters
2413             GetExport().Characters(rTextRange->getString());
2414         }
2415     }
2416 }
2417 
2418 void XMLTextParagraphExport::exportTextField(
2419         const Reference < XTextField > & xTextField,
2420         const sal_Bool bAutoStyles, const sal_Bool bIsProgress,
2421         const sal_Bool bRecursive )
2422 {
2423     if ( bAutoStyles )
2424     {
2425         pFieldExport->ExportFieldAutoStyle( xTextField, bIsProgress,
2426                 bRecursive );
2427     }
2428     else
2429     {
2430         pFieldExport->ExportField( xTextField, bIsProgress );
2431     }
2432 }
2433 
2434 void XMLTextParagraphExport::exportSoftPageBreak(
2435     const Reference<XPropertySet> & ,
2436     sal_Bool )
2437 {
2438     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2439                               XML_SOFT_PAGE_BREAK, sal_False,
2440                               sal_False );
2441 }
2442 
2443 void XMLTextParagraphExport::exportTextMark(
2444     const Reference<XPropertySet> & rPropSet,
2445     const OUString sProperty,
2446     const enum XMLTokenEnum pElements[],
2447     sal_Bool bAutoStyles)
2448 {
2449     // mib said: "Hau wech!"
2450     //
2451     // (Originally, I'd export a span element in case the (book|reference)mark
2452     //  was formatted. This actually makes a difference in case some pervert
2453     //  sets a point reference mark in the document and, say, formats it bold.
2454     //  This basically meaningless formatting will now been thrown away
2455     //  (aka cleaned up), since mib said: ...                   dvo
2456 
2457     if (!bAutoStyles)
2458     {
2459         // name element
2460         Reference<XNamed> xName(rPropSet->getPropertyValue(sProperty), UNO_QUERY);
2461         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
2462                                  xName->getName());
2463 
2464         // start, end, or point-reference?
2465         sal_Int8 nElement;
2466         if( *(sal_Bool *)rPropSet->getPropertyValue(sIsCollapsed).getValue() )
2467         {
2468             nElement = 0;
2469         }
2470         else
2471         {
2472             nElement = *(sal_Bool *)rPropSet->getPropertyValue(sIsStart).getValue() ? 1 : 2;
2473         }
2474 
2475         // bookmark, bookmark-start: xml:id and RDFa for RDF metadata
2476         if( nElement < 2 ) {
2477             GetExport().AddAttributeXmlId(xName);
2478             const uno::Reference<text::XTextContent> xTextContent(
2479                     xName, uno::UNO_QUERY_THROW);
2480             GetExport().AddAttributesRDFa(xTextContent);
2481         }
2482 
2483         // export element
2484         DBG_ASSERT(pElements != NULL, "illegal element array");
2485         DBG_ASSERT(nElement >= 0, "illegal element number");
2486         DBG_ASSERT(nElement <= 2, "illegal element number");
2487         SvXMLElementExport aElem(GetExport(),
2488                                  XML_NAMESPACE_TEXT, pElements[nElement],
2489                                  sal_False, sal_False);
2490     }
2491     // else: no styles. (see above)
2492 }
2493 
2494 sal_Bool lcl_txtpara_isBoundAsChar(
2495         const Reference < XPropertySet > & rPropSet,
2496         const Reference < XPropertySetInfo > & rPropSetInfo )
2497 {
2498     sal_Bool bIsBoundAsChar = sal_False;
2499     OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2500     if( rPropSetInfo->hasPropertyByName( sAnchorType ) )
2501     {
2502         TextContentAnchorType eAnchor;
2503         rPropSet->getPropertyValue( sAnchorType ) >>= eAnchor;
2504         bIsBoundAsChar = TextContentAnchorType_AS_CHARACTER == eAnchor;
2505     }
2506 
2507     return bIsBoundAsChar;
2508 }
2509 
2510 sal_Int32 XMLTextParagraphExport::addTextFrameAttributes(
2511     const Reference < XPropertySet >& rPropSet,
2512     sal_Bool bShape,
2513     OUString *pMinHeightValue )
2514 {
2515     sal_Int32 nShapeFeatures = SEF_DEFAULT;
2516 
2517     // draw:name (#97662#: not for shapes, since those names will be
2518     // treated in the shape export)
2519     if( !bShape )
2520     {
2521         Reference < XNamed > xNamed( rPropSet, UNO_QUERY );
2522         if( xNamed.is() )
2523         {
2524             OUString sName( xNamed->getName() );
2525             if( sName.getLength() )
2526                 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_NAME,
2527                                           xNamed->getName() );
2528         }
2529     }
2530 
2531     OUStringBuffer sValue;
2532 
2533     // text:anchor-type
2534     TextContentAnchorType eAnchor = TextContentAnchorType_AT_PARAGRAPH;
2535     rPropSet->getPropertyValue( sAnchorType ) >>= eAnchor;
2536     {
2537         XMLAnchorTypePropHdl aAnchorTypeHdl;
2538         OUString sTmp;
2539         aAnchorTypeHdl.exportXML( sTmp, uno::makeAny(eAnchor),
2540                                   GetExport().GetMM100UnitConverter() );
2541         GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, sTmp );
2542     }
2543 
2544     // text:anchor-page-number
2545     if( TextContentAnchorType_AT_PAGE == eAnchor )
2546     {
2547         sal_Int16 nPage = 0;
2548         rPropSet->getPropertyValue( sAnchorPageNo ) >>= nPage;
2549         GetExport().GetMM100UnitConverter().convertNumber( sValue,
2550                                                            (sal_Int32)nPage );
2551         GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_PAGE_NUMBER,
2552                                   sValue.makeStringAndClear() );
2553     }
2554     else
2555     {
2556         // #92210#
2557         nShapeFeatures |= SEF_EXPORT_NO_WS;
2558     }
2559 
2560     // OD 2004-06-01 #i27691# - correction: no export of svg:x, if object
2561     // is anchored as-character.
2562     if ( !bShape &&
2563          eAnchor != TextContentAnchorType_AS_CHARACTER )
2564     {
2565         // svg:x
2566         sal_Int16 nHoriOrient = HoriOrientation::NONE;
2567         rPropSet->getPropertyValue( sHoriOrient ) >>= nHoriOrient;
2568         if( HoriOrientation::NONE == nHoriOrient )
2569         {
2570             sal_Int32 nPos = 0;
2571             rPropSet->getPropertyValue( sHoriOrientPosition ) >>= nPos;
2572             GetExport().GetMM100UnitConverter().convertMeasure( sValue, nPos );
2573             GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_X,
2574                                       sValue.makeStringAndClear() );
2575         }
2576     }
2577     else if( TextContentAnchorType_AS_CHARACTER == eAnchor )
2578         nShapeFeatures = (nShapeFeatures & ~SEF_EXPORT_X);
2579 
2580     if( !bShape || TextContentAnchorType_AS_CHARACTER == eAnchor )
2581     {
2582         // svg:y
2583         sal_Int16 nVertOrient = VertOrientation::NONE;
2584         rPropSet->getPropertyValue( sVertOrient ) >>= nVertOrient;
2585         if( VertOrientation::NONE == nVertOrient )
2586         {
2587             sal_Int32 nPos = 0;
2588             rPropSet->getPropertyValue( sVertOrientPosition ) >>= nPos;
2589             GetExport().GetMM100UnitConverter().convertMeasure( sValue, nPos );
2590             GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_Y,
2591                                       sValue.makeStringAndClear() );
2592         }
2593         if( bShape )
2594             nShapeFeatures = (nShapeFeatures & ~SEF_EXPORT_Y);
2595     }
2596 
2597 
2598     Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo());
2599 
2600     // svg:width
2601     sal_Int16 nWidthType = SizeType::FIX;
2602     if( xPropSetInfo->hasPropertyByName( sWidthType ) )
2603     {
2604         rPropSet->getPropertyValue( sWidthType ) >>= nWidthType;
2605     }
2606     if( xPropSetInfo->hasPropertyByName( sWidth ) )
2607     {
2608         sal_Int32 nWidth = 0;
2609         // VAR size will be written as zero min-size
2610         if( SizeType::VARIABLE != nWidthType )
2611         {
2612             rPropSet->getPropertyValue( sWidth ) >>= nWidth;
2613         }
2614         GetExport().GetMM100UnitConverter().convertMeasure( sValue, nWidth );
2615         if( SizeType::FIX != nWidthType )
2616             GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_WIDTH,
2617                                       sValue.makeStringAndClear() );
2618         else
2619             GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH,
2620                                       sValue.makeStringAndClear() );
2621     }
2622     sal_Bool bSyncWidth = sal_False;
2623     if( xPropSetInfo->hasPropertyByName( sIsSyncWidthToHeight ) )
2624     {
2625         bSyncWidth = *(sal_Bool *)rPropSet->getPropertyValue( sIsSyncWidthToHeight ).getValue();
2626         if( bSyncWidth )
2627             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH,
2628                                       XML_SCALE );
2629     }
2630     if( !bSyncWidth && xPropSetInfo->hasPropertyByName( sRelativeWidth ) )
2631     {
2632         sal_Int16 nRelWidth = 0;
2633         rPropSet->getPropertyValue( sRelativeWidth ) >>= nRelWidth;
2634         DBG_ASSERT( nRelWidth >= 0 && nRelWidth <= 254,
2635                     "Got illegal relative width from API" );
2636         if( nRelWidth > 0 )
2637         {
2638             GetExport().GetMM100UnitConverter().convertPercent( sValue,
2639                                                                 nRelWidth );
2640             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH,
2641                                       sValue.makeStringAndClear() );
2642         }
2643     }
2644 
2645     // svg:height, fo:min-height or style:rel-height
2646     sal_Int16 nSizeType = SizeType::FIX;
2647     if( xPropSetInfo->hasPropertyByName( sSizeType ) )
2648     {
2649         rPropSet->getPropertyValue( sSizeType ) >>= nSizeType;
2650     }
2651     sal_Bool bSyncHeight = sal_False;
2652     if( xPropSetInfo->hasPropertyByName( sIsSyncHeightToWidth ) )
2653     {
2654         bSyncHeight = *(sal_Bool *)rPropSet->getPropertyValue( sIsSyncHeightToWidth ).getValue();
2655     }
2656     sal_Int16 nRelHeight = 0;
2657     if( !bSyncHeight && xPropSetInfo->hasPropertyByName( sRelativeHeight ) )
2658     {
2659         rPropSet->getPropertyValue( sRelativeHeight ) >>= nRelHeight;
2660     }
2661     if( xPropSetInfo->hasPropertyByName( sHeight ) )
2662     {
2663         sal_Int32 nHeight = 0;
2664         if( SizeType::VARIABLE != nSizeType )
2665         {
2666             rPropSet->getPropertyValue( sHeight ) >>= nHeight;
2667         }
2668         GetExport().GetMM100UnitConverter().convertMeasure( sValue,
2669                                                             nHeight );
2670         if( SizeType::FIX != nSizeType && 0==nRelHeight && !bSyncHeight &&
2671             pMinHeightValue )
2672             *pMinHeightValue = sValue.makeStringAndClear();
2673         else
2674             GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT,
2675                                       sValue.makeStringAndClear() );
2676     }
2677     if( bSyncHeight )
2678     {
2679         GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_HEIGHT,
2680                 SizeType::MIN == nSizeType ? XML_SCALE_MIN : XML_SCALE );
2681 
2682     }
2683     else if( nRelHeight > 0 )
2684     {
2685         GetExport().GetMM100UnitConverter().convertPercent( sValue,
2686                                                             nRelHeight );
2687         if( SizeType::MIN == nSizeType )
2688             GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_HEIGHT,
2689                                       sValue.makeStringAndClear() );
2690         else
2691             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_HEIGHT,
2692                                       sValue.makeStringAndClear() );
2693     }
2694 
2695     OUString sZOrder( RTL_CONSTASCII_USTRINGPARAM( "ZOrder" ) );
2696     if( xPropSetInfo->hasPropertyByName( sZOrder ) )
2697     {
2698         sal_Int32 nZIndex = 0;
2699         rPropSet->getPropertyValue( sZOrder ) >>= nZIndex;
2700         if( -1 != nZIndex )
2701         {
2702             GetExport().GetMM100UnitConverter().convertNumber( sValue,
2703                                                                 nZIndex );
2704             GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_ZINDEX,
2705                                       sValue.makeStringAndClear() );
2706         }
2707     }
2708 
2709     return nShapeFeatures;
2710 }
2711 
2712 void XMLTextParagraphExport::exportAnyTextFrame(
2713         const Reference < XTextContent > & rTxtCntnt,
2714         FrameType eType,
2715         sal_Bool bAutoStyles,
2716         sal_Bool bIsProgress,
2717         sal_Bool bExportContent,
2718         const Reference < XPropertySet > *pRangePropSet)
2719 {
2720     Reference < XPropertySet > xPropSet( rTxtCntnt, UNO_QUERY );
2721 
2722     if( bAutoStyles )
2723     {
2724         if( FT_EMBEDDED == eType )
2725             _collectTextEmbeddedAutoStyles( xPropSet );
2726         // --> OD 2004-08-09 #i28745# - no text frame style for shapes
2727         else if ( FT_SHAPE != eType )
2728             Add( XML_STYLE_FAMILY_TEXT_FRAME, xPropSet );
2729         // <--
2730 
2731         if( pRangePropSet && lcl_txtpara_isBoundAsChar( xPropSet,
2732                                             xPropSet->getPropertySetInfo() ) )
2733             Add( XML_STYLE_FAMILY_TEXT_TEXT, *pRangePropSet );
2734 
2735         switch( eType )
2736         {
2737         case FT_TEXT:
2738             {
2739                 // frame bound frames
2740                 if ( bExportContent )
2741                 {
2742                     Reference < XTextFrame > xTxtFrame( rTxtCntnt, UNO_QUERY );
2743                     Reference < XText > xTxt(xTxtFrame->getText());
2744                     exportFrameFrames( sal_True, bIsProgress, &xTxtFrame );
2745                     exportText( xTxt, bAutoStyles, bIsProgress, sal_True );
2746                 }
2747             }
2748             break;
2749         case FT_SHAPE:
2750             {
2751                 Reference < XShape > xShape( rTxtCntnt, UNO_QUERY );
2752                 GetExport().GetShapeExport()->collectShapeAutoStyles( xShape );
2753             }
2754             break;
2755         default:
2756             break;
2757         }
2758     }
2759     else
2760     {
2761         Reference< XPropertySetInfo > xPropSetInfo(xPropSet->getPropertySetInfo());
2762         Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY );
2763         {
2764             sal_Bool bAddCharStyles = pRangePropSet &&
2765                 lcl_txtpara_isBoundAsChar( xPropSet, xPropSetInfo );
2766 
2767             sal_Bool bIsUICharStyle;
2768             sal_Bool bHasAutoStyle = sal_False;
2769             sal_Bool bDummy;
2770 
2771             OUString sStyle;
2772 
2773             if( bAddCharStyles )
2774                 sStyle = FindTextStyleAndHyperlink( *pRangePropSet, bDummy, bIsUICharStyle, bHasAutoStyle );
2775             else
2776                 bIsUICharStyle = sal_False;
2777 
2778             XMLTextCharStyleNamesElementExport aCharStylesExport(
2779                 GetExport(), bIsUICharStyle &&
2780                              aCharStyleNamesPropInfoCache.hasProperty(
2781                                             *pRangePropSet ), bHasAutoStyle,
2782                 *pRangePropSet, sCharStyleNames );
2783 
2784             if( sStyle.getLength() )
2785                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
2786                                   GetExport().EncodeStyleName( sStyle ) );
2787             {
2788                 SvXMLElementExport aElem( GetExport(), sStyle.getLength() > 0,
2789                     XML_NAMESPACE_TEXT, XML_SPAN, sal_False, sal_False );
2790                 {
2791                     SvXMLElementExport aElement( GetExport(),
2792                         FT_SHAPE != eType &&
2793                         addHyperlinkAttributes( xPropSet,
2794                                                 xPropState,xPropSetInfo ),
2795                         XML_NAMESPACE_DRAW, XML_A, sal_False, sal_False );
2796                     switch( eType )
2797                     {
2798                     case FT_TEXT:
2799                         _exportTextFrame( xPropSet, xPropSetInfo, bIsProgress );
2800                         break;
2801                     case FT_GRAPHIC:
2802                         _exportTextGraphic( xPropSet, xPropSetInfo );
2803                         break;
2804                     case FT_EMBEDDED:
2805                         _exportTextEmbedded( xPropSet, xPropSetInfo );
2806                         break;
2807                     case FT_SHAPE:
2808                         {
2809                             Reference < XShape > xShape( rTxtCntnt, UNO_QUERY );
2810                             sal_Int32 nFeatures =
2811                                 addTextFrameAttributes( xPropSet, sal_True );
2812                             GetExport().GetShapeExport()
2813                                 ->exportShape( xShape, nFeatures );
2814                         }
2815                         break;
2816                     }
2817                 }
2818             }
2819         }
2820     }
2821 }
2822 
2823 void XMLTextParagraphExport::_exportTextFrame(
2824         const Reference < XPropertySet > & rPropSet,
2825         const Reference < XPropertySetInfo > & rPropSetInfo,
2826         sal_Bool bIsProgress )
2827 {
2828     Reference < XTextFrame > xTxtFrame( rPropSet, UNO_QUERY );
2829     Reference < XText > xTxt(xTxtFrame->getText());
2830 
2831     OUString sStyle;
2832     if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
2833     {
2834         rPropSet->getPropertyValue( sFrameStyleName ) >>= sStyle;
2835     }
2836 
2837     OUString sAutoStyle( sStyle );
2838     OUString aMinHeightValue;
2839     sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle );
2840     if( sAutoStyle.getLength() )
2841         GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME,
2842                               GetExport().EncodeStyleName( sAutoStyle ) );
2843     addTextFrameAttributes( rPropSet, sal_False, &aMinHeightValue );
2844 
2845     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
2846                               XML_FRAME, sal_False, sal_True );
2847 
2848     if( aMinHeightValue.getLength() )
2849         GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_HEIGHT,
2850                                   aMinHeightValue );
2851 
2852     // draw:chain-next-name
2853     if( rPropSetInfo->hasPropertyByName( sChainNextName ) )
2854     {
2855         OUString sNext;
2856         if( (rPropSet->getPropertyValue( sChainNextName ) >>= sNext) && sNext.getLength() > 0 )
2857             GetExport().AddAttribute( XML_NAMESPACE_DRAW,
2858                                       XML_CHAIN_NEXT_NAME,
2859                                       sNext );
2860     }
2861 
2862     {
2863         SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_DRAW,
2864                                   XML_TEXT_BOX, sal_True, sal_True );
2865 
2866         // frame bound frames
2867         exportFramesBoundToFrame( xTxtFrame, bIsProgress );
2868 
2869         exportText( xTxt, sal_False, bIsProgress, sal_True );
2870     }
2871 
2872     // script:events
2873     Reference<XEventsSupplier> xEventsSupp( xTxtFrame, UNO_QUERY );
2874     GetExport().GetEventExport().Export(xEventsSupp);
2875 
2876     // image map
2877     GetExport().GetImageMapExport().Export( rPropSet );
2878 
2879     // --> OD 2009-07-22 #i73249#
2880     // svg:title and svg:desc
2881     exportTitleAndDescription( rPropSet, rPropSetInfo );
2882     // <--
2883 }
2884 
2885 void XMLTextParagraphExport::exportContour(
2886     const Reference < XPropertySet > & rPropSet,
2887     const Reference < XPropertySetInfo > & rPropSetInfo )
2888 {
2889     if( !rPropSetInfo->hasPropertyByName( sContourPolyPolygon ) )
2890     {
2891         return;
2892     }
2893 
2894     PointSequenceSequence aSourcePolyPolygon;
2895     rPropSet->getPropertyValue( sContourPolyPolygon ) >>= aSourcePolyPolygon;
2896     const basegfx::B2DPolyPolygon aPolyPolygon(
2897         basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(
2898             aSourcePolyPolygon));
2899     const sal_uInt32 nPolygonCount(aPolyPolygon.count());
2900 
2901     if(!nPolygonCount)
2902     {
2903         return;
2904     }
2905 
2906     const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange());
2907     bool bPixel(false);
2908 
2909     if( rPropSetInfo->hasPropertyByName( sIsPixelContour ) )
2910     {
2911         bPixel = *(sal_Bool *)rPropSet->getPropertyValue( sIsPixelContour ).getValue();
2912     }
2913 
2914     // svg: width
2915     OUStringBuffer aStringBuffer( 10 );
2916 
2917     if(bPixel)
2918     {
2919         GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer, basegfx::fround(aPolyPolygonRange.getWidth()));
2920     }
2921     else
2922     {
2923         GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer, basegfx::fround(aPolyPolygonRange.getWidth()));
2924     }
2925 
2926     GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStringBuffer.makeStringAndClear());
2927 
2928     // svg: height
2929     if(bPixel)
2930     {
2931         GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer, basegfx::fround(aPolyPolygonRange.getHeight()));
2932     }
2933     else
2934     {
2935         GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer, basegfx::fround(aPolyPolygonRange.getHeight()));
2936     }
2937 
2938     GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStringBuffer.makeStringAndClear());
2939 
2940     // svg:viewbox
2941     SdXMLImExViewBox aViewBox(0.0, 0.0, aPolyPolygonRange.getWidth(), aPolyPolygonRange.getHeight());
2942     GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString());
2943     enum XMLTokenEnum eElem = XML_TOKEN_INVALID;
2944 
2945     if(1 == nPolygonCount )
2946     {
2947         // simple polygon shape, can be written as svg:points sequence
2948         const ::rtl::OUString aPointString(
2949             basegfx::tools::exportToSvgPoints(
2950                 aPolyPolygon.getB2DPolygon(0)));
2951 
2952         // write point array
2953         GetExport().AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPointString);
2954         eElem = XML_CONTOUR_POLYGON;
2955     }
2956     else
2957     {
2958         // polypolygon, needs to be written as a svg:path sequence
2959         const ::rtl::OUString aPolygonString(
2960             basegfx::tools::exportToSvgD(
2961                 aPolyPolygon,
2962                 true,           // bUseRelativeCoordinates
2963                 false,          // bDetectQuadraticBeziers: not used in old, but maybe activated now
2964                 true));         // bHandleRelativeNextPointCompatible
2965 
2966         // write point array
2967         GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_D, aPolygonString);
2968         eElem = XML_CONTOUR_PATH;
2969     }
2970 
2971     if( rPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
2972     {
2973         sal_Bool bTmp = *(sal_Bool *)rPropSet->getPropertyValue(
2974                                             sIsAutomaticContour ).getValue();
2975         GetExport().AddAttribute( XML_NAMESPACE_DRAW,
2976                       XML_RECREATE_ON_EDIT, bTmp ? XML_TRUE : XML_FALSE );
2977     }
2978 
2979     // write object now
2980     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, eElem,
2981                               sal_True, sal_True );
2982 }
2983 
2984 void XMLTextParagraphExport::_exportTextGraphic(
2985         const Reference < XPropertySet > & rPropSet,
2986         const Reference < XPropertySetInfo > & rPropSetInfo )
2987 {
2988     OUString sStyle;
2989     if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
2990     {
2991         rPropSet->getPropertyValue( sFrameStyleName ) >>= sStyle;
2992     }
2993 
2994     OUString sAutoStyle( sStyle );
2995     sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle );
2996     if( sAutoStyle.getLength() )
2997         GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME,
2998                                   GetExport().EncodeStyleName( sAutoStyle ) );
2999     addTextFrameAttributes( rPropSet, sal_False );
3000 
3001     // svg:transform
3002     sal_Int16 nVal = 0;
3003     rPropSet->getPropertyValue( sGraphicRotation ) >>= nVal;
3004     if( nVal != 0 )
3005     {
3006         OUStringBuffer sRet( GetXMLToken(XML_ROTATE).getLength()+4 );
3007         sRet.append( GetXMLToken(XML_ROTATE));
3008         sRet.append( (sal_Unicode)'(' );
3009         GetExport().GetMM100UnitConverter().convertNumber( sRet, (sal_Int32)nVal );
3010         sRet.append( (sal_Unicode)')' );
3011         GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_TRANSFORM,
3012                                   sRet.makeStringAndClear() );
3013     }
3014 
3015     // original content
3016     SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_DRAW, XML_FRAME, sal_False, sal_True);
3017 
3018     // replacement graphic for backwards compatibility, but
3019     // only for SVG currently
3020     OUString sReplacementOrigURL;
3021     rPropSet->getPropertyValue( sReplacementGraphicURL ) >>= sReplacementOrigURL;
3022 
3023     if(sReplacementOrigURL.getLength())
3024     {
3025         const OUString sReplacementURL(GetExport().AddEmbeddedGraphicObject( sReplacementOrigURL ));
3026 
3027         // If there is no url, then the graphic is empty
3028         if(sReplacementURL.getLength())
3029         {
3030             GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sReplacementURL);
3031             GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
3032             GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED);
3033             GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD);
3034 
3035             // xlink:href for replacement, only written for SVG content
3036             SvXMLElementExport aElement(GetExport(), XML_NAMESPACE_DRAW, XML_IMAGE, sal_False, sal_True);
3037 
3038             // optional office:binary-data
3039             GetExport().AddEmbeddedGraphicObjectAsBase64(sReplacementURL);
3040         }
3041     }
3042 
3043     // xlink:href
3044     OUString sOrigURL;
3045     rPropSet->getPropertyValue( sGraphicURL ) >>= sOrigURL;
3046     OUString sURL(GetExport().AddEmbeddedGraphicObject( sOrigURL ));
3047     setTextEmbeddedGraphicURL( rPropSet, sURL );
3048 
3049     // If there still is no url, then the graphic is empty
3050     if( sURL.getLength() )
3051     {
3052         GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
3053         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3054         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
3055         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE,
3056                                                        XML_ONLOAD );
3057     }
3058 
3059     // draw:filter-name
3060     OUString sGrfFilter;
3061     rPropSet->getPropertyValue( sGraphicFilter ) >>= sGrfFilter;
3062     if( sGrfFilter.getLength() )
3063         GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_FILTER_NAME,
3064                                   sGrfFilter );
3065 
3066     {
3067         SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_DRAW,
3068                                   XML_IMAGE, sal_False, sal_True );
3069 
3070         // optional office:binary-data
3071         GetExport().AddEmbeddedGraphicObjectAsBase64( sOrigURL );
3072     }
3073 
3074     // script:events
3075     Reference<XEventsSupplier> xEventsSupp( rPropSet, UNO_QUERY );
3076     GetExport().GetEventExport().Export(xEventsSupp);
3077 
3078     // image map
3079     GetExport().GetImageMapExport().Export( rPropSet );
3080 
3081     // --> OD 2009-07-22 #i73249#
3082     // svg:title and svg:desc
3083     exportTitleAndDescription( rPropSet, rPropSetInfo );
3084     // <--
3085 
3086     // draw:contour
3087     exportContour( rPropSet, rPropSetInfo );
3088 }
3089 
3090 void XMLTextParagraphExport::_collectTextEmbeddedAutoStyles(const Reference < XPropertySet > & )
3091 {
3092     DBG_ASSERT( sal_False, "no API implementation available" );
3093 }
3094 
3095 void XMLTextParagraphExport::_exportTextEmbedded(
3096         const Reference < XPropertySet > &,
3097         const Reference < XPropertySetInfo > & )
3098 {
3099     DBG_ASSERT( sal_False, "no API implementation available" );
3100 }
3101 
3102 void XMLTextParagraphExport::exportEvents( const Reference < XPropertySet > & rPropSet )
3103 {
3104     // script:events
3105     Reference<XEventsSupplier> xEventsSupp( rPropSet, UNO_QUERY );
3106     GetExport().GetEventExport().Export(xEventsSupp);
3107 
3108     // image map
3109     OUString sImageMap(RTL_CONSTASCII_USTRINGPARAM("ImageMap"));
3110     if (rPropSet->getPropertySetInfo()->hasPropertyByName(sImageMap))
3111         GetExport().GetImageMapExport().Export( rPropSet );
3112 }
3113 
3114 // --> OD 2009-07-22 #i73249#
3115 void XMLTextParagraphExport::exportTitleAndDescription(
3116         const Reference < XPropertySet > & rPropSet,
3117         const Reference < XPropertySetInfo > & rPropSetInfo )
3118 {
3119     // svg:title
3120     if( rPropSetInfo->hasPropertyByName( sTitle ) )
3121     {
3122         OUString sObjTitle;
3123         rPropSet->getPropertyValue( sTitle ) >>= sObjTitle;
3124         if( sObjTitle.getLength() )
3125         {
3126             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG,
3127                                       XML_TITLE, sal_True, sal_False );
3128             GetExport().Characters( sObjTitle );
3129         }
3130     }
3131 
3132     // svg:description
3133     if( rPropSetInfo->hasPropertyByName( sDescription ) )
3134     {
3135         OUString sObjDesc;
3136         rPropSet->getPropertyValue( sDescription ) >>= sObjDesc;
3137         if( sObjDesc.getLength() )
3138         {
3139             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG,
3140                                       XML_DESC, sal_True, sal_False );
3141             GetExport().Characters( sObjDesc );
3142         }
3143     }
3144 }
3145 // <--
3146 
3147 void XMLTextParagraphExport::setTextEmbeddedGraphicURL(
3148     const Reference < XPropertySet >&,
3149     OUString& /*rStreamName*/ ) const
3150 {
3151 }
3152 
3153 sal_Bool XMLTextParagraphExport::addHyperlinkAttributes(
3154     const Reference< XPropertySet > & rPropSet,
3155     const Reference< XPropertyState > & rPropState,
3156     const Reference< XPropertySetInfo > & rPropSetInfo )
3157 {
3158     sal_Bool bExport = sal_False;
3159     OUString sHRef, sName, sTargetFrame, sUStyleName, sVStyleName;
3160     sal_Bool bServerMap = sal_False;
3161 
3162     if ( rPropSetInfo->hasPropertyByName( sHyperLinkURL )
3163          && ( !rPropState.is()
3164               || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sHyperLinkURL ) ) )
3165     {
3166         rPropSet->getPropertyValue( sHyperLinkURL ) >>= sHRef;
3167         if ( !sHRef.isEmpty() )
3168             bExport = sal_True;
3169     }
3170     if ( sHRef.isEmpty() )
3171     {
3172         // hyperlink without an URL does not make sense
3173         OSL_ENSURE( false, "hyperlink without an URL --> no export to ODF" );
3174         return sal_False;
3175     }
3176 
3177 
3178     if ( rPropSetInfo->hasPropertyByName( sHyperLinkName )
3179          && ( !rPropState.is()
3180               || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sHyperLinkName ) ) )
3181     {
3182         rPropSet->getPropertyValue( sHyperLinkName ) >>= sName;
3183         if ( !sName.isEmpty() )
3184             bExport = sal_True;
3185     }
3186 
3187     if ( rPropSetInfo->hasPropertyByName( sHyperLinkTarget )
3188          && ( !rPropState.is()
3189               || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sHyperLinkTarget ) ) )
3190     {
3191         rPropSet->getPropertyValue( sHyperLinkTarget ) >>= sTargetFrame;
3192         if ( !sTargetFrame.isEmpty() )
3193             bExport = sal_True;
3194     }
3195 
3196     if ( rPropSetInfo->hasPropertyByName( sServerMap )
3197          && ( !rPropState.is()
3198               || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sServerMap ) ) )
3199     {
3200         bServerMap = *(sal_Bool *) rPropSet->getPropertyValue( sServerMap ).getValue();
3201         if ( bServerMap )
3202             bExport = sal_True;
3203     }
3204 
3205     if ( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName )
3206          && ( !rPropState.is()
3207               || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sUnvisitedCharStyleName ) ) )
3208     {
3209         rPropSet->getPropertyValue( sUnvisitedCharStyleName ) >>= sUStyleName;
3210         if ( !sUStyleName.isEmpty() )
3211             bExport = sal_True;
3212     }
3213 
3214     if ( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName )
3215          && ( !rPropState.is()
3216               || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sVisitedCharStyleName ) ) )
3217     {
3218         rPropSet->getPropertyValue( sVisitedCharStyleName ) >>= sVStyleName;
3219         if ( !sVStyleName.isEmpty() )
3220             bExport = sal_True;
3221     }
3222 
3223     if ( bExport )
3224     {
3225         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3226         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference( sHRef ) );
3227 
3228         if( !sName.isEmpty() )
3229             GetExport().AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME, sName );
3230 
3231         if( !sTargetFrame.isEmpty() )
3232         {
3233             GetExport().AddAttribute( XML_NAMESPACE_OFFICE,
3234                                       XML_TARGET_FRAME_NAME, sTargetFrame );
3235             enum XMLTokenEnum eTok =
3236                 sTargetFrame.equalsAsciiL( "_blank", sizeof("_blank")-1 )
3237                     ? XML_NEW : XML_REPLACE;
3238             GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, eTok );
3239         }
3240 
3241         if( bServerMap )
3242             GetExport().AddAttribute( XML_NAMESPACE_OFFICE,
3243                                       XML_SERVER_MAP, XML_TRUE );
3244 
3245         if( !sUStyleName.isEmpty() )
3246             GetExport().AddAttribute( XML_NAMESPACE_TEXT,
3247               XML_STYLE_NAME, GetExport().EncodeStyleName( sUStyleName ) );
3248 
3249         if( !sVStyleName.isEmpty() )
3250             GetExport().AddAttribute( XML_NAMESPACE_TEXT,
3251               XML_VISITED_STYLE_NAME, GetExport().EncodeStyleName( sVStyleName ) );
3252     }
3253 
3254     return bExport;
3255 }
3256 
3257 void XMLTextParagraphExport::exportTextRangeSpan(
3258     const com::sun::star::uno::Reference< com::sun::star::text::XTextRange > & rTextRange,
3259     Reference< XPropertySet > & xPropSet,
3260     Reference < XPropertySetInfo > & xPropSetInfo,
3261     const sal_Bool bIsUICharStyle,
3262     const sal_Bool bHasAutoStyle,
3263     const OUString& sStyle,
3264     sal_Bool& rPrevCharIsSpace )
3265 {
3266     XMLTextCharStyleNamesElementExport aCharStylesExport(
3267             GetExport(),
3268             bIsUICharStyle && aCharStyleNamesPropInfoCache.hasProperty( xPropSet, xPropSetInfo ),
3269             bHasAutoStyle,
3270             xPropSet,
3271             sCharStyleNames );
3272 
3273     if ( !sStyle.isEmpty() )
3274     {
3275         GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( sStyle ) );
3276     }
3277     {
3278         SvXMLElementExport aElement( GetExport(), !sStyle.isEmpty(), XML_NAMESPACE_TEXT, XML_SPAN, sal_False, sal_False );
3279         const OUString aText( rTextRange->getString() );
3280         exportText( aText, rPrevCharIsSpace );
3281     }
3282 }
3283 
3284 void XMLTextParagraphExport::exportTextRange(
3285         const Reference< XTextRange > & rTextRange,
3286         sal_Bool bAutoStyles,
3287         sal_Bool& rPrevCharIsSpace )
3288 {
3289     Reference< XPropertySet > xPropSet( rTextRange, UNO_QUERY );
3290     if ( bAutoStyles )
3291     {
3292         Add( XML_STYLE_FAMILY_TEXT_TEXT, xPropSet );
3293     }
3294     else
3295     {
3296         sal_Bool bHyperlink = sal_False;
3297         sal_Bool bIsUICharStyle = sal_False;
3298         sal_Bool bHasAutoStyle = sal_False;
3299         const OUString sStyle(
3300             FindTextStyleAndHyperlink( xPropSet, bHyperlink, bIsUICharStyle, bHasAutoStyle ) );
3301 
3302         Reference < XPropertySetInfo > xPropSetInfo;
3303         sal_Bool bHyperlinkAttrsAdded = sal_False;
3304         if ( bHyperlink )
3305         {
3306             Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY );
3307             xPropSetInfo.set( xPropSet->getPropertySetInfo() );
3308             bHyperlinkAttrsAdded = addHyperlinkAttributes( xPropSet, xPropState, xPropSetInfo );
3309         }
3310 
3311         if ( bHyperlink && bHyperlinkAttrsAdded )
3312         {
3313             SvXMLElementExport aElem( GetExport(), sal_True, XML_NAMESPACE_TEXT, XML_A, sal_False, sal_False );
3314 
3315             // export events (if supported)
3316             static const OUString sHyperLinkEvents( RTL_CONSTASCII_USTRINGPARAM( "HyperLinkEvents" ) );
3317             if ( xPropSetInfo->hasPropertyByName( sHyperLinkEvents ) )
3318             {
3319                 Reference< XNameReplace > xName( xPropSet->getPropertyValue( sHyperLinkEvents ), uno::UNO_QUERY );
3320                 GetExport().GetEventExport().Export( xName, sal_False );
3321             }
3322 
3323             exportTextRangeSpan( rTextRange, xPropSet, xPropSetInfo, bIsUICharStyle, bHasAutoStyle, sStyle, rPrevCharIsSpace );
3324         }
3325         else
3326         {
3327             exportTextRangeSpan( rTextRange, xPropSet, xPropSetInfo, bIsUICharStyle, bHasAutoStyle, sStyle, rPrevCharIsSpace );
3328         }
3329     }
3330 }
3331 
3332 void XMLTextParagraphExport::exportText( const OUString& rText,
3333                                          sal_Bool& rPrevCharIsSpace )
3334 {
3335     sal_Int32 nExpStartPos = 0;
3336     sal_Int32 nEndPos = rText.getLength();
3337     sal_Int32 nSpaceChars = 0;
3338     for( sal_Int32 nPos = 0; nPos < nEndPos; nPos++ )
3339     {
3340         sal_Unicode cChar = rText[nPos];
3341         sal_Bool bExpCharAsText = sal_True;
3342         sal_Bool bExpCharAsElement = sal_False;
3343         sal_Bool bCurrCharIsSpace = sal_False;
3344         switch( cChar )
3345         {
3346         case 0x0009: // Tab
3347         case 0x000A: // LF
3348             // These characters are exported as text.
3349             bExpCharAsElement = sal_True;
3350             bExpCharAsText = sal_False;
3351             break;
3352         case 0x000D:
3353             break; // legal character
3354         case 0x0020: // Blank
3355             if( rPrevCharIsSpace )
3356             {
3357                 // If the previous character is a space character,
3358                 // too, export a special space element.
3359                 bExpCharAsText = sal_False;
3360             }
3361             bCurrCharIsSpace = sal_True;
3362             break;
3363         default:
3364             if( cChar < 0x0020 )
3365             {
3366 #ifdef DBG_UTIL
3367                 OSL_ENSURE( txtparae_bContainsIllegalCharacters ||
3368                             cChar >= 0x0020,
3369                             "illegal character in text content" );
3370                 txtparae_bContainsIllegalCharacters = sal_True;
3371 #endif
3372                 bExpCharAsText = sal_False;
3373             }
3374             break;
3375         }
3376 
3377         // If the current character is not exported as text
3378         // the text that has not been exported by now has to be exported now.
3379         if( nPos > nExpStartPos && !bExpCharAsText )
3380         {
3381             DBG_ASSERT( 0==nSpaceChars, "pending spaces" );
3382             OUString sExp( rText.copy( nExpStartPos, nPos - nExpStartPos ) );
3383             GetExport().Characters( sExp );
3384             nExpStartPos = nPos;
3385         }
3386 
3387         // If there are spaces left that have not been exported and the
3388         // current character is not a space , the pending spaces have to be
3389         // exported now.
3390         if( nSpaceChars > 0 && !bCurrCharIsSpace )
3391         {
3392             DBG_ASSERT( nExpStartPos == nPos, " pending characters" );
3393 
3394             if( nSpaceChars > 1 )
3395             {
3396                 OUStringBuffer sTmp;
3397                 sTmp.append( (sal_Int32)nSpaceChars );
3398                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C,
3399                               sTmp.makeStringAndClear() );
3400             }
3401 
3402             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
3403                                       XML_S, sal_False, sal_False );
3404 
3405             nSpaceChars = 0;
3406         }
3407 
3408         // If the current character has to be exported as a special
3409         // element, the element will be exported now.
3410         if( bExpCharAsElement )
3411         {
3412             switch( cChar )
3413             {
3414             case 0x0009:    // Tab
3415                 {
3416                     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
3417                                               XML_TAB, sal_False,
3418                                               sal_False );
3419                 }
3420                 break;
3421             case 0x000A:    // LF
3422                 {
3423                     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
3424                                               XML_LINE_BREAK, sal_False,
3425                                               sal_False );
3426                 }
3427                 break;
3428             }
3429         }
3430 
3431         // If the current character is a space, and the previous one
3432         // is a space, too, the number of pending spaces is incremented
3433         // only.
3434         if( bCurrCharIsSpace && rPrevCharIsSpace )
3435             nSpaceChars++;
3436         rPrevCharIsSpace = bCurrCharIsSpace;
3437 
3438         // If the current character is not exported as text, the start
3439         // position for text is the position behind the current position.
3440         if( !bExpCharAsText )
3441         {
3442             DBG_ASSERT( nExpStartPos == nPos, "wrong export start pos" );
3443             nExpStartPos = nPos+1;
3444         }
3445     }
3446 
3447     if( nExpStartPos < nEndPos )
3448     {
3449         DBG_ASSERT( 0==nSpaceChars, " pending spaces " );
3450         OUString sExp( rText.copy( nExpStartPos, nEndPos - nExpStartPos ) );
3451         GetExport().Characters( sExp );
3452     }
3453 
3454     // If there are some spaces left, they have to be exported now.
3455     if( nSpaceChars > 0 )
3456     {
3457         if( nSpaceChars > 1 )
3458         {
3459             OUStringBuffer sTmp;
3460             sTmp.append( (sal_Int32)nSpaceChars );
3461             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C,
3462                           sTmp.makeStringAndClear() );
3463         }
3464 
3465         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_S,
3466                                   sal_False, sal_False );
3467     }
3468 }
3469 
3470 void XMLTextParagraphExport::exportTextDeclarations()
3471 {
3472     pFieldExport->ExportFieldDeclarations();
3473 
3474     // get XPropertySet from the document and ask for AutoMarkFileURL.
3475     // If it exists, export the auto-mark-file element.
3476     Reference<XPropertySet> xPropertySet( GetExport().GetModel(), UNO_QUERY );
3477     if (xPropertySet.is())
3478     {
3479         OUString sUrl;
3480         OUString sIndexAutoMarkFileURL(
3481             RTL_CONSTASCII_USTRINGPARAM("IndexAutoMarkFileURL"));
3482         if (xPropertySet->getPropertySetInfo()->hasPropertyByName(
3483             sIndexAutoMarkFileURL))
3484         {
3485             xPropertySet->getPropertyValue(sIndexAutoMarkFileURL) >>= sUrl;
3486             if (sUrl.getLength() > 0)
3487             {
3488                 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF,
3489                                           GetExport().GetRelativeReference(sUrl) );
3490                 SvXMLElementExport aAutoMarkElement(
3491                     GetExport(), XML_NAMESPACE_TEXT,
3492                     XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE,
3493                     sal_True, sal_True );
3494             }
3495         }
3496     }
3497 }
3498 
3499 void XMLTextParagraphExport::exportTextDeclarations(
3500     const Reference<XText> & rText )
3501 {
3502     pFieldExport->ExportFieldDeclarations(rText);
3503 }
3504 
3505 void XMLTextParagraphExport::exportUsedDeclarations( sal_Bool bOnlyUsed )
3506 {
3507     pFieldExport->SetExportOnlyUsedFieldDeclarations( bOnlyUsed );
3508 }
3509 
3510 
3511 void XMLTextParagraphExport::exportTrackedChanges(sal_Bool bAutoStyles)
3512 {
3513     if (NULL != pRedlineExport)
3514         pRedlineExport->ExportChangesList( bAutoStyles );
3515 }
3516 
3517 void XMLTextParagraphExport::exportTrackedChanges(
3518     const Reference<XText> & rText,
3519     sal_Bool bAutoStyle)
3520 {
3521     if (NULL != pRedlineExport)
3522         pRedlineExport->ExportChangesList(rText, bAutoStyle);
3523 }
3524 
3525 void XMLTextParagraphExport::recordTrackedChangesForXText(
3526     const Reference<XText> & rText )
3527 {
3528     if (NULL != pRedlineExport)
3529         pRedlineExport->SetCurrentXText(rText);
3530 }
3531 
3532 void XMLTextParagraphExport::recordTrackedChangesNoXText()
3533 {
3534     if (NULL != pRedlineExport)
3535         pRedlineExport->SetCurrentXText();
3536 }
3537 
3538 
3539 void XMLTextParagraphExport::exportTextAutoStyles()
3540 {
3541     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
3542                                    GetExport().GetDocHandler(),
3543                                    GetExport().GetMM100UnitConverter(),
3544                                    GetExport().GetNamespaceMap() );
3545 
3546     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_TEXT,
3547                                    GetExport().GetDocHandler(),
3548                                    GetExport().GetMM100UnitConverter(),
3549                                    GetExport().GetNamespaceMap() );
3550 
3551     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_FRAME,
3552                                    GetExport().GetDocHandler(),
3553                                    GetExport().GetMM100UnitConverter(),
3554                                    GetExport().GetNamespaceMap() );
3555 
3556     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_SECTION,
3557                                   GetExport().GetDocHandler(),
3558                                   GetExport().GetMM100UnitConverter(),
3559                                   GetExport().GetNamespaceMap() );
3560 
3561     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_RUBY,
3562                                   GetExport().GetDocHandler(),
3563                                   GetExport().GetMM100UnitConverter(),
3564                                   GetExport().GetNamespaceMap() );
3565 
3566     pListAutoPool->exportXML();
3567 }
3568 
3569 void XMLTextParagraphExport::exportRuby(
3570     const Reference<XPropertySet> & rPropSet,
3571     sal_Bool bAutoStyles )
3572 {
3573     // early out: a collapsed ruby makes no sense
3574     if (*(sal_Bool*)rPropSet->getPropertyValue(sIsCollapsed).getValue())
3575         return;
3576 
3577     // start value ?
3578     sal_Bool bStart = (*(sal_Bool*)rPropSet->getPropertyValue(sIsStart).getValue());
3579 
3580     if (bAutoStyles)
3581     {
3582         // ruby auto styles
3583         if (bStart)
3584             Add( XML_STYLE_FAMILY_TEXT_RUBY, rPropSet );
3585     }
3586     else
3587     {
3588         // prepare element names
3589         OUString aRuby(GetXMLToken(XML_RUBY));
3590         OUString sTextRuby(GetExport().GetNamespaceMap().
3591                            GetQNameByKey(XML_NAMESPACE_TEXT, aRuby));
3592         OUString sRubyBase(GetXMLToken(XML_RUBY_BASE));
3593         OUString sTextRubyBase(GetExport().GetNamespaceMap().
3594                            GetQNameByKey(XML_NAMESPACE_TEXT, sRubyBase));
3595 
3596         if (bStart)
3597         {
3598             // ruby start
3599 
3600             // we can only start a ruby if none is open
3601             DBG_ASSERT(! bOpenRuby, "Can't open a ruby inside of ruby!");
3602             if( bOpenRuby )
3603                 return;
3604 
3605             // save ruby text + ruby char style
3606             rPropSet->getPropertyValue(sRubyText) >>= sOpenRubyText;
3607             rPropSet->getPropertyValue(sRubyCharStyleName) >>= sOpenRubyCharStyle;
3608 
3609             // ruby style
3610             GetExport().CheckAttrList();
3611             OUString sEmpty;
3612             OUString sStyleName(Find( XML_STYLE_FAMILY_TEXT_RUBY, rPropSet,
3613                                         sEmpty ));
3614             DBG_ASSERT(sStyleName.getLength() > 0, "I can't find the style!");
3615             GetExport().AddAttribute(XML_NAMESPACE_TEXT,
3616                                      XML_STYLE_NAME, sStyleName);
3617 
3618             // export <text:ruby> and <text:ruby-base> start elements
3619             GetExport().StartElement( XML_NAMESPACE_TEXT, XML_RUBY, sal_False);
3620             GetExport().ClearAttrList();
3621             GetExport().StartElement( XML_NAMESPACE_TEXT, XML_RUBY_BASE,
3622                                       sal_False );
3623             bOpenRuby = sal_True;
3624         }
3625         else
3626         {
3627             // ruby end
3628 
3629             // check for an open ruby
3630             DBG_ASSERT(bOpenRuby, "Can't close a ruby if none is open!");
3631             if( !bOpenRuby )
3632                 return;
3633 
3634             // close <text:ruby-base>
3635             GetExport().EndElement(XML_NAMESPACE_TEXT, XML_RUBY_BASE,
3636                                    sal_False);
3637 
3638             // write the ruby text (with char style)
3639             {
3640                 if (sOpenRubyCharStyle.getLength() > 0)
3641                     GetExport().AddAttribute(
3642                         XML_NAMESPACE_TEXT, XML_STYLE_NAME,
3643                         GetExport().EncodeStyleName( sOpenRubyCharStyle) );
3644 
3645                 SvXMLElementExport aRubyElement(
3646                     GetExport(), XML_NAMESPACE_TEXT, XML_RUBY_TEXT,
3647                     sal_False, sal_False);
3648 
3649                 GetExport().Characters(sOpenRubyText);
3650             }
3651 
3652             // and finally, close the ruby
3653             GetExport().EndElement(XML_NAMESPACE_TEXT, XML_RUBY, sal_False);
3654             bOpenRuby = sal_False;
3655         }
3656     }
3657 }
3658 
3659 void XMLTextParagraphExport::exportMeta(
3660     const Reference<XPropertySet> & i_xPortion,
3661     sal_Bool i_bAutoStyles, sal_Bool i_isProgress)
3662 {
3663     static OUString sMeta(RTL_CONSTASCII_USTRINGPARAM("InContentMetadata"));
3664 
3665     bool doExport(!i_bAutoStyles); // do not export element if autostyles
3666     // check version >= 1.2
3667     switch (GetExport().getDefaultVersion()) {
3668         case SvtSaveOptions::ODFVER_011: // fall thru
3669         case SvtSaveOptions::ODFVER_010: doExport = false; break;
3670         default: break;
3671     }
3672 
3673     const Reference< XTextContent > xTextContent(
3674             i_xPortion->getPropertyValue(sMeta), UNO_QUERY_THROW);
3675     const Reference< XEnumerationAccess > xEA( xTextContent, UNO_QUERY_THROW );
3676     const Reference< XEnumeration > xTextEnum( xEA->createEnumeration() );
3677 
3678     if (doExport)
3679     {
3680         const Reference<rdf::XMetadatable> xMeta(xTextContent, UNO_QUERY_THROW);
3681 
3682         // text:meta with neither xml:id nor RDFa is invalid
3683         xMeta->ensureMetadataReference();
3684 
3685         // xml:id and RDFa for RDF metadata
3686         GetExport().AddAttributeXmlId(xMeta);
3687         GetExport().AddAttributesRDFa(xTextContent);
3688     }
3689 
3690     SvXMLElementExport aElem( GetExport(), doExport,
3691         XML_NAMESPACE_TEXT, XML_META, sal_False, sal_False );
3692 
3693     // recurse to export content
3694     exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_isProgress );
3695 }
3696 
3697 
3698 void XMLTextParagraphExport::PreventExportOfControlsInMuteSections(
3699     const Reference<XIndexAccess> & rShapes,
3700     UniReference<xmloff::OFormLayerXMLExport> xFormExport )
3701 {
3702     // check parameters and pre-conditions
3703     if( ( ! rShapes.is() ) || ( ! xFormExport.is() ) )
3704     {
3705         // if we don't have shapes or a form export, there's nothing to do
3706         return;
3707     }
3708     DBG_ASSERT( pSectionExport != NULL, "We need the section export." );
3709 
3710     Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration();
3711     if(!xShapesEnum.is())
3712         return;
3713     while( xShapesEnum->hasMoreElements() )
3714     {
3715         // now we need to check
3716         // 1) if this is a control shape, and
3717         // 2) if it's in a mute section
3718         // if both answers are 'yes', notify the form layer export
3719 
3720         // we join accessing the shape and testing for control
3721         Reference<XControlShape> xControlShape(xShapesEnum->nextElement(), UNO_QUERY);
3722         if( xControlShape.is() )
3723         {
3724             //            Reference<XPropertySet> xPropSet( xControlShape, UNO_QUERY );
3725             //            Reference<XTextContent> xTextContent;
3726             //            xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) ) ) >>= xTextContent;
3727 
3728             Reference<XTextContent> xTextContent( xControlShape, UNO_QUERY );
3729             if( xTextContent.is() )
3730             {
3731                 if( pSectionExport->IsMuteSection( xTextContent, sal_False ) )
3732                 {
3733                     // Ah, we've found a shape that
3734                     // 1) is a control shape
3735                     // 2) is anchored in a mute section
3736                     // so: don't export it!
3737                     xFormExport->excludeFromExport(
3738                         xControlShape->getControl() );
3739                 }
3740                 // else: not in mute section -> should be exported -> nothing
3741                 // to do
3742             }
3743             // else: no anchor -> ignore
3744         }
3745         // else: no control shape -> nothing to do
3746     }
3747 }
3748 sal_Int32 XMLTextParagraphExport::GetHeadingLevel( const OUString& rStyleName )
3749 {
3750     if( !pHeadingStyles )
3751     {
3752         pHeadingStyles = new XMLStringVector;
3753         SvxXMLNumRuleExport::GetOutlineStyles( *pHeadingStyles,
3754                                                GetExport().GetModel() );
3755     }
3756     for( XMLStringVector::size_type i=0; i < pHeadingStyles->size(); ++i )
3757     {
3758         if( (*pHeadingStyles)[i] == rStyleName )
3759             return static_cast < sal_Int32 >( i );
3760     }
3761 
3762     return -1;
3763 }
3764 
3765 // --> OD 2008-05-08 #refactorlists#
3766 void XMLTextParagraphExport::PushNewTextListsHelper()
3767 {
3768     mpTextListsHelper = new XMLTextListsHelper();
3769     maTextListsHelperStack.push_back( mpTextListsHelper );
3770 }
3771 
3772 void XMLTextParagraphExport::PopTextListsHelper()
3773 {
3774     delete mpTextListsHelper;
3775     mpTextListsHelper = 0;
3776     maTextListsHelperStack.pop_back();
3777     if ( !maTextListsHelperStack.empty() )
3778     {
3779         mpTextListsHelper = maTextListsHelperStack.back();
3780     }
3781 }
3782 // <--
3783