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