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
->getAnchor(), bAutoStyles
,
1474 Reference
< XPropertySet
> xSet( xTextField
, UNO_QUERY
);
1475 Reference
< XText
> xText
;
1476 Any a
= xSet
->getPropertyValue( ::rtl::OUString::createFromAscii("TextRange") );
1479 exportText( xText
, sal_True
, bIsProgress
, bExportContent
);
1480 GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText
);
1488 // Export text frames:
1489 Reference
<XEnumeration
> xTextFramesEnum
= pBoundFrameSets
->GetTexts()->createEnumeration();
1490 if(xTextFramesEnum
.is())
1491 while(xTextFramesEnum
->hasMoreElements())
1493 Reference
<XTextContent
> xTxtCntnt(xTextFramesEnum
->nextElement(), UNO_QUERY
);
1495 exportTextFrame(xTxtCntnt
, bAutoStyles
, bIsProgress
, bExportContent
, 0);
1498 // Export graphic objects:
1499 Reference
<XEnumeration
> xGraphicsEnum
= pBoundFrameSets
->GetGraphics()->createEnumeration();
1500 if(xGraphicsEnum
.is())
1501 while(xGraphicsEnum
->hasMoreElements())
1503 Reference
<XTextContent
> xTxtCntnt(xGraphicsEnum
->nextElement(), UNO_QUERY
);
1505 exportTextGraphic(xTxtCntnt
, true, 0);
1508 // Export embedded objects:
1509 Reference
<XEnumeration
> xEmbeddedsEnum
= pBoundFrameSets
->GetEmbeddeds()->createEnumeration();
1510 if(xEmbeddedsEnum
.is())
1511 while(xEmbeddedsEnum
->hasMoreElements())
1513 Reference
<XTextContent
> xTxtCntnt(xEmbeddedsEnum
->nextElement(), UNO_QUERY
);
1515 exportTextEmbedded(xTxtCntnt
, true, 0);
1519 Reference
<XEnumeration
> xShapesEnum
= pBoundFrameSets
->GetShapes()->createEnumeration();
1520 if(xShapesEnum
.is())
1521 while(xShapesEnum
->hasMoreElements())
1523 Reference
<XTextContent
> xTxtCntnt(xShapesEnum
->nextElement(), UNO_QUERY
);
1526 Reference
<XServiceInfo
> xServiceInfo(xTxtCntnt
, UNO_QUERY
);
1527 if( xServiceInfo
->supportsService(sShapeService
))
1528 exportShape(xTxtCntnt
, true, 0);
1533 // AutoStyles for sections
1534 Reference
< XTextSectionsSupplier
> xSectionsSupp( GetExport().GetModel(), UNO_QUERY
);
1535 if ( xSectionsSupp
.is() )
1537 Reference
< XIndexAccess
> xSections( xSectionsSupp
->getTextSections(), UNO_QUERY
);
1538 if ( xSections
.is() )
1540 nCount
= xSections
->getCount();
1541 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
1543 Any aAny
= xSections
->getByIndex( i
);
1544 Reference
< XTextSection
> xSection
= *(Reference
<XTextSection
>*)aAny
.getValue();
1545 Reference
< XPropertySet
> xPSet( xSection
, uno::UNO_QUERY
);
1546 Add( XML_STYLE_FAMILY_TEXT_SECTION
, xPSet
);
1551 // AutoStyles for tables (Note: suppress autostyle collection for paragraphs in exportTable)
1552 Reference
< XTextTablesSupplier
> xTablesSupp( GetExport().GetModel(), UNO_QUERY
);
1553 if ( xTablesSupp
.is() )
1555 Reference
< XIndexAccess
> xTables( xTablesSupp
->getTextTables(), UNO_QUERY
);
1558 nCount
= xTables
->getCount();
1559 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
1561 Any aAny
= xTables
->getByIndex( i
);
1562 Reference
< XTextTable
> xTable
= *(Reference
<XTextTable
>*)aAny
.getValue();
1563 Reference
< XTextContent
> xTextContent( xTable
, uno::UNO_QUERY
);
1564 exportTable( xTextContent
, sal_True
, sal_True
);
1569 Reference
< XNumberingRulesSupplier
> xNumberingRulesSupp( GetExport().GetModel(), UNO_QUERY
);
1570 if ( xNumberingRulesSupp
.is() )
1572 Reference
< XIndexAccess
> xNumberingRules
= xNumberingRulesSupp
->getNumberingRules();
1573 nCount
= xNumberingRules
->getCount();
1574 // --> OD 2007-01-12 #i73361#
1575 const OUString
sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) );
1577 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
1579 Reference
< XIndexReplace
> xNumRule( xNumberingRules
->getByIndex( i
), UNO_QUERY
);
1580 if( xNumRule
.is() && xNumRule
->getCount() )
1582 Reference
< XNamed
> xNamed( xNumRule
, UNO_QUERY
);
1585 sName
= xNamed
->getName();
1586 sal_Bool bAdd
= !sName
.getLength();
1589 Reference
< XPropertySet
> xNumPropSet( xNumRule
,
1591 const OUString
sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
1592 if( xNumPropSet
.is() &&
1593 xNumPropSet
->getPropertySetInfo()
1594 ->hasPropertyByName( sIsAutomatic
) )
1596 bAdd
= *(sal_Bool
*)xNumPropSet
->getPropertyValue( sIsAutomatic
).getValue();
1597 // --> OD 2007-01-12 #i73361# - check on outline style
1599 xNumPropSet
->getPropertySetInfo()
1600 ->hasPropertyByName( sNumberingIsOutline
) )
1602 bAdd
= !(*(sal_Bool
*)xNumPropSet
->getPropertyValue( sNumberingIsOutline
).getValue());
1612 pListAutoPool
->Add( xNumRule
);
1620 void XMLTextParagraphExport::exportText(
1621 const Reference
< XText
> & rText
,
1622 sal_Bool bAutoStyles
,
1623 sal_Bool bIsProgress
,
1624 sal_Bool bExportParagraph
)
1627 GetExport().GetShapeExport(); // make sure the graphics styles family
1629 Reference
< XEnumerationAccess
> xEA( rText
, UNO_QUERY
);
1630 Reference
< XEnumeration
> xParaEnum(xEA
->createEnumeration());
1631 Reference
< XPropertySet
> xPropertySet( rText
, UNO_QUERY
);
1632 Reference
< XTextSection
> xBaseSection
;
1634 // #97718# footnotes don't supply paragraph enumerations in some cases
1635 // This is always a bug, but at least we don't want to crash.
1636 DBG_ASSERT( xParaEnum
.is(), "We need a paragraph enumeration" );
1637 if( ! xParaEnum
.is() )
1640 sal_Bool bExportLevels
= sal_True
;
1642 if (xPropertySet
.is())
1644 Reference
< XPropertySetInfo
> xInfo ( xPropertySet
->getPropertySetInfo() );
1648 if (xInfo
->hasPropertyByName( sTextSection
))
1650 xPropertySet
->getPropertyValue(sTextSection
) >>= xBaseSection
;
1654 // for applications that use the outliner we need to check if
1655 // the current text object needs the level information exported
1658 // fixme: move string to class member, couldn't do now because
1659 // of no incompatible build
1660 OUString sHasLevels( RTL_CONSTASCII_USTRINGPARAM("HasLevels") );
1661 if (xInfo->hasPropertyByName( sHasLevels ) )
1663 xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels;
1670 // #96530# Export redlines at start & end of XText before & after
1671 // exporting the text content enumeration
1672 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1673 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_True
);
1674 exportTextContentEnumeration( xParaEnum
, bAutoStyles
, xBaseSection
,
1675 bIsProgress
, bExportParagraph
, 0, bExportLevels
);
1676 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1677 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_False
);
1680 void XMLTextParagraphExport::exportText(
1681 const Reference
< XText
> & rText
,
1682 const Reference
< XTextSection
> & rBaseSection
,
1683 sal_Bool bAutoStyles
,
1684 sal_Bool bIsProgress
,
1685 sal_Bool bExportParagraph
)
1688 GetExport().GetShapeExport(); // make sure the graphics styles family
1690 Reference
< XEnumerationAccess
> xEA( rText
, UNO_QUERY
);
1691 Reference
< XEnumeration
> xParaEnum(xEA
->createEnumeration());
1693 // #98165# don't continue without a paragraph enumeration
1694 if( ! xParaEnum
.is() )
1697 // #96530# Export redlines at start & end of XText before & after
1698 // exporting the text content enumeration
1699 Reference
<XPropertySet
> xPropertySet
;
1700 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1702 xPropertySet
.set(rText
, uno::UNO_QUERY
);
1703 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_True
);
1705 exportTextContentEnumeration( xParaEnum
, bAutoStyles
, rBaseSection
,
1706 bIsProgress
, bExportParagraph
);
1707 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1708 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_False
);
1711 sal_Bool
XMLTextParagraphExport::exportTextContentEnumeration(
1712 const Reference
< XEnumeration
> & rContEnum
,
1713 sal_Bool bAutoStyles
,
1714 const Reference
< XTextSection
> & rBaseSection
,
1715 sal_Bool bIsProgress
,
1716 sal_Bool bExportParagraph
,
1717 const Reference
< XPropertySet
> *pRangePropSet
,
1718 sal_Bool bExportLevels
)
1720 DBG_ASSERT( rContEnum
.is(), "No enumeration to export!" );
1721 sal_Bool bHasMoreElements
= rContEnum
->hasMoreElements();
1722 if( !bHasMoreElements
)
1725 XMLTextNumRuleInfo aPrevNumInfo
;
1726 XMLTextNumRuleInfo aNextNumInfo
;
1728 sal_Bool bHasContent
= sal_False
;
1729 Reference
<XTextSection
> xCurrentTextSection(rBaseSection
);
1731 MultiPropertySetHelper
aPropSetHelper(
1732 bAutoStyles
? aParagraphPropertyNamesAuto
:
1733 aParagraphPropertyNames
);
1735 sal_Bool bHoldElement
= sal_False
;
1736 Reference
< XTextContent
> xTxtCntnt
;
1737 while( bHoldElement
|| bHasMoreElements
)
1741 bHoldElement
= sal_False
;
1745 xTxtCntnt
.set(rContEnum
->nextElement(), uno::UNO_QUERY
);
1747 aPropSetHelper
.resetValues();
1751 Reference
<XServiceInfo
> xServiceInfo( xTxtCntnt
, UNO_QUERY
);
1752 if( xServiceInfo
->supportsService( sParagraphService
) )
1758 exportListAndSectionChange( xCurrentTextSection
, xTxtCntnt
,
1759 aPrevNumInfo
, aNextNumInfo
,
1764 // --> OD 2006-09-27 #i69627#
1765 // --> OD 2008-04-24 #refactorlists#
1766 // pass list auto style pool to <XMLTextNumRuleInfo> instance
1767 // --> OD 2008-11-26 #158694#
1768 // pass info about request to export <text:number> element
1769 // to <XMLTextNumRuleInfo> instance
1770 aNextNumInfo
.Set( xTxtCntnt
,
1771 GetExport().writeOutlineStyleAsNormalListStyle(),
1772 GetListAutoStylePool(),
1773 GetExport().exportTextNumberElement() );
1776 exportListAndSectionChange( xCurrentTextSection
, aPropSetHelper
,
1777 TEXT_SECTION
, xTxtCntnt
,
1778 aPrevNumInfo
, aNextNumInfo
,
1783 // if we found a mute section: skip all section content
1784 if (pSectionExport
->IsMuteSection(xCurrentTextSection
))
1786 // Make sure headings are exported anyway.
1788 pSectionExport
->ExportMasterDocHeadingDummies();
1790 while (rContEnum
->hasMoreElements() &&
1791 pSectionExport
->IsInSection( xCurrentTextSection
,
1792 xTxtCntnt
, sal_True
))
1794 xTxtCntnt
.set(rContEnum
->nextElement(), uno::UNO_QUERY
);
1795 aPropSetHelper
.resetValues();
1796 aNextNumInfo
.Reset();
1798 // the first non-mute element still needs to be processed
1800 ! pSectionExport
->IsInSection( xCurrentTextSection
,
1801 xTxtCntnt
, sal_False
);
1804 exportParagraph( xTxtCntnt
, bAutoStyles
, bIsProgress
,
1805 bExportParagraph
, aPropSetHelper
);
1806 bHasContent
= sal_True
;
1808 else if( xServiceInfo
->supportsService( sTableService
) )
1812 aNextNumInfo
.Reset();
1815 exportListAndSectionChange( xCurrentTextSection
, xTxtCntnt
,
1816 aPrevNumInfo
, aNextNumInfo
,
1819 if (! pSectionExport
->IsMuteSection(xCurrentTextSection
))
1821 // export start + end redlines (for wholly redlined tables)
1822 if ((! bAutoStyles
) && (NULL
!= pRedlineExport
))
1823 pRedlineExport
->ExportStartOrEndRedline(xTxtCntnt
, sal_True
);
1825 exportTable( xTxtCntnt
, bAutoStyles
, bIsProgress
);
1827 if ((! bAutoStyles
) && (NULL
!= pRedlineExport
))
1828 pRedlineExport
->ExportStartOrEndRedline(xTxtCntnt
, sal_False
);
1830 else if( !bAutoStyles
)
1832 // Make sure headings are exported anyway.
1833 pSectionExport
->ExportMasterDocHeadingDummies();
1836 bHasContent
= sal_True
;
1838 else if( xServiceInfo
->supportsService( sTextFrameService
) )
1840 exportTextFrame( xTxtCntnt
, bAutoStyles
, bIsProgress
, sal_True
, pRangePropSet
);
1842 else if( xServiceInfo
->supportsService( sTextGraphicService
) )
1844 exportTextGraphic( xTxtCntnt
, bAutoStyles
, pRangePropSet
);
1846 else if( xServiceInfo
->supportsService( sTextEmbeddedService
) )
1848 exportTextEmbedded( xTxtCntnt
, bAutoStyles
, pRangePropSet
);
1850 else if( xServiceInfo
->supportsService( sShapeService
) )
1852 exportShape( xTxtCntnt
, bAutoStyles
, pRangePropSet
);
1856 DBG_ASSERT( !xTxtCntnt
.is(), "unknown text content" );
1861 aPrevNumInfo
= aNextNumInfo
;
1864 bHasMoreElements
= rContEnum
->hasMoreElements();
1867 if( bExportLevels
&& bHasContent
&& !bAutoStyles
)
1869 aNextNumInfo
.Reset();
1871 // close open lists and sections; no new styles
1872 exportListAndSectionChange( xCurrentTextSection
, rBaseSection
,
1873 aPrevNumInfo
, aNextNumInfo
,
1880 void XMLTextParagraphExport::exportParagraph(
1881 const Reference
< XTextContent
> & rTextContent
,
1882 sal_Bool bAutoStyles
, sal_Bool bIsProgress
, sal_Bool bExportParagraph
,
1883 MultiPropertySetHelper
& rPropSetHelper
)
1885 sal_Int16 nOutlineLevel
= -1;
1889 ProgressBarHelper
*pProgress
= GetExport().GetProgressBarHelper();
1890 pProgress
->SetValue( pProgress
->GetValue()+1 );
1893 // get property set or multi property set and initialize helper
1894 Reference
<XMultiPropertySet
> xMultiPropSet( rTextContent
, UNO_QUERY
);
1895 Reference
<XPropertySet
> xPropSet( rTextContent
, UNO_QUERY
);
1897 // check for supported properties
1898 if( !rPropSetHelper
.checkedProperties() )
1899 rPropSetHelper
.hasProperties( xPropSet
->getPropertySetInfo() );
1901 // if( xMultiPropSet.is() )
1902 // rPropSetHelper.getValues( xMultiPropSet );
1904 // rPropSetHelper.getValues( xPropSet );
1906 if( bExportParagraph
)
1910 Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, rPropSetHelper
, xPropSet
);
1914 // xml:id for RDF metadata
1915 GetExport().AddAttributeXmlId(rTextContent
);
1916 GetExport().AddAttributesRDFa(rTextContent
);
1919 if( rPropSetHelper
.hasProperty( PARA_STYLE_NAME
) )
1921 if( xMultiPropSet
.is() )
1922 rPropSetHelper
.getValue( PARA_STYLE_NAME
,
1923 xMultiPropSet
) >>= sStyle
;
1925 rPropSetHelper
.getValue( PARA_STYLE_NAME
,
1926 xPropSet
) >>= sStyle
;
1929 Reference
< XInterface
> xRef( rTextContent
, UNO_QUERY
);
1932 const OUString
& rIdentifier
= GetExport().getInterfaceToIdentifierMapper().getIdentifier( xRef
);
1933 if( rIdentifier
.getLength() )
1934 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_ID
, rIdentifier
);
1937 OUString
sAutoStyle( sStyle
);
1938 sAutoStyle
= Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, xPropSet
, sStyle
);
1939 if( sAutoStyle
.getLength() )
1940 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
1941 GetExport().EncodeStyleName( sAutoStyle
) );
1943 if( rPropSetHelper
.hasProperty( PARA_CONDITIONAL_STYLE_NAME
) )
1945 OUString sCondStyle
;
1946 if( xMultiPropSet
.is() )
1947 rPropSetHelper
.getValue( PARA_CONDITIONAL_STYLE_NAME
,
1948 xMultiPropSet
) >>= sCondStyle
;
1950 rPropSetHelper
.getValue( PARA_CONDITIONAL_STYLE_NAME
,
1951 xPropSet
) >>= sCondStyle
;
1952 if( sCondStyle
!= sStyle
)
1954 sCondStyle
= Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, xPropSet
,
1956 if( sCondStyle
.getLength() )
1957 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
1958 XML_COND_STYLE_NAME
,
1959 GetExport().EncodeStyleName( sCondStyle
) );
1963 //if( rPropSetHelper.hasProperty( PARA_CHAPTER_NUMERBING_LEVEL ) ) //#outline level,zhaojianwei
1964 if( rPropSetHelper
.hasProperty( PARA_OUTLINE_LEVEL
) ) //<-end
1966 if( xMultiPropSet
.is() )
1967 //rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL, //#outline level,zhaojianwei
1968 rPropSetHelper
.getValue( PARA_OUTLINE_LEVEL
, //<-end
1969 xMultiPropSet
) >>= nOutlineLevel
;
1971 //rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL, //#outline level,zhaojianwei
1972 rPropSetHelper
.getValue( PARA_OUTLINE_LEVEL
, //<-end
1973 xPropSet
) >>= nOutlineLevel
;
1975 //if( -1 != nOutlineLevel ) //#outline level,zhaojianwei
1976 if( 0 < nOutlineLevel
) //<-end,zhaojianwei
1978 OUStringBuffer sTmp
;
1979 //sTmp.append( sal_Int32( nOutlineLevel + 1 ) ); //#outline level,zhaojianwei
1980 sTmp
.append( sal_Int32( nOutlineLevel
) ); //<-end,zhaojianwei
1981 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
1983 sTmp
.makeStringAndClear() );
1985 if( rPropSetHelper
.hasProperty( NUMBERING_IS_NUMBER
) )
1987 bool bIsNumber
= false;
1988 if( xMultiPropSet
.is() )
1989 rPropSetHelper
.getValue(
1990 NUMBERING_IS_NUMBER
, xMultiPropSet
) >>= bIsNumber
;
1992 rPropSetHelper
.getValue(
1993 NUMBERING_IS_NUMBER
, xPropSet
) >>= bIsNumber
;
1995 OUString sListStyleName
;
1996 if( xMultiPropSet
.is() )
1997 rPropSetHelper
.getValue(
1998 PARA_NUMBERING_STYLENAME
, xMultiPropSet
) >>= sListStyleName
;
2000 rPropSetHelper
.getValue(
2001 PARA_NUMBERING_STYLENAME
, xPropSet
) >>= sListStyleName
;
2005 bool bAssignedtoOutlineStyle
= false;//#outline level,add by zhaojianwei
2007 Reference
< XChapterNumberingSupplier
> xCNSupplier( GetExport().GetModel(), UNO_QUERY
);
2009 OUString sOutlineName
;
2010 if (xCNSupplier
.is())
2012 Reference
< XIndexReplace
> xNumRule ( xCNSupplier
->getChapterNumberingRules() );
2013 DBG_ASSERT( xNumRule
.is(), "no chapter numbering rules" );
2017 Reference
< XPropertySet
> xNumRulePropSet( xNumRule
, UNO_QUERY
);
2018 xNumRulePropSet
->getPropertyValue(
2019 OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) ) >>= sOutlineName
;
2020 bAssignedtoOutlineStyle
= ( sListStyleName
== sOutlineName
);
2024 } //<end,zhaojianwei
2026 //if( ! bIsNumber ) //#outline level,removed by zhaojianwei
2027 if( ! bIsNumber
&& bAssignedtoOutlineStyle
) //#outline level,add by zhaojianwei
2028 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
2034 String sParaIsNumberingRestart
2035 (RTL_CONSTASCII_USTRINGPARAM
2036 ("ParaIsNumberingRestart"));
2037 bool bIsRestartNumbering
= false;
2039 Reference
< XPropertySetInfo
>
2040 xPropSetInfo(xMultiPropSet
.is() ?
2041 xMultiPropSet
->getPropertySetInfo():
2042 xPropSet
->getPropertySetInfo());
2045 hasPropertyByName(sParaIsNumberingRestart
))
2047 xPropSet
->getPropertyValue(sParaIsNumberingRestart
)
2048 >>= bIsRestartNumbering
;
2051 if (bIsRestartNumbering
)
2053 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
2054 XML_RESTART_NUMBERING
,
2057 String sNumberingStartValue
2058 (RTL_CONSTASCII_USTRINGPARAM
2059 ("NumberingStartValue"));
2062 sal_Int32 nStartValue
= 0;
2065 hasPropertyByName(sNumberingStartValue
))
2067 xPropSet
->getPropertyValue(sNumberingStartValue
)
2070 OUStringBuffer sTmpStartValue
;
2072 sTmpStartValue
.append(nStartValue
);
2075 AddAttribute(XML_NAMESPACE_TEXT
,
2078 makeStringAndClear());
2087 Reference
< XEnumerationAccess
> xEA( rTextContent
, UNO_QUERY
);
2088 Reference
< XEnumeration
> xTextEnum
;
2089 xTextEnum
= xEA
->createEnumeration();
2090 const sal_Bool bHasPortions
= xTextEnum
.is();
2092 Reference
< XEnumeration
> xContentEnum
;
2093 Reference
< XContentEnumerationAccess
> xCEA( rTextContent
, UNO_QUERY
);
2095 xContentEnum
.set(xCEA
->createContentEnumeration( sTextContentService
));
2096 const sal_Bool bHasContentEnum
= xContentEnum
.is() &&
2097 xContentEnum
->hasMoreElements();
2099 Reference
< XTextSection
> xSection
;
2100 if( bHasContentEnum
)
2102 // For the auto styles, the multi property set helper is only used
2103 // if hard attributes are existing. Therfor, it seems to be a better
2104 // strategy to have the TextSection property seperate, because otherwise
2105 // we always retrieve the style names even if they are not required.
2108 if( xPropSet
->getPropertySetInfo()->hasPropertyByName( sTextSection
) )
2110 xSection
.set(xPropSet
->getPropertyValue( sTextSection
), uno::UNO_QUERY
);
2115 if( rPropSetHelper
.hasProperty( TEXT_SECTION
) )
2117 xSection
.set(rPropSetHelper
.getValue( TEXT_SECTION
), uno::UNO_QUERY
);
2124 sal_Bool bPrevCharIsSpace
= sal_True
;
2125 if( bHasContentEnum
)
2126 bPrevCharIsSpace
= !exportTextContentEnumeration(
2127 xContentEnum
, bAutoStyles
, xSection
,
2128 bIsProgress
, sal_True
, 0, sal_True
);
2130 exportTextRangeEnumeration( xTextEnum
, bAutoStyles
, bIsProgress
);
2134 sal_Bool bPrevCharIsSpace
= sal_True
;
2135 enum XMLTokenEnum eElem
=
2136 //-1 == nOutlineLevel ? XML_P : XML_H; //#outline level,zhaojianwei
2137 0 < nOutlineLevel
? XML_H
: XML_P
; //<-end,zhaojianwei
2138 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, eElem
,
2139 sal_True
, sal_False
);
2140 if( bHasContentEnum
)
2141 bPrevCharIsSpace
= !exportTextContentEnumeration(
2142 xContentEnum
, bAutoStyles
, xSection
,
2144 exportTextRangeEnumeration( xTextEnum
, bAutoStyles
, bIsProgress
,
2149 void XMLTextParagraphExport::exportTextRangeEnumeration(
2150 const Reference
< XEnumeration
> & rTextEnum
,
2151 sal_Bool bAutoStyles
, sal_Bool bIsProgress
,
2152 sal_Bool bPrvChrIsSpc
)
2154 static OUString
sMeta(RTL_CONSTASCII_USTRINGPARAM("Meta")); // FIXME
2155 sal_Bool bPrevCharIsSpace
= bPrvChrIsSpc
;
2157 while( rTextEnum
->hasMoreElements() )
2159 Reference
<XPropertySet
> xPropSet(rTextEnum
->nextElement(), UNO_QUERY
);
2160 Reference
< XTextRange
> xTxtRange(xPropSet
, uno::UNO_QUERY
);
2161 Reference
<XPropertySetInfo
> xPropInfo(xPropSet
->getPropertySetInfo());
2163 if (xPropInfo
->hasPropertyByName(sTextPortionType
))
2165 rtl::OUString sType
;
2166 xPropSet
->getPropertyValue(sTextPortionType
) >>= sType
;
2168 if( sType
.equals(sText
))
2170 exportTextRange( xTxtRange
, bAutoStyles
,
2173 else if( sType
.equals(sTextField
))
2175 exportTextField( xTxtRange
, bAutoStyles
, bIsProgress
);
2176 bPrevCharIsSpace
= sal_False
;
2178 else if( sType
.equals( sFrame
) )
2180 Reference
< XEnumeration
> xContentEnum
;
2181 Reference
< XContentEnumerationAccess
> xCEA( xTxtRange
,
2184 xContentEnum
.set(xCEA
->createContentEnumeration(
2185 sTextContentService
));
2186 // frames are never in sections
2187 Reference
<XTextSection
> xSection
;
2188 if( xContentEnum
.is() )
2189 exportTextContentEnumeration( xContentEnum
,
2191 xSection
, bIsProgress
, sal_True
,
2194 bPrevCharIsSpace
= sal_False
;
2196 else if (sType
.equals(sFootnote
))
2198 exportTextFootnote(xPropSet
,
2199 xTxtRange
->getString(),
2200 bAutoStyles
, bIsProgress
);
2201 bPrevCharIsSpace
= sal_False
;
2203 else if (sType
.equals(sBookmark
))
2205 exportTextMark(xPropSet
,
2207 lcl_XmlBookmarkElements
,
2210 else if (sType
.equals(sReferenceMark
))
2212 exportTextMark(xPropSet
,
2214 lcl_XmlReferenceElements
,
2217 else if (sType
.equals(sDocumentIndexMark
))
2219 pIndexMarkExport
->ExportIndexMark(xPropSet
, bAutoStyles
);
2221 else if (sType
.equals(sRedline
))
2223 if (NULL
!= pRedlineExport
)
2224 pRedlineExport
->ExportChange(xPropSet
, bAutoStyles
);
2226 else if (sType
.equals(sRuby
))
2228 exportRuby(xPropSet
, bAutoStyles
);
2230 else if (sType
.equals(sMeta
))
2232 exportMeta(xPropSet
, bAutoStyles
, bIsProgress
);
2234 else if (sType
.equals(sTextFieldStart
))
2236 Reference
<XNamed
> xBookmark(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2237 if (xBookmark
.is()) {
2238 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, xBookmark
->getName());
2240 Reference
< ::com::sun::star::text::XFormField
> xFormField(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2241 if (xFormField
.is()) {
2242 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_TYPE
, xFormField
->getFieldType());
2244 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_START
, sal_False
);
2245 if (xFormField
.is()) {
2246 for(sal_Int16 i
=0;i
<xFormField
->getParamCount();i
++) {
2247 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_NAME
, xFormField
->getParamName(i
));
2248 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_VALUE
, xFormField
->getParamValue(i
));
2249 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
2250 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
2253 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_START
, sal_False
);
2255 else if (sType
.equals(sTextFieldEnd
))
2257 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_END
, sal_False
);
2258 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_END
, sal_False
);
2260 else if (sType
.equals(sTextFieldStartEnd
))
2262 Reference
<XNamed
> xBookmark(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2263 if (xBookmark
.is()) {
2264 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, xBookmark
->getName());
2266 Reference
< ::com::sun::star::text::XFormField
> xFormField(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2267 if (xFormField
.is()) {
2268 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_TYPE
, xFormField
->getFieldType());
2270 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK
, sal_False
);
2271 if (xFormField
.is()) {
2272 for(sal_Int16 i
=0;i
<xFormField
->getParamCount();i
++) {
2273 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_NAME
, xFormField
->getParamName(i
));
2274 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_VALUE
, xFormField
->getParamValue(i
));
2275 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
2276 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
2279 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK
, sal_False
);
2281 else if (sType
.equals(sSoftPageBreak
))
2283 exportSoftPageBreak(xPropSet
, bAutoStyles
);
2286 DBG_ERROR("unknown text portion type");
2291 Reference
<XServiceInfo
> xServiceInfo( xTxtRange
, UNO_QUERY
);
2292 if( xServiceInfo
->supportsService( sTextFieldService
) )
2294 exportTextField( xTxtRange
, bAutoStyles
, bIsProgress
);
2295 bPrevCharIsSpace
= sal_False
;
2299 // no TextPortionType property -> non-Writer app -> text
2300 exportTextRange( xTxtRange
, bAutoStyles
, bPrevCharIsSpace
);
2305 DBG_ASSERT( !bOpenRuby
, "Red Alert: Ruby still open!" );
2308 void XMLTextParagraphExport::exportTable(
2309 const Reference
< XTextContent
> &,
2310 sal_Bool
/*bAutoStyles*/, sal_Bool
/*bIsProgress*/ )
2314 void XMLTextParagraphExport::exportTextField(
2315 const Reference
< XTextRange
> & rTextRange
,
2316 sal_Bool bAutoStyles
, sal_Bool bIsProgress
)
2318 Reference
< XPropertySet
> xPropSet( rTextRange
, UNO_QUERY
);
2319 // non-Writer apps need not support Property TextField, so test first
2320 if (xPropSet
->getPropertySetInfo()->hasPropertyByName( sTextField
))
2322 Reference
< XTextField
> xTxtFld(xPropSet
->getPropertyValue( sTextField
), uno::UNO_QUERY
);
2323 DBG_ASSERT( xTxtFld
.is(), "text field missing" );
2328 pFieldExport
->ExportFieldAutoStyle( xTxtFld
, bIsProgress
);
2332 pFieldExport
->ExportField( xTxtFld
, bIsProgress
);
2337 // write only characters
2338 GetExport().Characters(rTextRange
->getString());
2344 void XMLTextParagraphExport::exportSoftPageBreak(
2345 const Reference
<XPropertySet
> & ,
2348 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2349 XML_SOFT_PAGE_BREAK
, sal_False
,
2353 void XMLTextParagraphExport::exportTextMark(
2354 const Reference
<XPropertySet
> & rPropSet
,
2355 const OUString sProperty
,
2356 const enum XMLTokenEnum pElements
[],
2357 sal_Bool bAutoStyles
)
2359 // mib said: "Hau wech!"
2361 // (Originally, I'd export a span element in case the (book|reference)mark
2362 // was formatted. This actually makes a difference in case some pervert
2363 // sets a point reference mark in the document and, say, formats it bold.
2364 // This basically meaningless formatting will now been thrown away
2365 // (aka cleaned up), since mib said: ... dvo
2370 Reference
<XNamed
> xName(rPropSet
->getPropertyValue(sProperty
), UNO_QUERY
);
2371 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
,
2374 // start, end, or point-reference?
2376 if( *(sal_Bool
*)rPropSet
->getPropertyValue(sIsCollapsed
).getValue() )
2382 nElement
= *(sal_Bool
*)rPropSet
->getPropertyValue(sIsStart
).getValue() ? 1 : 2;
2385 // bookmark, bookmark-start: xml:id for RDF metadata
2386 if( nElement
< 2 ) {
2387 GetExport().AddAttributeXmlId(xName
);
2391 DBG_ASSERT(pElements
!= NULL
, "illegal element array");
2392 DBG_ASSERT(nElement
>= 0, "illegal element number");
2393 DBG_ASSERT(nElement
<= 2, "illegal element number");
2394 SvXMLElementExport
aElem(GetExport(),
2395 XML_NAMESPACE_TEXT
, pElements
[nElement
],
2396 sal_False
, sal_False
);
2398 // else: no styles. (see above)
2401 sal_Bool
lcl_txtpara_isBoundAsChar(
2402 const Reference
< XPropertySet
> & rPropSet
,
2403 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
2405 sal_Bool bIsBoundAsChar
= sal_False
;
2406 OUString
sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2407 if( rPropSetInfo
->hasPropertyByName( sAnchorType
) )
2409 TextContentAnchorType eAnchor
;
2410 rPropSet
->getPropertyValue( sAnchorType
) >>= eAnchor
;
2411 bIsBoundAsChar
= TextContentAnchorType_AS_CHARACTER
== eAnchor
;
2414 return bIsBoundAsChar
;
2417 sal_Int32
XMLTextParagraphExport::addTextFrameAttributes(
2418 const Reference
< XPropertySet
>& rPropSet
,
2420 OUString
*pMinHeightValue
)
2422 sal_Int32 nShapeFeatures
= SEF_DEFAULT
;
2424 // draw:name (#97662#: not for shapes, since those names will be
2425 // treated in the shape export)
2428 Reference
< XNamed
> xNamed( rPropSet
, UNO_QUERY
);
2431 OUString
sName( xNamed
->getName() );
2432 if( sName
.getLength() )
2433 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_NAME
,
2434 xNamed
->getName() );
2438 OUStringBuffer sValue
;
2441 TextContentAnchorType eAnchor
= TextContentAnchorType_AT_PARAGRAPH
;
2442 rPropSet
->getPropertyValue( sAnchorType
) >>= eAnchor
;
2444 XMLAnchorTypePropHdl aAnchorTypeHdl
;
2446 aAnchorTypeHdl
.exportXML( sTmp
, uno::makeAny(eAnchor
),
2447 GetExport().GetMM100UnitConverter() );
2448 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_ANCHOR_TYPE
, sTmp
);
2451 // text:anchor-page-number
2452 if( TextContentAnchorType_AT_PAGE
== eAnchor
)
2454 sal_Int16 nPage
= 0;
2455 rPropSet
->getPropertyValue( sAnchorPageNo
) >>= nPage
;
2456 GetExport().GetMM100UnitConverter().convertNumber( sValue
,
2458 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_ANCHOR_PAGE_NUMBER
,
2459 sValue
.makeStringAndClear() );
2464 nShapeFeatures
|= SEF_EXPORT_NO_WS
;
2467 // OD 2004-06-01 #i27691# - correction: no export of svg:x, if object
2468 // is anchored as-character.
2470 eAnchor
!= TextContentAnchorType_AS_CHARACTER
)
2473 sal_Int16 nHoriOrient
= HoriOrientation::NONE
;
2474 rPropSet
->getPropertyValue( sHoriOrient
) >>= nHoriOrient
;
2475 if( HoriOrientation::NONE
== nHoriOrient
)
2478 rPropSet
->getPropertyValue( sHoriOrientPosition
) >>= nPos
;
2479 GetExport().GetMM100UnitConverter().convertMeasure( sValue
, nPos
);
2480 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_X
,
2481 sValue
.makeStringAndClear() );
2484 else if( TextContentAnchorType_AS_CHARACTER
== eAnchor
)
2485 nShapeFeatures
= (nShapeFeatures
& ~SEF_EXPORT_X
);
2487 if( !bShape
|| TextContentAnchorType_AS_CHARACTER
== eAnchor
)
2490 sal_Int16 nVertOrient
= VertOrientation::NONE
;
2491 rPropSet
->getPropertyValue( sVertOrient
) >>= nVertOrient
;
2492 if( VertOrientation::NONE
== nVertOrient
)
2495 rPropSet
->getPropertyValue( sVertOrientPosition
) >>= nPos
;
2496 GetExport().GetMM100UnitConverter().convertMeasure( sValue
, nPos
);
2497 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_Y
,
2498 sValue
.makeStringAndClear() );
2501 nShapeFeatures
= (nShapeFeatures
& ~SEF_EXPORT_Y
);
2505 Reference
< XPropertySetInfo
> xPropSetInfo(rPropSet
->getPropertySetInfo());
2508 sal_Int16 nWidthType
= SizeType::FIX
;
2509 if( xPropSetInfo
->hasPropertyByName( sWidthType
) )
2511 rPropSet
->getPropertyValue( sWidthType
) >>= nWidthType
;
2513 if( xPropSetInfo
->hasPropertyByName( sWidth
) )
2515 sal_Int32 nWidth
= 0;
2516 // VAR size will be written as zero min-size
2517 if( SizeType::VARIABLE
!= nWidthType
)
2519 rPropSet
->getPropertyValue( sWidth
) >>= nWidth
;
2521 GetExport().GetMM100UnitConverter().convertMeasure( sValue
, nWidth
);
2522 if( SizeType::FIX
!= nWidthType
)
2523 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_MIN_WIDTH
,
2524 sValue
.makeStringAndClear() );
2526 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_WIDTH
,
2527 sValue
.makeStringAndClear() );
2529 sal_Bool bSyncWidth
= sal_False
;
2530 if( xPropSetInfo
->hasPropertyByName( sIsSyncWidthToHeight
) )
2532 bSyncWidth
= *(sal_Bool
*)rPropSet
->getPropertyValue( sIsSyncWidthToHeight
).getValue();
2534 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_WIDTH
,
2537 if( !bSyncWidth
&& xPropSetInfo
->hasPropertyByName( sRelativeWidth
) )
2539 sal_Int16 nRelWidth
= 0;
2540 rPropSet
->getPropertyValue( sRelativeWidth
) >>= nRelWidth
;
2541 DBG_ASSERT( nRelWidth
>= 0 && nRelWidth
<= 254,
2542 "Got illegal relative width from API" );
2545 GetExport().GetMM100UnitConverter().convertPercent( sValue
,
2547 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_WIDTH
,
2548 sValue
.makeStringAndClear() );
2552 // svg:height, fo:min-height or style:rel-height
2553 sal_Int16 nSizeType
= SizeType::FIX
;
2554 if( xPropSetInfo
->hasPropertyByName( sSizeType
) )
2556 rPropSet
->getPropertyValue( sSizeType
) >>= nSizeType
;
2558 sal_Bool bSyncHeight
= sal_False
;
2559 if( xPropSetInfo
->hasPropertyByName( sIsSyncHeightToWidth
) )
2561 bSyncHeight
= *(sal_Bool
*)rPropSet
->getPropertyValue( sIsSyncHeightToWidth
).getValue();
2563 sal_Int16 nRelHeight
= 0;
2564 if( !bSyncHeight
&& xPropSetInfo
->hasPropertyByName( sRelativeHeight
) )
2566 rPropSet
->getPropertyValue( sRelativeHeight
) >>= nRelHeight
;
2568 if( xPropSetInfo
->hasPropertyByName( sHeight
) )
2570 sal_Int32 nHeight
= 0;
2571 if( SizeType::VARIABLE
!= nSizeType
)
2573 rPropSet
->getPropertyValue( sHeight
) >>= nHeight
;
2575 GetExport().GetMM100UnitConverter().convertMeasure( sValue
,
2577 if( SizeType::FIX
!= nSizeType
&& 0==nRelHeight
&& !bSyncHeight
&&
2579 *pMinHeightValue
= sValue
.makeStringAndClear();
2581 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_HEIGHT
,
2582 sValue
.makeStringAndClear() );
2586 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_HEIGHT
,
2587 SizeType::MIN
== nSizeType
? XML_SCALE_MIN
: XML_SCALE
);
2590 else if( nRelHeight
> 0 )
2592 GetExport().GetMM100UnitConverter().convertPercent( sValue
,
2594 if( SizeType::MIN
== nSizeType
)
2595 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_MIN_HEIGHT
,
2596 sValue
.makeStringAndClear() );
2598 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_HEIGHT
,
2599 sValue
.makeStringAndClear() );
2602 OUString
sZOrder( RTL_CONSTASCII_USTRINGPARAM( "ZOrder" ) );
2603 if( xPropSetInfo
->hasPropertyByName( sZOrder
) )
2605 sal_Int32 nZIndex
= 0;
2606 rPropSet
->getPropertyValue( sZOrder
) >>= nZIndex
;
2609 GetExport().GetMM100UnitConverter().convertNumber( sValue
,
2611 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_ZINDEX
,
2612 sValue
.makeStringAndClear() );
2616 return nShapeFeatures
;
2619 void XMLTextParagraphExport::exportAnyTextFrame(
2620 const Reference
< XTextContent
> & rTxtCntnt
,
2622 sal_Bool bAutoStyles
,
2623 sal_Bool bIsProgress
,
2624 sal_Bool bExportContent
,
2625 const Reference
< XPropertySet
> *pRangePropSet
)
2627 Reference
< XPropertySet
> xPropSet( rTxtCntnt
, UNO_QUERY
);
2631 if( FT_EMBEDDED
== eType
)
2632 _collectTextEmbeddedAutoStyles( xPropSet
);
2633 // --> OD 2004-08-09 #i28745# - no text frame style for shapes
2634 else if ( FT_SHAPE
!= eType
)
2635 Add( XML_STYLE_FAMILY_TEXT_FRAME
, xPropSet
);
2638 if( pRangePropSet
&& lcl_txtpara_isBoundAsChar( xPropSet
,
2639 xPropSet
->getPropertySetInfo() ) )
2640 Add( XML_STYLE_FAMILY_TEXT_TEXT
, *pRangePropSet
);
2646 // frame bound frames
2647 if ( bExportContent
)
2649 Reference
< XTextFrame
> xTxtFrame( rTxtCntnt
, UNO_QUERY
);
2650 Reference
< XText
> xTxt(xTxtFrame
->getText());
2651 exportFrameFrames( sal_True
, bIsProgress
, &xTxtFrame
);
2652 exportText( xTxt
, bAutoStyles
, bIsProgress
, sal_True
);
2658 Reference
< XShape
> xShape( rTxtCntnt
, UNO_QUERY
);
2659 GetExport().GetShapeExport()->collectShapeAutoStyles( xShape
);
2668 Reference
< XPropertySetInfo
> xPropSetInfo(xPropSet
->getPropertySetInfo());
2669 Reference
< XPropertyState
> xPropState( xPropSet
, UNO_QUERY
);
2671 sal_Bool bAddCharStyles
= pRangePropSet
&&
2672 lcl_txtpara_isBoundAsChar( xPropSet
, xPropSetInfo
);
2674 sal_Bool bIsUICharStyle
;
2675 sal_Bool bHasAutoStyle
= sal_False
;
2680 if( bAddCharStyles
)
2681 sStyle
= FindTextStyleAndHyperlink( *pRangePropSet
, bDummy
, bIsUICharStyle
, bHasAutoStyle
);
2683 bIsUICharStyle
= sal_False
;
2685 XMLTextCharStyleNamesElementExport
aCharStylesExport(
2686 GetExport(), bIsUICharStyle
&&
2687 aCharStyleNamesPropInfoCache
.hasProperty(
2688 *pRangePropSet
), bHasAutoStyle
,
2689 *pRangePropSet
, sCharStyleNames
);
2691 if( sStyle
.getLength() )
2692 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
2693 GetExport().EncodeStyleName( sStyle
) );
2695 SvXMLElementExport
aElem( GetExport(), sStyle
.getLength() > 0,
2696 XML_NAMESPACE_TEXT
, XML_SPAN
, sal_False
, sal_False
);
2698 SvXMLElementExport
aElement( GetExport(),
2699 FT_SHAPE
!= eType
&&
2700 addHyperlinkAttributes( xPropSet
,
2701 xPropState
,xPropSetInfo
),
2702 XML_NAMESPACE_DRAW
, XML_A
, sal_False
, sal_False
);
2706 _exportTextFrame( xPropSet
, xPropSetInfo
, bIsProgress
);
2709 _exportTextGraphic( xPropSet
, xPropSetInfo
);
2712 _exportTextEmbedded( xPropSet
, xPropSetInfo
);
2716 Reference
< XShape
> xShape( rTxtCntnt
, UNO_QUERY
);
2717 sal_Int32 nFeatures
=
2718 addTextFrameAttributes( xPropSet
, sal_True
);
2719 GetExport().GetShapeExport()
2720 ->exportShape( xShape
, nFeatures
);
2730 void XMLTextParagraphExport::_exportTextFrame(
2731 const Reference
< XPropertySet
> & rPropSet
,
2732 const Reference
< XPropertySetInfo
> & rPropSetInfo
,
2733 sal_Bool bIsProgress
)
2735 Reference
< XTextFrame
> xTxtFrame( rPropSet
, UNO_QUERY
);
2736 Reference
< XText
> xTxt(xTxtFrame
->getText());
2739 if( rPropSetInfo
->hasPropertyByName( sFrameStyleName
) )
2741 rPropSet
->getPropertyValue( sFrameStyleName
) >>= sStyle
;
2744 OUString
sAutoStyle( sStyle
);
2745 OUString aMinHeightValue
;
2746 sAutoStyle
= Find( XML_STYLE_FAMILY_TEXT_FRAME
, rPropSet
, sStyle
);
2747 if( sAutoStyle
.getLength() )
2748 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_STYLE_NAME
,
2749 GetExport().EncodeStyleName( sAutoStyle
) );
2750 addTextFrameAttributes( rPropSet
, sal_False
, &aMinHeightValue
);
2752 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_DRAW
,
2753 XML_FRAME
, sal_False
, sal_True
);
2755 if( aMinHeightValue
.getLength() )
2756 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_MIN_HEIGHT
,
2759 // draw:chain-next-name
2760 if( rPropSetInfo
->hasPropertyByName( sChainNextName
) )
2763 if( (rPropSet
->getPropertyValue( sChainNextName
) >>= sNext
) && sNext
.getLength() > 0 )
2764 GetExport().AddAttribute( XML_NAMESPACE_DRAW
,
2765 XML_CHAIN_NEXT_NAME
,
2770 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_DRAW
,
2771 XML_TEXT_BOX
, sal_True
, sal_True
);
2773 // frame bound frames
2774 exportFramesBoundToFrame( xTxtFrame
, bIsProgress
);
2776 exportText( xTxt
, sal_False
, bIsProgress
, sal_True
);
2780 Reference
<XEventsSupplier
> xEventsSupp( xTxtFrame
, UNO_QUERY
);
2781 GetExport().GetEventExport().Export(xEventsSupp
);
2784 GetExport().GetImageMapExport().Export( rPropSet
);
2786 // --> OD 2009-07-22 #i73249#
2787 // svg:title and svg:desc
2788 exportTitleAndDescription( rPropSet
, rPropSetInfo
);
2792 void XMLTextParagraphExport::exportContour(
2793 const Reference
< XPropertySet
> & rPropSet
,
2794 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
2796 if( !rPropSetInfo
->hasPropertyByName( sContourPolyPolygon
) )
2799 PointSequenceSequence aSourcePolyPolygon
;
2800 rPropSet
->getPropertyValue( sContourPolyPolygon
) >>= aSourcePolyPolygon
;
2802 if( !aSourcePolyPolygon
.getLength() )
2805 awt::Point
aPoint( 0, 0 );
2806 awt::Size
aSize( 0, 0 );
2807 sal_Int32 nPolygons
= aSourcePolyPolygon
.getLength();
2808 const PointSequence
*pPolygons
= aSourcePolyPolygon
.getConstArray();
2809 while( nPolygons
-- )
2811 sal_Int32 nPoints
= pPolygons
->getLength();
2812 const awt::Point
*pPoints
= pPolygons
->getConstArray();
2815 if( aSize
.Width
< pPoints
->X
)
2816 aSize
.Width
= pPoints
->X
;
2817 if( aSize
.Height
< pPoints
->Y
)
2818 aSize
.Height
= pPoints
->Y
;
2824 sal_Bool bPixel
= sal_False
;
2825 if( rPropSetInfo
->hasPropertyByName( sIsPixelContour
) )
2827 bPixel
= *(sal_Bool
*)rPropSet
->getPropertyValue( sIsPixelContour
).getValue();
2831 OUStringBuffer
aStringBuffer( 10 );
2833 GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer
, aSize
.Width
);
2835 GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer
, aSize
.Width
);
2836 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_WIDTH
,
2837 aStringBuffer
.makeStringAndClear() );
2841 GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer
, aSize
.Height
);
2843 GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer
, aSize
.Height
);
2844 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_HEIGHT
,
2845 aStringBuffer
.makeStringAndClear() );
2848 SdXMLImExViewBox
aViewBox(0, 0, aSize
.Width
, aSize
.Height
);
2849 GetExport().AddAttribute(XML_NAMESPACE_SVG
, XML_VIEWBOX
,
2850 aViewBox
.GetExportString());
2852 sal_Int32
nOuterCnt( aSourcePolyPolygon
.getLength() );
2854 enum XMLTokenEnum eElem
= XML_TOKEN_INVALID
;
2855 if( 1L == nOuterCnt
)
2857 // simple polygon shape, can be written as svg:points sequence
2858 /*const*/ PointSequence
* pSequence
=
2859 (PointSequence
*)aSourcePolyPolygon
.getConstArray();
2861 SdXMLImExPointsElement
aPoints( pSequence
, aViewBox
, aPoint
, aSize
);
2863 // write point array
2864 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_POINTS
,
2865 aPoints
.GetExportString());
2866 eElem
= XML_CONTOUR_POLYGON
;
2870 // polypolygon, needs to be written as a svg:path sequence
2871 /*const*/ PointSequence
* pOuterSequence
=
2872 (PointSequence
*)aSourcePolyPolygon
.getConstArray();
2875 // prepare svx:d element export
2876 SdXMLImExSvgDElement
aSvgDElement( aViewBox
);
2878 for(sal_Int32
a(0L); a
< nOuterCnt
; a
++)
2880 /*const*/ PointSequence
* pSequence
= pOuterSequence
++;
2883 aSvgDElement
.AddPolygon(pSequence
, 0L, aPoint
,
2888 // write point array
2889 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_D
,
2890 aSvgDElement
.GetExportString());
2891 eElem
= XML_CONTOUR_PATH
;
2895 if( rPropSetInfo
->hasPropertyByName( sIsAutomaticContour
) )
2897 sal_Bool bTmp
= *(sal_Bool
*)rPropSet
->getPropertyValue(
2898 sIsAutomaticContour
).getValue();
2899 GetExport().AddAttribute( XML_NAMESPACE_DRAW
,
2900 XML_RECREATE_ON_EDIT
, bTmp
? XML_TRUE
: XML_FALSE
);
2904 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_DRAW
, eElem
,
2905 sal_True
, sal_True
);
2908 void XMLTextParagraphExport::_exportTextGraphic(
2909 const Reference
< XPropertySet
> & rPropSet
,
2910 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
2913 if( rPropSetInfo
->hasPropertyByName( sFrameStyleName
) )
2915 rPropSet
->getPropertyValue( sFrameStyleName
) >>= sStyle
;
2918 OUString
sAutoStyle( sStyle
);
2919 sAutoStyle
= Find( XML_STYLE_FAMILY_TEXT_FRAME
, rPropSet
, sStyle
);
2920 if( sAutoStyle
.getLength() )
2921 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_STYLE_NAME
,
2922 GetExport().EncodeStyleName( sAutoStyle
) );
2923 addTextFrameAttributes( rPropSet
, sal_False
);
2927 rPropSet
->getPropertyValue( sGraphicRotation
) >>= nVal
;
2930 OUStringBuffer
sRet( GetXMLToken(XML_ROTATE
).getLength()+4 );
2931 sRet
.append( GetXMLToken(XML_ROTATE
));
2932 sRet
.append( (sal_Unicode
)'(' );
2933 GetExport().GetMM100UnitConverter().convertNumber( sRet
, (sal_Int32
)nVal
);
2934 sRet
.append( (sal_Unicode
)')' );
2935 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_TRANSFORM
,
2936 sRet
.makeStringAndClear() );
2940 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_DRAW
,
2941 XML_FRAME
, sal_False
, sal_True
);
2945 rPropSet
->getPropertyValue( sGraphicURL
) >>= sOrigURL
;
2946 OUString
sURL(GetExport().AddEmbeddedGraphicObject( sOrigURL
));
2947 setTextEmbeddedGraphicURL( rPropSet
, sURL
);
2949 // If there still is no url, then then graphic is empty
2950 if( sURL
.getLength() )
2952 GetExport().AddAttribute(XML_NAMESPACE_XLINK
, XML_HREF
, sURL
);
2953 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
2954 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_SHOW
, XML_EMBED
);
2955 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_ACTUATE
,
2960 OUString sGrfFilter
;
2961 rPropSet
->getPropertyValue( sGraphicFilter
) >>= sGrfFilter
;
2962 if( sGrfFilter
.getLength() )
2963 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_FILTER_NAME
,
2967 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_DRAW
,
2968 XML_IMAGE
, sal_False
, sal_True
);
2970 // optional office:binary-data
2971 GetExport().AddEmbeddedGraphicObjectAsBase64( sOrigURL
);
2975 Reference
<XEventsSupplier
> xEventsSupp( rPropSet
, UNO_QUERY
);
2976 GetExport().GetEventExport().Export(xEventsSupp
);
2979 GetExport().GetImageMapExport().Export( rPropSet
);
2981 // --> OD 2009-07-22 #i73249#
2982 // svg:title and svg:desc
2983 exportTitleAndDescription( rPropSet
, rPropSetInfo
);
2987 exportContour( rPropSet
, rPropSetInfo
);
2990 void XMLTextParagraphExport::_collectTextEmbeddedAutoStyles(const Reference
< XPropertySet
> & )
2992 DBG_ASSERT( !this, "no API implementation avialable" );
2995 void XMLTextParagraphExport::_exportTextEmbedded(
2996 const Reference
< XPropertySet
> &,
2997 const Reference
< XPropertySetInfo
> & )
2999 DBG_ASSERT( !this, "no API implementation avialable" );
3002 void XMLTextParagraphExport::exportEvents( const Reference
< XPropertySet
> & rPropSet
)
3005 Reference
<XEventsSupplier
> xEventsSupp( rPropSet
, UNO_QUERY
);
3006 GetExport().GetEventExport().Export(xEventsSupp
);
3009 OUString
sImageMap(RTL_CONSTASCII_USTRINGPARAM("ImageMap"));
3010 if (rPropSet
->getPropertySetInfo()->hasPropertyByName(sImageMap
))
3011 GetExport().GetImageMapExport().Export( rPropSet
);
3014 // --> OD 2009-07-22 #i73249#
3015 void XMLTextParagraphExport::exportTitleAndDescription(
3016 const Reference
< XPropertySet
> & rPropSet
,
3017 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
3020 if( rPropSetInfo
->hasPropertyByName( sTitle
) )
3023 rPropSet
->getPropertyValue( sTitle
) >>= sObjTitle
;
3024 if( sObjTitle
.getLength() )
3026 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_SVG
,
3027 XML_TITLE
, sal_True
, sal_False
);
3028 GetExport().Characters( sObjTitle
);
3033 if( rPropSetInfo
->hasPropertyByName( sDescription
) )
3036 rPropSet
->getPropertyValue( sDescription
) >>= sObjDesc
;
3037 if( sObjDesc
.getLength() )
3039 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_SVG
,
3040 XML_DESC
, sal_True
, sal_False
);
3041 GetExport().Characters( sObjDesc
);
3047 void XMLTextParagraphExport::setTextEmbeddedGraphicURL(
3048 const Reference
< XPropertySet
>&,
3049 OUString
& /*rStreamName*/ ) const
3053 sal_Bool
XMLTextParagraphExport::addHyperlinkAttributes(
3054 const Reference
< XPropertySet
> & rPropSet
,
3055 const Reference
< XPropertyState
> & rPropState
,
3056 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
3058 sal_Bool bExport
= sal_False
;
3059 OUString sHRef
, sName
, sTargetFrame
, sUStyleName
, sVStyleName
;
3060 sal_Bool bServerMap
= sal_False
;
3062 /* bool bHyperLinkURL = false;
3063 bool bHyperLinkName = false;
3064 bool bHyperLinkTarget = false;
3065 bool bServer = false;
3066 bool bUnvisitedCharStyleName = false;
3067 bool bVisitedCharStyleName = false;
3069 const Reference< XMultiPropertySet > xMultiPropertySet( rPropSet, UNO_QUERY );
3070 if ( xMultiPropertySet.is() )
3072 sal_uInt32 nCount = 0;
3073 Sequence< OUString > aPropertyNames( 6 );
3074 OUString* pArray = aPropertyNames.getArray();
3076 if ( rPropSetInfo->hasPropertyByName( sServerMap ) )
3079 pArray[ nCount++ ] = sServerMap;
3081 if ( rPropSetInfo->hasPropertyByName( sHyperLinkName ) )
3083 bHyperLinkName = true;
3084 pArray[ nCount++ ] = sHyperLinkName;
3086 if ( rPropSetInfo->hasPropertyByName( sHyperLinkTarget ) )
3088 bHyperLinkTarget = true;
3089 pArray[ nCount++ ] = sHyperLinkTarget;
3091 if ( rPropSetInfo->hasPropertyByName( sHyperLinkURL ) )
3093 bHyperLinkURL = true;
3094 pArray[ nCount++ ] = sHyperLinkURL;
3096 if ( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) )
3098 bUnvisitedCharStyleName = true;
3099 pArray[ nCount++ ] = sUnvisitedCharStyleName;
3101 if ( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) )
3103 bVisitedCharStyleName = true;
3104 pArray[ nCount++ ] = sVisitedCharStyleName;
3107 aPropertyNames.realloc( nCount );
3111 Sequence< PropertyState > aPropertyStates( nCount );
3112 PropertyState* pStateArray = aPropertyStates.getArray();
3114 if ( rPropState.is() )
3115 aPropertyStates = rPropState->getPropertyStates( aPropertyNames );
3117 Sequence< Any > aPropertyValues ( xMultiPropertySet->getPropertyValues( aPropertyNames ) );
3118 Any* pValueArray = aPropertyValues.getArray();
3120 sal_uInt32 nIdx = 0;
3124 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3126 bServerMap = *(sal_Bool *)pValueArray[ nIdx ].getValue();
3132 if ( bHyperLinkName )
3134 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3136 pValueArray[ nIdx ] >>= sName;
3137 if( sName.getLength() > 0 )
3142 if ( bHyperLinkTarget )
3144 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3146 pValueArray[ nIdx ] >>= sTargetFrame;
3147 if( sTargetFrame.getLength() )
3152 if ( bHyperLinkURL )
3154 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3156 pValueArray[ nIdx ] >>= sHRef;
3157 if( sHRef.getLength() > 0 )
3162 if ( bUnvisitedCharStyleName )
3164 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3166 pValueArray[ nIdx ] >>= sUStyleName;
3167 if( sUStyleName.getLength() )
3172 if ( bVisitedCharStyleName )
3174 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] )
3176 pValueArray[ nIdx ] >>= sVStyleName;
3177 if( sVStyleName.getLength() )
3186 if( rPropSetInfo
->hasPropertyByName( sHyperLinkURL
) &&
3187 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3188 rPropState
->getPropertyState( sHyperLinkURL
) ) )
3190 rPropSet
->getPropertyValue( sHyperLinkURL
) >>= sHRef
;
3192 if( sHRef
.getLength() > 0 )
3196 if( rPropSetInfo
->hasPropertyByName( sHyperLinkName
) &&
3197 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3198 rPropState
->getPropertyState( sHyperLinkName
) ) )
3200 rPropSet
->getPropertyValue( sHyperLinkName
) >>= sName
;
3201 if( sName
.getLength() > 0 )
3205 if( rPropSetInfo
->hasPropertyByName( sHyperLinkTarget
) &&
3206 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3207 rPropState
->getPropertyState( sHyperLinkTarget
) ) )
3209 rPropSet
->getPropertyValue( sHyperLinkTarget
) >>= sTargetFrame
;
3210 if( sTargetFrame
.getLength() )
3214 if( rPropSetInfo
->hasPropertyByName( sServerMap
) &&
3215 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3216 rPropState
->getPropertyState( sServerMap
) ) )
3218 bServerMap
= *(sal_Bool
*)rPropSet
->getPropertyValue( sServerMap
).getValue();
3223 if( rPropSetInfo
->hasPropertyByName( sUnvisitedCharStyleName
) &&
3224 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3225 rPropState
->getPropertyState( sUnvisitedCharStyleName
) ) )
3227 rPropSet
->getPropertyValue( sUnvisitedCharStyleName
) >>= sUStyleName
;
3228 if( sUStyleName
.getLength() )
3232 if( rPropSetInfo
->hasPropertyByName( sVisitedCharStyleName
) &&
3233 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3234 rPropState
->getPropertyState( sVisitedCharStyleName
) ) )
3236 rPropSet
->getPropertyValue( sVisitedCharStyleName
) >>= sVStyleName
;
3237 if( sVStyleName
.getLength() )
3243 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
3244 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, GetExport().GetRelativeReference( sHRef
) );
3246 if( sName
.getLength() > 0 )
3247 GetExport().AddAttribute( XML_NAMESPACE_OFFICE
, XML_NAME
, sName
);
3249 if( sTargetFrame
.getLength() )
3251 GetExport().AddAttribute( XML_NAMESPACE_OFFICE
,
3252 XML_TARGET_FRAME_NAME
, sTargetFrame
);
3253 enum XMLTokenEnum eTok
=
3254 sTargetFrame
.equalsAsciiL( "_blank", sizeof("_blank")-1 )
3255 ? XML_NEW
: XML_REPLACE
;
3256 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_SHOW
, eTok
);
3260 GetExport().AddAttribute( XML_NAMESPACE_OFFICE
,
3261 XML_SERVER_MAP
, XML_TRUE
);
3263 if( sUStyleName
.getLength() )
3264 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
3265 XML_STYLE_NAME
, GetExport().EncodeStyleName( sUStyleName
) );
3267 if( sVStyleName
.getLength() )
3268 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
3269 XML_VISITED_STYLE_NAME
, GetExport().EncodeStyleName( sVStyleName
) );
3275 void XMLTextParagraphExport::exportTextRange(
3276 const Reference
< XTextRange
> & rTextRange
,
3277 sal_Bool bAutoStyles
,
3278 sal_Bool
& rPrevCharIsSpace
)
3280 Reference
< XPropertySet
> xPropSet( rTextRange
, UNO_QUERY
);
3283 Add( XML_STYLE_FAMILY_TEXT_TEXT
, xPropSet
);
3287 sal_Bool bHyperlink
= sal_False
;
3288 sal_Bool bIsUICharStyle
= sal_False
;
3289 sal_Bool bHasAutoStyle
= sal_False
;
3291 OUString
sStyle(FindTextStyleAndHyperlink( xPropSet
, bHyperlink
,
3292 bIsUICharStyle
, bHasAutoStyle
));
3294 Reference
< XPropertySetInfo
> xPropSetInfo
;
3297 Reference
< XPropertyState
> xPropState( xPropSet
, UNO_QUERY
);
3298 xPropSetInfo
.set(xPropSet
->getPropertySetInfo());
3299 bHyperlink
= addHyperlinkAttributes( xPropSet
, xPropState
, xPropSetInfo
);
3301 SvXMLElementExport
aElem( GetExport(), bHyperlink
, XML_NAMESPACE_TEXT
,
3302 XML_A
, sal_False
, sal_False
);
3305 // export events (if supported)
3306 OUString
sHyperLinkEvents(RTL_CONSTASCII_USTRINGPARAM(
3307 "HyperLinkEvents"));
3308 if (xPropSetInfo
->hasPropertyByName(sHyperLinkEvents
))
3310 Reference
<XNameReplace
> xName(xPropSet
->getPropertyValue(sHyperLinkEvents
), uno::UNO_QUERY
);
3311 GetExport().GetEventExport().Export(xName
, sal_False
);
3316 XMLTextCharStyleNamesElementExport
aCharStylesExport(
3317 GetExport(), bIsUICharStyle
&&
3318 aCharStyleNamesPropInfoCache
.hasProperty(
3319 xPropSet
, xPropSetInfo
), bHasAutoStyle
,
3320 xPropSet
, sCharStyleNames
);
3322 OUString
aText(rTextRange
->getString());
3323 if( sStyle
.getLength() )
3324 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
3325 GetExport().EncodeStyleName( sStyle
) );
3327 // in a block to make sure it is destroyed before the text:a element
3328 SvXMLElementExport
aElement( GetExport(), sStyle
.getLength() > 0,
3329 XML_NAMESPACE_TEXT
, XML_SPAN
, sal_False
,
3331 exportText( aText
, rPrevCharIsSpace
);
3337 void XMLTextParagraphExport::exportText( const OUString
& rText
,
3338 sal_Bool
& rPrevCharIsSpace
)
3340 sal_Int32 nExpStartPos
= 0L;
3341 sal_Int32 nEndPos
= rText
.getLength();
3342 sal_Int32 nSpaceChars
= 0;
3343 for( sal_Int32 nPos
= 0; nPos
< nEndPos
; nPos
++ )
3345 sal_Unicode cChar
= rText
[nPos
];
3346 sal_Bool bExpCharAsText
= sal_True
;
3347 sal_Bool bExpCharAsElement
= sal_False
;
3348 sal_Bool bCurrCharIsSpace
= sal_False
;
3353 // These characters are exported as text.
3354 bExpCharAsElement
= sal_True
;
3355 bExpCharAsText
= sal_False
;
3358 break; // legal character
3359 case 0x0020: // Blank
3360 if( rPrevCharIsSpace
)
3362 // If the previous character is a space character,
3363 // too, export a special space element.
3364 bExpCharAsText
= sal_False
;
3366 bCurrCharIsSpace
= sal_True
;
3369 if( cChar
< 0x0020 )
3372 OSL_ENSURE( txtparae_bContainsIllegalCharacters
||
3374 "illegal character in text content" );
3375 txtparae_bContainsIllegalCharacters
= sal_True
;
3377 bExpCharAsText
= sal_False
;
3382 // If the current character is not exported as text
3383 // the text that has not been exported by now has to be exported now.
3384 if( nPos
> nExpStartPos
&& !bExpCharAsText
)
3386 DBG_ASSERT( 0==nSpaceChars
, "pending spaces" );
3387 OUString
sExp( rText
.copy( nExpStartPos
, nPos
- nExpStartPos
) );
3388 GetExport().Characters( sExp
);
3389 nExpStartPos
= nPos
;
3392 // If there are spaces left that have not been exported and the
3393 // current chracter is not a space , the pending spaces have to be
3395 if( nSpaceChars
> 0 && !bCurrCharIsSpace
)
3397 DBG_ASSERT( nExpStartPos
== nPos
, " pending characters" );
3399 if( nSpaceChars
> 1 )
3401 OUStringBuffer sTmp
;
3402 sTmp
.append( (sal_Int32
)nSpaceChars
);
3403 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_C
,
3404 sTmp
.makeStringAndClear() );
3407 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
3408 XML_S
, sal_False
, sal_False
);
3413 // If the current character has to be exported as a special
3414 // element, the elemnt will be exported now.
3415 if( bExpCharAsElement
)
3421 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
3428 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
3429 XML_LINE_BREAK
, sal_False
,
3436 // If the current character is a space, and the previous one
3437 // is a space, too, the number of pending spaces is incremented
3439 if( bCurrCharIsSpace
&& rPrevCharIsSpace
)
3441 rPrevCharIsSpace
= bCurrCharIsSpace
;
3443 // If the currect character is not exported as text, the start
3444 // position for text is the position behind the current position.
3445 if( !bExpCharAsText
)
3447 DBG_ASSERT( nExpStartPos
== nPos
, "wrong export start pos" );
3448 nExpStartPos
= nPos
+1;
3452 if( nExpStartPos
< nEndPos
)
3454 DBG_ASSERT( 0==nSpaceChars
, " pending spaces " );
3455 OUString
sExp( rText
.copy( nExpStartPos
, nEndPos
- nExpStartPos
) );
3456 GetExport().Characters( sExp
);
3459 // If there are some spaces left, they have to be exported now.
3460 if( nSpaceChars
> 0 )
3462 if( nSpaceChars
> 1 )
3464 OUStringBuffer sTmp
;
3465 sTmp
.append( (sal_Int32
)nSpaceChars
);
3466 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_C
,
3467 sTmp
.makeStringAndClear() );
3470 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, XML_S
,
3471 sal_False
, sal_False
);
3475 void XMLTextParagraphExport::exportTextDeclarations()
3477 pFieldExport
->ExportFieldDeclarations();
3479 // get XPropertySet from the document and ask for AutoMarkFileURL.
3480 // If it exists, export the auto-mark-file element.
3481 Reference
<XPropertySet
> xPropertySet( GetExport().GetModel(), UNO_QUERY
);
3482 if (xPropertySet
.is())
3485 OUString
sIndexAutoMarkFileURL(
3486 RTL_CONSTASCII_USTRINGPARAM("IndexAutoMarkFileURL"));
3487 if (xPropertySet
->getPropertySetInfo()->hasPropertyByName(
3488 sIndexAutoMarkFileURL
))
3490 xPropertySet
->getPropertyValue(sIndexAutoMarkFileURL
) >>= sUrl
;
3491 if (sUrl
.getLength() > 0)
3493 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
,
3494 GetExport().GetRelativeReference(sUrl
) );
3495 SvXMLElementExport
aAutoMarkElement(
3496 GetExport(), XML_NAMESPACE_TEXT
,
3497 XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE
,
3498 sal_True
, sal_True
);
3504 void XMLTextParagraphExport::exportTextDeclarations(
3505 const Reference
<XText
> & rText
)
3507 pFieldExport
->ExportFieldDeclarations(rText
);
3510 void XMLTextParagraphExport::exportUsedDeclarations( sal_Bool bOnlyUsed
)
3512 pFieldExport
->SetExportOnlyUsedFieldDeclarations( bOnlyUsed
);
3516 void XMLTextParagraphExport::exportTrackedChanges(sal_Bool bAutoStyles
)
3518 if (NULL
!= pRedlineExport
)
3519 pRedlineExport
->ExportChangesList( bAutoStyles
);
3522 void XMLTextParagraphExport::exportTrackedChanges(
3523 const Reference
<XText
> & rText
,
3524 sal_Bool bAutoStyle
)
3526 if (NULL
!= pRedlineExport
)
3527 pRedlineExport
->ExportChangesList(rText
, bAutoStyle
);
3530 void XMLTextParagraphExport::recordTrackedChangesForXText(
3531 const Reference
<XText
> & rText
)
3533 if (NULL
!= pRedlineExport
)
3534 pRedlineExport
->SetCurrentXText(rText
);
3537 void XMLTextParagraphExport::recordTrackedChangesNoXText()
3539 if (NULL
!= pRedlineExport
)
3540 pRedlineExport
->SetCurrentXText();
3544 void XMLTextParagraphExport::exportTextAutoStyles()
3546 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_PARAGRAPH
,
3547 GetExport().GetDocHandler(),
3548 GetExport().GetMM100UnitConverter(),
3549 GetExport().GetNamespaceMap() );
3551 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_TEXT
,
3552 GetExport().GetDocHandler(),
3553 GetExport().GetMM100UnitConverter(),
3554 GetExport().GetNamespaceMap() );
3556 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_FRAME
,
3557 GetExport().GetDocHandler(),
3558 GetExport().GetMM100UnitConverter(),
3559 GetExport().GetNamespaceMap() );
3561 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_SECTION
,
3562 GetExport().GetDocHandler(),
3563 GetExport().GetMM100UnitConverter(),
3564 GetExport().GetNamespaceMap() );
3566 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_RUBY
,
3567 GetExport().GetDocHandler(),
3568 GetExport().GetMM100UnitConverter(),
3569 GetExport().GetNamespaceMap() );
3571 pListAutoPool
->exportXML();
3574 void XMLTextParagraphExport::exportRuby(
3575 const Reference
<XPropertySet
> & rPropSet
,
3576 sal_Bool bAutoStyles
)
3578 // early out: a collapsed ruby makes no sense
3579 if (*(sal_Bool
*)rPropSet
->getPropertyValue(sIsCollapsed
).getValue())
3583 sal_Bool bStart
= (*(sal_Bool
*)rPropSet
->getPropertyValue(sIsStart
).getValue());
3589 Add( XML_STYLE_FAMILY_TEXT_RUBY
, rPropSet
);
3593 // prepare element names
3594 OUString
aRuby(GetXMLToken(XML_RUBY
));
3595 OUString
sTextRuby(GetExport().GetNamespaceMap().
3596 GetQNameByKey(XML_NAMESPACE_TEXT
, aRuby
));
3597 OUString
sRubyBase(GetXMLToken(XML_RUBY_BASE
));
3598 OUString
sTextRubyBase(GetExport().GetNamespaceMap().
3599 GetQNameByKey(XML_NAMESPACE_TEXT
, sRubyBase
));
3605 // we can only start a ruby if none is open
3606 DBG_ASSERT(! bOpenRuby
, "Can't open a ruby inside of ruby!");
3610 // save ruby text + ruby char style
3611 rPropSet
->getPropertyValue(sRubyText
) >>= sOpenRubyText
;
3612 rPropSet
->getPropertyValue(sRubyCharStyleName
) >>= sOpenRubyCharStyle
;
3615 GetExport().CheckAttrList();
3617 OUString
sStyleName(Find( XML_STYLE_FAMILY_TEXT_RUBY
, rPropSet
,
3619 DBG_ASSERT(sStyleName
.getLength() > 0, "I can't find the style!");
3620 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
3621 XML_STYLE_NAME
, sStyleName
);
3623 // export <text:ruby> and <text:ruby-base> start elements
3624 GetExport().StartElement( XML_NAMESPACE_TEXT
, XML_RUBY
, sal_False
);
3625 GetExport().ClearAttrList();
3626 GetExport().StartElement( XML_NAMESPACE_TEXT
, XML_RUBY_BASE
,
3628 bOpenRuby
= sal_True
;
3634 // check for an open ruby
3635 DBG_ASSERT(bOpenRuby
, "Can't close a ruby if none is open!");
3639 // close <text:ruby-base>
3640 GetExport().EndElement(XML_NAMESPACE_TEXT
, XML_RUBY_BASE
,
3643 // write the ruby text (with char style)
3645 if (sOpenRubyCharStyle
.getLength() > 0)
3646 GetExport().AddAttribute(
3647 XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
3648 GetExport().EncodeStyleName( sOpenRubyCharStyle
) );
3650 SvXMLElementExport
aRubyElement(
3651 GetExport(), XML_NAMESPACE_TEXT
, XML_RUBY_TEXT
,
3652 sal_False
, sal_False
);
3654 GetExport().Characters(sOpenRubyText
);
3657 // and finally, close the ruby
3658 GetExport().EndElement(XML_NAMESPACE_TEXT
, XML_RUBY
, sal_False
);
3659 bOpenRuby
= sal_False
;
3664 // FIXME: this is untested
3665 void XMLTextParagraphExport::exportMeta(
3666 const Reference
<XPropertySet
> & i_xMeta
,
3667 sal_Bool i_bAutoStyles
, sal_Bool i_isProgress
)
3669 bool doExport(!i_bAutoStyles
); // do not export element if autostyles
3670 // check version >= 1.2
3671 switch (GetExport().getDefaultVersion()) {
3672 case SvtSaveOptions::ODFVER_011
: // fall thru
3673 case SvtSaveOptions::ODFVER_010
: doExport
= false; break;
3677 const Reference
< XEnumerationAccess
> xEA( i_xMeta
, UNO_QUERY_THROW
);
3678 const Reference
< XEnumeration
> xTextEnum( xEA
->createEnumeration() );
3682 const Reference
<rdf::XMetadatable
> xMeta( i_xMeta
, UNO_QUERY_THROW
);
3683 const Reference
<XTextContent
> xTextContent( i_xMeta
, UNO_QUERY_THROW
);
3685 // text:meta with neither xml:id nor RDFa is invalid
3686 xMeta
->ensureMetadataReference();
3688 // xml:id and RDFa for RDF metadata
3689 GetExport().AddAttributeXmlId(xMeta
);
3690 GetExport().AddAttributesRDFa(xTextContent
);
3693 SvXMLElementExport
aElem( GetExport(), doExport
,
3694 XML_NAMESPACE_TEXT
, XML_META
, sal_False
, sal_False
);
3696 // recurse to export content
3697 exportTextRangeEnumeration( xTextEnum
, i_bAutoStyles
, i_isProgress
);
3701 void XMLTextParagraphExport::PreventExportOfControlsInMuteSections(
3702 const Reference
<XIndexAccess
> & rShapes
,
3703 UniReference
<xmloff::OFormLayerXMLExport
> xFormExport
)
3705 // check parameters ad pre-conditions
3706 if( ( ! rShapes
.is() ) || ( ! xFormExport
.is() ) )
3708 // if we don't have shapes or a form export, there's nothing to do
3711 DBG_ASSERT( pSectionExport
!= NULL
, "We need the section export." );
3713 Reference
<XEnumeration
> xShapesEnum
= pBoundFrameSets
->GetShapes()->createEnumeration();
3714 if(!xShapesEnum
.is())
3716 while( xShapesEnum
->hasMoreElements() )
3718 // now we need to check
3719 // 1) if this is a control shape, and
3720 // 2) if it's in a mute section
3721 // if both answers are 'yes', notify the form layer export
3723 // we join accessing the shape and testing for control
3724 Reference
<XControlShape
> xControlShape(xShapesEnum
->nextElement(), UNO_QUERY
);
3725 if( xControlShape
.is() )
3727 // Reference<XPropertySet> xPropSet( xControlShape, UNO_QUERY );
3728 // Reference<XTextContent> xTextContent;
3729 // xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) ) ) >>= xTextContent;
3731 Reference
<XTextContent
> xTextContent( xControlShape
, UNO_QUERY
);
3732 if( xTextContent
.is() )
3734 if( pSectionExport
->IsMuteSection( xTextContent
, sal_False
) )
3736 // Ah, we've found a shape that
3737 // 1) is a control shape
3738 // 2) is anchored in a mute section
3739 // so: don't export it!
3740 xFormExport
->excludeFromExport(
3741 xControlShape
->getControl() );
3743 // else: not in mute section -> should be exported -> nothing
3746 // else: no anchor -> ignore
3748 // else: no control shape -> nothing to do
3751 sal_Int32
XMLTextParagraphExport::GetHeadingLevel( const OUString
& rStyleName
)
3753 if( !pHeadingStyles
)
3755 pHeadingStyles
= new XMLStringVector
;
3756 SvxXMLNumRuleExport::GetOutlineStyles( *pHeadingStyles
,
3757 GetExport().GetModel() );
3759 for( XMLStringVector::size_type i
=0; i
< pHeadingStyles
->size(); ++i
)
3761 if( (*pHeadingStyles
)[i
] == rStyleName
)
3762 return static_cast < sal_Int32
>( i
);
3768 // --> OD 2008-05-08 #refactorlists#
3769 void XMLTextParagraphExport::PushNewTextListsHelper()
3771 mpTextListsHelper
= new XMLTextListsHelper();
3772 maTextListsHelperStack
.push_back( mpTextListsHelper
);
3775 void XMLTextParagraphExport::PopTextListsHelper()
3777 delete mpTextListsHelper
;
3778 mpTextListsHelper
= 0;
3779 maTextListsHelperStack
.pop_back();
3780 if ( !maTextListsHelperStack
.empty() )
3782 mpTextListsHelper
= maTextListsHelperStack
.back();