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