Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/text/XTextDocument.hpp>
21 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
22 : #include <com/sun/star/beans/XPropertySet.hpp>
23 : #include <com/sun/star/container/XNameContainer.hpp>
24 : #include <com/sun/star/container/XIndexContainer.hpp>
25 : #include <com/sun/star/document/IndexedPropertyValues.hpp>
26 : #include <com/sun/star/uno/RuntimeException.hpp>
27 : #include <com/sun/star/xforms/XFormsSupplier.hpp>
28 :
29 : #include <sax/tools/converter.hxx>
30 : #include <svx/svdmodel.hxx>
31 : #include <svx/svdpage.hxx>
32 : #include <svx/xmleohlp.hxx>
33 : #include <svx/xmlgrhlp.hxx>
34 : #include <editeng/eeitem.hxx>
35 : #include <svx/svddef.hxx>
36 : #include <xmloff/nmspmap.hxx>
37 : #include <xmloff/xmlnmspe.hxx>
38 : #include <editeng/xmlcnitm.hxx>
39 : #include <xmloff/ProgressBarHelper.hxx>
40 : #include <xmloff/xmluconv.hxx>
41 : #include <xmloff/xformsexport.hxx>
42 : #include <drawdoc.hxx>
43 : #include <pam.hxx>
44 : #include <unofreg.hxx>
45 : #include <doc.hxx>
46 : #include <swmodule.hxx>
47 : #include <docsh.hxx>
48 : #include <viewsh.hxx>
49 : #include <docstat.hxx>
50 : #include <swerror.h>
51 : #include <unotext.hxx>
52 : #include <xmltexte.hxx>
53 : #include <xmlexp.hxx>
54 : #include <sfx2/viewsh.hxx>
55 : #include <comphelper/processfactory.hxx>
56 : #include <docary.hxx>
57 : #include <editeng/unolingu.hxx>
58 : #include <editeng/forbiddencharacterstable.hxx>
59 : #include <comphelper/servicehelper.hxx>
60 : #include <vcl/svapp.hxx>
61 : #include <osl/mutex.hxx>
62 : #include <IDocumentSettingAccess.hxx>
63 : #include <IDocumentDrawModelAccess.hxx>
64 : #include <IDocumentRedlineAccess.hxx>
65 : #include <IDocumentStatistics.hxx>
66 : #include <IDocumentLayoutAccess.hxx>
67 :
68 :
69 : #include <pausethreadstarting.hxx>
70 :
71 : using namespace ::com::sun::star;
72 : using namespace ::com::sun::star::frame;
73 : using namespace ::com::sun::star::lang;
74 : using namespace ::com::sun::star::xml::sax;
75 : using namespace ::com::sun::star::uno;
76 : using namespace ::com::sun::star::text;
77 : using namespace ::com::sun::star::container;
78 : using namespace ::com::sun::star::document;
79 : using namespace ::com::sun::star::drawing;
80 : using namespace ::com::sun::star::beans;
81 : using namespace ::com::sun::star::i18n;
82 : using namespace ::com::sun::star::xforms;
83 : using namespace ::xmloff::token;
84 :
85 242 : SwXMLExport::SwXMLExport(
86 : const uno::Reference< uno::XComponentContext > xContext,
87 : OUString const & implementationName, sal_uInt16 nExportFlags)
88 : : SvXMLExport( util::MeasureUnit::INCH, xContext, implementationName, XML_TEXT,
89 : nExportFlags ),
90 : pTableItemMapper( 0 ),
91 : pTableLines( 0 ),
92 : bBlock( false ),
93 : bShowProgress( true ),
94 : bSavedShowChanges( false ),
95 : doc( NULL ),
96 : sNumberFormat("NumberFormat"),
97 : sIsProtected("IsProtected"),
98 242 : sCell("Cell")
99 : {
100 242 : _InitItemExport();
101 242 : }
102 :
103 4 : void SwXMLExport::setBlockMode()
104 : {
105 4 : bBlock = true;
106 :
107 4 : }
108 :
109 230 : sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
110 : {
111 230 : if( !GetModel().is() )
112 0 : return ERR_SWG_WRITE_ERROR;
113 :
114 230 : SwPauseThreadStarting aPauseThreadStarting; // #i73788#
115 :
116 : // from here, we use core interfaces -> lock Solar-Mutex
117 460 : SolarMutexGuard aGuard;
118 :
119 : {
120 230 : Reference<XPropertySet> rInfoSet = getExportInfo();
121 230 : if( rInfoSet.is() )
122 : {
123 230 : const OUString sAutoTextMode("AutoTextMode");
124 460 : if( rInfoSet->getPropertySetInfo()->hasPropertyByName(
125 230 : sAutoTextMode ) )
126 : {
127 230 : Any aAny = rInfoSet->getPropertyValue(sAutoTextMode);
128 234 : if( aAny.getValueType() == ::getBooleanCppuType() &&
129 4 : *static_cast<const sal_Bool*>(aAny.getValue()) )
130 4 : setBlockMode();
131 230 : }
132 230 : }
133 : }
134 :
135 230 : SwDoc *pDoc = getDoc();
136 :
137 230 : bool bExtended = false;
138 230 : if( (getExportFlags() & (EXPORT_FONTDECLS|EXPORT_STYLES|
139 : EXPORT_MASTERSTYLES|EXPORT_CONTENT)) != 0 )
140 : {
141 120 : if( getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
142 : {
143 120 : _GetNamespaceMap().Add(
144 120 : GetXMLToken(XML_NP_OFFICE_EXT),
145 120 : GetXMLToken(XML_N_OFFICE_EXT),
146 120 : XML_NAMESPACE_OFFICE_EXT);
147 : }
148 :
149 120 : GetTextParagraphExport()->SetBlockMode( bBlock );
150 :
151 120 : const SfxItemPool& rPool = pDoc->GetAttrPool();
152 : sal_uInt16 aWhichIds[5] = { RES_UNKNOWNATR_CONTAINER,
153 : RES_TXTATR_UNKNOWN_CONTAINER,
154 : SDRATTR_XMLATTRIBUTES,
155 : EE_PARA_XMLATTRIBS,
156 120 : EE_CHAR_XMLATTRIBS };
157 :
158 120 : const int nWhichIds = rPool.GetSecondaryPool() ? 5 : 2;
159 720 : for( int j=0; j < nWhichIds; ++j )
160 : {
161 600 : const sal_uInt16 nWhichId = aWhichIds[j];
162 600 : const sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
163 616 : for( sal_uInt32 i = 0; i < nItems; ++i )
164 : {
165 16 : const SfxPoolItem* const pItem = rPool.GetItem2( nWhichId , i );
166 16 : if( 0 != pItem )
167 : {
168 : const SvXMLAttrContainerItem *pUnknown =
169 8 : PTR_CAST( SvXMLAttrContainerItem, pItem );
170 : OSL_ENSURE( pUnknown, "illegal attribute container item" );
171 8 : if( pUnknown && (pUnknown->GetAttrCount() > 0) )
172 : {
173 0 : sal_uInt16 nIdx = pUnknown->GetFirstNamespaceIndex();
174 0 : while( USHRT_MAX != nIdx )
175 : {
176 0 : _GetNamespaceMap().Add( pUnknown->GetPrefix( nIdx ),
177 0 : pUnknown->GetNamespace( nIdx ),
178 0 : XML_NAMESPACE_UNKNOWN );
179 0 : nIdx = pUnknown->GetNextNamespaceIndex( nIdx );
180 : }
181 0 : bExtended = true;
182 : }
183 : }
184 : }
185 : }
186 : }
187 :
188 : sal_uInt16 const eUnit = SvXMLUnitConverter::GetMeasureUnit(
189 230 : SW_MOD()->GetMetric(pDoc->getIDocumentSettingAccess().get(IDocumentSettingAccess::HTML_MODE)));
190 230 : if (GetMM100UnitConverter().GetXMLMeasureUnit() != eUnit )
191 : {
192 0 : GetMM100UnitConverter().SetXMLMeasureUnit( eUnit );
193 0 : pTwipUnitConv->SetXMLMeasureUnit( eUnit );
194 : }
195 :
196 230 : SetExtended( bExtended );
197 :
198 230 : if( (getExportFlags() & EXPORT_META) != 0 )
199 : {
200 : // Update doc stat, so that correct values are exported and
201 : // the progress works correctly.
202 52 : pDoc->getIDocumentStatistics().UpdateDocStat( false, true );
203 : }
204 230 : if( bShowProgress )
205 : {
206 230 : ProgressBarHelper *pProgress = GetProgressBarHelper();
207 230 : if( -1 == pProgress->GetReference() )
208 : {
209 : // progress isn't initialized:
210 : // We assume that the whole doc is exported, and the following
211 : // durations:
212 : // - meta information: 2
213 : // - settings: 4 (TODO: not now!)
214 : // - styles (except page styles): 2
215 : // - page styles: 2 (TODO: not now!) + 2 for each paragraph
216 : // - paragraph: 2 (1 for automatic styles and one for content)
217 :
218 : // count each item once, and then multiply by two to reach the
219 : // figures given above
220 : // The styles in pDoc also count the default style that never
221 : // gets exported -> subtract one.
222 60 : sal_Int32 nRef = 1; // meta.xml
223 60 : nRef += pDoc->GetCharFmts()->size() - 1;
224 60 : nRef += pDoc->GetFrmFmts()->size() - 1;
225 60 : nRef += pDoc->GetTxtFmtColls()->size() - 1;
226 60 : nRef *= 2; // for the above styles, xmloff will increment by 2!
227 : // #i93174#: count all paragraphs for the progress bar
228 60 : nRef += pDoc->getIDocumentStatistics().GetUpdatedDocStat( false, true ).nAllPara; // 1: only content, no autostyle
229 60 : pProgress->SetReference( nRef );
230 60 : pProgress->SetValue( 0 );
231 : }
232 : }
233 :
234 230 : if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT)) != 0 )
235 : {
236 : //Auf die Korrektheit der OrdNums sind wir schon angewiesen.
237 120 : SwDrawModel* pModel = pDoc->getIDocumentDrawModelAccess().GetDrawModel();
238 120 : if( pModel )
239 120 : pModel->GetPage( 0 )->RecalcObjOrdNums();
240 : }
241 :
242 : // adjust document class (eClass)
243 230 : if (pDoc->getIDocumentSettingAccess().get(IDocumentSettingAccess::GLOBAL_DOCUMENT))
244 : {
245 0 : eClass = XML_TEXT_GLOBAL;
246 :
247 : // additionally, we take care of the save-linked-sections-thingy
248 0 : mbSaveLinkedSections = pDoc->getIDocumentSettingAccess().get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS);
249 : }
250 : // MIB: 03/26/04: The Label information is saved in the settings, so
251 : // we don't need it here.
252 : // else: keep default pClass that we received
253 :
254 230 : SvXMLGraphicHelper *pGraphicResolver = 0;
255 230 : if( !GetGraphicResolver().is() )
256 : {
257 110 : pGraphicResolver = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_WRITE );
258 110 : Reference< XGraphicObjectResolver > xGraphicResolver( pGraphicResolver );
259 110 : SetGraphicResolver( xGraphicResolver );
260 : }
261 :
262 230 : SvXMLEmbeddedObjectHelper *pEmbeddedResolver = 0;
263 230 : if( !GetEmbeddedResolver().is() )
264 : {
265 110 : SfxObjectShell *pPersist = pDoc->GetPersist();
266 110 : if( pPersist )
267 : {
268 : pEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
269 : *pPersist,
270 110 : EMBEDDEDOBJECTHELPER_MODE_WRITE );
271 110 : Reference< XEmbeddedObjectResolver > xEmbeddedResolver( pEmbeddedResolver );
272 110 : SetEmbeddedResolver( xEmbeddedResolver );
273 : }
274 : }
275 :
276 : // set redline mode if we export STYLES or CONTENT, unless redline
277 : // mode is taken care of outside (through info XPropertySet)
278 : bool bSaveRedline =
279 230 : ( (getExportFlags() & (EXPORT_CONTENT|EXPORT_STYLES)) != 0 );
280 230 : if( bSaveRedline )
281 : {
282 : // if the info property set has a ShowChanges property,
283 : // then change tracking is taken care of on the outside,
284 : // so we don't have to!
285 120 : Reference<XPropertySet> rInfoSet = getExportInfo();
286 120 : if( rInfoSet.is() )
287 : {
288 240 : bSaveRedline = ! rInfoSet->getPropertySetInfo()->hasPropertyByName(
289 120 : "ShowChanges" );
290 120 : }
291 : }
292 230 : sal_uInt16 nRedlineMode = 0;
293 230 : bSavedShowChanges = IDocumentRedlineAccess::IsShowChanges( pDoc->getIDocumentRedlineAccess().GetRedlineMode() );
294 230 : if( bSaveRedline )
295 : {
296 : // now save and switch redline mode
297 0 : nRedlineMode = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
298 0 : pDoc->getIDocumentRedlineAccess().SetRedlineMode(
299 0 : (RedlineMode_t)(( nRedlineMode & nsRedlineMode_t::REDLINE_SHOW_MASK ) | nsRedlineType_t::REDLINE_INSERT ));
300 : }
301 :
302 230 : sal_uInt32 nRet = SvXMLExport::exportDoc( eClass );
303 :
304 : // now we can restore the redline mode (if we changed it previously)
305 230 : if( bSaveRedline )
306 : {
307 0 : pDoc->getIDocumentRedlineAccess().SetRedlineMode( (RedlineMode_t)(nRedlineMode ));
308 : }
309 :
310 230 : if( pGraphicResolver )
311 110 : SvXMLGraphicHelper::Destroy( pGraphicResolver );
312 230 : if( pEmbeddedResolver )
313 110 : SvXMLEmbeddedObjectHelper::Destroy( pEmbeddedResolver );
314 :
315 : OSL_ENSURE( !pTableLines, "there are table columns infos left" );
316 :
317 460 : return nRet;
318 : }
319 :
320 120 : XMLTextParagraphExport* SwXMLExport::CreateTextParagraphExport()
321 : {
322 120 : return new SwXMLTextParagraphExport( *this, *GetAutoStylePool().get() );
323 : }
324 :
325 120 : XMLShapeExport* SwXMLExport::CreateShapeExport()
326 : {
327 120 : XMLShapeExport* pShapeExport = new XMLShapeExport( *this, XMLTextParagraphExport::CreateShapeExtPropMapper( *this ) );
328 120 : Reference < XDrawPageSupplier > xDPS( GetModel(), UNO_QUERY );
329 120 : if( xDPS.is() )
330 : {
331 120 : Reference < XShapes > xShapes( xDPS->getDrawPage(), UNO_QUERY );
332 120 : pShapeExport->seekShapes( xShapes );
333 : }
334 :
335 120 : return pShapeExport;
336 : }
337 :
338 726 : SwXMLExport::~SwXMLExport()
339 : {
340 242 : DeleteTableLines();
341 242 : _FinitItemExport();
342 484 : }
343 :
344 120 : void SwXMLExport::_ExportFontDecls()
345 : {
346 120 : GetFontAutoStylePool(); // make sure the pool is created
347 120 : SvXMLExport::_ExportFontDecls();
348 120 : }
349 :
350 : #define NUM_EXPORTED_VIEW_SETTINGS 11
351 58 : void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps)
352 : {
353 58 : aProps.realloc( NUM_EXPORTED_VIEW_SETTINGS );
354 : // Currently exporting 9 properties
355 58 : PropertyValue *pValue = aProps.getArray();
356 58 : sal_Int32 nIndex = 0;
357 :
358 58 : Reference < XIndexContainer > xBox = IndexedPropertyValues::create( comphelper::getProcessComponentContext() );
359 58 : pValue[nIndex].Name = "Views";
360 58 : pValue[nIndex++].Value <<= xBox;
361 :
362 58 : SwDoc *pDoc = getDoc();
363 : const Rectangle rRect =
364 58 : pDoc->GetDocShell()->GetVisArea( ASPECT_CONTENT );
365 58 : bool bTwip = pDoc->GetDocShell()->GetMapUnit ( ) == MAP_TWIP;
366 :
367 : OSL_ENSURE( bTwip, "Map unit for visible area is not in TWIPS!" );
368 :
369 58 : pValue[nIndex].Name = "ViewAreaTop";
370 58 : pValue[nIndex++].Value <<= bTwip ? convertTwipToMm100 ( rRect.Top() ) : rRect.Top();
371 :
372 58 : pValue[nIndex].Name = "ViewAreaLeft";
373 58 : pValue[nIndex++].Value <<= bTwip ? convertTwipToMm100 ( rRect.Left() ) : rRect.Left();
374 :
375 58 : pValue[nIndex].Name = "ViewAreaWidth";
376 58 : pValue[nIndex++].Value <<= bTwip ? convertTwipToMm100 ( rRect.GetWidth() ) : rRect.GetWidth();
377 :
378 58 : pValue[nIndex].Name = "ViewAreaHeight";
379 58 : pValue[nIndex++].Value <<= bTwip ? convertTwipToMm100 ( rRect.GetHeight() ) : rRect.GetHeight();
380 :
381 : // "show redline mode" cannot simply be read from the document
382 : // since it gets changed during execution. If it's in the info
383 : // XPropertySet, we take it from there.
384 58 : sal_Bool bShowRedlineChanges = bSavedShowChanges;
385 116 : Reference<XPropertySet> xInfoSet( getExportInfo() );
386 58 : if ( xInfoSet.is() )
387 : {
388 58 : const OUString sShowChanges( "ShowChanges" );
389 58 : if( xInfoSet->getPropertySetInfo()->hasPropertyByName( sShowChanges ) )
390 : {
391 58 : bShowRedlineChanges = *(sal_Bool*) xInfoSet->
392 58 : getPropertyValue( sShowChanges ).getValue();
393 58 : }
394 : }
395 :
396 58 : pValue[nIndex].Name = "ShowRedlineChanges";
397 58 : pValue[nIndex++].Value.setValue( &bShowRedlineChanges, ::getBooleanCppuType() );
398 :
399 58 : sal_Bool bInBrowse = pDoc->getIDocumentSettingAccess().get(IDocumentSettingAccess::BROWSE_MODE);
400 58 : pValue[nIndex].Name = "InBrowseMode";
401 58 : pValue[nIndex++].Value.setValue( &bInBrowse, ::getBooleanCppuType() );
402 :
403 58 : if ( nIndex < NUM_EXPORTED_VIEW_SETTINGS )
404 116 : aProps.realloc(nIndex);
405 58 : }
406 : #undef NUM_EXPORTED_VIEW_SETTINGS
407 :
408 58 : void SwXMLExport::GetConfigurationSettings( Sequence < PropertyValue >& rProps)
409 : {
410 58 : Reference< XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
411 58 : if( xFac.is() )
412 : {
413 58 : Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
414 58 : if( xProps.is() )
415 58 : SvXMLUnitConverter::convertPropertySet( rProps, xProps );
416 58 : }
417 58 : }
418 :
419 58 : sal_Int32 SwXMLExport::GetDocumentSpecificSettings( ::std::list< SettingsGroup >& _out_rSettings )
420 : {
421 : // the only doc-specific settings group we know so far are the XForms settings
422 58 : uno::Sequence<beans::PropertyValue> aXFormsSettings;
423 116 : Reference< XFormsSupplier > xXFormsSupp( GetModel(), UNO_QUERY );
424 116 : Reference< XNameAccess > xXForms;
425 58 : if ( xXFormsSupp.is() )
426 58 : xXForms = xXFormsSupp->getXForms().get();
427 58 : if ( xXForms.is() )
428 : {
429 0 : getXFormsSettings( xXForms, aXFormsSettings );
430 0 : _out_rSettings.push_back( SettingsGroup( XML_XFORM_MODEL_SETTINGS, aXFormsSettings ) );
431 : }
432 :
433 116 : return aXFormsSettings.getLength() + SvXMLExport::GetDocumentSpecificSettings( _out_rSettings );
434 : }
435 :
436 60 : void SwXMLExport::SetBodyAttributes()
437 : {
438 : // export use of soft page breaks
439 60 : SwDoc *pDoc = getDoc();
440 112 : if( pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() &&
441 52 : pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->GetPageCount() > 1 )
442 : {
443 6 : bool bValue = true;
444 6 : OUStringBuffer sBuffer;
445 6 : ::sax::Converter::convertBool(sBuffer, bValue);
446 : AddAttribute(XML_NAMESPACE_TEXT, XML_USE_SOFT_PAGE_BREAKS,
447 6 : sBuffer.makeStringAndClear());
448 : }
449 60 : }
450 :
451 60 : void SwXMLExport::_ExportContent()
452 : {
453 : // export forms
454 60 : Reference<XDrawPageSupplier> xDrawPageSupplier(GetModel(), UNO_QUERY);
455 60 : if (xDrawPageSupplier.is())
456 : {
457 : // export only if we actually have elements
458 60 : Reference<XDrawPage> xPage = xDrawPageSupplier->getDrawPage();
459 60 : if (xPage.is())
460 : {
461 : // prevent export of form controls which are embedded in mute sections
462 : GetTextParagraphExport()->PreventExportOfControlsInMuteSections(
463 60 : xPage, GetFormExport() );
464 :
465 : // #i36597#
466 60 : if ( GetFormExport()->pageContainsForms( xPage ) || GetFormExport()->documentContainsXForms() )
467 : {
468 2 : ::xmloff::OOfficeFormsExport aOfficeForms(*this);
469 :
470 2 : GetFormExport()->exportXForms();
471 :
472 2 : GetFormExport()->seekPage(xPage);
473 2 : GetFormExport()->exportForms(xPage);
474 : }
475 60 : }
476 : }
477 :
478 120 : Reference<XPropertySet> xPropSet(GetModel(), UNO_QUERY);
479 60 : if (xPropSet.is())
480 : {
481 60 : Any aAny = xPropSet->getPropertyValue( "TwoDigitYear" );
482 60 : aAny <<= (sal_Int16)1930;
483 :
484 60 : sal_Int16 nYear = 0;
485 60 : aAny >>= nYear;
486 60 : if (nYear != 1930 )
487 : {
488 0 : OUStringBuffer sBuffer;
489 0 : ::sax::Converter::convertNumber(sBuffer, nYear);
490 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NULL_YEAR, sBuffer.makeStringAndClear());
491 0 : SvXMLElementExport aCalcSettings(*this, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, true, true);
492 60 : }
493 : }
494 :
495 60 : GetTextParagraphExport()->exportTrackedChanges( false );
496 60 : GetTextParagraphExport()->exportTextDeclarations();
497 120 : Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
498 120 : Reference < XText > xText = xTextDoc->getText();
499 :
500 60 : GetTextParagraphExport()->exportFramesBoundToPage( bShowProgress );
501 120 : GetTextParagraphExport()->exportText( xText, bShowProgress );
502 60 : }
503 :
504 : // uno component registration
505 : // helper functions for export service(s)
506 :
507 : // OOo
508 194 : OUString SAL_CALL SwXMLExportOOO_getImplementationName() throw()
509 : {
510 : return OUString(
511 194 : "com.sun.star.comp.Writer.XMLExporter" );
512 : }
513 :
514 0 : Sequence< OUString > SAL_CALL SwXMLExportOOO_getSupportedServiceNames()
515 : throw()
516 : {
517 0 : const OUString aServiceName(SwXMLExportOOO_getImplementationName());
518 0 : const Sequence< OUString > aSeq( &aServiceName, 1 );
519 0 : return aSeq;
520 : }
521 :
522 0 : Reference< XInterface > SAL_CALL SwXMLExportOOO_createInstance(
523 : const Reference< XMultiServiceFactory > & rSMgr)
524 : throw( Exception )
525 : {
526 0 : return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), SwXMLExportOOO_getImplementationName(), EXPORT_ALL);
527 : }
528 :
529 202 : OUString SAL_CALL SwXMLExportStylesOOO_getImplementationName() throw()
530 : {
531 : return OUString(
532 202 : "com.sun.star.comp.Writer.XMLStylesExporter" );
533 : }
534 :
535 2 : Sequence< OUString > SAL_CALL SwXMLExportStylesOOO_getSupportedServiceNames()
536 : throw()
537 : {
538 2 : const OUString aServiceName(SwXMLExportStylesOOO_getImplementationName());
539 2 : const Sequence< OUString > aSeq( &aServiceName, 1 );
540 2 : return aSeq;
541 : }
542 :
543 4 : Reference< XInterface > SAL_CALL SwXMLExportStylesOOO_createInstance(
544 : const Reference< XMultiServiceFactory > & rSMgr)
545 : throw( Exception )
546 : {
547 : return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), SwXMLExportStylesOOO_getImplementationName(),
548 : EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES |
549 4 : EXPORT_FONTDECLS );
550 : }
551 :
552 200 : OUString SAL_CALL SwXMLExportContentOOO_getImplementationName() throw()
553 : {
554 : return OUString(
555 200 : "com.sun.star.comp.Writer.XMLContentExporter" );
556 : }
557 :
558 2 : Sequence< OUString > SAL_CALL SwXMLExportContentOOO_getSupportedServiceNames()
559 : throw()
560 : {
561 2 : const OUString aServiceName(SwXMLExportContentOOO_getImplementationName());
562 2 : const Sequence< OUString > aSeq( &aServiceName, 1 );
563 2 : return aSeq;
564 : }
565 :
566 4 : Reference< XInterface > SAL_CALL SwXMLExportContentOOO_createInstance(
567 : const Reference< XMultiServiceFactory > & rSMgr)
568 : throw( Exception )
569 : {
570 : return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), SwXMLExportContentOOO_getImplementationName(),
571 : EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_SCRIPTS |
572 4 : EXPORT_FONTDECLS );
573 : }
574 :
575 190 : OUString SAL_CALL SwXMLExportMetaOOO_getImplementationName() throw()
576 : {
577 : return OUString(
578 190 : "com.sun.star.comp.Writer.XMLMetaExporter" );
579 : }
580 :
581 0 : Sequence< OUString > SAL_CALL SwXMLExportMetaOOO_getSupportedServiceNames()
582 : throw()
583 : {
584 0 : const OUString aServiceName(SwXMLExportMetaOOO_getImplementationName());
585 0 : const Sequence< OUString > aSeq( &aServiceName, 1 );
586 0 : return aSeq;
587 : }
588 :
589 0 : Reference< XInterface > SAL_CALL SwXMLExportMetaOOO_createInstance(
590 : const Reference< XMultiServiceFactory > & rSMgr)
591 : throw( Exception )
592 : {
593 0 : return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), SwXMLExportMetaOOO_getImplementationName(), EXPORT_META);
594 : }
595 :
596 198 : OUString SAL_CALL SwXMLExportSettingsOOO_getImplementationName() throw()
597 : {
598 : return OUString(
599 198 : "com.sun.star.comp.Writer.XMLSettingsExporter" );
600 : }
601 :
602 2 : Sequence< OUString > SAL_CALL SwXMLExportSettingsOOO_getSupportedServiceNames()
603 : throw()
604 : {
605 2 : const OUString aServiceName(SwXMLExportSettingsOOO_getImplementationName());
606 2 : const Sequence< OUString > aSeq( &aServiceName, 1 );
607 2 : return aSeq;
608 : }
609 :
610 4 : Reference< XInterface > SAL_CALL SwXMLExportSettingsOOO_createInstance(
611 : const Reference< XMultiServiceFactory > & rSMgr)
612 : throw( Exception )
613 : {
614 4 : return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), SwXMLExportSettingsOOO_getImplementationName(), EXPORT_SETTINGS);
615 : }
616 :
617 : // OASIS
618 188 : OUString SAL_CALL SwXMLExport_getImplementationName() throw()
619 : {
620 : return OUString(
621 188 : "com.sun.star.comp.Writer.XMLOasisExporter" );
622 : }
623 :
624 0 : Sequence< OUString > SAL_CALL SwXMLExport_getSupportedServiceNames()
625 : throw()
626 : {
627 0 : const OUString aServiceName(SwXMLExport_getImplementationName());
628 0 : const Sequence< OUString > aSeq( &aServiceName, 1 );
629 0 : return aSeq;
630 : }
631 :
632 0 : Reference< XInterface > SAL_CALL SwXMLExport_createInstance(
633 : const Reference< XMultiServiceFactory > & rSMgr)
634 : throw( Exception )
635 : {
636 0 : return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), SwXMLExport_getImplementationName(), EXPORT_ALL|EXPORT_OASIS);
637 : }
638 :
639 296 : OUString SAL_CALL SwXMLExportStyles_getImplementationName() throw()
640 : {
641 : return OUString(
642 296 : "com.sun.star.comp.Writer.XMLOasisStylesExporter" );
643 : }
644 :
645 24 : Sequence< OUString > SAL_CALL SwXMLExportStyles_getSupportedServiceNames()
646 : throw()
647 : {
648 24 : const OUString aServiceName(SwXMLExportStyles_getImplementationName());
649 24 : const Sequence< OUString > aSeq( &aServiceName, 1 );
650 24 : return aSeq;
651 : }
652 :
653 60 : Reference< XInterface > SAL_CALL SwXMLExportStyles_createInstance(
654 : const Reference< XMultiServiceFactory > & rSMgr)
655 : throw( Exception )
656 : {
657 : return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), SwXMLExportStyles_getImplementationName(),
658 : EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES |
659 60 : EXPORT_FONTDECLS|EXPORT_OASIS );
660 : }
661 :
662 272 : OUString SAL_CALL SwXMLExportContent_getImplementationName() throw()
663 : {
664 : return OUString(
665 272 : "com.sun.star.comp.Writer.XMLOasisContentExporter" );
666 : }
667 :
668 24 : Sequence< OUString > SAL_CALL SwXMLExportContent_getSupportedServiceNames()
669 : throw()
670 : {
671 24 : const OUString aServiceName(SwXMLExportContent_getImplementationName());
672 24 : const Sequence< OUString > aSeq( &aServiceName, 1 );
673 24 : return aSeq;
674 : }
675 :
676 60 : Reference< XInterface > SAL_CALL SwXMLExportContent_createInstance(
677 : const Reference< XMultiServiceFactory > & rSMgr)
678 : throw( Exception )
679 : {
680 : return (cppu::OWeakObject*)new SwXMLExport(
681 : comphelper::getComponentContext(rSMgr), SwXMLExportContent_getImplementationName(),
682 : EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_SCRIPTS |
683 60 : EXPORT_FONTDECLS|EXPORT_OASIS );
684 : }
685 :
686 228 : OUString SAL_CALL SwXMLExportMeta_getImplementationName() throw()
687 : {
688 : return OUString(
689 228 : "com.sun.star.comp.Writer.XMLOasisMetaExporter" );
690 : }
691 :
692 18 : Sequence< OUString > SAL_CALL SwXMLExportMeta_getSupportedServiceNames()
693 : throw()
694 : {
695 18 : const OUString aServiceName(SwXMLExportMeta_getImplementationName());
696 18 : const Sequence< OUString > aSeq( &aServiceName, 1 );
697 18 : return aSeq;
698 : }
699 :
700 52 : Reference< XInterface > SAL_CALL SwXMLExportMeta_createInstance(
701 : const Reference< XMultiServiceFactory > & rSMgr)
702 : throw( Exception )
703 : {
704 52 : return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), SwXMLExportMeta_getImplementationName(), EXPORT_META|EXPORT_OASIS);
705 : }
706 :
707 224 : OUString SAL_CALL SwXMLExportSettings_getImplementationName() throw()
708 : {
709 : return OUString(
710 224 : "com.sun.star.comp.Writer.XMLOasisSettingsExporter" );
711 : }
712 :
713 22 : Sequence< OUString > SAL_CALL SwXMLExportSettings_getSupportedServiceNames()
714 : throw()
715 : {
716 22 : const OUString aServiceName(SwXMLExportSettings_getImplementationName());
717 22 : const Sequence< OUString > aSeq( &aServiceName, 1 );
718 22 : return aSeq;
719 : }
720 :
721 58 : Reference< XInterface > SAL_CALL SwXMLExportSettings_createInstance(
722 : const Reference< XMultiServiceFactory > & rSMgr)
723 : throw( Exception )
724 : {
725 58 : return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), SwXMLExportSettings_getImplementationName(), EXPORT_SETTINGS|EXPORT_OASIS);
726 : }
727 :
728 : namespace
729 : {
730 : class theSwXMLExportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXMLExportUnoTunnelId > {};
731 : }
732 :
733 0 : const Sequence< sal_Int8 > & SwXMLExport::getUnoTunnelId() throw()
734 : {
735 0 : return theSwXMLExportUnoTunnelId::get().getSeq();
736 : }
737 :
738 0 : sal_Int64 SAL_CALL SwXMLExport::getSomething( const Sequence< sal_Int8 >& rId )
739 : throw(RuntimeException, std::exception)
740 : {
741 0 : if( rId.getLength() == 16
742 0 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
743 0 : rId.getConstArray(), 16 ) )
744 : {
745 0 : return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
746 : }
747 0 : return SvXMLExport::getSomething( rId );
748 : }
749 :
750 588 : SwDoc* SwXMLExport::getDoc()
751 : {
752 588 : if( doc != NULL )
753 358 : return doc;
754 230 : Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
755 460 : Reference < XText > xText = xTextDoc->getText();
756 460 : Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
757 : assert( xTextTunnel.is());
758 : SwXText *pText = reinterpret_cast< SwXText *>(
759 230 : sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
760 : assert( pText != NULL );
761 230 : doc = pText->GetDoc();
762 : assert( doc != NULL );
763 460 : return doc;
764 : }
765 :
766 0 : const SwDoc* SwXMLExport::getDoc() const
767 : {
768 0 : return const_cast< SwXMLExport* >( this )->getDoc();
769 270 : }
770 :
771 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|