20#include <config_wasm_strip.h>
27#include <com/sun/star/beans/XPropertySetInfo.hpp>
47#include <com/sun/star/container/XNameContainer.hpp>
48#include <com/sun/star/lang/XMultiServiceFactory.hpp>
49#include <com/sun/star/lang/XUnoTunnel.hpp>
50#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
51#include <com/sun/star/io/XOutputStream.hpp>
52#include <com/sun/star/util/MeasureUnit.hpp>
53#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
54#include <com/sun/star/frame/XModel.hpp>
55#include <com/sun/star/document/XBinaryStreamResolver.hpp>
56#include <com/sun/star/document/XStorageBasedDocument.hpp>
57#include <com/sun/star/document/XGraphicStorageHandler.hpp>
58#include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
59#include <com/sun/star/xml/sax/XLocator.hpp>
60#include <com/sun/star/xml/sax/FastParser.hpp>
61#include <com/sun/star/xml/sax/SAXException.hpp>
62#include <com/sun/star/packages/zip/ZipIOException.hpp>
63#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
76#include <fasttokenhandler.hxx>
80#include <com/sun/star/rdf/XMetadatable.hpp>
81#include <com/sun/star/rdf/XRepositorySupplier.hpp>
84using ::com::sun::star::beans::XPropertySetInfo;
95std::unordered_map< sal_Int32, std::pair< OUString, OUString > > SvXMLImport::aNamespaceMap;
96std::unordered_map< OUString, OUString > SvXMLImport::aNamespaceURIPrefixMap;
97bool SvXMLImport::bIsNSMapsInitialized =
false;
101class SvXMLImportEventListener :
public cppu::WeakImplHelper< css::lang::XEventListener >
104 SvXMLImport* pImport;
107 explicit SvXMLImportEventListener(SvXMLImport* pImport);
110 virtual void SAL_CALL disposing(
const lang::EventObject& rEventObject)
override;
115SvXMLImportEventListener::SvXMLImportEventListener(SvXMLImport* pTempImport)
116 : pImport(pTempImport)
121void SAL_CALL SvXMLImportEventListener::disposing(
const lang::EventObject& )
125 pImport->DisposingModel();
134getBuildIdsProperty(uno::Reference<beans::XPropertySet>
const& xImportInfo)
136 if (xImportInfo.is())
140 Reference< XPropertySetInfo >
const xSetInfo(
141 xImportInfo->getPropertySetInfo());
142 if (xSetInfo.is() && xSetInfo->hasPropertyByName(
"BuildId"))
145 xImportInfo->getPropertyValue(
"BuildId") >>= aBuildId;
149 catch (Exception
const&)
160 sal_uInt16 mnGeneratorVersion;
164 : mnGeneratorVersion( SvXMLImport::ProductVersionUnknown )
166 OUString
const buildIds(
167 getBuildIdsProperty(rImport.getImportInfo()));
168 if (!buildIds.isEmpty())
170 sal_Int32
const ix = buildIds.indexOf(
';');
173 OUString
const loVersion(buildIds.copy(ix + 1));
174 if (!loVersion.isEmpty())
176 auto const firstDot(loVersion.indexOf(
'.'));
179 if (
'3' == loVersion[0])
181 mnGeneratorVersion = SvXMLImport::LO_3x;
183 else if (
'4' == loVersion[0])
185 if (loVersion.getLength() > 2
186 && (loVersion[2] ==
'0' || loVersion[2] ==
'1'))
188 mnGeneratorVersion = SvXMLImport::LO_41x;
190 else if (loVersion.getLength() > 2 &&
'2' == loVersion[2])
192 mnGeneratorVersion = SvXMLImport::LO_42x;
194 else if (loVersion.getLength() > 2 &&
'3' == loVersion[2])
196 mnGeneratorVersion = SvXMLImport::LO_43x;
198 else if (loVersion.getLength() > 2 &&
'4' == loVersion[2])
200 mnGeneratorVersion = SvXMLImport::LO_44x;
203 else if (
'5' == loVersion[0])
205 mnGeneratorVersion = SvXMLImport::LO_5x;
207 else if (
'6' == loVersion[0])
209 if (loVersion.getLength() > 2
210 && (loVersion[2] ==
'0' || loVersion[2] ==
'1'
211 || loVersion[2] ==
'2'))
213 mnGeneratorVersion = SvXMLImport::LO_6x;
217 mnGeneratorVersion = SvXMLImport::LO_63x;
220 else if (
'7' == loVersion[0])
222 mnGeneratorVersion = SvXMLImport::LO_7x;
226 SAL_INFO(
"xmloff.core",
"unknown LO version: " << loVersion);
229 else if (1 < firstDot)
231 OUString
const nMajor(loVersion.subView(0, firstDot));
232 auto const year(nMajor.toInt32());
236 mnGeneratorVersion = SvXMLImport::LO_New;
240 SAL_INFO(
"xmloff.core",
"unknown LO version: " << loVersion);
245 SAL_INFO(
"xmloff.core",
"unknown LO version: " << loVersion);
251 sal_Int32 nUPD, nBuild;
252 if ( !rImport.getBuildIds( nUPD, nBuild ) )
255 if ( nUPD >= 640 && nUPD <= 645 )
257 mnGeneratorVersion = SvXMLImport::OOo_1x;
259 else if ( nUPD == 680 )
261 mnGeneratorVersion = SvXMLImport::OOo_2x;
263 else if ( nUPD == 300 && nBuild <= 9379 )
265 mnGeneratorVersion = SvXMLImport::OOo_30x;
267 else if ( nUPD == 310 )
269 mnGeneratorVersion = SvXMLImport::OOo_31x;
271 else if ( nUPD == 320 )
273 mnGeneratorVersion = SvXMLImport::OOo_32x;
275 else if ( nUPD == 330 )
277 mnGeneratorVersion = SvXMLImport::OOo_33x;
279 else if ( nUPD == 340 )
281 mnGeneratorVersion = SvXMLImport::OOo_34x;
283 else if (nUPD == 400 || nUPD == 401)
285 mnGeneratorVersion = SvXMLImport::AOO_40x;
287 else if (nUPD >= 410)
291 mnGeneratorVersion = SvXMLImport::AOO_4x;
295 sal_uInt16 getGeneratorVersion()
const
297 return mnGeneratorVersion;
340 OUString theImplementationName,
341 const css::uno::Sequence< OUString > & sSupportedServiceNames = {})
374 const uno::Reference< xml::sax::XFastAttributeList >& )
377 SAL_WARN(
"xmloff.core",
"CreateFastContext should be overridden, for element " << nElement);
381void SvXMLImport::InitCtor_()
421 mxNamespaceMap->Add(
"_office_libo",
425 if (mxNumberFormatsSupplier.is())
426 mpNumImport = std::make_unique<SvXMLNumFmtHelper>(mxNumberFormatsSupplier, GetComponentContext());
428 if (
mxModel.is() && !mxEventListener.is())
430 mxEventListener.set(
new SvXMLImportEventListener(
this));
431 mxModel->addEventListener(mxEventListener);
435SvXMLImport::SvXMLImport(
436 const css::uno::Reference< css::uno::XComponentContext >& xContext,
437 OUString
const & implementationName,
439 const css::uno::Sequence< OUString > & sSupportedServiceNames )
447 mnImportFlags( nImportFlags ),
449 mbIsFormsSupported( true ),
450 mbIsTableShapeSupported( false ),
451 mbNotifyMacroEventRead( false )
453 SAL_WARN_IF( !xContext.is(),
"xmloff.core",
"got no service manager" );
455 mxParser = xml::sax::FastParser::create( xContext );
456 setNamespaceHandler( maNamespaceHandler );
457 setTokenHandler( xTokenHandler );
458 if ( !bIsNSMapsInitialized )
460 initializeNamespaceMaps();
461 bIsNSMapsInitialized =
true;
463 registerNamespaces();
467void SvXMLImport::cleanup() noexcept
469 if (mxEventListener.is() &&
mxModel.is())
470 mxModel->removeEventListener(mxEventListener);
473 while (!maContexts.empty())
476 pStylesContext->dispose();
480 mxTextImport->dispose();
481 mxTextImport.clear();
485SvXMLImport::~SvXMLImport() noexcept
490bool SvXMLImport::addEmbeddedFont(
const css::uno::Reference< css::io::XInputStream >& stream,
491 const OUString& fontName, std::u16string_view extra,
492 std::vector<unsigned char>
const & key,
bool eot)
494 if (!mxEmbeddedFontHelper)
496 return mxEmbeddedFontHelper->addEmbeddedFont(stream, fontName, extra, key, eot);
501 class setFastDocumentHandlerGuard
504 css::uno::Reference<css::xml::sax::XFastParser> mxParser;
506 setFastDocumentHandlerGuard(css::uno::Reference<css::xml::sax::XFastParser> Parser,
507 const css::uno::Reference<css::xml::sax::XFastDocumentHandler>& Handler)
508 : mxParser(
std::move(Parser))
510 mxParser->setFastDocumentHandler(Handler);
513 ~setFastDocumentHandlerGuard()
515 mxParser->setFastDocumentHandler(
nullptr);
521void SAL_CALL SvXMLImport::parseStream(
const xml::sax::InputSource& aInputSource )
523 setFastDocumentHandlerGuard aDocumentHandlerGuard(mxParser, mxFastDocumentHandler.is() ? mxFastDocumentHandler :
this);
524 mxParser->parseStream(aInputSource);
527void SAL_CALL SvXMLImport::setFastDocumentHandler(
const uno::Reference< xml::sax::XFastDocumentHandler >& Handler )
529 mxFastDocumentHandler = Handler;
532void SAL_CALL SvXMLImport::setTokenHandler(
const uno::Reference< xml::sax::XFastTokenHandler >& Handler )
534 mxParser->setTokenHandler( Handler );
537void SAL_CALL SvXMLImport::registerNamespace(
const OUString& NamespaceURL, sal_Int32 NamespaceToken )
539 mxParser->registerNamespace( NamespaceURL, NamespaceToken );
542OUString SAL_CALL SvXMLImport::getNamespaceURL(
const OUString& rPrefix )
544 return mxParser->getNamespaceURL( rPrefix );
547void SAL_CALL SvXMLImport::setErrorHandler(
const uno::Reference< xml::sax::XErrorHandler >& Handler )
549 mxParser->setErrorHandler( Handler );
552void SAL_CALL SvXMLImport::setEntityResolver(
const uno::Reference< xml::sax::XEntityResolver >& Resolver )
554 mxParser->setEntityResolver( Resolver );
557void SAL_CALL SvXMLImport::setLocale(
const lang::Locale& rLocale )
559 mxParser->setLocale( rLocale );
562void SAL_CALL SvXMLImport::setNamespaceHandler(
const uno::Reference< xml::sax::XFastNamespaceHandler >& Handler)
564 mxParser->setNamespaceHandler( Handler );
567void SAL_CALL SvXMLImport::setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements )
569 mxParser->setCustomEntityNames( replacements );
572void SAL_CALL SvXMLImport::startDocument()
574 SAL_INFO(
"xmloff.core",
"{ SvXMLImport::startDocument" );
575 if (mxGraphicStorageHandler.is() && mxEmbeddedResolver.is())
578 Reference< lang::XMultiServiceFactory >
xFactory( mxModel, UNO_QUERY );
584 if (!mxGraphicStorageHandler.is())
587 mxGraphicStorageHandler.set(
588 xFactory->createInstance(
"com.sun.star.document.ImportGraphicStorageHandler"),
590 mpImpl->mbOwnGraphicResolver = mxGraphicStorageHandler.is();
593 if( !mxEmbeddedResolver.is() )
596 mxEmbeddedResolver.set(
597 xFactory->createInstance(
"com.sun.star.document.ImportEmbeddedObjectResolver"),
599 mpImpl->mbOwnEmbeddedResolver = mxEmbeddedResolver.is();
602 catch( css::uno::Exception& )
607void SAL_CALL SvXMLImport::endDocument()
609 SAL_INFO(
"xmloff.core",
"} SvXMLImport::endDocument" );
614 mxTextImport->MapCrossRefHeadingFieldsHorribly();
616 if (mpImpl->mpRDFaHelper)
618 const uno::Reference<rdf::XRepositorySupplier> xRS(mxModel,
622 mpImpl->mpRDFaHelper->InsertRDFa( xRS );
627 if (mxImportInfo.is())
629 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
630 if (xPropertySetInfo.is())
632 if (
bool(mpProgressBarHelper))
637 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
638 xPropertySetInfo->hasPropertyByName(sProgressCurrent))
640 sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
641 sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
642 mxImportInfo->setPropertyValue(sProgressMax,
uno::Any(nProgressMax));
643 mxImportInfo->setPropertyValue(sProgressCurrent,
uno::Any(nProgressCurrent));
645 if (xPropertySetInfo->hasPropertyByName(sRepeat))
646 mxImportInfo->setPropertyValue(sRepeat, css::uno::Any(mpProgressBarHelper->GetRepeat()));
650 if (mxNumberStyles.is() && xPropertySetInfo->hasPropertyByName(sNumberStyles))
652 mxImportInfo->setPropertyValue(sNumberStyles,
Any(mxNumberStyles));
657 if( mxFontDecls.is() )
658 mxFontDecls->dispose();
661 if( mxAutoStyles.is() )
662 mxAutoStyles->dispose();
663 if( mxMasterStyles.is() )
664 mxMasterStyles->dispose();
668 if ( mxFormImport.is() )
669 mxFormImport->documentDone();
673 mxShapeImport =
nullptr;
675 if( mpImpl->mbOwnGraphicResolver )
677 Reference<lang::XComponent> xComp(mxGraphicStorageHandler, UNO_QUERY);
681 if( mpImpl->mbOwnEmbeddedResolver )
683 Reference< lang::XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
688 if (
bool( mpXMLErrors ) )
694std::optional<SvXMLNamespaceMap> SvXMLImport::processNSAttributes(
695 std::optional<SvXMLNamespaceMap> & rpNamespaceMap,
696 SvXMLImport *
const pImport,
697 const uno::Reference< xml::sax::XAttributeList >& xAttrList)
699 std::optional<SvXMLNamespaceMap> pRewindMap;
700 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
701 for( sal_Int16 i=0;
i < nAttrCount;
i++ )
703 const OUString& rAttrName = xAttrList->getNameByIndex( i );
704 if (pImport && rAttrName ==
"office:version" && !pImport->mpImpl->mxODFVersion)
706 pImport->mpImpl->mxODFVersion = xAttrList->getValueByIndex( i );
709 if (pImport->mpImpl->mStreamName ==
"content.xml"
710 && !pImport->IsODFVersionConsistent(*pImport->mpImpl->mxODFVersion))
712 throw xml::sax::SAXException(
"Inconsistent ODF versions in content.xml and manifest.xml!",
713 uno::Reference< uno::XInterface >(),
715 packages::zip::ZipIOException(
"Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
718 else if( ( rAttrName.getLength() >= 5 ) &&
719 ( rAttrName.startsWith(
GetXMLToken(XML_XMLNS) ) ) &&
720 ( rAttrName.getLength() == 5 ||
':' == rAttrName[5] ) )
724 pRewindMap = std::move(rpNamespaceMap);
725 rpNamespaceMap.emplace(*pRewindMap);
727 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
729 OUString aPrefix( ( rAttrName.getLength() == 5 )
731 : rAttrName.copy( 6 ) );
733 sal_uInt16 nKey = rpNamespaceMap->AddIfKnown( aPrefix, rAttrValue );
738 OUString aTestName( rAttrValue );
740 nKey = rpNamespaceMap->AddIfKnown( aPrefix, aTestName );
744 rpNamespaceMap->Add( aPrefix, rAttrValue );
752void SAL_CALL SvXMLImport::characters(
const OUString& rChars )
754 maContexts.top()->characters( rChars );
757void SAL_CALL SvXMLImport::processingInstruction(
const OUString&,
762void SAL_CALL SvXMLImport::setDocumentLocator(
const uno::Reference< xml::sax::XLocator >& rLocator )
764 mxLocator = rLocator;
768void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
769 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
771 SAL_INFO(
"xmloff.core",
"startFastElement " << SvXMLImport::getNameFromToken( Element ));
772 if ( Attribs.is() && !mpImpl->mxODFVersion)
777 if( aIter != rAttribList.
end() )
779 mpImpl->mxODFVersion = aIter.toString();
782 if ( mpImpl->mStreamName ==
"content.xml" && !IsODFVersionConsistent( *mpImpl->mxODFVersion ) )
784 throw xml::sax::SAXException(
"Inconsistent ODF versions in content.xml and manifest.xml!",
785 uno::Reference< uno::XInterface >(),
787 packages::zip::ZipIOException(
"Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
792 maNamespaceAttrList->Clear();
794 maNamespaceHandler->addNSDeclAttributes( maNamespaceAttrList );
795 std::optional<SvXMLNamespaceMap> pRewindMap = processNSAttributes(mxNamespaceMap,
this, maNamespaceAttrList);
798 const bool bRootContext = maContexts.empty();
799 if (!maContexts.empty())
802 SAL_INFO(
"xmloff.core",
"calling createFastChildContext on " <<
typeid(*pHandler.get()).name());
803 auto tmp = pHandler->createFastChildContext( Element, Attribs );
805 assert((tmp && xContext) || (!tmp && !xContext));
808 xContext.set( CreateFastContext( Element, Attribs ) );
810 SAL_INFO_IF(!xContext.is(),
"xmloff.core",
"No fast context for element " << getNameFromToken(Element));
811 if (bRootContext && !xContext)
813 OUString
aName = getNameFromToken(Element);
815 {
aName },
"Root element " +
aName +
" unknown", Reference<xml::sax::XLocator>() );
822 xContext->PutRewindMap(std::move(pRewindMap));
825 xContext->startFastElement( Element, Attribs );
828 maContexts.push(xContext);
831void SAL_CALL SvXMLImport::startUnknownElement (
const OUString & rNamespace,
const OUString & rName,
832 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
834 SAL_INFO(
"xmloff.core",
"startUnknownElement " << rNamespace <<
" " << rName);
836 const bool bRootContext = maContexts.empty();
837 if (!maContexts.empty())
840 SAL_INFO(
"xmloff.core",
"calling createUnknownChildContext on " <<
typeid(*pHandler.get()).name());
841 auto tmp = pHandler->createUnknownChildContext( rNamespace, rName, Attribs );
843 assert((tmp && xContext) || (!tmp && !xContext));
846 xContext.set( CreateFastContext( -1, Attribs ) );
848 SAL_WARN_IF(!xContext.is(),
"xmloff.core",
"No context for unknown-element " << rNamespace <<
" " << rName);
849 if (bRootContext && !xContext)
852 { rName },
"Root element " + rName +
" unknown", Reference<xml::sax::XLocator>() );
856 if (!maContexts.empty())
859 xContext = maContexts.top();
864 xContext->startUnknownElement( rNamespace, rName, Attribs );
865 maContexts.push(xContext);
868void SAL_CALL SvXMLImport::endFastElement (sal_Int32 Element)
870 SAL_INFO(
"xmloff.core",
"endFastElement " << SvXMLImport::getNameFromToken( Element ));
871 if (maContexts.empty())
873 SAL_WARN(
"xmloff.core",
"SvXMLImport::endFastElement: no context left");
879 std::optional<SvXMLNamespaceMap> pRewindMap = xContext->TakeRewindMap();
881 xContext->endFastElement( Element );
884 mxNamespaceMap = std::move(pRewindMap);
887void SAL_CALL SvXMLImport::endUnknownElement (
const OUString & rPrefix,
const OUString & rLocalName)
889 SAL_INFO(
"xmloff.core",
"endUnknownElement " << rPrefix <<
" " << rLocalName);
890 if (maContexts.empty())
892 SAL_WARN(
"xmloff.core",
"SvXMLImport::endUnknownElement: no context left");
898 xContext->endUnknownElement( rPrefix, rLocalName );
901uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
902 SvXMLImport::createFastChildContext (sal_Int32,
903 const uno::Reference< xml::sax::XFastAttributeList > &)
908uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
909 SvXMLImport::createUnknownChildContext (
const OUString &,
const OUString &,
910 const uno::Reference< xml::sax::XFastAttributeList > &)
915void SvXMLImport::SetStatistics(
const uno::Sequence< beans::NamedValue> &)
917 GetProgressBarHelper()->SetRepeat(
false);
918 GetProgressBarHelper()->SetReference(0);
922void SAL_CALL SvXMLImport::setTargetDocument(
const uno::Reference< lang::XComponent >& xDoc )
924 mxModel.set( xDoc, UNO_QUERY );
926 throw lang::IllegalArgumentException();
930 uno::Reference<document::XStorageBasedDocument>
const xSBDoc(mxModel, uno::UNO_QUERY);
931 uno::Reference<embed::XStorage>
const xStor(xSBDoc.is() ? xSBDoc->getDocumentStorage()
940 catch (uno::Exception
const&)
944 if (!mxEventListener.is())
946 mxEventListener.set(
new SvXMLImportEventListener(
this));
947 mxModel->addEventListener(mxEventListener);
950 SAL_WARN_IF(
bool(mpNumImport),
"xmloff.core",
"number format import already exists." );
955sal_Bool SAL_CALL SvXMLImport::filter(
const uno::Sequence< beans::PropertyValue >& )
960void SAL_CALL SvXMLImport::cancel( )
965void SAL_CALL SvXMLImport::initialize(
const uno::Sequence< uno::Any >& aArguments )
967 for(
const auto& rAny : aArguments )
969 Reference<XInterface> xValue;
972 uno::Reference<task::XStatusIndicator> xTmpStatusIndicator(
974 if( xTmpStatusIndicator.is() )
977 uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(xValue, UNO_QUERY);
978 if (xGraphicStorageHandler.is())
979 mxGraphicStorageHandler = xGraphicStorageHandler;
981 uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
983 if( xTmpObjectResolver.is() )
984 mxEmbeddedResolver = xTmpObjectResolver;
986 uno::Reference<beans::XPropertySet> xTmpPropSet( xValue, UNO_QUERY );
987 if( xTmpPropSet.is() )
989 mxImportInfo = xTmpPropSet;
990 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
991 if (xPropertySetInfo.is())
994 if (xPropertySetInfo->hasPropertyByName(sPropName))
996 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
997 aAny >>= mxNumberStyles;
1000 sPropName =
"PrivateData";
1001 if (xPropertySetInfo->hasPropertyByName(sPropName))
1003 Reference < XInterface > xIfc;
1004 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1014 sPropName =
"BaseURI";
1015 if (xPropertySetInfo->hasPropertyByName(sPropName))
1017 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1019 mpImpl->aBaseURL.SetURL( sBaseURI );
1020 mpImpl->aDocBase.SetURL( sBaseURI );
1023 sPropName =
"StreamRelPath";
1024 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1026 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1030 sPropName =
"StreamName";
1031 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1033 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1036 if( !sBaseURI.isEmpty() && !
sName.isEmpty() )
1038 if( !sRelPath.isEmpty() )
1039 mpImpl->aBaseURL.insertName( sRelPath );
1040 mpImpl->aBaseURL.insertName( sName );
1042 mpImpl->mStreamName =
sName;
1044 sPropName =
"ShapePositionInHoriL2R";
1045 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1047 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1048 aAny >>= mpImpl->mbShapePositionInHoriL2R;
1050 sPropName =
"TextDocInOOoFileFormat";
1051 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1053 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1054 aAny >>= mpImpl->mbTextDocInOOoFileFormat;
1057 sPropName =
"SourceStorage";
1058 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1059 mxImportInfo->getPropertyValue(sPropName) >>= mpImpl->mxSourceStorage;
1064 uno::Reference<lang::XInitialization>
const xInit(mxParser, uno::UNO_QUERY_THROW);
1065 xInit->initialize( {
Any(OUString(
"IgnoreMissingNSDecl")) });
1069OUString SAL_CALL SvXMLImport::getImplementationName()
1071 return mpImpl->implementationName;
1074sal_Bool SAL_CALL SvXMLImport::supportsService(
const OUString& rServiceName )
1079uno::Sequence< OUString > SAL_CALL SvXMLImport::getSupportedServiceNames( )
1081 return mpImpl->maSupportedServiceNames;
1101#if !ENABLE_WASM_STRIP_CHART
1110 return new ::xmloff::OFormLayerXMLImport(*
this);
1117const Reference< container::XNameContainer > & SvXMLImport::GetGradientHelper()
1119 if( !mxGradientHelper.is() )
1123 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1124 if( xServiceFact.is() )
1128 mxGradientHelper.set( xServiceFact->createInstance(
1129 "com.sun.star.drawing.GradientTable" ), UNO_QUERY);
1131 catch( lang::ServiceNotRegisteredException& )
1137 return mxGradientHelper;
1140const Reference< container::XNameContainer > & SvXMLImport::GetHatchHelper()
1142 if( !mxHatchHelper.is() )
1146 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1147 if( xServiceFact.is() )
1151 mxHatchHelper.set( xServiceFact->createInstance(
1152 "com.sun.star.drawing.HatchTable" ), UNO_QUERY);
1154 catch( lang::ServiceNotRegisteredException& )
1160 return mxHatchHelper;
1163const Reference< container::XNameContainer > & SvXMLImport::GetBitmapHelper()
1165 if( !mxBitmapHelper.is() )
1169 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1170 if( xServiceFact.is() )
1174 mxBitmapHelper.set( xServiceFact->createInstance(
1175 "com.sun.star.drawing.BitmapTable" ), UNO_QUERY);
1177 catch( lang::ServiceNotRegisteredException& )
1183 return mxBitmapHelper;
1186const Reference< container::XNameContainer > & SvXMLImport::GetTransGradientHelper()
1188 if( !mxTransGradientHelper.is() )
1192 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1193 if( xServiceFact.is() )
1197 mxTransGradientHelper.set( xServiceFact->createInstance(
1198 "com.sun.star.drawing.TransparencyGradientTable" ), UNO_QUERY);
1200 catch( lang::ServiceNotRegisteredException& )
1206 return mxTransGradientHelper;
1209const Reference< container::XNameContainer > & SvXMLImport::GetMarkerHelper()
1211 if( !mxMarkerHelper.is() )
1215 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1216 if( xServiceFact.is() )
1220 mxMarkerHelper.set( xServiceFact->createInstance(
"com.sun.star.drawing.MarkerTable" ), UNO_QUERY);
1222 catch( lang::ServiceNotRegisteredException& )
1228 return mxMarkerHelper;
1231const Reference< container::XNameContainer > & SvXMLImport::GetDashHelper()
1233 if( !mxDashHelper.is() &&
mxModel.is() )
1235 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1236 if( xServiceFact.is() )
1240 mxDashHelper.set( xServiceFact->createInstance(
"com.sun.star.drawing.DashTable" ), UNO_QUERY);
1242 catch( lang::ServiceNotRegisteredException& )
1247 return mxDashHelper;
1250bool SvXMLImport::IsPackageURL( std::u16string_view rURL )
const
1255 if( (mnImportFlags & nTest) == nTest )
1261 size_t nLen = rURL.size();
1262 if( nLen > 0 &&
'/' == rURL[0] )
1265 else if( nLen > 1 &&
'.' == rURL[0] )
1267 if(
'.' == rURL[1] )
1271 else if(
'/' == rURL[1] )
1278 while( nPos < nLen )
1280 switch( rURL[nPos] )
1298uno::Reference<graphic::XGraphic> SvXMLImport::loadGraphicByURL(OUString
const & rURL)
1300 uno::Reference<graphic::XGraphic> xGraphic;
1302 if (mxGraphicStorageHandler.is())
1304 if (IsPackageURL(rURL))
1306 xGraphic = mxGraphicStorageHandler->loadGraphic(rURL);
1310 OUString
const & rAbsoluteURL = GetAbsoluteReference(rURL);
1312 Graphic aGraphic(aExternalLink);
1313 xGraphic = aGraphic.GetXGraphic();
1320uno::Reference<graphic::XGraphic> SvXMLImport::loadGraphicFromBase64(uno::Reference<io::XOutputStream>
const & rxOutputStream)
1322 uno::Reference<graphic::XGraphic> xGraphic;
1324 if (mxGraphicStorageHandler.is())
1326 xGraphic = mxGraphicStorageHandler->loadGraphicFromOutputStream(rxOutputStream);
1332Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64()
const
1334 Reference< XOutputStream > xOStm;
1335 Reference< document::XBinaryStreamResolver > xStmResolver(mxGraphicStorageHandler, UNO_QUERY);
1337 if( xStmResolver.is() )
1338 xOStm = xStmResolver->createOutputStream();
1343OUString SvXMLImport::ResolveEmbeddedObjectURL(
1344 const OUString& rURL,
1345 std::u16string_view rClassId )
1349 if( IsPackageURL( rURL ) )
1351 if ( mxEmbeddedResolver.is() )
1353 OUString sURL( rURL );
1354 if( !rClassId.empty() )
1356 sURL += OUString::Concat(
"!") + rClassId;
1358 sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( sURL );
1362 sRet = GetAbsoluteReference( rURL );
1367Reference< embed::XStorage >
const & SvXMLImport::GetSourceStorage()
const
1369 return mpImpl->mxSourceStorage;
1372Reference < XOutputStream >
1373 SvXMLImport::GetStreamForEmbeddedObjectURLFromBase64()
const
1375 Reference < XOutputStream > xOLEStream;
1377 if( mxEmbeddedResolver.is() )
1379 Reference< XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
1382 Any aAny = xNA->getByName(
"Obj12345678" );
1383 aAny >>= xOLEStream;
1390OUString SvXMLImport::ResolveEmbeddedObjectURLFromBase64()
1394 if( mxEmbeddedResolver.is() )
1396 sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL(
"Obj12345678" );
1403 const OUString& rName,
1404 const OUString& rDisplayName )
1406 if( !mpStyleMap.is() )
1409 if( mxImportInfo.is() )
1411 OUString sPrivateData(
"PrivateData" );
1412 Reference< beans::XPropertySetInfo > xPropertySetInfo =
1413 mxImportInfo->getPropertySetInfo();
1414 if( xPropertySetInfo.is() &&
1415 xPropertySetInfo->hasPropertyByName(sPrivateData) )
1417 Reference < XInterface > xIfc(
1418 static_cast< css::lang::XTypeProvider *
>( mpStyleMap.get() ) );
1419 mxImportInfo->setPropertyValue( sPrivateData,
Any(xIfc) );
1424 StyleMap::key_type aKey( nFamily, rName );
1425 StyleMap::value_type aValue( aKey, rDisplayName );
1426 ::std::pair<StyleMap::iterator,bool> aRes( mpStyleMap->insert( aValue ) );
1429 "duplicate style name of family " <<
static_cast<int>(nFamily) <<
": \"" << rName <<
"\"");
1433OUString SvXMLImport::GetStyleDisplayName(
XmlStyleFamily nFamily,
1434 const OUString& rName )
const
1436 OUString
sName( rName );
1437 if( mpStyleMap.is() && !rName.isEmpty() )
1439 StyleMap::key_type aKey( nFamily, rName );
1440 StyleMap::const_iterator aIter = mpStyleMap->find( aKey );
1441 if( aIter != mpStyleMap->end() )
1442 sName = (*aIter).second;
1447void SvXMLImport::SetViewSettings(
const css::uno::Sequence<css::beans::PropertyValue>&)
1451void SvXMLImport::SetConfigurationSettings(
const css::uno::Sequence<css::beans::PropertyValue>&)
1455void SvXMLImport::SetDocumentSpecificSettings(
const OUString&,
const uno::Sequence<beans::PropertyValue>&)
1461 if (!mpProgressBarHelper)
1463 mpProgressBarHelper = std::make_unique<ProgressBarHelper>(mxStatusIndicator,
false);
1465 if (mxImportInfo.is())
1467 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
1468 if (xPropertySetInfo.is())
1474 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1475 xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1476 xPropertySetInfo->hasPropertyByName(sProgressRange))
1479 sal_Int32 nProgressMax(0);
1480 sal_Int32 nProgressCurrent(0);
1481 sal_Int32 nProgressRange(0);
1482 aAny = mxImportInfo->getPropertyValue(sProgressRange);
1483 if (aAny >>= nProgressRange)
1484 mpProgressBarHelper->SetRange(nProgressRange);
1485 aAny = mxImportInfo->getPropertyValue(sProgressMax);
1486 if (aAny >>= nProgressMax)
1487 mpProgressBarHelper->SetReference(nProgressMax);
1488 aAny = mxImportInfo->getPropertyValue(sProgressCurrent);
1489 if (aAny >>= nProgressCurrent)
1490 mpProgressBarHelper->SetValue(nProgressCurrent);
1492 if (xPropertySetInfo->hasPropertyByName(sRepeat))
1494 uno::Any aAny = mxImportInfo->getPropertyValue(sRepeat);
1496 mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1498 SAL_WARN(
"xmloff.core",
"why is it no boolean?" );
1504 return mpProgressBarHelper.get();
1507void SvXMLImport::AddNumberStyle(sal_Int32 nKey,
const OUString& rName)
1509 if (!mxNumberStyles.is())
1511 if (mxNumberStyles.is())
1515 mxNumberStyles->insertByName(rName,
Any(nKey));
1517 catch ( uno::Exception& )
1523 SAL_WARN(
"xmloff.core",
"not possible to create NameContainer");
1529 if (!mpEventImportHelper)
1533 mpEventImportHelper = std::make_unique<XMLEventImportHelper>();
1535 mpEventImportHelper->RegisterFactory(sStarBasic,
1536 std::make_unique<XMLStarBasicContextFactory>());
1538 mpEventImportHelper->RegisterFactory(sScript,
1539 std::make_unique<XMLScriptContextFactory>());
1543 mpEventImportHelper->RegisterFactory(
"StarBasic",
1544 std::make_unique<XMLStarBasicContextFactory>());
1547 return *mpEventImportHelper;
1552 if (mxFontDecls.is())
1553 mxFontDecls->dispose();
1554 mxFontDecls = pFontDecls;
1566 if (pAutoStyles && mxNumberStyles.is())
1569 const uno::Sequence<OUString> aStyleNames = mxNumberStyles->getElementNames();
1570 for (
const auto& name : aStyleNames)
1572 uno::Any aAny(mxNumberStyles->getByName(name));
1577 *
this, name, xAttrList, nKey,
1578 GetDataStylesImport()->GetLanguageForKey(nKey), *pAutoStyles);
1583 if (mxAutoStyles.is())
1584 mxAutoStyles->dispose();
1585 mxAutoStyles = pAutoStyles;
1586 GetTextImport()->SetAutoStyles( pAutoStyles );
1587 GetShapeImport()->SetAutoStylesContext( pAutoStyles );
1588#if !ENABLE_WASM_STRIP_CHART
1589 GetChartImport()->SetAutoStylesContext( pAutoStyles );
1591 GetFormImport()->setAutoStyleContext( pAutoStyles );
1596 if (mxMasterStyles.is())
1598 mxMasterStyles = pMasterStyles;
1603 return mxFontDecls.get();
1608 return mxStyles.get();
1613 return mxAutoStyles.get();
1618 return mxFontDecls.get();
1623 return mxStyles.get();
1628 return mxAutoStyles.get();
1631OUString SvXMLImport::GetAbsoluteReference(
const OUString& rValue)
const
1633 if( rValue.isEmpty() || rValue[0] ==
'#' )
1637 if( mpImpl->aBaseURL.GetNewAbsURL( rValue, &aAbsURL ) )
1643bool SvXMLImport::IsODFVersionConsistent(
const OUString& aODFVersion )
1646 bool bResult =
true;
1648 if ( !aODFVersion.isEmpty() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
1654 uno::Reference<embed::XStorage>
const xStor(GetSourceStorage());
1657 uno::Reference< beans::XPropertySet > xStorProps( xStor, uno::UNO_QUERY_THROW );
1662 bool bRepairPackage =
false;
1665 xStorProps->getPropertyValue(
"RepairPackage" )
1667 }
catch ( uno::Exception& )
1671 if ( !bRepairPackage )
1673 OUString aStorVersion;
1674 xStorProps->getPropertyValue(
"Version" )
1681 if ( !aStorVersion.isEmpty() )
1682 bResult = aODFVersion == aStorVersion;
1684 xStorProps->setPropertyValue(
"Version",
1689 bool bInconsistent =
false;
1690 xStorProps->getPropertyValue(
"IsInconsistent" )
1692 bResult = !bInconsistent;
1697 catch( uno::Exception& )
1704void SvXMLImport::CreateNumberFormatsSupplier_()
1706 SAL_WARN_IF( mxNumberFormatsSupplier.is(),
"xmloff.core",
"number formats supplier already exists!" );
1708 mxNumberFormatsSupplier =
1709 uno::Reference< util::XNumberFormatsSupplier> (mxModel, uno::UNO_QUERY);
1712void SvXMLImport::CreateDataStylesImport_()
1714 SAL_WARN_IF(
bool(mpNumImport),
"xmloff.core",
"data styles import already exists!" );
1715 uno::Reference<util::XNumberFormatsSupplier> xNum =
1716 GetNumberFormatsSupplier();
1718 mpNumImport = std::make_unique<SvXMLNumFmtHelper>(xNum, GetComponentContext() );
1724 if( !mpImpl->hBatsFontConv )
1727 FontToSubsFontFlags::IMPORT );
1728 SAL_WARN_IF( !mpImpl->hBatsFontConv,
"xmloff.core",
"Got no symbol font converter" );
1730 if( mpImpl->hBatsFontConv )
1741 if( !mpImpl->hMathFontConv )
1744 FontToSubsFontFlags::IMPORT );
1745 SAL_WARN_IF( !mpImpl->hMathFontConv,
"xmloff.core",
"Got no symbol font converter" );
1747 if( mpImpl->hMathFontConv )
1755void SvXMLImport::SetError(
1757 const Sequence<OUString>& rMsgParams,
1758 const OUString& rExceptionMessage,
1759 const Reference<xml::sax::XLocator>& rLocator )
1763 mpXMLErrors = std::make_unique<XMLErrors>();
1767 mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage,
1768 rLocator.is() ? rLocator : mxLocator );
1771void SvXMLImport::SetError(
1773 const Sequence<OUString>& rMsgParams)
1775 SetError( nId, rMsgParams,
"",
nullptr );
1778void SvXMLImport::SetError(
1780 const OUString& rMsg1)
1782 Sequence<OUString>
aSeq { rMsg1 };
1786void SvXMLImport::DisposingModel()
1788 if( mxFontDecls.is() )
1789 mxFontDecls->dispose();
1791 mxStyles->dispose();
1792 if( mxAutoStyles.is() )
1793 mxAutoStyles->dispose();
1794 if( mxMasterStyles.is() )
1795 mxMasterStyles->dispose();
1798 mxEventListener.set(
nullptr);
1803 return mpImpl->maInterfaceToIdentifierMapper;
1806uno::Reference< uno::XComponentContext >
const &
1807SvXMLImport::GetComponentContext()
const
1809 return mpImpl->mxComponentContext;
1812OUString SvXMLImport::GetBaseURL()
const
1817OUString SvXMLImport::GetDocumentBase()
const
1823bool SvXMLImport::IsShapePositionInHoriL2R()
const
1825 return mpImpl->mbShapePositionInHoriL2R;
1828bool SvXMLImport::IsTextDocInOOoFileFormat()
const
1830 return mpImpl->mbTextDocInOOoFileFormat;
1833void SvXMLImport::initXForms()
1838bool SvXMLImport::getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild )
const
1841 OUString
const aBuildId(getBuildIdsProperty(mxImportInfo));
1842 if (!aBuildId.isEmpty())
1844 sal_Int32
nIndex = aBuildId.indexOf(
'$');
1848 sal_Int32 nIndexEnd = aBuildId.indexOf(
';', nIndex);
1849 rBuild = (nIndexEnd == -1)
1851 :
o3tl::toInt32(aBuildId.subView(nIndex + 1, nIndexEnd - nIndex - 1));
1858sal_uInt16 SvXMLImport::getGeneratorVersion()
const
1861 return mpImpl->getGeneratorVersion( *
this );
1865bool SvXMLImport::isGeneratorVersionOlderThan(
1866 sal_uInt16
const nOOoVersion, sal_uInt16
const nLOVersion)
1868 assert( (nLOVersion & LO_flag));
1869 assert(!(nOOoVersion & LO_flag));
1870 const sal_uInt16 nGeneratorVersion(getGeneratorVersion());
1871 return (nGeneratorVersion & LO_flag)
1872 ? nGeneratorVersion < nLOVersion
1873 : nGeneratorVersion < nOOoVersion;
1877OUString SvXMLImport::GetODFVersion()
const
1879 return mpImpl->mxODFVersion ? *mpImpl->mxODFVersion : OUString();
1882bool SvXMLImport::IsOOoXML()
const
1884 return mpImpl->mbIsOOoXML;
1887bool SvXMLImport::IsMSO()
const
1889 if (!mpImpl->mbIsMSO.has_value())
1891 uno::Reference<document::XDocumentPropertiesSupplier> xSupplier(GetModel(), uno::UNO_QUERY);
1894 uno::Reference<document::XDocumentProperties> xProps
1895 = xSupplier->getDocumentProperties();
1898 mpImpl->mbIsMSO = xProps->getGenerator().startsWith(
"MicrosoftOffice");
1903 return mpImpl->mbIsMSO.has_value() ? *mpImpl->mbIsMSO :
false;
1907void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface>
const & i_xIfc,
1908 OUString
const & i_rXmlId)
1910 if (i_rXmlId.isEmpty())
1914 const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
1918 const beans::StringPair mdref( mpImpl->mStreamName, i_rXmlId );
1920 xMeta->setMetadataReference(mdref);
1921 }
catch (lang::IllegalArgumentException &) {
1923 SAL_INFO(
"xmloff.core",
"SvXMLImport::SetXmlId: cannot set xml:id");
1926 }
catch (uno::Exception &) {
1932SvXMLImport::GetRDFaImportHelper()
1934 if (!mpImpl->mpRDFaHelper)
1936 mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*
this) );
1938 return *mpImpl->mpRDFaHelper;
1942SvXMLImport::AddRDFa(
const uno::Reference<rdf::XMetadatable>& i_xObject,
1943 OUString
const & i_rAbout,
1944 OUString
const & i_rProperty,
1945 OUString
const & i_rContent,
1946 OUString
const & i_rDatatype)
1951 rRDFaHelper.ParseAndAddRDFa(i_xObject,
1952 i_rAbout, i_rProperty, i_rContent, i_rDatatype);
1955bool SvXMLImport::embeddedFontAlreadyProcessed(
const OUString& url )
1957 if( m_embeddedFontUrlsKnown.count( url ) != 0 )
1959 m_embeddedFontUrlsKnown.insert( url );
1963const OUString & SvXMLImport::getNameFromToken( sal_Int32 nToken )
1965 return xTokenHandler->getIdentifier( nToken &
TOKEN_MASK );
1968OUString SvXMLImport::getPrefixAndNameFromToken( sal_Int32 nToken )
1972 auto aIter( aNamespaceMap.find( nNamespaceToken ) );
1973 if( aIter != aNamespaceMap.end() )
1974 rv = (*aIter).second.second +
" " + aIter->second.first +
":";
1975 return rv + xTokenHandler->getIdentifier( nToken &
TOKEN_MASK );
1978OUString SvXMLImport::getNamespacePrefixFromToken(sal_Int32 nToken,
const SvXMLNamespaceMap* pMap)
1981 auto aIter( aNamespaceMap.find( nNamespaceToken ) );
1982 if( aIter != aNamespaceMap.end() )
1987 if (!sRet.isEmpty())
1990 return (*aIter).second.first;
1996OUString SvXMLImport::getNamespaceURIFromToken( sal_Int32 nToken )
1999 auto aIter( aNamespaceMap.find( nNamespaceToken ) );
2000 if( aIter != aNamespaceMap.end() )
2001 return (*aIter).second.second;
2006OUString SvXMLImport::getNamespacePrefixFromURI(
const OUString& rURI )
2008 auto aIter( aNamespaceURIPrefixMap.find(rURI) );
2009 if( aIter != aNamespaceURIPrefixMap.end() )
2010 return (*aIter).second;
2015sal_Int32 SvXMLImport::getTokenFromName( std::u16string_view rName )
2019 return xTokenHandler->getTokenFromUTF8( aLocalNameSeq );
2022void SvXMLImport::initializeNamespaceMaps()
2024 auto mapTokenToNamespace = []( sal_Int32
nToken, sal_Int32 nPrefix, sal_Int32
nNamespace )
2030 assert( aNamespaceMap.find(nToken +1) == aNamespaceMap.end() &&
"cannot map two namespaces to the same token here");
2031 aNamespaceMap[
nToken + 1 ] = std::make_pair(
sPrefix, sNamespace );
2032 aNamespaceURIPrefixMap.emplace( sNamespace,
sPrefix );
2115void SvXMLImport::registerNamespaces()
2117 for(
auto const &aNamespaceEntry : aNamespaceMap )
2120 registerNamespace( aNamespaceEntry.second.second, aNamespaceEntry.first <<
NMSP_SHIFT );
2124void SvXMLImport::NotifyMacroEventRead()
2126 if (mbNotifyMacroEventRead)
2131 mbNotifyMacroEventRead =
true;
2142 const OUString& rPrefix = aNamespaceDefine.m_aPrefix;
2143 const OUString& rNamespaceURI = aNamespaceDefine.m_aNamespaceURI;
2145 if ( rPrefix.isEmpty() )
2148 sDecl =
"xmlns:" + rPrefix;
2149 rAttrList->AddAttribute( sDecl, rNamespaceURI );
2158 if ( rNamespacePrefix.isEmpty() )
2160 SvXMLImport::getNamespacePrefixFromURI( rNamespaceURI ), rNamespaceURI) );
2163 rNamespacePrefix, rNamespaceURI) );
2172: mrImport(
std::move( xImport )),
2173 mxFastAttributes( new
sax_fastparser::FastAttributeList( SvXMLImport::xTokenHandler.
get() ) )
2179 mrImport->setTargetDocument( xDoc );
2193 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
2198 SvXMLImport::processNSAttributes(
mrImport->mxNamespaceMap,
mrImport.get(), xAttrList);
2199 OUString aLocalName;
2200 sal_uInt16 nPrefix =
mrImport->mxNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
2201 sal_Int32 mnElement =
NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::getTokenFromName( aLocalName );
2204 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
2205 for( sal_Int16
i=0;
i < nAttrCount;
i++ )
2207 const OUString& rAttrName = xAttrList->getNameByIndex(
i );
2208 const OUString& rAttrValue = xAttrList->getValueByIndex(
i );
2209 if (rAttrName ==
"xmlns")
2211 sal_uInt16 nNamespaceKey =
mrImport->mxNamespaceMap->GetKeyByName(rAttrValue);
2214 nDefaultNamespace = nNamespaceKey;
2217 assert(
false &&
"unknown namespace");
2221 auto const nToken = SvXMLImport::getTokenFromName(rAttrName);
2236 OUString aLocalAttrName;
2237 OUString aNamespace;
2239 sal_uInt16
const nAttrPrefix =
mrImport->mxNamespaceMap->GetKeyByQName(
2243 auto const nToken = SvXMLImport::getTokenFromName(aLocalAttrName);
2262 OUString aLocalName;
2263 sal_uInt16 nPrefix =
mrImport->mxNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
2264 sal_Int32 mnElement =
NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::getTokenFromName(aLocalName);
2265 mrImport->endFastElement( mnElement );
2279 const OUString& aData)
2286 mrImport->setDocumentLocator( rLocator );
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
css::uno::Reference< css::frame::XModel2 > mxModel
constexpr OUStringLiteral XML_PROGRESSRANGE
constexpr OUStringLiteral XML_PROGRESSMAX
constexpr OUStringLiteral XML_PROGRESSCURRENT
constexpr OUStringLiteral XML_PROGRESSREPEAT
const XMLEventNameTranslation aStandardEventTable[]
a translation table for the events defined in the XEventsSupplier service (implemented in XMLEventExp...
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
With this class you can import a <chart:chart> element containing its data as <table:table> element o...
This class deliberately does not support XWeak, to improve performance when loading large documents.
SvXMLImportFastNamespaceHandler()
std::vector< NamespaceDefine > m_aNamespaceDefines
void addNSDeclAttributes(rtl::Reference< comphelper::AttributeList > const &rAttrList)
virtual OUString SAL_CALL getNamespaceURI(const OUString &rNamespacePrefix) override
virtual void SAL_CALL registerNamespace(const OUString &rNamespacePrefix, const OUString &rNamespaceURI) override
std::optional< OUString > mxODFVersion
sal_uInt16 getGeneratorVersion(const SvXMLImport &rImport)
OUString mStreamName
name of stream in package, e.g., "content.xml"
bool mbOwnEmbeddedResolver
FontToSubsFontConverter hMathFontConv
OUString implementationName
std::optional< DocumentInfo > moDocumentInfo
const uno::Reference< uno::XComponentContext > mxComponentContext
std::optional< bool > mbIsMSO
bool mbTextDocInOOoFileFormat
uno::Reference< embed::XStorage > mxSourceStorage
FontToSubsFontConverter hBatsFontConv
bool mbOwnGraphicResolver
bool mbShapePositionInHoriL2R
::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper
std::unique_ptr< xmloff::RDFaImportHelper > mpRDFaHelper
css::uno::Sequence< OUString > maSupportedServiceNames
SvXMLImport_Impl(uno::Reference< uno::XComponentContext > xContext, OUString theImplementationName, const css::uno::Sequence< OUString > &sSupportedServiceNames={})
rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes
virtual void SAL_CALL endDocument() override
virtual void SAL_CALL endElement(const OUString &aName) override
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
SvXMLLegacyToFastDocHandler(rtl::Reference< SvXMLImport > xImport)
virtual void SAL_CALL startDocument() override
rtl::Reference< SvXMLImport > mrImport
virtual void SAL_CALL ignorableWhitespace(const OUString &aWhitespaces) override
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
std::stack< sal_uInt16 > maDefaultNamespaces
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
virtual void SAL_CALL characters(const OUString &aChars) override
static bool NormalizeURI(OUString &rName)
sal_uInt16 GetKeyByName(const OUString &rName) const
const OUString & GetPrefixByKey(sal_uInt16 nKey) const
void AddStyle(SvXMLStyleContext &rNew)
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Helps the XMLEventsImportContext.
static sal_Int32 GetXStorageFormat(const css::uno::Reference< css::embed::XStorage > &xStorage)
FastAttributeIter find(sal_Int32 nToken) const
FastAttributeIter end() const
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XSingleServiceFactory > xFactory
UNOTOOLS_DLLPUBLIC FontToSubsFontConverter CreateFontToSubsFontConverter(std::u16string_view rFontName, FontToSubsFontFlags nFlags)
UNOTOOLS_DLLPUBLIC sal_Unicode ConvertFontToSubsFontChar(FontToSubsFontConverter hConverter, sal_Unicode c)
void * FontToSubsFontConverter
Sequence< sal_Int8 > aSeq
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral aData
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
COMPHELPER_DLLPUBLIC void notifyMacroEventRead(const css::uno::Reference< css::frame::XModel > &_rxDocument)
COMPHELPER_DLLPUBLIC css::uno::Reference< css::container::XNameContainer > NameContainer_createInstance(const css::uno::Type &aType)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral implementationName
const sal_uInt16 XML_NAMESPACE_UNKNOWN
const sal_uInt16 XML_NAMESPACE_XMLNS
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
@ XML_N_PRESENTATION_OASIS
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
OReadStatusBarDocumentHandler::StatusBar_XML_Namespace nNamespace
constexpr OUStringLiteral sScript
constexpr OUStringLiteral sStarBasic
#define XMLERROR_UNKNOWN_ROOT
#define XMLERROR_FLAG_SEVERE
#define XML_ELEMENT(prefix, name)
constexpr sal_Int32 NAMESPACE_TOKEN(sal_uInt16 prefixToken)
constexpr sal_Int32 NMSP_MASK
constexpr sal_Int32 TOKEN_MASK
constexpr size_t NMSP_SHIFT
constexpr sal_uInt16 XML_NAMESPACE_VERSIONS_LIST
constexpr sal_uInt16 XML_NAMESPACE_DRAW
constexpr sal_uInt16 XML_NAMESPACE_XHTML
constexpr sal_uInt16 XML_NAMESPACE_BLOCKLIST
constexpr sal_uInt16 XML_NAMESPACE_FORM_OOO
constexpr sal_uInt16 XML_NAMESPACE_FIELD
constexpr sal_uInt16 XML_NAMESPACE_TABLE_EXT
constexpr sal_uInt16 XML_NAMESPACE_DLG
constexpr sal_uInt16 XML_NAMESPACE_META
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_OASIS
constexpr sal_uInt16 XML_NAMESPACE_OFFICE_EXT
constexpr sal_uInt16 XML_NAMESPACE_SMIL
constexpr sal_uInt16 XML_NAMESPACE_DC
constexpr sal_uInt16 XML_NAMESPACE_REPORT
constexpr sal_uInt16 XML_NAMESPACE_DB
constexpr sal_uInt16 XML_NAMESPACE_TEXT_OOO
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT_OOO
constexpr sal_uInt16 XML_NAMESPACE_SMIL_COMPAT
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_ANIMATION
constexpr sal_uInt16 XML_NAMESPACE_OOOC
constexpr sal_uInt16 XML_NAMESPACE_STYLE_OOO
constexpr sal_uInt16 XML_NAMESPACE_XSD
constexpr sal_uInt16 XML_NAMESPACE_SVG
constexpr sal_uInt16 XML_NAMESPACE_TEXT_SO52
constexpr sal_uInt16 XML_NAMESPACE_META_SO52
constexpr sal_uInt16 XML_NAMESPACE_TEXT
constexpr sal_uInt16 XML_NAMESPACE_REPORT_OASIS
constexpr sal_uInt16 XML_NAMESPACE_FORM
constexpr sal_uInt16 XML_NAMESPACE_CHART_EXT
constexpr sal_uInt16 XML_NAMESPACE_DRAW_SO52
constexpr sal_uInt16 XML_NAMESPACE_NUMBER_OOO
constexpr sal_uInt16 XML_NAMESPACE_OFFICE_OOO
constexpr sal_uInt16 XML_NAMESPACE_FO_SO52
constexpr sal_uInt16 XML_NAMESPACE_XFORMS
constexpr sal_uInt16 XML_NAMESPACE_TABLE_SO52
constexpr sal_uInt16 XML_NAMESPACE_DR3D
constexpr sal_uInt16 XML_NAMESPACE_CHART
constexpr sal_uInt16 XML_NAMESPACE_XML
constexpr sal_uInt16 XML_NAMESPACE_NUMBER_SO52
constexpr sal_uInt16 XML_NAMESPACE_DR3D_OOO
constexpr sal_uInt16 XML_NAMESPACE_DOM
constexpr sal_uInt16 XML_NAMESPACE_DB_OASIS
constexpr sal_uInt16 XML_NAMESPACE_OF
constexpr sal_uInt16 XML_NAMESPACE_TABLE
constexpr sal_uInt16 XML_NAMESPACE_CALC_EXT
constexpr sal_uInt16 XML_NAMESPACE_TABLE_OOO
constexpr sal_uInt16 XML_NAMESPACE_CHART_SO52
constexpr sal_uInt16 XML_NAMESPACE_SVG_COMPAT
constexpr sal_uInt16 XML_NAMESPACE_OOOW
constexpr sal_uInt16 XML_NAMESPACE_CONFIG_OOO
constexpr sal_uInt16 XML_NAMESPACE_CSS3TEXT
constexpr sal_uInt16 XML_NAMESPACE_ANIMATION_OOO
constexpr sal_uInt16 XML_NAMESPACE_OFFICE_SO52
constexpr sal_uInt16 XML_NAMESPACE_FORMX
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
constexpr sal_uInt16 XML_NAMESPACE_CHART_OOO
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_OOO
constexpr sal_uInt16 XML_NAMESPACE_CONFIG
constexpr sal_uInt16 XML_NAMESPACE_STYLE_SO52
constexpr sal_uInt16 XML_NAMESPACE_OOO
constexpr sal_uInt16 XML_NAMESPACE_MATH
constexpr sal_uInt16 XML_NAMESPACE_XLINK_SO52
constexpr sal_uInt16 XML_NAMESPACE_GRDDL
constexpr sal_uInt16 XML_NAMESPACE_FO_COMPAT
constexpr sal_uInt16 XML_NAMESPACE_SMIL_SO52
constexpr sal_uInt16 XML_NAMESPACE_DRAW_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE
constexpr sal_uInt16 XML_NAMESPACE_META_OOO
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_SO52
constexpr sal_uInt16 XML_NAMESPACE_FO
constexpr sal_uInt16 XML_NAMESPACE_DRAW_OOO
constexpr sal_uInt16 XML_NAMESPACE_XSI
constexpr sal_uInt16 XML_NAMESPACE_NUMBER
constexpr OUStringLiteral XML_NUMBERSTYLES