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>
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");
337 ClearShapeImport();
338 }
340 // Call cleanup() here because the destruction of some stuff like XMLRedlineImportHelper will cast
341 // to cast their mrImport to SwXMLImport and that is illegal after this destructor is done.
342 cleanup();
343}
344
346 const Reference< XTextRange > & rInsertPos )
347{
348 m_bInsert = true;
349
350 Reference < XText > xText = rInsertPos->getText();
351 Reference < XTextCursor > xTextCursor =
352 xText->createTextCursorByRange( rInsertPos );
353 GetTextImport()->SetCursor( xTextCursor );
354}
355
357 bool bOverwrite )
358{
359 m_bInsert = !bOverwrite;
360 m_nStyleFamilyMask = nFamilies;
361 m_bLoadDoc = false;
362}
363
364const Sequence< sal_Int8 > & SwXMLImport::getUnoTunnelId() noexcept
365{
366 static const comphelper::UnoIdInit theSwXMLImportUnoTunnelId;
367 return theSwXMLImportUnoTunnelId.getSeq();
368}
369
370sal_Int64 SAL_CALL SwXMLImport::getSomething( const Sequence< sal_Int8 >& rId )
371{
372 return comphelper::getSomethingImpl(rId, this,
374}
375
376static OTextCursorHelper *lcl_xml_GetSwXTextCursor( const Reference < XTextCursor >& rTextCursor )
377{
378 OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(rTextCursor);
379 OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
380 return pTextCursor;
381}
382
384{
385 // delegate to parent
386 SvXMLImport::startDocument();
387
388 OSL_ENSURE( GetModel().is(), "model is missing" );
389 if( !GetModel().is() )
390 return;
391
392 // this method will modify the document directly -> lock SolarMutex
393 SolarMutexGuard aGuard;
394
395 Reference< XPropertySet > xImportInfo( getImportInfo() );
396 Reference< XPropertySetInfo > xPropertySetInfo;
397 if( xImportInfo.is() )
398 xPropertySetInfo = xImportInfo->getPropertySetInfo();
399 if( xPropertySetInfo.is() )
400 {
401 Any aAny;
402 // insert style mode?
403 OUString sStyleInsertModeFamilies("StyleInsertModeFamilies");
404 if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeFamilies) )
405 {
406 aAny = xImportInfo->getPropertyValue(sStyleInsertModeFamilies);
407 Sequence< OUString> aFamiliesSeq;
408 if( aAny >>= aFamiliesSeq )
409 {
410 SfxStyleFamily nFamilyMask = SfxStyleFamily::None;
411 for( const OUString& rFamily : std::as_const(aFamiliesSeq) )
412 {
413 if( rFamily=="FrameStyles" )
414 nFamilyMask |= SfxStyleFamily::Frame;
415 else if( rFamily=="PageStyles" )
416 nFamilyMask |= SfxStyleFamily::Page;
417 else if( rFamily=="CharacterStyles" )
418 nFamilyMask |= SfxStyleFamily::Char;
419 else if( rFamily=="ParagraphStyles" )
420 nFamilyMask |= SfxStyleFamily::Para;
421 else if( rFamily=="NumberingStyles" )
422 nFamilyMask |= SfxStyleFamily::Pseudo;
423 }
424
425 bool bOverwrite = false;
426 static const OUStringLiteral sStyleInsertModeOverwrite(u"StyleInsertModeOverwrite");
427 if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeOverwrite) )
428 {
429 aAny = xImportInfo->getPropertyValue(sStyleInsertModeOverwrite);
430 if( auto b = o3tl::tryAccess<bool>(aAny) )
431 {
432 if( *b )
433 bOverwrite = true;
434 }
435 }
436
437 setStyleInsertMode( nFamilyMask, bOverwrite );
438 }
439 }
440
441 // text insert mode?
442 static const OUStringLiteral sTextInsertModeRange(u"TextInsertModeRange");
443 if( xPropertySetInfo->hasPropertyByName(sTextInsertModeRange) )
444 {
445 aAny = xImportInfo->getPropertyValue(sTextInsertModeRange);
446 Reference<XTextRange> xInsertTextRange;
447 if( aAny >>= xInsertTextRange )
448 setTextInsertMode( xInsertTextRange );
449 }
450
451 // auto text mode
452 static const OUStringLiteral sAutoTextMode(u"AutoTextMode");
453 if( xPropertySetInfo->hasPropertyByName(sAutoTextMode) )
454 {
455 aAny = xImportInfo->getPropertyValue(sAutoTextMode);
456 if( auto b = o3tl::tryAccess<bool>(aAny) )
457 {
458 if( *b )
459 m_bBlock = true;
460 }
461 }
462
463 // organizer mode
464 static const OUStringLiteral sOrganizerMode(u"OrganizerMode");
465 if( xPropertySetInfo->hasPropertyByName(sOrganizerMode) )
466 {
467 aAny = xImportInfo->getPropertyValue(sOrganizerMode);
468 if( auto b = o3tl::tryAccess<bool>(aAny) )
469 {
470 if( *b )
471 m_bOrganizerMode = true;
472 }
473 }
474
475 // default document properties
476 static const OUStringLiteral sDefSettings(u"DefaultDocumentSettings");
477 if (xPropertySetInfo->hasPropertyByName(sDefSettings))
478 {
479 aAny = xImportInfo->getPropertyValue(sDefSettings);
480 Sequence<PropertyValue> aProps;
481 if (aAny >>= aProps)
482 {
483 Reference<lang::XMultiServiceFactory> xFac(GetModel(), UNO_QUERY);
484 Reference<XPropertySet> xProps(
485 xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY);
486 Reference<XPropertySetInfo> xInfo(xProps->getPropertySetInfo());
487
488 if (xProps.is() && xInfo.is())
489 {
490 for (const auto& rProp : std::as_const(aProps))
491 {
492 if (xInfo->hasPropertyByName(rProp.Name))
493 {
494 xProps->setPropertyValue(rProp.Name, rProp.Value);
495 }
496 }
497 }
498 }
499 }
500 }
501
502 // There only is a text cursor by now if we are in insert mode. In any
503 // other case we have to create one at the start of the document.
504 // We also might change into the insert mode later, so we have to make
505 // sure to first set the insert mode and then create the text import
506 // helper. Otherwise it won't have the insert flag set!
507 OTextCursorHelper *pTextCursor = nullptr;
508 Reference < XTextCursor > xTextCursor;
509 if( HasTextImport() )
510 xTextCursor = GetTextImport()->GetCursor();
511 if( !xTextCursor.is() )
512 {
513 Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
514 Reference < XText > xText = xTextDoc->getText();
515 xTextCursor = xText->createTextCursor();
516 SwCursorShell *pCursorSh = nullptr;
517 SwDoc *pDoc = nullptr;
518 if( SvXMLImportFlags::ALL == getImportFlags() )
519 {
520 pTextCursor = lcl_xml_GetSwXTextCursor( xTextCursor );
521 OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
522 if( !pTextCursor )
523 return;
524
525 pDoc = pTextCursor->GetDoc();
526 OSL_ENSURE( pDoc, "SwDoc missing" );
527 if( !pDoc )
528 return;
529
530 // Is there an edit shell. If yes, then we are currently inserting
531 // a document. We then have to insert at the current edit shell's
532 // cursor position. That not quite clean code, but there is no other
533 // way currently.
534 pCursorSh = pDoc->GetEditShell();
535 }
536 if( pCursorSh )
537 {
538 const rtl::Reference<SwXTextRange> xInsertTextRange(
540 *pDoc, *pCursorSh->GetCursor()->GetPoint(), nullptr ) );
541 setTextInsertMode( xInsertTextRange );
542 xTextCursor = GetTextImport()->GetCursor();
543 pTextCursor = nullptr;
544 }
545 else
546 GetTextImport()->SetCursor( xTextCursor );
547 }
548
549 if( !(getImportFlags() & (SvXMLImportFlags::CONTENT|SvXMLImportFlags::MASTERSTYLES)) )
550 return;
551
552 if( !pTextCursor )
553 pTextCursor = lcl_xml_GetSwXTextCursor( xTextCursor );
554 OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
555 if( !pTextCursor )
556 return;
557
558 SwDoc *pDoc = pTextCursor->GetDoc();
559 OSL_ENSURE( pDoc, "SwDoc missing" );
560 if( !pDoc )
561 return;
562
563 if (SvXMLImportFlags::ALL == getImportFlags())
564 {
565 // for flat ODF - this is done in SwReader::Read() for package ODF
566 pDoc->SetInReading(true);
567 pDoc->SetInXMLImport(true);
568 }
569
570 if( (getImportFlags() & SvXMLImportFlags::CONTENT) && !IsStylesOnlyMode() )
571 {
572 m_oSttNdIdx.emplace( pDoc->GetNodes() );
573 if( IsInsertMode() )
574 {
575 SwPaM *pPaM = pTextCursor->GetPaM();
576 const SwPosition* pPos = pPaM->GetPoint();
577
578 // Split once and remember the node that has been split.
579 pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
580 *m_oSttNdIdx = pPos->GetNodeIndex()-1;
581
582 // Split again.
583 pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
584
585 // Insert all content into the new node
586 pPaM->Move( fnMoveBackward );
589 }
590 }
591
592 // We need a draw model to be able to set the z order
593 pDoc->getIDocumentDrawModelAccess().GetOrCreateDrawModel(); // #i52858# - method name changed
594
595 // SJ: #i49801# locking the model to disable repaints
597 if ( pDrawModel )
598 pDrawModel->setLock(true);
599
600 if (!GetGraphicStorageHandler().is())
601 {
602 m_xGraphicStorageHandler = SvXMLGraphicHelper::Create(SvXMLGraphicHelperMode::Read);
603 SetGraphicStorageHandler(m_xGraphicStorageHandler);
604 }
605
606 if( !GetEmbeddedResolver().is() )
607 {
608 SfxObjectShell *pPersist = pDoc->GetPersist();
609 if( pPersist )
610 {
612 *pPersist,
613 SvXMLEmbeddedObjectHelperMode::Read );
614 SetEmbeddedResolver( m_xEmbeddedResolver );
615 }
616 }
617}
618
620{
621 OSL_ENSURE( GetModel().is(), "model missing; maybe startDocument wasn't called?" );
622 if( !GetModel().is() )
623 return;
624
625 // this method will modify the document directly -> lock SolarMutex
626 SolarMutexGuard aGuard;
627
629 m_xGraphicStorageHandler->dispose();
631
633 m_xEmbeddedResolver->dispose();
634 m_xEmbeddedResolver.clear();
635 // Clear the shape import to sort the shapes (and not in the
636 // destructor that might be called after the import has finished
637 // for Java filters.
638 if( HasShapeImport() )
639 ClearShapeImport();
640
641 SwDoc *pDoc = nullptr;
642 if( (getImportFlags() & SvXMLImportFlags::CONTENT) && !IsStylesOnlyMode() )
643 {
644 Reference<XUnoTunnel> xCursorTunnel( GetTextImport()->GetCursor(),
645 UNO_QUERY);
646 assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor");
647 OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel);
648 assert(pTextCursor && "SwXTextCursor missing");
649 SwPaM *pPaM = pTextCursor->GetPaM();
650 if( IsInsertMode() && m_oSttNdIdx->GetIndex() )
651 {
652 // If we are in insert mode, join the split node that is in front
653 // of the new content with the first new node. Or in other words:
654 // Revert the first split node.
655 SwTextNode* pTextNode = m_oSttNdIdx->GetNode().GetTextNode();
656 SwNodeIndex aNxtIdx( *m_oSttNdIdx );
657 if( pTextNode && pTextNode->CanJoinNext( &aNxtIdx ) &&
658 m_oSttNdIdx->GetIndex() + 1 == aNxtIdx.GetIndex() )
659 {
660 // If the PaM points to the first new node, move the PaM to the
661 // end of the previous node.
662 if( pPaM->GetPoint()->GetNode() == aNxtIdx.GetNode() )
663 {
664 pPaM->GetPoint()->Assign( *pTextNode,
665 pTextNode->GetText().getLength());
666 }
667
668#if OSL_DEBUG_LEVEL > 0
669 // !!! This should be impossible !!!!
670 OSL_ENSURE( m_oSttNdIdx->GetIndex()+1 !=
671 pPaM->GetBound().GetNodeIndex(),
672 "PaM.Bound1 point to new node " );
673 OSL_ENSURE( m_oSttNdIdx->GetIndex()+1 !=
674 pPaM->GetBound( false ).GetNodeIndex(),
675 "PaM.Bound2 points to new node" );
676
677 if( m_oSttNdIdx->GetIndex()+1 ==
678 pPaM->GetBound().GetNodeIndex() )
679 {
680 const sal_Int32 nCntPos =
681 pPaM->GetBound().GetContentIndex();
682 pPaM->GetBound().SetContent(
683 pTextNode->GetText().getLength() + nCntPos );
684 }
685 if( m_oSttNdIdx->GetIndex()+1 ==
686 pPaM->GetBound( false ).GetNodeIndex() )
687 {
688 const sal_Int32 nCntPos =
689 pPaM->GetBound( false ).GetContentIndex();
690 pPaM->GetBound( false ).SetContent(
691 pTextNode->GetText().getLength() + nCntPos );
692 }
693#endif
694 // If the first new node isn't empty, convert the node's text
695 // attributes into hints. Otherwise, set the new node's
696 // paragraph style at the previous (empty) node.
697 SwTextNode* pDelNd = aNxtIdx.GetNode().GetTextNode();
698 if (!pTextNode->GetText().isEmpty())
699 pDelNd->FormatToTextAttr( pTextNode );
700 else
701 {
703 pTextNode->ChgFormatColl( pDelNd->GetTextColl() );
704 if (!pDelNd->GetNoCondAttr(RES_PARATR_LIST_ID, /*bInParents=*/false))
705 {
706 // MergeListsAtDocumentInsertPosition() will deal with lists below, copy
707 // paragraph direct formatting otherwise.
708 pDelNd->CopyCollFormat(*pTextNode);
709 }
710 }
711 pTextNode->JoinNext();
712 }
713 }
714
715 SwPosition* pPos = pPaM->GetPoint();
716 OSL_ENSURE( !pPos->GetContentIndex(), "last paragraph isn't empty" );
717 if( !pPos->GetContentIndex() )
718 {
719 SwTextNode* pCurrNd;
720 SwNodeOffset nNodeIdx = pPos->GetNodeIndex();
721 pDoc = &pPaM->GetDoc();
722
723 OSL_ENSURE( pPos->GetNode().IsContentNode(),
724 "insert position is not a content node" );
725 if( !IsInsertMode() )
726 {
727 // If we're not in insert mode, the last node is deleted.
728 const SwNode *pPrev = pDoc->GetNodes()[nNodeIdx -1];
729 if( pPrev->IsContentNode() ||
730 ( pPrev->IsEndNode() &&
731 pPrev->StartOfSectionNode()->IsSectionNode() ) )
732 {
733 SwContentNode* pCNd = pPaM->GetPointContentNode();
734 if( pCNd && pCNd->StartOfSectionIndex()+2 <
735 pCNd->EndOfSectionIndex() )
736 {
737 SwNode& rDelNode = pPaM->GetPoint()->GetNode();
738 // move so we don't have a dangling SwContentIndex to the deleted node
739 pPaM->GetPoint()->Adjust(SwNodeOffset(+1));
740 if (pPaM->HasMark())
741 pPaM->GetMark()->Adjust(SwNodeOffset(+1));
742 pDoc->GetNodes().Delete( rDelNode );
743 }
744 }
745 }
746 else if( nullptr != (pCurrNd = pDoc->GetNodes()[nNodeIdx]->GetTextNode()) )
747 {
748 // Id we're in insert mode, the empty node is joined with
749 // the next and the previous one.
750 if( pCurrNd->CanJoinNext( pPos ))
751 {
752 SwTextNode* pNextNd = pPos->GetNode().GetTextNode();
753 bool endNodeFound = pDoc->GetNodes()[nNodeIdx-1]->IsEndNode();
754 SwNode *pLastPar = pDoc->GetNodes()[nNodeIdx -2];
755 if ( !pLastPar->IsTextNode() ) {
756 pLastPar = pDoc->GetNodes()[nNodeIdx -1];
757 }
758 if ( !endNodeFound && pLastPar->IsTextNode() )
759 {
760 pNextNd->ChgFormatColl(pLastPar->GetTextNode()->GetTextColl());
761 }
762
763 pPaM->SetMark(); pPaM->DeleteMark();
764 pNextNd->JoinPrev();
765
766 // Remove line break that has been inserted by the import,
767 // but only if one has been inserted and
768 // no endNode found to avoid removing section
769 if( pNextNd->CanJoinPrev(/* &pPos->nNode*/ ) && !endNodeFound &&
770 *m_oSttNdIdx != pPos->GetNode() )
771 {
772 pNextNd->JoinPrev();
773 }
774 }
775 else if (pCurrNd->GetText().isEmpty())
776 {
777 pPaM->SetMark(); pPaM->DeleteMark();
778 SwNode& rDelNode = pPos->GetNode();
779 // move so we don't have a dangling SwContentIndex to the deleted node
780 pPaM->GetPoint()->Adjust(SwNodeOffset(+1));
781 pDoc->GetNodes().Delete( rDelNode );
782 pPaM->Move( fnMoveBackward );
783 }
784 }
785
786 // tdf#113877
787 // when we insert one document with list inside into another one with list at the insert position,
788 // the resulting numbering in these lists is not consequent.
789 //
790 // Main document:
791 // 1. One
792 // 2. Two
793 // 3. Three
794 // 4. <-- insert position
795 //
796 // Inserted document:
797 // 1. One
798 // 2. Two
799 // 3. Three
800 // 4.
801 //
802 // Expected result
803 // 1. One
804 // 2. Two
805 // 3. Three
806 // 4. One
807 // 5. Two
808 // 6. Three
809 // 7.
810 //
812 }
813 }
814
815 /* Was called too early. Moved from SwXMLBodyContext_Impl::EndElement */
816
817 GetTextImport()->RedlineAdjustStartNodeCursor();
818
819 if( (getImportFlags() & SvXMLImportFlags::CONTENT) ||
820 ((getImportFlags() & SvXMLImportFlags::MASTERSTYLES) && IsStylesOnlyMode()) )
821 {
822 // pDoc might be 0. In this case UpdateTextCollCondition is looking
823 // for it itself.
825 }
826
827 GetTextImport()->ResetCursor();
828
829 m_oSttNdIdx.reset();
830
831 // tdf#150753: pDoc may be null e.g. when the package lacks content.xml;
832 // we should not forget to tidy up here, including unlocking draw model
833 if (!pDoc)
834 pDoc = getDoc();
835 assert(pDoc);
836 // SJ: #i49801# -> now permitting repaints
837 if (getImportFlags() == SvXMLImportFlags::ALL)
838 {
839 // Notify math objects. If we are in the package filter this will
840 // be done by the filter object itself
841 if (IsInsertMode())
842 pDoc->PrtOLENotify(false);
843 else if (pDoc->IsOLEPrtNotifyPending())
844 pDoc->PrtOLENotify(true);
845
846 assert(pDoc->IsInReading());
847 assert(pDoc->IsInXMLImport());
848 pDoc->SetInReading(false);
849 pDoc->SetInXMLImport(false);
850 }
851
853 if (pDrawModel)
854 pDrawModel->setLock(false);
855
856 // #i90243#
857 if ( m_bInititedXForms )
858 {
859 Reference< xforms::XFormsSupplier > xFormsSupp( GetModel(), UNO_QUERY );
860 Reference< XNameAccess > xXForms;
861 if ( xFormsSupp.is() )
862 xXForms = xFormsSupp->getXForms().get();
863
864 if ( xXForms.is() )
865 {
866 try
867 {
868 Sequence< beans::PropertyValue > aXFormsSettings;
869
870 const OUString& sXFormsSettingsName( GetXMLToken( XML_XFORM_MODEL_SETTINGS ) );
871 if ( m_xLateInitSettings.is() && m_xLateInitSettings->hasByName( sXFormsSettingsName ) )
872 {
873 OSL_VERIFY( m_xLateInitSettings->getByName( sXFormsSettingsName ) >>= aXFormsSettings );
874 applyXFormsSettings( xXForms, aXFormsSettings );
875 }
876 }
877 catch( const Exception& )
878 {
879 }
880 }
881 }
882
883 for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
884 {
885 if (SwTableNode *const pTableNode = pDoc->GetNodes()[i]->GetTableNode())
886 {
887 if (!pTableNode->GetTable().IsNewModel()
888 && pTableNode->GetTable().CanConvertSubtables())
889 {
890 pTableNode->GetTable().ConvertSubtables();
891 }
892 }
893 // don't skip to the end; nested tables could have subtables too...
894 }
895
896 // delegate to parent: takes care of error handling
897 SvXMLImport::endDocument();
898 ClearTextImport();
899}
900
901// tdf#113877
902// when we insert one document with list inside into another one with list at the insert position,
903// the resulting numbering in these lists is not consequent.
904//
905// CASE-1: Main document:
906// 1. One
907// 2. Two
908// 3. Three
909// 4. <-- insert position
910//
911// Inserted document:
912// 1. One
913// 2. Two
914// 3. Three
915// 4.
916//
917// Expected result
918// 1. One
919// 2. Two
920// 3. Three
921// 4. One
922// 5. Two
923// 6. Three
924// 7.
925//
926// CASE-2: Main document:
927// 1. One
928// 2. Two
929// 3. Three
930// 4. <-- insert position
931//
932// Inserted document:
933// A) One
934// B) Two
935// C) Three
936// D)
937//
938// Expected result
939// 1. One
940// 2. Two
941// 3. Three
942// 4. One
943// A) Two
944// B) Three
945// 5.
946//
948{
949 // 1. check environment
950 if (! pDoc)
951 return;
952
953 if (! IsInsertMode() || ! m_oSttNdIdx->GetIndex())
954 return;
955
957
958 // the last node of the main document where we have inserted a document
959 SwNode* const node1 = pDoc->GetNodes()[m_oSttNdIdx->GetIndex() + 0];
960
961 // the first node of the inserted document
962 SwNode* node2 = pDoc->GetNodes()[m_oSttNdIdx->GetIndex() + index];
963
964 if (! (node1 && node2
965 && (node1->GetNodeType() == node2->GetNodeType())
966 && (node1->IsTextNode() == node2->IsTextNode())
967 ))
968 {
969 // not a text node at insert position
970 return;
971 }
972
973 // 2. get the first node of the inserted document,
974 // which will be used to detect if inside inserted document a new list was started after the first list
975 const SfxPoolItem* pListId2Initial = nullptr;
976 {
977 SwContentNode* contentNode1 = static_cast<SwContentNode *>(node1);
978 SwContentNode* contentNode2 = static_cast<SwContentNode *>(node2);
979
980 // check if both lists have the same list properties
981 const SfxPoolItem* pListId1 = contentNode1->GetNoCondAttr( RES_PARATR_LIST_ID, false );
982 const SfxPoolItem* pListId2 = contentNode2->GetNoCondAttr( RES_PARATR_LIST_ID, false );
983
984 if (! pListId1)
985 return;
986 if (! pListId2)
987 return;
988
989 auto pStringListId1 = dynamic_cast<const SfxStringItem*>(pListId1);
990 assert(pStringListId1);
991 const OUString& sListId1 = pStringListId1->GetValue();
992 auto pStringListId2 = dynamic_cast<const SfxStringItem*>(pListId2);
993 assert(pStringListId2);
994 const OUString& sListId2 = pStringListId2->GetValue();
995
996 const SwList* pList1 = pDoc->getIDocumentListsAccess().getListByName( sListId1 );
997 const SwList* pList2 = pDoc->getIDocumentListsAccess().getListByName( sListId2 );
998
999 if (! pList1)
1000 return;
1001 if (! pList2)
1002 return;
1003
1004 const OUString& sDefaultListStyleName1 = pList1->GetDefaultListStyleName();
1005 const OUString& sDefaultListStyleName2 = pList2->GetDefaultListStyleName();
1006
1007 if (sDefaultListStyleName1 != sDefaultListStyleName2)
1008 {
1009 const SwNumRule* pNumRule1 = pDoc->FindNumRulePtr( sDefaultListStyleName1 );
1010 const SwNumRule* pNumRule2 = pDoc->FindNumRulePtr( sDefaultListStyleName2 );
1011
1012 if (pNumRule1 && pNumRule2)
1013 {
1014 // check style of the each list level
1015 for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
1016 {
1017 if( pNumRule1->Get( n ) != pNumRule2->Get( n ) )
1018 {
1019 return;
1020 }
1021 }
1022
1023 // our list should be merged
1024 pListId2Initial = pListId2;
1025 }
1026 }
1027 else
1028 {
1029 // our list should be merged
1030 pListId2Initial = pListId2;
1031 }
1032 }
1033
1034 if (! pListId2Initial)
1035 {
1036 // two lists have different styles => they should not be merged
1037 return;
1038 }
1039
1040 // 3. merge two lists
1041 while (
1042 node1 && node2
1043 && (node1->GetNodeType() == node2->GetNodeType())
1044 && (node1->IsTextNode() == node2->IsTextNode())
1045 )
1046 {
1047 SwContentNode* contentNode1 = static_cast<SwContentNode *>( node1 );
1048 SwContentNode* contentNode2 = static_cast<SwContentNode *>( node2 );
1049
1050 const SfxPoolItem* pListId1 = contentNode1->GetNoCondAttr( RES_PARATR_LIST_ID, false );
1051 const SfxPoolItem* pListId2 = contentNode2->GetNoCondAttr( RES_PARATR_LIST_ID, false );
1052
1053 if (! pListId1)
1054 return;
1055 if (! pListId2)
1056 return;
1057
1058 if (*pListId2Initial != *pListId2)
1059 {
1060 // no more list items of the first list inside inserted document
1061 return;
1062 }
1063
1064 // set list style to this list element
1065 contentNode2->SetAttr(*pListId1);
1066
1067 // get next item
1068 index++;
1069 if (index >= pDoc->GetNodes().Count())
1070 {
1071 // no more items
1072 return;
1073 }
1074
1075 node2 = pDoc->GetNodes()[m_oSttNdIdx->GetIndex() + index];
1076 }
1077}
1078
1079namespace {
1080
1081// Locally derive XMLTextShapeImportHelper, so we can take care of the
1082// form import This is Writer, but not text specific, so it should go
1083// here!
1084class SvTextShapeImportHelper : public XMLTextShapeImportHelper
1085{
1086 // hold own reference form import helper, because the SvxImport
1087 // stored in the superclass, from whom we originally got the
1088 // reference, is already destroyed when we want to use it in the
1089 // destructor
1091
1092 // hold reference to the one page (if it exists) for calling startPage()
1093 // and endPage. If !xPage.is(), then this document doesn't have a
1094 // XDrawPage.
1095 Reference<drawing::XDrawPage> xPage;
1096
1097public:
1098 explicit SvTextShapeImportHelper(SvXMLImport& rImp);
1099 virtual ~SvTextShapeImportHelper() override;
1100};
1101
1102}
1103
1104SvTextShapeImportHelper::SvTextShapeImportHelper(SvXMLImport& rImp) :
1106{
1107 Reference<drawing::XDrawPageSupplier> xSupplier(rImp.GetModel(),UNO_QUERY);
1108 if (xSupplier.is())
1109 {
1110 if (rImp.GetFormImport().is())
1111 {
1112 rImp.GetFormImport()->startPage(xSupplier->getDrawPage());
1113 rFormImport = rImp.GetFormImport();
1114 }
1115
1116 xPage = xSupplier->getDrawPage();
1118 }
1119}
1120
1121SvTextShapeImportHelper::~SvTextShapeImportHelper()
1122{
1123 rFormImport->endPage();
1124
1125 if (xPage.is())
1126 {
1128 }
1129}
1130
1132{
1133 return new SwXMLTextImportHelper( GetModel(), *this, getImportInfo(),
1134 IsInsertMode(),
1137}
1138
1140{
1141 return new SvTextShapeImportHelper( *this );
1142}
1143
1145{
1146 XMLFontStylesContext *pFSContext =
1147 new XMLFontStylesContext( *this, osl_getThreadTextEncoding() );
1148 SetFontDecls( pFSContext );
1149 return pFSContext;
1150}
1151
1152void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps)
1153{
1154 if (IsInsertMode() || IsStylesOnlyMode() || IsBlockMode() || m_bOrganizerMode || !GetModel().is() )
1155 return;
1156
1157 // this method will modify the document directly -> lock SolarMutex
1158 SolarMutexGuard aGuard;
1159
1160 SwDoc *pDoc = getDoc();
1161 tools::Rectangle aRect;
1162 if( pDoc->GetDocShell() )
1163 aRect = pDoc->GetDocShell()->GetVisArea( ASPECT_CONTENT );
1164 //TODO/LATER: why that cast?!
1165 //aRect = ((SfxInPlaceObject *)pDoc->GetDocShell())->GetVisArea();
1166
1167 sal_Int64 nTmp = 0;
1168 bool bShowRedlineChanges = false, bBrowseMode = false;
1169 bool bChangeShowRedline = false, bChangeBrowseMode = false;
1170
1171 //TODO/LATER: why that cast?!
1172 bool bTwip = pDoc->GetDocShell()->GetMapUnit ( ) == MapUnit::MapTwip;
1173 //sal_Bool bTwip = pDoc->GetDocShell()->SfxInPlaceObject::GetMapUnit ( ) == MapUnit::MapTwip;
1174
1175 for (const PropertyValue& rValue : aViewProps)
1176 {
1177 if ( rValue.Name == "ViewAreaTop" )
1178 {
1179 rValue.Value >>= nTmp;
1180 aRect.SetPosY(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
1181 }
1182 else if ( rValue.Name == "ViewAreaLeft" )
1183 {
1184 rValue.Value >>= nTmp;
1185 aRect.SetPosX(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
1186 }
1187 else if ( rValue.Name == "ViewAreaWidth" )
1188 {
1189 rValue.Value >>= nTmp;
1190 Size aSize( aRect.GetSize() );
1191 aSize.setWidth(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
1192 aRect.SetSize( aSize );
1193 }
1194 else if ( rValue.Name == "ViewAreaHeight" )
1195 {
1196 rValue.Value >>= nTmp;
1197 Size aSize( aRect.GetSize() );
1198 aSize.setHeight(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
1199 aRect.SetSize( aSize );
1200 }
1201 else if ( rValue.Name == "ShowRedlineChanges" )
1202 {
1203 bShowRedlineChanges = *o3tl::doAccess<bool>(rValue.Value);
1204 bChangeShowRedline = true;
1205 }
1206// Headers and footers are not displayed in BrowseView anymore
1207 else if ( rValue.Name == "InBrowseMode" )
1208 {
1209 bBrowseMode = *o3tl::doAccess<bool>(rValue.Value);
1210 bChangeBrowseMode = true;
1211 }
1212 }
1213 if( pDoc->GetDocShell() )
1214 pDoc->GetDocShell()->SetVisArea ( aRect );
1215
1216 if (bChangeBrowseMode)
1218
1219 if (bChangeShowRedline)
1220 GetTextImport()->SetShowChanges( bShowRedlineChanges );
1221}
1222
1223// Note: this will be called only if there are OOo elements in settings.xml.
1224// So if a setting is missing there we can assume that it was written
1225// by an OOo/LO version that is older than the introduction of the setting!
1226void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aConfigProps)
1227{
1228 // this method will modify the document directly -> lock SolarMutex
1229 SolarMutexGuard aGuard;
1230
1231 Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
1232 if( !xFac.is() )
1233 return;
1234
1235 Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
1236 if( !xProps.is() )
1237 return;
1238
1239 Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
1240 if( !xInfo.is() )
1241 return;
1242
1243 std::unordered_set< OUString > aExcludeAlways;
1244 aExcludeAlways.insert("LinkUpdateMode");
1245 // this should contain things that are actually user-settable, via Tools->Options
1246 std::unordered_set< OUString > aExcludeWhenNotLoadingUserSettings {
1247 "ForbiddenCharacters",
1248 "IsKernAsianPunctuation",
1249 "CharacterCompressionType",
1250 "FieldAutoUpdate",
1251 "ChartAutoUpdate",
1252 "AddParaTableSpacing",
1253 "AddParaTableSpacingAtStart",
1254 "PrintAnnotationMode",
1255 "PrintBlackFonts",
1256 "PrintControls",
1257 "PrintDrawings",
1258 "PrintGraphics",
1259 "PrintHiddenText",
1260 "PrintLeftPages",
1261 "PrintPageBackground",
1262 "PrintProspect",
1263 "PrintReversed",
1264 "PrintRightPages",
1265 "PrintFaxName",
1266 "PrintPaperFromSetup",
1267 "PrintTables",
1268 "PrintTextPlaceholder",
1269 "PrintSingleJobs",
1270 "UpdateFromTemplate",
1271 "PrinterIndependentLayout",
1272 "PrintEmptyPages",
1273 "ConsiderTextWrapOnObjPos",
1274 "DoNotJustifyLinesWithManualBreak",
1275 "ProtectForm",
1276 "MsWordCompTrailingBlanks",
1277 "SubtractFlysAnchoredAtFlys",
1278 "EmptyDbFieldHidesPara"
1279 };
1280
1281 bool bAreUserSettingsFromDocument = officecfg::Office::Common::Load::UserDefinedSettings::get();
1282
1283 // for some properties we don't want to use the application
1284 // default if they're missing. So we watch for them in the loop
1285 // below, and set them if not found
1286 bool bPrinterIndependentLayout = false;
1287 bool bUseOldNumbering = false;
1288 bool bAddExternalLeading = false;
1289 bool bAddParaSpacingToTableCells = false;
1290 bool bAddParaLineSpacingToTableCells = false;
1291 bool bUseFormerLineSpacing = false;
1292 bool bUseFormerObjectPositioning = false;
1293 bool bUseFormerTextWrapping = false;
1294 bool bConsiderWrapOnObjPos = false;
1295 bool bIgnoreFirstLineIndentInNumbering = false;
1296 bool bDoNotJustifyLinesWithManualBreak = false;
1297 bool bDoNotResetParaAttrsForNumFont = false;
1298 bool bDoNotCaptureDrawObjsOnPage( false );
1299 bool bClipAsCharacterAnchoredWriterFlyFrames( false );
1300 bool bUnixForceZeroExtLeading = false;
1301 bool bSmallCapsPercentage66 = false;
1302 bool bTabOverflow = false;
1303 bool bTabOverMarginValue = false;
1304 bool bPropLineSpacingShrinksFirstLine = false;
1305 bool bSubtractFlysAnchoredAtFlys = false;
1306 bool bEmptyDbFieldHidesPara = false;
1307 bool bCollapseEmptyCellPara = false;
1308 bool bAutoFirstLineIndentDisregardLineSpace = false;
1309 bool bDropCapPunctuation = false;
1310
1311 const PropertyValue* currentDatabaseDataSource = nullptr;
1312 const PropertyValue* currentDatabaseCommand = nullptr;
1313 const PropertyValue* currentDatabaseCommandType = nullptr;
1314 const PropertyValue* embeddedDatabaseName = nullptr;
1315
1316 for( const PropertyValue& rValue : aConfigProps )
1317 {
1318 bool bSet = aExcludeAlways.find(rValue.Name) == aExcludeAlways.end();
1319 if( bSet && !bAreUserSettingsFromDocument
1320 && (aExcludeWhenNotLoadingUserSettings.find(rValue.Name)
1321 != aExcludeWhenNotLoadingUserSettings.end()) )
1322 {
1323 bSet = false;
1324 }
1325
1326 if( bSet )
1327 {
1328 try
1329 {
1330 if( xInfo->hasPropertyByName( rValue.Name ) )
1331 {
1332 if( rValue.Name == "RedlineProtectionKey" )
1333 {
1334 Sequence<sal_Int8> aKey;
1335 rValue.Value >>= aKey;
1336 GetTextImport()->SetChangesProtectionKey( aKey );
1337 }
1338 else
1339 {
1340 // HACK: Setting these out of order does not work.
1341 if( rValue.Name == "CurrentDatabaseDataSource" )
1342 currentDatabaseDataSource = &rValue;
1343 else if( rValue.Name == "CurrentDatabaseCommand" )
1344 currentDatabaseCommand = &rValue;
1345 else if( rValue.Name == "CurrentDatabaseCommandType" )
1346 currentDatabaseCommandType = &rValue;
1347 else if (rValue.Name == "EmbeddedDatabaseName")
1348 embeddedDatabaseName = &rValue;
1349 else
1350 xProps->setPropertyValue( rValue.Name, rValue.Value );
1351 }
1352 }
1353
1354 // did we find any of the non-default cases?
1355 if ( rValue.Name == "PrinterIndependentLayout" )
1356 bPrinterIndependentLayout = true;
1357 else if ( rValue.Name == "AddExternalLeading" )
1358 bAddExternalLeading = true;
1359 else if ( rValue.Name == "AddParaSpacingToTableCells" )
1360 bAddParaSpacingToTableCells = true;
1361 else if ( rValue.Name == "AddParaLineSpacingToTableCells" )
1362 bAddParaLineSpacingToTableCells = true;
1363 else if ( rValue.Name == "UseFormerLineSpacing" )
1364 bUseFormerLineSpacing = true;
1365 else if ( rValue.Name == "UseFormerObjectPositioning" )
1366 bUseFormerObjectPositioning = true;
1367 else if ( rValue.Name == "UseFormerTextWrapping" )
1368 bUseFormerTextWrapping = true;
1369 else if ( rValue.Name == "UseOldNumbering" )
1370 bUseOldNumbering = true;
1371 else if ( rValue.Name == "ConsiderTextWrapOnObjPos" )
1372 bConsiderWrapOnObjPos = true;
1373 else if ( rValue.Name == "IgnoreFirstLineIndentInNumbering" )
1374 bIgnoreFirstLineIndentInNumbering = true;
1375 else if ( rValue.Name == "DoNotJustifyLinesWithManualBreak" )
1376 bDoNotJustifyLinesWithManualBreak = true;
1377 else if ( rValue.Name == "DoNotResetParaAttrsForNumFont" )
1378 bDoNotResetParaAttrsForNumFont = true;
1379 else if ( rValue.Name == "DoNotCaptureDrawObjsOnPage" )
1380 bDoNotCaptureDrawObjsOnPage = true;
1381 else if ( rValue.Name == "ClipAsCharacterAnchoredWriterFlyFrames" )
1382 bClipAsCharacterAnchoredWriterFlyFrames = true;
1383 else if ( rValue.Name == "UnxForceZeroExtLeading" )
1384 bUnixForceZeroExtLeading = true;
1385 else if ( rValue.Name == "SmallCapsPercentage66" )
1386 bSmallCapsPercentage66 = true;
1387 else if ( rValue.Name == "TabOverflow" )
1388 bTabOverflow = true;
1389 else if ( rValue.Name == "TabOverMargin" )
1390 {
1391 rValue.Value >>= bTabOverMarginValue;
1392 }
1393 else if ( rValue.Name == "PropLineSpacingShrinksFirstLine" )
1394 bPropLineSpacingShrinksFirstLine = true;
1395 else if (rValue.Name == "SubtractFlysAnchoredAtFlys")
1396 bSubtractFlysAnchoredAtFlys = true;
1397 else if (rValue.Name == "EmptyDbFieldHidesPara")
1398 bEmptyDbFieldHidesPara = true;
1399 else if (rValue.Name == "CollapseEmptyCellPara")
1400 bCollapseEmptyCellPara = true;
1401 else if (rValue.Name == "AutoFirstLineIndentDisregardLineSpace")
1402 bAutoFirstLineIndentDisregardLineSpace = true;
1403 else if ( rValue.Name == "DropCapPunctuation" )
1404 bDropCapPunctuation = true;
1405 }
1406 catch( Exception& )
1407 {
1408 TOOLS_WARN_EXCEPTION( "sw", "SwXMLImport::SetConfigurationSettings" );
1409 }
1410 }
1411 }
1412
1413 try
1414 {
1415 if( currentDatabaseDataSource != nullptr )
1416 xProps->setPropertyValue( currentDatabaseDataSource->Name, currentDatabaseDataSource->Value );
1417 if( currentDatabaseCommand != nullptr )
1418 xProps->setPropertyValue( currentDatabaseCommand->Name, currentDatabaseCommand->Value );
1419 if( currentDatabaseCommandType != nullptr )
1420 xProps->setPropertyValue( currentDatabaseCommandType->Name, currentDatabaseCommandType->Value );
1421 if (embeddedDatabaseName)
1422 xProps->setPropertyValue(embeddedDatabaseName->Name, embeddedDatabaseName->Value);
1423 } catch( Exception& )
1424 {
1425 TOOLS_WARN_EXCEPTION( "sw", "SwXMLImport::SetConfigurationSettings" );
1426 }
1427
1428 // finally, treat the non-default cases
1429 // introduce boolean, that indicates a document, written by version prior SO8.
1430 // If user settings are not loaded, we can't know if this is an old document. Better to assume no?
1431 const bool bDocumentPriorSO8 = !bConsiderWrapOnObjPos && bAreUserSettingsFromDocument;
1432
1433 // Use old behaviour if this setting didn't exist, but only if this setting is being read from the document.
1434 // (Obviously the setting doesn't exist if we are explicitly ignoring it, so then stick with program/user defaults)
1435 if(!bPrinterIndependentLayout && bAreUserSettingsFromDocument)
1436 {
1437 xProps->setPropertyValue( "PrinterIndependentLayout", Any(sal_Int16(document::PrinterIndependentLayout::DISABLED)) );
1438 }
1439
1440 if( ! bAddExternalLeading )
1441 {
1442 xProps->setPropertyValue( "AddExternalLeading", Any( false ) );
1443 }
1444
1445 if( ! bUseFormerLineSpacing )
1446 {
1447 xProps->setPropertyValue( "UseFormerLineSpacing", Any( true ) );
1448 }
1449
1450 if( !bUseFormerObjectPositioning )
1451 {
1452 xProps->setPropertyValue( "UseFormerObjectPositioning", Any( true ) );
1453 }
1454
1455 if( !bUseOldNumbering )
1456 {
1457 xProps->setPropertyValue( "UseOldNumbering", Any(true) );
1458 }
1459
1460 if( !bAddParaSpacingToTableCells )
1461 {
1462 xProps->setPropertyValue( "AddParaSpacingToTableCells",
1463 Any( false ) );
1464 }
1465 if (!bAddParaLineSpacingToTableCells)
1466 {
1467 xProps->setPropertyValue("AddParaLineSpacingToTableCells", Any(false));
1468 }
1469
1470 if( !bUseFormerTextWrapping )
1471 {
1472 xProps->setPropertyValue( "UseFormerTextWrapping", Any( true ) );
1473 }
1474
1475 if (!bConsiderWrapOnObjPos && bAreUserSettingsFromDocument)
1476 {
1477 xProps->setPropertyValue( "ConsiderTextWrapOnObjPos", Any( false ) );
1478 }
1479
1480 // #i47448#
1481 // For SO7pp4, part of the 'new numbering' stuff has been backported from
1482 // SO8. Unfortunately, only part of it and by using the same compatibility option
1483 // like in SO8. Therefore documents generated with SO7pp4, containing
1484 // numbered paragraphs with first line indent differ between SO7pp4 and
1485 // SO8. In order to fix this for SO8pp1, I introduce a new compatibility
1486 // flag 'bIgnoreFirstLineIndentInNumbering'. This flag has to be set for all
1487 // documents < SO8, but not for SO8. So if the property is not present, the
1488 // flag will be set to 'true'. SO8 documents surely have the
1489 // 'ConsiderWrapOnObjPos' property set (no matter if 'true' or 'false'),
1490 // therefore the correct condition to set this flag is this:
1491 if( !bIgnoreFirstLineIndentInNumbering && bDocumentPriorSO8 )
1492 {
1493 xProps->setPropertyValue( "IgnoreFirstLineIndentInNumbering",
1494 Any( true ) );
1495 }
1496
1497 // This flag has to be set for all documents < SO8
1498 if ( !bDoNotJustifyLinesWithManualBreak && bDocumentPriorSO8 )
1499 {
1500 xProps->setPropertyValue( "DoNotJustifyLinesWithManualBreak",
1501 Any( true ) );
1502 }
1503
1504 // This flag has to be set for all documents < SO8
1505 if ( !bDoNotResetParaAttrsForNumFont && bDocumentPriorSO8 )
1506 {
1507 xProps->setPropertyValue( "DoNotResetParaAttrsForNumFont",
1508 Any( true ) );
1509 }
1510
1511 // This flag has to be set for all documents < SO8
1512 if ( !bDoNotCaptureDrawObjsOnPage && bDocumentPriorSO8 )
1513 {
1514 xProps->setPropertyValue( "DoNotCaptureDrawObjsOnPage",
1515 Any( true ) );
1516 }
1517
1518 // This flag has to be set for all documents < SO8
1519 if ( !bClipAsCharacterAnchoredWriterFlyFrames && bDocumentPriorSO8 )
1520 {
1521 xProps->setPropertyValue( "ClipAsCharacterAnchoredWriterFlyFrames",
1522 Any( true ) );
1523 }
1524
1525 if ( !bUnixForceZeroExtLeading )
1526 {
1527 xProps->setPropertyValue( "UnxForceZeroExtLeading", Any( true ) );
1528 }
1529
1530 // Old LO versions had 66 as the value for small caps percentage, later changed to 80.
1531 // In order to keep backwards compatibility, SmallCapsPercentage66 option is written to .odt
1532 // files, and the default for new documents is 'false'. Files without this option
1533 // are considered to be old files, so set the compatibility option too.
1534 if ( !bSmallCapsPercentage66 )
1535 {
1536 xProps->setPropertyValue( "SmallCapsPercentage66", Any( true ) );
1537 }
1538
1539 if ( !bTabOverflow )
1540 {
1541 xProps->setPropertyValue( "TabOverflow", Any( false ) );
1542 }
1543
1544 if (bTabOverMarginValue)
1545 // Let TabOverMargin imply the new default for
1546 // PrinterIndependentLayout, knowing the first is set by Word import
1547 // filters and Word defaults to our new default as well.
1548 xProps->setPropertyValue(
1549 "PrinterIndependentLayout",
1550 uno::Any(document::PrinterIndependentLayout::HIGH_RESOLUTION));
1551
1552 if (!bPropLineSpacingShrinksFirstLine)
1553 xProps->setPropertyValue("PropLineSpacingShrinksFirstLine", Any(false));
1554
1555 if (!bSubtractFlysAnchoredAtFlys && bAreUserSettingsFromDocument)
1556 xProps->setPropertyValue("SubtractFlysAnchoredAtFlys", Any(true));
1557
1558 if (!bEmptyDbFieldHidesPara && bAreUserSettingsFromDocument)
1559 xProps->setPropertyValue("EmptyDbFieldHidesPara", Any(false));
1560
1561 if (!bCollapseEmptyCellPara)
1562 xProps->setPropertyValue("CollapseEmptyCellPara", Any(false));
1563
1564 if (!bAutoFirstLineIndentDisregardLineSpace)
1565 xProps->setPropertyValue("AutoFirstLineIndentDisregardLineSpace", Any(false));
1566
1567 // LO 7.4 and previous versions had different drop cap punctuation: very long dashes.
1568 // In order to keep backwards compatibility, DropCapPunctuation option is written to .odt
1569 // files, and the default for new documents is 'true'. Files without this option
1570 // are considered to be old files, so set the compatibility option too.
1571 if ( !bDropCapPunctuation )
1572 {
1573 xProps->setPropertyValue( "DropCapPunctuation", Any( false ) );
1574 }
1575
1576 SwDoc *pDoc = getDoc();
1577 SfxPrinter *pPrinter = pDoc->getIDocumentDeviceAccess().getPrinter( false );
1578 if( pPrinter )
1579 {
1580 // If the printer is known, then the OLE objects will
1581 // already have correct sizes, and we don't have to call
1582 // PrtOLENotify again. Otherwise we have to call it.
1583 // The flag might be set from setting the printer, so it
1584 // it is required to clear it.
1585 pDoc->SetOLEPrtNotifyPending( !pPrinter->IsKnown() );
1586 }
1587}
1588
1590 const OUString& _rSettingsGroupName,
1591 const Sequence< PropertyValue>& _rSettings )
1592{
1593 // the only doc-specific settings group we know so far are the XForms settings
1594 if ( !IsXMLToken( _rSettingsGroupName, XML_XFORM_MODEL_SETTINGS ) )
1595 return;
1596
1597 // preserve the settings for a later iteration - we are currently reading the settings.xml,
1598 // the content.xml will be read later, by another instance of SwXMLImport
1599 OSL_ENSURE( m_xLateInitSettings.is(), "SwXMLImport::SetDocumentSpecificSettings: no storage for those settings!" );
1600 if ( !m_xLateInitSettings.is() )
1601 return;
1602
1603 try
1604 {
1605 if ( m_xLateInitSettings->hasByName( _rSettingsGroupName ) )
1606 {
1607 m_xLateInitSettings->replaceByName( _rSettingsGroupName, Any( _rSettings ) );
1608 OSL_FAIL( "SwXMLImport::SetDocumentSpecificSettings: already have settings for this model!" );
1609 }
1610 else
1611 m_xLateInitSettings->insertByName( _rSettingsGroupName, Any( _rSettings ) );
1612 }
1613 catch( const Exception& )
1614 {
1615 }
1616}
1617
1619 const Sequence<Any>& aArguments )
1620{
1621 // delegate to super class
1622 SvXMLImport::initialize(aArguments);
1623
1624 // we are only looking for a NamedValue "LateInitSettings"
1625 for(const auto& rArgument : aArguments)
1626 {
1627 beans::NamedValue aNamedValue;
1628 if ( rArgument >>= aNamedValue )
1629 {
1630 if (aNamedValue.Name == "LateInitSettings")
1631 {
1632 OSL_VERIFY( aNamedValue.Value >>= m_xLateInitSettings );
1633 }
1634 }
1635 }
1636}
1637
1639{
1640 // obtain SwDoc
1641 auto pXTextDocument = comphelper::getFromUnoTunnel<SwXTextDocument>(GetModel());
1642 if( pXTextDocument == nullptr )
1643 return;
1644
1645 SwDoc *pDoc = pXTextDocument->GetDocShell()->GetDoc();
1646
1647 // init XForms (if not already done)
1648 // (no default model, since we'll load the models)
1649 if( ! pDoc->isXForms() )
1650 pDoc->initXForms( false );
1651
1652 m_bInititedXForms = true;
1653}
1654
1656{
1657 if( m_pDoc != nullptr )
1658 return m_pDoc;
1659 Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
1660 Reference < XText > xText = xTextDoc->getText();
1661 Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
1662 assert( xTextTunnel.is());
1663 SwXText* pText = comphelper::getFromUnoTunnel<SwXText>(xTextTunnel);
1664 assert( pText != nullptr );
1665 m_pDoc = pText->GetDoc();
1666 assert( m_pDoc != nullptr );
1667 return m_pDoc;
1668}
1669
1671{
1672 return const_cast< SwXMLImport* >( this )->getDoc();
1673}
1674
1675extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1677 css::uno::Sequence<css::uno::Any> const &)
1678{
1679 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisImporter",
1680 SvXMLImportFlags::ALL));
1681}
1682
1683
1684extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1686 css::uno::Sequence<css::uno::Any> const &)
1687{
1688 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisStylesImporter",
1689 SvXMLImportFlags::STYLES | SvXMLImportFlags::MASTERSTYLES | SvXMLImportFlags::AUTOSTYLES |
1690 SvXMLImportFlags::FONTDECLS));
1691}
1692
1693
1694extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1696 css::uno::Sequence<css::uno::Any> const &)
1697{
1698 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisContentImporter",
1699 SvXMLImportFlags::CONTENT | SvXMLImportFlags::SCRIPTS | SvXMLImportFlags::AUTOSTYLES |
1700 SvXMLImportFlags::FONTDECLS));
1701}
1702
1703extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1705 css::uno::Sequence<css::uno::Any> const &)
1706{
1707 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisMetaImporter",
1708 SvXMLImportFlags::META));
1709}
1710
1711
1712extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1714 css::uno::Sequence<css::uno::Any> const &)
1715{
1716 return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisSettingsImporter",
1717 SvXMLImportFlags::SETTINGS));
1718}
1719
1720extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODT(SvStream &rStream)
1721{
1723
1724 SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL));
1725 xDocSh->DoInitNew();
1726 uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
1727
1728 uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
1729 uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
1730 uno::Reference<uno::XInterface> xInterface(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.XmlFilterAdaptor"), uno::UNO_SET_THROW);
1731
1732 css::uno::Sequence<OUString> aUserData
1733 {
1734 "com.sun.star.comp.filter.OdfFlatXml",
1735 "",
1736 "com.sun.star.comp.Writer.XMLOasisImporter",
1737 "com.sun.star.comp.Writer.XMLOasisExporter",
1738 "",
1739 "",
1740 "true"
1741 };
1742 uno::Sequence<beans::PropertyValue> aAdaptorArgs(comphelper::InitPropertySequence(
1743 {
1744 { "UserData", uno::Any(aUserData) },
1745 }));
1746 css::uno::Sequence<uno::Any> aOuterArgs{ uno::Any(aAdaptorArgs) };
1747
1748 uno::Reference<lang::XInitialization> xInit(xInterface, uno::UNO_QUERY_THROW);
1749 xInit->initialize(aOuterArgs);
1750
1751 uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
1752 uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
1753 {
1754 { "InputStream", uno::Any(xStream) },
1755 { "URL", uno::Any(OUString("private:stream")) },
1756 }));
1757 xImporter->setTargetDocument(xModel);
1758
1759 uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
1760 //SetLoading hack because the document properties will be re-initted
1761 //by the xml filter and during the init, while it's considered uninitialized,
1762 //setting a property will inform the document it's modified, which attempts
1763 //to update the properties, which throws cause the properties are uninitialized
1764 xDocSh->SetLoading(SfxLoadedFlags::NONE);
1765 bool ret = xFilter->filter(aArgs);
1766 xDocSh->SetLoading(SfxLoadedFlags::ALL);
1767
1768 xDocSh->DoClose();
1769
1770 return ret;
1771}
1772
1773extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDOCX(SvStream &rStream)
1774{
1776
1777 SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL));
1778 xDocSh->DoInitNew();
1779 uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
1780
1781 uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
1782 uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
1783
1784 uno::Reference<document::XFilter> xFilter(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.WriterFilter"), uno::UNO_QUERY_THROW);
1785
1786 uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
1787 uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
1788 {
1789 { "InputStream", uno::Any(xStream) },
1790 { "InputMode", uno::Any(true) },
1791 }));
1792 xImporter->setTargetDocument(xModel);
1793
1794 //SetLoading hack because the document properties will be re-initted
1795 //by the xml filter and during the init, while it's considered uninitialized,
1796 //setting a property will inform the document it's modified, which attempts
1797 //to update the properties, which throws cause the properties are uninitialized
1798 xDocSh->SetLoading(SfxLoadedFlags::NONE);
1799 bool ret = false;
1800 try
1801 {
1802 ret = xFilter->filter(aArgs);
1803 }
1804 catch (...)
1805 {
1806 }
1807 xDocSh->SetLoading(SfxLoadedFlags::ALL);
1808
1809 xDocSh->DoClose();
1810
1811 return ret;
1812}
1813
1814/* 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
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
bool CanJoinNext(SwNodeIndex *pIdx=nullptr) const
Is it possible to join two nodes? In pIdx the second position can be returned.
Definition: node.cxx:1859
virtual bool SetAttr(const SfxPoolItem &)
made virtual
Definition: node.cxx:1601
bool CanJoinPrev(SwNodeIndex *pIdx=nullptr) const
Can we join two Nodes? We can return the 2nd position in pIdx.
Definition: node.cxx:1907
const SfxPoolItem * GetNoCondAttr(sal_uInt16 nWhich, bool bInParents) const
Obtains attribute that is not delivered via conditional style!
Definition: node.cxx:1819
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
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:194
bool IsInReading() const
Definition: doc.hxx:962
void SetInReading(bool bNew)
Definition: doc.hxx:963
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:244
SwNumRule * FindNumRulePtr(const OUString &rName) const
Definition: docnum.cxx:2441
void SetOLEPrtNotifyPending(bool bSet=true)
Definition: doc.hxx:1700
void PrtOLENotify(bool bAll)
Definition: docdesc.cxx:812
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:321
SwNodes & GetNodes()
Definition: doc.hxx:417
bool IsInXMLImport() const
Definition: doc.hxx:978
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:329
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:182
SfxObjectShell * GetPersist() const
Definition: docnew.cxx:649
void SetInXMLImport(bool bNew)
Definition: doc.hxx:979
void initXForms(bool bCreateDefaultModel)
Definition: docxforms.cxx:49
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:432
bool isXForms() const
Definition: docxforms.cxx:44
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:161
bool IsOLEPrtNotifyPending() const
Definition: doc.hxx:570
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:1081
SwDocShell * GetDocShell()
Definition: doc.hxx:1359
IDocumentListsAccess const & getIDocumentListsAccess() const
Definition: doc.cxx:299
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:136
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:171
Base class of the Writer document model elements.
Definition: node.hxx:98
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:897
bool IsContentNode() const
Definition: node.hxx:677
bool IsEndNode() const
Definition: node.hxx:681
SwNodeOffset StartOfSectionIndex() const
Definition: node.hxx:722
bool IsSectionNode() const
Definition: node.hxx:693
bool IsTextNode() const
Definition: node.hxx:685
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:153
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:726
SwNodeType GetNodeType() const
Definition: node.hxx:166
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
Definition: nodes.cxx:1065
SwNodeOffset Count() const
Definition: ndarr.hxx:142
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:87
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
const SwPosition * GetMark() const
Definition: pam.hxx:263
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:642
SwContentNode * GetPointContentNode() const
Definition: pam.hxx:287
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:668
SwDoc & GetDoc() const
Definition: pam.hxx:299
SwPosition & GetBound(bool bOne=true)
Definition: pam.hxx:301
void DeleteMark()
Definition: pam.hxx:231
const SwPosition * GetPoint() const
Definition: pam.hxx:261
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:259
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
virtual SwContentNode * JoinNext() override
Definition: ndtxt.cxx:1001
void FormatToTextAttr(SwTextNode *pNd)
Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
Definition: thints.cxx:2532
void JoinPrev()
Definition: ndtxt.cxx:1118
virtual SwFormatColl * ChgFormatColl(SwFormatColl *) override
Definition: ndtxt.cxx:4040
void CopyCollFormat(SwTextNode &rDestNd, bool bUndoForChgFormatColl=true)
Copy collection with all auto formats to dest-node.
Definition: ndcopy.cxx:339
const OUString & GetText() const
Definition: ndtxt.hxx:242
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:891
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
Definition: ndtxt.cxx:5259
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:619
rtl::Reference< SvXMLEmbeddedObjectHelper > m_xEmbeddedResolver
Definition: xmlimp.hxx:66
virtual void SetDocumentSpecificSettings(const OUString &_rSettingsGroupName, const css::uno::Sequence< css::beans::PropertyValue > &_rSettings) override
Definition: xmlimp.cxx:1589
const SwDoc * getDoc() const
Definition: xmlimp.cxx:1670
virtual ~SwXMLImport() noexcept override
Definition: xmlimp.cxx:332
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement)
Definition: xmlmeta.cxx:53
css::uno::Reference< css::container::XNameContainer > m_xLateInitSettings
Definition: xmlimp.hxx:73
rtl::Reference< SvXMLGraphicHelper > m_xGraphicStorageHandler
Definition: xmlimp.hxx:64
virtual XMLShapeImportHelper * CreateShapeImport() override
Definition: xmlimp.cxx:1139
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:383
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlimp.cxx:1618
std::optional< SwNodeIndex > m_oSttNdIdx
Definition: xmlimp.hxx:59
bool m_bInititedXForms
Definition: xmlimp.hxx:83
void UpdateTextCollConditions(SwDoc *pDoc)
Definition: xmlfmt.cxx:1006
bool m_bLoadDoc
Definition: xmlimp.hxx:76
void InitItemImport()
Definition: xmlitemi.cxx:225
SfxStyleFamily GetStyleFamilyMask() const
Definition: xmlimp.hxx:136
bool IsBlockMode() const
Definition: xmlimp.hxx:139
virtual void initXForms() override
Definition: xmlimp.cxx:1638
void setTextInsertMode(const css::uno::Reference< css::text::XTextRange > &rInsertPos)
Definition: xmlimp.cxx:345
bool m_bInsert
Definition: xmlimp.hxx:77
virtual XMLTextImportHelper * CreateTextImport() override
Definition: xmlimp.cxx:1131
bool m_bOrganizerMode
Definition: xmlimp.hxx:82
void setStyleInsertMode(SfxStyleFamily nFamilies, bool bOverwrite)
Definition: xmlimp.cxx:356
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Definition: xmlimp.cxx:1152
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() noexcept
Definition: xmlimp.cxx:364
SwDoc * m_pDoc
Definition: xmlimp.hxx:85
void MergeListsAtDocumentInsertPosition(SwDoc *pDoc)
Definition: xmlimp.cxx:947
SvXMLImportContext * CreateBodyContentContext()
Definition: xmltext.cxx:67
bool m_bBlock
Definition: xmlimp.hxx:81
bool IsInsertMode() const
Definition: xmlimp.hxx:137
SfxStyleFamily m_nStyleFamilyMask
Definition: xmlimp.hxx:75
void FinitItemImport()
Definition: xmlitemi.cxx:239
bool IsStylesOnlyMode() const
Definition: xmlimp.hxx:138
SvXMLImportContext * CreateFontDeclsContext()
Definition: xmlimp.cxx:1144
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: xmlimp.cxx:370
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
Definition: xmlimp.cxx:1226
static rtl::Reference< SwXTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1209
const SwDoc * GetDoc() const
Definition: unotext.cxx:134
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
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
@ 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)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
#define ASPECT_CONTENT
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:60
@ RES_POOLCOLL_STANDARD
Standard.
Definition: poolfmt.hxx:250
Marks a position in the document model.
Definition: pam.hxx:37
void Adjust(SwNodeOffset nDelta)
Adjust node position, and resets content position to zero.
Definition: pam.cxx:256
SwNode & GetNode() const
Definition: pam.hxx:80
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
Definition: pam.cxx:230
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
Definition: pam.cxx:266
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:77
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
SfxStyleFamily
Reference< XModel > xModel
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
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:1685
SAL_DLLPUBLIC_EXPORT bool TestImportDOCX(SvStream &rStream)
Definition: xmlimp.cxx:1773
SAL_DLLPUBLIC_EXPORT bool TestImportFODT(SvStream &rStream)
Definition: xmlimp.cxx:1720
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:1704
static OTextCursorHelper * lcl_xml_GetSwXTextCursor(const Reference< XTextCursor > &rTextCursor)
Definition: xmlimp.cxx:376
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:1695
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:1713
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:1676
#define PROGRESS_BAR_STEP
Definition: xmlimp.hxx:49
#define XML_ELEMENT(prefix, name)
SvXMLImportFlags
constexpr sal_Int32 TOKEN_MASK