1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtparae.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "unointerfacetouniqueidentifiermapper.hxx"
34 #include <tools/debug.hxx>
35 #ifndef _SVSTDARR_LONGS_DECL
36 #define _SVSTDARR_LONGS
37 #include <svtools/svstdarr.hxx>
39 #include <svtools/svarray.hxx>
40 #include <rtl/ustrbuf.hxx>
41 #include <sal/types.h>
47 #include <com/sun/star/lang/XServiceInfo.hpp>
48 #include <com/sun/star/container/XEnumerationAccess.hpp>
49 #include <com/sun/star/container/XEnumeration.hpp>
50 #include <com/sun/star/container/XIndexReplace.hpp>
51 #include <com/sun/star/beans/XPropertySet.hpp>
52 #include <com/sun/star/beans/XMultiPropertySet.hpp>
53 #include <com/sun/star/beans/XPropertyState.hpp>
54 #include <com/sun/star/text/XTextDocument.hpp>
55 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
56 #include <com/sun/star/text/XTextTablesSupplier.hpp>
57 #include <com/sun/star/text/XNumberingRulesSupplier.hpp>
58 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>//#outline level,add by zhaojianwei
59 #include <com/sun/star/text/XTextTable.hpp>
60 #include <com/sun/star/text/XText.hpp>
61 #include <com/sun/star/text/XTextContent.hpp>
62 #include <com/sun/star/text/XTextRange.hpp>
63 #include <com/sun/star/text/XTextField.hpp>
64 #include <com/sun/star/text/XFootnote.hpp>
65 #include <com/sun/star/container/XNamed.hpp>
66 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
67 #include <com/sun/star/text/XTextFrame.hpp>
68 #include <com/sun/star/container/XNameAccess.hpp>
69 #include <com/sun/star/text/SizeType.hpp>
70 #include <com/sun/star/text/HoriOrientation.hpp>
71 #include <com/sun/star/text/VertOrientation.hpp>
72 #include <com/sun/star/text/TextContentAnchorType.hpp>
73 #include <com/sun/star/text/XTextFramesSupplier.hpp>
74 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
75 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
76 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
77 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
78 #include <com/sun/star/document/XEventsSupplier.hpp>
79 #include <com/sun/star/document/XRedlinesSupplier.hpp>
81 #include <com/sun/star/text/XBookmarksSupplier.hpp>
82 #include <com/sun/star/text/XFormField.hpp>
84 #include <com/sun/star/text/XTextSection.hpp>
85 #include <com/sun/star/text/SectionFileLink.hpp>
86 #include <com/sun/star/drawing/XShape.hpp>
87 #include <com/sun/star/text/XTextShapesSupplier.hpp>
89 #include <com/sun/star/style/XAutoStylesSupplier.hpp>
90 #include <com/sun/star/style/XAutoStyleFamily.hpp>
91 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
92 #include <com/sun/star/text/XFootnotesSupplier.hpp>
93 #include <com/sun/star/text/XEndnotesSupplier.hpp>
94 #include <com/sun/star/drawing/XControlShape.hpp>
95 #include <com/sun/star/util/DateTime.hpp>
96 #include "xmlkywd.hxx"
97 #include "xmlnmspe.hxx"
98 #include <xmloff/xmlaustp.hxx>
99 #include <xmloff/families.hxx>
100 #include "txtexppr.hxx"
101 #include <xmloff/xmlnumfe.hxx>
102 #include <xmloff/xmlnume.hxx>
103 #include <xmloff/xmluconv.hxx>
104 #include "XMLAnchorTypePropHdl.hxx"
105 #include "xexptran.hxx"
106 #include <xmloff/ProgressBarHelper.hxx>
107 #include <xmloff/nmspmap.hxx>
108 #include <xmloff/xmlexp.hxx>
109 #include "txtflde.hxx"
110 #include <xmloff/txtprmap.hxx>
111 #include "XMLImageMapExport.hxx"
112 #include "XMLTextNumRuleInfo.hxx"
113 #include "XMLTextListAutoStylePool.hxx"
114 #include <xmloff/txtparae.hxx>
115 #include "XMLSectionExport.hxx"
116 #include "XMLIndexMarkExport.hxx"
117 #include <xmloff/XMLEventExport.hxx>
118 #include "XMLRedlineExport.hxx"
119 #include "MultiPropertySetHelper.hxx"
120 #include <xmloff/formlayerexport.hxx>
121 #include "XMLTextCharStyleNamesElementExport.hxx"
123 // --> OD 2008-04-25 #refactorlists#
124 #include <txtlists.hxx>
126 #include <com/sun/star/rdf/XMetadatable.hpp>
128 using ::rtl::OUString
;
129 using ::rtl::OUStringBuffer
;
131 using namespace ::std
;
132 using namespace ::com::sun::star
;
133 using namespace ::com::sun::star::uno
;
134 using namespace ::com::sun::star::lang
;
135 using namespace ::com::sun::star::beans
;
136 using namespace ::com::sun::star::container
;
137 using namespace ::com::sun::star::text
;
138 using namespace ::com::sun::star::style
;
139 using namespace ::com::sun::star::util
;
140 using namespace ::com::sun::star::drawing
;
141 using namespace ::com::sun::star::document
;
142 using namespace ::com::sun::star::frame
;
143 using namespace ::xmloff
;
144 using namespace ::xmloff::token
;
151 typedef Reference
<XTextContent
> text_content_ref_t
;
152 typedef list
<text_content_ref_t
> contents_t
;
153 typedef back_insert_iterator
<contents_t
> inserter_t
;
154 typedef contents_t::const_iterator const_iterator_t
;
156 inserter_t
getInserter()
157 { return back_insert_iterator
<contents_t
>(m_vTextContents
); };
158 const_iterator_t
getBegin() const
159 { return m_vTextContents
.begin(); };
160 const_iterator_t
getEnd() const
161 { return m_vTextContents
.end(); };
164 contents_t m_vTextContents
;
168 : public unary_function
<Reference
<XTextFrame
>, size_t>
170 size_t operator()(const Reference
<XTextFrame
> xFrame
) const
171 { return sal::static_int_cast
<size_t>(reinterpret_cast<sal_uIntPtr
>(xFrame
.get())); }
174 static bool lcl_TextContentsUnfiltered(const Reference
<XTextContent
>&)
177 static bool lcl_ShapeFilter(const Reference
<XTextContent
>& xTxtContent
)
179 static const OUString sTextFrameService
= OUString::createFromAscii("com.sun.star.text.TextFrame");
180 static const OUString sTextGraphicService
= OUString::createFromAscii("com.sun.star.text.TextGraphicObject");
181 static const OUString sTextEmbeddedService
= OUString::createFromAscii("com.sun.star.text.TextEmbeddedObject");
182 Reference
<XShape
> xShape(xTxtContent
, UNO_QUERY
);
185 Reference
<XServiceInfo
> xServiceInfo(xTxtContent
, UNO_QUERY
);
186 if(xServiceInfo
->supportsService(sTextFrameService
) ||
187 xServiceInfo
->supportsService(sTextGraphicService
) ||
188 xServiceInfo
->supportsService(sTextEmbeddedService
) )
196 typedef bool (*filter_t
)(const Reference
<XTextContent
>&);
198 const Reference
<XEnumerationAccess
> xEnumAccess
,
199 const filter_t
& rFilter
)
200 : m_xEnumAccess(xEnumAccess
)
206 const TextContentSet
* GetPageBoundContents() const
207 { return &m_vPageBounds
; };
208 const TextContentSet
* GetFrameBoundContents(const Reference
<XTextFrame
>& rParentFrame
) const
210 framebound_map_t::const_iterator it
= m_vFrameBoundsOf
.find(rParentFrame
);
211 if(it
== m_vFrameBoundsOf
.end())
213 return &(it
->second
);
215 Reference
<XEnumeration
> createEnumeration() const
217 if(!m_xEnumAccess
.is())
218 return Reference
<XEnumeration
>();
219 return m_xEnumAccess
->createEnumeration();
224 Reference
<XTextFrame
>,
226 FrameRefHash
> framebound_map_t
;
227 TextContentSet m_vPageBounds
;
228 framebound_map_t m_vFrameBoundsOf
;
229 const Reference
<XEnumerationAccess
> m_xEnumAccess
;
230 void Fill(const filter_t
& rFilter
);
231 static const OUString our_sAnchorType
;
232 static const OUString our_sAnchorFrame
;
234 const OUString
BoundFrames::our_sAnchorType
= OUString::createFromAscii("AnchorType");
235 const OUString
BoundFrames::our_sAnchorFrame
= OUString::createFromAscii("AnchorFrame");
244 BoundFrameSets(const Reference
<XInterface
> xModel
);
245 const BoundFrames
* GetTexts() const
246 { return m_pTexts
.get(); };
247 const BoundFrames
* GetGraphics() const
248 { return m_pGraphics
.get(); };
249 const BoundFrames
* GetEmbeddeds() const
250 { return m_pEmbeddeds
.get(); };
251 const BoundFrames
* GetShapes() const
252 { return m_pShapes
.get(); };
254 auto_ptr
<BoundFrames
> m_pTexts
;
255 auto_ptr
<BoundFrames
> m_pGraphics
;
256 auto_ptr
<BoundFrames
> m_pEmbeddeds
;
257 auto_ptr
<BoundFrames
> m_pShapes
;
261 typedef OUString
*OUStringPtr
;
262 SV_DECL_PTRARR_DEL( OUStrings_Impl
, OUStringPtr
, 20, 10 )
263 SV_IMPL_PTRARR( OUStrings_Impl
, OUStringPtr
)
265 SV_DECL_PTRARR_SORT_DEL( OUStringsSort_Impl
, OUStringPtr
, 20, 10 )
266 SV_IMPL_OP_PTRARR_SORT( OUStringsSort_Impl
, OUStringPtr
)
269 static int txtparae_bContainsIllegalCharacters
= sal_False
;
272 // The following map shows which property values are required:
274 // property auto style pass export
275 // --------------------------------------------------------
276 // ParaStyleName if style exists always
277 // ParaConditionalStyleName if style exists always
278 // NumberingRules if style exists always
279 // TextSection always always
280 // ParaChapterNumberingLevel never always
281 // NumberingIsNumber never always
283 // The conclusion is that for auto styles the first three properties
284 // should be queried using a multi property set if, and only if, an
285 // auto style needs to be exported. TextSection should be queried by
286 // an individual call to getPropertyvalue, because this seems to be
287 // less expensive than querying the first three properties if they aren't
290 // For the export pass all properties can be queried using a multi property
293 static const sal_Char
* aParagraphPropertyNamesAuto
[] =
296 "ParaConditionalStyleName",
301 enum eParagraphPropertyNamesEnumAuto
303 NUMBERING_RULES_AUTO
= 0,
304 PARA_CONDITIONAL_STYLE_NAME_AUTO
= 1,
305 PARA_STYLE_NAME_AUTO
= 2
308 static const sal_Char
* aParagraphPropertyNames
[] =
311 "NumberingStyleName", //#outline level,add by zhaojianwei
313 //"ParaChapterNumberingLevel", //#outline level,remove by zhaojianwei
314 "OutlineLevel", //<-end,add by zhaojianwei
315 "ParaConditionalStyleName",
321 enum eParagraphPropertyNamesEnum
323 NUMBERING_IS_NUMBER
= 0,
324 PARA_NUMBERING_STYLENAME
= 1, //#outline level,add by zhaojianwei
325 //PARA_CHAPTER_NUMERBING_LEVEL = 1, //#outline level,remove by zhaojianwei
326 PARA_OUTLINE_LEVEL
=2, //<-end.add by zhaojianwei
327 PARA_CONDITIONAL_STYLE_NAME
= 3,
332 void BoundFrames::Fill(const filter_t
& rFilter
)
334 if(!m_xEnumAccess
.is())
336 const Reference
< XEnumeration
> xEnum
= m_xEnumAccess
->createEnumeration();
339 while(xEnum
->hasMoreElements())
341 Reference
<XPropertySet
> xPropSet(xEnum
->nextElement(), UNO_QUERY
);
342 Reference
<XTextContent
> xTextContent(xPropSet
, UNO_QUERY
);
343 if(!xPropSet
.is() || !xTextContent
.is())
345 TextContentAnchorType eAnchor
;
346 xPropSet
->getPropertyValue(our_sAnchorType
) >>= eAnchor
;
347 if(TextContentAnchorType_AT_PAGE
!= eAnchor
&& TextContentAnchorType_AT_FRAME
!= eAnchor
)
349 if(!rFilter(xTextContent
))
352 TextContentSet::inserter_t pInserter
= m_vPageBounds
.getInserter();
353 if(TextContentAnchorType_AT_FRAME
== eAnchor
)
355 Reference
<XTextFrame
> xAnchorTxtFrame(
356 xPropSet
->getPropertyValue(our_sAnchorFrame
),
358 pInserter
= m_vFrameBoundsOf
[xAnchorTxtFrame
].getInserter();
360 *pInserter
++ = xTextContent
;
364 BoundFrameSets::BoundFrameSets(const Reference
<XInterface
> xModel
)
365 : m_pTexts(new BoundFrames())
366 , m_pGraphics(new BoundFrames())
367 , m_pEmbeddeds(new BoundFrames())
368 , m_pShapes(new BoundFrames())
370 const Reference
<XTextFramesSupplier
> xTFS(xModel
, UNO_QUERY
);
371 const Reference
<XTextGraphicObjectsSupplier
> xGOS(xModel
, UNO_QUERY
);
372 const Reference
<XTextEmbeddedObjectsSupplier
> xEOS(xModel
, UNO_QUERY
);
373 const Reference
<XDrawPageSupplier
> xDPS(xModel
, UNO_QUERY
);
375 m_pTexts
= auto_ptr
<BoundFrames
>(new BoundFrames(
376 Reference
<XEnumerationAccess
>(xTFS
->getTextFrames(), UNO_QUERY
),
377 &lcl_TextContentsUnfiltered
));
379 m_pGraphics
= auto_ptr
<BoundFrames
>(new BoundFrames(
380 Reference
<XEnumerationAccess
>(xGOS
->getGraphicObjects(), UNO_QUERY
),
381 &lcl_TextContentsUnfiltered
));
383 m_pEmbeddeds
= auto_ptr
<BoundFrames
>(new BoundFrames(
384 Reference
<XEnumerationAccess
>(xEOS
->getEmbeddedObjects(), UNO_QUERY
),
385 &lcl_TextContentsUnfiltered
));
387 m_pShapes
= auto_ptr
<BoundFrames
>(new BoundFrames(
388 Reference
<XEnumerationAccess
>(xDPS
->getDrawPage(), UNO_QUERY
),
392 void XMLTextParagraphExport::Add( sal_uInt16 nFamily
,
393 const Reference
< XPropertySet
> & rPropSet
,
394 const XMLPropertyState
** ppAddStates
, bool bDontSeek
)
396 UniReference
< SvXMLExportPropertyMapper
> xPropMapper
;
399 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
400 xPropMapper
= GetParaPropMapper();
402 case XML_STYLE_FAMILY_TEXT_TEXT
:
403 xPropMapper
= GetTextPropMapper();
405 case XML_STYLE_FAMILY_TEXT_FRAME
:
406 xPropMapper
= GetAutoFramePropMapper();
408 case XML_STYLE_FAMILY_TEXT_SECTION
:
409 xPropMapper
= GetSectionPropMapper();
411 case XML_STYLE_FAMILY_TEXT_RUBY
:
412 xPropMapper
= GetRubyPropMapper();
415 DBG_ASSERT( xPropMapper
.is(), "There is the property mapper?" );
417 vector
< XMLPropertyState
> xPropStates
=
418 xPropMapper
->Filter( rPropSet
);
422 while( *ppAddStates
)
424 xPropStates
.push_back( **ppAddStates
);
429 if( !xPropStates
.empty() )
431 Reference
< XPropertySetInfo
> xPropSetInfo(rPropSet
->getPropertySetInfo());
432 OUString sParent
, sCondParent
;
433 sal_uInt16 nIgnoreProps
= 0;
436 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
437 if( xPropSetInfo
->hasPropertyByName( sParaStyleName
) )
439 rPropSet
->getPropertyValue( sParaStyleName
) >>= sParent
;
441 if( xPropSetInfo
->hasPropertyByName( sParaConditionalStyleName
) )
443 rPropSet
->getPropertyValue( sParaConditionalStyleName
) >>= sCondParent
;
445 if( xPropSetInfo
->hasPropertyByName( sNumberingRules
) )
447 Reference
< XIndexReplace
> xNumRule(rPropSet
->getPropertyValue( sNumberingRules
), uno::UNO_QUERY
);
448 if( xNumRule
.is() && xNumRule
->getCount() )
450 Reference
< XNamed
> xNamed( xNumRule
, UNO_QUERY
);
453 sName
= xNamed
->getName();
454 sal_Bool bAdd
= !sName
.getLength();
457 Reference
< XPropertySet
> xNumPropSet( xNumRule
,
459 const OUString
sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
460 if( xNumPropSet
.is() &&
461 xNumPropSet
->getPropertySetInfo()
462 ->hasPropertyByName( sIsAutomatic
) )
464 bAdd
= *(sal_Bool
*)xNumPropSet
->getPropertyValue( sIsAutomatic
).getValue();
465 // --> OD 2007-01-12 #i73361# - check on outline style
466 const OUString
sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) );
468 xNumPropSet
->getPropertySetInfo()
469 ->hasPropertyByName( sNumberingIsOutline
) )
471 bAdd
= !(*(sal_Bool
*)xNumPropSet
->getPropertyValue( sNumberingIsOutline
).getValue());
481 pListAutoPool
->Add( xNumRule
);
485 case XML_STYLE_FAMILY_TEXT_TEXT
:
487 // Get parent and remove hyperlinks (they aren't of interest)
488 UniReference
< XMLPropertySetMapper
> xPM(xPropMapper
->getPropertySetMapper());
489 for( ::std::vector
< XMLPropertyState
>::iterator
i(xPropStates
.begin());
490 nIgnoreProps
< 2 && i
!= xPropStates
.end(); )
492 if( i
->mnIndex
== -1 )
498 switch( xPM
->GetEntryContextId(i
->mnIndex
) )
500 case CTF_CHAR_STYLE_NAME
:
501 case CTF_HYPERLINK_URL
:
504 i
= xPropStates
.erase( i
);
513 case XML_STYLE_FAMILY_TEXT_FRAME
:
514 if( xPropSetInfo
->hasPropertyByName( sFrameStyleName
) )
516 rPropSet
->getPropertyValue( sFrameStyleName
) >>= sParent
;
519 case XML_STYLE_FAMILY_TEXT_SECTION
:
520 case XML_STYLE_FAMILY_TEXT_RUBY
:
521 ; // section styles have no parents
524 if( (xPropStates
.size() - nIgnoreProps
) > 0 )
526 GetAutoStylePool().Add( nFamily
, sParent
, xPropStates
, bDontSeek
);
527 if( sCondParent
.getLength() && sParent
!= sCondParent
)
528 GetAutoStylePool().Add( nFamily
, sCondParent
, xPropStates
);
533 bool lcl_validPropState( const XMLPropertyState
& rState
)
535 return rState
.mnIndex
!= -1;
538 void XMLTextParagraphExport::Add( sal_uInt16 nFamily
,
539 MultiPropertySetHelper
& rPropSetHelper
,
540 const Reference
< XPropertySet
> & rPropSet
,
541 const XMLPropertyState
** ppAddStates
)
543 UniReference
< SvXMLExportPropertyMapper
> xPropMapper
;
546 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
547 xPropMapper
= GetParaPropMapper();
550 DBG_ASSERT( xPropMapper
.is(), "There is the property mapper?" );
552 vector
< XMLPropertyState
> xPropStates(xPropMapper
->Filter( rPropSet
));
555 while( *ppAddStates
)
557 xPropStates
.push_back( **ppAddStates
);
562 if( rPropSetHelper
.hasProperty( NUMBERING_RULES_AUTO
) )
564 Reference
< XIndexReplace
> xNumRule(rPropSetHelper
.getValue( NUMBERING_RULES_AUTO
,
565 rPropSet
, sal_True
), uno::UNO_QUERY
);
566 if( xNumRule
.is() && xNumRule
->getCount() )
568 Reference
< XNamed
> xNamed( xNumRule
, UNO_QUERY
);
571 sName
= xNamed
->getName();
572 sal_Bool bAdd
= !sName
.getLength();
575 Reference
< XPropertySet
> xNumPropSet( xNumRule
,
577 const OUString
sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
578 if( xNumPropSet
.is() &&
579 xNumPropSet
->getPropertySetInfo()
580 ->hasPropertyByName( sIsAutomatic
) )
582 bAdd
= *(sal_Bool
*)xNumPropSet
->getPropertyValue( sIsAutomatic
).getValue();
583 // --> OD 2007-01-12 #i73361# - check on outline style
584 const OUString
sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) );
586 xNumPropSet
->getPropertySetInfo()
587 ->hasPropertyByName( sNumberingIsOutline
) )
589 bAdd
= !(*(sal_Bool
*)xNumPropSet
->getPropertyValue( sNumberingIsOutline
).getValue());
599 pListAutoPool
->Add( xNumRule
);
603 if( !xPropStates
.empty() )
605 OUString sParent
, sCondParent
;
608 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
609 if( rPropSetHelper
.hasProperty( PARA_STYLE_NAME_AUTO
) )
611 rPropSetHelper
.getValue( PARA_STYLE_NAME_AUTO
, rPropSet
,
612 sal_True
) >>= sParent
;
614 if( rPropSetHelper
.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO
) )
616 rPropSetHelper
.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO
,
617 rPropSet
, sal_True
) >>= sCondParent
;
623 if( find_if( xPropStates
.begin(), xPropStates
.end(), lcl_validPropState
) != xPropStates
.end() )
625 GetAutoStylePool().Add( nFamily
, sParent
, xPropStates
);
626 if( sCondParent
.getLength() && sParent
!= sCondParent
)
627 GetAutoStylePool().Add( nFamily
, sCondParent
, xPropStates
);
632 OUString
XMLTextParagraphExport::Find(
634 const Reference
< XPropertySet
> & rPropSet
,
635 const OUString
& rParent
,
636 const XMLPropertyState
** ppAddStates
) const
638 OUString
sName( rParent
);
639 UniReference
< SvXMLExportPropertyMapper
> xPropMapper
;
642 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
643 xPropMapper
= GetParaPropMapper();
645 case XML_STYLE_FAMILY_TEXT_FRAME
:
646 xPropMapper
= GetAutoFramePropMapper();
648 case XML_STYLE_FAMILY_TEXT_SECTION
:
649 xPropMapper
= GetSectionPropMapper();
651 case XML_STYLE_FAMILY_TEXT_RUBY
:
652 xPropMapper
= GetRubyPropMapper();
655 DBG_ASSERT( xPropMapper
.is(), "There is the property mapper?" );
656 if( !xPropMapper
.is() )
658 vector
< XMLPropertyState
> xPropStates(xPropMapper
->Filter( rPropSet
));
661 while( *ppAddStates
)
663 xPropStates
.push_back( **ppAddStates
);
667 if( find_if( xPropStates
.begin(), xPropStates
.end(), lcl_validPropState
) != xPropStates
.end() )
668 sName
= GetAutoStylePool().Find( nFamily
, sName
, xPropStates
);
673 OUString
XMLTextParagraphExport::FindTextStyleAndHyperlink(
674 const Reference
< XPropertySet
> & rPropSet
,
675 sal_Bool
& rbHyperlink
,
676 sal_Bool
& rbHasCharStyle
,
677 sal_Bool
& rbHasAutoStyle
,
678 const XMLPropertyState
** ppAddStates
) const
680 UniReference
< SvXMLExportPropertyMapper
> xPropMapper(GetTextPropMapper());
681 vector
< XMLPropertyState
> xPropStates(xPropMapper
->Filter( rPropSet
));
683 // Get parent and remove hyperlinks (they aren't of interest)
685 rbHyperlink
= rbHasCharStyle
= rbHasAutoStyle
= sal_False
;
686 sal_uInt16 nIgnoreProps
= 0;
687 UniReference
< XMLPropertySetMapper
> xPM(xPropMapper
->getPropertySetMapper());
688 ::std::vector
< XMLPropertyState
>::iterator aFirstDel
= xPropStates
.end();
689 ::std::vector
< XMLPropertyState
>::iterator aSecondDel
= xPropStates
.end();
691 for( ::std::vector
< XMLPropertyState
>::iterator
692 i
= xPropStates
.begin();
693 nIgnoreProps
< 2 && i
!= xPropStates
.end();
696 if( i
->mnIndex
== -1 )
699 switch( xPM
->GetEntryContextId(i
->mnIndex
) )
701 case CTF_CHAR_STYLE_NAME
:
702 i
->maValue
>>= sName
;
704 rbHasCharStyle
= sName
.getLength() > 0;
711 case CTF_HYPERLINK_URL
:
712 rbHyperlink
= sal_True
;
724 while( *ppAddStates
)
726 xPropStates
.push_back( **ppAddStates
);
730 if( (xPropStates
.size() - nIgnoreProps
) > 0L )
732 // erase the character style, otherwise the autostyle cannot be found!
733 // erase the hyperlink, otherwise the autostyle cannot be found!
736 // If two elements of a vector have to be deleted,
737 // we should delete the second one first.
739 xPropStates
.erase( aSecondDel
);
740 xPropStates
.erase( aFirstDel
);
742 OUString sParent
; // AutoStyles should not have parents!
743 sName
= GetAutoStylePool().Find( XML_STYLE_FAMILY_TEXT_TEXT
, sParent
, xPropStates
);
744 DBG_ASSERT( sName
.getLength(), "AutoStyle could not be found" );
745 rbHasAutoStyle
= sal_True
;
751 OUString
XMLTextParagraphExport::FindTextStyle(
752 const Reference
< XPropertySet
> & rPropSet
,
753 sal_Bool
& rHasCharStyle
) const
757 return FindTextStyleAndHyperlink( rPropSet
, bDummy
, rHasCharStyle
, bDummy2
);
761 // --> OD 2008-04-25 #refactorlists#
762 // adjustments to support lists independent from list style
763 void XMLTextParagraphExport::exportListChange(
764 const XMLTextNumRuleInfo
& rPrevInfo
,
765 const XMLTextNumRuleInfo
& rNextInfo
)
767 const bool bGenerousListLevels(
768 GetExport().getExportFlags() & EXPORT_GENEROUS_LIST_LEVELS
);
771 if ( rPrevInfo
.GetLevel() > 0 )
773 bool bRootListToBeClosed
= false;
774 sal_Int16 nListLevelsToBeClosed
= 0;
775 if ( !rNextInfo
.BelongsToSameList( rPrevInfo
,
776 bGenerousListLevels
) ||
777 rNextInfo
.GetLevel() <= 0 )
779 // close complete previous list
780 bRootListToBeClosed
= true;
781 nListLevelsToBeClosed
= rPrevInfo
.GetLevel();
783 else if ( rPrevInfo
.GetLevel() > rNextInfo
.GetLevel() )
785 // close corresponding sub lists
786 DBG_ASSERT( rNextInfo
.GetLevel() > 0,
787 "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
788 nListLevelsToBeClosed
= rPrevInfo
.GetLevel() - rNextInfo
.GetLevel();
791 if ( nListLevelsToBeClosed
> 0 &&
793 pListElements
->Count() >= ( 2 * nListLevelsToBeClosed
) )
796 for( sal_uInt16 j
= 0; j
< 2; ++j
)
798 OUString
*pElem
= (*pListElements
)[pListElements
->Count()-1];
799 pListElements
->Remove( pListElements
->Count()-1 );
801 GetExport().EndElement( *pElem
, sal_True
);
806 // remove closed list from list stack
807 mpTextListsHelper
->PopListFromStack();
809 --nListLevelsToBeClosed
;
810 } while ( nListLevelsToBeClosed
> 0 );
815 if ( rNextInfo
.GetLevel() > 0 )
817 bool bRootListToBeStarted
= false;
818 sal_Int16 nListLevelsToBeOpened
= 0;
819 if ( !rPrevInfo
.BelongsToSameList( rNextInfo
,
820 bGenerousListLevels
) ||
821 rPrevInfo
.GetLevel() <= 0 )
824 bRootListToBeStarted
= true;
825 nListLevelsToBeOpened
= rNextInfo
.GetLevel();
827 else if ( rNextInfo
.GetLevel() > rPrevInfo
.GetLevel() )
829 // open corresponding sub lists
830 DBG_ASSERT( rPrevInfo
.GetLevel() > 0,
831 "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
832 nListLevelsToBeOpened
= rNextInfo
.GetLevel() - rPrevInfo
.GetLevel();
835 if ( nListLevelsToBeOpened
> 0 )
837 const bool bExportODF
=
838 ( GetExport().getExportFlags() & EXPORT_OASIS
) != 0;
839 const SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion
=
840 GetExport().getDefaultVersion();
841 const ::rtl::OUString
sListStyleName( rNextInfo
.GetNumRulesName() );
842 // Currently only the text documents support <ListId>.
843 // Thus, for other document types <sListId> is empty.
844 const ::rtl::OUString
sListId( rNextInfo
.GetListId() );
845 bool bExportListStyle( true );
846 bool bRestartNumberingAtContinuedRootList( false );
847 sal_Int16
nRestartValueForContinuedRootList( -1 );
848 // --> OD 2008-11-26 #158694#
849 bool bContinueingPreviousSubList
= !bRootListToBeStarted
&&
850 rNextInfo
.IsContinueingPreviousSubTree();
853 GetExport().CheckAttrList();
855 if ( bRootListToBeStarted
)
857 if ( !mpTextListsHelper
->IsListProcessed( sListId
) )
860 eODFDefaultVersion
>= SvtSaveOptions::ODFVER_012
&&
861 sListId
.getLength() > 0 )
863 // --> OD 2008-07-31 #i92221#
864 GetExport().AddAttribute( XML_NAMESPACE_XML
,
869 mpTextListsHelper
->KeepListAsProcessed( sListId
,
875 const ::rtl::OUString
sNewListId(
876 mpTextListsHelper
->GenerateNewListId() );
878 eODFDefaultVersion
>= SvtSaveOptions::ODFVER_012
&&
879 sListId
.getLength() > 0 )
881 // --> OD 2008-07-31 #i92221#
882 GetExport().AddAttribute( XML_NAMESPACE_XML
,
888 const ::rtl::OUString sContinueListId
=
889 mpTextListsHelper
->GetLastContinuingListId( sListId
);
890 // store that list with list id <sNewListId> is last list,
891 // which has continued list with list id <sListId>
892 mpTextListsHelper
->StoreLastContinuingList( sListId
,
894 if ( sListStyleName
==
895 mpTextListsHelper
->GetListStyleOfLastProcessedList() &&
896 // --> OD 2008-08-15 #i92811#
898 mpTextListsHelper
->GetLastProcessedListId() &&
900 !rNextInfo
.IsRestart() )
902 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
903 XML_CONTINUE_NUMBERING
,
909 eODFDefaultVersion
>= SvtSaveOptions::ODFVER_012
&&
910 sListId
.getLength() > 0 )
912 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
917 if ( rNextInfo
.IsRestart() &&
918 ( nListLevelsToBeOpened
!= 1 ||
919 !rNextInfo
.HasStartValue() ) )
921 bRestartNumberingAtContinuedRootList
= true;
922 nRestartValueForContinuedRootList
=
923 rNextInfo
.GetListLevelStartValue();
927 mpTextListsHelper
->KeepListAsProcessed( sNewListId
,
932 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
933 GetExport().EncodeStyleName( sListStyleName
) );
934 bExportListStyle
= false;
936 bRootListToBeStarted
= false;
938 else if ( bExportListStyle
&&
939 !mpTextListsHelper
->EqualsToTopListStyleOnStack( sListStyleName
) )
941 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
942 GetExport().EncodeStyleName( sListStyleName
) );
943 bExportListStyle
= false;
946 // --> OD 2008-11-26 #158694#
947 if ( bContinueingPreviousSubList
)
949 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
950 XML_CONTINUE_NUMBERING
, XML_TRUE
);
951 bContinueingPreviousSubList
= false;
955 enum XMLTokenEnum eLName
= XML_LIST
;
957 OUString
*pElem
= new OUString(
958 GetExport().GetNamespaceMap().GetQNameByKey(
960 GetXMLToken(eLName
) ) );
961 GetExport().IgnorableWhitespace();
962 GetExport().StartElement( *pElem
, sal_False
);
965 pListElements
= new OUStrings_Impl
;
966 pListElements
->Insert( pElem
, pListElements
->Count() );
968 mpTextListsHelper
->PushListOnStack( sListId
,
971 // <text:list-header> or <text:list-item>
972 GetExport().CheckAttrList();
974 // --> OD 2009-06-24 #i97309#
975 // export start value in case of <bRestartNumberingAtContinuedRootList>
976 // at correct list item
977 if ( nListLevelsToBeOpened
== 1 )
979 if ( rNextInfo
.HasStartValue() )
981 OUStringBuffer aBuffer
;
982 aBuffer
.append( (sal_Int32
)rNextInfo
.GetStartValue() );
983 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_START_VALUE
,
984 aBuffer
.makeStringAndClear() );
986 else if ( bRestartNumberingAtContinuedRootList
)
988 OUStringBuffer aBuffer
;
989 aBuffer
.append( (sal_Int32
)nRestartValueForContinuedRootList
);
990 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
992 aBuffer
.makeStringAndClear() );
993 bRestartNumberingAtContinuedRootList
= false;
998 eLName
= ( rNextInfo
.IsNumbered() || nListLevelsToBeOpened
> 1 )
1001 pElem
= new OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1003 GetXMLToken(eLName
) ) );
1004 GetExport().IgnorableWhitespace();
1005 GetExport().StartElement( *pElem
, sal_False
);
1007 pListElements
->Insert( pElem
, pListElements
->Count() );
1009 // --> OD 2008-11-26 #158694#
1010 // export of <text:number> element for last opened <text:list-item>, if requested
1011 if ( GetExport().exportTextNumberElement() &&
1012 eLName
== XML_LIST_ITEM
&& nListLevelsToBeOpened
== 1 && // last iteration --> last opened <text:list-item>
1013 rNextInfo
.ListLabelString().getLength() > 0 )
1015 const ::rtl::OUString aTextNumberElem
=
1016 OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1018 GetXMLToken(XML_NUMBER
) ) );
1019 GetExport().IgnorableWhitespace();
1020 GetExport().StartElement( aTextNumberElem
, sal_False
);
1021 GetExport().Characters( rNextInfo
.ListLabelString() );
1022 GetExport().EndElement( aTextNumberElem
, sal_True
);
1026 --nListLevelsToBeOpened
;
1027 } while ( nListLevelsToBeOpened
> 0 );
1031 if ( rNextInfo
.GetLevel() > 0 &&
1032 rNextInfo
.IsNumbered() &&
1033 rPrevInfo
.BelongsToSameList( rNextInfo
,
1034 bGenerousListLevels
) &&
1035 rPrevInfo
.GetLevel() >= rNextInfo
.GetLevel() )
1037 // close previous list-item
1038 DBG_ASSERT( pListElements
&& pListElements
->Count() >= 2,
1039 "SwXMLExport::ExportListChange: list elements missing" );
1041 OUString
*pElem
= (*pListElements
)[pListElements
->Count()-1];
1042 GetExport().EndElement( *pElem
, sal_True
);
1044 pListElements
->Remove( pListElements
->Count()-1 );
1047 if ( rNextInfo
.IsRestart() && !rNextInfo
.HasStartValue() )
1049 // start new sub list respectively list on same list level
1050 pElem
= (*pListElements
)[pListElements
->Count()-1];
1051 GetExport().EndElement( *pElem
, sal_True
);
1052 if ( rNextInfo
.GetLevel() == 1 )
1054 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
1055 GetExport().EncodeStyleName( rNextInfo
.GetNumRulesName() ) );
1057 GetExport().IgnorableWhitespace();
1058 GetExport().StartElement( *pElem
, sal_False
);
1061 // open new list-item
1062 GetExport().CheckAttrList();
1063 if( rNextInfo
.HasStartValue() )
1065 OUStringBuffer aBuffer
;
1066 aBuffer
.append( (sal_Int32
)rNextInfo
.GetStartValue() );
1067 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_START_VALUE
,
1068 aBuffer
.makeStringAndClear() );
1070 if ( ( GetExport().getExportFlags() & EXPORT_OASIS
) != 0 &&
1071 GetExport().getDefaultVersion() >= SvtSaveOptions::ODFVER_012
)
1073 const ::rtl::OUString
sListStyleName( rNextInfo
.GetNumRulesName() );
1074 if ( !mpTextListsHelper
->EqualsToTopListStyleOnStack( sListStyleName
) )
1076 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
1078 GetExport().EncodeStyleName( sListStyleName
) );
1081 pElem
= new OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1083 GetXMLToken(XML_LIST_ITEM
) ) );
1084 GetExport().IgnorableWhitespace();
1085 GetExport().StartElement( *pElem
, sal_False
);
1087 pListElements
->Insert( pElem
, pListElements
->Count() );
1089 // --> OD 2008-11-26 #158694#
1090 // export of <text:number> element for <text:list-item>, if requested
1091 if ( GetExport().exportTextNumberElement() &&
1092 rNextInfo
.ListLabelString().getLength() > 0 )
1094 const ::rtl::OUString aTextNumberElem
=
1095 OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1097 GetXMLToken(XML_NUMBER
) ) );
1098 GetExport().IgnorableWhitespace();
1099 GetExport().StartElement( aTextNumberElem
, sal_False
);
1100 GetExport().Characters( rNextInfo
.ListLabelString() );
1101 GetExport().EndElement( aTextNumberElem
, sal_True
);
1108 XMLTextParagraphExport::XMLTextParagraphExport(
1110 SvXMLAutoStylePoolP
& rASP
1112 XMLStyleExport( rExp
, OUString(), &rASP
),
1113 rAutoStylePool( rASP
),
1114 pBoundFrameSets(new BoundFrameSets(GetExport().GetModel())),
1117 // --> OD 2008-05-07 #refactorlists# - no longer needed
1118 // pExportedLists( 0 ),
1120 pListAutoPool( new XMLTextListAutoStylePool( this->GetExport() ) ),
1121 pSectionExport( NULL
),
1122 pIndexMarkExport( NULL
),
1124 pRedlineExport( NULL
),
1125 pHeadingStyles( NULL
),
1127 bProgress( sal_False
),
1128 bBlock( sal_False
),
1130 bOpenRuby( sal_False
),
1131 // --> OD 2008-04-25 #refactorlists#
1132 mpTextListsHelper( 0 ),
1133 maTextListsHelperStack(),
1136 sActualSize(RTL_CONSTASCII_USTRINGPARAM("ActualSize")),
1137 // --> OD 2009-07-22 #i73249#
1138 // sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")),
1139 sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")),
1140 sDescription(RTL_CONSTASCII_USTRINGPARAM("Description")),
1142 sAnchorCharStyleName(RTL_CONSTASCII_USTRINGPARAM("AnchorCharStyleName")),
1143 sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")),
1144 sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")),
1145 sBeginNotice(RTL_CONSTASCII_USTRINGPARAM("BeginNotice")),
1146 sBookmark(RTL_CONSTASCII_USTRINGPARAM("Bookmark")),
1147 sCategory(RTL_CONSTASCII_USTRINGPARAM("Category")),
1148 sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName")),
1149 sCharStyleName(RTL_CONSTASCII_USTRINGPARAM("CharStyleName")),
1150 sCharStyleNames(RTL_CONSTASCII_USTRINGPARAM("CharStyleNames")),
1151 sContourPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon")),
1152 sDocumentIndex(RTL_CONSTASCII_USTRINGPARAM("DocumentIndex")),
1153 sDocumentIndexMark(RTL_CONSTASCII_USTRINGPARAM("DocumentIndexMark")),
1154 sEndNotice(RTL_CONSTASCII_USTRINGPARAM("EndNotice")),
1155 sFootnote(RTL_CONSTASCII_USTRINGPARAM("Footnote")),
1156 sFootnoteCounting(RTL_CONSTASCII_USTRINGPARAM("FootnoteCounting")),
1157 sFrame(RTL_CONSTASCII_USTRINGPARAM("Frame")),
1158 sFrameHeightAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameHeightAbsolute")),
1159 sFrameHeightPercent(RTL_CONSTASCII_USTRINGPARAM("FrameHeightPercent")),
1160 sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName")),
1161 sFrameWidthAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameWidthAbsolute")),
1162 sFrameWidthPercent(RTL_CONSTASCII_USTRINGPARAM("FrameWidthPercent")),
1163 sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter")),
1164 sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")),
1165 sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")),
1166 sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")),
1167 sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")),
1168 sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")),
1169 sHyperLinkName(RTL_CONSTASCII_USTRINGPARAM("HyperLinkName")),
1170 sHyperLinkTarget(RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget")),
1171 sHyperLinkURL(RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")),
1172 sIsAutomaticContour(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour")),
1173 sIsCollapsed(RTL_CONSTASCII_USTRINGPARAM("IsCollapsed")),
1174 sIsPixelContour(RTL_CONSTASCII_USTRINGPARAM("IsPixelContour")),
1175 sIsStart(RTL_CONSTASCII_USTRINGPARAM("IsStart")),
1176 sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth")),
1177 sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight")),
1178 sNumberingRules(RTL_CONSTASCII_USTRINGPARAM("NumberingRules")),
1179 sNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType")),
1180 sPageDescName(RTL_CONSTASCII_USTRINGPARAM("PageDescName")),
1181 sPageStyleName(RTL_CONSTASCII_USTRINGPARAM("PageStyleName")),
1182 sParaChapterNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("ParaChapterNumberingLevel")),
1183 sParaConditionalStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaConditionalStyleName")),
1184 sParagraphService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Paragraph")),
1185 sParaStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaStyleName")),
1186 sPositionEndOfDoc(RTL_CONSTASCII_USTRINGPARAM("PositionEndOfDoc")),
1187 sPrefix(RTL_CONSTASCII_USTRINGPARAM("Prefix")),
1188 sRedline(RTL_CONSTASCII_USTRINGPARAM("Redline")),
1189 sReferenceId(RTL_CONSTASCII_USTRINGPARAM("ReferenceId")),
1190 sReferenceMark(RTL_CONSTASCII_USTRINGPARAM("ReferenceMark")),
1191 sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight")),
1192 sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")),
1193 sRuby(RTL_CONSTASCII_USTRINGPARAM("Ruby")),
1194 sRubyAdjust(RTL_CONSTASCII_USTRINGPARAM("RubyAdjust")),
1195 sRubyCharStyleName(RTL_CONSTASCII_USTRINGPARAM("RubyCharStyleName")),
1196 sRubyText(RTL_CONSTASCII_USTRINGPARAM("RubyText")),
1197 sServerMap(RTL_CONSTASCII_USTRINGPARAM("ServerMap")),
1198 sShapeService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape")),
1199 sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType")),
1200 sSoftPageBreak( RTL_CONSTASCII_USTRINGPARAM( "SoftPageBreak" ) ),
1201 sStartAt(RTL_CONSTASCII_USTRINGPARAM("StartAt")),
1202 sSuffix(RTL_CONSTASCII_USTRINGPARAM("Suffix")),
1203 sTableService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextTable")),
1204 sText(RTL_CONSTASCII_USTRINGPARAM("Text")),
1205 sTextContentService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextContent")),
1206 sTextEmbeddedService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextEmbeddedObject")),
1207 sTextEndnoteService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote")),
1208 sTextField(RTL_CONSTASCII_USTRINGPARAM("TextField")),
1209 sTextFieldService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField")),
1210 sTextFrameService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")),
1211 sTextGraphicService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextGraphicObject")),
1212 sTextPortionType(RTL_CONSTASCII_USTRINGPARAM("TextPortionType")),
1213 sTextSection(RTL_CONSTASCII_USTRINGPARAM("TextSection")),
1214 sUnvisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("UnvisitedCharStyleName")),
1215 sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient")),
1216 sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")),
1217 sVisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("VisitedCharStyleName")),
1218 sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")),
1219 sWidthType( RTL_CONSTASCII_USTRINGPARAM( "WidthType" ) ),
1220 sTextFieldStart( RTL_CONSTASCII_USTRINGPARAM( "TextFieldStart" ) ),
1221 sTextFieldEnd( RTL_CONSTASCII_USTRINGPARAM( "TextFieldEnd" ) ),
1222 sTextFieldStartEnd( RTL_CONSTASCII_USTRINGPARAM( "TextFieldStartEnd" ) ),
1223 aCharStyleNamesPropInfoCache( sCharStyleNames
)
1225 UniReference
< XMLPropertySetMapper
> xPropMapper(new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA
));
1226 xParaPropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1229 OUString
sFamily( GetXMLToken(XML_PARAGRAPH
) );
1230 OUString
aPrefix( String( 'P' ) );
1231 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, sFamily
,
1232 xParaPropMapper
, aPrefix
);
1234 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT
);
1235 xTextPropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1237 sFamily
= OUString( GetXMLToken(XML_TEXT
) );
1238 aPrefix
= OUString( String( 'T' ) );
1239 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_TEXT
, sFamily
,
1240 xTextPropMapper
, aPrefix
);
1242 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_AUTO_FRAME
);
1243 xAutoFramePropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1245 sFamily
= OUString( RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME
) );
1246 aPrefix
= OUString( RTL_CONSTASCII_USTRINGPARAM( "fr" ) );
1247 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_FRAME
, sFamily
,
1248 xAutoFramePropMapper
, aPrefix
);
1250 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION
);
1251 xSectionPropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1253 sFamily
= OUString( GetXMLToken( XML_SECTION
) );
1254 aPrefix
= OUString( RTL_CONSTASCII_USTRINGPARAM( "Sect" ) );
1255 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_SECTION
, sFamily
,
1256 xSectionPropMapper
, aPrefix
);
1258 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY
);
1259 xRubyPropMapper
= new SvXMLExportPropertyMapper( xPropMapper
);
1260 sFamily
= OUString( GetXMLToken( XML_RUBY
) );
1261 aPrefix
= OUString( RTL_CONSTASCII_USTRINGPARAM( "Ru" ) );
1262 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_RUBY
, sFamily
,
1263 xRubyPropMapper
, aPrefix
);
1265 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME
);
1266 xFramePropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1269 pSectionExport
= new XMLSectionExport( rExp
, *this );
1270 pIndexMarkExport
= new XMLIndexMarkExport( rExp
, *this );
1272 if( ! IsBlockMode() &&
1273 Reference
<XRedlinesSupplier
>( GetExport().GetModel(), UNO_QUERY
).is())
1274 pRedlineExport
= new XMLRedlineExport( rExp
);
1276 // The text field helper needs a pre-constructed XMLPropertyState
1277 // to export the combined characters field. We construct that
1278 // here, because we need the text property mapper to do it.
1280 // construct Any value, then find index
1281 sal_Int32 nIndex
= xTextPropMapper
->getPropertySetMapper()->FindEntryIndex(
1282 "", XML_NAMESPACE_STYLE
,
1283 GetXMLToken(XML_TEXT_COMBINE
));
1284 pFieldExport
= new XMLTextFieldExport( rExp
, new XMLPropertyState( nIndex
, uno::makeAny(sal_True
) ) );
1286 // --> OD 2008-05-08 #refactorlists#
1287 PushNewTextListsHelper();
1291 XMLTextParagraphExport::~XMLTextParagraphExport()
1293 delete pHeadingStyles
;
1294 delete pRedlineExport
;
1295 delete pIndexMarkExport
;
1296 delete pSectionExport
;
1297 delete pFieldExport
;
1298 delete pListElements
;
1299 // --> OD 2008-05-07 #refactorlists# - no longer needed
1300 // delete pExportedLists;
1302 delete pListAutoPool
;
1304 txtparae_bContainsIllegalCharacters
= sal_False
;
1306 // --> OD 2008-04-25 #refactorlists#
1307 // also deletes <mpTextListsHelper>
1308 PopTextListsHelper();
1309 DBG_ASSERT( maTextListsHelperStack
.size() == 0,
1310 "misusage of text lists helper stack - it is not empty. Serious defect - please inform OD" );
1314 SvXMLExportPropertyMapper
*XMLTextParagraphExport::CreateShapeExtPropMapper(
1315 SvXMLExport
& rExport
)
1317 UniReference
< XMLPropertySetMapper
> xPropMapper
=
1318 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE
);
1319 return new XMLTextExportPropertySetMapper( xPropMapper
, rExport
);
1322 SvXMLExportPropertyMapper
*XMLTextParagraphExport::CreateCharExtPropMapper(
1323 SvXMLExport
& rExport
)
1325 XMLPropertySetMapper
*pPropMapper
=
1326 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT
);
1327 return new XMLTextExportPropertySetMapper( pPropMapper
, rExport
);
1330 SvXMLExportPropertyMapper
*XMLTextParagraphExport::CreateParaExtPropMapper(
1331 SvXMLExport
& rExport
)
1333 XMLPropertySetMapper
*pPropMapper
=
1334 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA
);
1335 return new XMLTextExportPropertySetMapper( pPropMapper
, rExport
);
1338 SvXMLExportPropertyMapper
*XMLTextParagraphExport::CreateParaDefaultExtPropMapper(
1339 SvXMLExport
& rExport
)
1341 XMLPropertySetMapper
*pPropMapper
=
1342 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT_ADDITIONAL_DEFAULTS
);
1343 return new XMLTextExportPropertySetMapper( pPropMapper
, rExport
);
1346 void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles
,
1347 sal_Bool bIsProgress
)
1349 const TextContentSet
* const pTexts
= pBoundFrameSets
->GetTexts()->GetPageBoundContents();
1350 const TextContentSet
* const pGraphics
= pBoundFrameSets
->GetGraphics()->GetPageBoundContents();
1351 const TextContentSet
* const pEmbeddeds
= pBoundFrameSets
->GetEmbeddeds()->GetPageBoundContents();
1352 const TextContentSet
* const pShapes
= pBoundFrameSets
->GetShapes()->GetPageBoundContents();
1353 for(TextContentSet::const_iterator_t it
= pTexts
->getBegin();
1354 it
!= pTexts
->getEnd();
1356 exportTextFrame(*it
, bAutoStyles
, bIsProgress
, sal_True
);
1357 for(TextContentSet::const_iterator_t it
= pGraphics
->getBegin();
1358 it
!= pGraphics
->getEnd();
1360 exportTextGraphic(*it
, bAutoStyles
);
1361 for(TextContentSet::const_iterator_t it
= pEmbeddeds
->getBegin();
1362 it
!= pEmbeddeds
->getEnd();
1364 exportTextEmbedded(*it
, bAutoStyles
);
1365 for(TextContentSet::const_iterator_t it
= pShapes
->getBegin();
1366 it
!= pShapes
->getEnd();
1368 exportShape(*it
, bAutoStyles
);
1371 void XMLTextParagraphExport::exportFrameFrames(
1372 sal_Bool bAutoStyles
,
1373 sal_Bool bIsProgress
,
1374 const Reference
< XTextFrame
> *pParentTxtFrame
)
1376 const TextContentSet
* const pTexts
= pBoundFrameSets
->GetTexts()->GetFrameBoundContents(*pParentTxtFrame
);
1378 for(TextContentSet::const_iterator_t it
= pTexts
->getBegin();
1379 it
!= pTexts
->getEnd();
1381 exportTextFrame(*it
, bAutoStyles
, bIsProgress
, sal_True
);
1382 const TextContentSet
* const pGraphics
= pBoundFrameSets
->GetGraphics()->GetFrameBoundContents(*pParentTxtFrame
);
1384 for(TextContentSet::const_iterator_t it
= pGraphics
->getBegin();
1385 it
!= pGraphics
->getEnd();
1387 exportTextGraphic(*it
, bAutoStyles
);
1388 const TextContentSet
* const pEmbeddeds
= pBoundFrameSets
->GetEmbeddeds()->GetFrameBoundContents(*pParentTxtFrame
);
1390 for(TextContentSet::const_iterator_t it
= pEmbeddeds
->getBegin();
1391 it
!= pEmbeddeds
->getEnd();
1393 exportTextEmbedded(*it
, bAutoStyles
);
1394 const TextContentSet
* const pShapes
= pBoundFrameSets
->GetShapes()->GetFrameBoundContents(*pParentTxtFrame
);
1396 for(TextContentSet::const_iterator_t it
= pShapes
->getBegin();
1397 it
!= pShapes
->getEnd();
1399 exportShape(*it
, bAutoStyles
);
1402 // bookmarks, reference marks (and TOC marks) are the same except for the
1403 // element names. We use the same method for export and it an array with
1404 // the proper element names
1405 static const enum XMLTokenEnum lcl_XmlReferenceElements
[] = {
1406 XML_REFERENCE_MARK
, XML_REFERENCE_MARK_START
, XML_REFERENCE_MARK_END
};
1407 static const enum XMLTokenEnum lcl_XmlBookmarkElements
[] = {
1408 XML_BOOKMARK
, XML_BOOKMARK_START
, XML_BOOKMARK_END
};
1410 // This function replaces the text portion iteration during auto style
1412 bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgress
)
1414 GetExport().GetShapeExport(); // make sure the graphics styles family is added
1416 const sal_Bool bAutoStyles
= sal_True
;
1417 const sal_Bool bExportContent
= sal_False
;
1419 // Export AutoStyles:
1420 Reference
< XAutoStylesSupplier
> xAutoStylesSupp( GetExport().GetModel(), UNO_QUERY
);
1421 if ( xAutoStylesSupp
.is() )
1423 Reference
< XAutoStyles
> xAutoStyleFamilies
= xAutoStylesSupp
->getAutoStyles();
1427 for ( int i
= 0; i
< 3; ++i
)
1431 sName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "CharacterStyles" ) );
1432 nFamily
= XML_STYLE_FAMILY_TEXT_TEXT
;
1436 sName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "RubyStyles" ) );
1437 nFamily
= XML_STYLE_FAMILY_TEXT_RUBY
;
1441 sName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) );
1442 nFamily
= XML_STYLE_FAMILY_TEXT_PARAGRAPH
;
1445 Any aAny
= xAutoStyleFamilies
->getByName( sName
);
1446 Reference
< XAutoStyleFamily
> xAutoStyles
= *(Reference
<XAutoStyleFamily
>*)aAny
.getValue();
1447 Reference
< XEnumeration
> xAutoStylesEnum( xAutoStyles
->createEnumeration() );
1449 while ( xAutoStylesEnum
->hasMoreElements() )
1451 aAny
= xAutoStylesEnum
->nextElement();
1452 Reference
< XAutoStyle
> xAutoStyle
= *(Reference
<XAutoStyle
>*)aAny
.getValue();
1453 Reference
< XPropertySet
> xPSet( xAutoStyle
, uno::UNO_QUERY
);
1454 Add( nFamily
, xPSet
, 0, true );
1459 // Export Field AutoStyles:
1460 Reference
< XTextFieldsSupplier
> xTextFieldsSupp( GetExport().GetModel(), UNO_QUERY
);
1461 if ( xTextFieldsSupp
.is() )
1463 Reference
< XEnumerationAccess
> xTextFields
= xTextFieldsSupp
->getTextFields();
1464 Reference
< XEnumeration
> xTextFieldsEnum( xTextFields
->createEnumeration() );
1466 while ( xTextFieldsEnum
->hasMoreElements() )
1468 Any aAny
= xTextFieldsEnum
->nextElement();
1469 Reference
< XTextField
> xTextField
= *(Reference
<XTextField
>*)aAny
.getValue();
1470 exportTextField( xTextField
, bAutoStyles
, bIsProgress
,
1471 !xAutoStylesSupp
.is() );
1474 Reference
< XPropertySet
> xSet( xTextField
, UNO_QUERY
);
1475 Reference
< XText
> xText
;
1476 Any a
= xSet
->getPropertyValue( ::rtl::OUString::createFromAscii("TextRange") );
1480 exportText( xText
, sal_True
, bIsProgress
, bExportContent
);
1481 GetExport().GetTextParagraphExport()
1482 ->collectTextAutoStyles( xText
);
1491 // Export text frames:
1492 Reference
<XEnumeration
> xTextFramesEnum
= pBoundFrameSets
->GetTexts()->createEnumeration();
1493 if(xTextFramesEnum
.is())
1494 while(xTextFramesEnum
->hasMoreElements())
1496 Reference
<XTextContent
> xTxtCntnt(xTextFramesEnum
->nextElement(), UNO_QUERY
);
1498 exportTextFrame(xTxtCntnt
, bAutoStyles
, bIsProgress
, bExportContent
, 0);
1501 // Export graphic objects:
1502 Reference
<XEnumeration
> xGraphicsEnum
= pBoundFrameSets
->GetGraphics()->createEnumeration();
1503 if(xGraphicsEnum
.is())
1504 while(xGraphicsEnum
->hasMoreElements())
1506 Reference
<XTextContent
> xTxtCntnt(xGraphicsEnum
->nextElement(), UNO_QUERY
);
1508 exportTextGraphic(xTxtCntnt
, true, 0);
1511 // Export embedded objects:
1512 Reference
<XEnumeration
> xEmbeddedsEnum
= pBoundFrameSets
->GetEmbeddeds()->createEnumeration();
1513 if(xEmbeddedsEnum
.is())
1514 while(xEmbeddedsEnum
->hasMoreElements())
1516 Reference
<XTextContent
> xTxtCntnt(xEmbeddedsEnum
->nextElement(), UNO_QUERY
);
1518 exportTextEmbedded(xTxtCntnt
, true, 0);
1522 Reference
<XEnumeration
> xShapesEnum
= pBoundFrameSets
->GetShapes()->createEnumeration();
1523 if(xShapesEnum
.is())
1524 while(xShapesEnum
->hasMoreElements())
1526 Reference
<XTextContent
> xTxtCntnt(xShapesEnum
->nextElement(), UNO_QUERY
);
1529 Reference
<XServiceInfo
> xServiceInfo(xTxtCntnt
, UNO_QUERY
);
1530 if( xServiceInfo
->supportsService(sShapeService
))
1531 exportShape(xTxtCntnt
, true, 0);
1536 // AutoStyles for sections
1537 Reference
< XTextSectionsSupplier
> xSectionsSupp( GetExport().GetModel(), UNO_QUERY
);
1538 if ( xSectionsSupp
.is() )
1540 Reference
< XIndexAccess
> xSections( xSectionsSupp
->getTextSections(), UNO_QUERY
);
1541 if ( xSections
.is() )
1543 nCount
= xSections
->getCount();
1544 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
1546 Any aAny
= xSections
->getByIndex( i
);
1547 Reference
< XTextSection
> xSection
= *(Reference
<XTextSection
>*)aAny
.getValue();
1548 Reference
< XPropertySet
> xPSet( xSection
, uno::UNO_QUERY
);
1549 Add( XML_STYLE_FAMILY_TEXT_SECTION
, xPSet
);
1554 // AutoStyles for tables (Note: suppress autostyle collection for paragraphs in exportTable)
1555 Reference
< XTextTablesSupplier
> xTablesSupp( GetExport().GetModel(), UNO_QUERY
);
1556 if ( xTablesSupp
.is() )
1558 Reference
< XIndexAccess
> xTables( xTablesSupp
->getTextTables(), UNO_QUERY
);
1561 nCount
= xTables
->getCount();
1562 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
1564 Any aAny
= xTables
->getByIndex( i
);
1565 Reference
< XTextTable
> xTable
= *(Reference
<XTextTable
>*)aAny
.getValue();
1566 Reference
< XTextContent
> xTextContent( xTable
, uno::UNO_QUERY
);
1567 exportTable( xTextContent
, sal_True
, sal_True
);
1572 Reference
< XNumberingRulesSupplier
> xNumberingRulesSupp( GetExport().GetModel(), UNO_QUERY
);
1573 if ( xNumberingRulesSupp
.is() )
1575 Reference
< XIndexAccess
> xNumberingRules
= xNumberingRulesSupp
->getNumberingRules();
1576 nCount
= xNumberingRules
->getCount();
1577 // --> OD 2007-01-12 #i73361#
1578 const OUString
sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) );
1580 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
1582 Reference
< XIndexReplace
> xNumRule( xNumberingRules
->getByIndex( i
), UNO_QUERY
);
1583 if( xNumRule
.is() && xNumRule
->getCount() )
1585 Reference
< XNamed
> xNamed( xNumRule
, UNO_QUERY
);
1588 sName
= xNamed
->getName();
1589 sal_Bool bAdd
= !sName
.getLength();
1592 Reference
< XPropertySet
> xNumPropSet( xNumRule
,
1594 const OUString
sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
1595 if( xNumPropSet
.is() &&
1596 xNumPropSet
->getPropertySetInfo()
1597 ->hasPropertyByName( sIsAutomatic
) )
1599 bAdd
= *(sal_Bool
*)xNumPropSet
->getPropertyValue( sIsAutomatic
).getValue();
1600 // --> OD 2007-01-12 #i73361# - check on outline style
1602 xNumPropSet
->getPropertySetInfo()
1603 ->hasPropertyByName( sNumberingIsOutline
) )
1605 bAdd
= !(*(sal_Bool
*)xNumPropSet
->getPropertyValue( sNumberingIsOutline
).getValue());
1615 pListAutoPool
->Add( xNumRule
);
1623 void XMLTextParagraphExport::exportText(
1624 const Reference
< XText
> & rText
,
1625 sal_Bool bAutoStyles
,
1626 sal_Bool bIsProgress
,
1627 sal_Bool bExportParagraph
)
1630 GetExport().GetShapeExport(); // make sure the graphics styles family
1632 Reference
< XEnumerationAccess
> xEA( rText
, UNO_QUERY
);
1633 Reference
< XEnumeration
> xParaEnum(xEA
->createEnumeration());
1634 Reference
< XPropertySet
> xPropertySet( rText
, UNO_QUERY
);
1635 Reference
< XTextSection
> xBaseSection
;
1637 // #97718# footnotes don't supply paragraph enumerations in some cases
1638 // This is always a bug, but at least we don't want to crash.
1639 DBG_ASSERT( xParaEnum
.is(), "We need a paragraph enumeration" );
1640 if( ! xParaEnum
.is() )
1643 sal_Bool bExportLevels
= sal_True
;
1645 if (xPropertySet
.is())
1647 Reference
< XPropertySetInfo
> xInfo ( xPropertySet
->getPropertySetInfo() );
1651 if (xInfo
->hasPropertyByName( sTextSection
))
1653 xPropertySet
->getPropertyValue(sTextSection
) >>= xBaseSection
;
1657 // for applications that use the outliner we need to check if
1658 // the current text object needs the level information exported
1661 // fixme: move string to class member, couldn't do now because
1662 // of no incompatible build
1663 OUString sHasLevels( RTL_CONSTASCII_USTRINGPARAM("HasLevels") );
1664 if (xInfo->hasPropertyByName( sHasLevels ) )
1666 xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels;
1673 // #96530# Export redlines at start & end of XText before & after
1674 // exporting the text content enumeration
1675 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1676 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_True
);
1677 exportTextContentEnumeration( xParaEnum
, bAutoStyles
, xBaseSection
,
1678 bIsProgress
, bExportParagraph
, 0, bExportLevels
);
1679 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1680 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_False
);
1683 void XMLTextParagraphExport::exportText(
1684 const Reference
< XText
> & rText
,
1685 const Reference
< XTextSection
> & rBaseSection
,
1686 sal_Bool bAutoStyles
,
1687 sal_Bool bIsProgress
,
1688 sal_Bool bExportParagraph
)
1691 GetExport().GetShapeExport(); // make sure the graphics styles family
1693 Reference
< XEnumerationAccess
> xEA( rText
, UNO_QUERY
);
1694 Reference
< XEnumeration
> xParaEnum(xEA
->createEnumeration());
1696 // #98165# don't continue without a paragraph enumeration
1697 if( ! xParaEnum
.is() )
1700 // #96530# Export redlines at start & end of XText before & after
1701 // exporting the text content enumeration
1702 Reference
<XPropertySet
> xPropertySet
;
1703 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1705 xPropertySet
.set(rText
, uno::UNO_QUERY
);
1706 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_True
);
1708 exportTextContentEnumeration( xParaEnum
, bAutoStyles
, rBaseSection
,
1709 bIsProgress
, bExportParagraph
);
1710 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1711 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_False
);
1714 sal_Bool
XMLTextParagraphExport::exportTextContentEnumeration(
1715 const Reference
< XEnumeration
> & rContEnum
,
1716 sal_Bool bAutoStyles
,
1717 const Reference
< XTextSection
> & rBaseSection
,
1718 sal_Bool bIsProgress
,
1719 sal_Bool bExportParagraph
,
1720 const Reference
< XPropertySet
> *pRangePropSet
,
1721 sal_Bool bExportLevels
)
1723 DBG_ASSERT( rContEnum
.is(), "No enumeration to export!" );
1724 sal_Bool bHasMoreElements
= rContEnum
->hasMoreElements();
1725 if( !bHasMoreElements
)
1728 XMLTextNumRuleInfo aPrevNumInfo
;
1729 XMLTextNumRuleInfo aNextNumInfo
;
1731 sal_Bool bHasContent
= sal_False
;
1732 Reference
<XTextSection
> xCurrentTextSection(rBaseSection
);
1734 MultiPropertySetHelper
aPropSetHelper(
1735 bAutoStyles
? aParagraphPropertyNamesAuto
:
1736 aParagraphPropertyNames
);
1738 sal_Bool bHoldElement
= sal_False
;
1739 Reference
< XTextContent
> xTxtCntnt
;
1740 while( bHoldElement
|| bHasMoreElements
)
1744 bHoldElement
= sal_False
;
1748 xTxtCntnt
.set(rContEnum
->nextElement(), uno::UNO_QUERY
);
1750 aPropSetHelper
.resetValues();
1754 Reference
<XServiceInfo
> xServiceInfo( xTxtCntnt
, UNO_QUERY
);
1755 if( xServiceInfo
->supportsService( sParagraphService
) )
1761 exportListAndSectionChange( xCurrentTextSection
, xTxtCntnt
,
1762 aPrevNumInfo
, aNextNumInfo
,
1767 // --> OD 2006-09-27 #i69627#
1768 // --> OD 2008-04-24 #refactorlists#
1769 // pass list auto style pool to <XMLTextNumRuleInfo> instance
1770 // --> OD 2008-11-26 #158694#
1771 // pass info about request to export <text:number> element
1772 // to <XMLTextNumRuleInfo> instance
1773 aNextNumInfo
.Set( xTxtCntnt
,
1774 GetExport().writeOutlineStyleAsNormalListStyle(),
1775 GetListAutoStylePool(),
1776 GetExport().exportTextNumberElement() );
1779 exportListAndSectionChange( xCurrentTextSection
, aPropSetHelper
,
1780 TEXT_SECTION
, xTxtCntnt
,
1781 aPrevNumInfo
, aNextNumInfo
,
1786 // if we found a mute section: skip all section content
1787 if (pSectionExport
->IsMuteSection(xCurrentTextSection
))
1789 // Make sure headings are exported anyway.
1791 pSectionExport
->ExportMasterDocHeadingDummies();
1793 while (rContEnum
->hasMoreElements() &&
1794 pSectionExport
->IsInSection( xCurrentTextSection
,
1795 xTxtCntnt
, sal_True
))
1797 xTxtCntnt
.set(rContEnum
->nextElement(), uno::UNO_QUERY
);
1798 aPropSetHelper
.resetValues();
1799 aNextNumInfo
.Reset();
1801 // the first non-mute element still needs to be processed
1803 ! pSectionExport
->IsInSection( xCurrentTextSection
,
1804 xTxtCntnt
, sal_False
);
1807 exportParagraph( xTxtCntnt
, bAutoStyles
, bIsProgress
,
1808 bExportParagraph
, aPropSetHelper
);
1809 bHasContent
= sal_True
;
1811 else if( xServiceInfo
->supportsService( sTableService
) )
1815 aNextNumInfo
.Reset();
1818 exportListAndSectionChange( xCurrentTextSection
, xTxtCntnt
,
1819 aPrevNumInfo
, aNextNumInfo
,
1822 if (! pSectionExport
->IsMuteSection(xCurrentTextSection
))
1824 // export start + end redlines (for wholly redlined tables)
1825 if ((! bAutoStyles
) && (NULL
!= pRedlineExport
))
1826 pRedlineExport
->ExportStartOrEndRedline(xTxtCntnt
, sal_True
);
1828 exportTable( xTxtCntnt
, bAutoStyles
, bIsProgress
);
1830 if ((! bAutoStyles
) && (NULL
!= pRedlineExport
))
1831 pRedlineExport
->ExportStartOrEndRedline(xTxtCntnt
, sal_False
);
1833 else if( !bAutoStyles
)
1835 // Make sure headings are exported anyway.
1836 pSectionExport
->ExportMasterDocHeadingDummies();
1839 bHasContent
= sal_True
;
1841 else if( xServiceInfo
->supportsService( sTextFrameService
) )
1843 exportTextFrame( xTxtCntnt
, bAutoStyles
, bIsProgress
, sal_True
, pRangePropSet
);
1845 else if( xServiceInfo
->supportsService( sTextGraphicService
) )
1847 exportTextGraphic( xTxtCntnt
, bAutoStyles
, pRangePropSet
);
1849 else if( xServiceInfo
->supportsService( sTextEmbeddedService
) )
1851 exportTextEmbedded( xTxtCntnt
, bAutoStyles
, pRangePropSet
);
1853 else if( xServiceInfo
->supportsService( sShapeService
) )
1855 exportShape( xTxtCntnt
, bAutoStyles
, pRangePropSet
);
1859 DBG_ASSERT( !xTxtCntnt
.is(), "unknown text content" );
1864 aPrevNumInfo
= aNextNumInfo
;
1867 bHasMoreElements
= rContEnum
->hasMoreElements();
1870 if( bExportLevels
&& bHasContent
&& !bAutoStyles
)
1872 aNextNumInfo
.Reset();
1874 // close open lists and sections; no new styles
1875 exportListAndSectionChange( xCurrentTextSection
, rBaseSection
,
1876 aPrevNumInfo
, aNextNumInfo
,
1883 void XMLTextParagraphExport::exportParagraph(
1884 const Reference
< XTextContent
> & rTextContent
,
1885 sal_Bool bAutoStyles
, sal_Bool bIsProgress
, sal_Bool bExportParagraph
,
1886 MultiPropertySetHelper
& rPropSetHelper
)
1888 sal_Int16 nOutlineLevel
= -1;
1892 ProgressBarHelper
*pProgress
= GetExport().GetProgressBarHelper();
1893 pProgress
->SetValue( pProgress
->GetValue()+1 );
1896 // get property set or multi property set and initialize helper
1897 Reference
<XMultiPropertySet
> xMultiPropSet( rTextContent
, UNO_QUERY
);
1898 Reference
<XPropertySet
> xPropSet( rTextContent
, UNO_QUERY
);
1900 // check for supported properties
1901 if( !rPropSetHelper
.checkedProperties() )
1902 rPropSetHelper
.hasProperties( xPropSet
->getPropertySetInfo() );
1904 // if( xMultiPropSet.is() )
1905 // rPropSetHelper.getValues( xMultiPropSet );
1907 // rPropSetHelper.getValues( xPropSet );
1909 if( bExportParagraph
)
1913 Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, rPropSetHelper
, xPropSet
);
1917 // xml:id for RDF metadata
1918 GetExport().AddAttributeXmlId(rTextContent
);
1919 GetExport().AddAttributesRDFa(rTextContent
);
1922 if( rPropSetHelper
.hasProperty( PARA_STYLE_NAME
) )
1924 if( xMultiPropSet
.is() )
1925 rPropSetHelper
.getValue( PARA_STYLE_NAME
,
1926 xMultiPropSet
) >>= sStyle
;
1928 rPropSetHelper
.getValue( PARA_STYLE_NAME
,
1929 xPropSet
) >>= sStyle
;
1932 Reference
< XInterface
> xRef( rTextContent
, UNO_QUERY
);
1935 const OUString
& rIdentifier
= GetExport().getInterfaceToIdentifierMapper().getIdentifier( xRef
);
1936 if( rIdentifier
.getLength() )
1937 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_ID
, rIdentifier
);
1940 OUString
sAutoStyle( sStyle
);
1941 sAutoStyle
= Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, xPropSet
, sStyle
);
1942 if( sAutoStyle
.getLength() )
1943 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
1944 GetExport().EncodeStyleName( sAutoStyle
) );
1946 if( rPropSetHelper
.hasProperty( PARA_CONDITIONAL_STYLE_NAME
) )
1948 OUString sCondStyle
;
1949 if( xMultiPropSet
.is() )
1950 rPropSetHelper
.getValue( PARA_CONDITIONAL_STYLE_NAME
,
1951 xMultiPropSet
) >>= sCondStyle
;
1953 rPropSetHelper
.getValue( PARA_CONDITIONAL_STYLE_NAME
,
1954 xPropSet
) >>= sCondStyle
;
1955 if( sCondStyle
!= sStyle
)
1957 sCondStyle
= Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, xPropSet
,
1959 if( sCondStyle
.getLength() )
1960 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
1961 XML_COND_STYLE_NAME
,
1962 GetExport().EncodeStyleName( sCondStyle
) );
1966 //if( rPropSetHelper.hasProperty( PARA_CHAPTER_NUMERBING_LEVEL ) ) //#outline level,zhaojianwei
1967 if( rPropSetHelper
.hasProperty( PARA_OUTLINE_LEVEL
) ) //<-end
1969 if( xMultiPropSet
.is() )
1970 //rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL, //#outline level,zhaojianwei
1971 rPropSetHelper
.getValue( PARA_OUTLINE_LEVEL
, //<-end
1972 xMultiPropSet
) >>= nOutlineLevel
;
1974 //rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL, //#outline level,zhaojianwei
1975 rPropSetHelper
.getValue( PARA_OUTLINE_LEVEL
, //<-end
1976 xPropSet
) >>= nOutlineLevel
;
1978 //if( -1 != nOutlineLevel ) //#outline level,zhaojianwei
1979 if( 0 < nOutlineLevel
) //<-end,zhaojianwei
1981 OUStringBuffer sTmp
;
1982 //sTmp.append( sal_Int32( nOutlineLevel + 1 ) ); //#outline level,zhaojianwei
1983 sTmp
.append( sal_Int32( nOutlineLevel
) ); //<-end,zhaojianwei
1984 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
1986 sTmp
.makeStringAndClear() );
1988 if( rPropSetHelper
.hasProperty( NUMBERING_IS_NUMBER
) )
1990 bool bIsNumber
= false;
1991 if( xMultiPropSet
.is() )
1992 rPropSetHelper
.getValue(
1993 NUMBERING_IS_NUMBER
, xMultiPropSet
) >>= bIsNumber
;
1995 rPropSetHelper
.getValue(
1996 NUMBERING_IS_NUMBER
, xPropSet
) >>= bIsNumber
;
1998 OUString sListStyleName
;
1999 if( xMultiPropSet
.is() )
2000 rPropSetHelper
.getValue(
2001 PARA_NUMBERING_STYLENAME
, xMultiPropSet
) >>= sListStyleName
;
2003 rPropSetHelper
.getValue(
2004 PARA_NUMBERING_STYLENAME
, xPropSet
) >>= sListStyleName
;
2008 bool bAssignedtoOutlineStyle
= false;//#outline level,add by zhaojianwei
2010 Reference
< XChapterNumberingSupplier
> xCNSupplier( GetExport().GetModel(), UNO_QUERY
);
2012 OUString sOutlineName
;
2013 if (xCNSupplier
.is())
2015 Reference
< XIndexReplace
> xNumRule ( xCNSupplier
->getChapterNumberingRules() );
2016 DBG_ASSERT( xNumRule
.is(), "no chapter numbering rules" );
2020 Reference
< XPropertySet
> xNumRulePropSet( xNumRule
, UNO_QUERY
);
2021 xNumRulePropSet
->getPropertyValue(
2022 OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) ) >>= sOutlineName
;
2023 bAssignedtoOutlineStyle
= ( sListStyleName
== sOutlineName
);
2027 } //<end,zhaojianwei
2029 //if( ! bIsNumber ) //#outline level,removed by zhaojianwei
2030 if( ! bIsNumber
&& bAssignedtoOutlineStyle
) //#outline level,add by zhaojianwei
2031 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
2037 String sParaIsNumberingRestart
2038 (RTL_CONSTASCII_USTRINGPARAM
2039 ("ParaIsNumberingRestart"));
2040 bool bIsRestartNumbering
= false;
2042 Reference
< XPropertySetInfo
>
2043 xPropSetInfo(xMultiPropSet
.is() ?
2044 xMultiPropSet
->getPropertySetInfo():
2045 xPropSet
->getPropertySetInfo());
2048 hasPropertyByName(sParaIsNumberingRestart
))
2050 xPropSet
->getPropertyValue(sParaIsNumberingRestart
)
2051 >>= bIsRestartNumbering
;
2054 if (bIsRestartNumbering
)
2056 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
2057 XML_RESTART_NUMBERING
,
2060 String sNumberingStartValue
2061 (RTL_CONSTASCII_USTRINGPARAM
2062 ("NumberingStartValue"));
2065 sal_Int32 nStartValue
= 0;
2068 hasPropertyByName(sNumberingStartValue
))
2070 xPropSet
->getPropertyValue(sNumberingStartValue
)
2073 OUStringBuffer sTmpStartValue
;
2075 sTmpStartValue
.append(nStartValue
);
2078 AddAttribute(XML_NAMESPACE_TEXT
,
2081 makeStringAndClear());
2090 Reference
< XEnumerationAccess
> xEA( rTextContent
, UNO_QUERY
);
2091 Reference
< XEnumeration
> xTextEnum
;
2092 xTextEnum
= xEA
->createEnumeration();
2093 const sal_Bool bHasPortions
= xTextEnum
.is();
2095 Reference
< XEnumeration
> xContentEnum
;
2096 Reference
< XContentEnumerationAccess
> xCEA( rTextContent
, UNO_QUERY
);
2098 xContentEnum
.set(xCEA
->createContentEnumeration( sTextContentService
));
2099 const sal_Bool bHasContentEnum
= xContentEnum
.is() &&
2100 xContentEnum
->hasMoreElements();
2102 Reference
< XTextSection
> xSection
;
2103 if( bHasContentEnum
)
2105 // For the auto styles, the multi property set helper is only used
2106 // if hard attributes are existing. Therfor, it seems to be a better
2107 // strategy to have the TextSection property seperate, because otherwise
2108 // we always retrieve the style names even if they are not required.
2111 if( xPropSet
->getPropertySetInfo()->hasPropertyByName( sTextSection
) )
2113 xSection
.set(xPropSet
->getPropertyValue( sTextSection
), uno::UNO_QUERY
);
2118 if( rPropSetHelper
.hasProperty( TEXT_SECTION
) )
2120 xSection
.set(rPropSetHelper
.getValue( TEXT_SECTION
), uno::UNO_QUERY
);
2127 sal_Bool bPrevCharIsSpace
= sal_True
;
2128 if( bHasContentEnum
)
2129 bPrevCharIsSpace
= !exportTextContentEnumeration(
2130 xContentEnum
, bAutoStyles
, xSection
,
2131 bIsProgress
, sal_True
, 0, sal_True
);
2133 exportTextRangeEnumeration( xTextEnum
, bAutoStyles
, bIsProgress
);
2137 sal_Bool bPrevCharIsSpace
= sal_True
;
2138 enum XMLTokenEnum eElem
=
2139 //-1 == nOutlineLevel ? XML_P : XML_H; //#outline level,zhaojianwei
2140 0 < nOutlineLevel
? XML_H
: XML_P
; //<-end,zhaojianwei
2141 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, eElem
,
2142 sal_True
, sal_False
);
2143 if( bHasContentEnum
)
2144 bPrevCharIsSpace
= !exportTextContentEnumeration(
2145 xContentEnum
, bAutoStyles
, xSection
,
2147 exportTextRangeEnumeration( xTextEnum
, bAutoStyles
, bIsProgress
,
2152 void XMLTextParagraphExport::exportTextRangeEnumeration(
2153 const Reference
< XEnumeration
> & rTextEnum
,
2154 sal_Bool bAutoStyles
, sal_Bool bIsProgress
,
2155 sal_Bool bPrvChrIsSpc
)
2157 static OUString
sMeta(RTL_CONSTASCII_USTRINGPARAM("InContentMetadata"));
2158 sal_Bool bPrevCharIsSpace
= bPrvChrIsSpc
;
2160 while( rTextEnum
->hasMoreElements() )
2162 Reference
<XPropertySet
> xPropSet(rTextEnum
->nextElement(), UNO_QUERY
);
2163 Reference
< XTextRange
> xTxtRange(xPropSet
, uno::UNO_QUERY
);
2164 Reference
<XPropertySetInfo
> xPropInfo(xPropSet
->getPropertySetInfo());
2166 if (xPropInfo
->hasPropertyByName(sTextPortionType
))
2168 rtl::OUString sType
;
2169 xPropSet
->getPropertyValue(sTextPortionType
) >>= sType
;
2171 if( sType
.equals(sText
))
2173 exportTextRange( xTxtRange
, bAutoStyles
,
2176 else if( sType
.equals(sTextField
))
2178 exportTextField( xTxtRange
, bAutoStyles
, bIsProgress
);
2179 bPrevCharIsSpace
= sal_False
;
2181 else if( sType
.equals( sFrame
) )
2183 Reference
< XEnumeration
> xContentEnum
;
2184 Reference
< XContentEnumerationAccess
> xCEA( xTxtRange
,
2187 xContentEnum
.set(xCEA
->createContentEnumeration(
2188 sTextContentService
));
2189 // frames are never in sections
2190 Reference
<XTextSection
> xSection
;
2191 if( xContentEnum
.is() )
2192 exportTextContentEnumeration( xContentEnum
,
2194 xSection
, bIsProgress
, sal_True
,
2197 bPrevCharIsSpace
= sal_False
;
2199 else if (sType
.equals(sFootnote
))
2201 exportTextFootnote(xPropSet
,
2202 xTxtRange
->getString(),
2203 bAutoStyles
, bIsProgress
);
2204 bPrevCharIsSpace
= sal_False
;
2206 else if (sType
.equals(sBookmark
))
2208 exportTextMark(xPropSet
,
2210 lcl_XmlBookmarkElements
,
2213 else if (sType
.equals(sReferenceMark
))
2215 exportTextMark(xPropSet
,
2217 lcl_XmlReferenceElements
,
2220 else if (sType
.equals(sDocumentIndexMark
))
2222 pIndexMarkExport
->ExportIndexMark(xPropSet
, bAutoStyles
);
2224 else if (sType
.equals(sRedline
))
2226 if (NULL
!= pRedlineExport
)
2227 pRedlineExport
->ExportChange(xPropSet
, bAutoStyles
);
2229 else if (sType
.equals(sRuby
))
2231 exportRuby(xPropSet
, bAutoStyles
);
2233 else if (sType
.equals(sMeta
))
2235 exportMeta(xPropSet
, bAutoStyles
, bIsProgress
);
2237 else if (sType
.equals(sTextFieldStart
))
2239 Reference
<XNamed
> xBookmark(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2240 if (xBookmark
.is()) {
2241 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, xBookmark
->getName());
2243 Reference
< ::com::sun::star::text::XFormField
> xFormField(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2244 if (xFormField
.is()) {
2245 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_TYPE
, xFormField
->getFieldType());
2247 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_START
, sal_False
);
2248 if (xFormField
.is()) {
2249 for(sal_Int16 i
=0;i
<xFormField
->getParamCount();i
++) {
2250 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_NAME
, xFormField
->getParamName(i
));
2251 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_VALUE
, xFormField
->getParamValue(i
));
2252 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
2253 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
2256 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_START
, sal_False
);
2258 else if (sType
.equals(sTextFieldEnd
))
2260 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_END
, sal_False
);
2261 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_END
, sal_False
);
2263 else if (sType
.equals(sTextFieldStartEnd
))
2265 Reference
<XNamed
> xBookmark(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2266 if (xBookmark
.is()) {
2267 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, xBookmark
->getName());
2269 Reference
< ::com::sun::star::text::XFormField
> xFormField(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2270 if (xFormField
.is()) {
2271 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_TYPE
, xFormField
->getFieldType());
2273 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK
, sal_False
);
2274 if (xFormField
.is()) {
2275 for(sal_Int16 i
=0;i
<xFormField
->getParamCount();i
++) {
2276 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_NAME
, xFormField
->getParamName(i
));
2277 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_VALUE
, xFormField
->getParamValue(i
));
2278 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
2279 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
2282 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK
, sal_False
);
2284 else if (sType
.equals(sSoftPageBreak
))
2286 exportSoftPageBreak(xPropSet
, bAutoStyles
);
2289 DBG_ERROR("unknown text portion type");
2294 Reference
<XServiceInfo
> xServiceInfo( xTxtRange
, UNO_QUERY
);
2295 if( xServiceInfo
->supportsService( sTextFieldService
) )
2297 exportTextField( xTxtRange
, bAutoStyles
, bIsProgress
);
2298 bPrevCharIsSpace
= sal_False
;
2302 // no TextPortionType property -> non-Writer app -> text
2303 exportTextRange( xTxtRange
, bAutoStyles
, bPrevCharIsSpace
);
2308 // now that there are nested enumerations for meta(-field), this may be valid!
2309 // DBG_ASSERT( !bOpenRuby, "Red Alert: Ruby still open!" );
2312 void XMLTextParagraphExport::exportTable(
2313 const Reference
< XTextContent
> &,
2314 sal_Bool
/*bAutoStyles*/, sal_Bool
/*bIsProgress*/ )
2318 void XMLTextParagraphExport::exportTextField(
2319 const Reference
< XTextRange
> & rTextRange
,
2320 sal_Bool bAutoStyles
, sal_Bool bIsProgress
)
2322 Reference
< XPropertySet
> xPropSet( rTextRange
, UNO_QUERY
);
2323 // non-Writer apps need not support Property TextField, so test first
2324 if (xPropSet
->getPropertySetInfo()->hasPropertyByName( sTextField
))
2326 Reference
< XTextField
> xTxtFld(xPropSet
->getPropertyValue( sTextField
), uno::UNO_QUERY
);
2327 DBG_ASSERT( xTxtFld
.is(), "text field missing" );
2330 exportTextField(xTxtFld
, bAutoStyles
, bIsProgress
, sal_True
);
2334 // write only characters
2335 GetExport().Characters(rTextRange
->getString());
2340 void XMLTextParagraphExport::exportTextField(
2341 const Reference
< XTextField
> & xTextField
,
2342 const sal_Bool bAutoStyles
, const sal_Bool bIsProgress
,
2343 const sal_Bool bRecursive
)
2347 pFieldExport
->ExportFieldAutoStyle( xTextField
, bIsProgress
,
2352 pFieldExport
->ExportField( xTextField
, bIsProgress
);
2356 void XMLTextParagraphExport::exportSoftPageBreak(
2357 const Reference
<XPropertySet
> & ,
2360 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2361 XML_SOFT_PAGE_BREAK
, sal_False
,
2365 void XMLTextParagraphExport::exportTextMark(
2366 const Reference
<XPropertySet
> & rPropSet
,
2367 const OUString sProperty
,
2368 const enum XMLTokenEnum pElements
[],
2369 sal_Bool bAutoStyles
)
2371 // mib said: "Hau wech!"
2373 // (Originally, I'd export a span element in case the (book|reference)mark
2374 // was formatted. This actually makes a difference in case some pervert
2375 // sets a point reference mark in the document and, say, formats it bold.
2376 // This basically meaningless formatting will now been thrown away
2377 // (aka cleaned up), since mib said: ... dvo
2382 Reference
<XNamed
> xName(rPropSet
->getPropertyValue(sProperty
), UNO_QUERY
);
2383 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
,
2386 // start, end, or point-reference?
2388 if( *(sal_Bool
*)rPropSet
->getPropertyValue(sIsCollapsed
).getValue() )
2394 nElement
= *(sal_Bool
*)rPropSet
->getPropertyValue(sIsStart
).getValue() ? 1 : 2;
2397 // bookmark, bookmark-start: xml:id and RDFa for RDF metadata
2398 if( nElement
< 2 ) {
2399 GetExport().AddAttributeXmlId(xName
);
2400 const uno::Reference
<text::XTextContent
> xTextContent(
2401 xName
, uno::UNO_QUERY_THROW
);
2402 GetExport().AddAttributesRDFa(xTextContent
);
2406 DBG_ASSERT(pElements
!= NULL
, "illegal element array");
2407 DBG_ASSERT(nElement
>= 0, "illegal element number");
2408 DBG_ASSERT(nElement
<= 2, "illegal element number");
2409 SvXMLElementExport
aElem(GetExport(),
2410 XML_NAMESPACE_TEXT
, pElements
[nElement
],
2411 sal_False
, sal_False
);
2413 // else: no styles. (see above)
2416 sal_Bool
lcl_txtpara_isBoundAsChar(
2417 const Reference
< XPropertySet
> & rPropSet
,
2418 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
2420 sal_Bool bIsBoundAsChar
= sal_False
;
2421 OUString
sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2422 if( rPropSetInfo
->hasPropertyByName( sAnchorType
) )
2424 TextContentAnchorType eAnchor
;
2425 rPropSet
->getPropertyValue( sAnchorType
) >>= eAnchor
;
2426 bIsBoundAsChar
= TextContentAnchorType_AS_CHARACTER
== eAnchor
;
2429 return bIsBoundAsChar
;
2432 sal_Int32
XMLTextParagraphExport::addTextFrameAttributes(
2433 const Reference
< XPropertySet
>& rPropSet
,
2435 OUString
*pMinHeightValue
)
2437 sal_Int32 nShapeFeatures
= SEF_DEFAULT
;
2439 // draw:name (#97662#: not for shapes, since those names will be
2440 // treated in the shape export)
2443 Reference
< XNamed
> xNamed( rPropSet
, UNO_QUERY
);
2446 OUString
sName( xNamed
->getName() );
2447 if( sName
.getLength() )
2448 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_NAME
,
2449 xNamed
->getName() );
2453 OUStringBuffer sValue
;
2456 TextContentAnchorType eAnchor
= TextContentAnchorType_AT_PARAGRAPH
;
2457 rPropSet
->getPropertyValue( sAnchorType
) >>= eAnchor
;
2459 XMLAnchorTypePropHdl aAnchorTypeHdl
;
2461 aAnchorTypeHdl
.exportXML( sTmp
, uno::makeAny(eAnchor
),
2462 GetExport().GetMM100UnitConverter() );
2463 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_ANCHOR_TYPE
, sTmp
);
2466 // text:anchor-page-number
2467 if( TextContentAnchorType_AT_PAGE
== eAnchor
)
2469 sal_Int16 nPage
= 0;
2470 rPropSet
->getPropertyValue( sAnchorPageNo
) >>= nPage
;
2471 GetExport().GetMM100UnitConverter().convertNumber( sValue
,
2473 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_ANCHOR_PAGE_NUMBER
,
2474 sValue
.makeStringAndClear() );
2479 nShapeFeatures
|= SEF_EXPORT_NO_WS
;
2482 // OD 2004-06-01 #i27691# - correction: no export of svg:x, if object
2483 // is anchored as-character.
2485 eAnchor
!= TextContentAnchorType_AS_CHARACTER
)
2488 sal_Int16 nHoriOrient
= HoriOrientation::NONE
;
2489 rPropSet
->getPropertyValue( sHoriOrient
) >>= nHoriOrient
;
2490 if( HoriOrientation::NONE
== nHoriOrient
)
2493 rPropSet
->getPropertyValue( sHoriOrientPosition
) >>= nPos
;
2494 GetExport().GetMM100UnitConverter().convertMeasure( sValue
, nPos
);
2495 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_X
,
2496 sValue
.makeStringAndClear() );
2499 else if( TextContentAnchorType_AS_CHARACTER
== eAnchor
)
2500 nShapeFeatures
= (nShapeFeatures
& ~SEF_EXPORT_X
);
2502 if( !bShape
|| TextContentAnchorType_AS_CHARACTER
== eAnchor
)
2505 sal_Int16 nVertOrient
= VertOrientation::NONE
;
2506 rPropSet
->getPropertyValue( sVertOrient
) >>= nVertOrient
;
2507 if( VertOrientation::NONE
== nVertOrient
)
2510 rPropSet
->getPropertyValue( sVertOrientPosition
) >>= nPos
;
2511 GetExport().GetMM100UnitConverter().convertMeasure( sValue
, nPos
);
2512 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_Y
,
2513 sValue
.makeStringAndClear() );
2516 nShapeFeatures
= (nShapeFeatures
& ~SEF_EXPORT_Y
);
2520 Reference
< XPropertySetInfo
> xPropSetInfo(rPropSet
->getPropertySetInfo());
2523 sal_Int16 nWidthType
= SizeType::FIX
;
2524 if( xPropSetInfo
->hasPropertyByName( sWidthType
) )
2526 rPropSet
->getPropertyValue( sWidthType
) >>= nWidthType
;
2528 if( xPropSetInfo
->hasPropertyByName( sWidth
) )
2530 sal_Int32 nWidth
= 0;
2531 // VAR size will be written as zero min-size
2532 if( SizeType::VARIABLE
!= nWidthType
)
2534 rPropSet
->getPropertyValue( sWidth
) >>= nWidth
;
2536 GetExport().GetMM100UnitConverter().convertMeasure( sValue
, nWidth
);
2537 if( SizeType::FIX
!= nWidthType
)
2538 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_MIN_WIDTH
,
2539 sValue
.makeStringAndClear() );
2541 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_WIDTH
,
2542 sValue
.makeStringAndClear() );
2544 sal_Bool bSyncWidth
= sal_False
;
2545 if( xPropSetInfo
->hasPropertyByName( sIsSyncWidthToHeight
) )
2547 bSyncWidth
= *(sal_Bool
*)rPropSet
->getPropertyValue( sIsSyncWidthToHeight
).getValue();
2549 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_WIDTH
,
2552 if( !bSyncWidth
&& xPropSetInfo
->hasPropertyByName( sRelativeWidth
) )
2554 sal_Int16 nRelWidth
= 0;
2555 rPropSet
->getPropertyValue( sRelativeWidth
) >>= nRelWidth
;
2556 DBG_ASSERT( nRelWidth
>= 0 && nRelWidth
<= 254,
2557 "Got illegal relative width from API" );
2560 GetExport().GetMM100UnitConverter().convertPercent( sValue
,
2562 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_WIDTH
,
2563 sValue
.makeStringAndClear() );
2567 // svg:height, fo:min-height or style:rel-height
2568 sal_Int16 nSizeType
= SizeType::FIX
;
2569 if( xPropSetInfo
->hasPropertyByName( sSizeType
) )
2571 rPropSet
->getPropertyValue( sSizeType
) >>= nSizeType
;
2573 sal_Bool bSyncHeight
= sal_False
;
2574 if( xPropSetInfo
->hasPropertyByName( sIsSyncHeightToWidth
) )
2576 bSyncHeight
= *(sal_Bool
*)rPropSet
->getPropertyValue( sIsSyncHeightToWidth
).getValue();
2578 sal_Int16 nRelHeight
= 0;
2579 if( !bSyncHeight
&& xPropSetInfo
->hasPropertyByName( sRelativeHeight
) )
2581 rPropSet
->getPropertyValue( sRelativeHeight
) >>= nRelHeight
;
2583 if( xPropSetInfo
->hasPropertyByName( sHeight
) )
2585 sal_Int32 nHeight
= 0;
2586 if( SizeType::VARIABLE
!= nSizeType
)
2588 rPropSet
->getPropertyValue( sHeight
) >>= nHeight
;
2590 GetExport().GetMM100UnitConverter().convertMeasure( sValue
,
2592 if( SizeType::FIX
!= nSizeType
&& 0==nRelHeight
&& !bSyncHeight
&&
2594 *pMinHeightValue
= sValue
.makeStringAndClear();
2596 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_HEIGHT
,
2597 sValue
.makeStringAndClear() );
2601 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_HEIGHT
,
2602 SizeType::MIN
== nSizeType
? XML_SCALE_MIN
: XML_SCALE
);
2605 else if( nRelHeight
> 0 )
2607 GetExport().GetMM100UnitConverter().convertPercent( sValue
,
2609 if( SizeType::MIN
== nSizeType
)
2610 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_MIN_HEIGHT
,
2611 sValue
.makeStringAndClear() );
2613 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_HEIGHT
,
2614 sValue
.makeStringAndClear() );
2617 OUString
sZOrder( RTL_CONSTASCII_USTRINGPARAM( "ZOrder" ) );
2618 if( xPropSetInfo
->hasPropertyByName( sZOrder
) )
2620 sal_Int32 nZIndex
= 0;
2621 rPropSet
->getPropertyValue( sZOrder
) >>= nZIndex
;
2624 GetExport().GetMM100UnitConverter().convertNumber( sValue
,
2626 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_ZINDEX
,
2627 sValue
.makeStringAndClear() );
2631 return nShapeFeatures
;
2634 void XMLTextParagraphExport::exportAnyTextFrame(
2635 const Reference
< XTextContent
> & rTxtCntnt
,
2637 sal_Bool bAutoStyles
,
2638 sal_Bool bIsProgress
,
2639 sal_Bool bExportContent
,
2640 const Reference
< XPropertySet
> *pRangePropSet
)
2642 Reference
< XPropertySet
> xPropSet( rTxtCntnt
, UNO_QUERY
);
2646 if( FT_EMBEDDED
== eType
)
2647 _collectTextEmbeddedAutoStyles( xPropSet
);
2648 // --> OD 2004-08-09 #i28745# - no text frame style for shapes
2649 else if ( FT_SHAPE
!= eType
)
2650 Add( XML_STYLE_FAMILY_TEXT_FRAME
, xPropSet
);
2653 if( pRangePropSet
&& lcl_txtpara_isBoundAsChar( xPropSet
,
2654 xPropSet
->getPropertySetInfo() ) )
2655 Add( XML_STYLE_FAMILY_TEXT_TEXT
, *pRangePropSet
);
2661 // frame bound frames
2662 if ( bExportContent
)
2664 Reference
< XTextFrame
> xTxtFrame( rTxtCntnt
, UNO_QUERY
);
2665 Reference
< XText
> xTxt(xTxtFrame
->getText());
2666 exportFrameFrames( sal_True
, bIsProgress
, &xTxtFrame
);
2667 exportText( xTxt
, bAutoStyles
, bIsProgress
, sal_True
);
2673 Reference
< XShape
> xShape( rTxtCntnt
, UNO_QUERY
);
2674 GetExport().GetShapeExport()->collectShapeAutoStyles( xShape
);
2683 Reference
< XPropertySetInfo
> xPropSetInfo(xPropSet
->getPropertySetInfo());
2684 Reference
< XPropertyState
> xPropState( xPropSet
, UNO_QUERY
);
2686 sal_Bool bAddCharStyles
= pRangePropSet
&&
2687 lcl_txtpara_isBoundAsChar( xPropSet
, xPropSetInfo
);
2689 sal_Bool bIsUICharStyle
;
2690 sal_Bool bHasAutoStyle
= sal_False
;
2695 if( bAddCharStyles
)
2696 sStyle
= FindTextStyleAndHyperlink( *pRangePropSet
, bDummy
, bIsUICharStyle
, bHasAutoStyle
);
2698 bIsUICharStyle
= sal_False
;
2700 XMLTextCharStyleNamesElementExport
aCharStylesExport(
2701 GetExport(), bIsUICharStyle
&&
2702 aCharStyleNamesPropInfoCache
.hasProperty(
2703 *pRangePropSet
), bHasAutoStyle
,
2704 *pRangePropSet
, sCharStyleNames
);
2706 if( sStyle
.getLength() )
2707 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
2708 GetExport().EncodeStyleName( sStyle
) );
2710 SvXMLElementExport
aElem( GetExport(), sStyle
.getLength() > 0,
2711 XML_NAMESPACE_TEXT
, XML_SPAN
, sal_False
, sal_False
);
2713 SvXMLElementExport
aElement( GetExport(),
2714 FT_SHAPE
!= eType
&&
2715 addHyperlinkAttributes( xPropSet
,
2716 xPropState
,xPropSetInfo
),
2717 XML_NAMESPACE_DRAW
, XML_A
, sal_False
, sal_False
);
2721 _exportTextFrame( xPropSet
, xPropSetInfo
, bIsProgress
);
2724 _exportTextGraphic( xPropSet
, xPropSetInfo
);
2727 _exportTextEmbedded( xPropSet
, xPropSetInfo
);
2731 Reference
< XShape
> xShape( rTxtCntnt
, UNO_QUERY
);
2732 sal_Int32 nFeatures
=
2733 addTextFrameAttributes( xPropSet
, sal_True
);
2734 GetExport().GetShapeExport()
2735 ->exportShape( xShape
, nFeatures
);
2745 void XMLTextParagraphExport::_exportTextFrame(
2746 const Reference
< XPropertySet
> & rPropSet
,
2747 const Reference
< XPropertySetInfo
> & rPropSetInfo
,
2748 sal_Bool bIsProgress
)
2750 Reference
< XTextFrame
> xTxtFrame( rPropSet
, UNO_QUERY
);
2751 Reference
< XText
> xTxt(xTxtFrame
->getText());
2754 if( rPropSetInfo
->hasPropertyByName( sFrameStyleName
) )
2756 rPropSet
->getPropertyValue( sFrameStyleName
) >>= sStyle
;
2759 OUString
sAutoStyle( sStyle
);
2760 OUString aMinHeightValue
;
2761 sAutoStyle
= Find( XML_STYLE_FAMILY_TEXT_FRAME
, rPropSet
, sStyle
);
2762 if( sAutoStyle
.getLength() )
2763 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_STYLE_NAME
,
2764 GetExport().EncodeStyleName( sAutoStyle
) );
2765 addTextFrameAttributes( rPropSet
, sal_False
, &aMinHeightValue
);
2767 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_DRAW
,
2768 XML_FRAME
, sal_False
, sal_True
);
2770 if( aMinHeightValue
.getLength() )
2771 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_MIN_HEIGHT
,
2774 // draw:chain-next-name
2775 if( rPropSetInfo
->hasPropertyByName( sChainNextName
) )
2778 if( (rPropSet
->getPropertyValue( sChainNextName
) >>= sNext
) && sNext
.getLength() > 0 )
2779 GetExport().AddAttribute( XML_NAMESPACE_DRAW
,
2780 XML_CHAIN_NEXT_NAME
,
2785 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_DRAW
,
2786 XML_TEXT_BOX
, sal_True
, sal_True
);
2788 // frame bound frames
2789 exportFramesBoundToFrame( xTxtFrame
, bIsProgress
);
2791 exportText( xTxt
, sal_False
, bIsProgress
, sal_True
);
2795 Reference
<XEventsSupplier
> xEventsSupp( xTxtFrame
, UNO_QUERY
);
2796 GetExport().GetEventExport().Export(xEventsSupp
);
2799 GetExport().GetImageMapExport().Export( rPropSet
);
2801 // --> OD 2009-07-22 #i73249#
2802 // svg:title and svg:desc
2803 exportTitleAndDescription( rPropSet
, rPropSetInfo
);
2807 void XMLTextParagraphExport::exportContour(
2808 const Reference
< XPropertySet
> & rPropSet
,
2809 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
2811 if( !rPropSetInfo
->hasPropertyByName( sContourPolyPolygon
) )
2814 PointSequenceSequence aSourcePolyPolygon
;
2815 rPropSet
->getPropertyValue( sContourPolyPolygon
) >>= aSourcePolyPolygon
;
2817 if( !aSourcePolyPolygon
.getLength() )
2820 awt::Point
aPoint( 0, 0 );
2821 awt::Size
aSize( 0, 0 );
2822 sal_Int32 nPolygons
= aSourcePolyPolygon
.getLength();
2823 const PointSequence
*pPolygons
= aSourcePolyPolygon
.getConstArray();
2824 while( nPolygons
-- )
2826 sal_Int32 nPoints
= pPolygons
->getLength();
2827 const awt::Point
*pPoints
= pPolygons
->getConstArray();
2830 if( aSize
.Width
< pPoints
->X
)
2831 aSize
.Width
= pPoints
->X
;
2832 if( aSize
.Height
< pPoints
->Y
)
2833 aSize
.Height
= pPoints
->Y
;
2839 sal_Bool bPixel
= sal_False
;
2840 if( rPropSetInfo
->hasPropertyByName( sIsPixelContour
) )
2842 bPixel
= *(sal_Bool
*)rPropSet
->getPropertyValue( sIsPixelContour
).getValue();
2846 OUStringBuffer
aStringBuffer( 10 );
2848 GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer
, aSize
.Width
);
2850 GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer
, aSize
.Width
);
2851 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_WIDTH
,
2852 aStringBuffer
.makeStringAndClear() );
2856 GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer
, aSize
.Height
);
2858 GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer
, aSize
.Height
);
2859 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_HEIGHT
,
2860 aStringBuffer
.makeStringAndClear() );
2863 SdXMLImExViewBox
aViewBox(0, 0, aSize
.Width
, aSize
.Height
);
2864 GetExport().AddAttribute(XML_NAMESPACE_SVG
, XML_VIEWBOX
,
2865 aViewBox
.GetExportString());
2867 sal_Int32
nOuterCnt( aSourcePolyPolygon
.getLength() );
2869 enum XMLTokenEnum eElem
= XML_TOKEN_INVALID
;
2870 if( 1L == nOuterCnt
)
2872 // simple polygon shape, can be written as svg:points sequence
2873 /*const*/ PointSequence
* pSequence
=
2874 (PointSequence
*)aSourcePolyPolygon
.getConstArray();
2876 SdXMLImExPointsElement
aPoints( pSequence
, aViewBox
, aPoint
, aSize
);
2878 // write point array
2879 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_POINTS
,
2880 aPoints
.GetExportString());
2881 eElem
= XML_CONTOUR_POLYGON
;
2885 // polypolygon, needs to be written as a svg:path sequence
2886 /*const*/ PointSequence
* pOuterSequence
=
2887 (PointSequence
*)aSourcePolyPolygon
.getConstArray();
2890 // prepare svx:d element export
2891 SdXMLImExSvgDElement
aSvgDElement( aViewBox
);
2893 for(sal_Int32
a(0L); a
< nOuterCnt
; a
++)
2895 /*const*/ PointSequence
* pSequence
= pOuterSequence
++;
2898 aSvgDElement
.AddPolygon(pSequence
, 0L, aPoint
,
2903 // write point array
2904 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_D
,
2905 aSvgDElement
.GetExportString());
2906 eElem
= XML_CONTOUR_PATH
;
2910 if( rPropSetInfo
->hasPropertyByName( sIsAutomaticContour
) )
2912 sal_Bool bTmp
= *(sal_Bool
*)rPropSet
->getPropertyValue(
2913 sIsAutomaticContour
).getValue();
2914 GetExport().AddAttribute( XML_NAMESPACE_DRAW
,
2915 XML_RECREATE_ON_EDIT
, bTmp
? XML_TRUE
: XML_FALSE
);
2919 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_DRAW
, eElem
,
2920 sal_True
, sal_True
);
2923 void XMLTextParagraphExport::_exportTextGraphic(
2924 const Reference
< XPropertySet
> & rPropSet
,
2925 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
2928 if( rPropSetInfo
->hasPropertyByName( sFrameStyleName
) )
2930 rPropSet
->getPropertyValue( sFrameStyleName
) >>= sStyle
;
2933 OUString
sAutoStyle( sStyle
);
2934 sAutoStyle
= Find( XML_STYLE_FAMILY_TEXT_FRAME
, rPropSet
, sStyle
);
2935 if( sAutoStyle
.getLength() )
2936 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_STYLE_NAME
,
2937 GetExport().EncodeStyleName( sAutoStyle
) );
2938 addTextFrameAttributes( rPropSet
, sal_False
);
2942 rPropSet
->getPropertyValue( sGraphicRotation
) >>= nVal
;
2945 OUStringBuffer
sRet( GetXMLToken(XML_ROTATE
).getLength()+4 );
2946 sRet
.append( GetXMLToken(XML_ROTATE
));
2947 sRet
.append( (sal_Unicode
)'(' );
2948 GetExport().GetMM100UnitConverter().convertNumber( sRet
, (sal_Int32
)nVal
);
2949 sRet
.append( (sal_Unicode
)')' );
2950 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_TRANSFORM
,
2951 sRet
.makeStringAndClear() );
2955 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_DRAW
,
2956 XML_FRAME
, sal_False
, sal_True
);
2960 rPropSet
->getPropertyValue( sGraphicURL
) >>= sOrigURL
;
2961 OUString
sURL(GetExport().AddEmbeddedGraphicObject( sOrigURL
));
2962 setTextEmbeddedGraphicURL( rPropSet
, sURL
);
2964 // If there still is no url, then then graphic is empty
2965 if( sURL
.getLength() )
2967 GetExport().AddAttribute(XML_NAMESPACE_XLINK
, XML_HREF
, sURL
);
2968 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
2969 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_SHOW
, XML_EMBED
);
2970 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_ACTUATE
,
2975 OUString sGrfFilter
;
2976 rPropSet
->getPropertyValue( sGraphicFilter
) >>= sGrfFilter
;
2977 if( sGrfFilter
.getLength() )
2978 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_FILTER_NAME
,
2982 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_DRAW
,
2983 XML_IMAGE
, sal_False
, sal_True
);
2985 // optional office:binary-data
2986 GetExport().AddEmbeddedGraphicObjectAsBase64( sOrigURL
);
2990 Reference
<XEventsSupplier
> xEventsSupp( rPropSet
, UNO_QUERY
);
2991 GetExport().GetEventExport().Export(xEventsSupp
);
2994 GetExport().GetImageMapExport().Export( rPropSet
);
2996 // --> OD 2009-07-22 #i73249#
2997 // svg:title and svg:desc
2998 exportTitleAndDescription( rPropSet
, rPropSetInfo
);
3002 exportContour( rPropSet
, rPropSetInfo
);
3005 void XMLTextParagraphExport::_collectTextEmbeddedAutoStyles(const Reference
< XPropertySet
> & )
3007 DBG_ASSERT( !this, "no API implementation avialable" );
3010 void XMLTextParagraphExport::_exportTextEmbedded(
3011 const Reference
< XPropertySet
> &,
3012 const Reference
< XPropertySetInfo
> & )
3014 DBG_ASSERT( !this, "no API implementation avialable" );
3017 void XMLTextParagraphExport::exportEvents( const Reference
< XPropertySet
> & rPropSet
)
3020 Reference
<XEventsSupplier
> xEventsSupp( rPropSet
, UNO_QUERY
);
3021 GetExport().GetEventExport().Export(xEventsSupp
);
3024 OUString
sImageMap(RTL_CONSTASCII_USTRINGPARAM("ImageMap"));
3025 if (rPropSet
->getPropertySetInfo()->hasPropertyByName(sImageMap
))
3026 GetExport().GetImageMapExport().Export( rPropSet
);
3029 // --> OD 2009-07-22 #i73249#
3030 void XMLTextParagraphExport::exportTitleAndDescription(
3031 const Reference
< XPropertySet
> & rPropSet
,
3032 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
3035 if( rPropSetInfo
->hasPropertyByName( sTitle
) )
3038 rPropSet
->getPropertyValue( sTitle
) >>= sObjTitle
;
3039 if( sObjTitle
.getLength() )
3041 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_SVG
,
3042 XML_TITLE
, sal_True
, sal_False
);
3043 GetExport().Characters( sObjTitle
);
3048 if( rPropSetInfo
->hasPropertyByName( sDescription
) )
3051 rPropSet
->getPropertyValue( sDescription
) >>= sObjDesc
;
3052 if( sObjDesc
.getLength() )
3054 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_SVG
,
3055 XML_DESC
, sal_True
, sal_False
);
3056 GetExport().Characters( sObjDesc
);
3062 void XMLTextParagraphExport::setTextEmbeddedGraphicURL(
3063 const Reference
< XPropertySet
>&,
3064 OUString
& /*rStreamName*/ ) const
3068 sal_Bool
XMLTextParagraphExport::addHyperlinkAttributes(
3069 const Reference
< XPropertySet
> & rPropSet
,
3070 const Reference
< XPropertyState
> & rPropState
,
3071 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
3073 sal_Bool bExport
= sal_False
;
3074 OUString sHRef
, sName
, sTargetFrame
, sUStyleName
, sVStyleName
;
3075 sal_Bool bServerMap
= sal_False
;
3077 /* bool bHyperLinkURL = false;
3078 bool bHyperLinkName = false;
3079 bool bHyperLinkTarget = false;
3080 bool bServer = false;
3081 bool bUnvisitedCharStyleName = false;
3082 bool bVisitedCharStyleName = false;
3084 const Reference< XMultiPropertySet > xMultiPropertySet( rPropSet, UNO_QUERY );
3085 if ( xMultiPropertySet.is() )
3087 sal_uInt32 nCount = 0;
3088 Sequence< OUString > aPropertyNames( 6 );
3089 OUString* pArray = aPropertyNames.getArray();
3091 if ( rPropSetInfo->hasPropertyByName( sServerMap ) )
3094 pArray[ nCount++ ] = sServerMap;
3096 if ( rPropSetInfo->hasPropertyByName( sHyperLinkName ) )
3098 bHyperLinkName = true;
3099 pArray[ nCount++ ] = sHyperLinkName;
3101 if ( rPropSetInfo->hasPropertyByName( sHyperLinkTarget ) )
3103 bHyperLinkTarget = true;
3104 pArray[ nCount++ ] = sHyperLinkTarget;
3106 if ( rPropSetInfo->hasPropertyByName( sHyperLinkURL ) )
3108 bHyperLinkURL = true;
3109 pArray[ nCount++ ] = sHyperLinkURL;
3111 if ( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) )
3113 bUnvisitedCharStyleName = true;
3114 pArray[ nCount++ ] = sUnvisitedCharStyleName;
3116 if ( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) )
3118 bVisitedCharStyleName = true;
3119 pArray[ nCount++ ] = sVisitedCharStyleName;
3122 aPropertyNames.realloc( nCount );
3126 Sequence< PropertyState > aPropertyStates( nCount );
3127 PropertyState* pStateArray = aPropertyStates.getArray();
3129 if ( rPropState.is() )
3130 aPropertyStates = rPropState->getPropertyStates( aPropertyNames );
3132 Sequence< Any > aPropertyValues ( xMultiPropertySet->getPropertyValues( aPropertyNames ) );
3133 Any* pValueArray = aPropertyValues.getArray();
3135 sal_uInt32 nIdx = 0;
3139 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3141 bServerMap = *(sal_Bool *)pValueArray[ nIdx ].getValue();
3147 if ( bHyperLinkName )
3149 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3151 pValueArray[ nIdx ] >>= sName;
3152 if( sName.getLength() > 0 )
3157 if ( bHyperLinkTarget )
3159 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3161 pValueArray[ nIdx ] >>= sTargetFrame;
3162 if( sTargetFrame.getLength() )
3167 if ( bHyperLinkURL )
3169 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3171 pValueArray[ nIdx ] >>= sHRef;
3172 if( sHRef.getLength() > 0 )
3177 if ( bUnvisitedCharStyleName )
3179 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3181 pValueArray[ nIdx ] >>= sUStyleName;
3182 if( sUStyleName.getLength() )
3187 if ( bVisitedCharStyleName )
3189 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3191 pValueArray[ nIdx ] >>= sVStyleName;
3192 if( sVStyleName.getLength() )
3201 if( rPropSetInfo
->hasPropertyByName( sHyperLinkURL
) &&
3202 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3203 rPropState
->getPropertyState( sHyperLinkURL
) ) )
3205 rPropSet
->getPropertyValue( sHyperLinkURL
) >>= sHRef
;
3207 if( sHRef
.getLength() > 0 )
3211 if( rPropSetInfo
->hasPropertyByName( sHyperLinkName
) &&
3212 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3213 rPropState
->getPropertyState( sHyperLinkName
) ) )
3215 rPropSet
->getPropertyValue( sHyperLinkName
) >>= sName
;
3216 if( sName
.getLength() > 0 )
3220 if( rPropSetInfo
->hasPropertyByName( sHyperLinkTarget
) &&
3221 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3222 rPropState
->getPropertyState( sHyperLinkTarget
) ) )
3224 rPropSet
->getPropertyValue( sHyperLinkTarget
) >>= sTargetFrame
;
3225 if( sTargetFrame
.getLength() )
3229 if( rPropSetInfo
->hasPropertyByName( sServerMap
) &&
3230 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3231 rPropState
->getPropertyState( sServerMap
) ) )
3233 bServerMap
= *(sal_Bool
*)rPropSet
->getPropertyValue( sServerMap
).getValue();
3238 if( rPropSetInfo
->hasPropertyByName( sUnvisitedCharStyleName
) &&
3239 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3240 rPropState
->getPropertyState( sUnvisitedCharStyleName
) ) )
3242 rPropSet
->getPropertyValue( sUnvisitedCharStyleName
) >>= sUStyleName
;
3243 if( sUStyleName
.getLength() )
3247 if( rPropSetInfo
->hasPropertyByName( sVisitedCharStyleName
) &&
3248 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3249 rPropState
->getPropertyState( sVisitedCharStyleName
) ) )
3251 rPropSet
->getPropertyValue( sVisitedCharStyleName
) >>= sVStyleName
;
3252 if( sVStyleName
.getLength() )
3258 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
3259 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, GetExport().GetRelativeReference( sHRef
) );
3261 if( sName
.getLength() > 0 )
3262 GetExport().AddAttribute( XML_NAMESPACE_OFFICE
, XML_NAME
, sName
);
3264 if( sTargetFrame
.getLength() )
3266 GetExport().AddAttribute( XML_NAMESPACE_OFFICE
,
3267 XML_TARGET_FRAME_NAME
, sTargetFrame
);
3268 enum XMLTokenEnum eTok
=
3269 sTargetFrame
.equalsAsciiL( "_blank", sizeof("_blank")-1 )
3270 ? XML_NEW
: XML_REPLACE
;
3271 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_SHOW
, eTok
);
3275 GetExport().AddAttribute( XML_NAMESPACE_OFFICE
,
3276 XML_SERVER_MAP
, XML_TRUE
);
3278 if( sUStyleName
.getLength() )
3279 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
3280 XML_STYLE_NAME
, GetExport().EncodeStyleName( sUStyleName
) );
3282 if( sVStyleName
.getLength() )
3283 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
3284 XML_VISITED_STYLE_NAME
, GetExport().EncodeStyleName( sVStyleName
) );
3290 void XMLTextParagraphExport::exportTextRange(
3291 const Reference
< XTextRange
> & rTextRange
,
3292 sal_Bool bAutoStyles
,
3293 sal_Bool
& rPrevCharIsSpace
)
3295 Reference
< XPropertySet
> xPropSet( rTextRange
, UNO_QUERY
);
3298 Add( XML_STYLE_FAMILY_TEXT_TEXT
, xPropSet
);
3302 sal_Bool bHyperlink
= sal_False
;
3303 sal_Bool bIsUICharStyle
= sal_False
;
3304 sal_Bool bHasAutoStyle
= sal_False
;
3306 OUString
sStyle(FindTextStyleAndHyperlink( xPropSet
, bHyperlink
,
3307 bIsUICharStyle
, bHasAutoStyle
));
3309 Reference
< XPropertySetInfo
> xPropSetInfo
;
3312 Reference
< XPropertyState
> xPropState( xPropSet
, UNO_QUERY
);
3313 xPropSetInfo
.set(xPropSet
->getPropertySetInfo());
3314 bHyperlink
= addHyperlinkAttributes( xPropSet
, xPropState
, xPropSetInfo
);
3316 SvXMLElementExport
aElem( GetExport(), bHyperlink
, XML_NAMESPACE_TEXT
,
3317 XML_A
, sal_False
, sal_False
);
3320 // export events (if supported)
3321 OUString
sHyperLinkEvents(RTL_CONSTASCII_USTRINGPARAM(
3322 "HyperLinkEvents"));
3323 if (xPropSetInfo
->hasPropertyByName(sHyperLinkEvents
))
3325 Reference
<XNameReplace
> xName(xPropSet
->getPropertyValue(sHyperLinkEvents
), uno::UNO_QUERY
);
3326 GetExport().GetEventExport().Export(xName
, sal_False
);
3331 XMLTextCharStyleNamesElementExport
aCharStylesExport(
3332 GetExport(), bIsUICharStyle
&&
3333 aCharStyleNamesPropInfoCache
.hasProperty(
3334 xPropSet
, xPropSetInfo
), bHasAutoStyle
,
3335 xPropSet
, sCharStyleNames
);
3337 OUString
aText(rTextRange
->getString());
3338 if( sStyle
.getLength() )
3339 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
3340 GetExport().EncodeStyleName( sStyle
) );
3342 // in a block to make sure it is destroyed before the text:a element
3343 SvXMLElementExport
aElement( GetExport(), sStyle
.getLength() > 0,
3344 XML_NAMESPACE_TEXT
, XML_SPAN
, sal_False
,
3346 exportText( aText
, rPrevCharIsSpace
);
3352 void XMLTextParagraphExport::exportText( const OUString
& rText
,
3353 sal_Bool
& rPrevCharIsSpace
)
3355 sal_Int32 nExpStartPos
= 0L;
3356 sal_Int32 nEndPos
= rText
.getLength();
3357 sal_Int32 nSpaceChars
= 0;
3358 for( sal_Int32 nPos
= 0; nPos
< nEndPos
; nPos
++ )
3360 sal_Unicode cChar
= rText
[nPos
];
3361 sal_Bool bExpCharAsText
= sal_True
;
3362 sal_Bool bExpCharAsElement
= sal_False
;
3363 sal_Bool bCurrCharIsSpace
= sal_False
;
3368 // These characters are exported as text.
3369 bExpCharAsElement
= sal_True
;
3370 bExpCharAsText
= sal_False
;
3373 break; // legal character
3374 case 0x0020: // Blank
3375 if( rPrevCharIsSpace
)
3377 // If the previous character is a space character,
3378 // too, export a special space element.
3379 bExpCharAsText
= sal_False
;
3381 bCurrCharIsSpace
= sal_True
;
3384 if( cChar
< 0x0020 )
3387 OSL_ENSURE( txtparae_bContainsIllegalCharacters
||
3389 "illegal character in text content" );
3390 txtparae_bContainsIllegalCharacters
= sal_True
;
3392 bExpCharAsText
= sal_False
;
3397 // If the current character is not exported as text
3398 // the text that has not been exported by now has to be exported now.
3399 if( nPos
> nExpStartPos
&& !bExpCharAsText
)
3401 DBG_ASSERT( 0==nSpaceChars
, "pending spaces" );
3402 OUString
sExp( rText
.copy( nExpStartPos
, nPos
- nExpStartPos
) );
3403 GetExport().Characters( sExp
);
3404 nExpStartPos
= nPos
;
3407 // If there are spaces left that have not been exported and the
3408 // current chracter is not a space , the pending spaces have to be
3410 if( nSpaceChars
> 0 && !bCurrCharIsSpace
)
3412 DBG_ASSERT( nExpStartPos
== nPos
, " pending characters" );
3414 if( nSpaceChars
> 1 )
3416 OUStringBuffer sTmp
;
3417 sTmp
.append( (sal_Int32
)nSpaceChars
);
3418 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_C
,
3419 sTmp
.makeStringAndClear() );
3422 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
3423 XML_S
, sal_False
, sal_False
);
3428 // If the current character has to be exported as a special
3429 // element, the elemnt will be exported now.
3430 if( bExpCharAsElement
)
3436 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
3443 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
3444 XML_LINE_BREAK
, sal_False
,
3451 // If the current character is a space, and the previous one
3452 // is a space, too, the number of pending spaces is incremented
3454 if( bCurrCharIsSpace
&& rPrevCharIsSpace
)
3456 rPrevCharIsSpace
= bCurrCharIsSpace
;
3458 // If the currect character is not exported as text, the start
3459 // position for text is the position behind the current position.
3460 if( !bExpCharAsText
)
3462 DBG_ASSERT( nExpStartPos
== nPos
, "wrong export start pos" );
3463 nExpStartPos
= nPos
+1;
3467 if( nExpStartPos
< nEndPos
)
3469 DBG_ASSERT( 0==nSpaceChars
, " pending spaces " );
3470 OUString
sExp( rText
.copy( nExpStartPos
, nEndPos
- nExpStartPos
) );
3471 GetExport().Characters( sExp
);
3474 // If there are some spaces left, they have to be exported now.
3475 if( nSpaceChars
> 0 )
3477 if( nSpaceChars
> 1 )
3479 OUStringBuffer sTmp
;
3480 sTmp
.append( (sal_Int32
)nSpaceChars
);
3481 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_C
,
3482 sTmp
.makeStringAndClear() );
3485 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, XML_S
,
3486 sal_False
, sal_False
);
3490 void XMLTextParagraphExport::exportTextDeclarations()
3492 pFieldExport
->ExportFieldDeclarations();
3494 // get XPropertySet from the document and ask for AutoMarkFileURL.
3495 // If it exists, export the auto-mark-file element.
3496 Reference
<XPropertySet
> xPropertySet( GetExport().GetModel(), UNO_QUERY
);
3497 if (xPropertySet
.is())
3500 OUString
sIndexAutoMarkFileURL(
3501 RTL_CONSTASCII_USTRINGPARAM("IndexAutoMarkFileURL"));
3502 if (xPropertySet
->getPropertySetInfo()->hasPropertyByName(
3503 sIndexAutoMarkFileURL
))
3505 xPropertySet
->getPropertyValue(sIndexAutoMarkFileURL
) >>= sUrl
;
3506 if (sUrl
.getLength() > 0)
3508 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
,
3509 GetExport().GetRelativeReference(sUrl
) );
3510 SvXMLElementExport
aAutoMarkElement(
3511 GetExport(), XML_NAMESPACE_TEXT
,
3512 XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE
,
3513 sal_True
, sal_True
);
3519 void XMLTextParagraphExport::exportTextDeclarations(
3520 const Reference
<XText
> & rText
)
3522 pFieldExport
->ExportFieldDeclarations(rText
);
3525 void XMLTextParagraphExport::exportUsedDeclarations( sal_Bool bOnlyUsed
)
3527 pFieldExport
->SetExportOnlyUsedFieldDeclarations( bOnlyUsed
);
3531 void XMLTextParagraphExport::exportTrackedChanges(sal_Bool bAutoStyles
)
3533 if (NULL
!= pRedlineExport
)
3534 pRedlineExport
->ExportChangesList( bAutoStyles
);
3537 void XMLTextParagraphExport::exportTrackedChanges(
3538 const Reference
<XText
> & rText
,
3539 sal_Bool bAutoStyle
)
3541 if (NULL
!= pRedlineExport
)
3542 pRedlineExport
->ExportChangesList(rText
, bAutoStyle
);
3545 void XMLTextParagraphExport::recordTrackedChangesForXText(
3546 const Reference
<XText
> & rText
)
3548 if (NULL
!= pRedlineExport
)
3549 pRedlineExport
->SetCurrentXText(rText
);
3552 void XMLTextParagraphExport::recordTrackedChangesNoXText()
3554 if (NULL
!= pRedlineExport
)
3555 pRedlineExport
->SetCurrentXText();
3559 void XMLTextParagraphExport::exportTextAutoStyles()
3561 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_PARAGRAPH
,
3562 GetExport().GetDocHandler(),
3563 GetExport().GetMM100UnitConverter(),
3564 GetExport().GetNamespaceMap() );
3566 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_TEXT
,
3567 GetExport().GetDocHandler(),
3568 GetExport().GetMM100UnitConverter(),
3569 GetExport().GetNamespaceMap() );
3571 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_FRAME
,
3572 GetExport().GetDocHandler(),
3573 GetExport().GetMM100UnitConverter(),
3574 GetExport().GetNamespaceMap() );
3576 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_SECTION
,
3577 GetExport().GetDocHandler(),
3578 GetExport().GetMM100UnitConverter(),
3579 GetExport().GetNamespaceMap() );
3581 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_RUBY
,
3582 GetExport().GetDocHandler(),
3583 GetExport().GetMM100UnitConverter(),
3584 GetExport().GetNamespaceMap() );
3586 pListAutoPool
->exportXML();
3589 void XMLTextParagraphExport::exportRuby(
3590 const Reference
<XPropertySet
> & rPropSet
,
3591 sal_Bool bAutoStyles
)
3593 // early out: a collapsed ruby makes no sense
3594 if (*(sal_Bool
*)rPropSet
->getPropertyValue(sIsCollapsed
).getValue())
3598 sal_Bool bStart
= (*(sal_Bool
*)rPropSet
->getPropertyValue(sIsStart
).getValue());
3604 Add( XML_STYLE_FAMILY_TEXT_RUBY
, rPropSet
);
3608 // prepare element names
3609 OUString
aRuby(GetXMLToken(XML_RUBY
));
3610 OUString
sTextRuby(GetExport().GetNamespaceMap().
3611 GetQNameByKey(XML_NAMESPACE_TEXT
, aRuby
));
3612 OUString
sRubyBase(GetXMLToken(XML_RUBY_BASE
));
3613 OUString
sTextRubyBase(GetExport().GetNamespaceMap().
3614 GetQNameByKey(XML_NAMESPACE_TEXT
, sRubyBase
));
3620 // we can only start a ruby if none is open
3621 DBG_ASSERT(! bOpenRuby
, "Can't open a ruby inside of ruby!");
3625 // save ruby text + ruby char style
3626 rPropSet
->getPropertyValue(sRubyText
) >>= sOpenRubyText
;
3627 rPropSet
->getPropertyValue(sRubyCharStyleName
) >>= sOpenRubyCharStyle
;
3630 GetExport().CheckAttrList();
3632 OUString
sStyleName(Find( XML_STYLE_FAMILY_TEXT_RUBY
, rPropSet
,
3634 DBG_ASSERT(sStyleName
.getLength() > 0, "I can't find the style!");
3635 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
3636 XML_STYLE_NAME
, sStyleName
);
3638 // export <text:ruby> and <text:ruby-base> start elements
3639 GetExport().StartElement( XML_NAMESPACE_TEXT
, XML_RUBY
, sal_False
);
3640 GetExport().ClearAttrList();
3641 GetExport().StartElement( XML_NAMESPACE_TEXT
, XML_RUBY_BASE
,
3643 bOpenRuby
= sal_True
;
3649 // check for an open ruby
3650 DBG_ASSERT(bOpenRuby
, "Can't close a ruby if none is open!");
3654 // close <text:ruby-base>
3655 GetExport().EndElement(XML_NAMESPACE_TEXT
, XML_RUBY_BASE
,
3658 // write the ruby text (with char style)
3660 if (sOpenRubyCharStyle
.getLength() > 0)
3661 GetExport().AddAttribute(
3662 XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
3663 GetExport().EncodeStyleName( sOpenRubyCharStyle
) );
3665 SvXMLElementExport
aRubyElement(
3666 GetExport(), XML_NAMESPACE_TEXT
, XML_RUBY_TEXT
,
3667 sal_False
, sal_False
);
3669 GetExport().Characters(sOpenRubyText
);
3672 // and finally, close the ruby
3673 GetExport().EndElement(XML_NAMESPACE_TEXT
, XML_RUBY
, sal_False
);
3674 bOpenRuby
= sal_False
;
3679 void XMLTextParagraphExport::exportMeta(
3680 const Reference
<XPropertySet
> & i_xPortion
,
3681 sal_Bool i_bAutoStyles
, sal_Bool i_isProgress
)
3683 static OUString
sMeta(RTL_CONSTASCII_USTRINGPARAM("InContentMetadata"));
3685 bool doExport(!i_bAutoStyles
); // do not export element if autostyles
3686 // check version >= 1.2
3687 switch (GetExport().getDefaultVersion()) {
3688 case SvtSaveOptions::ODFVER_011
: // fall thru
3689 case SvtSaveOptions::ODFVER_010
: doExport
= false; break;
3693 const Reference
< XTextContent
> xTextContent(
3694 i_xPortion
->getPropertyValue(sMeta
), UNO_QUERY_THROW
);
3695 const Reference
< XEnumerationAccess
> xEA( xTextContent
, UNO_QUERY_THROW
);
3696 const Reference
< XEnumeration
> xTextEnum( xEA
->createEnumeration() );
3700 const Reference
<rdf::XMetadatable
> xMeta(xTextContent
, UNO_QUERY_THROW
);
3702 // text:meta with neither xml:id nor RDFa is invalid
3703 xMeta
->ensureMetadataReference();
3705 // xml:id and RDFa for RDF metadata
3706 GetExport().AddAttributeXmlId(xMeta
);
3707 GetExport().AddAttributesRDFa(xTextContent
);
3710 SvXMLElementExport
aElem( GetExport(), doExport
,
3711 XML_NAMESPACE_TEXT
, XML_META
, sal_False
, sal_False
);
3713 // recurse to export content
3714 exportTextRangeEnumeration( xTextEnum
, i_bAutoStyles
, i_isProgress
);
3718 void XMLTextParagraphExport::PreventExportOfControlsInMuteSections(
3719 const Reference
<XIndexAccess
> & rShapes
,
3720 UniReference
<xmloff::OFormLayerXMLExport
> xFormExport
)
3722 // check parameters ad pre-conditions
3723 if( ( ! rShapes
.is() ) || ( ! xFormExport
.is() ) )
3725 // if we don't have shapes or a form export, there's nothing to do
3728 DBG_ASSERT( pSectionExport
!= NULL
, "We need the section export." );
3730 Reference
<XEnumeration
> xShapesEnum
= pBoundFrameSets
->GetShapes()->createEnumeration();
3731 if(!xShapesEnum
.is())
3733 while( xShapesEnum
->hasMoreElements() )
3735 // now we need to check
3736 // 1) if this is a control shape, and
3737 // 2) if it's in a mute section
3738 // if both answers are 'yes', notify the form layer export
3740 // we join accessing the shape and testing for control
3741 Reference
<XControlShape
> xControlShape(xShapesEnum
->nextElement(), UNO_QUERY
);
3742 if( xControlShape
.is() )
3744 // Reference<XPropertySet> xPropSet( xControlShape, UNO_QUERY );
3745 // Reference<XTextContent> xTextContent;
3746 // xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) ) ) >>= xTextContent;
3748 Reference
<XTextContent
> xTextContent( xControlShape
, UNO_QUERY
);
3749 if( xTextContent
.is() )
3751 if( pSectionExport
->IsMuteSection( xTextContent
, sal_False
) )
3753 // Ah, we've found a shape that
3754 // 1) is a control shape
3755 // 2) is anchored in a mute section
3756 // so: don't export it!
3757 xFormExport
->excludeFromExport(
3758 xControlShape
->getControl() );
3760 // else: not in mute section -> should be exported -> nothing
3763 // else: no anchor -> ignore
3765 // else: no control shape -> nothing to do
3768 sal_Int32
XMLTextParagraphExport::GetHeadingLevel( const OUString
& rStyleName
)
3770 if( !pHeadingStyles
)
3772 pHeadingStyles
= new XMLStringVector
;
3773 SvxXMLNumRuleExport::GetOutlineStyles( *pHeadingStyles
,
3774 GetExport().GetModel() );
3776 for( XMLStringVector::size_type i
=0; i
< pHeadingStyles
->size(); ++i
)
3778 if( (*pHeadingStyles
)[i
] == rStyleName
)
3779 return static_cast < sal_Int32
>( i
);
3785 // --> OD 2008-05-08 #refactorlists#
3786 void XMLTextParagraphExport::PushNewTextListsHelper()
3788 mpTextListsHelper
= new XMLTextListsHelper();
3789 maTextListsHelperStack
.push_back( mpTextListsHelper
);
3792 void XMLTextParagraphExport::PopTextListsHelper()
3794 delete mpTextListsHelper
;
3795 mpTextListsHelper
= 0;
3796 maTextListsHelperStack
.pop_back();
3797 if ( !maTextListsHelperStack
.empty() )
3799 mpTextListsHelper
= maTextListsHelperStack
.back();