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 pSolarMutexGuard.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 OUString const sOrganizerMode(
1174 "OrganizerMode");
1175 if (xPropertySetInfo->hasPropertyByName(sOrganizerMode))
1176 {
1177 bool bStyleOnly(false);
1178 if (xImportInfo->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
1179 {
1180 bLoadDoc = !bStyleOnly;
1181 }
1182 }
1183 }
1184
1186}
1187
1188sal_Int32 ScXMLImport::GetRangeType(std::u16string_view sRangeType)
1189{
1190 sal_Int32 nRangeType(0);
1191 OUStringBuffer sBuffer;
1192 size_t i = 0;
1193 while (i <= sRangeType.size())
1194 {
1195 if ((i == sRangeType.size()) || (sRangeType[i] == ' '))
1196 {
1197 OUString sTemp = sBuffer.makeStringAndClear();
1198 if (sTemp == "repeat-column")
1200 else if (sTemp == SC_REPEAT_ROW)
1202 else if (sTemp == SC_FILTER)
1203 nRangeType |= sheet::NamedRangeFlag::FILTER_CRITERIA;
1204 else if (sTemp == SC_PRINT_RANGE)
1205 nRangeType |= sheet::NamedRangeFlag::PRINT_AREA;
1206 }
1207 else if (i < sRangeType.size())
1208 sBuffer.append(sRangeType[i]);
1209 ++i;
1210 }
1211 return nRangeType;
1212}
1213
1215{
1216 if (maMyLabelRanges.empty())
1217 return;
1218
1219 uno::Reference <beans::XPropertySet> xPropertySet (GetModel(), uno::UNO_QUERY);
1220 if (!xPropertySet.is())
1221 return;
1222
1223 uno::Any aColAny = xPropertySet->getPropertyValue(SC_UNO_COLLABELRNG);
1224 uno::Any aRowAny = xPropertySet->getPropertyValue(SC_UNO_ROWLABELRNG);
1225
1226 uno::Reference< sheet::XLabelRanges > xColRanges;
1227 uno::Reference< sheet::XLabelRanges > xRowRanges;
1228
1229 if ( !(( aColAny >>= xColRanges ) && ( aRowAny >>= xRowRanges )) )
1230 return;
1231
1232 table::CellRangeAddress aLabelRange;
1233 table::CellRangeAddress aDataRange;
1234
1235 for (const auto& rLabelRange : maMyLabelRanges)
1236 {
1237 sal_Int32 nOffset1(0);
1238 sal_Int32 nOffset2(0);
1239 FormulaGrammar::AddressConvention eConv = FormulaGrammar::CONV_OOO;
1240
1241 assert(pDoc);
1242 if (ScRangeStringConverter::GetRangeFromString( aLabelRange, rLabelRange.sLabelRangeStr, *pDoc, eConv, nOffset1 ) &&
1243 ScRangeStringConverter::GetRangeFromString( aDataRange, rLabelRange.sDataRangeStr, *pDoc, eConv, nOffset2 ))
1244 {
1245 if ( rLabelRange.bColumnOrientation )
1246 xColRanges->addNew( aLabelRange, aDataRange );
1247 else
1248 xRowRanges->addNew( aLabelRange, aDataRange );
1249 }
1250 }
1251
1252 maMyLabelRanges.clear();
1253}
1254
1255namespace {
1256
1257class RangeNameInserter
1258{
1259 ScDocument& mrDoc;
1260 ScRangeName& mrRangeName;
1261 SCTAB mnTab;
1262
1263public:
1264 RangeNameInserter(ScDocument& rDoc, ScRangeName& rRangeName, SCTAB nTab) :
1265 mrDoc(rDoc), mrRangeName(rRangeName), mnTab(nTab) {}
1266
1267 void operator() (const ScMyNamedExpression& p) const
1268 {
1269 using namespace formula;
1270
1271 const OUString& aType = p.sRangeType;
1272 sal_uInt32 nUnoType = ScXMLImport::GetRangeType(aType);
1273
1275 if ( nUnoType & sheet::NamedRangeFlag::FILTER_CRITERIA ) nNewType |= ScRangeData::Type::Criteria;
1276 if ( nUnoType & sheet::NamedRangeFlag::PRINT_AREA ) nNewType |= ScRangeData::Type::PrintArea;
1279
1280 // Insert a new name.
1281 ScAddress aPos;
1282 sal_Int32 nOffset = 0;
1284 aPos, p.sBaseCellAddress, mrDoc, FormulaGrammar::CONV_OOO, nOffset);
1285
1286 if (!bSuccess)
1287 {
1288 SAL_WARN("sc.filter", "No conversion from table:base-cell-address '" << p.sBaseCellAddress
1289 << "' for name '" << p.sName << "' on sheet " << mnTab);
1290 // Do not lose the defined name. Relative addressing in
1291 // content/expression, if any, will be broken though.
1292 // May had happened due to tdf#150312.
1293 aPos.SetTab(mnTab < 0 ? 0 : mnTab);
1294 bSuccess = true;
1295 }
1296
1297 if (bSuccess)
1298 {
1299 OUString aContent = p.sContent;
1300 if (!p.bIsExpression)
1302
1304 mrDoc, p.sName, aContent, aPos, nNewType, p.eGrammar);
1305 mrRangeName.insert(pData);
1306 }
1307 }
1308};
1309
1310}
1311
1313{
1314 if (m_aMyNamedExpressions.empty())
1315 return;
1316
1317 if (!pDoc)
1318 return;
1319
1320 // Insert the namedRanges
1321 ScRangeName* pRangeNames = pDoc->GetRangeName();
1322 ::std::for_each(m_aMyNamedExpressions.begin(), m_aMyNamedExpressions.end(),
1323 RangeNameInserter(*pDoc, *pRangeNames, -1));
1324}
1325
1327{
1328 if (!pDoc)
1329 return;
1330
1331 for (auto const& itr : m_SheetNamedExpressions)
1332 {
1333 const SCTAB nTab = itr.first;
1334 ScRangeName* pRangeNames = pDoc->GetRangeName(nTab);
1335 if (!pRangeNames)
1336 continue;
1337
1338 const ScMyNamedExpressions& rNames = itr.second;
1339 ::std::for_each(rNames.begin(), rNames.end(), RangeNameInserter(*pDoc, *pRangeNames, nTab));
1340 }
1341}
1342
1344{
1345 if (!pDoc)
1346 return;
1347
1348 ScCalcConfig aCalcConfig = pDoc->GetCalcConfig();
1349
1350 // Has any string ref syntax been imported?
1351 // If not, we need to take action
1352 if ( !aCalcConfig.mbHasStringRefSyntax )
1353 {
1355 pDoc->SetCalcConfig(aCalcConfig);
1356 }
1357}
1358
1360{
1361 ScXMLImport::MutexGuard aGuard(*this);
1362 if (getImportFlags() & SvXMLImportFlags::CONTENT)
1363 {
1364 if (GetModel().is())
1365 {
1366 mpDocImport->finalize();
1367
1368 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1369 if (xViewDataSupplier.is())
1370 {
1371 uno::Reference<container::XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
1372 if (xIndexAccess.is() && xIndexAccess->getCount() > 0)
1373 {
1374 uno::Sequence< beans::PropertyValue > aSeq;
1375 if (xIndexAccess->getByIndex(0) >>= aSeq)
1376 {
1377 for (const auto& rProp : std::as_const(aSeq))
1378 {
1379 OUString sName(rProp.Name);
1380 if (sName == SC_ACTIVETABLE)
1381 {
1382 OUString sTabName;
1383 if(rProp.Value >>= sTabName)
1384 {
1385 SCTAB nTab(0);
1386 if (pDoc->GetTable(sTabName, nTab))
1387 {
1388 pDoc->SetVisibleTab(nTab);
1389 break;
1390 }
1391 }
1392 }
1393 }
1394 }
1395 }
1396 }
1401 if (mpPivotSources)
1402 // Process pivot table sources after the named ranges have been set.
1403 mpPivotSources->process();
1404 }
1405 GetProgressBarHelper()->End(); // make room for subsequent SfxProgressBars
1406 if (pDoc)
1407 {
1408 pDoc->CompileXML();
1409
1410 // After CompileXML, links must be completely changed to the new URLs.
1411 // Otherwise, hasExternalFile for API wouldn't work (#i116940#),
1412 // and typing a new formula would create a second link with the same "real" file name.
1415 }
1416
1417 // If the stream contains cells outside of the current limits, the styles can't be re-created,
1418 // so stream copying is disabled then.
1419 if (pDoc && GetModel().is() && !pDoc->HasRangeOverflow())
1420 {
1421 // set "valid stream" flags after loading (before UpdateRowHeights, so changed formula results
1422 // in UpdateRowHeights can already clear the flags again)
1423 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetSheetSaveData();
1424
1425 SCTAB nTabCount = pDoc->GetTableCount();
1426 for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
1427 {
1428 pDoc->SetDrawPageSize(nTab);
1429 if (!pSheetData->IsSheetBlocked( nTab ))
1430 pDoc->SetStreamValid( nTab, true );
1431 }
1432 }
1433
1434 // There are rows with optimal height which need to be updated
1435 if (pDoc && !maRecalcRowRanges.empty())
1436 {
1437 bool bLockHeight = pDoc->IsAdjustHeightLocked();
1438 if (bLockHeight)
1439 {
1441 }
1442
1443 ScSizeDeviceProvider aProv(static_cast<ScDocShell*>(pDoc->GetDocumentShell()));
1444 ScDocRowHeightUpdater aUpdater(*pDoc, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), &maRecalcRowRanges);
1445 aUpdater.update();
1446
1447 if (bLockHeight)
1448 {
1450 }
1451 }
1452
1453 // Initialize and set position and size of objects
1454 if (pDoc && pDoc->GetDrawLayer())
1455 {
1456 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1457 SCTAB nTabCount = pDoc->GetTableCount();
1458 for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
1459 {
1460 const SdrPage* pPage = pDrawLayer->GetPage(nTab);
1461 if (!pPage)
1462 continue;
1463 bool bNegativePage = pDoc->IsNegativePage(nTab);
1464 const size_t nCount = pPage->GetObjCount();
1465 for (size_t i = 0; i < nCount; ++i)
1466 {
1467 SdrObject* pObj = pPage->GetObj(i);
1469 = ScDrawLayer::GetObjDataTab(pObj, nTab);
1470 // Existence of pData means, that it is a cell anchored object
1471 if (pData)
1472 {
1473 // Finish and correct import based on full size (no hidden row/col) and LTR
1474 pDrawLayer->InitializeCellAnchoredObj(pObj, *pData);
1475 // Adapt object to hidden row/col and RTL
1476 pDrawLayer->RecalcPos(pObj, *pData, bNegativePage,
1477 true /*bUpdateNoteCaptionPos*/);
1478 }
1479 }
1480 }
1481 }
1482
1484 }
1485 if (GetModel().is())
1486 {
1487 uno::Reference<document::XActionLockable> xActionLockable(GetModel(), uno::UNO_QUERY);
1488 if (xActionLockable.is())
1489 xActionLockable->removeActionLock();
1490 }
1491 SvXMLImport::endDocument();
1492
1493 if (pDoc)
1494 {
1495 pDoc->BroadcastUno(SfxHint(SfxHintId::ScClearCache));
1496 }
1497
1499 comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->AfterXMLLoading();
1500}
1501
1502// XEventListener
1504{
1505 SvXMLImport::DisposingModel();
1506 pDoc = nullptr;
1507}
1508
1510 mrImport(rImport)
1511{
1513}
1514
1516{
1517 mrImport.UnlockSolarMutex();
1518}
1519
1521{
1522 // #i62677# When called from DocShell/Wrapper, the SolarMutex is already locked,
1523 // so there's no need to allocate (and later delete) the SolarMutexGuard.
1524 if (!mbLockSolarMutex)
1525 {
1527 return;
1528 }
1529
1530 if (nSolarMutexLocked == 0)
1531 {
1532 OSL_ENSURE(!pSolarMutexGuard, "Solar Mutex is locked");
1533 pSolarMutexGuard.reset(new SolarMutexGuard());
1534 }
1536}
1537
1539{
1540 if (nSolarMutexLocked > 0)
1541 {
1543 if (nSolarMutexLocked == 0)
1544 {
1545 OSL_ENSURE(pSolarMutexGuard, "Solar Mutex is always unlocked");
1546 pSolarMutexGuard.reset();
1547 }
1548 }
1549}
1550
1552{
1553 sal_Int32 nOffset = -1;
1554 uno::Reference<xml::sax::XLocator> xLocator = GetLocator();
1555 uno::Reference<io::XSeekable> xSeek( xLocator, uno::UNO_QUERY );
1556 if ( xSeek.is() )
1557 nOffset = static_cast<sal_Int32>(xSeek->getPosition());
1558 return nOffset;
1559}
1560
1562{
1563 // #i31130# Overflow is stored in the document, because the ScXMLImport object
1564 // isn't available in ScXMLImportWrapper::ImportFromComponent when using the
1565 // OOo->Oasis transformation.
1566
1567 if ( pDoc )
1569}
1570
1572{
1574 if (nProgressCount > 100)
1575 {
1576 GetProgressBarHelper()->Increment(nProgressCount);
1577 nProgressCount = 0;
1578 }
1579}
1580
1582 OUString& rFormula, OUString& rFormulaNmsp, FormulaGrammar::Grammar& reGrammar,
1583 const OUString& rAttrValue, bool bRestrictToExternalNmsp ) const
1584{
1585 // parse the attribute value, extract namespace ID, literal namespace, and formula string
1586 rFormulaNmsp.clear();
1587 sal_uInt16 nNsId = GetNamespaceMap().GetKeyByQName(rAttrValue, nullptr, &rFormula, &rFormulaNmsp, SvXMLNamespaceMap::QNameMode::AttrValue);
1588
1589 // check if we have an ODF formula namespace
1590 if( !bRestrictToExternalNmsp ) switch( nNsId )
1591 {
1592 case XML_NAMESPACE_OOOC:
1593 rFormulaNmsp.clear(); // remove namespace string for built-in grammar
1594 reGrammar = FormulaGrammar::GRAM_PODF;
1595 return;
1596 case XML_NAMESPACE_OF:
1597 rFormulaNmsp.clear(); // remove namespace string for built-in grammar
1598 reGrammar = FormulaGrammar::GRAM_ODFF;
1599 return;
1600 }
1601
1602 /* Find default grammar for formulas without namespace. There may be
1603 documents in the wild that stored no namespace in ODF 1.0/1.1. Use
1604 GRAM_PODF then (old style ODF 1.0/1.1 formulas). The default for ODF
1605 1.2 and later without namespace is GRAM_ODFF (OpenFormula). */
1606 FormulaGrammar::Grammar eDefaultGrammar =
1607 (GetDocument()->GetStorageGrammar() == FormulaGrammar::GRAM_PODF) ?
1608 FormulaGrammar::GRAM_PODF : FormulaGrammar::GRAM_ODFF;
1609
1610 /* Check if we have no namespace at all. The value XML_NAMESPACE_NONE
1611 indicates that there is no colon. If the first character of the
1612 attribute value is the equality sign, the value XML_NAMESPACE_UNKNOWN
1613 indicates that there is a colon somewhere in the formula string. */
1614 if( (nNsId == XML_NAMESPACE_NONE) || ((nNsId == XML_NAMESPACE_UNKNOWN) && (rAttrValue.toChar() == '=')) )
1615 {
1616 rFormula = rAttrValue; // return entire string as formula
1617 reGrammar = eDefaultGrammar;
1618 return;
1619 }
1620
1621 /* Check if a namespace URL could be resolved from the attribute value.
1622 Use that namespace only, if the Calc document knows an associated
1623 external formula parser. This prevents that the range operator in
1624 conjunction with defined names is confused as namespaces prefix, e.g.
1625 in the expression 'table:A1' where 'table' is a named reference. */
1626 if( ((nNsId & XML_NAMESPACE_UNKNOWN_FLAG) != 0) && !rFormulaNmsp.isEmpty() &&
1628 {
1629 reGrammar = FormulaGrammar::GRAM_EXTERNAL;
1630 return;
1631 }
1632
1633 /* All attempts failed (e.g. no namespace and no leading equality sign, or
1634 an invalid namespace prefix), continue with the entire attribute value. */
1635 rFormula = rAttrValue;
1636 rFormulaNmsp.clear(); // remove any namespace string
1637 reGrammar = eDefaultGrammar;
1638}
1639
1641{
1642 if (!mpComp)
1643 return FormulaError::NONE;
1644
1645 return mpComp->GetErrorConstant(rStr);
1646}
1647
1649{
1650 if (!mpEditEngine)
1651 {
1653 mpEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
1654 mpEditEngine->SetEditTextObjectPool(pDoc->GetEditPool());
1655 mpEditEngine->SetUpdateLayout(false);
1656 mpEditEngine->EnableUndo(false);
1657 mpEditEngine->SetControlWord(mpEditEngine->GetControlWord() & ~EEControlBits::ALLOWBIGOBJS);
1658 }
1659 return mpEditEngine.get();
1660}
1661
1663{
1664 if (!mpEditAttrMap)
1666 return *mpEditAttrMap;
1667}
1668
1670{
1671 if (pDoc)
1672 pDoc->SetEmbedFonts(true);
1673}
1674
1676{
1677 if (!pDetectiveOpArray)
1679 return pDetectiveOpArray.get();
1680}
1681
1682extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODS(SvStream &rStream)
1683{
1684 ScDLL::Init();
1685
1686 SfxObjectShellLock xDocSh(new ScDocShell);
1687 xDocSh->DoInitNew();
1688 uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
1689
1690 uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
1691 uno::Reference<io::XInputStream> xStream(new ::utl::OSeekableInputStreamWrapper(rStream));
1692 uno::Reference<uno::XInterface> xInterface(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.XmlFilterAdaptor"), uno::UNO_SET_THROW);
1693
1694 css::uno::Sequence<OUString> aUserData
1695 {
1696 "com.sun.star.comp.filter.OdfFlatXml",
1697 "",
1698 "com.sun.star.comp.Calc.XMLOasisImporter",
1699 "com.sun.star.comp.Calc.XMLOasisExporter",
1700 "",
1701 "",
1702 "true"
1703 };
1704 uno::Sequence<beans::PropertyValue> aAdaptorArgs(comphelper::InitPropertySequence(
1705 {
1706 { "UserData", uno::Any(aUserData) },
1707 }));
1708 css::uno::Sequence<uno::Any> aOuterArgs{ uno::Any(aAdaptorArgs) };
1709
1710 uno::Reference<lang::XInitialization> xInit(xInterface, uno::UNO_QUERY_THROW);
1711 xInit->initialize(aOuterArgs);
1712
1713 uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
1714 uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
1715 {
1716 { "InputStream", uno::Any(xStream) },
1717 { "URL", uno::Any(OUString("private:stream")) },
1718 }));
1719 xImporter->setTargetDocument(xModel);
1720
1721 uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
1722 //SetLoading hack because the document properties will be re-initted
1723 //by the xml filter and during the init, while it's considered uninitialized,
1724 //setting a property will inform the document it's modified, which attempts
1725 //to update the properties, which throws cause the properties are uninitialized
1726 xDocSh->SetLoading(SfxLoadedFlags::NONE);
1727 bool ret = xFilter->filter(aArgs);
1728 xDocSh->SetLoading(SfxLoadedFlags::ALL);
1729
1730 xDocSh->DoClose();
1731
1732 return ret;
1733}
1734
1735extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportXLSX(SvStream &rStream)
1736{
1737 ScDLL::Init();
1738
1739 SfxObjectShellLock xDocSh(new ScDocShell);
1740 xDocSh->DoInitNew();
1741 uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
1742
1743 uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
1744 uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
1745
1746 uno::Reference<document::XFilter> xFilter(xMultiServiceFactory->createInstance("com.sun.star.comp.oox.xls.ExcelFilter"), uno::UNO_QUERY_THROW);
1747
1748 uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
1749 uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
1750 {
1751 { "InputStream", uno::Any(xStream) },
1752 { "InputMode", uno::Any(true) },
1753 }));
1754 xImporter->setTargetDocument(xModel);
1755
1756 //SetLoading hack because the document properties will be re-initted
1757 //by the xml filter and during the init, while it's considered uninitialized,
1758 //setting a property will inform the document it's modified, which attempts
1759 //to update the properties, which throws cause the properties are uninitialized
1760 xDocSh->SetLoading(SfxLoadedFlags::NONE);
1761 bool ret = false;
1762 try
1763 {
1764 ret = xFilter->filter(aArgs);
1765 }
1766 catch (const css::io::IOException&)
1767 {
1768 }
1769 catch (const css::lang::WrappedTargetRuntimeException&)
1770 {
1771 }
1772 xDocSh->SetLoading(SfxLoadedFlags::ALL);
1773
1774 xDocSh->DoClose();
1775
1776 return ret;
1777}
1778
1779/* 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:1121
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
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:6165
ScFormulaParserPool & GetFormulaParserPool() const
Returns the pool containing external formula parsers.
Definition: documen3.cxx:662
const ScCalcConfig & GetCalcConfig() const
Definition: document.hxx:2616
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
Definition: document.cxx:264
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)
Definition: document.hxx:879
bool IsAdjustHeightLocked() const
Definition: document.hxx:1597
void CompileXML()
Definition: document.cxx:4034
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:1006
formula::FormulaGrammar::Grammar GetStorageGrammar() const
Definition: document.hxx:2536
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
Definition: documen3.cxx:633
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
Definition: documen2.cxx:1153
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
Definition: document.cxx:937
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:473
void SetEmbedFonts(bool bUse)
Definition: document.hxx:588
bool HasRangeOverflow() const
Definition: document.hxx:2214
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
Definition: documen9.cxx:195
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1082
SC_DLLPUBLIC void SetCalcConfig(const ScCalcConfig &rConfig)
Definition: document10.cxx:203
void SetRangeOverflowType(ErrCode nType)
Definition: document.hxx:2213
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1081
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:174
bool HasExternalRefManager() const
Definition: document.hxx:1026
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2487
void LockAdjustHeight()
Definition: document.hxx:1598
SC_DLLPUBLIC void UnlockAdjustHeight()
Definition: document.cxx:1811
bool IsImportingXML() const
Definition: document.hxx:2222
void BroadcastUno(const SfxHint &rHint)
Definition: documen3.cxx:958
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:317
static ScDrawObjData * GetObjDataTab(SdrObject *pObj, SCTAB nTab)
Definition: drwlayer.cxx:2617
void RecalcPos(SdrObject *pObj, ScDrawObjData &rData, bool bNegativePage, bool bUpdateNoteCaptionPos)
Definition: drwlayer.cxx:1023
void InitializeCellAnchoredObj(SdrObject *pObj, ScDrawObjData &rData)
Definition: drwlayer.cxx:906
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:1509
std::unique_ptr< ScMyStyleNumberFormats > pStyleNumberFormats
Definition: xmlimprt.hxx:152
bool mbImportStyles
Definition: xmlimprt.hxx:167
void ProgressBarIncrement()
Definition: xmlimprt.cxx:1571
std::unique_ptr< SolarMutexGuard > pSolarMutexGuard
Definition: xmlimprt.hxx:149
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:1669
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:1520
void SetNamedRanges()
Definition: xmlimprt.cxx:1312
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:1503
void AddNamedExpression(ScMyNamedExpression aMyNamedExpression)
Definition: xmlimprt.hxx:226
static sal_Int32 GetRangeType(std::u16string_view sRangeType)
Definition: xmlimprt.cxx:1188
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:1214
virtual void SAL_CALL endDocument() override
Definition: xmlimprt.cxx:1359
FormulaError GetFormulaErrorConstant(const OUString &rStr) const
Definition: xmlimprt.cxx:1640
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:1326
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:1675
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:1662
ScXMLChangeTrackingImportHelper * GetChangeTrackingImportHelper()
Definition: xmlimprt.cxx:589
ScDocument * GetDocument()
Definition: xmlimprt.hxx:205
void UnlockSolarMutex()
Definition: xmlimprt.cxx:1538
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
void SetStylesToRangesFinished()
Definition: xmlimprt.cxx:1111
SvXMLImportContext * CreateStylesContext(bool bAutoStyles)
Definition: xmlimprt.cxx:431
void SetRangeOverflowType(ErrCode nType)
Definition: xmlimprt.cxx:1561
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:1581
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:1551
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:1343
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:1648
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)
void ApplyCondFormat(const css::uno::Sequence< css::table::CellRangeAddress > &xCellRanges)
Definition: xmlstyli.cxx:466
SCTAB GetLastSheet() const
Definition: xmlstyli.hxx:103
void SetLastSheet(SCTAB nNew)
Definition: xmlstyli.hxx:104
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
Definition: xmlstyli.cxx:510
sal_Int32 GetNumberFormat()
Definition: xmlstyli.cxx:581
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:31
void setWidth(tools::Long n)
SvxRedlinDateMode
int nCount
#define DBG_TESTSOLARMUTEX()
float u
FormulaError
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
const char * sName
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:107
constexpr OUStringLiteral SC_UNO_ODS_IMPORT_STYLES
Definition: unonames.hxx:710
constexpr OUStringLiteral SC_UNO_COLLABELRNG
Definition: unonames.hxx:42
constexpr OUStringLiteral SC_UNO_ODS_LOCK_SOLAR_MUTEX
Definition: unonames.hxx:709
constexpr OUStringLiteral SC_UNONAME_CELLSTYL
Definition: unonames.hxx:98
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:1735
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:1682
::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:123
const XMLPropertyMapEntry aXMLScTableStylesImportProperties[]
Definition: xmlstyle.cxx:154
const XMLPropertyMapEntry aXMLScColumnStylesProperties[]
Definition: xmlstyle.cxx:115
const XMLPropertyMapEntry aXMLScCellStylesProperties[]
Definition: xmlstyle.cxx:60
int SetError()