LibreOffice Module sc (master)  1
xmlimprt.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 #include <osl/diagnose.h>
23 
24 #include <svl/zforlist.hxx>
25 
26 #include <xmloff/namespacemap.hxx>
27 #include <xmloff/xmlnamespace.hxx>
28 #include <xmloff/xmltkmap.hxx>
29 #include <xmloff/xmlictxt.hxx>
30 #include <xmloff/xmlmetai.hxx>
31 #include <sfx2/objsh.hxx>
32 #include <unotools/streamwrap.hxx>
33 #include <xmloff/xmlscripti.hxx>
36 #include <xmloff/xmluconv.hxx>
37 #include <xmloff/numehelp.hxx>
38 #include <xmloff/xmltoken.hxx>
39 #include <xmloff/xmlerror.hxx>
41 #include <svx/svdpage.hxx>
42 
43 #include <svl/languageoptions.hxx>
44 #include <editeng/editstat.hxx>
45 #include <formula/errorcodes.hxx>
46 #include <vcl/svapp.hxx>
47 
48 #include <appluno.hxx>
49 #include "xmlimprt.hxx"
50 #include "importcontext.hxx"
51 #include <document.hxx>
52 #include <docsh.hxx>
53 #include <docuno.hxx>
54 #include "xmlbodyi.hxx"
55 #include "xmlstyli.hxx"
57 #include <userdat.hxx>
58 
59 #include <compiler.hxx>
60 
61 #include "XMLConverter.hxx"
62 #include "XMLDetectiveContext.hxx"
65 #include <chgviset.hxx>
67 #include <sheetdata.hxx>
68 #include <rangeutl.hxx>
69 #include <formulaparserpool.hxx>
70 #include <externalrefmgr.hxx>
71 #include <editutil.hxx>
72 #include "editattributemap.hxx"
73 #include <documentimport.hxx>
74 #include "pivotsource.hxx"
75 #include <unonames.hxx>
76 #include <numformat.hxx>
77 #include <sizedev.hxx>
78 #include <scdll.hxx>
79 #include "xmlstyle.hxx"
80 
81 #include <comphelper/base64.hxx>
82 #include <comphelper/extract.hxx>
85 
86 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
87 #include <com/sun/star/frame/XModel.hpp>
88 #include <com/sun/star/io/IOException.hpp>
89 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
90 #include <com/sun/star/document/XActionLockable.hpp>
91 #include <com/sun/star/util/MalformedNumberFormatException.hpp>
92 #include <com/sun/star/util/NumberFormat.hpp>
93 #include <com/sun/star/util/XNumberFormatTypes.hpp>
94 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
95 #include <com/sun/star/sheet/NamedRangeFlag.hpp>
96 #include <com/sun/star/sheet/XLabelRanges.hpp>
97 #include <com/sun/star/io/XSeekable.hpp>
98 #include <com/sun/star/beans/XPropertySet.hpp>
99 #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
100 #include <cellsuno.hxx>
101 
102 #include <memory>
103 #include <utility>
104 
105 #define SC_LOCALE "Locale"
106 #define SC_CURRENCYSYMBOL "CurrencySymbol"
107 #define SC_REPEAT_ROW "repeat-row"
108 #define SC_FILTER "filter"
109 #define SC_PRINT_RANGE "print-range"
110 
111 using namespace com::sun::star;
112 using namespace ::xmloff::token;
113 using namespace ::formula;
114 
115 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
117  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
118 {
119  return cppu::acquire(static_cast<cppu::OWeakObject*>(
120  new ScXMLImport(
121  context,
122  "com.sun.star.comp.Calc.XMLOasisImporter",
123  SvXMLImportFlags::ALL,
124  { "com.sun.star.comp.Calc.XMLOasisImporter" } )));
125 }
126 
127 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
129  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
130 {
131  return cppu::acquire(static_cast<cppu::OWeakObject*>(
132  new ScXMLImport(
133  context,
134  "com.sun.star.comp.Calc.XMLOasisMetaImporter",
135  SvXMLImportFlags::META,
136  { "com.sun.star.comp.Calc.XMLOasisMetaImporter" } )));
137 }
138 
139 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
141  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
142 {
143  return cppu::acquire(static_cast<cppu::OWeakObject*>(
144  new ScXMLImport(
145  context,
146  "com.sun.star.comp.Calc.XMLOasisStylesImporter",
147  SvXMLImportFlags::STYLES|SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::MASTERSTYLES|SvXMLImportFlags::FONTDECLS,
148  { "com.sun.star.comp.Calc.XMLOasisStylesImporter" } )));
149 }
150 
151 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
153  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
154 {
155  return cppu::acquire(static_cast<cppu::OWeakObject*>(new ScXMLImport(
156  context,
157  "com.sun.star.comp.Calc.XMLOasisContentImporter",
158  SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::CONTENT|SvXMLImportFlags::SCRIPTS|SvXMLImportFlags::FONTDECLS,
159  uno::Sequence< OUString > { "com.sun.star.comp.Calc.XMLOasisContentImporter" })));
160 }
161 
162 
163 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
165  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
166 {
167  return cppu::acquire(static_cast<cppu::OWeakObject*>(
168  new ScXMLImport(
169  context,
170  "com.sun.star.comp.Calc.XMLOasisSettingsImporter",
171  SvXMLImportFlags::SETTINGS,
172  { "com.sun.star.comp.Calc.XMLOasisSettingsImporter" } )));
173 }
174 
175 namespace {
176 
177 // NB: virtually inherit so we can multiply inherit properly
178 // in ScXMLFlatDocContext_Impl
179 class ScXMLDocContext_Impl : public virtual SvXMLImportContext
180 {
181 protected:
182  ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
183 
184 public:
185  ScXMLDocContext_Impl( ScXMLImport& rImport );
186 
187  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
188  createFastChildContext( sal_Int32 nElement,
189  const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
190 };
191 
192 }
193 
194 ScXMLDocContext_Impl::ScXMLDocContext_Impl( ScXMLImport& rImport ) :
195 SvXMLImportContext( rImport )
196 {
197 }
198 
199 namespace {
200 
201 // context for flat file xml format
202 class ScXMLFlatDocContext_Impl
203  : public ScXMLDocContext_Impl, public SvXMLMetaDocumentContext
204 {
205 public:
206 
207  ScXMLFlatDocContext_Impl( ScXMLImport& i_rImport,
208  const uno::Reference<document::XDocumentProperties>& i_xDocProps);
209 
210  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
211  createFastChildContext( sal_Int32 nElement,
212  const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
213 };
214 
215 }
216 
217 ScXMLFlatDocContext_Impl::ScXMLFlatDocContext_Impl( ScXMLImport& i_rImport,
218  const uno::Reference<document::XDocumentProperties>& i_xDocProps) :
219 SvXMLImportContext(i_rImport),
220 ScXMLDocContext_Impl(i_rImport),
221 SvXMLMetaDocumentContext(i_rImport, i_xDocProps)
222 {
223 }
224 
225 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
226  ScXMLFlatDocContext_Impl::createFastChildContext( sal_Int32 nElement,
227  const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
228 {
229  if ( nElement == XML_ELEMENT( OFFICE, XML_META ) )
230  return SvXMLMetaDocumentContext::createFastChildContext( nElement, xAttrList );
231  else
232  return ScXMLDocContext_Impl::createFastChildContext( nElement, xAttrList );
233 }
234 
235 namespace {
236 
237 class ScXMLBodyContext_Impl : public ScXMLImportContext
238 {
239 public:
240  ScXMLBodyContext_Impl( ScXMLImport& rImport );
241 
242  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
243  createFastChildContext( sal_Int32 nElement,
244  const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
245 };
246 
247 }
248 
249 ScXMLBodyContext_Impl::ScXMLBodyContext_Impl( ScXMLImport& rImport ) :
250 ScXMLImportContext( rImport )
251 {
252 }
253 
254 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
255  ScXMLBodyContext_Impl::createFastChildContext( sal_Int32 /*nElement*/,
256  const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
257 {
258  sax_fastparser::FastAttributeList *pAttribList =
260  return GetScImport().CreateBodyContext( pAttribList );
261 }
262 
263 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
264  ScXMLDocContext_Impl::createFastChildContext( sal_Int32 nElement,
265  const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList*/ )
266 {
267  SvXMLImportContext *pContext(nullptr);
268 
269  switch( nElement )
270  {
271  case XML_ELEMENT( OFFICE, XML_BODY ):
272  if (GetScImport().getImportFlags() & SvXMLImportFlags::CONTENT)
273  pContext = new ScXMLBodyContext_Impl( GetScImport() );
274  break;
275  case XML_ELEMENT( OFFICE, XML_SCRIPTS ):
276  if (GetScImport().getImportFlags() & SvXMLImportFlags::SCRIPTS)
277  pContext = GetScImport().CreateScriptContext();
278  break;
279  case XML_ELEMENT( OFFICE, XML_SETTINGS ):
280  if (GetScImport().getImportFlags() & SvXMLImportFlags::SETTINGS)
281  pContext = new XMLDocumentSettingsContext(GetScImport());
282  break;
283  case XML_ELEMENT(OFFICE, XML_STYLES):
284  if (GetScImport().getImportFlags() & SvXMLImportFlags::STYLES)
285  pContext = GetScImport().CreateStylesContext( false);
286  break;
287  case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES):
288  if (GetScImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES)
289  pContext = GetScImport().CreateStylesContext( true);
290  break;
291  case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS):
292  if (GetScImport().getImportFlags() & SvXMLImportFlags::FONTDECLS)
293  pContext = GetScImport().CreateFontDeclsContext();
294  break;
295  case XML_ELEMENT(OFFICE, XML_MASTER_STYLES):
296  if (GetScImport().getImportFlags() & SvXMLImportFlags::MASTERSTYLES)
297  pContext = new ScXMLMasterStylesContext( GetImport() );
298  break;
299  case XML_ELEMENT(OFFICE, XML_META):
300  SAL_INFO("sc", "XML_ELEMENT(OFFICE, XML_META): should not have come here, maybe document is invalid?");
301  break;
302  }
303 
304  return pContext;
305 }
306 
307 
309 {
310  mpPostProcessData = p;
311 }
312 
314 {
315  if (!mpPivotSources)
317 
318  return *mpPivotSources;
319 }
320 
322  const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
323 {
324  SvXMLImportContext *pContext = nullptr;
325 
326  switch( nElement )
327  {
331  pContext = new ScXMLDocContext_Impl( *this );
332  break;
333 
335  pContext = CreateMetaContext(nElement);
336  break;
337 
339  {
340  uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
341  GetModel(), uno::UNO_QUERY_THROW);
342  // flat OpenDocument file format
343  pContext = new ScXMLFlatDocContext_Impl( *this,
344  xDPS->getDocumentProperties());
345  break;
346  }
347 
348  }
349 
350  return pContext;
351 }
352 
353 constexpr OUStringLiteral gsNumberFormat(u"" SC_UNONAME_NUMFMT);
354 constexpr OUStringLiteral gsLocale(u"" SC_LOCALE);
355 constexpr OUStringLiteral gsCellStyle(u"" SC_UNONAME_CELLSTYL);
356 
358  const css::uno::Reference< css::uno::XComponentContext >& rContext,
359  OUString const & implementationName, SvXMLImportFlags nImportFlag,
360  const css::uno::Sequence< OUString > & sSupportedServiceNames)
361 : SvXMLImport( rContext, implementationName, nImportFlag, sSupportedServiceNames ),
362  pDoc( nullptr ),
363  mpPostProcessData(nullptr),
364  aTables(*this),
365  sPrevStyleName(),
366  sPrevCurrency(),
367  nSolarMutexLocked(0),
368  nProgressCount(0),
369  nPrevCellType(0),
370  bLoadDoc( true ),
371  bNullDateSetted(false),
372  bSelfImportingXMLSet(false),
373  mbLockSolarMutex(true),
374  mbImportStyles(true),
375  mbHasNewCondFormatData(false)
376 {
378 
384 
385  // #i66550# needed for 'presentation:event-listener' element for URLs in shapes
390 }
391 
393 {
396  pStyleNumberFormats.reset();
397  pStylesImportHelper.reset();
398 
399  m_pMyNamedExpressions.reset();
400  pMyLabelRanges.reset();
401  pValidations.reset();
402  pDetectiveOpArray.reset();
403 
404  //call SvXMLImport dtor contents before deleting pSolarMutexGuard
405  cleanup();
406 
407  pSolarMutexGuard.reset();
408 }
409 
410 void ScXMLImport::initialize( const css::uno::Sequence<css::uno::Any>& aArguments )
411 {
412  SvXMLImport::initialize(aArguments);
413 
414  uno::Reference<beans::XPropertySet> xInfoSet = getImportInfo();
415  if (!xInfoSet.is())
416  return;
417 
418  uno::Reference<beans::XPropertySetInfo> xInfoSetInfo = xInfoSet->getPropertySetInfo();
419  if (!xInfoSetInfo.is())
420  return;
421 
422  if (xInfoSetInfo->hasPropertyByName(SC_UNO_ODS_LOCK_SOLAR_MUTEX))
423  xInfoSet->getPropertyValue(SC_UNO_ODS_LOCK_SOLAR_MUTEX) >>= mbLockSolarMutex;
424 
425  if (xInfoSetInfo->hasPropertyByName(SC_UNO_ODS_IMPORT_STYLES))
426  xInfoSet->getPropertyValue(SC_UNO_ODS_IMPORT_STYLES) >>= mbImportStyles;
427 }
428 
430 {
431  XMLFontStylesContext *pFSContext = new XMLFontStylesContext(
432  *this, osl_getThreadTextEncoding());
433  SetFontDecls(pFSContext);
434  SvXMLImportContext* pContext = pFSContext;
435  return pContext;
436 }
437 
439 {
441  *this, bIsAutoStyle);
442 
443  if (bIsAutoStyle)
444  SetAutoStyles(static_cast<SvXMLStylesContext*>(pContext));
445  else
446  SetStyles(static_cast<SvXMLStylesContext*>(pContext));
447 
448  return pContext;
449 }
450 
452 {
453  return new ScXMLBodyContext(*this, rAttrList);
454 }
455 
457  const sal_Int32 /*nElement*/ )
458 {
459  SvXMLImportContext* pContext = nullptr;
460 
461  if (getImportFlags() & SvXMLImportFlags::META)
462  {
463  uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
464  GetModel(), uno::UNO_QUERY_THROW);
465  uno::Reference<document::XDocumentProperties> const xDocProps(
466  (IsStylesOnlyMode()) ? nullptr : xDPS->getDocumentProperties());
467  pContext = new SvXMLMetaDocumentContext(*this, xDocProps);
468  }
469 
470  return pContext;
471 }
472 
474 {
475  SvXMLImportContext* pContext = nullptr;
476 
477  if( !(IsStylesOnlyMode()) )
478  {
479  pContext = new XMLScriptContext( *this, GetModel() );
480  }
481 
482  return pContext;
483 }
484 
485 void ScXMLImport::SetStatistics(const uno::Sequence<beans::NamedValue> & i_rStats)
486 {
487  static const char* s_stats[] =
488  { "TableCount", "CellCount", "ObjectCount", nullptr };
489 
490  SvXMLImport::SetStatistics(i_rStats);
491 
492  sal_uInt32 nCount(0);
493  for (const auto& rStat : i_rStats) {
494  for (const char** pStat = s_stats; *pStat != nullptr; ++pStat) {
495  if (rStat.Name.equalsAscii(*pStat)) {
496  sal_Int32 val = 0;
497  if (rStat.Value >>= val) {
498  nCount += val;
499  } else {
500  OSL_FAIL("ScXMLImport::SetStatistics: invalid entry");
501  }
502  }
503  }
504  }
505 
506  if (nCount)
507  {
510  }
511 }
512 
514 {
515  return *mpDocImport;
516 }
517 
518 sal_Int16 ScXMLImport::GetCellType(const char* rStrValue, const sal_Int32 nStrLength)
519 {
520  sal_Int16 nCellType = util::NumberFormat::UNDEFINED;
521  if (rStrValue != nullptr)
522  {
523  switch (rStrValue[0])
524  {
525  case 'b':
526  if (nStrLength == 7 && !strcmp(rStrValue, "boolean"))
527  nCellType = util::NumberFormat::LOGICAL;
528  break;
529  case 'c':
530  if (nStrLength == 8 && !strcmp(rStrValue, "currency"))
531  nCellType = util::NumberFormat::CURRENCY;
532  break;
533  case 'd':
534  if (nStrLength == 4 && !strcmp(rStrValue, "date"))
535  nCellType = util::NumberFormat::DATETIME;
536  break;
537  case 'f':
538  if (nStrLength == 5 && !strcmp(rStrValue, "float"))
539  nCellType = util::NumberFormat::NUMBER;
540  break;
541  case 'p':
542  if (nStrLength == 10 && !strcmp(rStrValue, "percentage"))
543  nCellType = util::NumberFormat::PERCENT;
544  break;
545  case 's':
546  if (nStrLength == 6 && !strcmp(rStrValue, "string"))
547  nCellType = util::NumberFormat::TEXT;
548  break;
549  case 't':
550  if (nStrLength == 4 && !strcmp(rStrValue, "time"))
551  nCellType = util::NumberFormat::TIME;
552  break;
553  }
554  }
555 
556  return nCellType;
557 }
558 
560 {
561  return new XMLTableShapeImportHelper(*this);
562 }
563 
564 bool ScXMLImport::GetValidation(const OUString& sName, ScMyImportValidation& aValidation)
565 {
566  if (pValidations)
567  {
568  auto aItr = std::find_if(pValidations->begin(), pValidations->end(),
569  [&sName](const ScMyImportValidation& rValidation) { return rValidation.sName == sName; });
570  if (aItr != pValidations->end())
571  {
572  // source position must be set as string,
573  // so sBaseCellAddress no longer has to be converted here
574  aValidation = *aItr;
575  return true;
576  }
577  }
578  return false;
579 }
580 
582 {
583  ::std::unique_ptr<ScMyNamedExpression> p(pNamedExp);
584  SheetNamedExpMap::iterator itr = m_SheetNamedExpressions.find(nTab);
585  if (itr == m_SheetNamedExpressions.end())
586  {
587  // No chain exists for this sheet. Create one.
588  ::std::pair<SheetNamedExpMap::iterator, bool> r =
589  m_SheetNamedExpressions.insert(std::make_pair(nTab, std::make_unique<ScMyNamedExpressions>()));
590  if (!r.second)
591  // insertion failed.
592  return;
593 
594  itr = r.first;
595  }
596  ScMyNamedExpressions& r = *itr->second;
597  r.push_back(std::move(p));
598 }
599 
601 {
604  return pChangeTrackingImportHelper.get();
605 }
606 
608 {
609  GetStyles()->CopyStylesToDoc(true);
610 
611  // if content is going to be loaded with the same import, set bLatinDefaultStyle flag now
612  if ( getImportFlags() & SvXMLImportFlags::CONTENT )
614 }
615 
617 {
618  if (pDoc)
619  {
620  // #i62435# after inserting the styles, check if the default style has a latin-script-only
621  // number format (then, value cells can be pre-initialized with western script type)
622 
623  const ScPatternAttr* pDefPattern = pDoc->GetDefPattern();
624  if (pDefPattern && sc::NumFmtUtil::isLatinScript(*pDefPattern, *pDoc))
625  mpDocImport->setDefaultNumericScript(SvtScriptType::LATIN);
626  }
627 }
628 
629 void ScXMLImport::SetChangeTrackingViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& rChangeProps)
630 {
631  if (!pDoc)
632  return;
633 
634  if (!rChangeProps.hasElements())
635  return;
636 
637  ScXMLImport::MutexGuard aGuard(*this);
638  sal_Int16 nTemp16(0);
639  std::unique_ptr<ScChangeViewSettings> pViewSettings(new ScChangeViewSettings());
640  for (const auto& rChangeProp : rChangeProps)
641  {
642  OUString sName(rChangeProp.Name);
643  if (sName == "ShowChanges")
644  pViewSettings->SetShowChanges(::cppu::any2bool(rChangeProp.Value));
645  else if (sName == "ShowAcceptedChanges")
646  pViewSettings->SetShowAccepted(::cppu::any2bool(rChangeProp.Value));
647  else if (sName == "ShowRejectedChanges")
648  pViewSettings->SetShowRejected(::cppu::any2bool(rChangeProp.Value));
649  else if (sName == "ShowChangesByDatetime")
650  pViewSettings->SetHasDate(::cppu::any2bool(rChangeProp.Value));
651  else if (sName == "ShowChangesByDatetimeMode")
652  {
653  if (rChangeProp.Value >>= nTemp16)
654  pViewSettings->SetTheDateMode(static_cast<SvxRedlinDateMode>(nTemp16));
655  }
656  else if (sName == "ShowChangesByDatetimeFirstDatetime")
657  {
658  util::DateTime aDateTime;
659  if (rChangeProp.Value >>= aDateTime)
660  {
661  pViewSettings->SetTheFirstDateTime(::DateTime(aDateTime));
662  }
663  }
664  else if (sName == "ShowChangesByDatetimeSecondDatetime")
665  {
666  util::DateTime aDateTime;
667  if (rChangeProp.Value >>= aDateTime)
668  {
669  pViewSettings->SetTheLastDateTime(::DateTime(aDateTime));
670  }
671  }
672  else if (sName == "ShowChangesByAuthor")
673  pViewSettings->SetHasAuthor(::cppu::any2bool(rChangeProp.Value));
674  else if (sName == "ShowChangesByAuthorName")
675  {
676  OUString sOUName;
677  if (rChangeProp.Value >>= sOUName)
678  {
679  pViewSettings->SetTheAuthorToShow(sOUName);
680  }
681  }
682  else if (sName == "ShowChangesByComment")
683  pViewSettings->SetHasComment(::cppu::any2bool(rChangeProp.Value));
684  else if (sName == "ShowChangesByCommentText")
685  {
686  OUString sOUComment;
687  if (rChangeProp.Value >>= sOUComment)
688  {
689  pViewSettings->SetTheComment(sOUComment);
690  }
691  }
692  else if (sName == "ShowChangesByRanges")
693  pViewSettings->SetHasRange(::cppu::any2bool(rChangeProp.Value));
694  else if (sName == "ShowChangesByRangesList")
695  {
696  OUString sRanges;
697  if ((rChangeProp.Value >>= sRanges) && !sRanges.isEmpty())
698  {
699  ScRangeList aRangeList;
701  aRangeList, sRanges, *pDoc, FormulaGrammar::CONV_OOO);
702  pViewSettings->SetTheRangeList(aRangeList);
703  }
704  }
705  }
706  pDoc->SetChangeViewSettings(*pViewSettings);
707 }
708 
709 void ScXMLImport::SetViewSettings(const uno::Sequence<beans::PropertyValue>& aViewProps)
710 {
711  sal_Int32 nHeight(0);
712  sal_Int32 nLeft(0);
713  sal_Int32 nTop(0);
714  sal_Int32 nWidth(0);
715  for (const auto& rViewProp : aViewProps)
716  {
717  OUString sName(rViewProp.Name);
718  if (sName == "VisibleAreaHeight")
719  rViewProp.Value >>= nHeight;
720  else if (sName == "VisibleAreaLeft")
721  rViewProp.Value >>= nLeft;
722  else if (sName == "VisibleAreaTop")
723  rViewProp.Value >>= nTop;
724  else if (sName == "VisibleAreaWidth")
725  rViewProp.Value >>= nWidth;
726  else if (sName == "TrackedChangesViewSettings")
727  {
728  uno::Sequence<beans::PropertyValue> aChangeProps;
729  if(rViewProp.Value >>= aChangeProps)
730  SetChangeTrackingViewSettings(aChangeProps);
731  }
732  }
733  if (!(nHeight && nWidth && GetModel().is()))
734  return;
735 
736  ScModelObj* pDocObj(comphelper::getUnoTunnelImplementation<ScModelObj>( GetModel() ));
737  if (!pDocObj)
738  return;
739 
740  SfxObjectShell* pEmbeddedObj = pDocObj->GetEmbeddedObject();
741  if (pEmbeddedObj)
742  {
743  tools::Rectangle aRect;
744  aRect.setX( nLeft );
745  aRect.setY( nTop );
746  aRect.setWidth( nWidth );
747  aRect.setHeight( nHeight );
748  pEmbeddedObj->SetVisArea(aRect);
749  }
750 }
751 
752 void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyValue>& aConfigProps)
753 {
754  if (!GetModel().is())
755  return;
756 
757  uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
758  if (!xMultiServiceFactory.is())
759  return;
760 
761  sal_Int32 nCount(aConfigProps.getLength());
762  css::uno::Sequence<css::beans::PropertyValue> aFilteredProps(nCount);
763  sal_Int32 nFilteredPropsLen = 0;
764  for (sal_Int32 i = nCount - 1; i >= 0; --i)
765  {
766  if (aConfigProps[i].Name == "TrackedChangesProtectionKey")
767  {
768  OUString sKey;
769  if (aConfigProps[i].Value >>= sKey)
770  {
771  uno::Sequence<sal_Int8> aPass;
772  ::comphelper::Base64::decode(aPass, sKey);
773  if (aPass.hasElements())
774  {
775  if (pDoc->GetChangeTrack())
776  pDoc->GetChangeTrack()->SetProtection(aPass);
777  else
778  {
779  std::set<OUString> aUsers;
780  std::unique_ptr<ScChangeTrack> pTrack( new ScChangeTrack(*pDoc, aUsers) );
781  pTrack->SetProtection(aPass);
782  pDoc->SetChangeTrack(std::move(pTrack));
783  }
784  }
785  }
786  }
787  // store the following items for later use (after document is loaded)
788  else if ((aConfigProps[i].Name == "VBACompatibilityMode") || (aConfigProps[i].Name == "ScriptConfiguration"))
789  {
790  uno::Reference< beans::XPropertySet > xImportInfo = getImportInfo();
791  if (xImportInfo.is())
792  {
793  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xImportInfo->getPropertySetInfo();
794  if (xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName(aConfigProps[i].Name))
795  xImportInfo->setPropertyValue( aConfigProps[i].Name, aConfigProps[i].Value );
796  }
797  }
798  if (aConfigProps[i].Name != "LinkUpdateMode")
799  {
800  aFilteredProps[nFilteredPropsLen++] = aConfigProps[i];
801  }
802  }
803  aFilteredProps.realloc(nFilteredPropsLen);
804  uno::Reference <uno::XInterface> xInterface = xMultiServiceFactory->createInstance("com.sun.star.comp.SpreadsheetSettings");
805  uno::Reference <beans::XPropertySet> xProperties(xInterface, uno::UNO_QUERY);
806  if (xProperties.is())
807  SvXMLUnitConverter::convertPropertySet(xProperties, aFilteredProps);
808 }
809 
810 sal_Int32 ScXMLImport::SetCurrencySymbol(const sal_Int32 nKey, const OUString& rCurrency)
811 {
812  uno::Reference <util::XNumberFormatsSupplier> xNumberFormatsSupplier(GetNumberFormatsSupplier());
813  if (xNumberFormatsSupplier.is())
814  {
815  uno::Reference <util::XNumberFormats> xLocalNumberFormats(xNumberFormatsSupplier->getNumberFormats());
816  if (xLocalNumberFormats.is())
817  {
818  OUString sFormatString;
819  try
820  {
821  uno::Reference <beans::XPropertySet> xProperties(xLocalNumberFormats->getByKey(nKey));
822  if (xProperties.is())
823  {
824  lang::Locale aLocale;
825  if (GetDocument() && (xProperties->getPropertyValue(gsLocale) >>= aLocale))
826  {
827  {
828  ScXMLImport::MutexGuard aGuard(*this);
830  OUStringBuffer aBuffer(15);
831  aBuffer.append("#");
832  aBuffer.append( aLocaleData.getNumThousandSep() );
833  aBuffer.append("##0");
834  aBuffer.append( aLocaleData.getNumDecimalSep() );
835  aBuffer.append("00 [$");
836  aBuffer.append(rCurrency);
837  aBuffer.append("]");
838  sFormatString = aBuffer.makeStringAndClear();
839  }
840  sal_Int32 nNewKey = xLocalNumberFormats->queryKey(sFormatString, aLocale, true);
841  if (nNewKey == -1)
842  nNewKey = xLocalNumberFormats->addNew(sFormatString, aLocale);
843  return nNewKey;
844  }
845  }
846  }
847  catch ( const util::MalformedNumberFormatException& rException )
848  {
849  OUString sErrorMessage ="Error in Formatstring " +
850  sFormatString + " at position " +
851  OUString::number(rException.CheckPos);
852  uno::Sequence<OUString> aSeq { sErrorMessage };
853  uno::Reference<xml::sax::XLocator> xLocator;
854  SetError(XMLERROR_API | XMLERROR_FLAG_ERROR, aSeq, rException.Message, xLocator);
855  }
856  }
857  }
858  return nKey;
859 }
860 
861 bool ScXMLImport::IsCurrencySymbol(const sal_Int32 nNumberFormat, const OUString& sCurrentCurrency, std::u16string_view sBankSymbol)
862 {
863  uno::Reference <util::XNumberFormatsSupplier> xNumberFormatsSupplier(GetNumberFormatsSupplier());
864  if (xNumberFormatsSupplier.is())
865  {
866  uno::Reference <util::XNumberFormats> xLocalNumberFormats(xNumberFormatsSupplier->getNumberFormats());
867  if (xLocalNumberFormats.is())
868  {
869  try
870  {
871  uno::Reference <beans::XPropertySet> xNumberPropertySet(xLocalNumberFormats->getByKey(nNumberFormat));
872  if (xNumberPropertySet.is())
873  {
874  OUString sTemp;
875  if ( xNumberPropertySet->getPropertyValue(SC_CURRENCYSYMBOL) >>= sTemp)
876  {
877  if (sCurrentCurrency == sTemp)
878  return true;
879  // A release that saved an unknown currency may have
880  // saved the currency symbol of the number format
881  // instead of an ISO code bank symbol. In another
882  // release we may have a match for that. In this case
883  // sCurrentCurrency is the ISO code obtained through
884  // XMLNumberFormatAttributesExportHelper::GetCellType()
885  // and sBankSymbol is the currency symbol.
886  if (sCurrentCurrency.getLength() == 3 && sBankSymbol == sTemp)
887  return true;
888  // #i61657# This may be a legacy currency symbol that changed in the meantime.
889  if (SvNumberFormatter::GetLegacyOnlyCurrencyEntry( sCurrentCurrency, sBankSymbol) != nullptr)
890  return true;
891  // In the rare case that sCurrentCurrency is not the
892  // currency symbol, but a matching ISO code
893  // abbreviation instead that was obtained through
894  // XMLNumberFormatAttributesExportHelper::GetCellType(),
895  // check with the number format's symbol. This happens,
896  // for example, in the es_BO locale, where a legacy
897  // B$,BOB matched B$->BOP, which leads to
898  // sCurrentCurrency being BOP, and the previous call
899  // with BOP,BOB didn't find an entry, but B$,BOB will.
900  return SvNumberFormatter::GetLegacyOnlyCurrencyEntry( sTemp, sBankSymbol) != nullptr;
901  }
902  }
903  }
904  catch ( uno::Exception& )
905  {
906  OSL_FAIL("Numberformat not found");
907  }
908  }
909  }
910  return false;
911 }
912 
913 void ScXMLImport::SetType(const uno::Reference <beans::XPropertySet>& rProperties,
914  sal_Int32& rNumberFormat,
915  const sal_Int16 nCellType,
916  const OUString& rCurrency)
917 {
918  if (!mbImportStyles)
919  return;
920 
921  if ((nCellType == util::NumberFormat::TEXT) || (nCellType == util::NumberFormat::UNDEFINED))
922  return;
923 
924  if (rNumberFormat == -1)
925  rProperties->getPropertyValue( gsNumberFormat ) >>= rNumberFormat;
926  OSL_ENSURE(rNumberFormat != -1, "no NumberFormat");
927  bool bIsStandard;
928  // sCurrentCurrency may be the ISO code abbreviation if the currency
929  // symbol matches such, or if no match found the symbol itself!
930  OUString sCurrentCurrency;
931  sal_Int32 nCurrentCellType(
933  rNumberFormat, sCurrentCurrency, bIsStandard) & ~util::NumberFormat::DEFINED);
934  // If the (numeric) cell type (number, currency, date, time, boolean)
935  // is different from the format type then for some combinations we may
936  // have to apply a format, e.g. in case the generator deduced format
937  // from type and did not apply a format but we don't keep a dedicated
938  // type internally. Specifically this is necessary if the cell type is
939  // not number but the format type is (i.e. General). Currency cells
940  // need extra attention, see calls of ScXMLImport::IsCurrencySymbol()
941  // and description within there and ScXMLImport::SetCurrencySymbol().
942  if ((nCellType != nCurrentCellType) &&
943  (nCellType != util::NumberFormat::NUMBER) &&
944  (bIsStandard || (nCellType == util::NumberFormat::CURRENCY)))
945  {
946  if (!xNumberFormats.is())
947  {
948  uno::Reference <util::XNumberFormatsSupplier> xNumberFormatsSupplier(GetNumberFormatsSupplier());
949  if (xNumberFormatsSupplier.is())
950  xNumberFormats.set(xNumberFormatsSupplier->getNumberFormats());
951  }
952  if (xNumberFormats.is())
953  {
954  try
955  {
956  uno::Reference < beans::XPropertySet> xNumberFormatProperties(xNumberFormats->getByKey(rNumberFormat));
957  if (xNumberFormatProperties.is())
958  {
959  if (nCellType != util::NumberFormat::CURRENCY)
960  {
961  lang::Locale aLocale;
962  if ( xNumberFormatProperties->getPropertyValue(gsLocale) >>= aLocale )
963  {
964  if (!xNumberFormatTypes.is())
965  xNumberFormatTypes.set(uno::Reference <util::XNumberFormatTypes>(xNumberFormats, uno::UNO_QUERY));
966  rProperties->setPropertyValue( gsNumberFormat, uno::makeAny(xNumberFormatTypes->getStandardFormat(nCellType, aLocale)) );
967  }
968  }
969  else if (!rCurrency.isEmpty() && !sCurrentCurrency.isEmpty())
970  {
971  if (sCurrentCurrency != rCurrency)
972  if (!IsCurrencySymbol(rNumberFormat, sCurrentCurrency, rCurrency))
973  rProperties->setPropertyValue( gsNumberFormat, uno::makeAny(SetCurrencySymbol(rNumberFormat, rCurrency)));
974  }
975  }
976  }
977  catch ( uno::Exception& )
978  {
979  OSL_FAIL("Numberformat not found");
980  }
981  }
982  }
983  else
984  {
985  if ((nCellType == util::NumberFormat::CURRENCY) && !rCurrency.isEmpty() && !sCurrentCurrency.isEmpty() &&
986  sCurrentCurrency != rCurrency && !IsCurrencySymbol(rNumberFormat, sCurrentCurrency, rCurrency))
987  rProperties->setPropertyValue( gsNumberFormat, uno::makeAny(SetCurrencySymbol(rNumberFormat, rCurrency)));
988  }
989 }
990 
992 {
993  if (!mbImportStyles)
994  return;
995 
996  if (!sPrevStyleName.isEmpty())
997  {
998  uno::Reference <beans::XPropertySet> xProperties (xSheetCellRanges, uno::UNO_QUERY);
999  if (xProperties.is())
1000  {
1001  XMLTableStylesContext *pStyles(static_cast<XMLTableStylesContext *>(GetAutoStyles()));
1002  XMLTableStyleContext* pStyle = nullptr;
1003  if ( pStyles )
1004  pStyle = const_cast<XMLTableStyleContext*>(static_cast<const XMLTableStyleContext *>(pStyles->FindStyleChildContext(
1005  XmlStyleFamily::TABLE_CELL, sPrevStyleName, true)));
1006  if (pStyle)
1007  {
1008  pStyle->FillPropertySet(xProperties);
1009  // here needs to be the cond format import method
1010  sal_Int32 nNumberFormat(pStyle->GetNumberFormat());
1011  SetType(xProperties, nNumberFormat, nPrevCellType, sPrevCurrency);
1012 
1013  css::uno::Any aAny = xProperties->getPropertyValue("FormatID");
1014  sal_uInt64 nKey = 0;
1015  if ((aAny >>= nKey) && nKey)
1016  {
1017  ScFormatSaveData* pFormatSaveData = comphelper::getUnoTunnelImplementation<ScModelObj>(GetModel())->GetFormatSaveData();
1018  pFormatSaveData->maIDToName.insert(std::pair<sal_uInt64, OUString>(nKey, sPrevStyleName));
1019  }
1020 
1021  // store first cell of first range for each style, once per sheet
1022  uno::Sequence<table::CellRangeAddress> aAddresses(xSheetCellRanges->getRangeAddresses());
1023  pStyle->ApplyCondFormat(aAddresses);
1024  if ( aAddresses.hasElements() )
1025  {
1026  const table::CellRangeAddress& rRange = aAddresses[0];
1027  if ( rRange.Sheet != pStyle->GetLastSheet() )
1028  {
1029  ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(GetModel())->GetSheetSaveData();
1030  pSheetData->AddCellStyle( sPrevStyleName,
1031  ScAddress( static_cast<SCCOL>(rRange.StartColumn), static_cast<SCROW>(rRange.StartRow), static_cast<SCTAB>(rRange.Sheet) ) );
1032  pStyle->SetLastSheet(rRange.Sheet);
1033  }
1034  }
1035  }
1036  else
1037  {
1038  xProperties->setPropertyValue(gsCellStyle, uno::makeAny(GetStyleDisplayName( XmlStyleFamily::TABLE_CELL, sPrevStyleName )));
1039  sal_Int32 nNumberFormat(GetStyleNumberFormats()->GetStyleNumberFormat(sPrevStyleName));
1040  bool bInsert(nNumberFormat == -1);
1041  SetType(xProperties, nNumberFormat, nPrevCellType, sPrevCurrency);
1042  if (bInsert)
1044  }
1045  }
1046  }
1047  if (GetModel().is())
1048  {
1049  uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
1050  if (xMultiServiceFactory.is())
1051  xSheetCellRanges.set(uno::Reference <sheet::XSheetCellRangeContainer>(
1052  xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"),
1053  uno::UNO_QUERY));
1054  }
1055  OSL_ENSURE(xSheetCellRanges.is(), "didn't get SheetCellRanges");
1056 }
1057 
1058 void ScXMLImport::SetStyleToRanges(const ScRangeList& rRanges, const OUString* pStyleName,
1059  const sal_Int16 nCellType, const OUString* pCurrency)
1060 {
1061  if (!mbImportStyles)
1062  return;
1063 
1064  if (sPrevStyleName.isEmpty())
1065  {
1066  nPrevCellType = nCellType;
1067  if (pStyleName)
1068  sPrevStyleName = *pStyleName;
1069  if (pCurrency)
1070  sPrevCurrency = *pCurrency;
1071  else if (!sPrevCurrency.isEmpty())
1072  sPrevCurrency.clear();
1073  }
1074  else if ((nCellType != nPrevCellType) ||
1075  ((pStyleName && *pStyleName != sPrevStyleName) ||
1076  (!pStyleName && !sPrevStyleName.isEmpty())) ||
1077  ((pCurrency && *pCurrency != sPrevCurrency) ||
1078  (!pCurrency && !sPrevCurrency.isEmpty())))
1079  {
1080  SetStyleToRanges();
1081  nPrevCellType = nCellType;
1082  if (pStyleName)
1083  sPrevStyleName = *pStyleName;
1084  else if(!sPrevStyleName.isEmpty())
1085  sPrevStyleName.clear();
1086  if (pCurrency)
1087  sPrevCurrency = *pCurrency;
1088  else if(!sPrevCurrency.isEmpty())
1089  sPrevCurrency.clear();
1090  }
1091 
1092  if (!xSheetCellRanges.is() && GetModel().is())
1093  {
1094  uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
1095  if (xMultiServiceFactory.is())
1096  xSheetCellRanges.set(uno::Reference <sheet::XSheetCellRangeContainer>(xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"), uno::UNO_QUERY));
1097  OSL_ENSURE(xSheetCellRanges.is(), "didn't get SheetCellRanges");
1098 
1099  }
1100  static_cast<ScCellRangesObj*>(xSheetCellRanges.get())->SetNewRanges(rRanges);
1101 }
1102 
1104 {
1105  if (!bNullDateSetted)
1107  OSL_ENSURE(bNullDateSetted, "could not set the null date");
1108  return bNullDateSetted;
1109 }
1110 
1112 {
1116 }
1117 
1119 {
1120  if (!pStyleNumberFormats)
1122  return pStyleNumberFormats.get();
1123 }
1124 
1126 {
1127  SetStyleToRanges();
1128  sPrevStyleName.clear();
1129 }
1130 
1131 // XImporter
1132 void SAL_CALL ScXMLImport::setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc )
1133 {
1134  ScXMLImport::MutexGuard aGuard(*this);
1136 
1137  uno::Reference<frame::XModel> xModel(xDoc, uno::UNO_QUERY);
1138  pDoc = ScXMLConverter::GetScDocument( xModel );
1139  OSL_ENSURE( pDoc, "ScXMLImport::setTargetDocument - no ScDocument!" );
1140  if (!pDoc)
1141  throw lang::IllegalArgumentException();
1142 
1143  mpDocImport.reset(new ScDocumentImport(*pDoc));
1145 
1146  uno::Reference<document::XActionLockable> xActionLockable(xDoc, uno::UNO_QUERY);
1147  if (xActionLockable.is())
1148  xActionLockable->addActionLock();
1149 }
1150 
1151 // css::xml::sax::XDocumentHandler
1153 {
1154  ScXMLImport::MutexGuard aGuard(*this);
1156  if (pDoc && !pDoc->IsImportingXML())
1157  {
1158  comphelper::getUnoTunnelImplementation<ScModelObj>(GetModel())->BeforeXMLLoading();
1159  bSelfImportingXMLSet = true;
1160  }
1161 
1162  // if content and styles are loaded with separate imports,
1163  // set bLatinDefaultStyle flag at the start of the content import
1164  SvXMLImportFlags nFlags = getImportFlags();
1165  if ( ( nFlags & SvXMLImportFlags::CONTENT ) && !( nFlags & SvXMLImportFlags::STYLES ) )
1167 
1168  if (getImportFlags() & SvXMLImportFlags::CONTENT)
1169  {
1170  if (GetModel().is())
1171  {
1172  // store initial namespaces, to find the ones that were added from the file later
1173  ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(GetModel())->GetSheetSaveData();
1174  const SvXMLNamespaceMap& rNamespaces = GetNamespaceMap();
1175  pSheetData->StoreInitialNamespaces(rNamespaces);
1176  }
1177  }
1178 
1179  uno::Reference< beans::XPropertySet > const xImportInfo( getImportInfo() );
1180  uno::Reference< beans::XPropertySetInfo > const xPropertySetInfo(
1181  xImportInfo.is() ? xImportInfo->getPropertySetInfo() : nullptr);
1182  if (xPropertySetInfo.is())
1183  {
1184  OUString const sOrganizerMode(
1185  "OrganizerMode");
1186  if (xPropertySetInfo->hasPropertyByName(sOrganizerMode))
1187  {
1188  bool bStyleOnly(false);
1189  if (xImportInfo->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
1190  {
1191  bLoadDoc = !bStyleOnly;
1192  }
1193  }
1194  }
1195 
1196  UnlockSolarMutex();
1197 }
1198 
1199 sal_Int32 ScXMLImport::GetRangeType(const OUString& sRangeType)
1200 {
1201  sal_Int32 nRangeType(0);
1202  OUStringBuffer sBuffer;
1203  sal_Int32 i = 0;
1204  while (i <= sRangeType.getLength())
1205  {
1206  if ((i == sRangeType.getLength()) || (sRangeType[i] == ' '))
1207  {
1208  OUString sTemp = sBuffer.makeStringAndClear();
1209  if (sTemp == "repeat-column")
1211  else if (sTemp == SC_REPEAT_ROW)
1212  nRangeType |= sheet::NamedRangeFlag::ROW_HEADER;
1213  else if (sTemp == SC_FILTER)
1214  nRangeType |= sheet::NamedRangeFlag::FILTER_CRITERIA;
1215  else if (sTemp == SC_PRINT_RANGE)
1216  nRangeType |= sheet::NamedRangeFlag::PRINT_AREA;
1217  }
1218  else if (i < sRangeType.getLength())
1219  sBuffer.append(sRangeType[i]);
1220  ++i;
1221  }
1222  return nRangeType;
1223 }
1224 
1226 {
1227  if (!pMyLabelRanges)
1228  return;
1229 
1230  uno::Reference <beans::XPropertySet> xPropertySet (GetModel(), uno::UNO_QUERY);
1231  if (!xPropertySet.is())
1232  return;
1233 
1234  uno::Any aColAny = xPropertySet->getPropertyValue(SC_UNO_COLLABELRNG);
1235  uno::Any aRowAny = xPropertySet->getPropertyValue(SC_UNO_ROWLABELRNG);
1236 
1237  uno::Reference< sheet::XLabelRanges > xColRanges;
1238  uno::Reference< sheet::XLabelRanges > xRowRanges;
1239 
1240  if ( !(( aColAny >>= xColRanges ) && ( aRowAny >>= xRowRanges )) )
1241  return;
1242 
1243  table::CellRangeAddress aLabelRange;
1244  table::CellRangeAddress aDataRange;
1245 
1246  for (const auto& rxLabelRange : *pMyLabelRanges)
1247  {
1248  sal_Int32 nOffset1(0);
1249  sal_Int32 nOffset2(0);
1250  FormulaGrammar::AddressConvention eConv = FormulaGrammar::CONV_OOO;
1251 
1252  assert(pDoc);
1253  if (ScRangeStringConverter::GetRangeFromString( aLabelRange, rxLabelRange->sLabelRangeStr, *pDoc, eConv, nOffset1 ) &&
1254  ScRangeStringConverter::GetRangeFromString( aDataRange, rxLabelRange->sDataRangeStr, *pDoc, eConv, nOffset2 ))
1255  {
1256  if ( rxLabelRange->bColumnOrientation )
1257  xColRanges->addNew( aLabelRange, aDataRange );
1258  else
1259  xRowRanges->addNew( aLabelRange, aDataRange );
1260  }
1261  }
1262 
1263  pMyLabelRanges->clear();
1264 }
1265 
1266 namespace {
1267 
1268 class RangeNameInserter
1269 {
1270  ScDocument& mrDoc;
1271  ScRangeName& mrRangeName;
1272 
1273 public:
1274  RangeNameInserter(ScDocument& rDoc, ScRangeName& rRangeName) :
1275  mrDoc(rDoc), mrRangeName(rRangeName) {}
1276 
1277  void operator() (const std::unique_ptr<ScMyNamedExpression>& p) const
1278  {
1279  using namespace formula;
1280 
1281  const OUString& aType = p->sRangeType;
1282  sal_uInt32 nUnoType = ScXMLImport::GetRangeType(aType);
1283 
1285  if ( nUnoType & sheet::NamedRangeFlag::FILTER_CRITERIA ) nNewType |= ScRangeData::Type::Criteria;
1286  if ( nUnoType & sheet::NamedRangeFlag::PRINT_AREA ) nNewType |= ScRangeData::Type::PrintArea;
1289 
1290  // Insert a new name.
1291  ScAddress aPos;
1292  sal_Int32 nOffset = 0;
1294  aPos, p->sBaseCellAddress, mrDoc, FormulaGrammar::CONV_OOO, nOffset);
1295 
1296  if (bSuccess)
1297  {
1298  OUString aContent = p->sContent;
1299  if (!p->bIsExpression)
1301 
1302  ScRangeData* pData = new ScRangeData(
1303  mrDoc, p->sName, aContent, aPos, nNewType, p->eGrammar);
1304  mrRangeName.insert(pData);
1305  }
1306  }
1307 };
1308 
1309 }
1310 
1312 {
1313  if (!m_pMyNamedExpressions)
1314  return;
1315 
1316  if (!pDoc)
1317  return;
1318 
1319  // Insert the namedRanges
1320  ScRangeName* pRangeNames = pDoc->GetRangeName();
1321  ::std::for_each(m_pMyNamedExpressions->begin(), m_pMyNamedExpressions->end(), RangeNameInserter(*pDoc, *pRangeNames));
1322 }
1323 
1325 {
1326  if (!pDoc)
1327  return;
1328 
1329  for (auto const& itr : m_SheetNamedExpressions)
1330  {
1331  const SCTAB nTab = itr.first;
1332  ScRangeName* pRangeNames = pDoc->GetRangeName(nTab);
1333  if (!pRangeNames)
1334  continue;
1335 
1336  const ScMyNamedExpressions& rNames = *itr.second;
1337  ::std::for_each(rNames.begin(), rNames.end(), RangeNameInserter(*pDoc, *pRangeNames));
1338  }
1339 }
1340 
1342 {
1343  if (!pDoc)
1344  return;
1345 
1346  ScCalcConfig aCalcConfig = pDoc->GetCalcConfig();
1347 
1348  // Has any string ref syntax been imported?
1349  // If not, we need to take action
1350  if ( !aCalcConfig.mbHasStringRefSyntax )
1351  {
1353  pDoc->SetCalcConfig(aCalcConfig);
1354  }
1355 }
1356 
1358 {
1359  ScXMLImport::MutexGuard aGuard(*this);
1360  if (getImportFlags() & SvXMLImportFlags::CONTENT)
1361  {
1362  if (GetModel().is())
1363  {
1364  mpDocImport->finalize();
1365 
1366  uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1367  if (xViewDataSupplier.is())
1368  {
1369  uno::Reference<container::XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
1370  if (xIndexAccess.is() && xIndexAccess->getCount() > 0)
1371  {
1372  uno::Sequence< beans::PropertyValue > aSeq;
1373  if (xIndexAccess->getByIndex(0) >>= aSeq)
1374  {
1375  for (const auto& rProp : std::as_const(aSeq))
1376  {
1377  OUString sName(rProp.Name);
1378  if (sName == SC_ACTIVETABLE)
1379  {
1380  OUString sTabName;
1381  if(rProp.Value >>= sTabName)
1382  {
1383  SCTAB nTab(0);
1384  if (pDoc->GetTable(sTabName, nTab))
1385  {
1386  pDoc->SetVisibleTab(nTab);
1387  break;
1388  }
1389  }
1390  }
1391  }
1392  }
1393  }
1394  }
1395  SetLabelRanges();
1396  SetNamedRanges();
1399  if (mpPivotSources)
1400  // Process pivot table sources after the named ranges have been set.
1401  mpPivotSources->process();
1402  }
1403  GetProgressBarHelper()->End(); // make room for subsequent SfxProgressBars
1404  if (pDoc)
1405  {
1406  pDoc->CompileXML();
1407 
1408  // After CompileXML, links must be completely changed to the new URLs.
1409  // Otherwise, hasExternalFile for API wouldn't work (#i116940#),
1410  // and typing a new formula would create a second link with the same "real" file name.
1411  if (pDoc->HasExternalRefManager())
1413  }
1414 
1415  // If the stream contains cells outside of the current limits, the styles can't be re-created,
1416  // so stream copying is disabled then.
1417  if (pDoc && GetModel().is() && !pDoc->HasRangeOverflow())
1418  {
1419  // set "valid stream" flags after loading (before UpdateRowHeights, so changed formula results
1420  // in UpdateRowHeights can already clear the flags again)
1421  ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(GetModel())->GetSheetSaveData();
1422 
1423  SCTAB nTabCount = pDoc->GetTableCount();
1424  for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
1425  {
1426  pDoc->SetDrawPageSize(nTab);
1427  if (!pSheetData->IsSheetBlocked( nTab ))
1428  pDoc->SetStreamValid( nTab, true );
1429  }
1430  }
1431 
1432  // There are rows with optimal height which need to be updated
1433  if (pDoc && !maRecalcRowRanges.empty())
1434  {
1435  bool bLockHeight = pDoc->IsAdjustHeightLocked();
1436  if (bLockHeight)
1437  {
1439  }
1440 
1441  ScSizeDeviceProvider aProv(static_cast<ScDocShell*>(pDoc->GetDocumentShell()));
1442  ScDocRowHeightUpdater aUpdater(*pDoc, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), &maRecalcRowRanges);
1443  aUpdater.update();
1444 
1445  if (bLockHeight)
1446  {
1448  }
1449  }
1450 
1451  // Initialize and set position and size of objects
1452  if (pDoc && pDoc->GetDrawLayer())
1453  {
1454  ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1455  SCTAB nTabCount = pDoc->GetTableCount();
1456  for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
1457  {
1458  const SdrPage* pPage = pDrawLayer->GetPage(nTab);
1459  if (!pPage)
1460  continue;
1461  bool bNegativePage = pDoc->IsNegativePage(nTab);
1462  const size_t nCount = pPage->GetObjCount();
1463  for (size_t i = 0; i < nCount; ++i)
1464  {
1465  SdrObject* pObj = pPage->GetObj(i);
1467  = ScDrawLayer::GetObjDataTab(pObj, nTab);
1468  // Existence of pData means, that it is a cell anchored object
1469  if (pData)
1470  {
1471  // Finish and correct import based on full size (no hidden row/col) and LTR
1472  pDrawLayer->InitializeCellAnchoredObj(pObj, *pData);
1473  // Adapt object to hidden row/col and RTL
1474  pDrawLayer->RecalcPos(pObj, *pData, bNegativePage,
1475  true /*bUpdateNoteCaptionPos*/);
1476  }
1477  }
1478  }
1479  }
1480 
1481  aTables.FixupOLEs();
1482  }
1483  if (GetModel().is())
1484  {
1485  uno::Reference<document::XActionLockable> xActionLockable(GetModel(), uno::UNO_QUERY);
1486  if (xActionLockable.is())
1487  xActionLockable->removeActionLock();
1488  }
1490 
1491  if (pDoc)
1492  {
1493  pDoc->BroadcastUno(SfxHint(SfxHintId::ScClearCache));
1494  }
1495 
1496  if(pDoc && bSelfImportingXMLSet)
1497  comphelper::getUnoTunnelImplementation<ScModelObj>(GetModel())->AfterXMLLoading();
1498 }
1499 
1500 // XEventListener
1502 {
1504  pDoc = nullptr;
1505 }
1506 
1508  mrImport(rImport)
1509 {
1511 }
1512 
1514 {
1515  mrImport.UnlockSolarMutex();
1516 }
1517 
1519 {
1520  // #i62677# When called from DocShell/Wrapper, the SolarMutex is already locked,
1521  // so there's no need to allocate (and later delete) the SolarMutexGuard.
1522  if (!mbLockSolarMutex)
1523  {
1525  return;
1526  }
1527 
1528  if (nSolarMutexLocked == 0)
1529  {
1530  OSL_ENSURE(!pSolarMutexGuard, "Solar Mutex is locked");
1531  pSolarMutexGuard.reset(new SolarMutexGuard());
1532  }
1534 }
1535 
1537 {
1538  if (nSolarMutexLocked > 0)
1539  {
1541  if (nSolarMutexLocked == 0)
1542  {
1543  OSL_ENSURE(pSolarMutexGuard, "Solar Mutex is always unlocked");
1544  pSolarMutexGuard.reset();
1545  }
1546  }
1547 }
1548 
1550 {
1551  sal_Int32 nOffset = -1;
1552  uno::Reference<xml::sax::XLocator> xLocator = GetLocator();
1553  uno::Reference<io::XSeekable> xSeek( xLocator, uno::UNO_QUERY );
1554  if ( xSeek.is() )
1555  nOffset = static_cast<sal_Int32>(xSeek->getPosition());
1556  return nOffset;
1557 }
1558 
1560 {
1561  // #i31130# Overflow is stored in the document, because the ScXMLImport object
1562  // isn't available in ScXMLImportWrapper::ImportFromComponent when using the
1563  // OOo->Oasis transformation.
1564 
1565  if ( pDoc )
1566  pDoc->SetRangeOverflowType( nType );
1567 }
1568 
1570 {
1571  nProgressCount++;
1572  if (nProgressCount > 100)
1573  {
1575  nProgressCount = 0;
1576  }
1577 }
1578 
1580  OUString& rFormula, OUString& rFormulaNmsp, FormulaGrammar::Grammar& reGrammar,
1581  const OUString& rAttrValue, bool bRestrictToExternalNmsp ) const
1582 {
1583  // parse the attribute value, extract namespace ID, literal namespace, and formula string
1584  rFormulaNmsp.clear();
1585  sal_uInt16 nNsId = GetNamespaceMap().GetKeyByQName(rAttrValue, nullptr, &rFormula, &rFormulaNmsp, SvXMLNamespaceMap::QNameMode::AttrValue);
1586 
1587  // check if we have an ODF formula namespace
1588  if( !bRestrictToExternalNmsp ) switch( nNsId )
1589  {
1590  case XML_NAMESPACE_OOOC:
1591  rFormulaNmsp.clear(); // remove namespace string for built-in grammar
1592  reGrammar = FormulaGrammar::GRAM_PODF;
1593  return;
1594  case XML_NAMESPACE_OF:
1595  rFormulaNmsp.clear(); // remove namespace string for built-in grammar
1596  reGrammar = FormulaGrammar::GRAM_ODFF;
1597  return;
1598  }
1599 
1600  /* Find default grammar for formulas without namespace. There may be
1601  documents in the wild that stored no namespace in ODF 1.0/1.1. Use
1602  GRAM_PODF then (old style ODF 1.0/1.1 formulas). The default for ODF
1603  1.2 and later without namespace is GRAM_ODFF (OpenFormula). */
1604  FormulaGrammar::Grammar eDefaultGrammar =
1605  (GetDocument()->GetStorageGrammar() == FormulaGrammar::GRAM_PODF) ?
1606  FormulaGrammar::GRAM_PODF : FormulaGrammar::GRAM_ODFF;
1607 
1608  /* Check if we have no namespace at all. The value XML_NAMESPACE_NONE
1609  indicates that there is no colon. If the first character of the
1610  attribute value is the equality sign, the value XML_NAMESPACE_UNKNOWN
1611  indicates that there is a colon somewhere in the formula string. */
1612  if( (nNsId == XML_NAMESPACE_NONE) || ((nNsId == XML_NAMESPACE_UNKNOWN) && (rAttrValue.toChar() == '=')) )
1613  {
1614  rFormula = rAttrValue; // return entire string as formula
1615  reGrammar = eDefaultGrammar;
1616  return;
1617  }
1618 
1619  /* Check if a namespace URL could be resolved from the attribute value.
1620  Use that namespace only, if the Calc document knows an associated
1621  external formula parser. This prevents that the range operator in
1622  conjunction with defined names is confused as namespaces prefix, e.g.
1623  in the expression 'table:A1' where 'table' is a named reference. */
1624  if( ((nNsId & XML_NAMESPACE_UNKNOWN_FLAG) != 0) && !rFormulaNmsp.isEmpty() &&
1625  GetDocument()->GetFormulaParserPool().hasFormulaParser( rFormulaNmsp ) )
1626  {
1627  reGrammar = FormulaGrammar::GRAM_EXTERNAL;
1628  return;
1629  }
1630 
1631  /* All attempts failed (e.g. no namespace and no leading equality sign, or
1632  an invalid namespace prefix), continue with the entire attribute value. */
1633  rFormula = rAttrValue;
1634  rFormulaNmsp.clear(); // remove any namespace string
1635  reGrammar = eDefaultGrammar;
1636 }
1637 
1639 {
1640  if (!mpComp)
1641  return FormulaError::NONE;
1642 
1643  return mpComp->GetErrorConstant(rStr);
1644 }
1645 
1647 {
1648  if (!mpEditEngine)
1649  {
1651  mpEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
1652  mpEditEngine->SetEditTextObjectPool(pDoc->GetEditPool());
1653  mpEditEngine->SetUpdateMode(false);
1654  mpEditEngine->EnableUndo(false);
1655  mpEditEngine->SetControlWord(mpEditEngine->GetControlWord() & ~EEControlBits::ALLOWBIGOBJS);
1656  }
1657  return mpEditEngine.get();
1658 }
1659 
1661 {
1662  if (!mpEditAttrMap)
1664  return *mpEditAttrMap;
1665 }
1666 
1668 {
1669  if (pDoc)
1670  pDoc->SetEmbedFonts(true);
1671 }
1672 
1674 {
1675  if (!pDetectiveOpArray)
1677  return pDetectiveOpArray.get();
1678 }
1679 
1680 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODS(SvStream &rStream)
1681 {
1682  ScDLL::Init();
1683 
1684  SfxObjectShellLock xDocSh(new ScDocShell);
1685  xDocSh->DoInitNew();
1686  uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
1687 
1688  uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
1689  uno::Reference<io::XInputStream> xStream(new ::utl::OSeekableInputStreamWrapper(rStream));
1690  uno::Reference<uno::XInterface> xInterface(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.XmlFilterAdaptor"), uno::UNO_SET_THROW);
1691 
1692  css::uno::Sequence<OUString> aUserData(7);
1693  aUserData[0] = "com.sun.star.comp.filter.OdfFlatXml";
1694  aUserData[2] = "com.sun.star.comp.Calc.XMLOasisImporter";
1695  aUserData[3] = "com.sun.star.comp.Calc.XMLOasisExporter";
1696  aUserData[6] = "true";
1697  uno::Sequence<beans::PropertyValue> aAdaptorArgs(comphelper::InitPropertySequence(
1698  {
1699  { "UserData", uno::Any(aUserData) },
1700  }));
1701  css::uno::Sequence<uno::Any> aOuterArgs(1);
1702  aOuterArgs[0] <<= aAdaptorArgs;
1703 
1704  uno::Reference<lang::XInitialization> xInit(xInterface, uno::UNO_QUERY_THROW);
1705  xInit->initialize(aOuterArgs);
1706 
1707  uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
1708  uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
1709  {
1710  { "InputStream", uno::Any(xStream) },
1711  { "URL", uno::Any(OUString("private:stream")) },
1712  }));
1713  xImporter->setTargetDocument(xModel);
1714 
1715  uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
1716  //SetLoading hack because the document properties will be re-initted
1717  //by the xml filter and during the init, while it's considered uninitialized,
1718  //setting a property will inform the document it's modified, which attempts
1719  //to update the properties, which throws cause the properties are uninitialized
1720  xDocSh->SetLoading(SfxLoadedFlags::NONE);
1721  bool ret = xFilter->filter(aArgs);
1722  xDocSh->SetLoading(SfxLoadedFlags::ALL);
1723 
1724  xDocSh->DoClose();
1725 
1726  return ret;
1727 }
1728 
1729 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportXLSX(SvStream &rStream)
1730 {
1731  ScDLL::Init();
1732 
1733  SfxObjectShellLock xDocSh(new ScDocShell);
1734  xDocSh->DoInitNew();
1735  uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
1736 
1737  uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
1738  uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
1739 
1740  uno::Reference<document::XFilter> xFilter(xMultiServiceFactory->createInstance("com.sun.star.comp.oox.xls.ExcelFilter"), uno::UNO_QUERY_THROW);
1741 
1742  uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
1743  uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
1744  {
1745  { "InputStream", uno::makeAny(xStream) },
1746  { "InputMode", uno::makeAny(true) },
1747  }));
1748  xImporter->setTargetDocument(xModel);
1749 
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 = false;
1756  try
1757  {
1758  ret = xFilter->filter(aArgs);
1759  }
1760  catch (const css::io::IOException&)
1761  {
1762  }
1763  catch (const css::lang::WrappedTargetRuntimeException&)
1764  {
1765  }
1766  xDocSh->SetLoading(SfxLoadedFlags::ALL);
1767 
1768  xDocSh->DoClose();
1769 
1770  return ret;
1771 }
1772 
1773 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SC_REPEAT_ROW
Definition: xmlimprt.cxx:107
virtual void SetVisArea(const tools::Rectangle &rVisArea)
void SetStringRefSyntaxIfMissing()
Definition: xmlimprt.cxx:1341
css::uno::Reference< css::sheet::XSheetCellRangeContainer > xSheetCellRanges
Definition: xmlimprt.hxx:157
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlimprt.cxx:321
bool HasExternalRefManager() const
Definition: document.hxx:1000
double GetPPTY() const
Definition: sizedev.hxx:43
void SetStyles(SvXMLStylesContext *pStyles)
SvXMLImportContext * CreateScriptContext()
Definition: xmlimprt.cxx:473
css::uno::Reference< css::util::XNumberFormatTypes > xNumberFormatTypes
Definition: xmlimprt.hxx:155
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:1000
ScMyTables aTables
Lift cycle managed elsewhere, no need to delete.
Definition: xmlimprt.hxx:140
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisStylesImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimprt.cxx:140
Provide mapping from ODF text formatting styles to EditEngine's, for rich-text cell content import...
static bool GetAddressFromString(ScAddress &rAddress, const OUString &rAddressStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator= ' ', sal_Unicode cQuote= '\'')
String to Range core.
Definition: rangeutl.cxx:435
#define SC_UNO_ODS_LOCK_SOLAR_MUTEX
Definition: unonames.hxx:700
XML_DOCUMENT_META
sal_Int32 nProgressCount
Definition: xmlimprt.hxx:162
XML_DOCUMENT_STYLES
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
Definition: documen2.cxx:1108
#define SC_ACTIVETABLE
SAL_DLLPUBLIC_EXPORT bool TestImportFODS(SvStream &rStream)
Definition: xmlimprt.cxx:1680
std::unique_ptr< ContentProperties > pData
ScDocument * pDoc
Definition: xmlimprt.hxx:122
void SetProtection(const css::uno::Sequence< sal_Int8 > &rPass)
Definition: chgtrack.hxx:1129
Store pivot table data that need to be post-processed at the end of the import.
Definition: pivotsource.hxx:26
constexpr sal_uInt16 XML_NAMESPACE_OOOC
ScDocument * GetDocument()
Definition: xmlimprt.hxx:206
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
Definition: documen9.cxx:193
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:167
void updateAbsAfterLoad()
Replace the original URL with the real URL that was generated from the relative URL.
constexpr OUStringLiteral PERCENT(u"Percent")
void StoreInitialNamespaces(const SvXMLNamespaceMap &rNamespaces)
Definition: sheetdata.cxx:172
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
Stores data imported from the file that need to be processed at the end of the import process...
static ScDocument * GetScDocument(const css::uno::Reference< css::frame::XModel > &xModel)
SvXMLNamespaceMap & GetNamespaceMap()
std::vector< ScDocRowHeightUpdater::TabRanges > maRecalcRowRanges
Definition: xmlimprt.hxx:142
SvXMLImportContext * CreateFontDeclsContext()
Definition: xmlimprt.cxx:429
SCTAB GetLastSheet() const
Definition: xmlstyli.hxx:104
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void SetLastSheet(SCTAB nNew)
Definition: xmlstyli.hxx:105
const ScXMLEditAttributeMap & GetEditAttributeMap() const
Definition: xmlimprt.cxx:1660
void RecalcPos(SdrObject *pObj, ScDrawObjData &rData, bool bNegativePage, bool bUpdateNoteCaptionPos)
Definition: drwlayer.cxx:990
OUString Name
OUString sPrevCurrency
Definition: xmlimprt.hxx:160
css::uno::Reference< css::frame::XModel > GetModel() const
bool mbLockSolarMutex
Definition: xmlimprt.hxx:167
Accessor class to ScDocument.
std::unique_ptr< ScMyImportValidations > pValidations
Definition: xmlimprt.hxx:148
EEControlBits
OUString sPrevStyleName
Definition: xmlimprt.hxx:159
bool IsAdjustHeightLocked() const
Definition: document.hxx:1532
#define XMLERROR_API
void SetFontDecls(XMLFontStylesContext *pFontDecls)
const sal_uInt16 XML_NAMESPACE_UNKNOWN
Value
SvXMLImportContext * CreateMetaContext(sal_Int32 nElement)
Definition: xmlimprt.cxx:456
rtl::Reference< XMLPropertySetMapper > xRowStylesPropertySetMapper
Definition: xmlimprt.hxx:135
bool SetNullDateOnUnitConverter()
Definition: xmlimprt.cxx:1103
Reference< XInputStream > xStream
SvXMLImportFlags
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:312
void LockSolarMutex()
Definition: xmlimprt.cxx:1518
std::unique_ptr< ScDocumentImport > mpDocImport
Definition: xmlimprt.hxx:123
sc::ImportPostProcessData * mpPostProcessData
Definition: xmlimprt.hxx:138
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
Definition: xmlstyli.cxx:511
int nCount
std::unique_ptr< sc::PivotTableSources > mpPivotSources
Definition: xmlimprt.hxx:126
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
Definition: document.cxx:258
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
Definition: documen3.cxx:617
sal_Int32 SetCurrencySymbol(const sal_Int32 nKey, const OUString &rCurrency)
Definition: xmlimprt.cxx:810
constexpr OUStringLiteral gsCellStyle(u""SC_UNONAME_CELLSTYL)
bool bSelfImportingXMLSet
Definition: xmlimprt.hxx:166
XML_DOCUMENT_SETTINGS
void FixupOLEs()
Definition: xmlsubti.hxx:77
FormulaError GetFormulaErrorConstant(const OUString &rStr) const
Definition: xmlimprt.cxx:1638
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)
ScXMLImport(const ScXMLImport &)=delete
void setX(tools::Long x)
const char * sName
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2389
virtual void SAL_CALL endDocument() override
Definition: xmlimprt.cxx:1357
SvXMLImportContext * CreateStylesContext(bool bAutoStyles)
Definition: xmlimprt.cxx:438
static bool GetRangeFromString(ScRange &rRange, const OUString &rRangeStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator= ' ', sal_Unicode cQuote= '\'')
SvXMLStylesContext * GetStyles()
bool bNullDateSetted
Definition: xmlimprt.hxx:165
OutputDevice * GetDevice() const
Definition: sizedev.hxx:41
void InsertStyles()
Definition: xmlimprt.cxx:607
SheetNamedExpMap m_SheetNamedExpressions
Definition: xmlimprt.hxx:145
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 GetValidation(const OUString &sName, ScMyImportValidation &aValidation)
Definition: xmlimprt.cxx:564
void ApplyCondFormat(const css::uno::Sequence< css::table::CellRangeAddress > &xCellRanges)
Definition: xmlstyli.cxx:467
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)
Definition: document.hxx:857
void ExamineDefaultStyle()
Definition: xmlimprt.cxx:616
This class exists only to provide GetScImport() to its derived classes.
void Increment(sal_Int32 nInc=1)
const OUString & getNumDecimalSep() const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1056
void setY(tools::Long y)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisSettingsImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimprt.cxx:164
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisContentImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimprt.cxx:152
const XMLPropertyMapEntry aXMLScTableStylesImportProperties[]
Definition: xmlstyle.cxx:154
bool IsImportingXML() const
Definition: document.hxx:2134
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats) override
Definition: xmlimprt.cxx:485
sal_Int32 GetNumberFormat()
Definition: xmlstyli.cxx:582
void SetPostProcessData(sc::ImportPostProcessData *p)
Definition: xmlimprt.cxx:308
int i
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
Definition: xmlimprt.cxx:752
void CopyStylesToDoc(bool bOverwrite, bool bFinish=true)
std::unique_ptr< ScXMLEditAttributeMap > mpEditAttrMap
Definition: xmlimprt.hxx:128
void CompileXML()
Definition: document.cxx:3968
virtual void SAL_CALL startDocument() override
Definition: xmlimprt.cxx:1152
static void decode(css::uno::Sequence< sal_Int8 > &aPass, const OUString &sBuffer)
static SC_DLLPUBLIC void Init()
DLL-init/exit-code must be linked to the DLL only.
Definition: scdll.cxx:99
void SetLoading(SfxLoadedFlags nFlags)
std::unique_ptr< ScMyStyleNumberFormats > pStyleNumberFormats
Definition: xmlimprt.hxx:153
SfxObjectShell * GetEmbeddedObject() const
Definition: docuno.cxx:453
void SetStyleToRanges()
Definition: xmlimprt.cxx:991
const sal_uInt16 XML_NAMESPACE_UNKNOWN_FLAG
bool HasRangeOverflow() const
Definition: document.hxx:2126
std::unique_ptr< ScCompiler > mpComp
Definition: xmlimprt.hxx:124
ScFormulaParserPool & GetFormulaParserPool() const
Returns the pool containing external formula parsers.
Definition: documen3.cxx:646
static void ConvertCellRangeAddress(OUString &sFormula)
const SdrPage * GetPage(sal_uInt16 nPgNum) const
bool IsCurrencySymbol(const sal_Int32 nNumberFormat, const OUString &sCurrencySymbol, std::u16string_view sBankSymbol)
Definition: xmlimprt.cxx:861
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
Definition: documen2.cxx:448
#define SC_CURRENCYSYMBOL
Definition: xmlimprt.cxx:106
SC_DLLPUBLIC void UnlockAdjustHeight()
Definition: document.cxx:1813
bool hasFormulaParser(const OUString &rNamespace)
Returns true, if a formula parser is registered for the passed namespace.
std::unique_ptr< ScMyLabelRanges > pMyLabelRanges
Definition: xmlimprt.hxx:147
const XMLPropertyMapEntry aXMLScColumnStylesProperties[]
Definition: xmlstyle.cxx:115
#define SC_UNO_ODS_IMPORT_STYLES
Definition: unonames.hxx:701
sal_uInt32 nSolarMutexLocked
Definition: xmlimprt.hxx:161
bool setNullDate(const css::uno::Reference< css::frame::XModel > &xModel)
ProgressBarHelper * GetProgressBarHelper()
Use this class to manage solar mutex locking instead of calling LockSolarMutex() and UnlockSolarMutex...
Definition: xmlimprt.hxx:294
void BroadcastUno(const SfxHint &rHint)
Definition: documen3.cxx:943
std::unique_ptr< ScMyNamedExpressions > m_pMyNamedExpressions
Definition: xmlimprt.hxx:144
#define SC_LOCALE
Definition: xmlimprt.cxx:105
formula::FormulaGrammar::Grammar GetStorageGrammar() const
Definition: document.hxx:2436
static sal_Int16 GetCellType(const char *rStrValue, const sal_Int32 nStrLength)
Definition: xmlimprt.cxx:518
const sal_uInt16 XML_NAMESPACE_NONE
ScXMLImport & mrImport
Definition: xmlimprt.hxx:300
void cleanup()
void ExtractFormulaNamespaceGrammar(OUString &rFormula, OUString &rFormulaNmsp,::formula::FormulaGrammar::Grammar &reGrammar, const OUString &rAttrValue, bool bRestrictToExternalNmsp=false) const
Extracts the formula string, the formula grammar namespace URL, and a grammar enum value from the pas...
Definition: xmlimprt.cxx:1579
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax
Definition: calcconfig.hxx:54
::std::list< std::unique_ptr< ScMyNamedExpression > > ScMyNamedExpressions
Definition: xmlimprt.hxx:77
std::map< sal_uInt64, OUString > maIDToName
Definition: sheetdata.hxx:177
FormulaError
XMLNumberFormatAttributesExportHelper * GetNumberFormatAttributesExportHelper()
Definition: xmlimprt.cxx:1111
std::unique_ptr< ScEditEngineDefaulter > mpEditEngine
Definition: xmlimprt.hxx:125
static sal_Int32 GetRangeType(const OUString &sRangeType)
Definition: xmlimprt.cxx:1199
#define SC_PRINT_RANGE
Definition: xmlimprt.cxx:109
std::unique_ptr< XMLNumberFormatAttributesExportHelper > pNumberFormatAttributesExportHelper
Definition: xmlimprt.hxx:152
#define SC_UNONAME_CELLSTYL
Definition: unonames.hxx:97
ScEditEngineDefaulter * GetEditEngine()
Definition: xmlimprt.cxx:1646
void SetRangeOverflowType(ErrCode nType)
Definition: document.hxx:2125
Configuration options for formula interpreter.
Definition: calcconfig.hxx:44
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimprt.cxx:116
css::uno::Reference< css::util::XNumberFormats > xNumberFormats
Definition: xmlimprt.hxx:154
SvXMLImportContext * CreateBodyContext(const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList)
Definition: xmlimprt.cxx:451
constexpr OUStringLiteral gsLocale(u""SC_LOCALE)
SAL_DLLPUBLIC_EXPORT bool TestImportXLSX(SvStream &rStream)
Definition: xmlimprt.cxx:1729
static const NfCurrencyEntry * GetLegacyOnlyCurrencyEntry(std::u16string_view rSymbol, std::u16string_view rAbbrev)
virtual void SAL_CALL startDocument() override
sal_Int16 nPrevCellType
Definition: xmlimprt.hxx:163
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Definition: xmlimprt.cxx:709
void SetNamedRanges()
Definition: xmlimprt.cxx:1311
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
void SetLabelRanges()
Definition: xmlimprt.cxx:1225
Reference< XMultiServiceFactory > getProcessServiceFactory()
std::unique_ptr< char[]> aBuffer
XML_DOCUMENT
bool IsStylesOnlyMode() const
Definition: xmlimprt.hxx:213
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
Definition: document.cxx:923
std::unique_ptr< SolarMutexGuard > pSolarMutexGuard
Definition: xmlimprt.hxx:150
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlimprt.cxx:410
#define SC_FILTER
Definition: xmlimprt.cxx:108
void LockAdjustHeight()
Definition: document.hxx:1533
XML_DOCUMENT_CONTENT
SvXMLImportFlags getImportFlags() const
OUString GetStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName) const
bool mbHasStringRefSyntax
Definition: calcconfig.hxx:57
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
ScMyStyleNumberFormats * GetStyleNumberFormats()
Definition: xmlimprt.cxx:1118
void AddCellStyle(const OUString &rName, const ScAddress &rCellPos)
Definition: sheetdata.cxx:41
void setWidth(tools::Long n)
rtl::Reference< XMLPropertySetMapper > xColumnStylesPropertySetMapper
Definition: xmlimprt.hxx:134
static ScDrawObjData * GetObjDataTab(SdrObject *pObj, SCTAB nTab)
Definition: drwlayer.cxx:2495
const ScCalcConfig & GetCalcConfig() const
Definition: document.hxx:2520
std::unique_ptr< ScMyStylesImportHelper > pStylesImportHelper
Definition: xmlimprt.hxx:130
void SetEmbedFonts(bool bUse)
Definition: document.hxx:578
rtl::Reference< XMLPropertySetMapper > xTableStylesPropertySetMapper
Definition: xmlimprt.hxx:136
#define SC_UNONAME_NUMFMT
Definition: unonames.hxx:106
SC_DLLPUBLIC void SetChangeTrack(std::unique_ptr< ScChangeTrack > pTrack)
only for import filter, deletes any existing ChangeTrack via EndChangeTracking() and takes ownership ...
Definition: documen2.cxx:271
#define SAL_INFO(area, stream)
const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
void UnlockSolarMutex()
Definition: xmlimprt.cxx:1536
bool DoInitNew(SfxMedium *pMedium=nullptr)
#define XMLERROR_FLAG_ERROR
XML_N_PRESENTATION
ScXMLChangeTrackingImportHelper * GetChangeTrackingImportHelper()
Definition: xmlimprt.cxx:600
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats)
const XMLPropertyMapEntry aXMLScRowStylesImportProperties[]
Definition: xmlstyle.cxx:123
std::unique_ptr< ScMyImpDetectiveOpArray > pDetectiveOpArray
Definition: xmlimprt.hxx:149
#define XML_ELEMENT(prefix, name)
sal_uInt16 Add(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey=XML_NAMESPACE_UNKNOWN)
virtual void DisposingModel() override
Definition: xmlimprt.cxx:1501
const SvXMLUnitConverter & GetMM100UnitConverter() const
const css::uno::Reference< css::frame::XModel > & GetModel() const
void * p
Reference< XComponentContext > getProcessComponentContext()
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:400
void InitializeCellAnchoredObj(SdrObject *pObj, ScDrawObjData &rData)
Definition: drwlayer.cxx:873
void SetValue(sal_Int32 nValue)
static void convertPropertySet(css::uno::Sequence< css::beans::PropertyValue > &rProps, const css::uno::Reference< css::beans::XPropertySet > &aProperties)
void SetError(sal_Int32 nId, const css::uno::Sequence< OUString > &rMsgParams, const OUString &rExceptionMessage, const css::uno::Reference< css::xml::sax::XLocator > &rLocator)
Sequence< sal_Int8 > aSeq
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
Definition: document.cxx:6049
constexpr sal_uInt16 XML_NAMESPACE_OF
#define SC_UNO_COLLABELRNG
Definition: unonames.hxx:41
bool bLoadDoc
Definition: xmlimprt.hxx:164
void AddStyleNumberFormat(const OUString &rStyleName, const sal_Int32 nNumberFormat)
const struct statistic s_stats[]
void SetAutoStyles(SvXMLStylesContext *pAutoStyles)
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:443
const XMLPropertyMapEntry aXMLScCellStylesProperties[]
Definition: xmlstyle.cxx:60
ScMyImpDetectiveOpArray * GetDetectiveOpArray()
Definition: xmlimprt.cxx:1673
static bool GetRangeListFromString(ScRangeList &rRangeList, const OUString &rRangeListStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator= ' ', sal_Unicode cQuote= '\'')
Definition: rangeutl.cxx:526
const OUString & getNumThousandSep() const
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
const css::uno::Reference< css::beans::XPropertySet > & getImportInfo() const
void SetReference(sal_Int32 nVal)
void SetChangeTrackingViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &rChangeProps)
Definition: xmlimprt.cxx:629
XML_NP_PRESENTATION
static bool isLatinScript(const ScPatternAttr &rPat, ScDocument &rDoc)
Check if the attribute pattern has a number format that only produces latin script output...
Definition: numformat.cxx:31
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1055
Reference< XModel > xModel
constexpr OUStringLiteral gsNumberFormat(u""SC_UNONAME_NUMFMT)
bool mbImportStyles
Definition: xmlimprt.hxx:168
#define DBG_TESTSOLARMUTEX()
virtual ~ScXMLImport() override
Definition: xmlimprt.cxx:392
virtual void DisposingModel()
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
rtl::Reference< XMLPropertyHandlerFactory > xScPropHdlFactory
Definition: xmlimprt.hxx:132
bool IsSheetBlocked(SCTAB nTab) const
Definition: sheetdata.cxx:100
void AddNamedExpression(ScMyNamedExpression *pMyNamedExpression)
Definition: xmlimprt.hxx:227
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
rtl::Reference< XMLPropertySetMapper > xCellStylesPropertySetMapper
Definition: xmlimprt.hxx:133
sal_Int32 GetByteOffset() const
Definition: xmlimprt.cxx:1549
#define SC_UNO_ROWLABELRNG
Definition: unonames.hxx:45
void ProgressBarIncrement()
Definition: xmlimprt.cxx:1569
sc::PivotTableSources & GetPivotTableSources()
Definition: xmlimprt.cxx:313
SvXMLStylesContext * GetAutoStyles()
SC_DLLPUBLIC void SetCalcConfig(const ScCalcConfig &rConfig)
Definition: document10.cxx:199
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlimprt.cxx:1132
css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier()
void SetType(const css::uno::Reference< css::beans::XPropertySet > &rProperties, sal_Int32 &rNumberFormat, const sal_Int16 nCellType, const OUString &rCurrency)
Definition: xmlimprt.cxx:913
MutexGuard(ScXMLImport &rImport)
Definition: xmlimprt.cxx:1507
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisMetaImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlimprt.cxx:128
double GetPPTX() const
Definition: sizedev.hxx:42
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
Definition: rangenam.cxx:807
virtual XMLShapeImportHelper * CreateShapeImport() override
Definition: xmlimprt.cxx:559
virtual void NotifyContainsEmbeddedFont() override
Definition: xmlimprt.cxx:1667
ScDocumentImport & GetDoc()
Definition: xmlimprt.cxx:513
void setHeight(tools::Long n)
sal_Int16 SCTAB
Definition: types.hxx:23
sal_uInt16 GetKeyByQName(const OUString &rQName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace, QNameMode eMode) const
virtual void SAL_CALL endDocument() override
bool any2bool(const css::uno::Any &rAny)
void SetStylesToRangesFinished()
Definition: xmlimprt.cxx:1125
void SetRangeOverflowType(ErrCode nType)
Definition: xmlimprt.cxx:1559
void SetSheetNamedRanges()
Definition: xmlimprt.cxx:1324
std::unique_ptr< ScXMLChangeTrackingImportHelper > pChangeTrackingImportHelper
Definition: xmlimprt.hxx:129