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