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