22#include <osl/diagnose.h>
50#include <document.hxx>
58#include <compiler.hxx>
74#include <unonames.hxx>
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>
114extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
116 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
118 return cppu::acquire(
121 "com.sun.star.comp.Calc.XMLOasisImporter",
122 SvXMLImportFlags::ALL,
123 {
"com.sun.star.comp.Calc.XMLOasisImporter" } ));
126extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
128 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
130 return cppu::acquire(
133 "com.sun.star.comp.Calc.XMLOasisMetaImporter",
134 SvXMLImportFlags::META,
135 {
"com.sun.star.comp.Calc.XMLOasisMetaImporter" } ));
138extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
140 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
142 return cppu::acquire(
145 "com.sun.star.comp.Calc.XMLOasisStylesImporter",
146 SvXMLImportFlags::STYLES|SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::MASTERSTYLES|SvXMLImportFlags::FONTDECLS,
147 {
"com.sun.star.comp.Calc.XMLOasisStylesImporter" } ));
150extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
152 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
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" }));
162extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
164 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
166 return cppu::acquire(
169 "com.sun.star.comp.Calc.XMLOasisSettingsImporter",
170 SvXMLImportFlags::SETTINGS,
171 {
"com.sun.star.comp.Calc.XMLOasisSettingsImporter" } ));
186 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
188 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList )
override;
193ScXMLDocContext_Impl::ScXMLDocContext_Impl(
ScXMLImport& rImport ) :
201class ScXMLFlatDocContext_Impl
207 const uno::Reference<document::XDocumentProperties>& i_xDocProps);
209 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
211 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList )
override;
216ScXMLFlatDocContext_Impl::ScXMLFlatDocContext_Impl(
ScXMLImport& i_rImport,
217 const uno::Reference<document::XDocumentProperties>& i_xDocProps) :
219ScXMLDocContext_Impl(i_rImport),
224uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
225 ScXMLFlatDocContext_Impl::createFastChildContext( sal_Int32 nElement,
226 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
231 return ScXMLDocContext_Impl::createFastChildContext( nElement, xAttrList );
241 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
243 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList )
override;
248ScXMLBodyContext_Impl::ScXMLBodyContext_Impl(
ScXMLImport& rImport ) :
253uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
254 ScXMLBodyContext_Impl::createFastChildContext( sal_Int32 ,
255 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
259 return GetScImport().CreateBodyContext( pAttribList );
262uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
263 ScXMLDocContext_Impl::createFastChildContext( sal_Int32 nElement,
264 const uno::Reference< xml::sax::XFastAttributeList > & )
272 pContext = new ScXMLBodyContext_Impl( GetScImport() );
276 pContext = GetScImport().CreateScriptContext();
284 pContext = GetScImport().CreateStylesContext( false);
288 pContext = GetScImport().CreateStylesContext( true);
292 pContext = GetScImport().CreateFontDeclsContext();
299 SAL_INFO(
"sc",
"XML_ELEMENT(OFFICE, XML_META): should not have come here, maybe document is invalid?");
321 const uno::Reference< xml::sax::XFastAttributeList >& )
330 pContext =
new ScXMLDocContext_Impl( *
this );
339 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
340 GetModel(), uno::UNO_QUERY_THROW);
342 pContext =
new ScXMLFlatDocContext_Impl( *
this,
343 xDPS->getDocumentProperties());
353 const css::uno::Reference< css::uno::XComponentContext >& rContext,
355 const css::uno::Sequence< OUString > & sSupportedServiceNames)
358 mpPostProcessData(nullptr),
360 nSolarMutexLocked(0),
364 bNullDateSetted(false),
365 bSelfImportingXMLSet(false),
366 mbLockSolarMutex(true),
367 mbImportStyles(true),
368 mbHasNewCondFormatData(false)
379 GetNamespaceMap().Add(
407 uno::Reference<beans::XPropertySet> xInfoSet = getImportInfo();
411 uno::Reference<beans::XPropertySetInfo> xInfoSetInfo = xInfoSet->getPropertySetInfo();
412 if (!xInfoSetInfo.is())
425 *
this, osl_getThreadTextEncoding());
426 SetFontDecls(pFSContext);
434 *
this, bIsAutoStyle);
454 if (getImportFlags() & SvXMLImportFlags::META)
456 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
457 GetModel(), uno::UNO_QUERY_THROW);
458 uno::Reference<document::XDocumentProperties>
const xDocProps(
481 {
"TableCount",
"CellCount",
"ObjectCount",
nullptr };
483 SvXMLImport::SetStatistics(i_rStats);
486 for (
const auto& rStat : i_rStats) {
487 for (
const char** pStat =
s_stats; *pStat !=
nullptr; ++pStat) {
488 if (rStat.Name.equalsAscii(*pStat)) {
490 if (rStat.Value >>= val) {
493 OSL_FAIL(
"ScXMLImport::SetStatistics: invalid entry");
501 GetProgressBarHelper()->SetReference(
nCount);
502 GetProgressBarHelper()->SetValue(0);
513 sal_Int16 nCellType = util::NumberFormat::UNDEFINED;
514 if (rStrValue !=
nullptr)
516 switch (rStrValue[0])
519 if (nStrLength == 7 && !strcmp(rStrValue,
"boolean"))
520 nCellType = util::NumberFormat::LOGICAL;
523 if (nStrLength == 8 && !strcmp(rStrValue,
"currency"))
524 nCellType = util::NumberFormat::CURRENCY;
527 if (nStrLength == 4 && !strcmp(rStrValue,
"date"))
528 nCellType = util::NumberFormat::DATETIME;
531 if (nStrLength == 5 && !strcmp(rStrValue,
"float"))
532 nCellType = util::NumberFormat::NUMBER;
535 if (nStrLength == 10 && !strcmp(rStrValue,
"percentage"))
539 if (nStrLength == 6 && !strcmp(rStrValue,
"string"))
540 nCellType = util::NumberFormat::TEXT;
543 if (nStrLength == 4 && !strcmp(rStrValue,
"time"))
544 nCellType = util::NumberFormat::TIME;
577 ::std::pair<SheetNamedExpMap::iterator, bool> r =
586 r.push_back(std::move(aNamedExp));
598 GetStyles()->CopyStylesToDoc(
true);
601 if ( getImportFlags() & SvXMLImportFlags::CONTENT )
614 mpDocImport->setDefaultNumericScript(SvtScriptType::LATIN);
623 if (!rChangeProps.hasElements())
627 sal_Int16 nTemp16(0);
629 for (
const auto& rChangeProp : rChangeProps)
631 OUString
sName(rChangeProp.Name);
632 if (
sName ==
"ShowChanges")
633 aViewSettings.
SetShowChanges(::cppu::any2bool(rChangeProp.Value));
634 else if (
sName ==
"ShowAcceptedChanges")
636 else if (
sName ==
"ShowRejectedChanges")
638 else if (
sName ==
"ShowChangesByDatetime")
639 aViewSettings.
SetHasDate(::cppu::any2bool(rChangeProp.Value));
640 else if (
sName ==
"ShowChangesByDatetimeMode")
642 if (rChangeProp.Value >>= nTemp16)
645 else if (
sName ==
"ShowChangesByDatetimeFirstDatetime")
647 util::DateTime aDateTime;
648 if (rChangeProp.Value >>= aDateTime)
653 else if (
sName ==
"ShowChangesByDatetimeSecondDatetime")
655 util::DateTime aDateTime;
656 if (rChangeProp.Value >>= aDateTime)
661 else if (
sName ==
"ShowChangesByAuthor")
662 aViewSettings.
SetHasAuthor(::cppu::any2bool(rChangeProp.Value));
663 else if (
sName ==
"ShowChangesByAuthorName")
666 if (rChangeProp.Value >>= sOUName)
671 else if (
sName ==
"ShowChangesByComment")
672 aViewSettings.
SetHasComment(::cppu::any2bool(rChangeProp.Value));
673 else if (
sName ==
"ShowChangesByCommentText")
676 if (rChangeProp.Value >>= sOUComment)
681 else if (
sName ==
"ShowChangesByRanges")
682 aViewSettings.
SetHasRange(::cppu::any2bool(rChangeProp.Value));
683 else if (
sName ==
"ShowChangesByRangesList")
686 if ((rChangeProp.Value >>= sRanges) && !sRanges.isEmpty())
690 aRangeList, sRanges, *
pDoc, FormulaGrammar::CONV_OOO);
700 sal_Int32 nHeight(0);
704 for (
const auto& rViewProp : aViewProps)
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")
717 uno::Sequence<beans::PropertyValue> aChangeProps;
718 if(rViewProp.Value >>= aChangeProps)
722 if (!(nHeight && nWidth && GetModel().is()))
725 ScModelObj* pDocObj(comphelper::getFromUnoTunnel<ScModelObj>( GetModel() ));
734 aRect.setHeight( nHeight );
741 if (!GetModel().is())
744 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
745 if (!xMultiServiceFactory.is())
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)
754 if (aConfigProps[
i].
Name ==
"TrackedChangesProtectionKey")
757 if (aConfigProps[
i].
Value >>= sKey)
759 uno::Sequence<sal_Int8> aPass;
761 if (aPass.hasElements())
767 std::set<OUString> aUsers;
768 std::unique_ptr<ScChangeTrack> pTrack(
new ScChangeTrack(*
pDoc, std::move(aUsers)) );
769 pTrack->SetProtection(aPass);
776 else if ((aConfigProps[
i].
Name ==
"VBACompatibilityMode") || (aConfigProps[
i].
Name ==
"ScriptConfiguration"))
778 uno::Reference< beans::XPropertySet > xImportInfo = getImportInfo();
779 if (xImportInfo.is())
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 );
786 if (aConfigProps[
i].
Name !=
"LinkUpdateMode")
788 pFilteredProps[nFilteredPropsLen++] = aConfigProps[
i];
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())
800 uno::Reference <util::XNumberFormatsSupplier> xNumberFormatsSupplier(GetNumberFormatsSupplier());
801 if (xNumberFormatsSupplier.is())
803 uno::Reference <util::XNumberFormats> xLocalNumberFormats(xNumberFormatsSupplier->getNumberFormats());
804 if (xLocalNumberFormats.is())
806 OUString sFormatString;
809 uno::Reference <beans::XPropertySet> xProperties(xLocalNumberFormats->getByKey(nKey));
810 if (xProperties.is())
812 lang::Locale aLocale;
818 sFormatString =
"#" +
826 sal_Int32 nNewKey = xLocalNumberFormats->queryKey(sFormatString, aLocale,
true);
828 nNewKey = xLocalNumberFormats->addNew(sFormatString, aLocale);
833 catch (
const util::MalformedNumberFormatException& rException )
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;
849 uno::Reference <util::XNumberFormatsSupplier> xNumberFormatsSupplier(GetNumberFormatsSupplier());
850 if (xNumberFormatsSupplier.is())
852 uno::Reference <util::XNumberFormats> xLocalNumberFormats(xNumberFormatsSupplier->getNumberFormats());
853 if (xLocalNumberFormats.is())
857 uno::Reference <beans::XPropertySet> xNumberPropertySet(xLocalNumberFormats->getByKey(nNumberFormat));
858 if (xNumberPropertySet.is())
863 if (sCurrentCurrency == sTemp)
872 if (sCurrentCurrency.size() == 3 && sBankSymbol == sTemp)
890 catch ( uno::Exception& )
892 OSL_FAIL(
"Numberformat not found");
900 sal_Int32& rNumberFormat,
901 const sal_Int16 nCellType,
902 std::u16string_view rCurrency)
907 if ((nCellType == util::NumberFormat::TEXT) || (nCellType == util::NumberFormat::UNDEFINED))
910 if (rNumberFormat == -1)
912 OSL_ENSURE(rNumberFormat != -1,
"no NumberFormat");
916 OUString sCurrentCurrency;
917 sal_Int32 nCurrentCellType(
919 rNumberFormat, sCurrentCurrency, bIsStandard) & ~util::NumberFormat::DEFINED);
928 if ((nCellType != nCurrentCellType) &&
929 (nCellType != util::NumberFormat::NUMBER) &&
930 (bIsStandard || (nCellType == util::NumberFormat::CURRENCY)))
934 uno::Reference <util::XNumberFormatsSupplier> xNumberFormatsSupplier(GetNumberFormatsSupplier());
935 if (xNumberFormatsSupplier.is())
942 uno::Reference < beans::XPropertySet> xNumberFormatProperties(
xNumberFormats->getByKey(rNumberFormat));
943 if (xNumberFormatProperties.is())
945 if (nCellType != util::NumberFormat::CURRENCY)
947 lang::Locale aLocale;
948 if ( xNumberFormatProperties->getPropertyValue(
SC_LOCALE) >>= aLocale )
955 else if (!rCurrency.empty() && !sCurrentCurrency.isEmpty())
957 if (sCurrentCurrency != rCurrency)
963 catch ( uno::Exception& )
965 OSL_FAIL(
"Numberformat not found");
971 if ((nCellType == util::NumberFormat::CURRENCY) && !rCurrency.empty() && !sCurrentCurrency.isEmpty() &&
972 sCurrentCurrency != rCurrency && !
IsCurrencySymbol(rNumberFormat, sCurrentCurrency, rCurrency))
984 uno::Reference <beans::XPropertySet> xProperties (
xSheetCellRanges, uno::UNO_QUERY);
985 if (xProperties.is())
999 css::uno::Any aAny = xProperties->getPropertyValue(
"FormatID");
1000 sal_uInt64 nKey = 0;
1001 if ((aAny >>= nKey) && nKey)
1003 ScFormatSaveData* pFormatSaveData = comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetFormatSaveData();
1008 uno::Sequence<table::CellRangeAddress> aAddresses(
xSheetCellRanges->getRangeAddresses());
1010 if ( aAddresses.hasElements() )
1012 const table::CellRangeAddress& rRange = aAddresses[0];
1015 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetSheetSaveData();
1017 ScAddress(
static_cast<SCCOL>(rRange.StartColumn),
static_cast<SCROW>(rRange.StartRow),
static_cast<SCTAB>(rRange.Sheet) ) );
1026 bool bInsert(nNumberFormat == -1);
1033 if (GetModel().is())
1035 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
1036 if (xMultiServiceFactory.is())
1038 xMultiServiceFactory->createInstance(
"com.sun.star.sheet.SheetCellRanges"),
1045 const sal_Int16 nCellType,
const OUString* pCurrency)
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));
1086 static_cast<ScCellRangesObj*
>(
xSheetCellRanges.get())->SetNewRanges(rRanges);
1121 SvXMLImport::setTargetDocument( xDoc );
1123 uno::Reference<frame::XModel>
xModel(xDoc, uno::UNO_QUERY);
1125 OSL_ENSURE(
pDoc,
"ScXMLImport::setTargetDocument - no ScDocument!" );
1127 throw lang::IllegalArgumentException();
1130 pDocSh->SetInitialLinkUpdate( pDocSh->GetMedium());
1135 uno::Reference<document::XActionLockable> xActionLockable(xDoc, uno::UNO_QUERY);
1136 if (xActionLockable.is())
1137 xActionLockable->addActionLock();
1144 SvXMLImport::startDocument();
1147 comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->BeforeXMLLoading();
1154 if ( ( nFlags & SvXMLImportFlags::CONTENT ) && !( nFlags & SvXMLImportFlags::STYLES ) )
1157 if (getImportFlags() & SvXMLImportFlags::CONTENT)
1159 if (GetModel().is())
1162 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetSheetSaveData();
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())
1173 static constexpr OUStringLiteral sOrganizerMode(
u"OrganizerMode");
1174 if (xPropertySetInfo->hasPropertyByName(sOrganizerMode))
1176 bool bStyleOnly(
false);
1177 if (xImportInfo->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
1189 sal_Int32 nRangeType(0);
1190 OUStringBuffer sBuffer;
1192 while (
i <= sRangeType.size())
1194 if ((
i == sRangeType.size()) || (sRangeType[
i] ==
' '))
1196 OUString sTemp = sBuffer.makeStringAndClear();
1197 if (sTemp ==
"repeat-column")
1202 nRangeType |= sheet::NamedRangeFlag::FILTER_CRITERIA;
1204 nRangeType |= sheet::NamedRangeFlag::PRINT_AREA;
1206 else if (
i < sRangeType.size())
1207 sBuffer.append(sRangeType[
i]);
1218 uno::Reference <beans::XPropertySet> xPropertySet (GetModel(), uno::UNO_QUERY);
1219 if (!xPropertySet.is())
1225 uno::Reference< sheet::XLabelRanges > xColRanges;
1226 uno::Reference< sheet::XLabelRanges > xRowRanges;
1228 if ( !(( aColAny >>= xColRanges ) && ( aRowAny >>= xRowRanges )) )
1231 table::CellRangeAddress aLabelRange;
1232 table::CellRangeAddress aDataRange;
1236 sal_Int32 nOffset1(0);
1237 sal_Int32 nOffset2(0);
1238 FormulaGrammar::AddressConvention eConv = FormulaGrammar::CONV_OOO;
1244 if ( rLabelRange.bColumnOrientation )
1245 xColRanges->addNew( aLabelRange, aDataRange );
1247 xRowRanges->addNew( aLabelRange, aDataRange );
1256class RangeNameInserter
1264 mrDoc(rDoc), mrRangeName(rRangeName), mnTab(nTab) {}
1270 const OUString& aType =
p.sRangeType;
1281 sal_Int32 nOffset = 0;
1283 aPos,
p.sBaseCellAddress, mrDoc, FormulaGrammar::CONV_OOO, nOffset);
1287 SAL_WARN(
"sc.filter",
"No conversion from table:base-cell-address '" <<
p.sBaseCellAddress
1288 <<
"' for name '" <<
p.sName <<
"' on sheet " << mnTab);
1292 aPos.
SetTab(mnTab < 0 ? 0 : mnTab);
1298 OUString aContent =
p.sContent;
1299 if (!
p.bIsExpression)
1303 mrDoc,
p.sName, aContent, aPos, nNewType,
p.eGrammar);
1304 mrRangeName.
insert(pData);
1322 RangeNameInserter(*
pDoc, *pRangeNames, -1));
1332 const SCTAB nTab = itr.first;
1338 ::std::for_each(rNames.begin(), rNames.end(), RangeNameInserter(*
pDoc, *pRangeNames, nTab));
1361 if (getImportFlags() & SvXMLImportFlags::CONTENT)
1363 if (GetModel().is())
1367 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1368 if (xViewDataSupplier.is())
1370 uno::Reference<container::XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
1371 if (xIndexAccess.is() && xIndexAccess->getCount() > 0)
1373 uno::Sequence< beans::PropertyValue >
aSeq;
1374 if (xIndexAccess->getByIndex(0) >>=
aSeq)
1376 for (
const auto& rProp : std::as_const(
aSeq))
1378 OUString
sName(rProp.Name);
1382 if(rProp.Value >>= sTabName)
1404 GetProgressBarHelper()->End();
1422 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetSheetSaveData();
1425 for (
SCTAB nTab=0; nTab<nTabCount; ++nTab)
1457 for (
SCTAB nTab = 0; nTab < nTabCount; ++nTab)
1484 if (GetModel().is())
1486 uno::Reference<document::XActionLockable> xActionLockable(GetModel(), uno::UNO_QUERY);
1487 if (xActionLockable.is())
1488 xActionLockable->removeActionLock();
1490 SvXMLImport::endDocument();
1498 comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->AfterXMLLoading();
1504 SvXMLImport::DisposingModel();
1516 mrImport.UnlockSolarMutex();
1552 sal_Int32 nOffset = -1;
1553 uno::Reference<xml::sax::XLocator> xLocator = GetLocator();
1554 uno::Reference<io::XSeekable> xSeek( xLocator, uno::UNO_QUERY );
1556 nOffset =
static_cast<sal_Int32
>(xSeek->getPosition());
1581 OUString& rFormula, OUString& rFormulaNmsp, FormulaGrammar::Grammar& reGrammar,
1582 const OUString& rAttrValue,
bool bRestrictToExternalNmsp )
const
1585 rFormulaNmsp.clear();
1589 if( !bRestrictToExternalNmsp )
switch( nNsId )
1592 rFormulaNmsp.clear();
1593 reGrammar = FormulaGrammar::GRAM_PODF;
1596 rFormulaNmsp.clear();
1597 reGrammar = FormulaGrammar::GRAM_ODFF;
1605 FormulaGrammar::Grammar eDefaultGrammar =
1607 FormulaGrammar::GRAM_PODF : FormulaGrammar::GRAM_ODFF;
1615 rFormula = rAttrValue;
1616 reGrammar = eDefaultGrammar;
1628 reGrammar = FormulaGrammar::GRAM_EXTERNAL;
1634 rFormula = rAttrValue;
1635 rFormulaNmsp.clear();
1636 reGrammar = eDefaultGrammar;
1642 return FormulaError::NONE;
1644 return mpComp->GetErrorConstant(rStr);
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);
1693 css::uno::Sequence<OUString> aUserData
1695 "com.sun.star.comp.filter.OdfFlatXml",
1697 "com.sun.star.comp.Calc.XMLOasisImporter",
1698 "com.sun.star.comp.Calc.XMLOasisExporter",
1705 {
"UserData",
uno::Any(aUserData) },
1707 css::uno::Sequence<uno::Any> aOuterArgs{
uno::Any(aAdaptorArgs) };
1709 uno::Reference<lang::XInitialization> xInit(xInterface, uno::UNO_QUERY_THROW);
1710 xInit->initialize(aOuterArgs);
1712 uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
1716 {
"URL",
uno::Any(OUString(
"private:stream")) },
1718 xImporter->setTargetDocument(
xModel);
1720 uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
1726 bool ret = xFilter->filter(aArgs);
1745 uno::Reference<document::XFilter> xFilter(xMultiServiceFactory->createInstance(
"com.sun.star.comp.oox.xls.ExcelFilter"), uno::UNO_QUERY_THROW);
1747 uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
1753 xImporter->setTargetDocument(
xModel);
1763 ret = xFilter->filter(aArgs);
1765 catch (
const css::io::IOException&)
1768 catch (
const css::lang::WrappedTargetRuntimeException&)
constexpr OUStringLiteral SC_ACTIVETABLE
const OUString & getNumThousandSep() const
const OUString & getNumDecimalSep() const
void SetProtection(const css::uno::Sequence< sal_Int8 > &rPass)
void SetHasDate(bool bFlag)
void SetHasAuthor(bool bFlag)
void SetHasRange(bool bFlag)
void SetTheLastDateTime(const DateTime &aDateTime)
void SetTheFirstDateTime(const DateTime &aDateTime)
void SetShowChanges(bool bFlag)
void SetTheComment(const OUString &aString)
void SetTheDateMode(SvxRedlinDateMode eDatMod)
void SetShowRejected(bool bVal)
void SetTheAuthorToShow(const OUString &aString)
void SetTheRangeList(const ScRangeList &aRl)
void SetShowAccepted(bool bVal)
void SetHasComment(bool bFlag)
static SC_DLLPUBLIC void Init()
DLL-init/exit-code must be linked to the DLL only.
void update(const bool bOnlyUsedRows=false)
Accessor class to ScDocument.
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
SC_DLLPUBLIC void SetChangeTrack(std::unique_ptr< ScChangeTrack > pTrack)
only for import filter, deletes any existing ChangeTrack via EndChangeTracking() and takes ownership ...
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
ScFormulaParserPool & GetFormulaParserPool() const
Returns the pool containing external formula parsers.
const ScCalcConfig & GetCalcConfig() const
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)
bool IsAdjustHeightLocked() const
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
formula::FormulaGrammar::Grammar GetStorageGrammar() const
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
void SetEmbedFonts(bool bUse)
bool HasRangeOverflow() const
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC void SetCalcConfig(const ScCalcConfig &rConfig)
void SetRangeOverflowType(ErrCode nType)
SfxObjectShell * GetDocumentShell() const
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
bool HasExternalRefManager() const
ScChangeTrack * GetChangeTrack() const
SC_DLLPUBLIC void UnlockAdjustHeight()
bool IsImportingXML() const
void BroadcastUno(const SfxHint &rHint)
SC_DLLPUBLIC SCTAB GetTableCount() const
static ScDrawObjData * GetObjDataTab(SdrObject *pObj, SCTAB nTab)
void RecalcPos(SdrObject *pObj, ScDrawObjData &rData, bool bNegativePage, bool bUpdateNoteCaptionPos)
void InitializeCellAnchoredObj(SdrObject *pObj, ScDrawObjData &rData)
void updateAbsAfterLoad()
Replace the original URL with the real URL that was generated from the relative URL.
SfxObjectShell * GetEmbeddedObject() const
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
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.
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='\'')
void AddCellStyle(const OUString &rName, const ScAddress &rCellPos)
bool IsSheetBlocked(SCTAB nTab) const
void StoreInitialNamespaces(const SvXMLNamespaceMap &rNamespaces)
OutputDevice * GetDevice() const
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...
MutexGuard(ScXMLImport &rImport)
std::unique_ptr< ScMyStyleNumberFormats > pStyleNumberFormats
void ProgressBarIncrement()
ScDocumentImport & GetDoc()
std::unique_ptr< ScMyStylesImportHelper > pStylesImportHelper
SvXMLImportContext * CreateBodyContext(const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList)
virtual void NotifyContainsEmbeddedFont() override
bool SetNullDateOnUnitConverter()
rtl::Reference< XMLPropertySetMapper > xCellStylesPropertySetMapper
ScXMLImport(const ScXMLImport &)=delete
std::unique_ptr< ScXMLChangeTrackingImportHelper > pChangeTrackingImportHelper
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
css::uno::Reference< css::util::XNumberFormatTypes > xNumberFormatTypes
bool IsCurrencySymbol(const sal_Int32 nNumberFormat, std::u16string_view sCurrencySymbol, std::u16string_view sBankSymbol)
bool bSelfImportingXMLSet
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
std::unique_ptr< XMLNumberFormatAttributesExportHelper > pNumberFormatAttributesExportHelper
void SetChangeTrackingViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &rChangeProps)
rtl::Reference< XMLPropertySetMapper > xColumnStylesPropertySetMapper
rtl::Reference< XMLPropertyHandlerFactory > xScPropHdlFactory
std::unique_ptr< sc::PivotTableSources > mpPivotSources
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual void DisposingModel() override
void AddNamedExpression(ScMyNamedExpression aMyNamedExpression)
static sal_Int32 GetRangeType(std::u16string_view sRangeType)
SheetNamedExpMap m_SheetNamedExpressions
std::vector< ScDocRowHeightUpdater::TabRanges > maRecalcRowRanges
sc::ImportPostProcessData * mpPostProcessData
virtual void SAL_CALL endDocument() override
FormulaError GetFormulaErrorConstant(const OUString &rStr) const
sal_uInt32 nSolarMutexLocked
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats) override
sal_Int32 SetCurrencySymbol(const sal_Int32 nKey, std::u16string_view rCurrency)
void ExamineDefaultStyle()
std::unique_ptr< ScEditEngineDefaulter > mpEditEngine
void SetSheetNamedRanges()
SvXMLImportContext * CreateMetaContext(sal_Int32 nElement)
std::unique_ptr< ScMyImpDetectiveOpArray > pDetectiveOpArray
ScMyTables aTables
Lift cycle managed elsewhere, no need to delete.
css::uno::Reference< css::util::XNumberFormats > xNumberFormats
ScMyImpDetectiveOpArray * GetDetectiveOpArray()
ScMyImportValidations maValidations
ScMyLabelRanges maMyLabelRanges
virtual XMLShapeImportHelper * CreateShapeImport() override
const ScXMLEditAttributeMap & GetEditAttributeMap() const
ScXMLChangeTrackingImportHelper * GetChangeTrackingImportHelper()
ScDocument * GetDocument()
std::unique_ptr< ScCompiler > mpComp
ScMyNamedExpressions m_aMyNamedExpressions
bool GetValidation(const OUString &sName, ScMyImportValidation &aValidation)
virtual ~ScXMLImport() noexcept override
std::optional< SolarMutexGuard > moSolarMutexGuard
void SetStylesToRangesFinished()
SvXMLImportContext * CreateStylesContext(bool bAutoStyles)
void SetRangeOverflowType(ErrCode nType)
rtl::Reference< XMLPropertySetMapper > xRowStylesPropertySetMapper
virtual void SAL_CALL startDocument() override
sc::PivotTableSources & GetPivotTableSources()
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...
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
sal_Int32 GetByteOffset() const
std::unique_ptr< ScXMLEditAttributeMap > mpEditAttrMap
rtl::Reference< XMLPropertySetMapper > xTableStylesPropertySetMapper
void SetType(const css::uno::Reference< css::beans::XPropertySet > &rProperties, sal_Int32 &rNumberFormat, const sal_Int16 nCellType, std::u16string_view rCurrency)
void SetStringRefSyntaxIfMissing()
bool IsStylesOnlyMode() const
css::uno::Reference< css::sheet::XSheetCellRangeContainer > xSheetCellRanges
ScMyStyleNumberFormats * GetStyleNumberFormats()
SvXMLImportContext * CreateScriptContext()
XMLNumberFormatAttributesExportHelper * GetNumberFormatAttributesExportHelper()
static sal_Int16 GetCellType(const char *rStrValue, const sal_Int32 nStrLength)
void SetPostProcessData(sc::ImportPostProcessData *p)
ScEditEngineDefaulter * GetEditEngine()
SvXMLImportContext * CreateFontDeclsContext()
std::unique_ptr< ScDocumentImport > mpDocImport
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)
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)
SCTAB GetLastSheet() const
void SetLastSheet(SCTAB nNew)
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
sal_Int32 GetNumberFormat()
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.
#define DBG_TESTSOLARMUTEX()
Sequence< PropertyValue > aArguments
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)
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)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
Configuration options for formula interpreter.
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax
bool mbHasStringRefSyntax
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.
Reference< XModel > xModel
constexpr OUStringLiteral SC_UNONAME_NUMFMT
constexpr OUStringLiteral SC_UNO_ODS_IMPORT_STYLES
constexpr OUStringLiteral SC_UNO_COLLABELRNG
constexpr OUStringLiteral SC_UNO_ODS_LOCK_SOLAR_MUTEX
constexpr OUStringLiteral SC_UNONAME_CELLSTYL
constexpr OUStringLiteral SC_UNO_ROWLABELRNG
constexpr OUStringLiteral PERCENT(u"Percent")
#define XMLERROR_FLAG_ERROR
#define XML_ELEMENT(prefix, name)
constexpr OUStringLiteral SC_REPEAT_ROW
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisSettingsImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisStylesImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT bool TestImportXLSX(SvStream &rStream)
constexpr OUStringLiteral SC_PRINT_RANGE
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisMetaImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral SC_CURRENCYSYMBOL
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisContentImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral SC_FILTER
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral SC_LOCALE
SAL_DLLPUBLIC_EXPORT bool TestImportFODS(SvStream &rStream)
::std::list< ScMyNamedExpression > ScMyNamedExpressions
constexpr sal_uInt16 XML_NAMESPACE_OOOC
constexpr sal_uInt16 XML_NAMESPACE_OF
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
const XMLPropertyMapEntry aXMLScRowStylesImportProperties[]
const XMLPropertyMapEntry aXMLScTableStylesImportProperties[]
const XMLPropertyMapEntry aXMLScColumnStylesProperties[]
const XMLPropertyMapEntry aXMLScCellStylesProperties[]