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