LibreOffice Module sw (master) 1
xmlimp.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21#include <sal/log.hxx>
22
23#include <cassert>
24
25#include <com/sun/star/document/PrinterIndependentLayout.hpp>
26#include <com/sun/star/drawing/XDrawPage.hpp>
27#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
28#include <com/sun/star/text/XTextDocument.hpp>
29#include <com/sun/star/text/XTextRange.hpp>
30
31#include <o3tl/any.hxx>
33#include <xmloff/xmlictxt.hxx>
34#include <xmloff/txtimp.hxx>
38#include <doc.hxx>
39#include <drawdoc.hxx>
45#include <TextCursorHelper.hxx>
46#include <unotext.hxx>
47#include <unotextrange.hxx>
48#include <poolfmt.hxx>
49#include <ndtxt.hxx>
50#include <editsh.hxx>
51#include <strings.hrc>
52#include <svl/stritem.hxx>
53#include "xmlimp.hxx"
54#include "xmlimpit.hxx"
55#include "xmltexti.hxx"
56#include <list.hxx>
57#include <swdll.hxx>
59#include <docsh.hxx>
60#include <svx/xmlgrhlp.hxx>
61#include <svx/xmleohlp.hxx>
62#include <sfx2/printer.hxx>
63#include <xmloff/xmluconv.hxx>
66#include <tools/diagnose_ex.h>
67
68#include <vcl/svapp.hxx>
69#include <unotxdoc.hxx>
70#include <numrule.hxx>
71
72#include <xmloff/xmlmetai.hxx>
77#include <officecfg/Office/Common.hxx>
78
79#include <unordered_set>
80
81using namespace ::com::sun::star;
82using namespace ::com::sun::star::uno;
83using namespace ::com::sun::star::text;
84using namespace ::com::sun::star::lang;
85using namespace ::com::sun::star::beans;
86using namespace ::com::sun::star::container;
87using namespace ::com::sun::star::i18n;
88using namespace ::com::sun::star::drawing;
89using namespace ::com::sun::star::xforms;
90using namespace ::xmloff::token;
91using namespace ::std;
92
93namespace {
94
95class SwXMLBodyContext_Impl : public SvXMLImportContext
96{
97 SwXMLImport& GetSwImport() { return static_cast<SwXMLImport&>(GetImport()); }
98
99public:
100
101 SwXMLBodyContext_Impl( SwXMLImport& rImport );
102
103 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
104 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
105};
106
107}
108
109SwXMLBodyContext_Impl::SwXMLBodyContext_Impl( SwXMLImport& rImport ) :
110 SvXMLImportContext( rImport )
111{
112 // tdf#107211: if at this point we don't have a defined char style "Default"
113 // or "Default Style", add a mapping for it as it is not written
114 // into the file since it's not really a style but "no style"
115 // (hence referencing it actually makes no sense except for hyperlinks
116 // which default to something other than "Default")
117 OUString const sDefault(SwResId(STR_POOLCHR_STANDARD));
118 uno::Reference<container::XNameContainer> const& xStyles(
119 rImport.GetTextImport()->GetTextStyles());
120 if (!xStyles->hasByName("Default"))
121 { // this old name was used before LO 4.0
122 rImport.AddStyleDisplayName(XmlStyleFamily::TEXT_TEXT, "Default", sDefault);
123 }
124 if (!xStyles->hasByName("Default_20_Style"))
125 { // this new name contains a space which is converted to _20_ on export
126 rImport.AddStyleDisplayName(XmlStyleFamily::TEXT_TEXT, "Default_20_Style", sDefault);
127 }
128 bool isEncoded(false);
129 OUString const defaultEncoded(
130 rImport.GetMM100UnitConverter().encodeStyleName(sDefault, &isEncoded));
131 if (isEncoded && defaultEncoded != "Default_20_Style"
132 && !xStyles->hasByName(defaultEncoded))
133 { // new name may contain a space which is converted to _20_ on export
134 rImport.AddStyleDisplayName(XmlStyleFamily::TEXT_TEXT, defaultEncoded, sDefault);
135 }
136}
137
138css::uno::Reference< css::xml::sax::XFastContextHandler > SwXMLBodyContext_Impl::createFastChildContext(
139 sal_Int32 /*nElement*/,
140 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ )
141{
142 return GetSwImport().CreateBodyContentContext();
143}
144
145namespace {
146
147// #i69629#
148// enhance class <SwXMLDocContext_Impl> in order to be able to create subclasses
149// NB: virtually inherit so we can multiply inherit properly
150// in SwXMLOfficeDocContext_Impl
151class SwXMLDocContext_Impl : public virtual SvXMLImportContext
152{
153 sal_Int32 mnElement;
154
155protected: // #i69629#
156 SwXMLImport& GetSwImport() { return static_cast<SwXMLImport&>(GetImport()); }
157
158public:
159 SwXMLDocContext_Impl( SwXMLImport& rImport, sal_Int32 nElement );
160
161 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
162 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
163};
164
165}
166
167SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport, sal_Int32 nElement ) :
168 SvXMLImportContext( rImport ), mnElement(nElement)
169{
170}
171
172uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLDocContext_Impl::createFastChildContext(
173 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
174{
175 switch (nElement)
176 {
177 case XML_ELEMENT(OFFICE, XML_SCRIPTS):
178 return GetSwImport().CreateScriptContext();
179 case XML_ELEMENT(OFFICE, XML_SETTINGS):
180 return new XMLDocumentSettingsContext( GetImport() );
181 case XML_ELEMENT(OFFICE, XML_STYLES):
182 GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
183 return GetSwImport().CreateStylesContext( false );
184 case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES):
185 // don't use the autostyles from the styles-document for the progress
186 if ( mnElement != 0 && (mnElement & TOKEN_MASK) != XML_DOCUMENT_STYLES )
187 GetSwImport().GetProgressBarHelper()->Increment
189 return GetSwImport().CreateStylesContext( true );
190 case XML_ELEMENT(OFFICE, XML_MASTER_STYLES):
191 return GetSwImport().CreateMasterStylesContext();
192 case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS):
193 return GetSwImport().CreateFontDeclsContext();
194 case XML_ELEMENT(OFFICE, XML_META):
195 OSL_FAIL(" XML_ELEMENT(OFFICE, XML_META): should not have come here, maybe document is invalid?");
196 break;
197 case XML_ELEMENT(OFFICE, XML_BODY):
198 GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
199 return new SwXMLBodyContext_Impl( GetSwImport() );
200 case XML_ELEMENT(XFORMS, XML_MODEL):
201 return createXFormsModelContext(GetImport());
202 default:
203 XMLOFF_WARN_UNKNOWN_ELEMENT("sw", nElement);
204 }
205 return nullptr;
206}
207
208namespace {
209
210// #i69629# - new subclass <SwXMLOfficeDocContext_Impl> of class <SwXMLDocContext_Impl>
211class SwXMLOfficeDocContext_Impl :
212 public SwXMLDocContext_Impl, public SvXMLMetaDocumentContext
213{
214public:
215
216 SwXMLOfficeDocContext_Impl( SwXMLImport& rImport, sal_Int32 nElement,
217 const Reference< document::XDocumentProperties >& xDocProps);
218
219 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
220 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
221};
222
223}
224
225SwXMLOfficeDocContext_Impl::SwXMLOfficeDocContext_Impl(
226 SwXMLImport& rImport,
227 sal_Int32 nElement,
228 const Reference< document::XDocumentProperties >& xDocProps) :
229 SvXMLImportContext( rImport ),
230 SwXMLDocContext_Impl( rImport, nElement ),
231 SvXMLMetaDocumentContext( rImport, xDocProps )
232{
233}
234
235uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLOfficeDocContext_Impl::createFastChildContext(
236 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
237{
238 // assign paragraph styles to list levels of outline style after all styles
239 // are imported and finished. This is the case, when <office:body> starts
240 // in flat OpenDocument file format.
241 {
242 if( nElement == XML_ELEMENT( OFFICE, XML_BODY ) )
243 {
244 GetImport().GetTextImport()->SetOutlineStyles( true );
245 }
246 }
247
248 // behave like meta base class iff we encounter office:meta
249 if ( nElement == XML_ELEMENT( OFFICE, XML_META ) ) {
251 nElement, xAttrList );
252 } else {
253 return SwXMLDocContext_Impl::createFastChildContext(
254 nElement, xAttrList );
255 }
256}
257
258namespace {
259
260// #i69629# - new subclass <SwXMLDocStylesContext_Impl> of class <SwXMLDocContext_Impl>
261class SwXMLDocStylesContext_Impl : public SwXMLDocContext_Impl
262{
263public:
264
265 SwXMLDocStylesContext_Impl( SwXMLImport& rImport, sal_Int32 nElement );
266
267 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
268};
269
270}
271
272SwXMLDocStylesContext_Impl::SwXMLDocStylesContext_Impl( SwXMLImport& rImport, sal_Int32 nElement ) :
273 SvXMLImportContext( rImport ),
274 SwXMLDocContext_Impl( rImport, nElement )
275{
276}
277
278void SwXMLDocStylesContext_Impl::endFastElement(sal_Int32 )
279{
280 // assign paragraph styles to list levels of outline style after all styles
281 // are imported and finished.
282 SwXMLImport& rSwImport = dynamic_cast<SwXMLImport&>( GetImport());
283 GetImport().GetTextImport()->SetOutlineStyles(
284 bool(rSwImport.GetStyleFamilyMask() & SfxStyleFamily::Para));
285}
286
288 const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
289{
290 SvXMLImportContext *pContext = nullptr;
291
292 switch (nElement)
293 {
295 pContext = CreateMetaContext(nElement);
296 break;
298 {
299 uno::Reference<document::XDocumentProperties> const xDocProps(
301 // flat OpenDocument file format
302 pContext = new SwXMLOfficeDocContext_Impl( *this, nElement, xDocProps );
303 }
304 break;
305 // #i69629# - own subclasses for <office:document> and <office:document-styles>
308 pContext = new SwXMLDocContext_Impl( *this, nElement );
309 break;
311 pContext = new SwXMLDocStylesContext_Impl( *this, nElement );
312 break;
313 }
314 return pContext;
315}
316
318 const uno::Reference< uno::XComponentContext >& rContext,
319 OUString const & implementationName, SvXMLImportFlags nImportFlags)
320: SvXMLImport( rContext, implementationName, nImportFlags ),
321 m_nStyleFamilyMask( SfxStyleFamily::All ),
322 m_bLoadDoc( true ),
323 m_bInsert( false ),
324 m_bBlock( false ),
325 m_bOrganizerMode( false ),
326 m_bInititedXForms( false ),
327 m_pDoc( nullptr )
328{
330}
331
333{
334 if (HasShapeImport())
335 {
336 SAL_WARN("sw", "endDocument skipped, dropping shapes now to avoid dangling SvTextShapeImportHelper pointing to this");
338 }
340}
341
343 const Reference< XTextRange > & rInsertPos )
344{
345 m_bInsert = true;
346
347 Reference < XText > xText = rInsertPos->getText();
348 Reference < XTextCursor > xTextCursor =
349 xText->createTextCursorByRange( rInsertPos );
350 GetTextImport()->SetCursor( xTextCursor );
351}
352
354 bool bOverwrite )
355{
356 m_bInsert = !bOverwrite;
357 m_nStyleFamilyMask = nFamilies;
358 m_bLoadDoc = false;
359}
360
361const Sequence< sal_Int8 > & SwXMLImport::getUnoTunnelId() noexcept
362{
363 static const comphelper::UnoIdInit theSwXMLImportUnoTunnelId;
364 return theSwXMLImportUnoTunnelId.getSeq();
365}
366
367sal_Int64 SAL_CALL SwXMLImport::getSomething( const Sequence< sal_Int8 >& rId )
368{
369 return comphelper::getSomethingImpl(rId, this,
371}
372
373static OTextCursorHelper *lcl_xml_GetSwXTextCursor( const Reference < XTextCursor >& rTextCursor )
374{
375 OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(rTextCursor);
376 OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
377 return pTextCursor;
378}
379
381{
382 // delegate to parent
384
385 OSL_ENSURE( GetModel().is(), "model is missing" );
386 if( !GetModel().is() )
387 return;
388
389 // this method will modify the document directly -> lock SolarMutex
390 SolarMutexGuard aGuard;
391
392 Reference< XPropertySet > xImportInfo( getImportInfo() );
393 Reference< XPropertySetInfo > xPropertySetInfo;
394 if( xImportInfo.is() )
395 xPropertySetInfo = xImportInfo->getPropertySetInfo();
396 if( xPropertySetInfo.is() )
397 {
398 Any aAny;
399 // insert style mode?
400 OUString sStyleInsertModeFamilies("StyleInsertModeFamilies");
401 if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeFamilies) )
402 {
403 aAny = xImportInfo->getPropertyValue(sStyleInsertModeFamilies);
404 Sequence< OUString> aFamiliesSeq;
405 if( aAny >>= aFamiliesSeq )
406 {
407 SfxStyleFamily nFamilyMask = SfxStyleFamily::None;
408 for( const OUString& rFamily : std::as_const(aFamiliesSeq) )
409 {
410 if( rFamily=="FrameStyles" )
411 nFamilyMask |= SfxStyleFamily::Frame;
412 else if( rFamily=="PageStyles" )
413 nFamilyMask |= SfxStyleFamily::Page;
414 else if( rFamily=="CharacterStyles" )
415 nFamilyMask |= SfxStyleFamily::Char;
416 else if( rFamily=="ParagraphStyles" )
417 nFamilyMask |= SfxStyleFamily::Para;
418 else if( rFamily=="NumberingStyles" )
419 nFamilyMask |= SfxStyleFamily::Pseudo;
420 }
421
422 bool bOverwrite = false;
423 static const OUStringLiteral sStyleInsertModeOverwrite(u"StyleInsertModeOverwrite");
424 if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeOverwrite) )
425 {
426 aAny = xImportInfo->getPropertyValue(sStyleInsertModeOverwrite);
427 if( auto b = o3tl::tryAccess<bool>(aAny) )
428 {
429 if( *b )
430 bOverwrite = true;
431 }
432 }
433
434 setStyleInsertMode( nFamilyMask, bOverwrite );
435 }
436 }
437
438 // text insert mode?
439 static const OUStringLiteral sTextInsertModeRange(u"TextInsertModeRange");
440 if( xPropertySetInfo->hasPropertyByName(sTextInsertModeRange) )
441 {
442 aAny = xImportInfo->getPropertyValue(sTextInsertModeRange);
443 Reference<XTextRange> xInsertTextRange;
444 if( aAny >>= xInsertTextRange )
445 setTextInsertMode( xInsertTextRange );
446 }
447
448 // auto text mode
449 static const OUStringLiteral sAutoTextMode(u"AutoTextMode");
450 if( xPropertySetInfo->hasPropertyByName(sAutoTextMode) )
451 {
452 aAny = xImportInfo->getPropertyValue(sAutoTextMode);
453 if( auto b = o3tl::tryAccess<bool>(aAny) )
454 {
455 if( *b )
456 m_bBlock = true;
457 }
458 }
459
460 // organizer mode
461 static const OUStringLiteral sOrganizerMode(u"OrganizerMode");
462 if( xPropertySetInfo->hasPropertyByName(sOrganizerMode) )
463 {
464 aAny = xImportInfo->getPropertyValue(sOrganizerMode);
465 if( auto b = o3tl::tryAccess<bool>(aAny) )
466 {
467 if( *b )
468 m_bOrganizerMode = true;
469 }
470 }
471
472 // default document properties
473 static const OUStringLiteral sDefSettings(u"DefaultDocumentSettings");
474 if (xPropertySetInfo->hasPropertyByName(sDefSettings))
475 {
476 aAny = xImportInfo->getPropertyValue(sDefSettings);
477 Sequence<PropertyValue> aProps;
478 if (aAny >>= aProps)
479 {
480 Reference<lang::XMultiServiceFactory> xFac(GetModel(), UNO_QUERY);
481 Reference<XPropertySet> xProps(
482 xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY);
483 Reference<XPropertySetInfo> xInfo(xProps->getPropertySetInfo());
484
485 if (xProps.is() && xInfo.is())
486 {
487 for (const auto& rProp : std::as_const(aProps))
488 {
489 if (xInfo->hasPropertyByName(rProp.Name))
490 {
491 xProps->setPropertyValue(rProp.Name, rProp.Value);
492 }
493 }
494 }
495 }
496 }
497 }
498
499 // There only is a text cursor by now if we are in insert mode. In any
500 // other case we have to create one at the start of the document.
501 // We also might change into the insert mode later, so we have to make
502 // sure to first set the insert mode and then create the text import
503 // helper. Otherwise it won't have the insert flag set!
504 OTextCursorHelper *pTextCursor = nullptr;
505 Reference < XTextCursor > xTextCursor;
506 if( HasTextImport() )
507 xTextCursor = GetTextImport()->GetCursor();
508 if( !xTextCursor.is() )
509 {
510 Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
511 Reference < XText > xText = xTextDoc->getText();
512 xTextCursor = xText->createTextCursor();
513 SwCursorShell *pCursorSh = nullptr;
514 SwDoc *pDoc = nullptr;
515 if( SvXMLImportFlags::ALL == getImportFlags() )
516 {
517 pTextCursor = lcl_xml_GetSwXTextCursor( xTextCursor );
518 OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
519 if( !pTextCursor )
520 return;
521
522 pDoc = pTextCursor->GetDoc();
523 OSL_ENSURE( pDoc, "SwDoc missing" );
524 if( !pDoc )
525 return;
526
527 // Is there an edit shell. If yes, then we are currently inserting
528 // a document. We then have to insert at the current edit shell's
529 // cursor position. That not quite clean code, but there is no other
530 // way currently.
531 pCursorSh = pDoc->GetEditShell();
532 }
533 if( pCursorSh )
534 {
535 const uno::Reference<text::XTextRange> xInsertTextRange(
537 *pDoc, *pCursorSh->GetCursor()->GetPoint(), nullptr ) );
538 setTextInsertMode( xInsertTextRange );
539 xTextCursor = GetTextImport()->GetCursor();
540 pTextCursor = nullptr;
541 }
542 else
543 GetTextImport()->SetCursor( xTextCursor );
544 }
545
546 if( !(getImportFlags() & (SvXMLImportFlags::CONTENT|SvXMLImportFlags::MASTERSTYLES)) )
547 return;
548
549 if( !pTextCursor )
550 pTextCursor = lcl_xml_GetSwXTextCursor( xTextCursor );
551 OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
552 if( !pTextCursor )
553 return;
554
555 SwDoc *pDoc = pTextCursor->GetDoc();
556 OSL_ENSURE( pDoc, "SwDoc missing" );
557 if( !pDoc )
558 return;
559
560 if (SvXMLImportFlags::ALL == getImportFlags())
561 {
562 // for flat ODF - this is done in SwReader::Read() for package ODF
563 pDoc->SetInReading(true);
564 pDoc->SetInXMLImport(true);
565 }
566
567 if( (getImportFlags() & SvXMLImportFlags::CONTENT) && !IsStylesOnlyMode() )
568 {
569 m_pSttNdIdx.reset(new SwNodeIndex( pDoc->GetNodes() ));
570 if( IsInsertMode() )
571 {
572 SwPaM *pPaM = pTextCursor->GetPaM();
573 const SwPosition* pPos = pPaM->GetPoint();
574
575 // Split once and remember the node that has been split.
576 pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
577 *m_pSttNdIdx = pPos->nNode.GetIndex()-1;
578
579 // Split again.
580 pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
581
582 // Insert all content into the new node
583 pPaM->Move( fnMoveBackward );
586 }
587 }
588
589 // We need a draw model to be able to set the z order
590 pDoc->getIDocumentDrawModelAccess().GetOrCreateDrawModel(); // #i52858# - method name changed
591
592 // SJ: #i49801# locking the model to disable repaints
594 if ( pDrawModel )
595 pDrawModel->setLock(true);
596
597 if (!GetGraphicStorageHandler().is())
598 {
599 m_xGraphicStorageHandler = SvXMLGraphicHelper::Create(SvXMLGraphicHelperMode::Read);
601 }
602
603 if( !GetEmbeddedResolver().is() )
604 {
605 SfxObjectShell *pPersist = pDoc->GetPersist();
606 if( pPersist )
607 {
609 *pPersist,
610 SvXMLEmbeddedObjectHelperMode::Read );
612 }
613 }
614}
615
617{
618 OSL_ENSURE( GetModel().is(), "model missing; maybe startDocument wasn't called?" );
619 if( !GetModel().is() )
620 return;
621
622 // this method will modify the document directly -> lock SolarMutex
623 SolarMutexGuard aGuard;
624
626 m_xGraphicStorageHandler->dispose();
628
630 m_xEmbeddedResolver->dispose();
631 m_xEmbeddedResolver.clear();
632 // Clear the shape import to sort the shapes (and not in the
633 // destructor that might be called after the import has finished
634 // for Java filters.
635 if( HasShapeImport() )
637
638 SwDoc *pDoc = nullptr;
639 if( (getImportFlags() & SvXMLImportFlags::CONTENT) && !IsStylesOnlyMode() )
640 {
641 Reference<XUnoTunnel> xCursorTunnel( GetTextImport()->GetCursor(),
642 UNO_QUERY);
643 assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor");
644 OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel);
645 assert(pTextCursor && "SwXTextCursor missing");
646 SwPaM *pPaM = pTextCursor->GetPaM();
647 if( IsInsertMode() && m_pSttNdIdx->GetIndex() )
648 {
649 // If we are in insert mode, join the split node that is in front
650 // of the new content with the first new node. Or in other words:
651 // Revert the first split node.
652 SwTextNode* pTextNode = m_pSttNdIdx->GetNode().GetTextNode();
653 SwNodeIndex aNxtIdx( *m_pSttNdIdx );
654 if( pTextNode && pTextNode->CanJoinNext( &aNxtIdx ) &&
655 m_pSttNdIdx->GetIndex() + 1 == aNxtIdx.GetIndex() )
656 {
657 // If the PaM points to the first new node, move the PaM to the
658 // end of the previous node.
659 if( pPaM->GetPoint()->nNode == aNxtIdx )
660 {
661 pPaM->GetPoint()->nNode = *m_pSttNdIdx;
662 pPaM->GetPoint()->nContent.Assign( pTextNode,
663 pTextNode->GetText().getLength());
664 }
665
666#if OSL_DEBUG_LEVEL > 0
667 // !!! This should be impossible !!!!
668 OSL_ENSURE( m_pSttNdIdx->GetIndex()+1 !=
669 pPaM->GetBound().nNode.GetIndex(),
670 "PaM.Bound1 point to new node " );
671 OSL_ENSURE( m_pSttNdIdx->GetIndex()+1 !=
672 pPaM->GetBound( false ).nNode.GetIndex(),
673 "PaM.Bound2 points to new node" );
674
675 if( m_pSttNdIdx->GetIndex()+1 ==
676 pPaM->GetBound().nNode.GetIndex() )
677 {
678 const sal_Int32 nCntPos =
679 pPaM->GetBound().nContent.GetIndex();
680 pPaM->GetBound().nContent.Assign( pTextNode,
681 pTextNode->GetText().getLength() + nCntPos );
682 }
683 if( m_pSttNdIdx->GetIndex()+1 ==
684 pPaM->GetBound( false ).nNode.GetIndex() )
685 {
686 const sal_Int32 nCntPos =
687 pPaM->GetBound( false ).nContent.GetIndex();
688 pPaM->GetBound( false ).nContent.Assign( pTextNode,
689 pTextNode->GetText().getLength() + nCntPos );
690 }
691#endif
692 // If the first new node isn't empty, convert the node's text
693 // attributes into hints. Otherwise, set the new node's
694 // paragraph style at the previous (empty) node.
695 SwTextNode* pDelNd = aNxtIdx.GetNode().GetTextNode();
696 if (!pTextNode->GetText().isEmpty())
697 pDelNd->FormatToTextAttr( pTextNode );
698 else
699 {
701 pTextNode->ChgFormatColl( pDelNd->GetTextColl() );
702 if (!pDelNd->GetNoCondAttr(RES_PARATR_LIST_ID, /*bInParents=*/false))
703 {
704 // MergeListsAtDocumentInsertPosition() will deal with lists below, copy
705 // paragraph direct formatting otherwise.
706 pDelNd->CopyCollFormat(*pTextNode);
707 }
708 }
709 pTextNode->JoinNext();
710 }
711 }
712
713 SwPosition* pPos = pPaM->GetPoint();
714 OSL_ENSURE( !pPos->nContent.GetIndex(), "last paragraph isn't empty" );
715 if( !pPos->nContent.GetIndex() )
716 {
717 SwTextNode* pCurrNd;
718 SwNodeOffset nNodeIdx = pPos->nNode.GetIndex();
719 pDoc = &pPaM->GetDoc();
720
721 OSL_ENSURE( pPos->nNode.GetNode().IsContentNode(),
722 "insert position is not a content node" );
723 if( !IsInsertMode() )
724 {
725 // If we're not in insert mode, the last node is deleted.
726 const SwNode *pPrev = pDoc->GetNodes()[nNodeIdx -1];
727 if( pPrev->IsContentNode() ||
728 ( pPrev->IsEndNode() &&
729 pPrev->StartOfSectionNode()->IsSectionNode() ) )
730 {
731 SwContentNode* pCNd = pPaM->GetContentNode();
732 if( pCNd && pCNd->StartOfSectionIndex()+2 <
733 pCNd->EndOfSectionIndex() )
734 {
735 pPaM->GetBound().nContent.Assign( nullptr, 0 );
736 pPaM->GetBound(false).nContent.Assign( nullptr, 0 );
737 pDoc->GetNodes().Delete( pPaM->GetPoint()->nNode );
738 }
739 }
740 }
741 else if( nullptr != (pCurrNd = pDoc->GetNodes()[nNodeIdx]->GetTextNode()) )
742 {
743 // Id we're in insert mode, the empty node is joined with
744 // the next and the previous one.
745 if( pCurrNd->CanJoinNext( &pPos->nNode ))
746 {
747 SwTextNode* pNextNd = pPos->nNode.GetNode().GetTextNode();
748 bool endNodeFound = pDoc->GetNodes()[nNodeIdx-1]->IsEndNode();
749 SwNode *pLastPar = pDoc->GetNodes()[nNodeIdx -2];
750 if ( !pLastPar->IsTextNode() ) {
751 pLastPar = pDoc->GetNodes()[nNodeIdx -1];
752 }
753 if ( !endNodeFound && pLastPar->IsTextNode() )
754 {
755 pNextNd->ChgFormatColl(pLastPar->GetTextNode()->GetTextColl());
756 }
757
758 pPos->nContent.Assign( pNextNd, 0 );
759 pPaM->SetMark(); pPaM->DeleteMark();
760 pNextNd->JoinPrev();
761
762 // Remove line break that has been inserted by the import,
763 // but only if one has been inserted and
764 // no endNode found to avoid removing section
765 if( pNextNd->CanJoinPrev(/* &pPos->nNode*/ ) && !endNodeFound &&
766 *m_pSttNdIdx != pPos->nNode )
767 {
768 pNextNd->JoinPrev();
769 }
770 }
771 else if (pCurrNd->GetText().isEmpty())
772 {
773 pPos->nContent.Assign( nullptr, 0 );
774 pPaM->SetMark(); pPaM->DeleteMark();
775 pDoc->GetNodes().Delete( pPos->nNode );
776 pPaM->Move( fnMoveBackward );
777 }
778 }
779
780 // tdf#113877
781 // when we insert one document with list inside into another one with list at the insert position,
782 // the resulting numbering in these lists is not consequent.
783 //
784 // Main document:
785 // 1. One
786 // 2. Two
787 // 3. Three
788 // 4. <-- insert position
789 //
790 // Inserted document:
791 // 1. One
792 // 2. Two
793 // 3. Three
794 // 4.
795 //
796 // Expected result
797 // 1. One
798 // 2. Two
799 // 3. Three
800 // 4. One
801 // 5. Two
802 // 6. Three
803 // 7.
804 //
806 }
807 }
808
809 /* Was called too early. Moved from SwXMLBodyContext_Impl::EndElement */
810
811 GetTextImport()->RedlineAdjustStartNodeCursor();
812
813 if( (getImportFlags() & SvXMLImportFlags::CONTENT) ||
814 ((getImportFlags() & SvXMLImportFlags::MASTERSTYLES) && IsStylesOnlyMode()) )
815 {
816 // pDoc might be 0. In this case UpdateTextCollCondition is looking
817 // for it itself.
819 }
820
821 GetTextImport()->ResetCursor();
822
823 m_pSttNdIdx.reset();
824
825 // SJ: #i49801# -> now permitting repaints
826 if ( pDoc )
827 {
828 if( getImportFlags() == SvXMLImportFlags::ALL )
829 {
830 // Notify math objects. If we are in the package filter this will
831 // be done by the filter object itself
832 if( IsInsertMode() )
833 pDoc->PrtOLENotify( false );
834 else if ( pDoc->IsOLEPrtNotifyPending() )
835 pDoc->PrtOLENotify( true );
836
837 assert(pDoc->IsInReading());
838 assert(pDoc->IsInXMLImport());
839 pDoc->SetInReading(false);
840 pDoc->SetInXMLImport(false);
841 }
842
844 if ( pDrawModel )
845 pDrawModel->setLock(false);
846 }
847
848 // #i90243#
849 if ( m_bInititedXForms )
850 {
851 Reference< xforms::XFormsSupplier > xFormsSupp( GetModel(), UNO_QUERY );
852 Reference< XNameAccess > xXForms;
853 if ( xFormsSupp.is() )
854 xXForms = xFormsSupp->getXForms().get();
855
856 if ( xXForms.is() )
857 {
858 try
859 {
860 Sequence< beans::PropertyValue > aXFormsSettings;
861
862 const OUString& sXFormsSettingsName( GetXMLToken( XML_XFORM_MODEL_SETTINGS ) );
863 if ( m_xLateInitSettings.is() && m_xLateInitSettings->hasByName( sXFormsSettingsName ) )
864 {
865 OSL_VERIFY( m_xLateInitSettings->getByName( sXFormsSettingsName ) >>= aXFormsSettings );
866 applyXFormsSettings( xXForms, aXFormsSettings );
867 }
868 }
869 catch( const Exception& )
870 {
871 }
872 }
873 }
874
875#if 1
876 if (!pDoc) { pDoc = SwImport::GetDocFromXMLImport(*this); }
877 for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
878 {
879 if (SwTableNode *const pTableNode = pDoc->GetNodes()[i]->GetTableNode())
880 {
881 if (!pTableNode->GetTable().IsNewModel()
882 && pTableNode->GetTable().CanConvertSubtables())
883 {
884 pTableNode->GetTable().ConvertSubtables();
885 }
886 }
887 // don't skip to the end; nested tables could have subtables too...
888 }
889#endif
890
891 // delegate to parent: takes care of error handling
894}
895
896// tdf#113877
897// when we insert one document with list inside into another one with list at the insert position,
898// the resulting numbering in these lists is not consequent.
899//
900// CASE-1: Main document:
901// 1. One
902// 2. Two
903// 3. Three
904// 4. <-- insert position
905//
906// Inserted document:
907// 1. One
908// 2. Two
909// 3. Three
910// 4.
911//
912// Expected result
913// 1. One
914// 2. Two
915// 3. Three
916// 4. One
917// 5. Two
918// 6. Three
919// 7.
920//
921// CASE-2: Main document:
922// 1. One
923// 2. Two
924// 3. Three
925// 4. <-- insert position
926//
927// Inserted document:
928// A) One
929// B) Two
930// C) Three
931// D)
932//
933// Expected result
934// 1. One
935// 2. Two
936// 3. Three
937// 4. One
938// A) Two
939// B) Three
940// 5.
941//
943{
944 // 1. check environment
945 if (! pDoc)
946 return;
947
948 if (! IsInsertMode() || ! m_pSttNdIdx->GetIndex())
949 return;
950
952
953 // the last node of the main document where we have inserted a document
954 SwNode* const node1 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + 0];
955
956 // the first node of the inserted document
957 SwNode* node2 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + index];
958
959 if (! (node1 && node2
960 && (node1->GetNodeType() == node2->GetNodeType())
961 && (node1->IsTextNode() == node2->IsTextNode())
962 ))
963 {
964 // not a text node at insert position
965 return;
966 }
967
968 // 2. get the first node of the inserted document,
969 // which will be used to detect if inside inserted document a new list was started after the first list
970 const SfxPoolItem* pListId2Initial = nullptr;
971 {
972 SwContentNode* contentNode1 = static_cast<SwContentNode *>(node1);
973 SwContentNode* contentNode2 = static_cast<SwContentNode *>(node2);
974
975 // check if both lists have the same list properties
976 const SfxPoolItem* pListId1 = contentNode1->GetNoCondAttr( RES_PARATR_LIST_ID, false );
977 const SfxPoolItem* pListId2 = contentNode2->GetNoCondAttr( RES_PARATR_LIST_ID, false );
978
979 if (! pListId1)
980 return;
981 if (! pListId2)
982 return;
983
984 auto pStringListId1 = dynamic_cast<const SfxStringItem*>(pListId1);
985 assert(pStringListId1);
986 const OUString& sListId1 = pStringListId1->GetValue();
987 auto pStringListId2 = dynamic_cast<const SfxStringItem*>(pListId2);
988 assert(pStringListId2);
989 const OUString& sListId2 = pStringListId2->GetValue();
990
991 const SwList* pList1 = pDoc->getIDocumentListsAccess().getListByName( sListId1 );
992 const SwList* pList2 = pDoc->getIDocumentListsAccess().getListByName( sListId2 );
993
994 if (! pList1)
995 return;
996 if (! pList2)
997 return;
998
999 const OUString& sDefaultListStyleName1 = pList1->GetDefaultListStyleName();
1000 const OUString& sDefaultListStyleName2 = pList2->GetDefaultListStyleName();
1001
1002 if (sDefaultListStyleName1 != sDefaultListStyleName2)
1003 {
1004 const SwNumRule* pNumRule1 = pDoc->FindNumRulePtr( sDefaultListStyleName1 );
1005 const SwNumRule* pNumRule2 = pDoc->FindNumRulePtr( sDefaultListStyleName2 );
1006
1007 if (pNumRule1 && pNumRule2)
1008 {
1009 // check style of the each list level
1010 for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
1011 {
1012 if( pNumRule1->Get( n ) != pNumRule2->Get( n ) )
1013 {
1014 return;
1015 }
1016 }
1017
1018 // our list should be merged
1019 pListId2Initial = pListId2;
1020 }
1021 }
1022 else
1023 {
1024 // our list should be merged
1025 pListId2Initial = pListId2;
1026 }
1027 }
1028
1029 if (! pListId2Initial)
1030 {
1031 // two lists have different styles => they should not be merged
1032 return;
1033 }
1034
1035 // 3. merge two lists
1036 while (
1037 node1 && node2
1038 && (node1->GetNodeType() == node2->GetNodeType())
1039 && (node1->IsTextNode() == node2->IsTextNode())
1040 )
1041 {
1042 SwContentNode* contentNode1 = static_cast<SwContentNode *>( node1 );
1043 SwContentNode* contentNode2 = static_cast<SwContentNode *>( node2 );
1044
1045 const SfxPoolItem* pListId1 = contentNode1->GetNoCondAttr( RES_PARATR_LIST_ID, false );
1046 const SfxPoolItem* pListId2 = contentNode2->GetNoCondAttr( RES_PARATR_LIST_ID, false );
1047
1048 if (! pListId1)
1049 return;
1050 if (! pListId2)
1051 return;
1052
1053 if (*pListId2Initial != *pListId2)
1054 {
1055 // no more list items of the first list inside inserted document
1056 return;
1057 }
1058
1059 // set list style to this list element
1060 contentNode2->SetAttr(*pListId1);
1061
1062 // get next item
1063 index++;
1064 if (index >= pDoc->GetNodes().Count())
1065 {
1066 // no more items
1067 return;
1068 }
1069
1070 node2 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + index];
1071 }
1072}
1073
1074namespace {
1075
1076// Locally derive XMLTextShapeImportHelper, so we can take care of the
1077// form import This is Writer, but not text specific, so it should go
1078// here!
1079class SvTextShapeImportHelper : public XMLTextShapeImportHelper
1080{
1081 // hold own reference form import helper, because the SvxImport
1082 // stored in the superclass, from whom we originally got the
1083 // reference, is already destroyed when we want to use it in the
1084 // destructor
1086
1087 // hold reference to the one page (if it exists) for calling startPage()
1088 // and endPage. If !xPage.is(), then this document doesn't have a
1089 // XDrawPage.
1090 Reference<drawing::XDrawPage> xPage;
1091
1092public:
1093 explicit SvTextShapeImportHelper(SvXMLImport& rImp);
1094 virtual ~SvTextShapeImportHelper() override;
1095};
1096
1097}
1098
1099SvTextShapeImportHelper::SvTextShapeImportHelper(SvXMLImport& rImp) :
1101{
1102 Reference<drawing::XDrawPageSupplier> xSupplier(rImp.GetModel(),UNO_QUERY);
1103 if (xSupplier.is())
1104 {
1105 if (rImp.GetFormImport().is())
1106 {
1107 rImp.GetFormImport()->startPage(xSupplier->getDrawPage());
1108 rFormImport = rImp.GetFormImport();
1109 }
1110
1111 xPage = xSupplier->getDrawPage();
1113 }
1114}
1115
1116SvTextShapeImportHelper::~SvTextShapeImportHelper()
1117{
1118 rFormImport->endPage();
1119
1120 if (xPage.is())
1121 {
1123 }
1124}
1125
1127{
1128 return new SwXMLTextImportHelper( GetModel(), *this, getImportInfo(),
1129 IsInsertMode(),
1132}
1133
1135{
1136 return new SvTextShapeImportHelper( *this );
1137}
1138
1140{
1141 XMLFontStylesContext *pFSContext =
1142 new XMLFontStylesContext( *this, osl_getThreadTextEncoding() );
1143 SetFontDecls( pFSContext );
1144 return pFSContext;
1145}
1146
1147void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps)
1148{
1149 if (IsInsertMode() || IsStylesOnlyMode() || IsBlockMode() || m_bOrganizerMode || !GetModel().is() )
1150 return;
1151
1152 // this method will modify the document directly -> lock SolarMutex
1153 SolarMutexGuard aGuard;
1154
1155 SwDoc *pDoc = getDoc();
1156 tools::Rectangle aRect;
1157 if( pDoc->GetDocShell() )
1158 aRect = pDoc->GetDocShell()->GetVisArea( ASPECT_CONTENT );
1159 //TODO/LATER: why that cast?!
1160 //aRect = ((SfxInPlaceObject *)pDoc->GetDocShell())->GetVisArea();
1161
1162 sal_Int64 nTmp = 0;
1163 bool bShowRedlineChanges = false, bBrowseMode = false;
1164 bool bChangeShowRedline = false, bChangeBrowseMode = false;
1165
1166 //TODO/LATER: why that cast?!
1167 bool bTwip = pDoc->GetDocShell()->GetMapUnit ( ) == MapUnit::MapTwip;
1168 //sal_Bool bTwip = pDoc->GetDocShell()->SfxInPlaceObject::GetMapUnit ( ) == MapUnit::MapTwip;
1169
1170 for (const PropertyValue& rValue : aViewProps)
1171 {
1172 if ( rValue.Name == "ViewAreaTop" )
1173 {
1174 rValue.Value >>= nTmp;
1175 aRect.SetPosY(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
1176 }
1177 else if ( rValue.Name == "ViewAreaLeft" )
1178 {
1179 rValue.Value >>= nTmp;
1180 aRect.SetPosX(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
1181 }
1182 else if ( rValue.Name == "ViewAreaWidth" )
1183 {
1184 rValue.Value >>= nTmp;
1185 Size aSize( aRect.GetSize() );
1186 aSize.setWidth(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
1187 aRect.SetSize( aSize );
1188 }
1189 else if ( rValue.Name == "ViewAreaHeight" )
1190 {
1191 rValue.Value >>= nTmp;
1192 Size aSize( aRect.GetSize() );
1193 aSize.setHeight(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
1194 aRect.SetSize( aSize );
1195 }
1196 else if ( rValue.Name == "ShowRedlineChanges" )
1197 {
1198 bShowRedlineChanges = *o3tl::doAccess<bool>(rValue.Value);
1199 bChangeShowRedline = true;
1200 }
1201// Headers and footers are not displayed in BrowseView anymore
1202 else if ( rValue.Name == "InBrowseMode" )
1203 {
1204 bBrowseMode = *o3tl::doAccess<bool>(rValue.Value);
1205 bChangeBrowseMode = true;
1206 }
1207 }
1208 if( pDoc->GetDocShell() )
1209 pDoc->GetDocShell()->SetVisArea ( aRect );
1210
1211 if (bChangeBrowseMode)
1213
1214 if (bChangeShowRedline)
1215 GetTextImport()->SetShowChanges( bShowRedlineChanges );
1216}
1217
1218// Note: this will be called only if there are OOo elements in settings.xml.
1219// So if a setting is missing there we can assume that it was written
1220// by an OOo/LO version that is older than the introduction of the setting!
1221void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aConfigProps)
1222{
1223 // this method will modify the document directly -> lock SolarMutex
1224 SolarMutexGuard aGuard;
1225
1226 Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
1227 if( !xFac.is() )
1228 return;
1229
1230 Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
1231 if( !xProps.is() )
1232 return;
1233
1234 Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
1235 if( !xInfo.is() )
1236 return;
1237
1238 std::unordered_set< OUString > aExcludeAlways;
1239 aExcludeAlways.insert("LinkUpdateMode");
1240 // this should contain things that are actually user-settable, via Tools->Options
1241 std::unordered_set< OUString > aExcludeWhenNotLoadingUserSettings {
1242 "ForbiddenCharacters",
1243 "IsKernAsianPunctuation",
1244 "CharacterCompressionType",
1245 "FieldAutoUpdate",
1246 "ChartAutoUpdate",
1247 "AddParaTableSpacing",
1248 "AddParaTableSpacingAtStart",
1249 "PrintAnnotationMode",
1250 "PrintBlackFonts",
1251 "PrintControls",
1252 "PrintDrawings",
1253 "PrintGraphics",
1254 "PrintHiddenText",
1255 "PrintLeftPages",
1256 "PrintPageBackground",
1257 "PrintProspect",
1258 "PrintReversed",
1259 "PrintRightPages",
1260 "PrintFaxName",
1261 "PrintPaperFromSetup",
1262 "PrintTables",
1263 "PrintTextPlaceholder",
1264 "PrintSingleJobs",
1265 "UpdateFromTemplate",
1266 "PrinterIndependentLayout",
1267 "PrintEmptyPages",
1268 "ConsiderTextWrapOnObjPos",
1269 "DoNotJustifyLinesWithManualBreak",
1270 "ProtectForm",
1271 "MsWordCompTrailingBlanks",
1272 "SubtractFlysAnchoredAtFlys",
1273 "EmptyDbFieldHidesPara"
1274 };
1275
1276 bool bAreUserSettingsFromDocument = officecfg::Office::Common::Load::UserDefinedSettings::get();
1277
1278 // for some properties we don't want to use the application
1279 // default if they're missing. So we watch for them in the loop
1280 // below, and set them if not found
1281 bool bPrinterIndependentLayout = false;
1282 bool bUseOldNumbering = false;
1283 bool bAddExternalLeading = false;
1284 bool bAddParaSpacingToTableCells = false;
1285 bool bAddParaLineSpacingToTableCells = false;
1286 bool bUseFormerLineSpacing = false;
1287 bool bUseFormerObjectPositioning = false;
1288 bool bUseFormerTextWrapping = false;
1289 bool bConsiderWrapOnObjPos = false;
1290 bool bIgnoreFirstLineIndentInNumbering = false;
1291 bool bDoNotJustifyLinesWithManualBreak = false;
1292 bool bDoNotResetParaAttrsForNumFont = false;
1293 bool bDoNotCaptureDrawObjsOnPage( false );
1294 bool bClipAsCharacterAnchoredWriterFlyFrames( false );
1295 bool bUnixForceZeroExtLeading = false;
1296 bool bSmallCapsPercentage66 = false;
1297 bool bTabOverflow = false;
1298 bool bTabOverMarginValue = false;
1299 bool bPropLineSpacingShrinksFirstLine = false;
1300 bool bSubtractFlysAnchoredAtFlys = false;
1301 bool bEmptyDbFieldHidesPara = false;
1302 bool bCollapseEmptyCellPara = false;
1303 bool bAutoFirstLineIndentDisregardLineSpace = false;
1304
1305 const PropertyValue* currentDatabaseDataSource = nullptr;
1306 const PropertyValue* currentDatabaseCommand = nullptr;
1307 const PropertyValue* currentDatabaseCommandType = nullptr;
1308 const PropertyValue* embeddedDatabaseName = nullptr;
1309
1310 for( const PropertyValue& rValue : aConfigProps )
1311 {
1312 bool bSet = aExcludeAlways.find(rValue.Name) == aExcludeAlways.end();
1313 if( bSet && !bAreUserSettingsFromDocument
1314 && (aExcludeWhenNotLoadingUserSettings.find(rValue.Name)
1315 != aExcludeWhenNotLoadingUserSettings.end()) )
1316 {
1317 bSet = false;
1318 }
1319
1320 if( bSet )
1321 {
1322 try
1323 {
1324 if( xInfo->hasPropertyByName( rValue.Name ) )
1325 {
1326 if( rValue.Name == "RedlineProtectionKey" )
1327 {
1328 Sequence<sal_Int8> aKey;
1329 rValue.Value >>= aKey;
1330 GetTextImport()->SetChangesProtectionKey( aKey );
1331 }
1332 else
1333 {
1334 // HACK: Setting these out of order does not work.
1335 if( rValue.Name == "CurrentDatabaseDataSource" )
1336 currentDatabaseDataSource = &rValue;
1337 else if( rValue.Name == "CurrentDatabaseCommand" )
1338 currentDatabaseCommand = &rValue;
1339 else if( rValue.Name == "CurrentDatabaseCommandType" )
1340 currentDatabaseCommandType = &rValue;
1341 else if (rValue.Name == "EmbeddedDatabaseName")
1342 embeddedDatabaseName = &rValue;
1343 else
1344 xProps->setPropertyValue( rValue.Name, rValue.Value );
1345 }
1346 }
1347
1348 // did we find any of the non-default cases?
1349 if ( rValue.Name == "PrinterIndependentLayout" )
1350 bPrinterIndependentLayout = true;
1351 else if ( rValue.Name == "AddExternalLeading" )
1352 bAddExternalLeading = true;
1353 else if ( rValue.Name == "AddParaSpacingToTableCells" )
1354 bAddParaSpacingToTableCells = true;
1355 else if ( rValue.Name == "AddParaLineSpacingToTableCells" )
1356 bAddParaLineSpacingToTableCells = true;
1357 else if ( rValue.Name == "UseFormerLineSpacing" )
1358 bUseFormerLineSpacing = true;
1359 else if ( rValue.Name == "UseFormerObjectPositioning" )
1360 bUseFormerObjectPositioning = true;
1361 else if ( rValue.Name == "UseFormerTextWrapping" )
1362 bUseFormerTextWrapping = true;
1363 else if ( rValue.Name == "UseOldNumbering" )
1364 bUseOldNumbering = true;
1365 else if ( rValue.Name == "ConsiderTextWrapOnObjPos" )
1366 bConsiderWrapOnObjPos = true;
1367 else if ( rValue.Name == "IgnoreFirstLineIndentInNumbering" )
1368 bIgnoreFirstLineIndentInNumbering = true;
1369 else if ( rValue.Name == "DoNotJustifyLinesWithManualBreak" )
1370 bDoNotJustifyLinesWithManualBreak = true;
1371 else if ( rValue.Name == "DoNotResetParaAttrsForNumFont" )
1372 bDoNotResetParaAttrsForNumFont = true;
1373 else if ( rValue.Name == "DoNotCaptureDrawObjsOnPage" )
1374 bDoNotCaptureDrawObjsOnPage = true;
1375 else if ( rValue.Name == "ClipAsCharacterAnchoredWriterFlyFrames" )
1376 bClipAsCharacterAnchoredWriterFlyFrames = true;
1377 else if ( rValue.Name == "UnxForceZeroExtLeading" )
1378 bUnixForceZeroExtLeading = true;
1379 else if ( rValue.Name == "SmallCapsPercentage66" )
1380 bSmallCapsPercentage66 = true;
1381 else if ( rValue.Name == "TabOverflow" )
1382 bTabOverflow = true;
1383 else if ( rValue.Name == "TabOverMargin" )
1384 {
1385 rValue.Value >>= bTabOverMarginValue;
1386 }
1387 else if ( rValue.Name == "PropLineSpacingShrinksFirstLine" )
1388 bPropLineSpacingShrinksFirstLine = true;
1389 else if (rValue.Name == "SubtractFlysAnchoredAtFlys")
1390 bSubtractFlysAnchoredAtFlys = true;
1391 else if (rValue.Name == "EmptyDbFieldHidesPara")
1392 bEmptyDbFieldHidesPara = true;
1393 else if (rValue.Name == "CollapseEmptyCellPara")
1394 bCollapseEmptyCellPara = true;
1395 else if (rValue.Name == "AutoFirstLineIndentDisregardLineSpace")
1396 bAutoFirstLineIndentDisregardLineSpace = true;
1397 }
1398 catch( Exception& )
1399 {
1400 TOOLS_WARN_EXCEPTION( "sw", "SwXMLImport::SetConfigurationSettings" );
1401 }
1402 }
1403 }
1404
1405 try
1406 {
1407 if( currentDatabaseDataSource != nullptr )
1408 xProps->setPropertyValue( currentDatabaseDataSource->Name, currentDatabaseDataSource->Value );
1409 if( currentDatabaseCommand != nullptr )
1410 xProps->setPropertyValue( currentDatabaseCommand->Name, currentDatabaseCommand->Value );
1411 if( currentDatabaseCommandType != nullptr )
1412 xProps->setPropertyValue( currentDatabaseCommandType->Name, currentDatabaseCommandType->Value );
1413 if (embeddedDatabaseName)
1414 xProps->setPropertyValue(embeddedDatabaseName->Name, embeddedDatabaseName->Value);
1415 } catch( Exception& )
1416 {
1417 TOOLS_WARN_EXCEPTION( "sw", "SwXMLImport::SetConfigurationSettings" );
1418 }
1419
1420 // finally, treat the non-default cases
1421 // introduce boolean, that indicates a document, written by version prior SO8.
1422 // If user settings are not loaded, we can't know if this is an old document. Better to assume no?
1423 const bool bDocumentPriorSO8 = !bConsiderWrapOnObjPos && bAreUserSettingsFromDocument;
1424
1425 // Use old behaviour if this setting didn't exist, but only if this setting is being read from the document.
1426 // (Obviously the setting doesn't exist if we are explicitly ignoring it, so then stick with program/user defaults)
1427 if(!bPrinterIndependentLayout && bAreUserSettingsFromDocument)
1428 {
1429 xProps->setPropertyValue( "PrinterIndependentLayout", Any(sal_Int16(document::PrinterIndependentLayout::DISABLED)) );
1430 }
1431
1432 if( ! bAddExternalLeading )
1433 {
1434 xProps->setPropertyValue( "AddExternalLeading", Any( false ) );
1435 }
1436
1437 if( ! bUseFormerLineSpacing )
1438 {
1439 xProps->setPropertyValue( "UseFormerLineSpacing", Any( true ) );
1440 }
1441
1442 if( !bUseFormerObjectPositioning )
1443 {
1444 xProps->setPropertyValue( "UseFormerObjectPositioning", Any( true ) );
1445 }
1446
1447 if( !bUseOldNumbering )
1448 {
1449 xProps->setPropertyValue( "UseOldNumbering", Any(true) );
1450 }
1451
1452 if( !bAddParaSpacingToTableCells )
1453 {
1454 xProps->setPropertyValue( "AddParaSpacingToTableCells",
1455 Any( false ) );
1456 }
1457 if (!bAddParaLineSpacingToTableCells)
1458 {
1459 xProps->setPropertyValue("AddParaLineSpacingToTableCells", Any(false));
1460 }
1461
1462 if( !bUseFormerTextWrapping )
1463 {
1464 xProps->setPropertyValue( "UseFormerTextWrapping", Any( true ) );
1465 }
1466
1467 if (!bConsiderWrapOnObjPos && bAreUserSettingsFromDocument)
1468 {
1469 xProps->setPropertyValue( "ConsiderTextWrapOnObjPos", Any( false ) );
1470 }
1471
1472 // #i47448#
1473 // For SO7pp4, part of the 'new numbering' stuff has been backported from
1474 // SO8. Unfortunately, only part of it and by using the same compatibility option
1475 // like in SO8. Therefore documents generated with SO7pp4, containing
1476 // numbered paragraphs with first line indent differ between SO7pp4 and
1477 // SO8. In order to fix this for SO8pp1, I introduce a new compatibility
1478 // flag 'bIgnoreFirstLineIndentInNumbering'. This flag has to be set for all
1479 // documents < SO8, but not for SO8. So if the property is not present, the
1480 // flag will be set to 'true'. SO8 documents surely have the
1481 // 'ConsiderWrapOnObjPos' property set (no matter if 'true' or 'false'),
1482 // therefore the correct condition to set this flag is this:
1483 if( !bIgnoreFirstLineIndentInNumbering && bDocumentPriorSO8 )
1484 {
1485 xProps->setPropertyValue( "IgnoreFirstLineIndentInNumbering",
1486 Any( true ) );
1487 }
1488
1489 // This flag has to be set for all documents < SO8
1490 if ( !bDoNotJustifyLinesWithManualBreak && bDocumentPriorSO8 )
1491 {
1492 xProps->setPropertyValue( "DoNotJustifyLinesWithManualBreak",
1493 Any( true ) );
1494 }
1495
1496 // This flag has to be set for all documents < SO8
1497 if ( !bDoNotResetParaAttrsForNumFont && bDocumentPriorSO8 )
1498 {
1499 xProps->setPropertyValue( "DoNotResetParaAttrsForNumFont",
1500 Any( true ) );
1501 }
1502
1503 // This flag has to be set for all documents < SO8
1504 if ( !bDoNotCaptureDrawObjsOnPage && bDocumentPriorSO8 )
1505 {
1506 xProps->setPropertyValue( "DoNotCaptureDrawObjsOnPage",
1507 Any( true ) );
1508 }
1509
1510 // This flag has to be set for all documents < SO8
1511 if ( !bClipAsCharacterAnchoredWriterFlyFrames && bDocumentPriorSO8 )
1512 {
1513 xProps->setPropertyValue( "ClipAsCharacterAnchoredWriterFlyFrames",
1514 Any( true ) );
1515 }
1516
1517 if ( !bUnixForceZeroExtLeading )
1518 {
1519 xProps->setPropertyValue( "UnxForceZeroExtLeading", Any( true ) );
1520 }
1521
1522 // Old LO versions had 66 as the value for small caps percentage, later changed to 80.
1523 // In order to keep backwards compatibility, SmallCapsPercentage66 option is written to .odt
1524 // files, and the default for new documents is 'false'. Files without this option
1525 // are considered to be old files, so set the compatibility option too.
1526 if ( !bSmallCapsPercentage66 )
1527 {
1528 xProps->setPropertyValue( "SmallCapsPercentage66", Any( true ) );
1529 }
1530
1531 if ( !bTabOverflow )
1532 {
1533 xProps->setPropertyValue( "TabOverflow", Any( false ) );
1534 }
1535
1536 if (bTabOverMarginValue)
1537 // Let TabOverMargin imply the new default for
1538 // PrinterIndependentLayout, knowing the first is set by Word import
1539 // filters and Word defaults to our new default as well.
1540 xProps->setPropertyValue(
1541 "PrinterIndependentLayout",
1542 uno::Any(document::PrinterIndependentLayout::HIGH_RESOLUTION));
1543
1544 if (!bPropLineSpacingShrinksFirstLine)
1545 xProps->setPropertyValue("PropLineSpacingShrinksFirstLine", Any(false));
1546
1547 if (!bSubtractFlysAnchoredAtFlys && bAreUserSettingsFromDocument)
1548 xProps->setPropertyValue("SubtractFlysAnchoredAtFlys", Any(true));
1549
1550 if (!bEmptyDbFieldHidesPara && bAreUserSettingsFromDocument)
1551 xProps->setPropertyValue("EmptyDbFieldHidesPara", Any(false));
1552
1553 if (!bCollapseEmptyCellPara)
1554 xProps->setPropertyValue("CollapseEmptyCellPara", Any(false));
1555
1556 if (!bAutoFirstLineIndentDisregardLineSpace)
1557 xProps->setPropertyValue("AutoFirstLineIndentDisregardLineSpace", Any(false));
1558
1559 SwDoc *pDoc = getDoc();
1560 SfxPrinter *pPrinter = pDoc->getIDocumentDeviceAccess().getPrinter( false );
1561 if( pPrinter )
1562 {
1563 // If the printer is known, then the OLE objects will
1564 // already have correct sizes, and we don't have to call
1565 // PrtOLENotify again. Otherwise we have to call it.
1566 // The flag might be set from setting the printer, so it
1567 // it is required to clear it.
1568 pDoc->SetOLEPrtNotifyPending( !pPrinter->IsKnown() );
1569 }
1570}
1571
1573 const OUString& _rSettingsGroupName,
1574 const Sequence< PropertyValue>& _rSettings )
1575{
1576 // the only doc-specific settings group we know so far are the XForms settings
1577 if ( !IsXMLToken( _rSettingsGroupName, XML_XFORM_MODEL_SETTINGS ) )
1578 return;
1579
1580 // preserve the settings for a later iteration - we are currently reading the settings.xml,
1581 // the content.xml will be read later, by another instance of SwXMLImport
1582 OSL_ENSURE( m_xLateInitSettings.is(), "SwXMLImport::SetDocumentSpecificSettings: no storage for those settings!" );
1583 if ( !m_xLateInitSettings.is() )
1584 return;
1585
1586 try
1587 {
1588 if ( m_xLateInitSettings->hasByName( _rSettingsGroupName ) )
1589 {
1590 m_xLateInitSettings->replaceByName( _rSettingsGroupName, Any( _rSettings ) );
1591 OSL_FAIL( "SwXMLImport::SetDocumentSpecificSettings: already have settings for this model!" );
1592 }
1593 else
1594 m_xLateInitSettings->insertByName( _rSettingsGroupName, Any( _rSettings ) );
1595 }
1596 catch( const Exception& )
1597 {
1598 }
1599}
1600
1602 const Sequence<Any>& aArguments )
1603{
1604 // delegate to super class
1606
1607 // we are only looking for a NamedValue "LateInitSettings"
1608 for(const auto& rArgument : aArguments)
1609 {
1610 beans::NamedValue aNamedValue;
1611 if ( rArgument >>= aNamedValue )
1612 {
1613 if (aNamedValue.Name == "LateInitSettings")
1614 {
1615 OSL_VERIFY( aNamedValue.Value >>= m_xLateInitSettings );
1616 }
1617 }
1618 }
1619}
1620
1622{
1623 auto pTextDoc = comphelper::getFromUnoTunnel<SwXTextDocument>(rImport.GetModel());
1624 assert( pTextDoc );
1625 assert( pTextDoc->GetDocShell() );
1626 SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
1627 OSL_ENSURE( pDoc, "Where is my document?" );
1628 return pDoc;
1629}
1630
1632{
1633 // obtain SwDoc
1634 auto pXTextDocument = comphelper::getFromUnoTunnel<SwXTextDocument>(GetModel());
1635 if( pXTextDocument == nullptr )
1636 return;
1637
1638 SwDoc *pDoc = pXTextDocument->GetDocShell()->GetDoc();
1639
1640 // init XForms (if not already done)
1641 // (no default model, since we'll load the models)
1642 if( ! pDoc->isXForms() )
1643 pDoc->initXForms( false );
1644
1645 m_bInititedXForms = true;
1646}
1647
1649{
1650 if( m_pDoc != nullptr )
1651 return m_pDoc;
1652 Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
1653 Reference < XText > xText = xTextDoc->getText();
1654 Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
1655 assert( xTextTunnel.is());
1656 SwXText* pText = comphelper::getFromUnoTunnel<SwXText>(xTextTunnel);
1657 assert( pText != nullptr );
1658 m_pDoc = pText->GetDoc();
1659 assert( m_pDoc != nullptr );
1660 return m_pDoc;
1661}
1662
1664{
1665 return const_cast< SwXMLImport* >( this )->getDoc();
1666}
1667
1668extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1670 css::uno::Sequence<css::uno::Any> const &)
1671{
1672 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisImporter",
1673 SvXMLImportFlags::ALL));
1674}
1675
1676
1677extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1679 css::uno::Sequence<css::uno::Any> const &)
1680{
1681 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisStylesImporter",
1682 SvXMLImportFlags::STYLES | SvXMLImportFlags::MASTERSTYLES | SvXMLImportFlags::AUTOSTYLES |
1683 SvXMLImportFlags::FONTDECLS));
1684}
1685
1686
1687extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1689 css::uno::Sequence<css::uno::Any> const &)
1690{
1691 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisContentImporter",
1692 SvXMLImportFlags::CONTENT | SvXMLImportFlags::SCRIPTS | SvXMLImportFlags::AUTOSTYLES |
1693 SvXMLImportFlags::FONTDECLS));
1694}
1695
1696extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1698 css::uno::Sequence<css::uno::Any> const &)
1699{
1700 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisMetaImporter",
1701 SvXMLImportFlags::META));
1702}
1703
1704
1705extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1707 css::uno::Sequence<css::uno::Any> const &)
1708{
1709 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisSettingsImporter",
1710 SvXMLImportFlags::SETTINGS));
1711}
1712
1713extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODT(SvStream &rStream)
1714{
1716
1717 SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL));
1718 xDocSh->DoInitNew();
1719 uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
1720
1721 uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
1722 uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
1723 uno::Reference<uno::XInterface> xInterface(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.XmlFilterAdaptor"), uno::UNO_SET_THROW);
1724
1725 css::uno::Sequence<OUString> aUserData
1726 {
1727 "com.sun.star.comp.filter.OdfFlatXml",
1728 "",
1729 "com.sun.star.comp.Writer.XMLOasisImporter",
1730 "com.sun.star.comp.Writer.XMLOasisExporter",
1731 "",
1732 "",
1733 "true"
1734 };
1735 uno::Sequence<beans::PropertyValue> aAdaptorArgs(comphelper::InitPropertySequence(
1736 {
1737 { "UserData", uno::Any(aUserData) },
1738 }));
1739 css::uno::Sequence<uno::Any> aOuterArgs{ uno::Any(aAdaptorArgs) };
1740
1741 uno::Reference<lang::XInitialization> xInit(xInterface, uno::UNO_QUERY_THROW);
1742 xInit->initialize(aOuterArgs);
1743
1744 uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
1745 uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
1746 {
1747 { "InputStream", uno::Any(xStream) },
1748 { "URL", uno::Any(OUString("private:stream")) },
1749 }));
1750 xImporter->setTargetDocument(xModel);
1751
1752 uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
1753 //SetLoading hack because the document properties will be re-initted
1754 //by the xml filter and during the init, while it's considered uninitialized,
1755 //setting a property will inform the document it's modified, which attempts
1756 //to update the properties, which throws cause the properties are uninitialized
1757 xDocSh->SetLoading(SfxLoadedFlags::NONE);
1758 bool ret = xFilter->filter(aArgs);
1759 xDocSh->SetLoading(SfxLoadedFlags::ALL);
1760
1761 xDocSh->DoClose();
1762
1763 return ret;
1764}
1765
1766extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDOCX(SvStream &rStream)
1767{
1769
1770 SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL));
1771 xDocSh->DoInitNew();
1772 uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
1773
1774 uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
1775 uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
1776
1777 uno::Reference<document::XFilter> xFilter(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.WriterFilter"), uno::UNO_QUERY_THROW);
1778
1779 uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
1780 uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
1781 {
1782 { "InputStream", uno::Any(xStream) },
1783 { "InputMode", uno::Any(true) },
1784 }));
1785 xImporter->setTargetDocument(xModel);
1786
1787 //SetLoading hack because the document properties will be re-initted
1788 //by the xml filter and during the init, while it's considered uninitialized,
1789 //setting a property will inform the document it's modified, which attempts
1790 //to update the properties, which throws cause the properties are uninitialized
1791 xDocSh->SetLoading(SfxLoadedFlags::NONE);
1792 bool ret = false;
1793 try
1794 {
1795 ret = xFilter->filter(aArgs);
1796 }
1797 catch (...)
1798 {
1799 }
1800 xDocSh->SetLoading(SfxLoadedFlags::ALL);
1801
1802 xDocSh->DoClose();
1803
1804 return ret;
1805}
1806
1807/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_Int64 sanitiseMm100ToTwip(sal_Int64 n)
Reference< XInputStream > xStream
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
virtual SwDrawModel * GetOrCreateDrawModel()=0
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
virtual SwList * getListByName(const OUString &rListId) const =0
virtual void set(DocumentSettingId id, bool value)=0
Set the specified document setting.
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
virtual const SwDoc * GetDoc() const =0
virtual const SwPaM * GetPaM() const =0
void setLock(bool bLock)
MapUnit GetMapUnit() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
void SetLoading(SfxLoadedFlags nFlags)
bool IsKnown() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
static rtl::Reference< SvXMLEmbeddedObjectHelper > Create(const css::uno::Reference< css::embed::XStorage > &, ::comphelper::IEmbeddedHelper &rDocPersist, SvXMLEmbeddedObjectHelperMode eCreateMode)
static rtl::Reference< SvXMLGraphicHelper > Create(const css::uno::Reference< css::embed::XStorage > &rXMLStorage, SvXMLGraphicHelperMode eCreateMode)
SvXMLImport & GetImport()
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
const css::uno::Reference< css::beans::XPropertySet > & getImportInfo() const
const css::uno::Reference< css::document::XEmbeddedObjectResolver > & GetEmbeddedResolver() const
virtual void SAL_CALL startDocument() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport()
void SetEmbeddedResolver(css::uno::Reference< css::document::XEmbeddedObjectResolver > const &_xEmbeddedResolver)
virtual void SAL_CALL endDocument() override
void ClearShapeImport()
void ClearTextImport()
void AddStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName, const OUString &rDisplayName)
const SvXMLUnitConverter & GetMM100UnitConverter() const
void SetFontDecls(XMLFontStylesContext *pFontDecls)
SvXMLImportFlags getImportFlags() const
bool HasTextImport() const
void SetGraphicStorageHandler(css::uno::Reference< css::document::XGraphicStorageHandler > const &rxGraphicStorageHandler)
const css::uno::Reference< css::frame::XModel > & GetModel() const
bool HasShapeImport() const
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
const css::uno::Reference< css::document::XGraphicStorageHandler > & GetGraphicStorageHandler() const
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
OUString encodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
bool CanJoinNext(SwNodeIndex *pIdx=nullptr) const
Is it possible to join two nodes? In pIdx the second position can be returned.
Definition: node.cxx:1824
virtual bool SetAttr(const SfxPoolItem &)
made virtual
Definition: node.cxx:1566
bool CanJoinPrev(SwNodeIndex *pIdx=nullptr) const
Can we join two Nodes? We can return the 2nd position in pIdx.
Definition: node.cxx:1848
const SfxPoolItem * GetNoCondAttr(sal_uInt16 nWhich, bool bInParents) const
Obtains attribute that is not delivered via conditional style!
Definition: node.cxx:1784
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
virtual tools::Rectangle GetVisArea(sal_uInt16 nAspect) const override
Definition: docsh.cxx:914
virtual void SetVisArea(const tools::Rectangle &rRect) override
OLE-stuff.
Definition: docsh.cxx:890
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:204
Definition: doc.hxx:188
bool IsInReading() const
Definition: doc.hxx:953
void SetInReading(bool bNew)
Definition: doc.hxx:954
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:238
SwNumRule * FindNumRulePtr(const OUString &rName) const
Definition: docnum.cxx:2473
void SetOLEPrtNotifyPending(bool bSet=true)
Definition: doc.hxx:1687
void PrtOLENotify(bool bAll)
Definition: docdesc.cxx:818
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
SwNodes & GetNodes()
Definition: doc.hxx:408
bool IsInXMLImport() const
Definition: doc.hxx:969
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:328
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:176
SfxObjectShell * GetPersist() const
Definition: docnew.cxx:640
void SetInXMLImport(bool bNew)
Definition: doc.hxx:970
void initXForms(bool bCreateDefaultModel)
Definition: docxforms.cxx:49
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:426
bool isXForms() const
Definition: docxforms.cxx:44
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
bool IsOLEPrtNotifyPending() const
Definition: doc.hxx:561
bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat, const bool bReset=true, const bool bResetListAttrs=false, SwRootFrame const *pLayout=nullptr)
Add 4th optional parameter <bResetListAttrs>.
Definition: docfmt.cxx:1083
SwDocShell * GetDocShell()
Definition: doc.hxx:1351
IDocumentListsAccess const & getIDocumentListsAccess() const
Definition: doc.cxx:293
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
sal_Int32 GetIndex() const
Definition: index.hxx:91
Definition: list.hxx:40
const OUString & GetDefaultListStyleName() const
Definition: list.hxx:49
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNode & GetNode() const
Definition: ndindex.hxx:128
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:161
Base class of the Writer document model elements.
Definition: node.hxx:83
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:871
bool IsContentNode() const
Definition: node.hxx:640
bool IsEndNode() const
Definition: node.hxx:644
SwNodeOffset StartOfSectionIndex() const
Definition: node.hxx:685
bool IsSectionNode() const
Definition: node.hxx:656
bool IsTextNode() const
Definition: node.hxx:648
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:133
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:689
SwNodeType GetNodeType() const
Definition: node.hxx:146
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
delete nodes
Definition: nodes.cxx:1085
SwNodeOffset Count() const
Definition: ndarr.hxx:141
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:86
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:138
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:230
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:477
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:503
SwDoc & GetDoc() const
Definition: pam.hxx:244
SwPosition & GetBound(bool bOne=true)
Definition: pam.hxx:246
void DeleteMark()
Definition: pam.hxx:178
const SwPosition * GetPoint() const
Definition: pam.hxx:208
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:84
virtual SwContentNode * JoinNext() override
Definition: ndtxt.cxx:981
void FormatToTextAttr(SwTextNode *pNd)
Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
Definition: thints.cxx:2509
void JoinPrev()
Definition: ndtxt.cxx:1096
virtual SwFormatColl * ChgFormatColl(SwFormatColl *) override
Definition: ndtxt.cxx:3959
void CopyCollFormat(SwTextNode &rDestNd, bool bUndoForChgFormatColl=true)
Copy collection with all auto formats to dest-node.
Definition: ndcopy.cxx:336
const OUString & GetText() const
Definition: ndtxt.hxx:220
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:865
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
Definition: ndtxt.cxx:5173
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:616
rtl::Reference< SvXMLEmbeddedObjectHelper > m_xEmbeddedResolver
Definition: xmlimp.hxx:69
virtual void SetDocumentSpecificSettings(const OUString &_rSettingsGroupName, const css::uno::Sequence< css::beans::PropertyValue > &_rSettings) override
Definition: xmlimp.cxx:1572
const SwDoc * getDoc() const
Definition: xmlimp.cxx:1663
virtual ~SwXMLImport() noexcept override
Definition: xmlimp.cxx:332
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement)
Definition: xmlmeta.cxx:53
std::unique_ptr< SwNodeIndex > m_pSttNdIdx
Definition: xmlimp.hxx:62
css::uno::Reference< css::container::XNameContainer > m_xLateInitSettings
Definition: xmlimp.hxx:76
rtl::Reference< SvXMLGraphicHelper > m_xGraphicStorageHandler
Definition: xmlimp.hxx:67
virtual XMLShapeImportHelper * CreateShapeImport() override
Definition: xmlimp.cxx:1134
css::uno::Reference< css::document::XDocumentProperties > GetDocumentProperties() const
Definition: xmlmeta.cxx:41
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlimp.cxx:287
SwXMLImport(const css::uno::Reference< css::uno::XComponentContext > &rContext, OUString const &implementationName, SvXMLImportFlags nImportFlags)
Definition: xmlimp.cxx:317
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:380
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlimp.cxx:1601
bool m_bInititedXForms
Definition: xmlimp.hxx:86
void UpdateTextCollConditions(SwDoc *pDoc)
Definition: xmlfmt.cxx:1006
bool m_bLoadDoc
Definition: xmlimp.hxx:79
void InitItemImport()
Definition: xmlitemi.cxx:225
SfxStyleFamily GetStyleFamilyMask() const
Definition: xmlimp.hxx:139
bool IsBlockMode() const
Definition: xmlimp.hxx:142
virtual void initXForms() override
Definition: xmlimp.cxx:1631
void setTextInsertMode(const css::uno::Reference< css::text::XTextRange > &rInsertPos)
Definition: xmlimp.cxx:342
bool m_bInsert
Definition: xmlimp.hxx:80
virtual XMLTextImportHelper * CreateTextImport() override
Definition: xmlimp.cxx:1126
bool m_bOrganizerMode
Definition: xmlimp.hxx:85
void setStyleInsertMode(SfxStyleFamily nFamilies, bool bOverwrite)
Definition: xmlimp.cxx:353
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Definition: xmlimp.cxx:1147
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() noexcept
Definition: xmlimp.cxx:361
SwDoc * m_pDoc
Definition: xmlimp.hxx:88
void MergeListsAtDocumentInsertPosition(SwDoc *pDoc)
Definition: xmlimp.cxx:942
bool m_bBlock
Definition: xmlimp.hxx:84
bool IsInsertMode() const
Definition: xmlimp.hxx:140
SfxStyleFamily m_nStyleFamilyMask
Definition: xmlimp.hxx:78
void FinitItemImport()
Definition: xmlitemi.cxx:239
bool IsStylesOnlyMode() const
Definition: xmlimp.hxx:141
SvXMLImportContext * CreateFontDeclsContext()
Definition: xmlimp.cxx:1139
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: xmlimp.cxx:367
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
Definition: xmlimp.cxx:1221
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1214
const SwDoc * GetDoc() const
Definition: unotext.cxx:133
void endPage(css::uno::Reference< css::drawing::XShapes > const &rShapes)
void startPage(css::uno::Reference< css::drawing::XShapes > const &rShapes)
const css::uno::Sequence< sal_Int8 > & getSeq() const
void SetSize(const Size &)
void SetPosY(tools::Long y)
constexpr Size GetSize() const
void SetPosX(tools::Long x)
#define TOOLS_WARN_EXCEPTION(area, stream)
float u
constexpr TypedWhichId< SfxStringItem > RES_PARATR_LIST_ID(RES_PARATR_LIST_BEGIN)
constexpr sal_uInt16 RES_CHRATR_END(46)
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
Sequence< PropertyValue > aArguments
sal_Int64 n
#define SAL_WARN(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
void ensure()
Definition: swdll.cxx:67
SwDoc * GetDocFromXMLImport(SvXMLImport const &)
Definition: xmlimp.cxx:1621
@ Exception
sal_Int64 getSomethingImpl(const css::uno::Sequence< sal_Int8 > &rId, T *pThis, FallbackToGetSomethingOf< Base >={})
Reference< XMultiServiceFactory > getProcessServiceFactory()
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
int i
constexpr OUStringLiteral implementationName
index
detail::Optional< bool >::type tryAccess< bool >(css::uno::Any const &any)
Count
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
XML_DOCUMENT_SETTINGS
XML_DOCUMENT
XML_DOCUMENT_STYLES
XML_DOCUMENT_META
XML_XFORM_MODEL_SETTINGS
XML_DOCUMENT_CONTENT
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
#define ASPECT_CONTENT
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
@ RES_POOLCOLL_STANDARD
Standard.
Definition: poolfmt.hxx:250
Marks a position in the document model.
Definition: pam.hxx:37
SwNodeIndex nNode
Definition: pam.hxx:38
SwIndex nContent
Definition: pam.hxx:39
SfxStyleFamily
Reference< XModel > xModel
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
unsigned char sal_uInt8
XMLOFF_DLLPUBLIC SvXMLImportContext * createXFormsModelContext(SvXMLImport &rImport)
void XMLOFF_DLLPUBLIC applyXFormsSettings(const css::uno::Reference< css::container::XNameAccess > &_rXForms, const css::uno::Sequence< css::beans::PropertyValue > &_rSettings)
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Writer_XMLOasisStylesImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimp.cxx:1678
SAL_DLLPUBLIC_EXPORT bool TestImportDOCX(SvStream &rStream)
Definition: xmlimp.cxx:1766
SAL_DLLPUBLIC_EXPORT bool TestImportFODT(SvStream &rStream)
Definition: xmlimp.cxx:1713
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Writer_XMLOasisMetaImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimp.cxx:1697
static OTextCursorHelper * lcl_xml_GetSwXTextCursor(const Reference< XTextCursor > &rTextCursor)
Definition: xmlimp.cxx:373
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Writer_XMLOasisContentImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimp.cxx:1688
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Writer_XMLOasisSettingsImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimp.cxx:1706
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Writer_XMLOasisImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimp.cxx:1669
#define PROGRESS_BAR_STEP
Definition: xmlimp.hxx:48
#define XML_ELEMENT(prefix, name)
SvXMLImportFlags
constexpr sal_Int32 TOKEN_MASK