merge the formfield patch from ooo-build
[ooovba.git] / sw / source / filter / xml / xmlimp.cxx
blob666a717bc15379a7d27888e3a10159137492ffdd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlimp.cxx,v $
10 * $Revision: 1.107 $
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"
33 #include <com/sun/star/text/XTextDocument.hpp>
34 #include <com/sun/star/text/XTextRange.hpp>
35 #include <com/sun/star/drawing/XDrawPage.hpp>
36 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
37 #include <com/sun/star/container/XIndexAccess.hpp>
38 #include <xmloff/xmlnmspe.hxx>
39 #include <xmloff/xmltkmap.hxx>
40 #include <xmloff/xmlictxt.hxx>
41 #ifndef _XMLOFF_TXTIMP_HXX
42 #include <xmloff/txtimp.hxx>
43 #endif
44 #include <xmloff/nmspmap.hxx>
45 #ifndef _XMLOFF_XMLTEXTSHAPEIMPORTHELPER_HXX_
46 #include <xmloff/XMLTextShapeImportHelper.hxx>
47 #endif
48 #include <xmloff/XMLFontStylesContext.hxx>
49 #include <xmloff/ProgressBarHelper.hxx>
50 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
51 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
52 #include <doc.hxx>
53 #include <unoobj.hxx>
54 #include "unocrsr.hxx"
55 #include <poolfmt.hxx>
56 #include <ndtxt.hxx>
57 #include <editsh.hxx>
58 #include "xmlimp.hxx"
59 #include <xmloff/DocumentSettingsContext.hxx>
60 #include <docsh.hxx>
61 #include <svx/unolingu.hxx>
62 #include <svx/svdmodel.hxx>
63 #include <svx/xmlgrhlp.hxx>
64 #include <svx/xmleohlp.hxx>
65 #include <sfx2/printer.hxx>
66 #include <ForbiddenCharactersEnum.hxx>
67 #include <xmloff/xmluconv.hxx>
68 #include <svtools/saveopt.hxx>
69 #include <tools/diagnose_ex.h>
70 #include <hash_set>
71 #include <stringhash.hxx>
73 // for locking SolarMutex: svapp + mutex
74 #include <vcl/svapp.hxx>
75 #include <vos/mutex.hxx>
76 #include <unotxdoc.hxx> // for initXForms()
78 #include <xmloff/xmlmetai.hxx>
79 #include <xmloff/xformsimport.hxx>
81 using ::rtl::OUString;
83 using namespace ::com::sun::star;
84 using namespace ::com::sun::star::uno;
85 using namespace ::com::sun::star::text;
86 using namespace ::com::sun::star::lang;
87 using namespace ::com::sun::star::beans;
88 using namespace ::com::sun::star::container;
89 using namespace ::com::sun::star::i18n;
90 using namespace ::com::sun::star::drawing;
91 using namespace ::com::sun::star::xforms;
92 using namespace ::xmloff::token;
93 using namespace ::std;
95 struct OUStringEquals
97 sal_Bool operator()( const rtl::OUString &r1,
98 const rtl::OUString &r2) const
100 return r1 == r2;
104 //----------------------------------------------------------------------------
106 enum SwXMLDocTokens
108 XML_TOK_DOC_FONTDECLS,
109 XML_TOK_DOC_STYLES,
110 XML_TOK_DOC_AUTOSTYLES,
111 XML_TOK_DOC_MASTERSTYLES,
112 XML_TOK_DOC_META,
113 XML_TOK_DOC_BODY,
114 XML_TOK_DOC_SCRIPT,
115 XML_TOK_DOC_SETTINGS,
116 XML_TOK_DOC_XFORMS,
117 XML_TOK_OFFICE_END=XML_TOK_UNKNOWN
120 static __FAR_DATA SvXMLTokenMapEntry aDocTokenMap[] =
122 { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS, XML_TOK_DOC_FONTDECLS },
123 { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES },
124 { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES },
125 { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, XML_TOK_DOC_MASTERSTYLES },
126 { XML_NAMESPACE_OFFICE, XML_META, XML_TOK_DOC_META },
127 { XML_NAMESPACE_OFFICE, XML_BODY, XML_TOK_DOC_BODY },
128 { XML_NAMESPACE_OFFICE, XML_SCRIPTS, XML_TOK_DOC_SCRIPT },
129 { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS },
130 { XML_NAMESPACE_XFORMS, XML_MODEL, XML_TOK_DOC_XFORMS },
131 XML_TOKEN_MAP_END
134 // ----------------------------------------------------------------------------
136 class SwXMLBodyContext_Impl : public SvXMLImportContext
138 const SwXMLImport& GetSwImport() const
139 { return (const SwXMLImport&)GetImport(); }
140 SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
142 public:
144 SwXMLBodyContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
145 const OUString& rLName,
146 const Reference< xml::sax::XAttributeList > & xAttrList );
147 virtual ~SwXMLBodyContext_Impl();
149 TYPEINFO();
151 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
152 const OUString& rLocalName,
153 const Reference< xml::sax::XAttributeList > & xAttrList );
156 SwXMLBodyContext_Impl::SwXMLBodyContext_Impl( SwXMLImport& rImport,
157 sal_uInt16 nPrfx, const OUString& rLName,
158 const Reference< xml::sax::XAttributeList > & /*xAttrList*/ ) :
159 SvXMLImportContext( rImport, nPrfx, rLName )
163 SwXMLBodyContext_Impl::~SwXMLBodyContext_Impl()
167 TYPEINIT1( SwXMLBodyContext_Impl, SvXMLImportContext );
169 SvXMLImportContext *SwXMLBodyContext_Impl::CreateChildContext(
170 sal_uInt16 /*nPrefix*/,
171 const OUString& rLocalName,
172 const Reference< xml::sax::XAttributeList > & /*xAttrList*/ )
174 return GetSwImport().CreateBodyContentContext( rLocalName );
177 // ----------------------------------------------------------------------------
179 // --> OD 2006-10-11 #i69629#
180 // enhance class <SwXMLDocContext_Impl> in order to be able to create subclasses
181 // NB: virtually inherit so we can multiply inherit properly
182 // in SwXMLOfficeDocContext_Impl
183 class SwXMLDocContext_Impl : public virtual SvXMLImportContext
185 // --> OD 2006-10-11 #i69629#
186 protected:
187 // <--
188 const SwXMLImport& GetSwImport() const
189 { return (const SwXMLImport&)GetImport(); }
190 SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
192 public:
194 SwXMLDocContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
195 const OUString& rLName,
196 const Reference< xml::sax::XAttributeList > & xAttrList );
197 virtual ~SwXMLDocContext_Impl();
199 TYPEINFO();
201 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
202 const OUString& rLocalName,
203 const Reference< xml::sax::XAttributeList > & xAttrList );
206 SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport,
207 sal_uInt16 nPrfx, const OUString& rLName,
208 const Reference< xml::sax::XAttributeList > & /*xAttrList*/ ) :
209 SvXMLImportContext( rImport, nPrfx, rLName )
213 SwXMLDocContext_Impl::~SwXMLDocContext_Impl()
217 TYPEINIT1( SwXMLDocContext_Impl, SvXMLImportContext );
219 SvXMLImportContext *SwXMLDocContext_Impl::CreateChildContext(
220 sal_uInt16 nPrefix,
221 const OUString& rLocalName,
222 const Reference< xml::sax::XAttributeList > & xAttrList )
224 SvXMLImportContext *pContext = 0;
226 const SvXMLTokenMap& rTokenMap = GetSwImport().GetDocElemTokenMap();
227 switch( rTokenMap.Get( nPrefix, rLocalName ) )
229 case XML_TOK_DOC_FONTDECLS:
230 pContext = GetSwImport().CreateFontDeclsContext( rLocalName,
231 xAttrList );
232 break;
233 case XML_TOK_DOC_STYLES:
234 GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
235 pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList,
236 sal_False );
237 break;
238 case XML_TOK_DOC_AUTOSTYLES:
239 // don't use the autostyles from the styles-document for the progress
240 if ( ! IsXMLToken( GetLocalName(), XML_DOCUMENT_STYLES ) )
241 GetSwImport().GetProgressBarHelper()->Increment
242 ( PROGRESS_BAR_STEP );
243 pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList,
244 sal_True );
245 break;
246 // case XML_TOK_DOC_USESTYLES:
247 // pContext = GetSwImport().CreateUseStylesContext( rLocalName,
248 // xAttrList );
249 // break;
250 case XML_TOK_DOC_MASTERSTYLES:
251 pContext = GetSwImport().CreateMasterStylesContext( rLocalName,
252 xAttrList );
253 break;
254 case XML_TOK_DOC_META:
255 DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
256 break;
257 case XML_TOK_DOC_SCRIPT:
258 pContext = GetSwImport().CreateScriptContext( rLocalName );
259 break;
260 case XML_TOK_DOC_BODY:
261 GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
262 pContext = new SwXMLBodyContext_Impl( GetSwImport(), nPrefix,
263 rLocalName, xAttrList );
264 break;
265 case XML_TOK_DOC_SETTINGS:
266 pContext = new XMLDocumentSettingsContext( GetImport(), nPrefix, rLocalName, xAttrList );
267 break;
268 case XML_TOK_DOC_XFORMS:
269 pContext = createXFormsModelContext(GetImport(), nPrefix, rLocalName);
270 break;
273 if( !pContext )
274 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
277 return pContext;
280 // --> OD 2006-10-11 #i69629#
281 // new subclass <SwXMLOfficeDocContext_Impl> of class <SwXMLDocContext_Impl>
282 class SwXMLOfficeDocContext_Impl :
283 public SwXMLDocContext_Impl, public SvXMLMetaDocumentContext
285 public:
287 SwXMLOfficeDocContext_Impl( SwXMLImport& rImport,
288 sal_uInt16 nPrfx,
289 const OUString& rLName,
290 const Reference< xml::sax::XAttributeList > & xAttrList,
291 const Reference< document::XDocumentProperties >& xDocProps,
292 const Reference< xml::sax::XDocumentHandler >& xDocBuilder);
293 virtual ~SwXMLOfficeDocContext_Impl();
295 TYPEINFO();
297 virtual SvXMLImportContext *CreateChildContext(
298 sal_uInt16 nPrefix,
299 const OUString& rLocalName,
300 const Reference< xml::sax::XAttributeList > & xAttrList );
303 SwXMLOfficeDocContext_Impl::SwXMLOfficeDocContext_Impl(
304 SwXMLImport& rImport,
305 sal_uInt16 nPrfx,
306 const OUString& rLName,
307 const Reference< xml::sax::XAttributeList > & xAttrList,
308 const Reference< document::XDocumentProperties >& xDocProps,
309 const Reference< xml::sax::XDocumentHandler >& xDocBuilder) :
310 SvXMLImportContext( rImport, nPrfx, rLName ),
311 SwXMLDocContext_Impl( rImport, nPrfx, rLName, xAttrList ),
312 SvXMLMetaDocumentContext( rImport, nPrfx, rLName, xDocProps, xDocBuilder)
316 SwXMLOfficeDocContext_Impl::~SwXMLOfficeDocContext_Impl()
320 TYPEINIT1( SwXMLOfficeDocContext_Impl, SwXMLDocContext_Impl );
322 SvXMLImportContext* SwXMLOfficeDocContext_Impl::CreateChildContext(
323 sal_uInt16 nPrefix,
324 const OUString& rLocalName,
325 const Reference< xml::sax::XAttributeList > & xAttrList )
327 const SvXMLTokenMap& rTokenMap = GetSwImport().GetDocElemTokenMap();
329 // assign paragraph styles to list levels of outline style after all styles
330 // are imported and finished. This is the case, when <office:body> starts
331 // in flat OpenDocument file format.
333 if ( rTokenMap.Get( nPrefix, rLocalName ) == XML_TOK_DOC_BODY )
335 GetImport().GetTextImport()->SetOutlineStyles( sal_True );
339 // behave like meta base class iff we encounter office:meta
340 if ( XML_TOK_DOC_META == rTokenMap.Get( nPrefix, rLocalName ) ) {
341 return SvXMLMetaDocumentContext::CreateChildContext(
342 nPrefix, rLocalName, xAttrList );
343 } else {
344 return SwXMLDocContext_Impl::CreateChildContext(
345 nPrefix, rLocalName, xAttrList );
348 // <--
350 // --> OD 2006-10-11 #i69629#
351 // new subclass <SwXMLDocStylesContext_Impl> of class <SwXMLDocContext_Impl>
352 class SwXMLDocStylesContext_Impl : public SwXMLDocContext_Impl
354 public:
356 SwXMLDocStylesContext_Impl( SwXMLImport& rImport,
357 sal_uInt16 nPrfx,
358 const OUString& rLName,
359 const Reference< xml::sax::XAttributeList > & xAttrList );
360 virtual ~SwXMLDocStylesContext_Impl();
362 TYPEINFO();
364 virtual void EndElement();
367 SwXMLDocStylesContext_Impl::SwXMLDocStylesContext_Impl(
368 SwXMLImport& rImport,
369 sal_uInt16 nPrfx,
370 const OUString& rLName,
371 const Reference< xml::sax::XAttributeList > & xAttrList ) :
372 SvXMLImportContext( rImport, nPrfx, rLName ),
373 SwXMLDocContext_Impl( rImport, nPrfx, rLName, xAttrList )
377 SwXMLDocStylesContext_Impl::~SwXMLDocStylesContext_Impl()
381 TYPEINIT1( SwXMLDocStylesContext_Impl, SwXMLDocContext_Impl );
383 void SwXMLDocStylesContext_Impl::EndElement()
385 // assign paragraph styles to list levels of outline style after all styles
386 // are imported and finished.
387 SwXMLImport& rSwImport = dynamic_cast<SwXMLImport&>( GetImport());
388 GetImport().GetTextImport()->SetOutlineStyles(
389 (rSwImport.GetStyleFamilyMask() & SFX_STYLE_FAMILY_PARA ) ? sal_True : sal_False);
390 // <--
392 // <--
393 //----------------------------------------------------------------------------
395 const SvXMLTokenMap& SwXMLImport::GetDocElemTokenMap()
397 if( !pDocElemTokenMap )
398 pDocElemTokenMap = new SvXMLTokenMap( aDocTokenMap );
400 return *pDocElemTokenMap;
403 SvXMLImportContext *SwXMLImport::CreateContext(
404 sal_uInt16 nPrefix,
405 const OUString& rLocalName,
406 const Reference< xml::sax::XAttributeList > & xAttrList )
408 SvXMLImportContext *pContext = 0;
410 // --> OD 2006-10-11 #i69629#
411 // own subclasses for <office:document> and <office:document-styles>
412 if( XML_NAMESPACE_OFFICE==nPrefix &&
413 // ( IsXMLToken( rLocalName, XML_DOCUMENT ) ||
414 // ( IsXMLToken( rLocalName, XML_DOCUMENT_META ) ||
415 ( IsXMLToken( rLocalName, XML_DOCUMENT_SETTINGS ) ||
416 // IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) ||
417 IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT ) ))
418 pContext = new SwXMLDocContext_Impl( *this, nPrefix, rLocalName,
419 xAttrList );
420 else if ( XML_NAMESPACE_OFFICE==nPrefix &&
421 IsXMLToken( rLocalName, XML_DOCUMENT_META ) )
423 pContext = CreateMetaContext(rLocalName);
425 else if ( XML_NAMESPACE_OFFICE==nPrefix &&
426 IsXMLToken( rLocalName, XML_DOCUMENT ) )
428 uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
429 mxServiceFactory->createInstance(::rtl::OUString::createFromAscii(
430 "com.sun.star.xml.dom.SAXDocumentBuilder")),
431 uno::UNO_QUERY_THROW);
432 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
433 GetModel(), UNO_QUERY_THROW);
434 // flat OpenDocument file format
435 pContext = new SwXMLOfficeDocContext_Impl( *this, nPrefix, rLocalName,
436 xAttrList, xDPS->getDocumentProperties(), xDocBuilder);
438 else if ( XML_NAMESPACE_OFFICE==nPrefix &&
439 IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) )
441 pContext = new SwXMLDocStylesContext_Impl( *this, nPrefix, rLocalName,
442 xAttrList );
444 // <--
445 else
446 pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
448 return pContext;
451 // #110680#
452 SwXMLImport::SwXMLImport(
453 const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
454 sal_uInt16 nImportFlags)
455 : SvXMLImport( xServiceFactory, nImportFlags ),
456 pSttNdIdx( 0 ),
457 pTableItemMapper( 0 ),
458 pDocElemTokenMap( 0 ),
459 pTableElemTokenMap( 0 ),
460 pTableCellAttrTokenMap( 0 ),
461 pGraphicResolver( 0 ),
462 pEmbeddedResolver( 0 ),
463 nStyleFamilyMask( SFX_STYLE_FAMILY_ALL ),
464 bLoadDoc( sal_True ),
465 bInsert( sal_False ),
466 bBlock( sal_False ),
467 bShowProgress( sal_True ),
468 bOrganizerMode( sal_False ),
469 bInititedXForms( sal_False ),
470 bPreserveRedlineMode( sal_True )
472 _InitItemImport();
476 #ifdef XML_CORE_API
477 // #110680#
478 SwXMLImport::SwXMLImport(
479 const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
480 SwDoc& rDoc,
481 const SwPaM& rPaM,
482 sal_Bool bLDoc,
483 sal_Bool bInsertMode,
484 sal_uInt16 nStyleFamMask,
485 const uno::Reference< frame::XModel > & rModel,
486 const uno::Reference< document::XGraphicObjectResolver > & rEGO,
487 SvStorage *pPkg )
488 : SvXMLImport( xServiceFactory, rModel, rEGO ),
489 bLoadDoc( bLDoc ),
490 bInsert( bInsertMode ),
491 nStyleFamilyMask( nStyleFamMask ),
492 pDocElemTokenMap( 0 ),
493 pTableElemTokenMap( 0 ),
494 pTableCellAttrTokenMap( 0 ),
495 pTableItemMapper( 0 ),
496 pSttNdIdx( 0 ),
497 bShowProgress( sal_True ),
498 bPreserveRedlineMode( sal_True ),
499 xPackage( pPkg )
501 _InitItemImport();
503 Reference < XTextRange > xTextRange =
504 SwXTextRange::CreateTextRangeFromPosition( &rDoc, *rPaM.GetPoint(), 0 );
505 Reference < XText > xText = xTextRange->getText();
506 Reference < XTextCursor > xTextCursor =
507 xText->createTextCursorByRange( xTextRange );
508 GetTextImport()->SetCursor( xTextCursor );
510 #endif
512 SwXMLImport::~SwXMLImport() throw ()
514 delete pDocElemTokenMap;
515 delete pTableElemTokenMap;
516 delete pTableCellAttrTokenMap;
517 _FinitItemImport();
520 void SwXMLImport::setTextInsertMode(
521 const Reference< XTextRange > & rInsertPos )
523 bInsert = sal_True;
525 Reference < XText > xText = rInsertPos->getText();
526 Reference < XTextCursor > xTextCursor =
527 xText->createTextCursorByRange( rInsertPos );
528 GetTextImport()->SetCursor( xTextCursor );
531 void SwXMLImport::setStyleInsertMode( sal_uInt16 nFamilies,
532 sal_Bool bOverwrite )
534 bInsert = !bOverwrite;
535 nStyleFamilyMask = nFamilies;
536 bLoadDoc = sal_False;
539 void SwXMLImport::setBlockMode( )
541 bBlock = sal_True;
544 void SwXMLImport::setOrganizerMode( )
546 bOrganizerMode = sal_True;
549 const Sequence< sal_Int8 > & SwXMLImport::getUnoTunnelId() throw()
551 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
552 return aSeq;
555 sal_Int64 SAL_CALL SwXMLImport::getSomething( const Sequence< sal_Int8 >& rId )
556 throw(RuntimeException)
558 if( rId.getLength() == 16
559 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
560 rId.getConstArray(), 16 ) )
562 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
564 return SvXMLImport::getSomething( rId );
567 OTextCursorHelper *lcl_xml_GetSwXTextCursor( const Reference < XTextCursor >& rTextCursor )
569 Reference<XUnoTunnel> xCrsrTunnel( rTextCursor, UNO_QUERY );
570 ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
571 if( !xCrsrTunnel.is() )
572 return 0;
573 OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper *>(
574 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
575 ASSERT( pTxtCrsr, "SwXTextCursor missing" );
576 return pTxtCrsr;
579 void SwXMLImport::startDocument( void )
580 throw( xml::sax::SAXException, uno::RuntimeException )
582 // delegate to parent
583 SvXMLImport::startDocument();
585 DBG_ASSERT( GetModel().is(), "model is missing" );
586 if( !GetModel().is() )
587 return;
589 // this method will modify the document directly -> lock SolarMutex
590 vos::OGuard aGuard(Application::GetSolarMutex());
593 Reference< XPropertySet > xImportInfo( getImportInfo() );
594 Reference< XPropertySetInfo > xPropertySetInfo;
595 if( xImportInfo.is() )
596 xPropertySetInfo = xImportInfo->getPropertySetInfo();
597 if( xPropertySetInfo.is() )
599 Any aAny;
600 // insert style mode?
601 OUString sStyleInsertModeFamilies(
602 RTL_CONSTASCII_USTRINGPARAM("StyleInsertModeFamilies"));
603 if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeFamilies) )
605 aAny = xImportInfo->getPropertyValue(sStyleInsertModeFamilies);
606 Sequence< OUString> aFamiliesSeq;
607 if( aAny >>= aFamiliesSeq )
609 OUString sFrameStyles( RTL_CONSTASCII_USTRINGPARAM ( "FrameStyles" ) );
610 OUString sPageStyles( RTL_CONSTASCII_USTRINGPARAM ( "PageStyles" ) );
611 OUString sCharacterStyles( RTL_CONSTASCII_USTRINGPARAM ( "CharacterStyles" ) );
612 OUString sParagraphStyles( RTL_CONSTASCII_USTRINGPARAM ( "ParagraphStyles" ) );
613 OUString sNumberingStyles( RTL_CONSTASCII_USTRINGPARAM ( "NumberingStyles" ) );
614 sal_uInt16 nFamilyMask = 0U;
615 sal_Int32 nCount = aFamiliesSeq.getLength();
616 const OUString *pSeq = aFamiliesSeq.getConstArray();
617 for( sal_Int32 i=0; i < nCount; i++ )
619 const OUString& rFamily = pSeq[i];
620 if( rFamily==sFrameStyles )
621 nFamilyMask |= SFX_STYLE_FAMILY_FRAME;
622 else if( rFamily==sPageStyles )
623 nFamilyMask |= SFX_STYLE_FAMILY_PAGE;
624 else if( rFamily==sCharacterStyles )
625 nFamilyMask |= SFX_STYLE_FAMILY_CHAR;
626 else if( rFamily==sParagraphStyles )
627 nFamilyMask |= SFX_STYLE_FAMILY_PARA;
628 else if( rFamily==sNumberingStyles )
629 nFamilyMask |= SFX_STYLE_FAMILY_PSEUDO;
632 sal_Bool bOverwrite = sal_False;
633 OUString sStyleInsertModeOverwrite(
634 RTL_CONSTASCII_USTRINGPARAM("StyleInsertModeOverwrite"));
635 if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeOverwrite) )
637 aAny = xImportInfo->getPropertyValue(sStyleInsertModeOverwrite);
638 if( aAny.getValueType() == ::getBooleanCppuType() &&
639 *static_cast<const sal_Bool*>(aAny.getValue()) )
640 bOverwrite = sal_True;
643 setStyleInsertMode( nFamilyMask, bOverwrite );
647 // text insert mode?
648 OUString sTextInsertModeRange(
649 RTL_CONSTASCII_USTRINGPARAM("TextInsertModeRange"));
650 if( xPropertySetInfo->hasPropertyByName(sTextInsertModeRange) )
652 aAny = xImportInfo->getPropertyValue(sTextInsertModeRange);
653 Reference<XTextRange> xInsertTextRange;
654 if( aAny >>= xInsertTextRange )
655 setTextInsertMode( xInsertTextRange );
658 // auto text mode
659 OUString sAutoTextMode(
660 RTL_CONSTASCII_USTRINGPARAM("AutoTextMode"));
661 if( xPropertySetInfo->hasPropertyByName(sAutoTextMode) )
663 aAny = xImportInfo->getPropertyValue(sAutoTextMode);
664 if( aAny.getValueType() == ::getBooleanCppuType() &&
665 *static_cast<const sal_Bool*>(aAny.getValue()) )
666 setBlockMode();
669 // organizer mode
670 OUString sOrganizerMode(
671 RTL_CONSTASCII_USTRINGPARAM("OrganizerMode"));
672 if( xPropertySetInfo->hasPropertyByName(sOrganizerMode) )
674 aAny = xImportInfo->getPropertyValue(sOrganizerMode);
675 if( aAny.getValueType() == ::getBooleanCppuType() &&
676 *static_cast<const sal_Bool*>(aAny.getValue()) )
677 setOrganizerMode();
681 // There only is a text cursor by now if we are in insert mode. In any
682 // other case we have to create one at the start of the document.
683 // We also might change into the insert mode later, so we have to make
684 // sure to first set the insert mode and then create the text import
685 // helper. Otherwise it won't have the insert flag set!
686 OTextCursorHelper *pTxtCrsr = 0;
687 Reference < XTextCursor > xTextCursor;
688 if( HasTextImport() )
689 xTextCursor = GetTextImport()->GetCursor();
690 if( !xTextCursor.is() )
692 Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
693 Reference < XText > xText = xTextDoc->getText();
694 xTextCursor = xText->createTextCursor();
695 SwCrsrShell *pCrsrSh = 0;
696 SwDoc *pDoc = 0;
697 if( IMPORT_ALL == getImportFlags() )
699 pTxtCrsr = lcl_xml_GetSwXTextCursor( xTextCursor );
700 ASSERT( pTxtCrsr, "SwXTextCursor missing" );
701 if( !pTxtCrsr )
702 return;
704 pDoc = pTxtCrsr->GetDoc();
705 ASSERT( pDoc, "SwDoc missing" );
706 if( !pDoc )
707 return;
709 // Is there a edit shell. If yes, then we are currently inserting
710 // a document. We then have to insert at the current edit shell's
711 // cursor position. That not quite clean code, but there is no other
712 // way currently.
713 pCrsrSh = pDoc->GetEditShell();
715 if( pCrsrSh )
717 Reference<XTextRange> xInsertTextRange(
718 SwXTextRange::CreateTextRangeFromPosition(
719 pDoc, *pCrsrSh->GetCrsr()->GetPoint(), 0 ) );
720 setTextInsertMode( xInsertTextRange );
721 xTextCursor = GetTextImport()->GetCursor();
722 pTxtCrsr = 0;
724 else
725 GetTextImport()->SetCursor( xTextCursor );
728 if( (getImportFlags() & (IMPORT_CONTENT|IMPORT_MASTERSTYLES)) == 0 )
729 return;
731 if( !pTxtCrsr )
732 pTxtCrsr = lcl_xml_GetSwXTextCursor( xTextCursor );
733 ASSERT( pTxtCrsr, "SwXTextCursor missing" );
734 if( !pTxtCrsr )
735 return;
737 SwDoc *pDoc = pTxtCrsr->GetDoc();
738 ASSERT( pDoc, "SwDoc missing" );
739 if( !pDoc )
740 return;
742 if( (getImportFlags() & IMPORT_CONTENT) != 0 && !IsStylesOnlyMode() )
744 pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() );
745 if( IsInsertMode() )
747 SwPaM *pPaM = pTxtCrsr->GetPaM();
748 const SwPosition* pPos = pPaM->GetPoint();
750 // Split once and remember the node that has been splitted.
751 pDoc->SplitNode( *pPos, false );
752 *pSttNdIdx = pPos->nNode.GetIndex()-1;
754 // Split again.
755 pDoc->SplitNode( *pPos, false );
757 // Insert all content into the new node
758 pPaM->Move( fnMoveBackward );
759 pDoc->SetTxtFmtColl
760 ( *pPaM, pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false ) );
764 // We need a draw model to be able to set the z order
765 // --> OD 2005-08-08 #i52858# - method name changed
766 pDoc->GetOrCreateDrawModel();
767 // <--
769 // SJ: #i49801# locking the modell to disable repaints
770 SdrModel* pDrawModel = pDoc->GetDrawModel();
771 if ( pDrawModel )
772 pDrawModel->setLock( sal_True );
774 if( !GetGraphicResolver().is() )
776 pGraphicResolver = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_READ );
777 Reference< document::XGraphicObjectResolver > xGraphicResolver( pGraphicResolver );
778 SetGraphicResolver( xGraphicResolver );
781 if( !GetEmbeddedResolver().is() )
783 SfxObjectShell *pPersist = pDoc->GetPersist();
784 if( pPersist )
786 pEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
787 *pPersist,
788 EMBEDDEDOBJECTHELPER_MODE_READ );
789 Reference< document::XEmbeddedObjectResolver > xEmbeddedResolver( pEmbeddedResolver );
790 SetEmbeddedResolver( xEmbeddedResolver );
795 void SwXMLImport::endDocument( void )
796 throw( xml::sax::SAXException, uno::RuntimeException )
798 DBG_ASSERT( GetModel().is(), "model missing; maybe startDocument wasn't called?" );
799 if( !GetModel().is() )
800 return;
802 // this method will modify the document directly -> lock SolarMutex
803 vos::OGuard aGuard(Application::GetSolarMutex());
805 if( pGraphicResolver )
806 SvXMLGraphicHelper::Destroy( pGraphicResolver );
807 if( pEmbeddedResolver )
808 SvXMLEmbeddedObjectHelper::Destroy( pEmbeddedResolver );
809 // Clear the shape import to sort the shapes (and not in the
810 // destructor that might be called after the import has finished
811 // for Java filters.
812 if( HasShapeImport() )
813 ClearShapeImport();
816 SwDoc *pDoc = 0;
817 if( (getImportFlags() & IMPORT_CONTENT) != 0 && !IsStylesOnlyMode() )
819 Reference<XUnoTunnel> xCrsrTunnel( GetTextImport()->GetCursor(),
820 UNO_QUERY);
821 ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
822 OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper *>(
823 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
824 ASSERT( pTxtCrsr, "SwXTextCursor missing" );
825 SwPaM *pPaM = pTxtCrsr->GetPaM();
826 if( IsInsertMode() && pSttNdIdx->GetIndex() )
828 // If we are in insert mode, join the splitted node that is in front
829 // of the new content with the first new node. Or in other words:
830 // Revert the first split node.
831 SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode();
832 SwNodeIndex aNxtIdx( *pSttNdIdx );
833 if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx ) &&
834 pSttNdIdx->GetIndex() + 1 == aNxtIdx.GetIndex() )
836 // If the PaM points to the first new node, move the PaM to the
837 // end of the previous node.
838 if( pPaM && pPaM->GetPoint()->nNode == aNxtIdx )
840 pPaM->GetPoint()->nNode = *pSttNdIdx;
841 pPaM->GetPoint()->nContent.Assign( pTxtNode,
842 pTxtNode->GetTxt().Len() );
845 #ifndef PRODUCT
846 // !!! This should be impossible !!!!
847 ASSERT( pSttNdIdx->GetIndex()+1 !=
848 pPaM->GetBound( sal_True ).nNode.GetIndex(),
849 "PaM.Bound1 point to new node " );
850 ASSERT( pSttNdIdx->GetIndex()+1 !=
851 pPaM->GetBound( sal_False ).nNode.GetIndex(),
852 "PaM.Bound2 points to new node" );
854 if( pSttNdIdx->GetIndex()+1 ==
855 pPaM->GetBound( sal_True ).nNode.GetIndex() )
857 sal_uInt16 nCntPos =
858 pPaM->GetBound( sal_True ).nContent.GetIndex();
859 pPaM->GetBound( sal_True ).nContent.Assign( pTxtNode,
860 pTxtNode->GetTxt().Len() + nCntPos );
862 if( pSttNdIdx->GetIndex()+1 ==
863 pPaM->GetBound( sal_False ).nNode.GetIndex() )
865 sal_uInt16 nCntPos =
866 pPaM->GetBound( sal_False ).nContent.GetIndex();
867 pPaM->GetBound( sal_False ).nContent.Assign( pTxtNode,
868 pTxtNode->GetTxt().Len() + nCntPos );
870 #endif
871 // If the first new node isn't empty, convert the node's text
872 // attributes into hints. Otherwise, set the new node's
873 // paragraph style at the previous (empty) node.
874 SwTxtNode* pDelNd = aNxtIdx.GetNode().GetTxtNode();
875 if( pTxtNode->GetTxt().Len() )
876 pDelNd->FmtToTxtAttr( pTxtNode );
877 else
878 pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() );
879 pTxtNode->JoinNext();
883 SwPosition* pPos = pPaM->GetPoint();
884 DBG_ASSERT( !pPos->nContent.GetIndex(), "last paragraph isn't empty" );
885 if( !pPos->nContent.GetIndex() )
887 SwTxtNode* pCurrNd;
888 ULONG nNodeIdx = pPos->nNode.GetIndex();
889 pDoc = pPaM->GetDoc();
891 DBG_ASSERT( pPos->nNode.GetNode().IsCntntNode(),
892 "insert position is not a content node" );
893 if( !IsInsertMode() )
895 // If we're not in insert mode, the last node is deleted.
896 const SwNode *pPrev = pDoc->GetNodes()[nNodeIdx -1];
897 if( pPrev->IsCntntNode() ||
898 ( pPrev->IsEndNode() &&
899 pPrev->StartOfSectionNode()->IsSectionNode() ) )
901 SwCntntNode* pCNd = pPaM->GetCntntNode();
902 if( pCNd && pCNd->StartOfSectionIndex()+2 <
903 pCNd->EndOfSectionIndex() )
905 pPaM->GetBound(sal_True).nContent.Assign( 0, 0 );
906 pPaM->GetBound(sal_False).nContent.Assign( 0, 0 );
907 pDoc->GetNodes().Delete( pPaM->GetPoint()->nNode );
911 else if( 0 != (pCurrNd = pDoc->GetNodes()[nNodeIdx]->GetTxtNode()) )
913 // Id we're in insert mode, the empty node is joined with
914 // the next and the previous one.
915 if( pCurrNd->CanJoinNext( &pPos->nNode ))
917 SwTxtNode* pNextNd = pPos->nNode.GetNode().GetTxtNode();
918 pPos->nContent.Assign( pNextNd, 0 );
919 pPaM->SetMark(); pPaM->DeleteMark();
920 pNextNd->JoinPrev();
922 // Remove line break that has been inserted by the import,
923 // but only if one has been inserted!
924 if( pNextNd->CanJoinPrev(/* &pPos->nNode*/ ) &&
925 *pSttNdIdx != pPos->nNode )
927 // SwTxtNode* pPrevNd = pPos->nNode.GetNode().GetTxtNode();
928 // pPos->nContent.Assign( pPrevNd, 0 );
929 // pPaM->SetMark(); pPaM->DeleteMark();
930 // pPrevNd->JoinNext();
931 pNextNd->JoinPrev();
934 else if( !pCurrNd->GetTxt().Len() )
936 pPos->nContent.Assign( 0, 0 );
937 pPaM->SetMark(); pPaM->DeleteMark();
938 pDoc->GetNodes().Delete( pPos->nNode, 1 );
939 pPaM->Move( fnMoveBackward );
945 /* #108146# Was called too early. Moved from
946 SwXMLBodyContext_Impl::EndElement */
948 GetTextImport()->RedlineAdjustStartNodeCursor( sal_False );
950 if( (getImportFlags() & IMPORT_CONTENT) != 0 ||
951 ((getImportFlags() & IMPORT_MASTERSTYLES) != 0 && IsStylesOnlyMode()) )
953 // pDoc might be 0. In this case UpdateTxtCollCondition is looking
954 // for it itself.
955 UpdateTxtCollConditions( pDoc );
958 GetTextImport()->ResetCursor();
960 delete pSttNdIdx;
961 pSttNdIdx = 0;
963 if( (getImportFlags() == IMPORT_ALL ) )
965 // Notify math objects. If we are in the package filter this will
966 // be done by the filter object itself
967 if( IsInsertMode() )
968 pDoc->PrtOLENotify( FALSE );
969 else if ( pDoc->IsOLEPrtNotifyPending() )
970 pDoc->PrtOLENotify( TRUE );
973 // SJ: #i49801# -> now permitting repaints
974 if ( pDoc )
976 SdrModel* pDrawModel = pDoc->GetDrawModel();
977 if ( pDrawModel )
978 pDrawModel->setLock( sal_False );
981 // #i90243#
982 if ( bInititedXForms )
984 Reference< xforms::XFormsSupplier > xFormsSupp( GetModel(), UNO_QUERY );
985 Reference< XNameAccess > xXForms;
986 if ( xFormsSupp.is() )
987 xXForms = xFormsSupp->getXForms().get();
989 if ( xXForms.is() )
993 Sequence< beans::PropertyValue > aXFormsSettings;
995 ::rtl::OUString sXFormsSettingsName( GetXMLToken( XML_XFORM_MODEL_SETTINGS ) );
996 if ( xLateInitSettings.is() && xLateInitSettings->hasByName( sXFormsSettingsName ) )
998 OSL_VERIFY( xLateInitSettings->getByName( sXFormsSettingsName ) >>= aXFormsSettings );
999 applyXFormsSettings( xXForms, aXFormsSettings );
1002 catch( const Exception& )
1004 DBG_UNHANDLED_EXCEPTION();
1009 // delegate to parent: takes care of error handling
1010 SvXMLImport::endDocument();
1014 // Locally derive XMLTextShapeImportHelper, so we can take care of the
1015 // form import This is Writer, but not text specific, so it should go
1016 // here!
1017 class SvTextShapeImportHelper : public XMLTextShapeImportHelper
1019 // hold own reference form import helper, because the SvxImport
1020 // stored in the superclass, from whom we originally got the
1021 // reference, is already destroyed when we want to use it in the
1022 // destructor
1023 UniReference< ::xmloff::OFormLayerXMLImport > rFormImport;
1025 // hold reference to the one page (if it exists) for calling startPage()
1026 // and endPage. If !xPage.is(), then this document doesn't have a
1027 // XDrawPage.
1028 Reference<drawing::XDrawPage> xPage;
1030 public:
1032 SvTextShapeImportHelper(SvXMLImport& rImp);
1033 virtual ~SvTextShapeImportHelper();
1036 SvTextShapeImportHelper::SvTextShapeImportHelper(SvXMLImport& rImp) :
1037 XMLTextShapeImportHelper(rImp)
1039 Reference<drawing::XDrawPageSupplier> xSupplier(rImp.GetModel(),UNO_QUERY);
1040 if (xSupplier.is())
1042 if (rImp.GetFormImport().is())
1044 rImp.GetFormImport()->startPage(xSupplier->getDrawPage());
1045 rFormImport = rImp.GetFormImport();
1048 xPage = xSupplier->getDrawPage();
1049 Reference<XShapes> xShapes( xPage, UNO_QUERY );
1050 XMLShapeImportHelper::startPage( xShapes );
1054 SvTextShapeImportHelper::~SvTextShapeImportHelper()
1056 rFormImport->endPage();
1058 if (xPage.is())
1060 Reference<XShapes> xShapes( xPage, UNO_QUERY );
1061 XMLShapeImportHelper::endPage(xShapes);
1066 XMLShapeImportHelper* SwXMLImport::CreateShapeImport()
1068 return new SvTextShapeImportHelper( *this );
1071 SvXMLImportContext *SwXMLImport::CreateFontDeclsContext(
1072 const OUString& rLocalName,
1073 const Reference< xml::sax::XAttributeList > & xAttrList )
1075 XMLFontStylesContext *pFSContext =
1076 new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE,
1077 rLocalName, xAttrList,
1078 gsl_getSystemTextEncoding() );
1079 SetFontDecls( pFSContext );
1080 return pFSContext;
1082 void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps)
1084 if (IsInsertMode() || IsStylesOnlyMode() || IsBlockMode() || IsOrganizerMode() || !GetModel().is() )
1085 return;
1087 // this method will modify the document directly -> lock SolarMutex
1088 vos::OGuard aGuard(Application::GetSolarMutex());
1090 Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
1091 Reference < XText > xText = xTextDoc->getText();
1092 Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
1093 ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" );
1094 if( !xTextTunnel.is() )
1095 return;
1097 SwXText *pText = reinterpret_cast< SwXText *>(
1098 sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
1099 ASSERT( pText, "SwXText missing" );
1100 if( !pText )
1101 return;
1103 SwDoc *pDoc = pText->GetDoc();
1104 Rectangle aRect;
1105 if( pDoc->GetDocShell() )
1106 aRect = pDoc->GetDocShell()->GetVisArea( ASPECT_CONTENT );
1107 //TODO/LATER: why that cast?!
1108 //aRect = ((SfxInPlaceObject *)pDoc->GetDocShell())->GetVisArea();
1110 sal_Int32 nCount = aViewProps.getLength();
1111 const PropertyValue *pValue = aViewProps.getConstArray();
1113 sal_Int64 nTmp = 0;
1114 sal_Bool bShowRedlineChanges = sal_False, bBrowseMode = sal_False;
1115 sal_Bool bChangeShowRedline = sal_False, bChangeBrowseMode = sal_False;
1117 //TODO/LATER: why that cast?!
1118 sal_Bool bTwip = pDoc->GetDocShell()->GetMapUnit ( ) == MAP_TWIP;
1119 //sal_Bool bTwip = pDoc->GetDocShell()->SfxInPlaceObject::GetMapUnit ( ) == MAP_TWIP;
1121 for (sal_Int32 i = 0; i < nCount ; i++)
1123 if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaTop" ) ) )
1125 pValue->Value >>= nTmp;
1126 aRect.setY( static_cast< long >(bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp) );
1128 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaLeft" ) ) )
1130 pValue->Value >>= nTmp;
1131 aRect.setX( static_cast< long >(bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp) );
1133 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaWidth" ) ) )
1135 pValue->Value >>= nTmp;
1136 Size aSize( aRect.GetSize() );
1137 aSize.Width() = static_cast< long >(bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp);
1138 aRect.SetSize( aSize );
1140 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaHeight" ) ) )
1142 pValue->Value >>= nTmp;
1143 Size aSize( aRect.GetSize() );
1144 aSize.Height() = static_cast< long >(bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp);
1145 aRect.SetSize( aSize );
1147 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ShowRedlineChanges" ) ) )
1149 bShowRedlineChanges = *(sal_Bool *)(pValue->Value.getValue());
1150 bChangeShowRedline = sal_True;
1152 // #105372#: Headers and footers are not displayed in BrowseView anymore
1153 // else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ShowHeaderWhileBrowsing" ) ) )
1154 // else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ShowFooterWhileBrowsing" ) ) )
1155 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "InBrowseMode" ) ) )
1157 bBrowseMode = *(sal_Bool *)(pValue->Value.getValue());
1158 bChangeBrowseMode = sal_True;
1160 pValue++;
1162 if( pDoc->GetDocShell() )
1163 pDoc->GetDocShell()->SetVisArea ( aRect );
1165 if (bChangeBrowseMode)
1166 pDoc->set(IDocumentSettingAccess::BROWSE_MODE, bBrowseMode );
1168 if (bChangeShowRedline)
1169 GetTextImport()->SetShowChanges( bShowRedlineChanges );
1172 void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aConfigProps)
1174 // this method will modify the document directly -> lock SolarMutex
1175 vos::OGuard aGuard(Application::GetSolarMutex());
1177 Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
1178 if( !xFac.is() )
1179 return;
1181 Reference< XPropertySet > xProps( xFac->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY );
1182 if( !xProps.is() )
1183 return;
1185 Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
1186 if( !xInfo.is() )
1187 return;
1189 // #111955#
1190 hash_set< String, StringHashRef, StringEqRef > aSet;
1191 aSet.insert(String("ForbiddenCharacters", RTL_TEXTENCODING_ASCII_US));
1192 aSet.insert(String("IsKernAsianPunctuation", RTL_TEXTENCODING_ASCII_US));
1193 aSet.insert(String("CharacterCompressionType", RTL_TEXTENCODING_ASCII_US));
1194 aSet.insert(String("LinkUpdateMode", RTL_TEXTENCODING_ASCII_US));
1195 aSet.insert(String("FieldAutoUpdate", RTL_TEXTENCODING_ASCII_US));
1196 aSet.insert(String("ChartAutoUpdate", RTL_TEXTENCODING_ASCII_US));
1197 aSet.insert(String("AddParaTableSpacing", RTL_TEXTENCODING_ASCII_US));
1198 aSet.insert(String("AddParaTableSpacingAtStart", RTL_TEXTENCODING_ASCII_US));
1199 aSet.insert(String("PrintAnnotationMode", RTL_TEXTENCODING_ASCII_US));
1200 aSet.insert(String("PrintBlackFonts", RTL_TEXTENCODING_ASCII_US));
1201 aSet.insert(String("PrintControls", RTL_TEXTENCODING_ASCII_US));
1202 aSet.insert(String("PrintDrawings", RTL_TEXTENCODING_ASCII_US));
1203 aSet.insert(String("PrintGraphics", RTL_TEXTENCODING_ASCII_US));
1204 aSet.insert(String("PrintLeftPages", RTL_TEXTENCODING_ASCII_US));
1205 aSet.insert(String("PrintPageBackground", RTL_TEXTENCODING_ASCII_US));
1206 aSet.insert(String("PrintProspect", RTL_TEXTENCODING_ASCII_US));
1207 aSet.insert(String("PrintReversed", RTL_TEXTENCODING_ASCII_US));
1208 aSet.insert(String("PrintRightPages", RTL_TEXTENCODING_ASCII_US));
1209 aSet.insert(String("PrintFaxName", RTL_TEXTENCODING_ASCII_US));
1210 aSet.insert(String("PrintPaperFromSetup", RTL_TEXTENCODING_ASCII_US));
1211 aSet.insert(String("PrintTables", RTL_TEXTENCODING_ASCII_US));
1212 aSet.insert(String("PrintSingleJobs", RTL_TEXTENCODING_ASCII_US));
1213 aSet.insert(String("UpdateFromTemplate", RTL_TEXTENCODING_ASCII_US));
1214 aSet.insert(String("PrinterIndependentLayout", RTL_TEXTENCODING_ASCII_US));
1215 // --> FME 2005-12-13 #b6354161#
1216 aSet.insert(String("PrintEmptyPages", RTL_TEXTENCODING_ASCII_US));
1217 // <--
1219 sal_Int32 nCount = aConfigProps.getLength();
1220 const PropertyValue* pValues = aConfigProps.getConstArray();
1222 SvtSaveOptions aSaveOpt;
1223 BOOL bIsUserSetting = aSaveOpt.IsLoadUserSettings(),
1224 bSet = bIsUserSetting;
1226 // for some properties we don't want to use the application
1227 // default if they're missing. So we watch for them in the loop
1228 // below, and set them if not found
1229 bool bPrinterIndependentLayout = false;
1230 bool bUseOldNumbering = false; // #111955#
1231 bool bOutlineLevelYieldsOutlineRule = false;
1232 bool bAddExternalLeading = false;
1233 bool bAddParaSpacingToTableCells = false;
1234 bool bUseFormerLineSpacing = false;
1235 bool bUseFormerObjectPositioning = false;
1236 bool bUseFormerTextWrapping = false;
1237 bool bConsiderWrapOnObjPos = false;
1238 bool bIgnoreFirstLineIndentInNumbering = false;
1239 bool bDoNotJustifyLinesWithManualBreak = false;
1240 bool bDoNotResetParaAttrsForNumFont = false;
1241 bool bLoadReadonly = false;
1242 bool bDoNotCaptureDrawObjsOnPage( false );
1243 bool bClipAsCharacterAnchoredWriterFlyFrames( false );
1244 bool bUnixForceZeroExtLeading = false;
1245 bool bUseOldPrinterMetrics = false;
1247 OUString sRedlineProtectionKey( RTL_CONSTASCII_USTRINGPARAM( "RedlineProtectionKey" ) );
1249 while( nCount-- )
1251 if( !bIsUserSetting )
1253 // test over the hash value if the entry is in the table.
1254 String aStr(pValues->Name);
1256 bSet = aSet.find(aStr) == aSet.end();
1259 if( bSet )
1263 if( xInfo->hasPropertyByName( pValues->Name ) )
1265 if( pValues->Name.equals( sRedlineProtectionKey ) )
1267 Sequence<sal_Int8> aKey;
1268 pValues->Value >>= aKey;
1269 GetTextImport()->SetChangesProtectionKey( aKey );
1271 else
1273 xProps->setPropertyValue( pValues->Name,
1274 pValues->Value );
1278 // did we find any of the non-default cases?
1279 if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("PrinterIndependentLayout")) )
1280 bPrinterIndependentLayout = true;
1281 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("AddExternalLeading")) )
1282 bAddExternalLeading = true;
1283 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("AddParaSpacingToTableCells")) )
1284 bAddParaSpacingToTableCells = true;
1285 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UseFormerLineSpacing")) )
1286 bUseFormerLineSpacing = true;
1287 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UseFormerObjectPositioning")) )
1288 bUseFormerObjectPositioning = true;
1289 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UseFormerTextWrapping")) )
1290 bUseFormerTextWrapping = true;
1291 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UseOldNumbering")) )
1292 bUseOldNumbering = true;
1293 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("OutlineLevelYieldsNumbering")) )
1294 bOutlineLevelYieldsOutlineRule = true;
1295 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ConsiderTextWrapOnObjPos")) )
1296 bConsiderWrapOnObjPos = true;
1297 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("IgnoreFirstLineIndentInNumbering")) )
1298 bIgnoreFirstLineIndentInNumbering = true;
1299 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("DoNotJustifyLinesWithManualBreak")) )
1300 bDoNotJustifyLinesWithManualBreak = true;
1301 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("DoNotResetParaAttrsForNumFont")) )
1302 bDoNotResetParaAttrsForNumFont = true;
1303 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("LoadReadonly")) )
1304 bLoadReadonly = true;
1305 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("DoNotCaptureDrawObjsOnPage")) )
1306 bDoNotCaptureDrawObjsOnPage = true;
1307 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ClipAsCharacterAnchoredWriterFlyFrames")) )
1308 bClipAsCharacterAnchoredWriterFlyFrames = true;
1309 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UnxForceZeroExtLeading")) )
1310 bUnixForceZeroExtLeading = true;
1311 else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UseOldPrinterMetrics")) )
1312 bUseOldPrinterMetrics = true;
1314 catch( Exception& )
1316 DBG_ERROR( "SwXMLImport::SetConfigurationSettings: Exception!" );
1319 pValues++;
1322 // finally, treat the non-default cases
1323 // --> OD 2006-04-18 #b6402800#
1324 // introduce boolean, that indicates a document, written by version prior SO8.
1325 const bool bDocumentPriorSO8 = !bConsiderWrapOnObjPos;
1326 // <--
1328 if( ! bPrinterIndependentLayout )
1330 Any aAny;
1331 sal_Int16 nTmp = document::PrinterIndependentLayout::DISABLED;
1332 aAny <<= nTmp;
1333 xProps->setPropertyValue(
1334 OUString( RTL_CONSTASCII_USTRINGPARAM("PrinterIndependentLayout") ),
1335 aAny );
1338 if( ! bAddExternalLeading )
1340 xProps->setPropertyValue(
1341 OUString( RTL_CONSTASCII_USTRINGPARAM("AddExternalLeading")), makeAny( false ) );
1344 if( ! bUseFormerLineSpacing )
1346 xProps->setPropertyValue(
1347 OUString( RTL_CONSTASCII_USTRINGPARAM("UseFormerLineSpacing")), makeAny( true ) );
1350 if( !bUseFormerObjectPositioning )
1352 xProps->setPropertyValue(
1353 OUString( RTL_CONSTASCII_USTRINGPARAM("UseFormerObjectPositioning")), makeAny( true ) );
1356 if( !bUseOldNumbering ) // #111955#
1358 Any aAny;
1359 sal_Bool bOldNum = true;
1360 aAny.setValue(&bOldNum, ::getBooleanCppuType());
1361 xProps->setPropertyValue
1362 (OUString( RTL_CONSTASCII_USTRINGPARAM("UseOldNumbering")),
1363 aAny );
1366 if( !bOutlineLevelYieldsOutlineRule )
1368 Any aAny;
1369 sal_Bool bTmp = true;
1370 aAny.setValue(&bTmp, ::getBooleanCppuType());
1371 xProps->setPropertyValue
1372 (OUString( RTL_CONSTASCII_USTRINGPARAM
1373 ("OutlineLevelYieldsNumbering")),
1374 aAny );
1377 if( !bAddParaSpacingToTableCells )
1379 xProps->setPropertyValue(
1380 OUString( RTL_CONSTASCII_USTRINGPARAM("AddParaSpacingToTableCells")), makeAny( false ) );
1383 if( !bUseFormerTextWrapping )
1385 xProps->setPropertyValue(
1386 OUString( RTL_CONSTASCII_USTRINGPARAM("UseFormerTextWrapping")), makeAny( true ) );
1389 if( !bConsiderWrapOnObjPos )
1391 xProps->setPropertyValue(
1392 OUString( RTL_CONSTASCII_USTRINGPARAM("ConsiderTextWrapOnObjPos")), makeAny( false ) );
1395 // FME 2005-05-27 #i47448#
1396 // For SO7pp4, part of the 'new numbering' stuff has been backported from
1397 // SO8. Unfortunately, only part of it and by using the same compatibility option
1398 // like in SO8. Therefore documents generated with SO7pp4, containing
1399 // numbered paragraphs with first line indent differ between SO7pp4 and
1400 // SO8. In order to fix this for SO8pp1, I introduce a new compatiblity
1401 // flag 'bIgnoreFirstLineIndentInNumbering'. This flag has to be set for all
1402 // documents < SO8, but not for SO8. So if the property is not present, the
1403 // flag will be set to 'true'. SO8 documents surely have the
1404 // 'ConsiderWrapOnObjPos' property set (no matter if 'true' or 'false'),
1405 // therefore the correct condition to set this flag is this:
1406 if( !bIgnoreFirstLineIndentInNumbering && bDocumentPriorSO8 )
1408 xProps->setPropertyValue(
1409 OUString( RTL_CONSTASCII_USTRINGPARAM("IgnoreFirstLineIndentInNumbering")), makeAny( true ) );
1412 // This flag has to be set for all documents < SO8
1413 if ( !bDoNotJustifyLinesWithManualBreak && bDocumentPriorSO8 )
1415 xProps->setPropertyValue(
1416 OUString( RTL_CONSTASCII_USTRINGPARAM("DoNotJustifyLinesWithManualBreak")), makeAny( true ) );
1418 // <--
1420 // This flag has to be set for all documents < SO8
1421 if ( !bDoNotResetParaAttrsForNumFont && bDocumentPriorSO8 )
1423 xProps->setPropertyValue(
1424 OUString( RTL_CONSTASCII_USTRINGPARAM("DoNotResetParaAttrsForNumFont")), makeAny( true ) );
1427 if ( !bLoadReadonly )
1429 xProps->setPropertyValue(
1430 OUString( RTL_CONSTASCII_USTRINGPARAM("LoadReadonly") ), makeAny( false ) );
1433 // This flag has to be set for all documents < SO8
1434 if ( !bDoNotCaptureDrawObjsOnPage && bDocumentPriorSO8 )
1436 xProps->setPropertyValue(
1437 OUString( RTL_CONSTASCII_USTRINGPARAM("DoNotCaptureDrawObjsOnPage") ), makeAny( true ) );
1440 // This flag has to be set for all documents < SO8
1441 if ( !bClipAsCharacterAnchoredWriterFlyFrames && bDocumentPriorSO8 )
1443 xProps->setPropertyValue(
1444 OUString( RTL_CONSTASCII_USTRINGPARAM("ClipAsCharacterAnchoredWriterFlyFrames") ), makeAny( true ) );
1447 if ( !bUnixForceZeroExtLeading )
1449 xProps->setPropertyValue(
1450 OUString( RTL_CONSTASCII_USTRINGPARAM("UnxForceZeroExtLeading") ), makeAny( true ) );
1453 if ( !bUseOldPrinterMetrics )
1455 xProps->setPropertyValue(
1456 OUString( RTL_CONSTASCII_USTRINGPARAM("UseOldPrinterMetrics") ), makeAny( true ) );
1458 // <--
1460 Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
1461 Reference < XText > xText = xTextDoc->getText();
1462 Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
1463 ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" );
1464 if( xTextTunnel.is() )
1466 SwXText *pText = reinterpret_cast< SwXText *>(
1467 sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
1468 ASSERT( pText, "SwXText missing" );
1469 if( pText )
1471 SwDoc *pDoc = pText->GetDoc();
1472 if( pDoc )
1474 SfxPrinter *pPrinter = pDoc->getPrinter( false );
1475 if( pPrinter )
1477 // If the printer is known, then the OLE objects will
1478 // already have correct sizes, and we don't have to call
1479 // PrtOLENotify again. Otherwise we have to call it.
1480 // The flag might be set from setting the printer, so it
1481 // it is required to clear it.
1482 pDoc->SetOLEPrtNotifyPending( !pPrinter->IsKnown() );
1484 // FME 2007-05-14 #147385# old printer metrics compatibility
1485 if ( pDoc->get(IDocumentSettingAccess::USE_OLD_PRINTER_METRICS ) &&
1486 !pDoc->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
1488 pPrinter->Compat_OldPrinterMetrics( true );
1489 pDoc->GetDocShell()->UpdateFontList();
1498 void SwXMLImport::SetDocumentSpecificSettings(
1499 const ::rtl::OUString& _rSettingsGroupName,
1500 const Sequence< PropertyValue>& _rSettings )
1502 // the only doc-specific settings group we know so far are the XForms settings
1503 if ( !IsXMLToken( _rSettingsGroupName, XML_XFORM_MODEL_SETTINGS ) )
1504 return;
1506 // preserve the settings for a later iteration - we are currently reading the settings.xml,
1507 // the content.xml will be read later, by another instance of SwXMLImport
1508 OSL_ENSURE( xLateInitSettings.is(), "SwXMLImport::SetDocumentSpecificSettings: no storage for those settings!" );
1509 if ( !xLateInitSettings.is() )
1510 return;
1514 if ( xLateInitSettings->hasByName( _rSettingsGroupName ) )
1516 xLateInitSettings->replaceByName( _rSettingsGroupName, makeAny( _rSettings ) );
1517 OSL_ENSURE( false, "SwXMLImport::SetDocumentSpecificSettings: already have settings for this model!" );
1519 else
1520 xLateInitSettings->insertByName( _rSettingsGroupName, makeAny( _rSettings ) );
1522 catch( const Exception& )
1524 DBG_UNHANDLED_EXCEPTION();
1528 void SwXMLImport::initialize(
1529 const Sequence<Any>& aArguments )
1530 throw( uno::Exception, uno::RuntimeException)
1532 // delegate to super class
1533 SvXMLImport::initialize(aArguments);
1535 // we are only looking for a PropertyValue "PreserveRedlineMode"
1536 sal_Int32 nLength = aArguments.getLength();
1537 for(sal_Int32 i = 0; i < nLength; i++)
1539 beans::PropertyValue aValue;
1540 if ( aArguments[i] >>= aValue )
1542 if (aValue.Name.equalsAsciiL(
1543 RTL_CONSTASCII_STRINGPARAM("PreserveRedlineMode")))
1545 OSL_VERIFY( aValue.Value >>= bPreserveRedlineMode );
1547 continue;
1550 beans::NamedValue aNamedValue;
1551 if ( aArguments[i] >>= aNamedValue )
1553 if (aNamedValue.Name.equalsAsciiL(
1554 RTL_CONSTASCII_STRINGPARAM("LateInitSettings")))
1556 OSL_VERIFY( aNamedValue.Value >>= xLateInitSettings );
1564 // UNO component registration helper functions
1567 OUString SAL_CALL SwXMLImport_getImplementationName() throw()
1569 return OUString( RTL_CONSTASCII_USTRINGPARAM(
1570 "com.sun.star.comp.Writer.XMLOasisImporter" ) );
1573 uno::Sequence< OUString > SAL_CALL SwXMLImport_getSupportedServiceNames()
1574 throw()
1576 const OUString aServiceName( SwXMLImport_getImplementationName() );
1577 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1578 return aSeq;
1581 uno::Reference< uno::XInterface > SAL_CALL SwXMLImport_createInstance(
1582 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1583 throw( uno::Exception )
1585 // #110680#
1586 // return (cppu::OWeakObject*)new SwXMLImport(IMPORT_ALL);
1587 return (cppu::OWeakObject*)new SwXMLImport( rSMgr, IMPORT_ALL );
1590 OUString SAL_CALL SwXMLImportStyles_getImplementationName() throw()
1592 return OUString( RTL_CONSTASCII_USTRINGPARAM(
1593 "com.sun.star.comp.Writer.XMLOasisStylesImporter" ) );
1596 uno::Sequence< OUString > SAL_CALL SwXMLImportStyles_getSupportedServiceNames()
1597 throw()
1599 const OUString aServiceName( SwXMLImportStyles_getImplementationName() );
1600 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1601 return aSeq;
1604 uno::Reference< uno::XInterface > SAL_CALL SwXMLImportStyles_createInstance(
1605 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1606 throw( uno::Exception )
1608 // #110680#
1609 //return (cppu::OWeakObject*)new SwXMLImport(
1610 // IMPORT_STYLES | IMPORT_MASTERSTYLES | IMPORT_AUTOSTYLES |
1611 // IMPORT_FONTDECLS );
1612 return (cppu::OWeakObject*)new SwXMLImport(
1613 rSMgr,
1614 IMPORT_STYLES | IMPORT_MASTERSTYLES | IMPORT_AUTOSTYLES |
1615 IMPORT_FONTDECLS );
1618 OUString SAL_CALL SwXMLImportContent_getImplementationName() throw()
1620 return OUString( RTL_CONSTASCII_USTRINGPARAM(
1621 "com.sun.star.comp.Writer.XMLOasisContentImporter" ) );
1624 uno::Sequence< OUString > SAL_CALL SwXMLImportContent_getSupportedServiceNames()
1625 throw()
1627 const OUString aServiceName( SwXMLImportContent_getImplementationName() );
1628 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1629 return aSeq;
1632 uno::Reference< uno::XInterface > SAL_CALL SwXMLImportContent_createInstance(
1633 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1634 throw( uno::Exception )
1636 // #110680#
1637 //return (cppu::OWeakObject*)new SwXMLImport(
1638 // IMPORT_AUTOSTYLES | IMPORT_CONTENT | IMPORT_SCRIPTS |
1639 // IMPORT_FONTDECLS );
1640 return (cppu::OWeakObject*)new SwXMLImport(
1641 rSMgr,
1642 IMPORT_AUTOSTYLES | IMPORT_CONTENT | IMPORT_SCRIPTS |
1643 IMPORT_FONTDECLS );
1646 OUString SAL_CALL SwXMLImportMeta_getImplementationName() throw()
1648 return OUString( RTL_CONSTASCII_USTRINGPARAM(
1649 "com.sun.star.comp.Writer.XMLOasisMetaImporter" ) );
1652 uno::Sequence< OUString > SAL_CALL SwXMLImportMeta_getSupportedServiceNames()
1653 throw()
1655 const OUString aServiceName( SwXMLImportMeta_getImplementationName() );
1656 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1657 return aSeq;
1660 uno::Reference< uno::XInterface > SAL_CALL SwXMLImportMeta_createInstance(
1661 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1662 throw( uno::Exception )
1664 // #110680#
1665 // return (cppu::OWeakObject*)new SwXMLImport( IMPORT_META );
1666 return (cppu::OWeakObject*)new SwXMLImport( rSMgr, IMPORT_META );
1669 OUString SAL_CALL SwXMLImportSettings_getImplementationName() throw()
1671 return OUString( RTL_CONSTASCII_USTRINGPARAM(
1672 "com.sun.star.comp.Writer.XMLOasisSettingsImporter" ) );
1675 uno::Sequence< OUString > SAL_CALL SwXMLImportSettings_getSupportedServiceNames()
1676 throw()
1678 const OUString aServiceName( SwXMLImportSettings_getImplementationName() );
1679 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1680 return aSeq;
1683 uno::Reference< uno::XInterface > SAL_CALL SwXMLImportSettings_createInstance(
1684 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1685 throw( uno::Exception )
1687 // #110680#
1688 // return (cppu::OWeakObject*)new SwXMLImport( IMPORT_SETTINGS );
1689 return (cppu::OWeakObject*)new SwXMLImport( rSMgr, IMPORT_SETTINGS );
1693 // XServiceInfo
1694 // override empty method from parent class
1695 OUString SAL_CALL SwXMLImport::getImplementationName()
1696 throw(RuntimeException)
1698 switch( getImportFlags() )
1700 case IMPORT_ALL:
1701 return SwXMLImport_getImplementationName();
1702 case (IMPORT_STYLES|IMPORT_MASTERSTYLES|IMPORT_AUTOSTYLES|IMPORT_FONTDECLS):
1703 return SwXMLImportStyles_getImplementationName();
1704 case (IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS):
1705 return SwXMLImportContent_getImplementationName();
1706 case IMPORT_META:
1707 return SwXMLImportMeta_getImplementationName();
1708 case IMPORT_SETTINGS:
1709 return SwXMLImportSettings_getImplementationName();
1710 default:
1711 // generic name for 'unknown' cases
1712 return OUString( RTL_CONSTASCII_USTRINGPARAM(
1713 "com.sun.star.comp.Writer.SwXMLImport" ) );
1717 SwDoc* SwImport::GetDocFromXMLImport( SvXMLImport& rImport )
1719 uno::Reference<lang::XUnoTunnel> xModelTunnel( rImport.GetModel(), uno::UNO_QUERY );
1720 SwXTextDocument *pTxtDoc = reinterpret_cast< SwXTextDocument *>(
1721 sal::static_int_cast< sal_IntPtr >( xModelTunnel->getSomething(SwXTextDocument::getUnoTunnelId() )));
1722 ASSERT( pTxtDoc, "Where is my model?" )
1723 ASSERT( pTxtDoc->GetDocShell(), "Where is my shell?" )
1724 SwDoc* pDoc = pTxtDoc->GetDocShell()->GetDoc();
1725 ASSERT( pDoc, "Where is my document?" )
1726 return pDoc;
1730 void SwXMLImport::initXForms()
1732 // obtain SwDoc
1733 Reference<XUnoTunnel> xDocTunnel( GetModel(), UNO_QUERY );
1734 if( ! xDocTunnel.is() )
1735 return;
1736 SwXTextDocument* pXTextDocument = reinterpret_cast<SwXTextDocument*>(
1737 xDocTunnel->getSomething( SwXTextDocument::getUnoTunnelId() ) );
1738 if( pXTextDocument == NULL )
1739 return;
1741 SwDoc *pDoc = pXTextDocument->GetDocShell()->GetDoc();
1743 // init XForms (if not already done)
1744 // (no default model, since we'll load the models)
1745 if( ! pDoc->isXForms() )
1746 pDoc->initXForms( false );
1748 bInititedXForms = sal_True;