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