22 #include <osl/diagnose.h>
51 #include <document.hxx>
59 #include <compiler.hxx>
75 #include <unonames.hxx>
86 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
87 #include <com/sun/star/frame/XModel.hpp>
88 #include <com/sun/star/io/IOException.hpp>
89 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
90 #include <com/sun/star/document/XActionLockable.hpp>
91 #include <com/sun/star/util/MalformedNumberFormatException.hpp>
92 #include <com/sun/star/util/NumberFormat.hpp>
93 #include <com/sun/star/util/XNumberFormatTypes.hpp>
94 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
95 #include <com/sun/star/sheet/NamedRangeFlag.hpp>
96 #include <com/sun/star/sheet/XLabelRanges.hpp>
97 #include <com/sun/star/io/XSeekable.hpp>
98 #include <com/sun/star/beans/XPropertySet.hpp>
99 #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
105 #define SC_LOCALE "Locale"
106 #define SC_CURRENCYSYMBOL "CurrencySymbol"
107 #define SC_REPEAT_ROW "repeat-row"
108 #define SC_FILTER "filter"
109 #define SC_PRINT_RANGE "print-range"
115 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
117 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
119 return cppu::acquire(static_cast<cppu::OWeakObject*>(
122 "com.sun.star.comp.Calc.XMLOasisImporter",
123 SvXMLImportFlags::ALL,
124 {
"com.sun.star.comp.Calc.XMLOasisImporter" } )));
127 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
129 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
131 return cppu::acquire(static_cast<cppu::OWeakObject*>(
134 "com.sun.star.comp.Calc.XMLOasisMetaImporter",
135 SvXMLImportFlags::META,
136 {
"com.sun.star.comp.Calc.XMLOasisMetaImporter" } )));
139 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
141 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
143 return cppu::acquire(static_cast<cppu::OWeakObject*>(
146 "com.sun.star.comp.Calc.XMLOasisStylesImporter",
147 SvXMLImportFlags::STYLES|SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::MASTERSTYLES|SvXMLImportFlags::FONTDECLS,
148 {
"com.sun.star.comp.Calc.XMLOasisStylesImporter" } )));
151 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
153 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
155 return cppu::acquire(static_cast<cppu::OWeakObject*>(
new ScXMLImport(
157 "com.sun.star.comp.Calc.XMLOasisContentImporter",
158 SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::CONTENT|SvXMLImportFlags::SCRIPTS|SvXMLImportFlags::FONTDECLS,
159 uno::Sequence< OUString > {
"com.sun.star.comp.Calc.XMLOasisContentImporter" })));
163 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
165 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
167 return cppu::acquire(static_cast<cppu::OWeakObject*>(
170 "com.sun.star.comp.Calc.XMLOasisSettingsImporter",
171 SvXMLImportFlags::SETTINGS,
172 {
"com.sun.star.comp.Calc.XMLOasisSettingsImporter" } )));
187 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
188 createFastChildContext( sal_Int32 nElement,
189 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList )
override;
194 ScXMLDocContext_Impl::ScXMLDocContext_Impl(
ScXMLImport& rImport ) :
202 class ScXMLFlatDocContext_Impl
208 const uno::Reference<document::XDocumentProperties>& i_xDocProps);
210 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
212 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList )
override;
217 ScXMLFlatDocContext_Impl::ScXMLFlatDocContext_Impl(
ScXMLImport& i_rImport,
218 const uno::Reference<document::XDocumentProperties>& i_xDocProps) :
220 ScXMLDocContext_Impl(i_rImport),
225 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
226 ScXMLFlatDocContext_Impl::createFastChildContext( sal_Int32 nElement,
227 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
232 return ScXMLDocContext_Impl::createFastChildContext( nElement, xAttrList );
242 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
244 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList )
override;
249 ScXMLBodyContext_Impl::ScXMLBodyContext_Impl(
ScXMLImport& rImport ) :
254 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
255 ScXMLBodyContext_Impl::createFastChildContext( sal_Int32 ,
256 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
260 return GetScImport().CreateBodyContext( pAttribList );
263 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
264 ScXMLDocContext_Impl::createFastChildContext( sal_Int32 nElement,
265 const uno::Reference< xml::sax::XFastAttributeList > & )
273 pContext = new ScXMLBodyContext_Impl( GetScImport() );
277 pContext = GetScImport().CreateScriptContext();
285 pContext = GetScImport().CreateStylesContext( false);
289 pContext = GetScImport().CreateStylesContext( true);
293 pContext = GetScImport().CreateFontDeclsContext();
300 SAL_INFO(
"sc",
"XML_ELEMENT(OFFICE, XML_META): should not have come here, maybe document is invalid?");
322 const uno::Reference< xml::sax::XFastAttributeList >& )
331 pContext =
new ScXMLDocContext_Impl( *
this );
340 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
343 pContext =
new ScXMLFlatDocContext_Impl( *
this,
344 xDPS->getDocumentProperties());
358 const css::uno::Reference< css::uno::XComponentContext >& rContext,
360 const css::uno::Sequence< OUString > & sSupportedServiceNames)
361 :
SvXMLImport( rContext, implementationName, nImportFlag, sSupportedServiceNames ),
363 mpPostProcessData(nullptr),
367 nSolarMutexLocked(0),
371 bNullDateSetted(false),
372 bSelfImportingXMLSet(false),
373 mbLockSolarMutex(true),
374 mbImportStyles(true),
375 mbHasNewCondFormatData(false)
414 uno::Reference<beans::XPropertySet> xInfoSet =
getImportInfo();
418 uno::Reference<beans::XPropertySetInfo> xInfoSetInfo = xInfoSet->getPropertySetInfo();
419 if (!xInfoSetInfo.is())
432 *
this, osl_getThreadTextEncoding());
441 *
this, bIsAutoStyle);
446 SetStyles(static_cast<SvXMLStylesContext*>(pContext));
463 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
465 uno::Reference<document::XDocumentProperties>
const xDocProps(
488 {
"TableCount",
"CellCount",
"ObjectCount",
nullptr };
493 for (
const auto& rStat : i_rStats) {
494 for (
const char** pStat = s_stats; *pStat !=
nullptr; ++pStat) {
495 if (rStat.Name.equalsAscii(*pStat)) {
497 if (rStat.Value >>= val) {
500 OSL_FAIL(
"ScXMLImport::SetStatistics: invalid entry");
520 sal_Int16 nCellType = util::NumberFormat::UNDEFINED;
521 if (rStrValue !=
nullptr)
523 switch (rStrValue[0])
526 if (nStrLength == 7 && !strcmp(rStrValue,
"boolean"))
527 nCellType = util::NumberFormat::LOGICAL;
530 if (nStrLength == 8 && !strcmp(rStrValue,
"currency"))
531 nCellType = util::NumberFormat::CURRENCY;
534 if (nStrLength == 4 && !strcmp(rStrValue,
"date"))
535 nCellType = util::NumberFormat::DATETIME;
538 if (nStrLength == 5 && !strcmp(rStrValue,
"float"))
539 nCellType = util::NumberFormat::NUMBER;
542 if (nStrLength == 10 && !strcmp(rStrValue,
"percentage"))
546 if (nStrLength == 6 && !strcmp(rStrValue,
"string"))
547 nCellType = util::NumberFormat::TEXT;
550 if (nStrLength == 4 && !strcmp(rStrValue,
"time"))
551 nCellType = util::NumberFormat::TIME;
583 ::std::unique_ptr<ScMyNamedExpression>
p(pNamedExp);
588 ::std::pair<SheetNamedExpMap::iterator, bool> r =
597 r.push_back(std::move(p));
625 mpDocImport->setDefaultNumericScript(SvtScriptType::LATIN);
634 if (!rChangeProps.hasElements())
638 sal_Int16 nTemp16(0);
640 for (
const auto& rChangeProp : rChangeProps)
642 OUString
sName(rChangeProp.Name);
643 if (sName ==
"ShowChanges")
644 pViewSettings->SetShowChanges(::
cppu::any2bool(rChangeProp.Value));
645 else if (sName ==
"ShowAcceptedChanges")
646 pViewSettings->SetShowAccepted(::
cppu::any2bool(rChangeProp.Value));
647 else if (sName ==
"ShowRejectedChanges")
648 pViewSettings->SetShowRejected(::
cppu::any2bool(rChangeProp.Value));
649 else if (sName ==
"ShowChangesByDatetime")
651 else if (sName ==
"ShowChangesByDatetimeMode")
653 if (rChangeProp.Value >>= nTemp16)
654 pViewSettings->SetTheDateMode(static_cast<SvxRedlinDateMode>(nTemp16));
656 else if (sName ==
"ShowChangesByDatetimeFirstDatetime")
658 util::DateTime aDateTime;
659 if (rChangeProp.Value >>= aDateTime)
661 pViewSettings->SetTheFirstDateTime(::
DateTime(aDateTime));
664 else if (sName ==
"ShowChangesByDatetimeSecondDatetime")
666 util::DateTime aDateTime;
667 if (rChangeProp.Value >>= aDateTime)
669 pViewSettings->SetTheLastDateTime(::
DateTime(aDateTime));
672 else if (sName ==
"ShowChangesByAuthor")
674 else if (sName ==
"ShowChangesByAuthorName")
677 if (rChangeProp.Value >>= sOUName)
679 pViewSettings->SetTheAuthorToShow(sOUName);
682 else if (sName ==
"ShowChangesByComment")
683 pViewSettings->SetHasComment(::
cppu::any2bool(rChangeProp.Value));
684 else if (sName ==
"ShowChangesByCommentText")
687 if (rChangeProp.Value >>= sOUComment)
689 pViewSettings->SetTheComment(sOUComment);
692 else if (sName ==
"ShowChangesByRanges")
694 else if (sName ==
"ShowChangesByRangesList")
697 if ((rChangeProp.Value >>= sRanges) && !sRanges.isEmpty())
701 aRangeList, sRanges, *
pDoc, FormulaGrammar::CONV_OOO);
702 pViewSettings->SetTheRangeList(aRangeList);
711 sal_Int32 nHeight(0);
715 for (
const auto& rViewProp : aViewProps)
717 OUString
sName(rViewProp.Name);
718 if (sName ==
"VisibleAreaHeight")
719 rViewProp.Value >>= nHeight;
720 else if (sName ==
"VisibleAreaLeft")
721 rViewProp.Value >>= nLeft;
722 else if (sName ==
"VisibleAreaTop")
723 rViewProp.Value >>= nTop;
724 else if (sName ==
"VisibleAreaWidth")
725 rViewProp.Value >>= nWidth;
726 else if (sName ==
"TrackedChangesViewSettings")
728 uno::Sequence<beans::PropertyValue> aChangeProps;
729 if(rViewProp.Value >>= aChangeProps)
733 if (!(nHeight && nWidth &&
GetModel().is()))
736 ScModelObj* pDocObj(comphelper::getUnoTunnelImplementation<ScModelObj>(
GetModel() ));
757 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(
GetModel(), uno::UNO_QUERY);
758 if (!xMultiServiceFactory.is())
761 sal_Int32
nCount(aConfigProps.getLength());
762 css::uno::Sequence<css::beans::PropertyValue> aFilteredProps(
nCount);
763 sal_Int32 nFilteredPropsLen = 0;
764 for (sal_Int32
i =
nCount - 1;
i >= 0; --
i)
766 if (aConfigProps[
i].
Name ==
"TrackedChangesProtectionKey")
769 if (aConfigProps[
i].
Value >>= sKey)
771 uno::Sequence<sal_Int8> aPass;
773 if (aPass.hasElements())
779 std::set<OUString> aUsers;
781 pTrack->SetProtection(aPass);
788 else if ((aConfigProps[
i].
Name ==
"VBACompatibilityMode") || (aConfigProps[
i].
Name ==
"ScriptConfiguration"))
790 uno::Reference< beans::XPropertySet > xImportInfo =
getImportInfo();
791 if (xImportInfo.is())
793 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xImportInfo->getPropertySetInfo();
794 if (xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName(aConfigProps[
i].
Name))
795 xImportInfo->setPropertyValue( aConfigProps[
i].Name, aConfigProps[i].Value );
798 if (aConfigProps[
i].
Name !=
"LinkUpdateMode")
800 aFilteredProps[nFilteredPropsLen++] = aConfigProps[
i];
803 aFilteredProps.realloc(nFilteredPropsLen);
804 uno::Reference <uno::XInterface> xInterface = xMultiServiceFactory->createInstance(
"com.sun.star.comp.SpreadsheetSettings");
805 uno::Reference <beans::XPropertySet> xProperties(xInterface, uno::UNO_QUERY);
806 if (xProperties.is())
813 if (xNumberFormatsSupplier.is())
815 uno::Reference <util::XNumberFormats> xLocalNumberFormats(xNumberFormatsSupplier->getNumberFormats());
816 if (xLocalNumberFormats.is())
818 OUString sFormatString;
821 uno::Reference <beans::XPropertySet> xProperties(xLocalNumberFormats->getByKey(nKey));
822 if (xProperties.is())
824 lang::Locale aLocale;
833 aBuffer.append(
"##0");
835 aBuffer.append(
"00 [$");
836 aBuffer.append(rCurrency);
838 sFormatString = aBuffer.makeStringAndClear();
840 sal_Int32 nNewKey = xLocalNumberFormats->queryKey(sFormatString, aLocale,
true);
842 nNewKey = xLocalNumberFormats->addNew(sFormatString, aLocale);
847 catch (
const util::MalformedNumberFormatException& rException )
849 OUString sErrorMessage =
"Error in Formatstring " +
850 sFormatString +
" at position " +
851 OUString::number(rException.CheckPos);
852 uno::Sequence<OUString>
aSeq { sErrorMessage };
853 uno::Reference<xml::sax::XLocator> xLocator;
864 if (xNumberFormatsSupplier.is())
866 uno::Reference <util::XNumberFormats> xLocalNumberFormats(xNumberFormatsSupplier->getNumberFormats());
867 if (xLocalNumberFormats.is())
871 uno::Reference <beans::XPropertySet> xNumberPropertySet(xLocalNumberFormats->getByKey(nNumberFormat));
872 if (xNumberPropertySet.is())
877 if (sCurrentCurrency == sTemp)
886 if (sCurrentCurrency.getLength() == 3 && sBankSymbol == sTemp)
904 catch ( uno::Exception& )
906 OSL_FAIL(
"Numberformat not found");
914 sal_Int32& rNumberFormat,
915 const sal_Int16 nCellType,
916 const OUString& rCurrency)
921 if ((nCellType == util::NumberFormat::TEXT) || (nCellType == util::NumberFormat::UNDEFINED))
924 if (rNumberFormat == -1)
925 rProperties->getPropertyValue(
gsNumberFormat ) >>= rNumberFormat;
926 OSL_ENSURE(rNumberFormat != -1,
"no NumberFormat");
930 OUString sCurrentCurrency;
931 sal_Int32 nCurrentCellType(
933 rNumberFormat, sCurrentCurrency, bIsStandard) & ~util::NumberFormat::DEFINED);
942 if ((nCellType != nCurrentCellType) &&
943 (nCellType != util::NumberFormat::NUMBER) &&
944 (bIsStandard || (nCellType == util::NumberFormat::CURRENCY)))
949 if (xNumberFormatsSupplier.is())
956 uno::Reference < beans::XPropertySet> xNumberFormatProperties(
xNumberFormats->getByKey(rNumberFormat));
957 if (xNumberFormatProperties.is())
959 if (nCellType != util::NumberFormat::CURRENCY)
961 lang::Locale aLocale;
962 if ( xNumberFormatProperties->getPropertyValue(
gsLocale) >>= aLocale )
969 else if (!rCurrency.isEmpty() && !sCurrentCurrency.isEmpty())
971 if (sCurrentCurrency != rCurrency)
977 catch ( uno::Exception& )
979 OSL_FAIL(
"Numberformat not found");
985 if ((nCellType == util::NumberFormat::CURRENCY) && !rCurrency.isEmpty() && !sCurrentCurrency.isEmpty() &&
986 sCurrentCurrency != rCurrency && !
IsCurrencySymbol(rNumberFormat, sCurrentCurrency, rCurrency))
998 uno::Reference <beans::XPropertySet> xProperties (
xSheetCellRanges, uno::UNO_QUERY);
999 if (xProperties.is())
1013 css::uno::Any aAny = xProperties->getPropertyValue(
"FormatID");
1014 sal_uInt64 nKey = 0;
1015 if ((aAny >>= nKey) && nKey)
1017 ScFormatSaveData* pFormatSaveData = comphelper::getUnoTunnelImplementation<ScModelObj>(
GetModel())->GetFormatSaveData();
1022 uno::Sequence<table::CellRangeAddress> aAddresses(
xSheetCellRanges->getRangeAddresses());
1024 if ( aAddresses.hasElements() )
1026 const table::CellRangeAddress& rRange = aAddresses[0];
1029 ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(
GetModel())->GetSheetSaveData();
1031 ScAddress( static_cast<SCCOL>(rRange.StartColumn), static_cast<SCROW>(rRange.StartRow), static_cast<SCTAB>(rRange.Sheet) ) );
1040 bool bInsert(nNumberFormat == -1);
1049 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(
GetModel(), uno::UNO_QUERY);
1050 if (xMultiServiceFactory.is())
1052 xMultiServiceFactory->createInstance(
"com.sun.star.sheet.SheetCellRanges"),
1059 const sal_Int16 nCellType,
const OUString* pCurrency)
1094 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(
GetModel(), uno::UNO_QUERY);
1095 if (xMultiServiceFactory.is())
1096 xSheetCellRanges.set(uno::Reference <sheet::XSheetCellRangeContainer>(xMultiServiceFactory->createInstance(
"com.sun.star.sheet.SheetCellRanges"), uno::UNO_QUERY));
1137 uno::Reference<frame::XModel>
xModel(xDoc, uno::UNO_QUERY);
1139 OSL_ENSURE(
pDoc,
"ScXMLImport::setTargetDocument - no ScDocument!" );
1141 throw lang::IllegalArgumentException();
1146 uno::Reference<document::XActionLockable> xActionLockable(xDoc, uno::UNO_QUERY);
1147 if (xActionLockable.is())
1148 xActionLockable->addActionLock();
1158 comphelper::getUnoTunnelImplementation<ScModelObj>(
GetModel())->BeforeXMLLoading();
1165 if ( ( nFlags & SvXMLImportFlags::CONTENT ) && !( nFlags & SvXMLImportFlags::STYLES ) )
1173 ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(
GetModel())->GetSheetSaveData();
1179 uno::Reference< beans::XPropertySet >
const xImportInfo(
getImportInfo() );
1180 uno::Reference< beans::XPropertySetInfo >
const xPropertySetInfo(
1181 xImportInfo.is() ? xImportInfo->getPropertySetInfo() :
nullptr);
1182 if (xPropertySetInfo.is())
1184 OUString
const sOrganizerMode(
1186 if (xPropertySetInfo->hasPropertyByName(sOrganizerMode))
1188 bool bStyleOnly(
false);
1189 if (xImportInfo->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
1201 sal_Int32 nRangeType(0);
1202 OUStringBuffer sBuffer;
1204 while (i <= sRangeType.getLength())
1206 if ((i == sRangeType.getLength()) || (sRangeType[i] ==
' '))
1208 OUString sTemp = sBuffer.makeStringAndClear();
1209 if (sTemp ==
"repeat-column")
1214 nRangeType |= sheet::NamedRangeFlag::FILTER_CRITERIA;
1216 nRangeType |= sheet::NamedRangeFlag::PRINT_AREA;
1218 else if (i < sRangeType.getLength())
1219 sBuffer.append(sRangeType[i]);
1230 uno::Reference <beans::XPropertySet> xPropertySet (
GetModel(), uno::UNO_QUERY);
1231 if (!xPropertySet.is())
1237 uno::Reference< sheet::XLabelRanges > xColRanges;
1238 uno::Reference< sheet::XLabelRanges > xRowRanges;
1240 if ( !(( aColAny >>= xColRanges ) && ( aRowAny >>= xRowRanges )) )
1243 table::CellRangeAddress aLabelRange;
1244 table::CellRangeAddress aDataRange;
1248 sal_Int32 nOffset1(0);
1249 sal_Int32 nOffset2(0);
1250 FormulaGrammar::AddressConvention eConv = FormulaGrammar::CONV_OOO;
1256 if ( rxLabelRange->bColumnOrientation )
1257 xColRanges->addNew( aLabelRange, aDataRange );
1259 xRowRanges->addNew( aLabelRange, aDataRange );
1263 pMyLabelRanges->clear();
1268 class RangeNameInserter
1275 mrDoc(rDoc), mrRangeName(rRangeName) {}
1277 void operator() (
const std::unique_ptr<ScMyNamedExpression>& p)
const
1281 const OUString& aType = p->sRangeType;
1292 sal_Int32 nOffset = 0;
1294 aPos, p->sBaseCellAddress, mrDoc, FormulaGrammar::CONV_OOO, nOffset);
1298 OUString aContent = p->sContent;
1299 if (!p->bIsExpression)
1303 mrDoc, p->sName, aContent, aPos, nNewType, p->eGrammar);
1304 mrRangeName.
insert(pData);
1331 const SCTAB nTab = itr.first;
1337 ::std::for_each(rNames.begin(), rNames.end(), RangeNameInserter(*
pDoc, *pRangeNames));
1366 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(
GetModel(), uno::UNO_QUERY);
1367 if (xViewDataSupplier.is())
1369 uno::Reference<container::XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
1370 if (xIndexAccess.is() && xIndexAccess->getCount() > 0)
1372 uno::Sequence< beans::PropertyValue >
aSeq;
1373 if (xIndexAccess->getByIndex(0) >>= aSeq)
1375 for (
const auto& rProp : std::as_const(aSeq))
1377 OUString
sName(rProp.Name);
1381 if(rProp.Value >>= sTabName)
1421 ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(
GetModel())->GetSheetSaveData();
1424 for (
SCTAB nTab=0; nTab<nTabCount; ++nTab)
1456 for (
SCTAB nTab = 0; nTab < nTabCount; ++nTab)
1463 for (
size_t i = 0;
i < nCount; ++
i)
1474 pDrawLayer->
RecalcPos(pObj, *pData, bNegativePage,
1485 uno::Reference<document::XActionLockable> xActionLockable(
GetModel(), uno::UNO_QUERY);
1486 if (xActionLockable.is())
1487 xActionLockable->removeActionLock();
1497 comphelper::getUnoTunnelImplementation<ScModelObj>(
GetModel())->AfterXMLLoading();
1515 mrImport.UnlockSolarMutex();
1551 sal_Int32 nOffset = -1;
1552 uno::Reference<xml::sax::XLocator> xLocator =
GetLocator();
1553 uno::Reference<io::XSeekable> xSeek( xLocator, uno::UNO_QUERY );
1555 nOffset = static_cast<sal_Int32>(xSeek->getPosition());
1580 OUString& rFormula, OUString& rFormulaNmsp, FormulaGrammar::Grammar& reGrammar,
1581 const OUString& rAttrValue,
bool bRestrictToExternalNmsp )
const
1584 rFormulaNmsp.clear();
1588 if( !bRestrictToExternalNmsp )
switch( nNsId )
1591 rFormulaNmsp.clear();
1592 reGrammar = FormulaGrammar::GRAM_PODF;
1595 rFormulaNmsp.clear();
1596 reGrammar = FormulaGrammar::GRAM_ODFF;
1604 FormulaGrammar::Grammar eDefaultGrammar =
1606 FormulaGrammar::GRAM_PODF : FormulaGrammar::GRAM_ODFF;
1614 rFormula = rAttrValue;
1615 reGrammar = eDefaultGrammar;
1627 reGrammar = FormulaGrammar::GRAM_EXTERNAL;
1633 rFormula = rAttrValue;
1634 rFormulaNmsp.clear();
1635 reGrammar = eDefaultGrammar;
1641 return FormulaError::NONE;
1643 return mpComp->GetErrorConstant(rStr);
1689 uno::Reference<io::XInputStream>
xStream(new ::utl::OSeekableInputStreamWrapper(rStream));
1690 uno::Reference<uno::XInterface> xInterface(xMultiServiceFactory->createInstance(
"com.sun.star.comp.Writer.XmlFilterAdaptor"), uno::UNO_SET_THROW);
1692 css::uno::Sequence<OUString> aUserData(7);
1693 aUserData[0] =
"com.sun.star.comp.filter.OdfFlatXml";
1694 aUserData[2] =
"com.sun.star.comp.Calc.XMLOasisImporter";
1695 aUserData[3] =
"com.sun.star.comp.Calc.XMLOasisExporter";
1696 aUserData[6] =
"true";
1699 {
"UserData",
uno::Any(aUserData) },
1701 css::uno::Sequence<uno::Any> aOuterArgs(1);
1702 aOuterArgs[0] <<= aAdaptorArgs;
1704 uno::Reference<lang::XInitialization> xInit(xInterface, uno::UNO_QUERY_THROW);
1705 xInit->initialize(aOuterArgs);
1707 uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
1710 {
"InputStream",
uno::Any(xStream) },
1711 {
"URL",
uno::Any(OUString(
"private:stream")) },
1713 xImporter->setTargetDocument(
xModel);
1715 uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
1721 bool ret = xFilter->filter(aArgs);
1740 uno::Reference<document::XFilter> xFilter(xMultiServiceFactory->createInstance(
"com.sun.star.comp.oox.xls.ExcelFilter"), uno::UNO_QUERY_THROW);
1742 uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
1745 {
"InputStream", uno::makeAny(xStream) },
1746 {
"InputMode", uno::makeAny(
true) },
1748 xImporter->setTargetDocument(
xModel);
1758 ret = xFilter->filter(aArgs);
1760 catch (
const css::io::IOException&)
1763 catch (
const css::lang::WrappedTargetRuntimeException&)
virtual void SetVisArea(const tools::Rectangle &rVisArea)
void SetStringRefSyntaxIfMissing()
css::uno::Reference< css::sheet::XSheetCellRangeContainer > xSheetCellRanges
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
bool HasExternalRefManager() const
void SetStyles(SvXMLStylesContext *pStyles)
SvXMLImportContext * CreateScriptContext()
css::uno::Reference< css::util::XNumberFormatTypes > xNumberFormatTypes
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
ScMyTables aTables
Lift cycle managed elsewhere, no need to delete.
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisStylesImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Provide mapping from ODF text formatting styles to EditEngine's, for rich-text cell content import...
static bool GetAddressFromString(ScAddress &rAddress, const OUString &rAddressStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator= ' ', sal_Unicode cQuote= '\'')
String to Range core.
#define SC_UNO_ODS_LOCK_SOLAR_MUTEX
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
SAL_DLLPUBLIC_EXPORT bool TestImportFODS(SvStream &rStream)
std::unique_ptr< ContentProperties > pData
void SetProtection(const css::uno::Sequence< sal_Int8 > &rPass)
Store pivot table data that need to be post-processed at the end of the import.
constexpr sal_uInt16 XML_NAMESPACE_OOOC
ScDocument * GetDocument()
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
void updateAbsAfterLoad()
Replace the original URL with the real URL that was generated from the relative URL.
constexpr OUStringLiteral PERCENT(u"Percent")
void StoreInitialNamespaces(const SvXMLNamespaceMap &rNamespaces)
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
Stores data imported from the file that need to be processed at the end of the import process...
static ScDocument * GetScDocument(const css::uno::Reference< css::frame::XModel > &xModel)
SvXMLNamespaceMap & GetNamespaceMap()
std::vector< ScDocRowHeightUpdater::TabRanges > maRecalcRowRanges
SvXMLImportContext * CreateFontDeclsContext()
SCTAB GetLastSheet() const
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void SetLastSheet(SCTAB nNew)
const ScXMLEditAttributeMap & GetEditAttributeMap() const
void RecalcPos(SdrObject *pObj, ScDrawObjData &rData, bool bNegativePage, bool bUpdateNoteCaptionPos)
css::uno::Reference< css::frame::XModel > GetModel() const
Accessor class to ScDocument.
std::unique_ptr< ScMyImportValidations > pValidations
bool IsAdjustHeightLocked() const
void SetFontDecls(XMLFontStylesContext *pFontDecls)
const sal_uInt16 XML_NAMESPACE_UNKNOWN
SvXMLImportContext * CreateMetaContext(sal_Int32 nElement)
rtl::Reference< XMLPropertySetMapper > xRowStylesPropertySetMapper
bool SetNullDateOnUnitConverter()
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SC_DLLPUBLIC SCTAB GetTableCount() const
std::unique_ptr< ScDocumentImport > mpDocImport
sc::ImportPostProcessData * mpPostProcessData
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
std::unique_ptr< sc::PivotTableSources > mpPivotSources
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
sal_Int32 SetCurrencySymbol(const sal_Int32 nKey, const OUString &rCurrency)
constexpr OUStringLiteral gsCellStyle(u""SC_UNONAME_CELLSTYL)
bool bSelfImportingXMLSet
FormulaError GetFormulaErrorConstant(const OUString &rStr) const
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
ScXMLImport(const ScXMLImport &)=delete
ScChangeTrack * GetChangeTrack() const
virtual void SAL_CALL endDocument() override
SvXMLImportContext * CreateStylesContext(bool bAutoStyles)
static bool GetRangeFromString(ScRange &rRange, const OUString &rRangeStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator= ' ', sal_Unicode cQuote= '\'')
SvXMLStylesContext * GetStyles()
OutputDevice * GetDevice() const
SheetNamedExpMap m_SheetNamedExpressions
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
bool GetValidation(const OUString &sName, ScMyImportValidation &aValidation)
void ApplyCondFormat(const css::uno::Sequence< css::table::CellRangeAddress > &xCellRanges)
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)
void ExamineDefaultStyle()
This class exists only to provide GetScImport() to its derived classes.
void Increment(sal_Int32 nInc=1)
const OUString & getNumDecimalSep() const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
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_XMLOasisContentImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
const XMLPropertyMapEntry aXMLScTableStylesImportProperties[]
bool IsImportingXML() const
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats) override
sal_Int32 GetNumberFormat()
void SetPostProcessData(sc::ImportPostProcessData *p)
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
void CopyStylesToDoc(bool bOverwrite, bool bFinish=true)
std::unique_ptr< ScXMLEditAttributeMap > mpEditAttrMap
virtual void SAL_CALL startDocument() override
static void decode(css::uno::Sequence< sal_Int8 > &aPass, const OUString &sBuffer)
static SC_DLLPUBLIC void Init()
DLL-init/exit-code must be linked to the DLL only.
void SetLoading(SfxLoadedFlags nFlags)
std::unique_ptr< ScMyStyleNumberFormats > pStyleNumberFormats
SfxObjectShell * GetEmbeddedObject() const
const sal_uInt16 XML_NAMESPACE_UNKNOWN_FLAG
bool HasRangeOverflow() const
std::unique_ptr< ScCompiler > mpComp
ScFormulaParserPool & GetFormulaParserPool() const
Returns the pool containing external formula parsers.
static void ConvertCellRangeAddress(OUString &sFormula)
const SdrPage * GetPage(sal_uInt16 nPgNum) const
bool IsCurrencySymbol(const sal_Int32 nNumberFormat, const OUString &sCurrencySymbol, std::u16string_view sBankSymbol)
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
#define SC_CURRENCYSYMBOL
SC_DLLPUBLIC void UnlockAdjustHeight()
std::unique_ptr< ScMyLabelRanges > pMyLabelRanges
const XMLPropertyMapEntry aXMLScColumnStylesProperties[]
#define SC_UNO_ODS_IMPORT_STYLES
sal_uInt32 nSolarMutexLocked
bool setNullDate(const css::uno::Reference< css::frame::XModel > &xModel)
ProgressBarHelper * GetProgressBarHelper()
Use this class to manage solar mutex locking instead of calling LockSolarMutex() and UnlockSolarMutex...
void BroadcastUno(const SfxHint &rHint)
std::unique_ptr< ScMyNamedExpressions > m_pMyNamedExpressions
formula::FormulaGrammar::Grammar GetStorageGrammar() const
static sal_Int16 GetCellType(const char *rStrValue, const sal_Int32 nStrLength)
const sal_uInt16 XML_NAMESPACE_NONE
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...
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax
::std::list< std::unique_ptr< ScMyNamedExpression > > ScMyNamedExpressions
XMLNumberFormatAttributesExportHelper * GetNumberFormatAttributesExportHelper()
std::unique_ptr< ScEditEngineDefaulter > mpEditEngine
static sal_Int32 GetRangeType(const OUString &sRangeType)
std::unique_ptr< XMLNumberFormatAttributesExportHelper > pNumberFormatAttributesExportHelper
#define SC_UNONAME_CELLSTYL
ScEditEngineDefaulter * GetEditEngine()
void SetRangeOverflowType(ErrCode nType)
Configuration options for formula interpreter.
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
css::uno::Reference< css::util::XNumberFormats > xNumberFormats
SvXMLImportContext * CreateBodyContext(const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList)
constexpr OUStringLiteral gsLocale(u""SC_LOCALE)
SAL_DLLPUBLIC_EXPORT bool TestImportXLSX(SvStream &rStream)
virtual void SAL_CALL startDocument() override
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
Reference< XMultiServiceFactory > getProcessServiceFactory()
std::unique_ptr< char[]> aBuffer
bool IsStylesOnlyMode() const
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
std::unique_ptr< SolarMutexGuard > pSolarMutexGuard
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
SvXMLImportFlags getImportFlags() const
OUString GetStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName) const
bool mbHasStringRefSyntax
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
ScMyStyleNumberFormats * GetStyleNumberFormats()
void AddCellStyle(const OUString &rName, const ScAddress &rCellPos)
rtl::Reference< XMLPropertySetMapper > xColumnStylesPropertySetMapper
static ScDrawObjData * GetObjDataTab(SdrObject *pObj, SCTAB nTab)
const ScCalcConfig & GetCalcConfig() const
std::unique_ptr< ScMyStylesImportHelper > pStylesImportHelper
void SetEmbedFonts(bool bUse)
rtl::Reference< XMLPropertySetMapper > xTableStylesPropertySetMapper
#define SC_UNONAME_NUMFMT
SC_DLLPUBLIC void SetChangeTrack(std::unique_ptr< ScChangeTrack > pTrack)
only for import filter, deletes any existing ChangeTrack via EndChangeTracking() and takes ownership ...
#define SAL_INFO(area, stream)
const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
bool DoInitNew(SfxMedium *pMedium=nullptr)
#define XMLERROR_FLAG_ERROR
ScXMLChangeTrackingImportHelper * GetChangeTrackingImportHelper()
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats)
const XMLPropertyMapEntry aXMLScRowStylesImportProperties[]
std::unique_ptr< ScMyImpDetectiveOpArray > pDetectiveOpArray
#define XML_ELEMENT(prefix, name)
sal_uInt16 Add(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey=XML_NAMESPACE_UNKNOWN)
virtual void DisposingModel() override
const SvXMLUnitConverter & GetMM100UnitConverter() const
const css::uno::Reference< css::frame::XModel > & GetModel() const
Reference< XComponentContext > getProcessComponentContext()
void InitializeCellAnchoredObj(SdrObject *pObj, ScDrawObjData &rData)
void SetValue(sal_Int32 nValue)
static void convertPropertySet(css::uno::Sequence< css::beans::PropertyValue > &rProps, const css::uno::Reference< css::beans::XPropertySet > &aProperties)
void SetError(sal_Int32 nId, const css::uno::Sequence< OUString > &rMsgParams, const OUString &rExceptionMessage, const css::uno::Reference< css::xml::sax::XLocator > &rLocator)
Sequence< sal_Int8 > aSeq
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
constexpr sal_uInt16 XML_NAMESPACE_OF
#define SC_UNO_COLLABELRNG
void SetAutoStyles(SvXMLStylesContext *pAutoStyles)
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
const XMLPropertyMapEntry aXMLScCellStylesProperties[]
ScMyImpDetectiveOpArray * GetDetectiveOpArray()
static bool GetRangeListFromString(ScRangeList &rRangeList, const OUString &rRangeListStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator= ' ', sal_Unicode cQuote= '\'')
const OUString & getNumThousandSep() const
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
const css::uno::Reference< css::beans::XPropertySet > & getImportInfo() const
void SetReference(sal_Int32 nVal)
void SetChangeTrackingViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &rChangeProps)
static bool isLatinScript(const ScPatternAttr &rPat, ScDocument &rDoc)
Check if the attribute pattern has a number format that only produces latin script output...
SfxObjectShell * GetDocumentShell() const
Reference< XModel > xModel
constexpr OUStringLiteral gsNumberFormat(u""SC_UNONAME_NUMFMT)
#define DBG_TESTSOLARMUTEX()
virtual ~ScXMLImport() override
virtual void DisposingModel()
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
rtl::Reference< XMLPropertyHandlerFactory > xScPropHdlFactory
bool IsSheetBlocked(SCTAB nTab) const
void AddNamedExpression(ScMyNamedExpression *pMyNamedExpression)
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
rtl::Reference< XMLPropertySetMapper > xCellStylesPropertySetMapper
sal_Int32 GetByteOffset() const
#define SC_UNO_ROWLABELRNG
void ProgressBarIncrement()
sc::PivotTableSources & GetPivotTableSources()
SvXMLStylesContext * GetAutoStyles()
SC_DLLPUBLIC void SetCalcConfig(const ScCalcConfig &rConfig)
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier()
void SetType(const css::uno::Reference< css::beans::XPropertySet > &rProperties, sal_Int32 &rNumberFormat, const sal_Int16 nCellType, const OUString &rCurrency)
MutexGuard(ScXMLImport &rImport)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisMetaImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
virtual XMLShapeImportHelper * CreateShapeImport() override
virtual void NotifyContainsEmbeddedFont() override
ScDocumentImport & GetDoc()
sal_uInt16 GetKeyByQName(const OUString &rQName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace, QNameMode eMode) const
virtual void SAL_CALL endDocument() override
bool any2bool(const css::uno::Any &rAny)
void SetStylesToRangesFinished()
void SetRangeOverflowType(ErrCode nType)
void SetSheetNamedRanges()
std::unique_ptr< ScXMLChangeTrackingImportHelper > pChangeTrackingImportHelper