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 286 : SwXMLExport::SwXMLExport(
86 : const uno::Reference< uno::XComponentContext >& rContext,
87 : OUString const & implementationName, SvXMLExportFlags nExportFlags)
88 : : SvXMLExport( util::MeasureUnit::INCH, rContext, 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 286 : sCell("Cell")
99 : {
100 286 : _InitItemExport();
101 286 : }
102 :
103 2 : void SwXMLExport::setBlockMode()
104 : {
105 2 : bBlock = true;
106 :
107 2 : }
108 :
109 280 : sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
110 : {
111 280 : if( !GetModel().is() )
112 0 : return ERR_SWG_WRITE_ERROR;
113 :
114 280 : SwPauseThreadStarting aPauseThreadStarting; // #i73788#
115 :
116 : // from here, we use core interfaces -> lock Solar-Mutex
117 560 : SolarMutexGuard aGuard;
118 :
119 : {
120 280 : Reference<XPropertySet> rInfoSet = getExportInfo();
121 280 : if( rInfoSet.is() )
122 : {
123 280 : const OUString sAutoTextMode("AutoTextMode");
124 560 : if( rInfoSet->getPropertySetInfo()->hasPropertyByName(
125 280 : sAutoTextMode ) )
126 : {
127 278 : Any aAny = rInfoSet->getPropertyValue(sAutoTextMode);
128 280 : if( aAny.getValueType() == cppu::UnoType<bool>::get() &&
129 2 : *static_cast<const sal_Bool*>(aAny.getValue()) )
130 2 : setBlockMode();
131 280 : }
132 280 : }
133 : }
134 :
135 280 : SwDoc *pDoc = getDoc();
136 :
137 280 : bool bExtended = false;
138 280 : if( getExportFlags() & (SvXMLExportFlags::FONTDECLS|SvXMLExportFlags::STYLES|
139 280 : SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::CONTENT))
140 : {
141 144 : if( getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
142 : {
143 144 : _GetNamespaceMap().Add(
144 144 : GetXMLToken(XML_NP_OFFICE_EXT),
145 144 : GetXMLToken(XML_N_OFFICE_EXT),
146 144 : XML_NAMESPACE_OFFICE_EXT);
147 : }
148 :
149 144 : GetTextParagraphExport()->SetBlockMode( bBlock );
150 :
151 144 : 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 144 : EE_CHAR_XMLATTRIBS };
157 :
158 144 : const int nWhichIds = rPool.GetSecondaryPool() ? 5 : 2;
159 864 : for( int j=0; j < nWhichIds; ++j )
160 : {
161 720 : const sal_uInt16 nWhichId = aWhichIds[j];
162 720 : const sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
163 728 : for( sal_uInt32 i = 0; i < nItems; ++i )
164 : {
165 8 : const SfxPoolItem* const pItem = rPool.GetItem2( nWhichId , i );
166 8 : if( 0 != pItem )
167 : {
168 : const SvXMLAttrContainerItem *pUnknown =
169 4 : PTR_CAST( SvXMLAttrContainerItem, pItem );
170 : OSL_ENSURE( pUnknown, "illegal attribute container item" );
171 4 : 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 280 : SW_MOD()->GetMetric(pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE)));
190 280 : if (GetMM100UnitConverter().GetXMLMeasureUnit() != eUnit )
191 : {
192 0 : GetMM100UnitConverter().SetXMLMeasureUnit( eUnit );
193 0 : pTwipUnitConv->SetXMLMeasureUnit( eUnit );
194 : }
195 :
196 280 : SetExtended( bExtended );
197 :
198 280 : if( getExportFlags() & SvXMLExportFlags::META)
199 : {
200 : // Update doc stat, so that correct values are exported and
201 : // the progress works correctly.
202 68 : pDoc->getIDocumentStatistics().UpdateDocStat( false, true );
203 : }
204 280 : if( bShowProgress )
205 : {
206 280 : ProgressBarHelper *pProgress = GetProgressBarHelper();
207 280 : 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 71 : sal_Int32 nRef = 1; // meta.xml
223 71 : nRef += pDoc->GetCharFormats()->size() - 1;
224 71 : nRef += pDoc->GetFrameFormats()->size() - 1;
225 71 : nRef += pDoc->GetTextFormatColls()->size() - 1;
226 71 : nRef *= 2; // for the above styles, xmloff will increment by 2!
227 : // #i93174#: count all paragraphs for the progress bar
228 71 : nRef += pDoc->getIDocumentStatistics().GetUpdatedDocStat( false, true ).nAllPara; // 1: only content, no autostyle
229 71 : pProgress->SetReference( nRef );
230 71 : pProgress->SetValue( 0 );
231 : }
232 : }
233 :
234 280 : if( getExportFlags() & (SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::CONTENT))
235 : {
236 : //Auf die Korrektheit der OrdNums sind wir schon angewiesen.
237 144 : SwDrawModel* pModel = pDoc->getIDocumentDrawModelAccess().GetDrawModel();
238 144 : if( pModel )
239 144 : pModel->GetPage( 0 )->RecalcObjOrdNums();
240 : }
241 :
242 : // adjust document class (eClass)
243 280 : if (pDoc->getIDocumentSettingAccess().get(DocumentSettingId::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(DocumentSettingId::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 280 : SvXMLGraphicHelper *pGraphicResolver = 0;
255 280 : if( !GetGraphicResolver().is() )
256 : {
257 138 : pGraphicResolver = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_WRITE );
258 138 : Reference< XGraphicObjectResolver > xGraphicResolver( pGraphicResolver );
259 138 : SetGraphicResolver( xGraphicResolver );
260 : }
261 :
262 280 : SvXMLEmbeddedObjectHelper *pEmbeddedResolver = 0;
263 280 : if( !GetEmbeddedResolver().is() )
264 : {
265 138 : SfxObjectShell *pPersist = pDoc->GetPersist();
266 138 : if( pPersist )
267 : {
268 : pEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
269 : *pPersist,
270 138 : EMBEDDEDOBJECTHELPER_MODE_WRITE );
271 138 : Reference< XEmbeddedObjectResolver > xEmbeddedResolver( pEmbeddedResolver );
272 138 : 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 280 : bool( getExportFlags() & (SvXMLExportFlags::CONTENT|SvXMLExportFlags::STYLES) );
280 280 : 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 144 : Reference<XPropertySet> rInfoSet = getExportInfo();
286 144 : if( rInfoSet.is() )
287 : {
288 288 : bSaveRedline = ! rInfoSet->getPropertySetInfo()->hasPropertyByName(
289 144 : "ShowChanges" );
290 144 : }
291 : }
292 280 : sal_uInt16 nRedlineMode = 0;
293 280 : bSavedShowChanges = IDocumentRedlineAccess::IsShowChanges( pDoc->getIDocumentRedlineAccess().GetRedlineMode() );
294 280 : if( bSaveRedline )
295 : {
296 : // now save and switch redline mode
297 2 : nRedlineMode = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
298 2 : pDoc->getIDocumentRedlineAccess().SetRedlineMode(
299 2 : (RedlineMode_t)(( nRedlineMode & nsRedlineMode_t::REDLINE_SHOW_MASK ) | nsRedlineType_t::REDLINE_INSERT ));
300 : }
301 :
302 280 : sal_uInt32 nRet = SvXMLExport::exportDoc( eClass );
303 :
304 : // now we can restore the redline mode (if we changed it previously)
305 280 : if( bSaveRedline )
306 : {
307 2 : pDoc->getIDocumentRedlineAccess().SetRedlineMode( (RedlineMode_t)(nRedlineMode ));
308 : }
309 :
310 280 : if( pGraphicResolver )
311 138 : SvXMLGraphicHelper::Destroy( pGraphicResolver );
312 280 : if( pEmbeddedResolver )
313 138 : SvXMLEmbeddedObjectHelper::Destroy( pEmbeddedResolver );
314 :
315 : OSL_ENSURE( !pTableLines, "there are table columns infos left" );
316 :
317 560 : return nRet;
318 : }
319 :
320 144 : XMLTextParagraphExport* SwXMLExport::CreateTextParagraphExport()
321 : {
322 144 : return new SwXMLTextParagraphExport( *this, *GetAutoStylePool().get() );
323 : }
324 :
325 144 : XMLShapeExport* SwXMLExport::CreateShapeExport()
326 : {
327 144 : XMLShapeExport* pShapeExport = new XMLShapeExport( *this, XMLTextParagraphExport::CreateShapeExtPropMapper( *this ) );
328 144 : Reference < XDrawPageSupplier > xDPS( GetModel(), UNO_QUERY );
329 144 : if( xDPS.is() )
330 : {
331 144 : Reference < XShapes > xShapes( xDPS->getDrawPage(), UNO_QUERY );
332 144 : pShapeExport->seekShapes( xShapes );
333 : }
334 :
335 144 : return pShapeExport;
336 : }
337 :
338 858 : SwXMLExport::~SwXMLExport()
339 : {
340 286 : DeleteTableLines();
341 286 : _FinitItemExport();
342 572 : }
343 :
344 144 : void SwXMLExport::_ExportFontDecls()
345 : {
346 144 : GetFontAutoStylePool(); // make sure the pool is created
347 144 : SvXMLExport::_ExportFontDecls();
348 144 : }
349 :
350 : #define NUM_EXPORTED_VIEW_SETTINGS 11
351 72 : void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps)
352 : {
353 72 : aProps.realloc( NUM_EXPORTED_VIEW_SETTINGS );
354 : // Currently exporting 9 properties
355 72 : PropertyValue *pValue = aProps.getArray();
356 72 : sal_Int32 nIndex = 0;
357 :
358 72 : Reference < XIndexContainer > xBox = IndexedPropertyValues::create( comphelper::getProcessComponentContext() );
359 72 : pValue[nIndex].Name = "Views";
360 72 : pValue[nIndex++].Value <<= xBox;
361 :
362 72 : SwDoc *pDoc = getDoc();
363 : const Rectangle rRect =
364 72 : pDoc->GetDocShell()->GetVisArea( ASPECT_CONTENT );
365 72 : bool bTwip = pDoc->GetDocShell()->GetMapUnit ( ) == MAP_TWIP;
366 :
367 : OSL_ENSURE( bTwip, "Map unit for visible area is not in TWIPS!" );
368 :
369 72 : pValue[nIndex].Name = "ViewAreaTop";
370 72 : pValue[nIndex++].Value <<= bTwip ? convertTwipToMm100 ( rRect.Top() ) : rRect.Top();
371 :
372 72 : pValue[nIndex].Name = "ViewAreaLeft";
373 72 : pValue[nIndex++].Value <<= bTwip ? convertTwipToMm100 ( rRect.Left() ) : rRect.Left();
374 :
375 72 : pValue[nIndex].Name = "ViewAreaWidth";
376 72 : pValue[nIndex++].Value <<= bTwip ? convertTwipToMm100 ( rRect.GetWidth() ) : rRect.GetWidth();
377 :
378 72 : pValue[nIndex].Name = "ViewAreaHeight";
379 72 : 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 72 : bool bShowRedlineChanges = bSavedShowChanges;
385 144 : Reference<XPropertySet> xInfoSet( getExportInfo() );
386 72 : if ( xInfoSet.is() )
387 : {
388 72 : const OUString sShowChanges( "ShowChanges" );
389 72 : if( xInfoSet->getPropertySetInfo()->hasPropertyByName( sShowChanges ) )
390 : {
391 70 : bShowRedlineChanges = *static_cast<sal_Bool const *>(xInfoSet->
392 70 : getPropertyValue( sShowChanges ).getValue());
393 72 : }
394 : }
395 :
396 72 : pValue[nIndex].Name = "ShowRedlineChanges";
397 72 : pValue[nIndex++].Value <<= bShowRedlineChanges;
398 :
399 72 : pValue[nIndex].Name = "InBrowseMode";
400 72 : pValue[nIndex++].Value <<= pDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE);
401 :
402 72 : if ( nIndex < NUM_EXPORTED_VIEW_SETTINGS )
403 144 : aProps.realloc(nIndex);
404 72 : }
405 : #undef NUM_EXPORTED_VIEW_SETTINGS
406 :
407 72 : void SwXMLExport::GetConfigurationSettings( Sequence < PropertyValue >& rProps)
408 : {
409 72 : Reference< XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
410 72 : if( xFac.is() )
411 : {
412 72 : Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
413 72 : if( xProps.is() )
414 72 : SvXMLUnitConverter::convertPropertySet( rProps, xProps );
415 72 : }
416 72 : }
417 :
418 72 : sal_Int32 SwXMLExport::GetDocumentSpecificSettings( ::std::list< SettingsGroup >& _out_rSettings )
419 : {
420 : // the only doc-specific settings group we know so far are the XForms settings
421 72 : uno::Sequence<beans::PropertyValue> aXFormsSettings;
422 144 : Reference< XFormsSupplier > xXFormsSupp( GetModel(), UNO_QUERY );
423 144 : Reference< XNameAccess > xXForms;
424 72 : if ( xXFormsSupp.is() )
425 72 : xXForms = xXFormsSupp->getXForms().get();
426 72 : if ( xXForms.is() )
427 : {
428 0 : getXFormsSettings( xXForms, aXFormsSettings );
429 0 : _out_rSettings.push_back( SettingsGroup( XML_XFORM_MODEL_SETTINGS, aXFormsSettings ) );
430 : }
431 :
432 144 : return aXFormsSettings.getLength() + SvXMLExport::GetDocumentSpecificSettings( _out_rSettings );
433 : }
434 :
435 73 : void SwXMLExport::SetBodyAttributes()
436 : {
437 : // export use of soft page breaks
438 73 : SwDoc *pDoc = getDoc();
439 141 : if( pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() &&
440 68 : pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->GetPageCount() > 1 )
441 : {
442 16 : bool bValue = true;
443 16 : OUStringBuffer sBuffer;
444 16 : ::sax::Converter::convertBool(sBuffer, bValue);
445 : AddAttribute(XML_NAMESPACE_TEXT, XML_USE_SOFT_PAGE_BREAKS,
446 16 : sBuffer.makeStringAndClear());
447 : }
448 73 : }
449 :
450 73 : void SwXMLExport::_ExportContent()
451 : {
452 : // export forms
453 73 : Reference<XDrawPageSupplier> xDrawPageSupplier(GetModel(), UNO_QUERY);
454 73 : if (xDrawPageSupplier.is())
455 : {
456 : // export only if we actually have elements
457 73 : Reference<XDrawPage> xPage = xDrawPageSupplier->getDrawPage();
458 73 : if (xPage.is())
459 : {
460 : // prevent export of form controls which are embedded in mute sections
461 : GetTextParagraphExport()->PreventExportOfControlsInMuteSections(
462 73 : xPage, GetFormExport() );
463 :
464 : // #i36597#
465 73 : if ( xmloff::OFormLayerXMLExport::pageContainsForms( xPage ) || GetFormExport()->documentContainsXForms() )
466 : {
467 2 : ::xmloff::OOfficeFormsExport aOfficeForms(*this);
468 :
469 2 : GetFormExport()->exportXForms();
470 :
471 2 : GetFormExport()->seekPage(xPage);
472 2 : GetFormExport()->exportForms(xPage);
473 : }
474 73 : }
475 : }
476 :
477 146 : Reference<XPropertySet> xPropSet(GetModel(), UNO_QUERY);
478 73 : if (xPropSet.is())
479 : {
480 73 : Any aAny = xPropSet->getPropertyValue( "TwoDigitYear" );
481 73 : aAny <<= (sal_Int16)1930;
482 :
483 73 : sal_Int16 nYear = 0;
484 73 : aAny >>= nYear;
485 73 : if (nYear != 1930 )
486 : {
487 0 : OUStringBuffer sBuffer;
488 0 : ::sax::Converter::convertNumber(sBuffer, nYear);
489 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NULL_YEAR, sBuffer.makeStringAndClear());
490 0 : SvXMLElementExport aCalcSettings(*this, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, true, true);
491 73 : }
492 : }
493 :
494 73 : GetTextParagraphExport()->exportTrackedChanges( false );
495 73 : GetTextParagraphExport()->exportTextDeclarations();
496 146 : Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
497 146 : Reference < XText > xText = xTextDoc->getText();
498 :
499 73 : GetTextParagraphExport()->exportFramesBoundToPage( bShowProgress );
500 146 : GetTextParagraphExport()->exportText( xText, bShowProgress );
501 73 : }
502 :
503 : namespace
504 : {
505 : class theSwXMLExportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXMLExportUnoTunnelId > {};
506 : }
507 :
508 0 : const Sequence< sal_Int8 > & SwXMLExport::getUnoTunnelId() throw()
509 : {
510 0 : return theSwXMLExportUnoTunnelId::get().getSeq();
511 : }
512 :
513 0 : sal_Int64 SAL_CALL SwXMLExport::getSomething( const Sequence< sal_Int8 >& rId )
514 : throw(RuntimeException, std::exception)
515 : {
516 0 : if( rId.getLength() == 16
517 0 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
518 0 : rId.getConstArray(), 16 ) )
519 : {
520 0 : return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
521 : }
522 0 : return SvXMLExport::getSomething( rId );
523 : }
524 :
525 713 : SwDoc* SwXMLExport::getDoc()
526 : {
527 713 : if( doc != NULL )
528 433 : return doc;
529 280 : Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
530 560 : Reference < XText > xText = xTextDoc->getText();
531 560 : Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
532 : assert( xTextTunnel.is());
533 : SwXText *pText = reinterpret_cast< SwXText *>(
534 280 : sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
535 : assert( pText != NULL );
536 280 : doc = pText->GetDoc();
537 : assert( doc != NULL );
538 560 : return doc;
539 : }
540 :
541 0 : const SwDoc* SwXMLExport::getDoc() const
542 : {
543 0 : return const_cast< SwXMLExport* >( this )->getDoc();
544 : }
545 :
546 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
547 2 : com_sun_star_comp_Writer_XMLExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
548 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
549 : {
550 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLExporter"),
551 2 : SvXMLExportFlags::ALL));
552 : }
553 :
554 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
555 2 : com_sun_star_comp_Writer_XMLStylesExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
556 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
557 : {
558 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLStylesExporter"),
559 4 : SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES | SvXMLExportFlags::AUTOSTYLES |
560 6 : SvXMLExportFlags::FONTDECLS));
561 : }
562 :
563 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
564 2 : com_sun_star_comp_Writer_XMLContentExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
565 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
566 : {
567 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLContentExporter"),
568 4 : SvXMLExportFlags::SCRIPTS | SvXMLExportFlags::CONTENT | SvXMLExportFlags::AUTOSTYLES |
569 6 : SvXMLExportFlags::FONTDECLS));
570 : }
571 :
572 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
573 0 : com_sun_star_comp_Writer_XMLMetaExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
574 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
575 : {
576 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLMetaExporter"),
577 0 : SvXMLExportFlags::META));
578 : }
579 :
580 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
581 2 : com_sun_star_comp_Writer_XMLSettingsExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
582 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
583 : {
584 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLSettingsExporter"),
585 2 : SvXMLExportFlags::SETTINGS));
586 : }
587 :
588 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
589 0 : com_sun_star_comp_Writer_XMLOasisExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
590 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
591 : {
592 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLOasisExporter"),
593 0 : SvXMLExportFlags::ALL | SvXMLExportFlags::OASIS));
594 : }
595 :
596 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
597 71 : com_sun_star_comp_Writer_XMLOasisStylesExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
598 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
599 : {
600 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLOasisStylesExporter"),
601 : SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES | SvXMLExportFlags::AUTOSTYLES |
602 71 : SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::OASIS));
603 : }
604 :
605 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
606 71 : com_sun_star_comp_Writer_XMLOasisContentExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
607 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
608 : {
609 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLOasisContentExporter"),
610 : SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS |
611 71 : SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::OASIS));
612 : }
613 :
614 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
615 66 : com_sun_star_comp_Writer_XMLOasisMetaExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
616 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
617 : {
618 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLOasisMetaExporter"),
619 66 : SvXMLExportFlags::META | SvXMLExportFlags::OASIS));
620 : }
621 :
622 : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
623 70 : com_sun_star_comp_Writer_XMLOasisSettingsExporter_get_implementation(::com::sun::star::uno::XComponentContext* context,
624 : ::com::sun::star::uno::Sequence<css::uno::Any> const &)
625 : {
626 : return cppu::acquire(new SwXMLExport(context, OUString("com.sun.star.comp.Writer.XMLOasisSettingsExporter"),
627 70 : SvXMLExportFlags::SETTINGS | SvXMLExportFlags::OASIS));
628 177 : }
629 :
630 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|