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: xmlexp.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_sw.hxx"
35 #include <com/sun/star/text/XTextDocument.hpp>
36 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/container/XNameContainer.hpp>
39 #include <com/sun/star/container/XIndexContainer.hpp>
40 #include <com/sun/star/uno/RuntimeException.hpp>
41 #include <com/sun/star/xforms/XFormsSupplier.hpp>
42 #include <svx/svdmodel.hxx>
43 #include <svx/svdpage.hxx>
46 #include <svx/xmlgrhlp.hxx>
48 #include <svx/xmleohlp.hxx>
49 #include <svx/xmlgrhlp.hxx>
51 #include <svx/eeitem.hxx>
52 #include <svx/svddef.hxx>
53 #include <xmloff/nmspmap.hxx>
54 #include <xmloff/xmlnmspe.hxx>
55 #include <svx/xmlcnitm.hxx>
56 #include <xmloff/ProgressBarHelper.hxx>
57 #include <xmloff/xmluconv.hxx>
58 #include <xmloff/xformsexport.hxx>
61 #include <swmodule.hxx>
63 #include <docstat.hxx>
66 #include <xmltexte.hxx>
68 #include <sfx2/viewsh.hxx>
69 #ifndef _COMPHELPER_PROCESSFACTORYHXX_
70 #include <comphelper/processfactory.hxx>
73 #include <svx/unolingu.hxx>
74 #include <svx/forbiddencharacterstable.hxx>
75 #include <ForbiddenCharactersEnum.hxx>
77 // for locking SolarMutex: svapp + mutex
78 #include <vcl/svapp.hxx>
79 #include <vos/mutex.hxx>
81 // --> OD 2007-03-30 #i73788#
82 #include <pausethreadstarting.hxx>
85 using ::rtl::OUString
;
86 using namespace ::com::sun::star
;
87 using namespace ::com::sun::star::frame
;
88 using namespace ::com::sun::star::lang
;
89 using namespace ::com::sun::star::xml::sax
;
90 using namespace ::com::sun::star::uno
;
91 using namespace ::com::sun::star::text
;
92 using namespace ::com::sun::star::container
;
93 using namespace ::com::sun::star::document
;
94 using namespace ::com::sun::star::drawing
;
95 using namespace ::com::sun::star::beans
;
96 using namespace ::com::sun::star::i18n
;
97 using namespace ::com::sun::star::xforms
;
98 using namespace ::xmloff::token
;
101 void SwXMLExport::SetCurPaM( SwPaM
& rPaM
, sal_Bool bWhole
, sal_Bool bTabOnly
)
105 pCurPaM
= new SwPaM( *rPaM
.End(), *rPaM
.Start() );
109 *pCurPaM
->GetPoint() = *rPaM
.Start();
110 *pCurPaM
->GetMark() = *rPaM
.End();
113 // Set PaM to table/section start node if whole doc should be exported
116 SwTableNode
*pTblNd
= pCurPaM
->GetNode()->FindTableNode();
119 pCurPaM
->GetPoint()->nNode
= *pTblNd
;
122 pCurPaM
->GetMark()->nNode
= *pTblNd
->EndOfSectionNode();
125 SwSectionNode
* pSectNd
= pCurPaM
->GetNode()->FindSectionNode();
128 pCurPaM
->GetPoint()->nNode
= *pSectNd
;
130 // SwSectionNode::FindSectionNode() returns the section node itself
131 pSectNd
= pSectNd
->StartOfSectionNode()->FindSectionNode();
138 SwXMLExport::SwXMLExport(
139 const uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory
,
140 sal_uInt16 nExportFlags
)
141 : SvXMLExport( xServiceFactory
, MAP_INCH
, XML_TEXT
, nExportFlags
),
146 pTableItemMapper( 0 ),
149 bExportWholeDoc( bExpWholeDoc
),
150 bExportFirstTableOnly( bExpFirstTableOnly
),
153 bShowProgress( sal_True
),
154 sNumberFormat(RTL_CONSTASCII_USTRINGPARAM("NumberFormat")),
155 sIsProtected(RTL_CONSTASCII_USTRINGPARAM("IsProtected")),
156 sCell(RTL_CONSTASCII_USTRINGPARAM("Cell"))
163 SwXMLExport::SwXMLExport(
164 const uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory
,
165 const Reference
< XModel
>& rModel
,
167 const OUString
& rFileName
,
168 const Reference
< XDocumentHandler
> & rHandler
,
169 const Reference
< XGraphicObjectResolver
> & rEmbeddedGrfObjs
,
170 sal_Bool bExpWholeDoc
, sal_Bool bExpFirstTableOnly
,
172 : SvXMLExport( xServiceFactory
, rFileName
, rHandler
, rModel
, rEmbeddedGrfObjs
,
173 SW_MOD()->GetMetric( rPaM
.GetDoc()->get(IDocumentSettingAccess::HTML_MODE
) ) ),
176 pTableItemMapper( 0 ),
178 bExportWholeDoc( bExpWholeDoc
),
179 bExportFirstTableOnly( bExpFirstTableOnly
),
180 bShowProgress( bShowProg
),
181 sNumberFormat(RTL_CONSTASCII_USTRINGPARAM("NumberFormat")),
182 sIsProtected(RTL_CONSTASCII_USTRINGPARAM("IsProtected")),
183 sCell(RTL_CONSTASCII_USTRINGPARAM("Cell"))
189 void SwXMLExport::setBlockMode()
195 sal_uInt32
SwXMLExport::exportDoc( enum XMLTokenEnum eClass
)
197 if( !GetModel().is() )
198 return ERR_SWG_WRITE_ERROR
;
200 // --> OD 2007-03-30 #i73788#
201 SwPauseThreadStarting aPauseThreadStarting
;
204 Reference
< XTextDocument
> xTextDoc( GetModel(), UNO_QUERY
);
205 Reference
< XText
> xText
= xTextDoc
->getText();
206 Reference
<XUnoTunnel
> xTextTunnel( xText
, UNO_QUERY
);
207 ASSERT( xTextTunnel
.is(), "missing XUnoTunnel for Cursor" );
208 if( !xTextTunnel
.is() )
209 return ERR_SWG_WRITE_ERROR
;
211 // from here, we use core interfaces -> lock Solar-Mutex (#91949#)
212 vos::OGuard
aGuard(Application::GetSolarMutex());
215 Reference
<XPropertySet
> rInfoSet
= getExportInfo();
218 OUString
sAutoTextMode(
219 RTL_CONSTASCII_USTRINGPARAM("AutoTextMode"));
220 if( rInfoSet
->getPropertySetInfo()->hasPropertyByName(
223 Any aAny
= rInfoSet
->getPropertyValue(sAutoTextMode
);
224 if( aAny
.getValueType() == ::getBooleanCppuType() &&
225 *static_cast<const sal_Bool
*>(aAny
.getValue()) )
231 SwXText
*pText
= reinterpret_cast< SwXText
* >(
232 sal::static_int_cast
< sal_IntPtr
>( xTextTunnel
->getSomething( SwXText::getUnoTunnelId() )));
233 ASSERT( pText
, "SwXText missing" );
235 return ERR_SWG_WRITE_ERROR
;
237 SwDoc
*pDoc
= pText
->GetDoc();
239 sal_Bool bExtended
= sal_False
;
240 if( (getExportFlags() & (EXPORT_FONTDECLS
|EXPORT_STYLES
|
241 EXPORT_MASTERSTYLES
|EXPORT_CONTENT
)) != 0 )
243 GetTextParagraphExport()->SetBlockMode( bBlock
);
245 const SfxPoolItem
* pItem
;
246 const SfxItemPool
& rPool
= pDoc
->GetAttrPool();
247 sal_uInt16 aWhichIds
[5] = { RES_UNKNOWNATR_CONTAINER
,
248 RES_TXTATR_UNKNOWN_CONTAINER
,
249 SDRATTR_XMLATTRIBUTES
,
251 EE_CHAR_XMLATTRIBS
};
253 sal_uInt16 nWhichIds
= rPool
.GetSecondaryPool() ? 5 : 2;
254 for( sal_uInt16 j
=0; j
< nWhichIds
; j
++ )
256 sal_uInt16 nWhichId
= aWhichIds
[j
];
257 sal_uInt16 i
=0, nItems
= rPool
.GetItemCount( nWhichId
);
258 for( i
= 0; i
< nItems
; ++i
)
260 if( 0 != (pItem
= rPool
.GetItem( nWhichId
, i
) ) )
262 const SvXMLAttrContainerItem
*pUnknown
=
263 PTR_CAST( SvXMLAttrContainerItem
, pItem
);
264 ASSERT( pUnknown
, "illegal attribute container item" );
265 if( pUnknown
&& (pUnknown
->GetAttrCount() > 0) )
267 sal_uInt16 nIdx
= pUnknown
->GetFirstNamespaceIndex();
268 while( USHRT_MAX
!= nIdx
)
270 const OUString
& rPrefix
=
271 pUnknown
->GetPrefix( nIdx
);
272 _GetNamespaceMap().Add( rPrefix
,
273 pUnknown
->GetNamespace( nIdx
),
274 XML_NAMESPACE_UNKNOWN
);
275 nIdx
= pUnknown
->GetNextNamespaceIndex( nIdx
);
277 bExtended
= sal_True
;
285 SvXMLUnitConverter::GetMapUnit( SW_MOD()->GetMetric(pDoc
->get(IDocumentSettingAccess::HTML_MODE
)) );
286 if( GetMM100UnitConverter().getXMLMeasureUnit() != eUnit
)
288 GetMM100UnitConverter().setXMLMeasureUnit( eUnit
);
289 pTwipUnitConv
->setXMLMeasureUnit( eUnit
);
292 SetExtended( bExtended
);
294 SwDocStat
aDocStat( pDoc
->GetDocStat() );
295 if( (getExportFlags() & EXPORT_META
) != 0 )
297 // Update doc stat, so that correct values are exported and
298 // the progress works correctly.
299 if( aDocStat
.bModified
)
300 pDoc
->UpdateDocStat( aDocStat
);
302 SfxObjectShell
* pObjSh
= pDoc
->GetDocShell();
304 pObjSh
->UpdateDocInfoForSave(); // update information
308 ProgressBarHelper
*pProgress
= GetProgressBarHelper();
309 if( -1 == pProgress
->GetReference() )
311 // progress isn't initialized:
312 // We assume that the whole doc is exported, and the following
314 // - meta information: 2
315 // - settings: 4 (TODO: not now!)
316 // - styles (except page styles): 2
317 // - page styles: 2 (TODO: not now!) + 2 for each paragraph
318 // - paragraph: 2 (1 for automatic styles and one for content)
320 // If required, update doc stat, so that
321 // the progress works correctly.
322 if( aDocStat
.bModified
)
323 pDoc
->UpdateDocStat( aDocStat
);
325 // count each item once, and then multiply by two to reach the
326 // figures given above
327 // The styles in pDoc also count the default style that never
328 // gets exported -> subtract one.
330 nRef
+= pDoc
->GetCharFmts()->Count() - 1;
331 nRef
+= pDoc
->GetFrmFmts()->Count() - 1;
332 nRef
+= pDoc
->GetTxtFmtColls()->Count() - 1;
333 // nRef += pDoc->GetPageDescCnt();
334 nRef
+= aDocStat
.nPara
;
335 pProgress
->SetReference( 2*nRef
);
336 pProgress
->SetValue( 0 );
340 if( (getExportFlags() & (EXPORT_MASTERSTYLES
|EXPORT_CONTENT
)) != 0 )
342 //Auf die Korrektheit der OrdNums sind wir schon angewiesen.
343 SdrModel
* pModel
= pDoc
->GetDrawModel();
345 pModel
->GetPage( 0 )->RecalcObjOrdNums();
348 // adjust document class (eClass)
349 if (pDoc
->get(IDocumentSettingAccess::GLOBAL_DOCUMENT
))
351 eClass
= XML_TEXT_GLOBAL
;
353 // additionally, we take care of the save-linked-sections-thingy
354 mbSaveLinkedSections
= pDoc
->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS
);
356 // MIB: 03/26/04: The Label information is saved in the settings, so
357 // we don't need it here.
358 // else: keep default pClass that we received
360 SvXMLGraphicHelper
*pGraphicResolver
= 0;
361 if( !GetGraphicResolver().is() )
363 pGraphicResolver
= SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_WRITE
);
364 Reference
< XGraphicObjectResolver
> xGraphicResolver( pGraphicResolver
);
365 SetGraphicResolver( xGraphicResolver
);
368 SvXMLEmbeddedObjectHelper
*pEmbeddedResolver
= 0;
369 if( !GetEmbeddedResolver().is() )
371 SfxObjectShell
*pPersist
= pDoc
->GetPersist();
374 pEmbeddedResolver
= SvXMLEmbeddedObjectHelper::Create(
376 EMBEDDEDOBJECTHELPER_MODE_WRITE
);
377 Reference
< XEmbeddedObjectResolver
> xEmbeddedResolver( pEmbeddedResolver
);
378 SetEmbeddedResolver( xEmbeddedResolver
);
382 // set redline mode if we export STYLES or CONTENT, unless redline
383 // mode is taken care of outside (through info XPropertySet)
384 sal_Bool bSaveRedline
=
385 ( (getExportFlags() & (EXPORT_CONTENT
|EXPORT_STYLES
)) != 0 );
388 // if the info property set has a ShowChanges property,
389 // then change tracking is taken care of on the outside,
390 // so we don't have to!
391 Reference
<XPropertySet
> rInfoSet
= getExportInfo();
394 OUString
sShowChanges( RTL_CONSTASCII_USTRINGPARAM("ShowChanges"));
395 bSaveRedline
= ! rInfoSet
->getPropertySetInfo()->hasPropertyByName(
399 sal_uInt16 nRedlineMode
= 0;
400 bSavedShowChanges
= IDocumentRedlineAccess::IsShowChanges( pDoc
->GetRedlineMode() );
403 // now save and switch redline mode
404 nRedlineMode
= pDoc
->GetRedlineMode();
405 pDoc
->SetRedlineMode(
406 (RedlineMode_t
)(( nRedlineMode
& nsRedlineMode_t::REDLINE_SHOW_MASK
) | nsRedlineType_t::REDLINE_INSERT
));
409 sal_uInt32 nRet
= SvXMLExport::exportDoc( eClass
);
411 // now we can restore the redline mode (if we changed it previously)
414 pDoc
->SetRedlineMode( (RedlineMode_t
)(nRedlineMode
));
418 if( pGraphicResolver
)
419 SvXMLGraphicHelper::Destroy( pGraphicResolver
);
420 if( pEmbeddedResolver
)
421 SvXMLEmbeddedObjectHelper::Destroy( pEmbeddedResolver
);
423 ASSERT( !pTableLines
, "there are table columns infos left" );
428 XMLTextParagraphExport
* SwXMLExport::CreateTextParagraphExport()
430 return new SwXMLTextParagraphExport( *this, *GetAutoStylePool().get() );
433 XMLShapeExport
* SwXMLExport::CreateShapeExport()
435 XMLShapeExport
* pShapeExport
= new XMLShapeExport( *this, XMLTextParagraphExport::CreateShapeExtPropMapper( *this ) );
436 Reference
< XDrawPageSupplier
> xDPS( GetModel(), UNO_QUERY
);
439 Reference
< XShapes
> xShapes( xDPS
->getDrawPage(), UNO_QUERY
);
440 pShapeExport
->seekShapes( xShapes
);
446 __EXPORT
SwXMLExport::~SwXMLExport()
452 void SwXMLExport::_ExportFontDecls()
454 GetFontAutoStylePool(); // make sure the pool is created
455 SvXMLExport::_ExportFontDecls();
458 #define NUM_EXPORTED_VIEW_SETTINGS 11
459 void SwXMLExport::GetViewSettings(Sequence
<PropertyValue
>& aProps
)
461 Reference
< XMultiServiceFactory
> xServiceFactory
=
462 comphelper::getProcessServiceFactory();
463 ASSERT( xServiceFactory
.is(),
464 "XMLReader::Read: got no service manager" );
465 if( !xServiceFactory
.is() )
468 aProps
.realloc( NUM_EXPORTED_VIEW_SETTINGS
);
469 // Currently exporting 9 properties
470 PropertyValue
*pValue
= aProps
.getArray();
471 sal_Int32 nIndex
= 0;
473 Reference
< XIndexContainer
> xBox (xServiceFactory
->createInstance
474 (OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), UNO_QUERY
);
477 pValue
[nIndex
].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM ( "Views") );
478 pValue
[nIndex
++].Value
<<= Reference
< XIndexAccess
> ( xBox
, UNO_QUERY
);
481 Reference
< XText
> xText
;
484 if( GetModel().is() )
486 Reference
< XTextDocument
> xTextDoc( GetModel(), UNO_QUERY
);
487 xText
= xTextDoc
->getText();
488 Reference
<XUnoTunnel
> xTextTunnel( xText
, UNO_QUERY
);
489 ASSERT( xTextTunnel
.is(), "missing XUnoTunnel for Cursor" );
490 if( xTextTunnel
.is() )
492 pText
= reinterpret_cast< SwXText
* >(
493 sal::static_int_cast
< sal_IntPtr
>( xTextTunnel
->getSomething( SwXText::getUnoTunnelId()) ));
494 ASSERT( pText
, "SwXText missing" );
500 aProps
.realloc(nIndex
);
504 SwDoc
*pDoc
= pText
->GetDoc();
505 const Rectangle rRect
=
506 pDoc
->GetDocShell()->GetVisArea( ASPECT_CONTENT
);
507 sal_Bool bTwip
= pDoc
->GetDocShell()->GetMapUnit ( ) == MAP_TWIP
;
509 ASSERT ( bTwip
, "Map unit for visible area is not in TWIPS!" );
511 pValue
[nIndex
].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaTop") );
512 pValue
[nIndex
++].Value
<<= bTwip
? TWIP_TO_MM100 ( rRect
.Top() ) : rRect
.Top();
514 pValue
[nIndex
].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaLeft") );
515 pValue
[nIndex
++].Value
<<= bTwip
? TWIP_TO_MM100 ( rRect
.Left() ) : rRect
.Left();
517 pValue
[nIndex
].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaWidth") );
518 pValue
[nIndex
++].Value
<<= bTwip
? TWIP_TO_MM100 ( rRect
.GetWidth() ) : rRect
.GetWidth();
520 pValue
[nIndex
].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaHeight") );
521 pValue
[nIndex
++].Value
<<= bTwip
? TWIP_TO_MM100 ( rRect
.GetHeight() ) : rRect
.GetHeight();
523 // "show redline mode" cannot simply be read from the document
524 // since it gets changed during execution. If it's in the info
525 // XPropertySet, we take it from there.
526 sal_Bool bShowRedlineChanges
= bSavedShowChanges
;
527 Reference
<XPropertySet
> xInfoSet( getExportInfo() );
530 OUString
sShowChanges( RTL_CONSTASCII_USTRINGPARAM( "ShowChanges" ));
531 if( xInfoSet
->getPropertySetInfo()->hasPropertyByName( sShowChanges
) )
533 bShowRedlineChanges
= *(sal_Bool
*) xInfoSet
->
534 getPropertyValue( sShowChanges
).getValue();
538 pValue
[nIndex
].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM ( "ShowRedlineChanges") );
539 pValue
[nIndex
++].Value
.setValue( &bShowRedlineChanges
, ::getBooleanCppuType() );
541 sal_Bool bInBrowse
= pDoc
->get(IDocumentSettingAccess::BROWSE_MODE
);
542 pValue
[nIndex
].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM ( "InBrowseMode") );
543 pValue
[nIndex
++].Value
.setValue( &bInBrowse
, ::getBooleanCppuType() );
545 if ( nIndex
< NUM_EXPORTED_VIEW_SETTINGS
)
546 aProps
.realloc(nIndex
);
548 #undef NUM_EXPORTED_VIEW_SETTINGS
550 void SwXMLExport::GetConfigurationSettings( Sequence
< PropertyValue
>& rProps
)
552 Reference
< XMultiServiceFactory
> xFac( GetModel(), UNO_QUERY
);
555 Reference
< XPropertySet
> xProps( xFac
->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY
);
557 SvXMLUnitConverter::convertPropertySet( rProps
, xProps
);
561 sal_Int32
SwXMLExport::GetDocumentSpecificSettings( ::std::list
< SettingsGroup
>& _out_rSettings
)
563 // the only doc-specific settings group we know so far are the XForms settings
564 uno::Sequence
<beans::PropertyValue
> aXFormsSettings
;
565 Reference
< XFormsSupplier
> xXFormsSupp( GetModel(), UNO_QUERY
);
566 Reference
< XNameAccess
> xXForms
;
567 if ( xXFormsSupp
.is() )
568 xXForms
= xXFormsSupp
->getXForms().get();
571 getXFormsSettings( xXForms
, aXFormsSettings
);
572 _out_rSettings
.push_back( SettingsGroup( XML_XFORM_MODEL_SETTINGS
, aXFormsSettings
) );
575 return aXFormsSettings
.getLength() + SvXMLExport::GetDocumentSpecificSettings( _out_rSettings
);
578 void SwXMLExport::SetBodyAttributes()
580 Reference
< XTextDocument
> xTextDoc( GetModel(), UNO_QUERY
);
581 Reference
< XText
> xText
= xTextDoc
->getText();
582 // export use of soft page breaks
584 Reference
<XUnoTunnel
> xTextTunnel( xText
, UNO_QUERY
);
585 ASSERT( xTextTunnel
.is(), "missing XUnoTunnel for Cursor" );
586 if( xTextTunnel
.is() )
588 SwXText
*pText
= reinterpret_cast< SwXText
* >(
589 sal::static_int_cast
< sal_IntPtr
>( xTextTunnel
->getSomething( SwXText::getUnoTunnelId() )));
590 ASSERT( pText
, "SwXText missing" );
593 SwDoc
*pDoc
= pText
->GetDoc();
594 if( pDoc
&& pDoc
->GetPageCount() > 1 )
596 sal_Bool bValue
= sal_True
;
597 rtl::OUStringBuffer sBuffer
;
598 GetMM100UnitConverter().convertBool(sBuffer
, bValue
);
599 AddAttribute(XML_NAMESPACE_TEXT
, XML_USE_SOFT_PAGE_BREAKS
,
600 sBuffer
.makeStringAndClear());
608 void SwXMLExport::_ExportContent()
611 Reference
<XDrawPageSupplier
> xDrawPageSupplier(GetModel(), UNO_QUERY
);
612 if (xDrawPageSupplier
.is())
614 // export only if we actually have elements
615 Reference
<XDrawPage
> xPage
= xDrawPageSupplier
->getDrawPage();
618 // #103597# prevent export of form controls which are embedded in
620 Reference
<XIndexAccess
> xIAPage( xPage
, UNO_QUERY
);
621 GetTextParagraphExport()->PreventExportOfControlsInMuteSections(
622 xIAPage
, GetFormExport() );
624 // #i36597# / 2004-12-13 / fs@openoffice.org
625 if ( GetFormExport()->pageContainsForms( xPage
) || GetFormExport()->documentContainsXForms() )
627 ::xmloff::OOfficeFormsExport
aOfficeForms(*this);
629 GetFormExport()->exportXForms();
631 GetFormExport()->seekPage(xPage
);
632 GetFormExport()->exportForms(xPage
);
637 Reference
<XPropertySet
> xPropSet(GetModel(), UNO_QUERY
);
640 OUString
sTwoDigitYear(RTL_CONSTASCII_USTRINGPARAM("TwoDigitYear"));
642 Any aAny
= xPropSet
->getPropertyValue( sTwoDigitYear
);
643 aAny
<<= (sal_Int16
)1930;
649 rtl::OUStringBuffer sBuffer
;
650 GetMM100UnitConverter().convertNumber(sBuffer
, nYear
);
651 AddAttribute(XML_NAMESPACE_TABLE
, XML_NULL_YEAR
, sBuffer
.makeStringAndClear());
652 SvXMLElementExport
aCalcSettings(*this, XML_NAMESPACE_TABLE
, XML_CALCULATION_SETTINGS
, sal_True
, sal_True
);
656 GetTextParagraphExport()->exportTrackedChanges( sal_False
);
657 GetTextParagraphExport()->exportTextDeclarations();
658 Reference
< XTextDocument
> xTextDoc( GetModel(), UNO_QUERY
);
659 Reference
< XText
> xText
= xTextDoc
->getText();
661 GetTextParagraphExport()->exportFramesBoundToPage( bShowProgress
);
662 GetTextParagraphExport()->exportText( xText
, bShowProgress
);
668 // uno component registration
669 // helper functions for export service(s)
673 OUString SAL_CALL
SwXMLExportOOO_getImplementationName() throw()
675 return OUString( RTL_CONSTASCII_USTRINGPARAM(
676 "com.sun.star.comp.Writer.XMLExporter" ) );
679 Sequence
< OUString
> SAL_CALL
SwXMLExportOOO_getSupportedServiceNames()
682 const OUString
aServiceName(SwXMLExportOOO_getImplementationName());
683 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
687 Reference
< XInterface
> SAL_CALL
SwXMLExportOOO_createInstance(
688 const Reference
< XMultiServiceFactory
> & rSMgr
)
691 return (cppu::OWeakObject
*)new SwXMLExport( rSMgr
, EXPORT_ALL
);
694 OUString SAL_CALL
SwXMLExportStylesOOO_getImplementationName() throw()
696 return OUString( RTL_CONSTASCII_USTRINGPARAM(
697 "com.sun.star.comp.Writer.XMLStylesExporter" ) );
700 Sequence
< OUString
> SAL_CALL
SwXMLExportStylesOOO_getSupportedServiceNames()
703 const OUString
aServiceName(SwXMLExportStylesOOO_getImplementationName());
704 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
708 Reference
< XInterface
> SAL_CALL
SwXMLExportStylesOOO_createInstance(
709 const Reference
< XMultiServiceFactory
> & rSMgr
)
712 return (cppu::OWeakObject
*)new SwXMLExport( rSMgr
,
713 EXPORT_STYLES
| EXPORT_MASTERSTYLES
| EXPORT_AUTOSTYLES
|
717 OUString SAL_CALL
SwXMLExportContentOOO_getImplementationName() throw()
719 return OUString( RTL_CONSTASCII_USTRINGPARAM(
720 "com.sun.star.comp.Writer.XMLContentExporter" ) );
723 Sequence
< OUString
> SAL_CALL
SwXMLExportContentOOO_getSupportedServiceNames()
726 const OUString
aServiceName(SwXMLExportContentOOO_getImplementationName());
727 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
731 Reference
< XInterface
> SAL_CALL
SwXMLExportContentOOO_createInstance(
732 const Reference
< XMultiServiceFactory
> & rSMgr
)
735 return (cppu::OWeakObject
*)new SwXMLExport(rSMgr
,
736 EXPORT_AUTOSTYLES
| EXPORT_CONTENT
| EXPORT_SCRIPTS
|
740 OUString SAL_CALL
SwXMLExportMetaOOO_getImplementationName() throw()
742 return OUString( RTL_CONSTASCII_USTRINGPARAM(
743 "com.sun.star.comp.Writer.XMLMetaExporter" ) );
746 Sequence
< OUString
> SAL_CALL
SwXMLExportMetaOOO_getSupportedServiceNames()
749 const OUString
aServiceName(SwXMLExportMetaOOO_getImplementationName());
750 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
754 Reference
< XInterface
> SAL_CALL
SwXMLExportMetaOOO_createInstance(
755 const Reference
< XMultiServiceFactory
> & rSMgr
)
758 return (cppu::OWeakObject
*)new SwXMLExport( rSMgr
, EXPORT_META
);
761 OUString SAL_CALL
SwXMLExportSettingsOOO_getImplementationName() throw()
763 return OUString( RTL_CONSTASCII_USTRINGPARAM(
764 "com.sun.star.comp.Writer.XMLSettingsExporter" ) );
767 Sequence
< OUString
> SAL_CALL
SwXMLExportSettingsOOO_getSupportedServiceNames()
770 const OUString
aServiceName(SwXMLExportSettingsOOO_getImplementationName());
771 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
775 Reference
< XInterface
> SAL_CALL
SwXMLExportSettingsOOO_createInstance(
776 const Reference
< XMultiServiceFactory
> & rSMgr
)
779 return (cppu::OWeakObject
*)new SwXMLExport( rSMgr
, EXPORT_SETTINGS
);
783 OUString SAL_CALL
SwXMLExport_getImplementationName() throw()
785 return OUString( RTL_CONSTASCII_USTRINGPARAM(
786 "com.sun.star.comp.Writer.XMLOasisExporter" ) );
789 Sequence
< OUString
> SAL_CALL
SwXMLExport_getSupportedServiceNames()
792 const OUString
aServiceName(SwXMLExport_getImplementationName());
793 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
797 Reference
< XInterface
> SAL_CALL
SwXMLExport_createInstance(
798 const Reference
< XMultiServiceFactory
> & rSMgr
)
801 return (cppu::OWeakObject
*)new SwXMLExport( rSMgr
, EXPORT_ALL
|EXPORT_OASIS
);
804 OUString SAL_CALL
SwXMLExportStyles_getImplementationName() throw()
806 return OUString( RTL_CONSTASCII_USTRINGPARAM(
807 "com.sun.star.comp.Writer.XMLOasisStylesExporter" ) );
810 Sequence
< OUString
> SAL_CALL
SwXMLExportStyles_getSupportedServiceNames()
813 const OUString
aServiceName(SwXMLExportStyles_getImplementationName());
814 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
818 Reference
< XInterface
> SAL_CALL
SwXMLExportStyles_createInstance(
819 const Reference
< XMultiServiceFactory
> & rSMgr
)
823 //return (cppu::OWeakObject*)new SwXMLExport(
824 // EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES |
825 // EXPORT_FONTDECLS );
826 return (cppu::OWeakObject
*)new SwXMLExport( rSMgr
,
827 EXPORT_STYLES
| EXPORT_MASTERSTYLES
| EXPORT_AUTOSTYLES
|
828 EXPORT_FONTDECLS
|EXPORT_OASIS
);
831 OUString SAL_CALL
SwXMLExportContent_getImplementationName() throw()
833 return OUString( RTL_CONSTASCII_USTRINGPARAM(
834 "com.sun.star.comp.Writer.XMLOasisContentExporter" ) );
837 Sequence
< OUString
> SAL_CALL
SwXMLExportContent_getSupportedServiceNames()
840 const OUString
aServiceName(SwXMLExportContent_getImplementationName());
841 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
845 Reference
< XInterface
> SAL_CALL
SwXMLExportContent_createInstance(
846 const Reference
< XMultiServiceFactory
> & rSMgr
)
850 //return (cppu::OWeakObject*)new SwXMLExport(
851 // EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_SCRIPTS |
852 // EXPORT_FONTDECLS );
853 return (cppu::OWeakObject
*)new SwXMLExport(
855 EXPORT_AUTOSTYLES
| EXPORT_CONTENT
| EXPORT_SCRIPTS
|
856 EXPORT_FONTDECLS
|EXPORT_OASIS
);
859 OUString SAL_CALL
SwXMLExportMeta_getImplementationName() throw()
861 return OUString( RTL_CONSTASCII_USTRINGPARAM(
862 "com.sun.star.comp.Writer.XMLOasisMetaExporter" ) );
865 Sequence
< OUString
> SAL_CALL
SwXMLExportMeta_getSupportedServiceNames()
868 const OUString
aServiceName(SwXMLExportMeta_getImplementationName());
869 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
873 Reference
< XInterface
> SAL_CALL
SwXMLExportMeta_createInstance(
874 const Reference
< XMultiServiceFactory
> & rSMgr
)
877 return (cppu::OWeakObject
*)new SwXMLExport(rSMgr
, EXPORT_META
|EXPORT_OASIS
);
880 OUString SAL_CALL
SwXMLExportSettings_getImplementationName() throw()
882 return OUString( RTL_CONSTASCII_USTRINGPARAM(
883 "com.sun.star.comp.Writer.XMLOasisSettingsExporter" ) );
886 Sequence
< OUString
> SAL_CALL
SwXMLExportSettings_getSupportedServiceNames()
889 const OUString
aServiceName(SwXMLExportSettings_getImplementationName());
890 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
894 Reference
< XInterface
> SAL_CALL
SwXMLExportSettings_createInstance(
895 const Reference
< XMultiServiceFactory
> & rSMgr
)
898 return (cppu::OWeakObject
*)new SwXMLExport(rSMgr
, EXPORT_SETTINGS
|EXPORT_OASIS
);
901 const Sequence
< sal_Int8
> & SwXMLExport::getUnoTunnelId() throw()
903 static Sequence
< sal_Int8
> aSeq
= ::CreateUnoTunnelId();
907 sal_Int64 SAL_CALL
SwXMLExport::getSomething( const Sequence
< sal_Int8
>& rId
)
908 throw(RuntimeException
)
910 if( rId
.getLength() == 16
911 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
912 rId
.getConstArray(), 16 ) )
914 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
916 return SvXMLExport::getSomething( rId
);
921 // override empty method from parent class
922 OUString SAL_CALL
SwXMLExport::getImplementationName()
923 throw(RuntimeException
)
925 switch( getExportFlags() )
928 return SwXMLExport_getImplementationName();
929 case (EXPORT_STYLES
|EXPORT_MASTERSTYLES
|EXPORT_AUTOSTYLES
|EXPORT_FONTDECLS
):
930 return SwXMLExportStyles_getImplementationName();
931 case (EXPORT_AUTOSTYLES
|EXPORT_CONTENT
|EXPORT_SCRIPTS
|EXPORT_FONTDECLS
):
932 return SwXMLExportContent_getImplementationName();
934 return SwXMLExportMeta_getImplementationName();
935 case EXPORT_SETTINGS
:
936 return SwXMLExportSettings_getImplementationName();
938 // generic name for 'unknown' cases
939 return OUString( RTL_CONSTASCII_USTRINGPARAM(
940 "com.sun.star.comp.Writer.SwXMLExport" ) );
946 void SwXMLExport::ExportCurPaM( sal_Bool bExportWholePaM
)
948 sal_Bool bFirstNode
= sal_True
;
949 sal_Bool bExportWholeNode
= bExportWholePaM
;
951 SwXMLNumRuleInfo aPrevNumInfo
;
952 SwXMLNumRuleInfo aNextNumInfo
;
954 while( pCurPaM
->GetPoint()->nNode
.GetIndex() <
955 pCurPaM
->GetMark()->nNode
.GetIndex() ||
956 ( pCurPaM
->GetPoint()->nNode
.GetIndex() ==
957 pCurPaM
->GetMark()->nNode
.GetIndex() &&
958 pCurPaM
->GetPoint()->nContent
.GetIndex() <=
959 pCurPaM
->GetMark()->nContent
.GetIndex() ) )
961 SwNode
*pNd
= pCurPaM
->GetNode();
963 aNextNumInfo
.Set( *pNd
);
964 ExportListChange( aPrevNumInfo
, aNextNumInfo
);
966 ASSERT( !(pNd
->IsGrfNode() || pNd
->IsOLENode()),
967 "SwXMLExport::exportCurPaM: grf or OLE node unexpected" );
968 if( pNd
->IsTxtNode() )
970 SwTxtNode
* pTxtNd
= pNd
->GetTxtNode();
973 pCurPaM
->GetPoint()->nContent
.Assign( pTxtNd
, 0 );
975 ExportTxtNode( *pTxtNd
, 0, STRING_LEN
, bExportWholeNode
);
977 else if( pNd
->IsTableNode() )
979 ExportTable( *pNd
->GetTableNode() );
981 else if( pNd
->IsSectionNode() )
983 ExportSection( *pNd
->GetSectionNode() );
985 else if( pNd
== &pDoc
->GetNodes().GetEndOfContent() )
988 pCurPaM
->GetPoint()->nNode
++; // next node
990 sal_uInt32 nPos
= pCurPaM
->GetPoint()->nNode
.GetIndex();
992 // if not everything should be exported, the WriteAll flag must be
993 // set for all but the first and last node anyway.
994 bExportWholeNode
= bExportWholePaM
||
995 nPos
!= pCurPaM
->GetMark()->nNode
.GetIndex();
996 bFirstNode
= sal_False
;
998 aPrevNumInfo
= aNextNumInfo
;
1000 aNextNumInfo
.Reset();
1001 ExportListChange( aPrevNumInfo
, aNextNumInfo
);