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 :
21 : #include <com/sun/star/container/XIndexAccess.hpp>
22 : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
23 : #include <com/sun/star/drawing/XDrawPage.hpp>
24 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
25 : #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
26 : #include <com/sun/star/text/XTextDocument.hpp>
27 : #include <com/sun/star/text/XTextRange.hpp>
28 :
29 : #include <xmloff/xmlnmspe.hxx>
30 : #include <xmloff/xmltkmap.hxx>
31 : #include <xmloff/xmlictxt.hxx>
32 : #include <xmloff/txtimp.hxx>
33 : #include <xmloff/nmspmap.hxx>
34 : #include <xmloff/XMLTextShapeImportHelper.hxx>
35 : #include <xmloff/XMLFontStylesContext.hxx>
36 : #include <xmloff/ProgressBarHelper.hxx>
37 : #include <doc.hxx>
38 : #include <TextCursorHelper.hxx>
39 : #include <unotext.hxx>
40 : #include <unotextrange.hxx>
41 : #include "unocrsr.hxx"
42 : #include <poolfmt.hxx>
43 : #include <ndtxt.hxx>
44 : #include <editsh.hxx>
45 : #include "xmlimp.hxx"
46 : #include "xmltexti.hxx"
47 : #include <xmloff/DocumentSettingsContext.hxx>
48 : #include <docsh.hxx>
49 : #include <editeng/unolingu.hxx>
50 : #include <svx/svdmodel.hxx>
51 : #include <svx/xmlgrhlp.hxx>
52 : #include <svx/xmleohlp.hxx>
53 : #include <sfx2/printer.hxx>
54 : #include <xmloff/xmluconv.hxx>
55 : #include <unotools/saveopt.hxx>
56 : #include <tools/diagnose_ex.h>
57 : #include <boost/unordered_set.hpp>
58 : #include <stringhash.hxx>
59 :
60 : // for locking SolarMutex: svapp + mutex
61 : #include <vcl/svapp.hxx>
62 : #include <osl/mutex.hxx>
63 : #include <unotxdoc.hxx> // for initXForms()
64 :
65 : #include <xmloff/xmlmetai.hxx>
66 : #include <xmloff/xformsimport.hxx>
67 : #include <comphelper/servicehelper.hxx>
68 : #include <comphelper/processfactory.hxx>
69 :
70 :
71 : using namespace ::com::sun::star;
72 : using namespace ::com::sun::star::uno;
73 : using namespace ::com::sun::star::text;
74 : using namespace ::com::sun::star::lang;
75 : using namespace ::com::sun::star::beans;
76 : using namespace ::com::sun::star::container;
77 : using namespace ::com::sun::star::i18n;
78 : using namespace ::com::sun::star::drawing;
79 : using namespace ::com::sun::star::xforms;
80 : using namespace ::xmloff::token;
81 : using namespace ::std;
82 :
83 : //----------------------------------------------------------------------------
84 :
85 : enum SwXMLDocTokens
86 : {
87 : XML_TOK_DOC_FONTDECLS,
88 : XML_TOK_DOC_STYLES,
89 : XML_TOK_DOC_AUTOSTYLES,
90 : XML_TOK_DOC_MASTERSTYLES,
91 : XML_TOK_DOC_META,
92 : XML_TOK_DOC_BODY,
93 : XML_TOK_DOC_SCRIPT,
94 : XML_TOK_DOC_SETTINGS,
95 : XML_TOK_DOC_XFORMS,
96 : XML_TOK_OFFICE_END=XML_TOK_UNKNOWN
97 : };
98 :
99 : static SvXMLTokenMapEntry aDocTokenMap[] =
100 : {
101 : { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS, XML_TOK_DOC_FONTDECLS },
102 : { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES },
103 : { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES },
104 : { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, XML_TOK_DOC_MASTERSTYLES },
105 : { XML_NAMESPACE_OFFICE, XML_META, XML_TOK_DOC_META },
106 : { XML_NAMESPACE_OFFICE, XML_BODY, XML_TOK_DOC_BODY },
107 : { XML_NAMESPACE_OFFICE, XML_SCRIPTS, XML_TOK_DOC_SCRIPT },
108 : { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS },
109 : { XML_NAMESPACE_XFORMS, XML_MODEL, XML_TOK_DOC_XFORMS },
110 : XML_TOKEN_MAP_END
111 : };
112 :
113 : // ----------------------------------------------------------------------------
114 :
115 : class SwXMLBodyContext_Impl : public SvXMLImportContext
116 : {
117 : const SwXMLImport& GetSwImport() const
118 : { return (const SwXMLImport&)GetImport(); }
119 52 : SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
120 :
121 : public:
122 :
123 : SwXMLBodyContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
124 : const OUString& rLName,
125 : const Reference< xml::sax::XAttributeList > & xAttrList );
126 : virtual ~SwXMLBodyContext_Impl();
127 :
128 : TYPEINFO();
129 :
130 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
131 : const OUString& rLocalName,
132 : const Reference< xml::sax::XAttributeList > & xAttrList );
133 : };
134 :
135 52 : SwXMLBodyContext_Impl::SwXMLBodyContext_Impl( SwXMLImport& rImport,
136 : sal_uInt16 nPrfx, const OUString& rLName,
137 : const Reference< xml::sax::XAttributeList > & /*xAttrList*/ ) :
138 52 : SvXMLImportContext( rImport, nPrfx, rLName )
139 : {
140 52 : }
141 :
142 104 : SwXMLBodyContext_Impl::~SwXMLBodyContext_Impl()
143 : {
144 104 : }
145 :
146 0 : TYPEINIT1( SwXMLBodyContext_Impl, SvXMLImportContext );
147 :
148 52 : SvXMLImportContext *SwXMLBodyContext_Impl::CreateChildContext(
149 : sal_uInt16 /*nPrefix*/,
150 : const OUString& rLocalName,
151 : const Reference< xml::sax::XAttributeList > & /*xAttrList*/ )
152 : {
153 52 : return GetSwImport().CreateBodyContentContext( rLocalName );
154 : }
155 :
156 : // ----------------------------------------------------------------------------
157 :
158 : // #i69629#
159 : // enhance class <SwXMLDocContext_Impl> in order to be able to create subclasses
160 : // NB: virtually inherit so we can multiply inherit properly
161 : // in SwXMLOfficeDocContext_Impl
162 : class SwXMLDocContext_Impl : public virtual SvXMLImportContext
163 : {
164 :
165 : protected: // #i69629#
166 : const SwXMLImport& GetSwImport() const
167 : { return (const SwXMLImport&)GetImport(); }
168 1031 : SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
169 :
170 : public:
171 :
172 : SwXMLDocContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
173 : const OUString& rLName,
174 : const Reference< xml::sax::XAttributeList > & xAttrList );
175 : virtual ~SwXMLDocContext_Impl();
176 :
177 : TYPEINFO();
178 :
179 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
180 : const OUString& rLocalName,
181 : const Reference< xml::sax::XAttributeList > & xAttrList );
182 : };
183 :
184 155 : SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport,
185 : sal_uInt16 nPrfx, const OUString& rLName,
186 : const Reference< xml::sax::XAttributeList > & /*xAttrList*/ ) :
187 155 : SvXMLImportContext( rImport, nPrfx, rLName )
188 : {
189 155 : }
190 :
191 359 : SwXMLDocContext_Impl::~SwXMLDocContext_Impl()
192 : {
193 359 : }
194 :
195 0 : TYPEINIT1( SwXMLDocContext_Impl, SvXMLImportContext );
196 :
197 463 : SvXMLImportContext *SwXMLDocContext_Impl::CreateChildContext(
198 : sal_uInt16 nPrefix,
199 : const OUString& rLocalName,
200 : const Reference< xml::sax::XAttributeList > & xAttrList )
201 : {
202 463 : SvXMLImportContext *pContext = 0;
203 :
204 463 : const SvXMLTokenMap& rTokenMap = GetSwImport().GetDocElemTokenMap();
205 463 : switch( rTokenMap.Get( nPrefix, rLocalName ) )
206 : {
207 : case XML_TOK_DOC_FONTDECLS:
208 103 : pContext = GetSwImport().CreateFontDeclsContext( rLocalName,
209 103 : xAttrList );
210 103 : break;
211 : case XML_TOK_DOC_STYLES:
212 52 : GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
213 52 : pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList,
214 52 : sal_False );
215 52 : break;
216 : case XML_TOK_DOC_AUTOSTYLES:
217 : // don't use the autostyles from the styles-document for the progress
218 103 : if ( ! IsXMLToken( GetLocalName(), XML_DOCUMENT_STYLES ) )
219 51 : GetSwImport().GetProgressBarHelper()->Increment
220 51 : ( PROGRESS_BAR_STEP );
221 103 : pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList,
222 103 : sal_True );
223 103 : break;
224 :
225 : case XML_TOK_DOC_MASTERSTYLES:
226 52 : pContext = GetSwImport().CreateMasterStylesContext( rLocalName,
227 52 : xAttrList );
228 52 : break;
229 : case XML_TOK_DOC_META:
230 : OSL_FAIL("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
231 0 : break;
232 : case XML_TOK_DOC_SCRIPT:
233 50 : pContext = GetSwImport().CreateScriptContext( rLocalName );
234 50 : break;
235 : case XML_TOK_DOC_BODY:
236 52 : GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
237 : pContext = new SwXMLBodyContext_Impl( GetSwImport(), nPrefix,
238 52 : rLocalName, xAttrList );
239 52 : break;
240 : case XML_TOK_DOC_SETTINGS:
241 51 : pContext = new XMLDocumentSettingsContext( GetImport(), nPrefix, rLocalName, xAttrList );
242 51 : break;
243 : case XML_TOK_DOC_XFORMS:
244 0 : pContext = createXFormsModelContext(GetImport(), nPrefix, rLocalName);
245 0 : break;
246 : }
247 :
248 463 : if( !pContext )
249 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
250 :
251 :
252 463 : return pContext;
253 : }
254 :
255 : // #i69629# - new subclass <SwXMLOfficeDocContext_Impl> of class <SwXMLDocContext_Impl>
256 : class SwXMLOfficeDocContext_Impl :
257 : public SwXMLDocContext_Impl, public SvXMLMetaDocumentContext
258 : {
259 : public:
260 :
261 : SwXMLOfficeDocContext_Impl( SwXMLImport& rImport,
262 : sal_uInt16 nPrfx,
263 : const OUString& rLName,
264 : const Reference< xml::sax::XAttributeList > & xAttrList,
265 : const Reference< document::XDocumentProperties >& xDocProps);
266 : virtual ~SwXMLOfficeDocContext_Impl();
267 :
268 : TYPEINFO();
269 :
270 : virtual SvXMLImportContext *CreateChildContext(
271 : sal_uInt16 nPrefix,
272 : const OUString& rLocalName,
273 : const Reference< xml::sax::XAttributeList > & xAttrList );
274 : };
275 :
276 1 : SwXMLOfficeDocContext_Impl::SwXMLOfficeDocContext_Impl(
277 : SwXMLImport& rImport,
278 : sal_uInt16 nPrfx,
279 : const OUString& rLName,
280 : const Reference< xml::sax::XAttributeList > & xAttrList,
281 : const Reference< document::XDocumentProperties >& xDocProps) :
282 : SvXMLImportContext( rImport, nPrfx, rLName ),
283 : SwXMLDocContext_Impl( rImport, nPrfx, rLName, xAttrList ),
284 1 : SvXMLMetaDocumentContext( rImport, nPrfx, rLName, xDocProps)
285 : {
286 1 : }
287 :
288 3 : SwXMLOfficeDocContext_Impl::~SwXMLOfficeDocContext_Impl()
289 : {
290 3 : }
291 :
292 0 : TYPEINIT1( SwXMLOfficeDocContext_Impl, SwXMLDocContext_Impl );
293 :
294 1 : SvXMLImportContext* SwXMLOfficeDocContext_Impl::CreateChildContext(
295 : sal_uInt16 nPrefix,
296 : const OUString& rLocalName,
297 : const Reference< xml::sax::XAttributeList > & xAttrList )
298 : {
299 1 : const SvXMLTokenMap& rTokenMap = GetSwImport().GetDocElemTokenMap();
300 :
301 : // assign paragraph styles to list levels of outline style after all styles
302 : // are imported and finished. This is the case, when <office:body> starts
303 : // in flat OpenDocument file format.
304 : {
305 1 : if ( rTokenMap.Get( nPrefix, rLocalName ) == XML_TOK_DOC_BODY )
306 : {
307 1 : GetImport().GetTextImport()->SetOutlineStyles( sal_True );
308 : }
309 : }
310 :
311 : // behave like meta base class iff we encounter office:meta
312 1 : if ( XML_TOK_DOC_META == rTokenMap.Get( nPrefix, rLocalName ) ) {
313 : return SvXMLMetaDocumentContext::CreateChildContext(
314 0 : nPrefix, rLocalName, xAttrList );
315 : } else {
316 : return SwXMLDocContext_Impl::CreateChildContext(
317 1 : nPrefix, rLocalName, xAttrList );
318 : }
319 : }
320 :
321 : // #i69629# - new subclass <SwXMLDocStylesContext_Impl> of class <SwXMLDocContext_Impl>
322 : class SwXMLDocStylesContext_Impl : public SwXMLDocContext_Impl
323 : {
324 : public:
325 :
326 : SwXMLDocStylesContext_Impl( SwXMLImport& rImport,
327 : sal_uInt16 nPrfx,
328 : const OUString& rLName,
329 : const Reference< xml::sax::XAttributeList > & xAttrList );
330 : virtual ~SwXMLDocStylesContext_Impl();
331 :
332 : TYPEINFO();
333 :
334 : virtual void EndElement();
335 : };
336 :
337 52 : SwXMLDocStylesContext_Impl::SwXMLDocStylesContext_Impl(
338 : SwXMLImport& rImport,
339 : sal_uInt16 nPrfx,
340 : const OUString& rLName,
341 : const Reference< xml::sax::XAttributeList > & xAttrList ) :
342 : SvXMLImportContext( rImport, nPrfx, rLName ),
343 52 : SwXMLDocContext_Impl( rImport, nPrfx, rLName, xAttrList )
344 : {
345 52 : }
346 :
347 156 : SwXMLDocStylesContext_Impl::~SwXMLDocStylesContext_Impl()
348 : {
349 156 : }
350 :
351 0 : TYPEINIT1( SwXMLDocStylesContext_Impl, SwXMLDocContext_Impl );
352 :
353 52 : void SwXMLDocStylesContext_Impl::EndElement()
354 : {
355 : // assign paragraph styles to list levels of outline style after all styles
356 : // are imported and finished.
357 52 : SwXMLImport& rSwImport = dynamic_cast<SwXMLImport&>( GetImport());
358 52 : GetImport().GetTextImport()->SetOutlineStyles(
359 104 : (rSwImport.GetStyleFamilyMask() & SFX_STYLE_FAMILY_PARA ) ? sal_True : sal_False);
360 52 : }
361 : //----------------------------------------------------------------------------
362 :
363 464 : const SvXMLTokenMap& SwXMLImport::GetDocElemTokenMap()
364 : {
365 464 : if( !pDocElemTokenMap )
366 155 : pDocElemTokenMap = new SvXMLTokenMap( aDocTokenMap );
367 :
368 464 : return *pDocElemTokenMap;
369 : }
370 :
371 208 : SvXMLImportContext *SwXMLImport::CreateContext(
372 : sal_uInt16 nPrefix,
373 : const OUString& rLocalName,
374 : const Reference< xml::sax::XAttributeList > & xAttrList )
375 : {
376 208 : SvXMLImportContext *pContext = 0;
377 :
378 : // #i69629# - own subclasses for <office:document> and <office:document-styles>
379 517 : if( XML_NAMESPACE_OFFICE==nPrefix &&
380 363 : ( IsXMLToken( rLocalName, XML_DOCUMENT_SETTINGS ) ||
381 156 : IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT ) ))
382 204 : pContext = new SwXMLDocContext_Impl( *this, nPrefix, rLocalName,
383 204 : xAttrList );
384 211 : else if ( XML_NAMESPACE_OFFICE==nPrefix &&
385 105 : IsXMLToken( rLocalName, XML_DOCUMENT_META ) )
386 : {
387 52 : pContext = CreateMetaContext(rLocalName);
388 : }
389 107 : else if ( XML_NAMESPACE_OFFICE==nPrefix &&
390 53 : IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) )
391 : {
392 104 : pContext = new SwXMLDocStylesContext_Impl( *this, nPrefix, rLocalName,
393 104 : xAttrList );
394 : }
395 3 : else if ( XML_NAMESPACE_OFFICE==nPrefix &&
396 1 : IsXMLToken( rLocalName, XML_DOCUMENT ) )
397 : {
398 : uno::Reference<document::XDocumentProperties> const xDocProps(
399 1 : GetDocumentProperties());
400 : // flat OpenDocument file format
401 2 : pContext = new SwXMLOfficeDocContext_Impl( *this, nPrefix, rLocalName,
402 2 : xAttrList, xDocProps);
403 : }
404 : else
405 1 : pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
406 :
407 208 : return pContext;
408 : }
409 :
410 213 : SwXMLImport::SwXMLImport(
411 : const uno::Reference< uno::XComponentContext > xContext,
412 : sal_uInt16 nImportFlags)
413 : : SvXMLImport( xContext, nImportFlags ),
414 : pSttNdIdx( 0 ),
415 : pTableItemMapper( 0 ),
416 : pDocElemTokenMap( 0 ),
417 : pTableElemTokenMap( 0 ),
418 : pTableCellAttrTokenMap( 0 ),
419 : pGraphicResolver( 0 ),
420 : pEmbeddedResolver( 0 ),
421 : nStyleFamilyMask( SFX_STYLE_FAMILY_ALL ),
422 : bLoadDoc( true ),
423 : bInsert( false ),
424 : bBlock( false ),
425 : bShowProgress( true ),
426 : bOrganizerMode( false ),
427 : bInititedXForms( false ),
428 : bPreserveRedlineMode( sal_True ),
429 213 : doc( NULL )
430 : {
431 213 : _InitItemImport();
432 :
433 213 : }
434 :
435 639 : SwXMLImport::~SwXMLImport() throw ()
436 : {
437 213 : delete pDocElemTokenMap;
438 213 : delete pTableElemTokenMap;
439 213 : delete pTableCellAttrTokenMap;
440 213 : _FinitItemImport();
441 426 : }
442 :
443 1 : void SwXMLImport::setTextInsertMode(
444 : const Reference< XTextRange > & rInsertPos )
445 : {
446 1 : bInsert = true;
447 :
448 1 : Reference < XText > xText = rInsertPos->getText();
449 : Reference < XTextCursor > xTextCursor =
450 2 : xText->createTextCursorByRange( rInsertPos );
451 2 : GetTextImport()->SetCursor( xTextCursor );
452 1 : }
453 :
454 0 : void SwXMLImport::setStyleInsertMode( sal_uInt16 nFamilies,
455 : sal_Bool bOverwrite )
456 : {
457 0 : bInsert = !bOverwrite;
458 0 : nStyleFamilyMask = nFamilies;
459 0 : bLoadDoc = false;
460 0 : }
461 :
462 0 : void SwXMLImport::setBlockMode( )
463 : {
464 0 : bBlock = true;
465 0 : }
466 :
467 2 : void SwXMLImport::setOrganizerMode( )
468 : {
469 2 : bOrganizerMode = true;
470 2 : }
471 :
472 : namespace
473 : {
474 : class theSwXMLImportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXMLImportUnoTunnelId > {};
475 : }
476 :
477 0 : const Sequence< sal_Int8 > & SwXMLImport::getUnoTunnelId() throw()
478 : {
479 0 : return theSwXMLImportUnoTunnelId::get().getSeq();
480 : }
481 :
482 0 : sal_Int64 SAL_CALL SwXMLImport::getSomething( const Sequence< sal_Int8 >& rId )
483 : throw(RuntimeException)
484 : {
485 0 : if( rId.getLength() == 16
486 0 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
487 0 : rId.getConstArray(), 16 ) )
488 : {
489 0 : return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
490 : }
491 0 : return SvXMLImport::getSomething( rId );
492 : }
493 :
494 105 : static OTextCursorHelper *lcl_xml_GetSwXTextCursor( const Reference < XTextCursor >& rTextCursor )
495 : {
496 105 : Reference<XUnoTunnel> xCrsrTunnel( rTextCursor, UNO_QUERY );
497 : OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
498 105 : if( !xCrsrTunnel.is() )
499 0 : return 0;
500 : OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper *>(
501 105 : sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
502 : OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
503 105 : return pTxtCrsr;
504 : }
505 :
506 207 : void SwXMLImport::startDocument( void )
507 : throw( xml::sax::SAXException, uno::RuntimeException )
508 : {
509 : // delegate to parent
510 207 : SvXMLImport::startDocument();
511 :
512 : OSL_ENSURE( GetModel().is(), "model is missing" );
513 207 : if( !GetModel().is() )
514 103 : return;
515 :
516 : // this method will modify the document directly -> lock SolarMutex
517 207 : SolarMutexGuard aGuard;
518 :
519 :
520 311 : Reference< XPropertySet > xImportInfo( getImportInfo() );
521 311 : Reference< XPropertySetInfo > xPropertySetInfo;
522 207 : if( xImportInfo.is() )
523 206 : xPropertySetInfo = xImportInfo->getPropertySetInfo();
524 207 : if( xPropertySetInfo.is() )
525 : {
526 206 : Any aAny;
527 : // insert style mode?
528 412 : OUString sStyleInsertModeFamilies("StyleInsertModeFamilies");
529 206 : if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeFamilies) )
530 : {
531 206 : aAny = xImportInfo->getPropertyValue(sStyleInsertModeFamilies);
532 206 : Sequence< OUString> aFamiliesSeq;
533 206 : if( aAny >>= aFamiliesSeq )
534 : {
535 0 : OUString sFrameStyles( "FrameStyles" );
536 0 : OUString sPageStyles( "PageStyles" );
537 0 : OUString sCharacterStyles( "CharacterStyles" );
538 0 : OUString sParagraphStyles( "ParagraphStyles" );
539 0 : OUString sNumberingStyles( "NumberingStyles" );
540 0 : sal_uInt16 nFamilyMask = 0U;
541 0 : sal_Int32 nCount = aFamiliesSeq.getLength();
542 0 : const OUString *pSeq = aFamiliesSeq.getConstArray();
543 0 : for( sal_Int32 i=0; i < nCount; i++ )
544 : {
545 0 : const OUString& rFamily = pSeq[i];
546 0 : if( rFamily==sFrameStyles )
547 0 : nFamilyMask |= SFX_STYLE_FAMILY_FRAME;
548 0 : else if( rFamily==sPageStyles )
549 0 : nFamilyMask |= SFX_STYLE_FAMILY_PAGE;
550 0 : else if( rFamily==sCharacterStyles )
551 0 : nFamilyMask |= SFX_STYLE_FAMILY_CHAR;
552 0 : else if( rFamily==sParagraphStyles )
553 0 : nFamilyMask |= SFX_STYLE_FAMILY_PARA;
554 0 : else if( rFamily==sNumberingStyles )
555 0 : nFamilyMask |= SFX_STYLE_FAMILY_PSEUDO;
556 : }
557 :
558 0 : sal_Bool bOverwrite = sal_False;
559 0 : OUString sStyleInsertModeOverwrite("StyleInsertModeOverwrite");
560 0 : if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeOverwrite) )
561 : {
562 0 : aAny = xImportInfo->getPropertyValue(sStyleInsertModeOverwrite);
563 0 : if( aAny.getValueType() == ::getBooleanCppuType() &&
564 0 : *static_cast<const sal_Bool*>(aAny.getValue()) )
565 0 : bOverwrite = sal_True;
566 : }
567 :
568 0 : setStyleInsertMode( nFamilyMask, bOverwrite );
569 206 : }
570 : }
571 :
572 : // text insert mode?
573 412 : OUString sTextInsertModeRange("TextInsertModeRange");
574 206 : if( xPropertySetInfo->hasPropertyByName(sTextInsertModeRange) )
575 : {
576 206 : aAny = xImportInfo->getPropertyValue(sTextInsertModeRange);
577 206 : Reference<XTextRange> xInsertTextRange;
578 206 : if( aAny >>= xInsertTextRange )
579 0 : setTextInsertMode( xInsertTextRange );
580 : }
581 :
582 : // auto text mode
583 412 : OUString sAutoTextMode("AutoTextMode");
584 206 : if( xPropertySetInfo->hasPropertyByName(sAutoTextMode) )
585 : {
586 206 : aAny = xImportInfo->getPropertyValue(sAutoTextMode);
587 206 : if( aAny.getValueType() == ::getBooleanCppuType() &&
588 0 : *static_cast<const sal_Bool*>(aAny.getValue()) )
589 0 : setBlockMode();
590 : }
591 :
592 : // organizer mode
593 412 : OUString sOrganizerMode("OrganizerMode");
594 206 : if( xPropertySetInfo->hasPropertyByName(sOrganizerMode) )
595 : {
596 206 : aAny = xImportInfo->getPropertyValue(sOrganizerMode);
597 208 : if( aAny.getValueType() == ::getBooleanCppuType() &&
598 2 : *static_cast<const sal_Bool*>(aAny.getValue()) )
599 2 : setOrganizerMode();
600 206 : }
601 : }
602 :
603 : // There only is a text cursor by now if we are in insert mode. In any
604 : // other case we have to create one at the start of the document.
605 : // We also might change into the insert mode later, so we have to make
606 : // sure to first set the insert mode and then create the text import
607 : // helper. Otherwise it won't have the insert flag set!
608 207 : OTextCursorHelper *pTxtCrsr = 0;
609 311 : Reference < XTextCursor > xTextCursor;
610 207 : if( HasTextImport() )
611 0 : xTextCursor = GetTextImport()->GetCursor();
612 207 : if( !xTextCursor.is() )
613 : {
614 207 : Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
615 414 : Reference < XText > xText = xTextDoc->getText();
616 207 : xTextCursor = xText->createTextCursor();
617 207 : SwCrsrShell *pCrsrSh = 0;
618 207 : SwDoc *pDoc = 0;
619 207 : if( IMPORT_ALL == getImportFlags() )
620 : {
621 1 : pTxtCrsr = lcl_xml_GetSwXTextCursor( xTextCursor );
622 : OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
623 1 : if( !pTxtCrsr )
624 0 : return;
625 :
626 1 : pDoc = pTxtCrsr->GetDoc();
627 : OSL_ENSURE( pDoc, "SwDoc missing" );
628 1 : if( !pDoc )
629 0 : return;
630 :
631 : // Is there a edit shell. If yes, then we are currently inserting
632 : // a document. We then have to insert at the current edit shell's
633 : // cursor position. That not quite clean code, but there is no other
634 : // way currently.
635 1 : pCrsrSh = pDoc->GetEditShell();
636 : }
637 207 : if( pCrsrSh )
638 : {
639 : const uno::Reference<text::XTextRange> xInsertTextRange(
640 : SwXTextRange::CreateXTextRange(
641 1 : *pDoc, *pCrsrSh->GetCrsr()->GetPoint(), 0 ) );
642 1 : setTextInsertMode( xInsertTextRange );
643 1 : xTextCursor = GetTextImport()->GetCursor();
644 1 : pTxtCrsr = 0;
645 : }
646 : else
647 413 : GetTextImport()->SetCursor( xTextCursor );
648 : }
649 :
650 207 : if( (getImportFlags() & (IMPORT_CONTENT|IMPORT_MASTERSTYLES)) == 0 )
651 103 : return;
652 :
653 104 : if( !pTxtCrsr )
654 104 : pTxtCrsr = lcl_xml_GetSwXTextCursor( xTextCursor );
655 : OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
656 104 : if( !pTxtCrsr )
657 0 : return;
658 :
659 104 : SwDoc *pDoc = pTxtCrsr->GetDoc();
660 : OSL_ENSURE( pDoc, "SwDoc missing" );
661 104 : if( !pDoc )
662 0 : return;
663 :
664 104 : if( (getImportFlags() & IMPORT_CONTENT) != 0 && !IsStylesOnlyMode() )
665 : {
666 52 : pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() );
667 52 : if( IsInsertMode() )
668 : {
669 1 : SwPaM *pPaM = pTxtCrsr->GetPaM();
670 1 : const SwPosition* pPos = pPaM->GetPoint();
671 :
672 : // Split once and remember the node that has been splitted.
673 1 : pDoc->SplitNode( *pPos, false );
674 1 : *pSttNdIdx = pPos->nNode.GetIndex()-1;
675 :
676 : // Split again.
677 1 : pDoc->SplitNode( *pPos, false );
678 :
679 : // Insert all content into the new node
680 1 : pPaM->Move( fnMoveBackward );
681 : pDoc->SetTxtFmtColl
682 1 : ( *pPaM, pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false ) );
683 : }
684 : }
685 :
686 : // We need a draw model to be able to set the z order
687 104 : pDoc->GetOrCreateDrawModel(); // #i52858# - method name changed
688 :
689 : // SJ: #i49801# locking the modell to disable repaints
690 104 : SdrModel* pDrawModel = pDoc->GetDrawModel();
691 104 : if ( pDrawModel )
692 104 : pDrawModel->setLock(true);
693 :
694 104 : if( !GetGraphicResolver().is() )
695 : {
696 0 : pGraphicResolver = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_READ );
697 0 : Reference< document::XGraphicObjectResolver > xGraphicResolver( pGraphicResolver );
698 0 : SetGraphicResolver( xGraphicResolver );
699 : }
700 :
701 104 : if( !GetEmbeddedResolver().is() )
702 : {
703 0 : SfxObjectShell *pPersist = pDoc->GetPersist();
704 0 : if( pPersist )
705 : {
706 : pEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
707 : *pPersist,
708 0 : EMBEDDEDOBJECTHELPER_MODE_READ );
709 0 : Reference< document::XEmbeddedObjectResolver > xEmbeddedResolver( pEmbeddedResolver );
710 0 : SetEmbeddedResolver( xEmbeddedResolver );
711 : }
712 104 : }
713 : }
714 :
715 207 : void SwXMLImport::endDocument( void )
716 : throw( xml::sax::SAXException, uno::RuntimeException )
717 : {
718 : OSL_ENSURE( GetModel().is(), "model missing; maybe startDocument wasn't called?" );
719 207 : if( !GetModel().is() )
720 207 : return;
721 :
722 : // this method will modify the document directly -> lock SolarMutex
723 207 : SolarMutexGuard aGuard;
724 :
725 207 : if( pGraphicResolver )
726 0 : SvXMLGraphicHelper::Destroy( pGraphicResolver );
727 207 : if( pEmbeddedResolver )
728 0 : SvXMLEmbeddedObjectHelper::Destroy( pEmbeddedResolver );
729 : // Clear the shape import to sort the shapes (and not in the
730 : // destructor that might be called after the import has finished
731 : // for Java filters.
732 207 : if( HasShapeImport() )
733 103 : ClearShapeImport();
734 :
735 :
736 207 : SwDoc *pDoc = 0;
737 207 : if( (getImportFlags() & IMPORT_CONTENT) != 0 && !IsStylesOnlyMode() )
738 : {
739 104 : Reference<XUnoTunnel> xCrsrTunnel( GetTextImport()->GetCursor(),
740 52 : UNO_QUERY);
741 : OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
742 : OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper *>(
743 52 : sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
744 : OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
745 52 : SwPaM *pPaM = pTxtCrsr->GetPaM();
746 52 : if( IsInsertMode() && pSttNdIdx->GetIndex() )
747 : {
748 : // If we are in insert mode, join the splitted node that is in front
749 : // of the new content with the first new node. Or in other words:
750 : // Revert the first split node.
751 1 : SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode();
752 1 : SwNodeIndex aNxtIdx( *pSttNdIdx );
753 2 : if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx ) &&
754 1 : pSttNdIdx->GetIndex() + 1 == aNxtIdx.GetIndex() )
755 : {
756 : // If the PaM points to the first new node, move the PaM to the
757 : // end of the previous node.
758 1 : if( pPaM && pPaM->GetPoint()->nNode == aNxtIdx )
759 : {
760 0 : pPaM->GetPoint()->nNode = *pSttNdIdx;
761 0 : pPaM->GetPoint()->nContent.Assign( pTxtNode,
762 0 : pTxtNode->GetTxt().getLength());
763 : }
764 :
765 : #if OSL_DEBUG_LEVEL > 0
766 : // !!! This should be impossible !!!!
767 : OSL_ENSURE( pSttNdIdx->GetIndex()+1 !=
768 : pPaM->GetBound( sal_True ).nNode.GetIndex(),
769 : "PaM.Bound1 point to new node " );
770 : OSL_ENSURE( pSttNdIdx->GetIndex()+1 !=
771 : pPaM->GetBound( sal_False ).nNode.GetIndex(),
772 : "PaM.Bound2 points to new node" );
773 :
774 : if( pSttNdIdx->GetIndex()+1 ==
775 : pPaM->GetBound( sal_True ).nNode.GetIndex() )
776 : {
777 : sal_uInt16 nCntPos =
778 : pPaM->GetBound( sal_True ).nContent.GetIndex();
779 : pPaM->GetBound( sal_True ).nContent.Assign( pTxtNode,
780 : pTxtNode->GetTxt().getLength() + nCntPos );
781 : }
782 : if( pSttNdIdx->GetIndex()+1 ==
783 : pPaM->GetBound( sal_False ).nNode.GetIndex() )
784 : {
785 : sal_uInt16 nCntPos =
786 : pPaM->GetBound( sal_False ).nContent.GetIndex();
787 : pPaM->GetBound( sal_False ).nContent.Assign( pTxtNode,
788 : pTxtNode->GetTxt().getLength() + nCntPos );
789 : }
790 : #endif
791 : // If the first new node isn't empty, convert the node's text
792 : // attributes into hints. Otherwise, set the new node's
793 : // paragraph style at the previous (empty) node.
794 1 : SwTxtNode* pDelNd = aNxtIdx.GetNode().GetTxtNode();
795 1 : if (!pTxtNode->GetTxt().isEmpty())
796 0 : pDelNd->FmtToTxtAttr( pTxtNode );
797 : else
798 1 : pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() );
799 1 : pTxtNode->JoinNext();
800 1 : }
801 : }
802 :
803 52 : SwPosition* pPos = pPaM->GetPoint();
804 : OSL_ENSURE( !pPos->nContent.GetIndex(), "last paragraph isn't empty" );
805 52 : if( !pPos->nContent.GetIndex() )
806 : {
807 : SwTxtNode* pCurrNd;
808 52 : sal_uLong nNodeIdx = pPos->nNode.GetIndex();
809 52 : pDoc = pPaM->GetDoc();
810 :
811 : OSL_ENSURE( pPos->nNode.GetNode().IsCntntNode(),
812 : "insert position is not a content node" );
813 52 : if( !IsInsertMode() )
814 : {
815 : // If we're not in insert mode, the last node is deleted.
816 51 : const SwNode *pPrev = pDoc->GetNodes()[nNodeIdx -1];
817 103 : if( pPrev->IsCntntNode() ||
818 4 : ( pPrev->IsEndNode() &&
819 2 : pPrev->StartOfSectionNode()->IsSectionNode() ) )
820 : {
821 50 : SwCntntNode* pCNd = pPaM->GetCntntNode();
822 100 : if( pCNd && pCNd->StartOfSectionIndex()+2 <
823 50 : pCNd->EndOfSectionIndex() )
824 : {
825 50 : pPaM->GetBound(sal_True).nContent.Assign( 0, 0 );
826 50 : pPaM->GetBound(sal_False).nContent.Assign( 0, 0 );
827 50 : pDoc->GetNodes().Delete( pPaM->GetPoint()->nNode );
828 : }
829 : }
830 : }
831 1 : else if( 0 != (pCurrNd = pDoc->GetNodes()[nNodeIdx]->GetTxtNode()) )
832 : {
833 : // Id we're in insert mode, the empty node is joined with
834 : // the next and the previous one.
835 1 : if( pCurrNd->CanJoinNext( &pPos->nNode ))
836 : {
837 1 : SwTxtNode* pNextNd = pPos->nNode.GetNode().GetTxtNode();
838 1 : pPos->nContent.Assign( pNextNd, 0 );
839 1 : pPaM->SetMark(); pPaM->DeleteMark();
840 1 : pNextNd->JoinPrev();
841 :
842 : // Remove line break that has been inserted by the import,
843 : // but only if one has been inserted!
844 2 : if( pNextNd->CanJoinPrev(/* &pPos->nNode*/ ) &&
845 1 : *pSttNdIdx != pPos->nNode )
846 : {
847 1 : pNextNd->JoinPrev();
848 : }
849 : }
850 0 : else if (pCurrNd->GetTxt().isEmpty())
851 : {
852 0 : pPos->nContent.Assign( 0, 0 );
853 0 : pPaM->SetMark(); pPaM->DeleteMark();
854 0 : pDoc->GetNodes().Delete( pPos->nNode, 1 );
855 0 : pPaM->Move( fnMoveBackward );
856 : }
857 : }
858 52 : }
859 : }
860 :
861 : /* Was called too early. Moved from SwXMLBodyContext_Impl::EndElement */
862 :
863 207 : GetTextImport()->RedlineAdjustStartNodeCursor( sal_False );
864 :
865 414 : if( (getImportFlags() & IMPORT_CONTENT) != 0 ||
866 207 : ((getImportFlags() & IMPORT_MASTERSTYLES) != 0 && IsStylesOnlyMode()) )
867 : {
868 : // pDoc might be 0. In this case UpdateTxtCollCondition is looking
869 : // for it itself.
870 52 : UpdateTxtCollConditions( pDoc );
871 : }
872 :
873 207 : GetTextImport()->ResetCursor();
874 :
875 207 : delete pSttNdIdx;
876 207 : pSttNdIdx = 0;
877 :
878 207 : if( (getImportFlags() == IMPORT_ALL ) )
879 : {
880 : // Notify math objects. If we are in the package filter this will
881 : // be done by the filter object itself
882 1 : if( IsInsertMode() )
883 1 : pDoc->PrtOLENotify( sal_False );
884 0 : else if ( pDoc->IsOLEPrtNotifyPending() )
885 0 : pDoc->PrtOLENotify( sal_True );
886 : }
887 :
888 : // SJ: #i49801# -> now permitting repaints
889 207 : if ( pDoc )
890 : {
891 52 : SdrModel* pDrawModel = pDoc->GetDrawModel();
892 52 : if ( pDrawModel )
893 52 : pDrawModel->setLock(false);
894 : }
895 :
896 : // #i90243#
897 207 : if ( bInititedXForms )
898 : {
899 0 : Reference< xforms::XFormsSupplier > xFormsSupp( GetModel(), UNO_QUERY );
900 0 : Reference< XNameAccess > xXForms;
901 0 : if ( xFormsSupp.is() )
902 0 : xXForms = xFormsSupp->getXForms().get();
903 :
904 0 : if ( xXForms.is() )
905 : {
906 : try
907 : {
908 0 : Sequence< beans::PropertyValue > aXFormsSettings;
909 :
910 0 : OUString sXFormsSettingsName( GetXMLToken( XML_XFORM_MODEL_SETTINGS ) );
911 0 : if ( xLateInitSettings.is() && xLateInitSettings->hasByName( sXFormsSettingsName ) )
912 : {
913 0 : OSL_VERIFY( xLateInitSettings->getByName( sXFormsSettingsName ) >>= aXFormsSettings );
914 0 : applyXFormsSettings( xXForms, aXFormsSettings );
915 0 : }
916 : }
917 0 : catch( const Exception& )
918 : {
919 : DBG_UNHANDLED_EXCEPTION();
920 : }
921 0 : }
922 : }
923 :
924 : // delegate to parent: takes care of error handling
925 207 : SvXMLImport::endDocument();
926 207 : ClearTextImport();
927 : }
928 :
929 :
930 : // Locally derive XMLTextShapeImportHelper, so we can take care of the
931 : // form import This is Writer, but not text specific, so it should go
932 : // here!
933 : class SvTextShapeImportHelper : public XMLTextShapeImportHelper
934 : {
935 : // hold own reference form import helper, because the SvxImport
936 : // stored in the superclass, from whom we originally got the
937 : // reference, is already destroyed when we want to use it in the
938 : // destructor
939 : UniReference< ::xmloff::OFormLayerXMLImport > rFormImport;
940 :
941 : // hold reference to the one page (if it exists) for calling startPage()
942 : // and endPage. If !xPage.is(), then this document doesn't have a
943 : // XDrawPage.
944 : Reference<drawing::XDrawPage> xPage;
945 :
946 : public:
947 :
948 : SvTextShapeImportHelper(SvXMLImport& rImp);
949 : virtual ~SvTextShapeImportHelper();
950 : };
951 :
952 103 : SvTextShapeImportHelper::SvTextShapeImportHelper(SvXMLImport& rImp) :
953 103 : XMLTextShapeImportHelper(rImp)
954 : {
955 103 : Reference<drawing::XDrawPageSupplier> xSupplier(rImp.GetModel(),UNO_QUERY);
956 103 : if (xSupplier.is())
957 : {
958 103 : if (rImp.GetFormImport().is())
959 : {
960 103 : rImp.GetFormImport()->startPage(xSupplier->getDrawPage());
961 103 : rFormImport = rImp.GetFormImport();
962 : }
963 :
964 103 : xPage = xSupplier->getDrawPage();
965 103 : Reference<XShapes> xShapes( xPage, UNO_QUERY );
966 103 : XMLShapeImportHelper::startPage( xShapes );
967 103 : }
968 103 : }
969 :
970 309 : SvTextShapeImportHelper::~SvTextShapeImportHelper()
971 : {
972 103 : rFormImport->endPage();
973 :
974 103 : if (xPage.is())
975 : {
976 103 : Reference<XShapes> xShapes( xPage, UNO_QUERY );
977 103 : XMLShapeImportHelper::endPage(xShapes);
978 : }
979 206 : }
980 :
981 :
982 207 : XMLTextImportHelper* SwXMLImport::CreateTextImport()
983 : {
984 207 : return new SwXMLTextImportHelper( GetModel(), *this, getImportInfo(),
985 207 : IsInsertMode(),
986 207 : IsStylesOnlyMode(), bShowProgress,
987 414 : IsBlockMode(), IsOrganizerMode(),
988 1035 : bPreserveRedlineMode );
989 : }
990 :
991 103 : XMLShapeImportHelper* SwXMLImport::CreateShapeImport()
992 : {
993 103 : return new SvTextShapeImportHelper( *this );
994 : }
995 :
996 103 : SvXMLImportContext *SwXMLImport::CreateFontDeclsContext(
997 : const OUString& rLocalName,
998 : const Reference< xml::sax::XAttributeList > & xAttrList )
999 : {
1000 : XMLFontStylesContext *pFSContext =
1001 : new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE,
1002 : rLocalName, xAttrList,
1003 103 : osl_getThreadTextEncoding() );
1004 103 : SetFontDecls( pFSContext );
1005 103 : return pFSContext;
1006 : }
1007 50 : void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps)
1008 : {
1009 50 : if (IsInsertMode() || IsStylesOnlyMode() || IsBlockMode() || IsOrganizerMode() || !GetModel().is() )
1010 50 : return;
1011 :
1012 : // this method will modify the document directly -> lock SolarMutex
1013 50 : SolarMutexGuard aGuard;
1014 :
1015 50 : SwDoc *pDoc = getDoc();
1016 50 : Rectangle aRect;
1017 50 : if( pDoc->GetDocShell() )
1018 50 : aRect = pDoc->GetDocShell()->GetVisArea( ASPECT_CONTENT );
1019 : //TODO/LATER: why that cast?!
1020 : //aRect = ((SfxInPlaceObject *)pDoc->GetDocShell())->GetVisArea();
1021 :
1022 50 : sal_Int32 nCount = aViewProps.getLength();
1023 50 : const PropertyValue *pValue = aViewProps.getConstArray();
1024 :
1025 50 : sal_Int64 nTmp = 0;
1026 50 : sal_Bool bShowRedlineChanges = sal_False, bBrowseMode = sal_False;
1027 50 : sal_Bool bChangeShowRedline = sal_False, bChangeBrowseMode = sal_False;
1028 :
1029 : //TODO/LATER: why that cast?!
1030 50 : sal_Bool bTwip = pDoc->GetDocShell()->GetMapUnit ( ) == MAP_TWIP;
1031 : //sal_Bool bTwip = pDoc->GetDocShell()->SfxInPlaceObject::GetMapUnit ( ) == MAP_TWIP;
1032 :
1033 396 : for (sal_Int32 i = 0; i < nCount ; i++)
1034 : {
1035 346 : if ( pValue->Name == "ViewAreaTop" )
1036 : {
1037 50 : pValue->Value >>= nTmp;
1038 50 : aRect.setY( static_cast< long >(bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp) );
1039 : }
1040 296 : else if ( pValue->Name == "ViewAreaLeft" )
1041 : {
1042 50 : pValue->Value >>= nTmp;
1043 50 : aRect.setX( static_cast< long >(bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp) );
1044 : }
1045 246 : else if ( pValue->Name == "ViewAreaWidth" )
1046 : {
1047 50 : pValue->Value >>= nTmp;
1048 50 : Size aSize( aRect.GetSize() );
1049 50 : aSize.Width() = static_cast< long >(bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp);
1050 50 : aRect.SetSize( aSize );
1051 : }
1052 196 : else if ( pValue->Name == "ViewAreaHeight" )
1053 : {
1054 50 : pValue->Value >>= nTmp;
1055 50 : Size aSize( aRect.GetSize() );
1056 50 : aSize.Height() = static_cast< long >(bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp);
1057 50 : aRect.SetSize( aSize );
1058 : }
1059 146 : else if ( pValue->Name == "ShowRedlineChanges" )
1060 : {
1061 50 : bShowRedlineChanges = *(sal_Bool *)(pValue->Value.getValue());
1062 50 : bChangeShowRedline = sal_True;
1063 : }
1064 : // Headers and footers are not displayed in BrowseView anymore
1065 96 : else if ( pValue->Name == "InBrowseMode" )
1066 : {
1067 50 : bBrowseMode = *(sal_Bool *)(pValue->Value.getValue());
1068 50 : bChangeBrowseMode = sal_True;
1069 : }
1070 346 : pValue++;
1071 : }
1072 50 : if( pDoc->GetDocShell() )
1073 50 : pDoc->GetDocShell()->SetVisArea ( aRect );
1074 :
1075 50 : if (bChangeBrowseMode)
1076 50 : pDoc->set(IDocumentSettingAccess::BROWSE_MODE, bBrowseMode );
1077 :
1078 50 : if (bChangeShowRedline)
1079 50 : GetTextImport()->SetShowChanges( bShowRedlineChanges );
1080 : }
1081 :
1082 51 : void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aConfigProps)
1083 : {
1084 : // this method will modify the document directly -> lock SolarMutex
1085 51 : SolarMutexGuard aGuard;
1086 :
1087 102 : Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
1088 51 : if( !xFac.is() )
1089 0 : return;
1090 :
1091 102 : Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
1092 51 : if( !xProps.is() )
1093 0 : return;
1094 :
1095 102 : Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
1096 51 : if( !xInfo.is() )
1097 0 : return;
1098 :
1099 102 : boost::unordered_set< String, StringHashRef, StringEqRef > aSet;
1100 51 : aSet.insert(String("ForbiddenCharacters", RTL_TEXTENCODING_ASCII_US));
1101 51 : aSet.insert(String("IsKernAsianPunctuation", RTL_TEXTENCODING_ASCII_US));
1102 51 : aSet.insert(String("CharacterCompressionType", RTL_TEXTENCODING_ASCII_US));
1103 51 : aSet.insert(String("LinkUpdateMode", RTL_TEXTENCODING_ASCII_US));
1104 51 : aSet.insert(String("FieldAutoUpdate", RTL_TEXTENCODING_ASCII_US));
1105 51 : aSet.insert(String("ChartAutoUpdate", RTL_TEXTENCODING_ASCII_US));
1106 51 : aSet.insert(String("AddParaTableSpacing", RTL_TEXTENCODING_ASCII_US));
1107 51 : aSet.insert(String("AddParaTableSpacingAtStart", RTL_TEXTENCODING_ASCII_US));
1108 51 : aSet.insert(String("PrintAnnotationMode", RTL_TEXTENCODING_ASCII_US));
1109 51 : aSet.insert(String("PrintBlackFonts", RTL_TEXTENCODING_ASCII_US));
1110 51 : aSet.insert(String("PrintControls", RTL_TEXTENCODING_ASCII_US));
1111 51 : aSet.insert(String("PrintDrawings", RTL_TEXTENCODING_ASCII_US));
1112 51 : aSet.insert(String("PrintGraphics", RTL_TEXTENCODING_ASCII_US));
1113 51 : aSet.insert(String("PrintLeftPages", RTL_TEXTENCODING_ASCII_US));
1114 51 : aSet.insert(String("PrintPageBackground", RTL_TEXTENCODING_ASCII_US));
1115 51 : aSet.insert(String("PrintProspect", RTL_TEXTENCODING_ASCII_US));
1116 51 : aSet.insert(String("PrintReversed", RTL_TEXTENCODING_ASCII_US));
1117 51 : aSet.insert(String("PrintRightPages", RTL_TEXTENCODING_ASCII_US));
1118 51 : aSet.insert(String("PrintFaxName", RTL_TEXTENCODING_ASCII_US));
1119 51 : aSet.insert(String("PrintPaperFromSetup", RTL_TEXTENCODING_ASCII_US));
1120 51 : aSet.insert(String("PrintTables", RTL_TEXTENCODING_ASCII_US));
1121 51 : aSet.insert(String("PrintSingleJobs", RTL_TEXTENCODING_ASCII_US));
1122 51 : aSet.insert(String("UpdateFromTemplate", RTL_TEXTENCODING_ASCII_US));
1123 51 : aSet.insert(String("PrinterIndependentLayout", RTL_TEXTENCODING_ASCII_US));
1124 51 : aSet.insert(String("PrintEmptyPages", RTL_TEXTENCODING_ASCII_US));
1125 51 : aSet.insert(String("SmallCapsPercentage66", RTL_TEXTENCODING_ASCII_US));
1126 51 : aSet.insert(String("TabOverflow", RTL_TEXTENCODING_ASCII_US));
1127 51 : aSet.insert(String("UnbreakableNumberings", RTL_TEXTENCODING_ASCII_US));
1128 51 : aSet.insert(String("ClippedPictures", RTL_TEXTENCODING_ASCII_US));
1129 51 : aSet.insert(String("BackgroundParaOverDrawings", RTL_TEXTENCODING_ASCII_US));
1130 51 : aSet.insert(String("TabOverMargin", RTL_TEXTENCODING_ASCII_US));
1131 :
1132 51 : sal_Int32 nCount = aConfigProps.getLength();
1133 51 : const PropertyValue* pValues = aConfigProps.getConstArray();
1134 :
1135 102 : SvtSaveOptions aSaveOpt;
1136 51 : sal_Bool bIsUserSetting = aSaveOpt.IsLoadUserSettings(),
1137 51 : bSet = bIsUserSetting;
1138 :
1139 : // for some properties we don't want to use the application
1140 : // default if they're missing. So we watch for them in the loop
1141 : // below, and set them if not found
1142 51 : bool bPrinterIndependentLayout = false;
1143 51 : bool bUseOldNumbering = false;
1144 51 : bool bOutlineLevelYieldsOutlineRule = false;
1145 51 : bool bAddExternalLeading = false;
1146 51 : bool bAddParaSpacingToTableCells = false;
1147 51 : bool bUseFormerLineSpacing = false;
1148 51 : bool bUseFormerObjectPositioning = false;
1149 51 : bool bUseFormerTextWrapping = false;
1150 51 : bool bConsiderWrapOnObjPos = false;
1151 51 : bool bIgnoreFirstLineIndentInNumbering = false;
1152 51 : bool bDoNotJustifyLinesWithManualBreak = false;
1153 51 : bool bDoNotResetParaAttrsForNumFont = false;
1154 51 : bool bLoadReadonly = false;
1155 51 : bool bDoNotCaptureDrawObjsOnPage( false );
1156 51 : bool bClipAsCharacterAnchoredWriterFlyFrames( false );
1157 51 : bool bUnixForceZeroExtLeading = false;
1158 51 : bool bUseOldPrinterMetrics = false;
1159 51 : bool bSmallCapsPercentage66 = false;
1160 51 : bool bTabOverflow = false;
1161 51 : bool bUnbreakableNumberings = false;
1162 51 : bool bClippedPictures = false;
1163 51 : bool bBackgroundParaOverDrawings = false;
1164 51 : bool bTabOverMargin = false;
1165 :
1166 102 : OUString sRedlineProtectionKey( "RedlineProtectionKey" );
1167 :
1168 51 : const PropertyValue* currentDatabaseDataSource = NULL;
1169 51 : const PropertyValue* currentDatabaseCommand = NULL;
1170 51 : const PropertyValue* currentDatabaseCommandType = NULL;
1171 102 : OUString currentDatabaseDataSourceKey( "CurrentDatabaseDataSource" );
1172 102 : OUString currentDatabaseCommandKey( "CurrentDatabaseCommand" );
1173 102 : OUString currentDatabaseCommandTypeKey( "CurrentDatabaseCommandType" );
1174 :
1175 3585 : while( nCount-- )
1176 : {
1177 3483 : if( !bIsUserSetting )
1178 : {
1179 : // test over the hash value if the entry is in the table.
1180 0 : String aStr(pValues->Name);
1181 :
1182 0 : bSet = aSet.find(aStr) == aSet.end();
1183 : }
1184 :
1185 3483 : if( bSet )
1186 : {
1187 : try
1188 : {
1189 3483 : if( xInfo->hasPropertyByName( pValues->Name ) )
1190 : {
1191 3483 : if( pValues->Name.equals( sRedlineProtectionKey ) )
1192 : {
1193 50 : Sequence<sal_Int8> aKey;
1194 50 : pValues->Value >>= aKey;
1195 50 : GetTextImport()->SetChangesProtectionKey( aKey );
1196 : }
1197 : else
1198 : {
1199 : // HACK: Setting these out of order does not work.
1200 3433 : if( pValues->Name.equals( currentDatabaseDataSourceKey ))
1201 50 : currentDatabaseDataSource = pValues;
1202 3383 : else if( pValues->Name.equals( currentDatabaseCommandKey ))
1203 50 : currentDatabaseCommand = pValues;
1204 3333 : else if( pValues->Name.equals( currentDatabaseCommandTypeKey ))
1205 50 : currentDatabaseCommandType = pValues;
1206 : else
1207 3283 : xProps->setPropertyValue( pValues->Name,
1208 3283 : pValues->Value );
1209 : }
1210 : }
1211 :
1212 : // did we find any of the non-default cases?
1213 3483 : if ( pValues->Name == "PrinterIndependentLayout" )
1214 50 : bPrinterIndependentLayout = true;
1215 3433 : else if ( pValues->Name == "AddExternalLeading" )
1216 50 : bAddExternalLeading = true;
1217 3383 : else if ( pValues->Name == "AddParaSpacingToTableCells" )
1218 50 : bAddParaSpacingToTableCells = true;
1219 3333 : else if ( pValues->Name == "UseFormerLineSpacing" )
1220 50 : bUseFormerLineSpacing = true;
1221 3283 : else if ( pValues->Name == "UseFormerObjectPositioning" )
1222 50 : bUseFormerObjectPositioning = true;
1223 3233 : else if ( pValues->Name == "UseFormerTextWrapping" )
1224 50 : bUseFormerTextWrapping = true;
1225 3183 : else if ( pValues->Name == "UseOldNumbering" )
1226 50 : bUseOldNumbering = true;
1227 3133 : else if ( pValues->Name == "OutlineLevelYieldsNumbering" )
1228 50 : bOutlineLevelYieldsOutlineRule = true;
1229 3083 : else if ( pValues->Name == "ConsiderTextWrapOnObjPos" )
1230 50 : bConsiderWrapOnObjPos = true;
1231 3033 : else if ( pValues->Name == "IgnoreFirstLineIndentInNumbering" )
1232 50 : bIgnoreFirstLineIndentInNumbering = true;
1233 2983 : else if ( pValues->Name == "DoNotJustifyLinesWithManualBreak" )
1234 50 : bDoNotJustifyLinesWithManualBreak = true;
1235 2933 : else if ( pValues->Name == "DoNotResetParaAttrsForNumFont" )
1236 50 : bDoNotResetParaAttrsForNumFont = true;
1237 2883 : else if ( pValues->Name == "LoadReadonly" )
1238 50 : bLoadReadonly = true;
1239 2833 : else if ( pValues->Name == "DoNotCaptureDrawObjsOnPage" )
1240 50 : bDoNotCaptureDrawObjsOnPage = true;
1241 2783 : else if ( pValues->Name == "ClipAsCharacterAnchoredWriterFlyFrames" )
1242 50 : bClipAsCharacterAnchoredWriterFlyFrames = true;
1243 2733 : else if ( pValues->Name == "UnxForceZeroExtLeading" )
1244 50 : bUnixForceZeroExtLeading = true;
1245 2683 : else if ( pValues->Name == "UseOldPrinterMetrics" )
1246 50 : bUseOldPrinterMetrics = true;
1247 2633 : else if ( pValues->Name == "SmallCapsPercentage66" )
1248 36 : bSmallCapsPercentage66 = true;
1249 2597 : else if ( pValues->Name == "TabOverflow" )
1250 35 : bTabOverflow = true;
1251 2562 : else if ( pValues->Name == "UnbreakableNumberings" )
1252 35 : bUnbreakableNumberings = true;
1253 2527 : else if ( pValues->Name == "ClippedPictures" )
1254 24 : bClippedPictures = true;
1255 2503 : else if ( pValues->Name == "BackgroundParaOverDrawings" )
1256 24 : bBackgroundParaOverDrawings = true;
1257 2479 : else if ( pValues->Name == "TabOverMargin" )
1258 20 : bTabOverMargin = true;
1259 : }
1260 0 : catch( Exception& )
1261 : {
1262 : OSL_FAIL( "SwXMLImport::SetConfigurationSettings: Exception!" );
1263 : }
1264 : }
1265 3483 : pValues++;
1266 : }
1267 :
1268 : try
1269 : {
1270 51 : if( currentDatabaseDataSource != NULL )
1271 50 : xProps->setPropertyValue( currentDatabaseDataSource->Name, currentDatabaseDataSource->Value );
1272 51 : if( currentDatabaseCommand != NULL )
1273 50 : xProps->setPropertyValue( currentDatabaseCommand->Name, currentDatabaseCommand->Value );
1274 51 : if( currentDatabaseCommandType != NULL )
1275 50 : xProps->setPropertyValue( currentDatabaseCommandType->Name, currentDatabaseCommandType->Value );
1276 0 : } catch( Exception& )
1277 : {
1278 : OSL_FAIL( "SwXMLImport::SetConfigurationSettings: Exception!" );
1279 : }
1280 :
1281 : // finally, treat the non-default cases
1282 : // introduce boolean, that indicates a document, written by version prior SO8.
1283 51 : const bool bDocumentPriorSO8 = !bConsiderWrapOnObjPos;
1284 :
1285 51 : if( ! bPrinterIndependentLayout )
1286 : {
1287 1 : Any aAny;
1288 1 : sal_Int16 nTmp = document::PrinterIndependentLayout::DISABLED;
1289 1 : aAny <<= nTmp;
1290 1 : xProps->setPropertyValue(
1291 : OUString("PrinterIndependentLayout"),
1292 1 : aAny );
1293 : }
1294 :
1295 51 : if( ! bAddExternalLeading )
1296 : {
1297 1 : xProps->setPropertyValue(
1298 1 : OUString("AddExternalLeading"), makeAny( false ) );
1299 : }
1300 :
1301 51 : if( ! bUseFormerLineSpacing )
1302 : {
1303 1 : xProps->setPropertyValue(
1304 1 : OUString("UseFormerLineSpacing"), makeAny( true ) );
1305 : }
1306 :
1307 51 : if( !bUseFormerObjectPositioning )
1308 : {
1309 1 : xProps->setPropertyValue(
1310 1 : OUString("UseFormerObjectPositioning"), makeAny( true ) );
1311 : }
1312 :
1313 51 : if( !bUseOldNumbering )
1314 : {
1315 1 : Any aAny;
1316 1 : sal_Bool bOldNum = true;
1317 1 : aAny.setValue(&bOldNum, ::getBooleanCppuType());
1318 1 : xProps->setPropertyValue
1319 : (OUString("UseOldNumbering"),
1320 1 : aAny );
1321 : }
1322 :
1323 51 : if( !bOutlineLevelYieldsOutlineRule )
1324 : {
1325 1 : Any aAny;
1326 1 : sal_Bool bTmp = true;
1327 1 : aAny.setValue(&bTmp, ::getBooleanCppuType());
1328 1 : xProps->setPropertyValue
1329 : (OUString("OutlineLevelYieldsNumbering"),
1330 1 : aAny );
1331 : }
1332 :
1333 51 : if( !bAddParaSpacingToTableCells )
1334 : {
1335 1 : xProps->setPropertyValue(
1336 1 : OUString("AddParaSpacingToTableCells"), makeAny( false ) );
1337 : }
1338 :
1339 51 : if( !bUseFormerTextWrapping )
1340 : {
1341 1 : xProps->setPropertyValue(
1342 1 : OUString("UseFormerTextWrapping"), makeAny( true ) );
1343 : }
1344 :
1345 51 : if( !bConsiderWrapOnObjPos )
1346 : {
1347 1 : xProps->setPropertyValue(
1348 1 : OUString("ConsiderTextWrapOnObjPos"), makeAny( false ) );
1349 : }
1350 :
1351 : // #i47448#
1352 : // For SO7pp4, part of the 'new numbering' stuff has been backported from
1353 : // SO8. Unfortunately, only part of it and by using the same compatibility option
1354 : // like in SO8. Therefore documents generated with SO7pp4, containing
1355 : // numbered paragraphs with first line indent differ between SO7pp4 and
1356 : // SO8. In order to fix this for SO8pp1, I introduce a new compatiblity
1357 : // flag 'bIgnoreFirstLineIndentInNumbering'. This flag has to be set for all
1358 : // documents < SO8, but not for SO8. So if the property is not present, the
1359 : // flag will be set to 'true'. SO8 documents surely have the
1360 : // 'ConsiderWrapOnObjPos' property set (no matter if 'true' or 'false'),
1361 : // therefore the correct condition to set this flag is this:
1362 51 : if( !bIgnoreFirstLineIndentInNumbering && bDocumentPriorSO8 )
1363 : {
1364 1 : xProps->setPropertyValue(
1365 1 : OUString("IgnoreFirstLineIndentInNumbering"), makeAny( true ) );
1366 : }
1367 :
1368 : // This flag has to be set for all documents < SO8
1369 51 : if ( !bDoNotJustifyLinesWithManualBreak && bDocumentPriorSO8 )
1370 : {
1371 1 : xProps->setPropertyValue(
1372 1 : OUString("DoNotJustifyLinesWithManualBreak"), makeAny( true ) );
1373 : }
1374 :
1375 : // This flag has to be set for all documents < SO8
1376 51 : if ( !bDoNotResetParaAttrsForNumFont && bDocumentPriorSO8 )
1377 : {
1378 1 : xProps->setPropertyValue(
1379 1 : OUString("DoNotResetParaAttrsForNumFont"), makeAny( true ) );
1380 : }
1381 :
1382 51 : if ( !bLoadReadonly )
1383 : {
1384 1 : xProps->setPropertyValue(
1385 1 : OUString("LoadReadonly"), makeAny( false ) );
1386 : }
1387 :
1388 : // This flag has to be set for all documents < SO8
1389 51 : if ( !bDoNotCaptureDrawObjsOnPage && bDocumentPriorSO8 )
1390 : {
1391 1 : xProps->setPropertyValue(
1392 1 : OUString("DoNotCaptureDrawObjsOnPage"), makeAny( true ) );
1393 : }
1394 :
1395 : // This flag has to be set for all documents < SO8
1396 51 : if ( !bClipAsCharacterAnchoredWriterFlyFrames && bDocumentPriorSO8 )
1397 : {
1398 1 : xProps->setPropertyValue(
1399 1 : OUString("ClipAsCharacterAnchoredWriterFlyFrames"), makeAny( true ) );
1400 : }
1401 :
1402 51 : if ( !bUnixForceZeroExtLeading )
1403 : {
1404 1 : xProps->setPropertyValue(
1405 1 : OUString("UnxForceZeroExtLeading"), makeAny( true ) );
1406 : }
1407 :
1408 51 : if ( !bUseOldPrinterMetrics )
1409 : {
1410 1 : xProps->setPropertyValue(
1411 1 : OUString("UseOldPrinterMetrics"), makeAny( true ) );
1412 : }
1413 :
1414 : // Old LO versions had 66 as the value for small caps percentage, later changed to 80.
1415 : // In order to keep backwards compatibility, SmallCapsPercentage66 option is written to .odt
1416 : // files, and the default for new documents is 'false'. Files without this option
1417 : // are considered to be old files, so set the compatibility option too.
1418 51 : if ( !bSmallCapsPercentage66 )
1419 : {
1420 15 : xProps->setPropertyValue(
1421 15 : OUString("SmallCapsPercentage66"), makeAny( true ) );
1422 : }
1423 :
1424 51 : if ( !bTabOverflow )
1425 : {
1426 16 : xProps->setPropertyValue(
1427 16 : OUString("TabOverflow"), makeAny( false ) );
1428 : }
1429 :
1430 51 : if ( !bUnbreakableNumberings )
1431 : {
1432 16 : xProps->setPropertyValue(
1433 16 : OUString("UnbreakableNumberings"), makeAny( false ) );
1434 : }
1435 :
1436 51 : if ( !bClippedPictures )
1437 : {
1438 27 : xProps->setPropertyValue(
1439 27 : OUString("ClippedPictures"), makeAny( false ) );
1440 : }
1441 :
1442 51 : if ( !bBackgroundParaOverDrawings )
1443 27 : xProps->setPropertyValue("BackgroundParaOverDrawings", makeAny( false ) );
1444 :
1445 51 : if ( !bTabOverMargin )
1446 31 : xProps->setPropertyValue("TabOverMargin", makeAny( false ) );
1447 :
1448 51 : SwDoc *pDoc = getDoc();
1449 51 : SfxPrinter *pPrinter = pDoc->getPrinter( false );
1450 51 : if( pPrinter )
1451 : {
1452 : // If the printer is known, then the OLE objects will
1453 : // already have correct sizes, and we don't have to call
1454 : // PrtOLENotify again. Otherwise we have to call it.
1455 : // The flag might be set from setting the printer, so it
1456 : // it is required to clear it.
1457 5 : pDoc->SetOLEPrtNotifyPending( !pPrinter->IsKnown() );
1458 51 : }
1459 : }
1460 :
1461 :
1462 0 : void SwXMLImport::SetDocumentSpecificSettings(
1463 : const OUString& _rSettingsGroupName,
1464 : const Sequence< PropertyValue>& _rSettings )
1465 : {
1466 : // the only doc-specific settings group we know so far are the XForms settings
1467 0 : if ( !IsXMLToken( _rSettingsGroupName, XML_XFORM_MODEL_SETTINGS ) )
1468 0 : return;
1469 :
1470 : // preserve the settings for a later iteration - we are currently reading the settings.xml,
1471 : // the content.xml will be read later, by another instance of SwXMLImport
1472 : OSL_ENSURE( xLateInitSettings.is(), "SwXMLImport::SetDocumentSpecificSettings: no storage for those settings!" );
1473 0 : if ( !xLateInitSettings.is() )
1474 0 : return;
1475 :
1476 : try
1477 : {
1478 0 : if ( xLateInitSettings->hasByName( _rSettingsGroupName ) )
1479 : {
1480 0 : xLateInitSettings->replaceByName( _rSettingsGroupName, makeAny( _rSettings ) );
1481 : OSL_FAIL( "SwXMLImport::SetDocumentSpecificSettings: already have settings for this model!" );
1482 : }
1483 : else
1484 0 : xLateInitSettings->insertByName( _rSettingsGroupName, makeAny( _rSettings ) );
1485 : }
1486 0 : catch( const Exception& )
1487 : {
1488 : DBG_UNHANDLED_EXCEPTION();
1489 : }
1490 : }
1491 :
1492 213 : void SwXMLImport::initialize(
1493 : const Sequence<Any>& aArguments )
1494 : throw( uno::Exception, uno::RuntimeException)
1495 : {
1496 : // delegate to super class
1497 213 : SvXMLImport::initialize(aArguments);
1498 :
1499 : // we are only looking for a PropertyValue "PreserveRedlineMode"
1500 213 : sal_Int32 nLength = aArguments.getLength();
1501 1139 : for(sal_Int32 i = 0; i < nLength; i++)
1502 : {
1503 926 : beans::PropertyValue aValue;
1504 926 : if ( aArguments[i] >>= aValue )
1505 : {
1506 0 : if (aValue.Name.equalsAsciiL(
1507 0 : RTL_CONSTASCII_STRINGPARAM("PreserveRedlineMode")))
1508 : {
1509 0 : OSL_VERIFY( aValue.Value >>= bPreserveRedlineMode );
1510 : }
1511 0 : continue;
1512 : }
1513 :
1514 1852 : beans::NamedValue aNamedValue;
1515 926 : if ( aArguments[i] >>= aNamedValue )
1516 : {
1517 154 : if (aNamedValue.Name.equalsAsciiL(
1518 154 : RTL_CONSTASCII_STRINGPARAM("LateInitSettings")))
1519 : {
1520 154 : OSL_VERIFY( aNamedValue.Value >>= xLateInitSettings );
1521 : }
1522 : }
1523 926 : }
1524 213 : }
1525 :
1526 :
1527 : //
1528 : // UNO component registration helper functions
1529 : //
1530 :
1531 134 : OUString SAL_CALL SwXMLImport_getImplementationName() throw()
1532 : {
1533 : return OUString(
1534 134 : "com.sun.star.comp.Writer.XMLOasisImporter" );
1535 : }
1536 :
1537 1 : uno::Sequence< OUString > SAL_CALL SwXMLImport_getSupportedServiceNames()
1538 : throw()
1539 : {
1540 1 : const OUString aServiceName( SwXMLImport_getImplementationName() );
1541 1 : const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1542 1 : return aSeq;
1543 : }
1544 :
1545 3 : uno::Reference< uno::XInterface > SAL_CALL SwXMLImport_createInstance(
1546 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1547 : throw( uno::Exception )
1548 : {
1549 3 : return (cppu::OWeakObject*)new SwXMLImport( comphelper::getComponentContext(rSMgr), IMPORT_ALL );
1550 : }
1551 :
1552 159 : OUString SAL_CALL SwXMLImportStyles_getImplementationName() throw()
1553 : {
1554 : return OUString(
1555 159 : "com.sun.star.comp.Writer.XMLOasisStylesImporter" );
1556 : }
1557 :
1558 14 : uno::Sequence< OUString > SAL_CALL SwXMLImportStyles_getSupportedServiceNames()
1559 : throw()
1560 : {
1561 14 : const OUString aServiceName( SwXMLImportStyles_getImplementationName() );
1562 14 : const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1563 14 : return aSeq;
1564 : }
1565 :
1566 52 : uno::Reference< uno::XInterface > SAL_CALL SwXMLImportStyles_createInstance(
1567 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1568 : throw( uno::Exception )
1569 : {
1570 : return (cppu::OWeakObject*)new SwXMLImport(
1571 : comphelper::getComponentContext(rSMgr),
1572 : IMPORT_STYLES | IMPORT_MASTERSTYLES | IMPORT_AUTOSTYLES |
1573 52 : IMPORT_FONTDECLS );
1574 : }
1575 :
1576 145 : OUString SAL_CALL SwXMLImportContent_getImplementationName() throw()
1577 : {
1578 : return OUString(
1579 145 : "com.sun.star.comp.Writer.XMLOasisContentImporter" );
1580 : }
1581 :
1582 14 : uno::Sequence< OUString > SAL_CALL SwXMLImportContent_getSupportedServiceNames()
1583 : throw()
1584 : {
1585 14 : const OUString aServiceName( SwXMLImportContent_getImplementationName() );
1586 14 : const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1587 14 : return aSeq;
1588 : }
1589 :
1590 51 : uno::Reference< uno::XInterface > SAL_CALL SwXMLImportContent_createInstance(
1591 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1592 : throw( uno::Exception )
1593 : {
1594 : return (cppu::OWeakObject*)new SwXMLImport(
1595 : comphelper::getComponentContext(rSMgr),
1596 : IMPORT_AUTOSTYLES | IMPORT_CONTENT | IMPORT_SCRIPTS |
1597 51 : IMPORT_FONTDECLS );
1598 : }
1599 :
1600 133 : OUString SAL_CALL SwXMLImportMeta_getImplementationName() throw()
1601 : {
1602 : return OUString(
1603 133 : "com.sun.star.comp.Writer.XMLOasisMetaImporter" );
1604 : }
1605 :
1606 15 : uno::Sequence< OUString > SAL_CALL SwXMLImportMeta_getSupportedServiceNames()
1607 : throw()
1608 : {
1609 15 : const OUString aServiceName( SwXMLImportMeta_getImplementationName() );
1610 15 : const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1611 15 : return aSeq;
1612 : }
1613 :
1614 54 : uno::Reference< uno::XInterface > SAL_CALL SwXMLImportMeta_createInstance(
1615 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1616 : throw( uno::Exception )
1617 : {
1618 54 : return (cppu::OWeakObject*)new SwXMLImport( comphelper::getComponentContext(rSMgr), IMPORT_META );
1619 : }
1620 :
1621 118 : OUString SAL_CALL SwXMLImportSettings_getImplementationName() throw()
1622 : {
1623 : return OUString(
1624 118 : "com.sun.star.comp.Writer.XMLOasisSettingsImporter" );
1625 : }
1626 :
1627 15 : uno::Sequence< OUString > SAL_CALL SwXMLImportSettings_getSupportedServiceNames()
1628 : throw()
1629 : {
1630 15 : const OUString aServiceName( SwXMLImportSettings_getImplementationName() );
1631 15 : const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
1632 15 : return aSeq;
1633 : }
1634 :
1635 53 : uno::Reference< uno::XInterface > SAL_CALL SwXMLImportSettings_createInstance(
1636 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
1637 : throw( uno::Exception )
1638 : {
1639 53 : return (cppu::OWeakObject*)new SwXMLImport( comphelper::getComponentContext(rSMgr), IMPORT_SETTINGS );
1640 : }
1641 :
1642 :
1643 : // XServiceInfo
1644 : // override empty method from parent class
1645 0 : OUString SAL_CALL SwXMLImport::getImplementationName()
1646 : throw(RuntimeException)
1647 : {
1648 0 : switch( getImportFlags() )
1649 : {
1650 : case IMPORT_ALL:
1651 0 : return SwXMLImport_getImplementationName();
1652 : case (IMPORT_STYLES|IMPORT_MASTERSTYLES|IMPORT_AUTOSTYLES|IMPORT_FONTDECLS):
1653 0 : return SwXMLImportStyles_getImplementationName();
1654 : case (IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS):
1655 0 : return SwXMLImportContent_getImplementationName();
1656 : case IMPORT_META:
1657 0 : return SwXMLImportMeta_getImplementationName();
1658 : case IMPORT_SETTINGS:
1659 0 : return SwXMLImportSettings_getImplementationName();
1660 : default:
1661 : // generic name for 'unknown' cases
1662 : return OUString(
1663 0 : "com.sun.star.comp.Writer.SwXMLImport" );
1664 : }
1665 : }
1666 :
1667 240 : SwDoc* SwImport::GetDocFromXMLImport( SvXMLImport& rImport )
1668 : {
1669 240 : uno::Reference<lang::XUnoTunnel> xModelTunnel( rImport.GetModel(), uno::UNO_QUERY );
1670 : SwXTextDocument *pTxtDoc = reinterpret_cast< SwXTextDocument *>(
1671 240 : sal::static_int_cast< sal_IntPtr >( xModelTunnel->getSomething(SwXTextDocument::getUnoTunnelId() )));
1672 : OSL_ENSURE( pTxtDoc, "Where is my model?" );
1673 : OSL_ENSURE( pTxtDoc->GetDocShell(), "Where is my shell?" );
1674 240 : SwDoc* pDoc = pTxtDoc->GetDocShell()->GetDoc();
1675 : OSL_ENSURE( pDoc, "Where is my document?" );
1676 240 : return pDoc;
1677 : }
1678 :
1679 :
1680 0 : void SwXMLImport::initXForms()
1681 : {
1682 : // obtain SwDoc
1683 0 : Reference<XUnoTunnel> xDocTunnel( GetModel(), UNO_QUERY );
1684 0 : if( ! xDocTunnel.is() )
1685 0 : return;
1686 : SwXTextDocument* pXTextDocument = reinterpret_cast<SwXTextDocument*>(
1687 0 : xDocTunnel->getSomething( SwXTextDocument::getUnoTunnelId() ) );
1688 0 : if( pXTextDocument == NULL )
1689 0 : return;
1690 :
1691 0 : SwDoc *pDoc = pXTextDocument->GetDocShell()->GetDoc();
1692 :
1693 : // init XForms (if not already done)
1694 : // (no default model, since we'll load the models)
1695 0 : if( ! pDoc->isXForms() )
1696 0 : pDoc->initXForms( false );
1697 :
1698 0 : bInititedXForms = true;
1699 : }
1700 :
1701 101 : SwDoc* SwXMLImport::getDoc()
1702 : {
1703 101 : if( doc != NULL )
1704 50 : return doc;
1705 51 : Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
1706 102 : Reference < XText > xText = xTextDoc->getText();
1707 102 : Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
1708 : assert( xTextTunnel.is());
1709 : SwXText *pText = reinterpret_cast< SwXText *>(
1710 51 : sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
1711 : assert( pText != NULL );
1712 51 : doc = pText->GetDoc();
1713 : assert( doc != NULL );
1714 102 : return doc;
1715 : }
1716 :
1717 0 : const SwDoc* SwXMLImport::getDoc() const
1718 : {
1719 0 : return const_cast< SwXMLImport* >( this )->getDoc();
1720 99 : }
1721 :
1722 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|