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 if (
'3' == loVersion[0])
178 mnGeneratorVersion = SvXMLImport::LO_3x;
180 else if (
'4' == loVersion[0])
182 if (loVersion.getLength() > 1
183 && (loVersion[1] ==
'0' || loVersion[1] ==
'1'))
185 mnGeneratorVersion = SvXMLImport::LO_41x;
187 else if (loVersion.getLength() > 1 &&
'2' == loVersion[1])
189 mnGeneratorVersion = SvXMLImport::LO_42x;
191 else if (loVersion.getLength() > 1 &&
'3' == loVersion[1])
193 mnGeneratorVersion = SvXMLImport::LO_43x;
195 else if (loVersion.getLength() > 1 &&
'4' == loVersion[1])
197 mnGeneratorVersion = SvXMLImport::LO_44x;
200 else if (
'5' == loVersion[0])
202 mnGeneratorVersion = SvXMLImport::LO_5x;
204 else if (
'6' == loVersion[0])
206 if (loVersion.getLength() > 1
207 && (loVersion[1] ==
'0' || loVersion[1] ==
'1'
208 || loVersion[1] ==
'2'))
210 mnGeneratorVersion = SvXMLImport::LO_6x;
214 mnGeneratorVersion = SvXMLImport::LO_63x;
217 else if (
'7' == loVersion[0])
219 mnGeneratorVersion = SvXMLImport::LO_7x;
223 SAL_INFO(
"xmloff.core",
"unknown LO version: " << loVersion);
229 sal_Int32 nUPD, nBuild;
230 if ( !rImport.getBuildIds( nUPD, nBuild ) )
233 if ( nUPD >= 640 && nUPD <= 645 )
235 mnGeneratorVersion = SvXMLImport::OOo_1x;
237 else if ( nUPD == 680 )
239 mnGeneratorVersion = SvXMLImport::OOo_2x;
241 else if ( nUPD == 300 && nBuild <= 9379 )
243 mnGeneratorVersion = SvXMLImport::OOo_30x;
245 else if ( nUPD == 310 )
247 mnGeneratorVersion = SvXMLImport::OOo_31x;
249 else if ( nUPD == 320 )
251 mnGeneratorVersion = SvXMLImport::OOo_32x;
253 else if ( nUPD == 330 )
255 mnGeneratorVersion = SvXMLImport::OOo_33x;
257 else if ( nUPD == 340 )
259 mnGeneratorVersion = SvXMLImport::OOo_34x;
261 else if (nUPD == 400 || nUPD == 401)
263 mnGeneratorVersion = SvXMLImport::AOO_40x;
265 else if (nUPD >= 410)
269 mnGeneratorVersion = SvXMLImport::AOO_4x;
273 sal_uInt16 getGeneratorVersion()
const
275 return mnGeneratorVersion;
318 OUString theImplementationName,
319 const css::uno::Sequence< OUString > & sSupportedServiceNames = {})
352 const uno::Reference< xml::sax::XFastAttributeList >& )
355 SAL_WARN(
"xmloff.core",
"CreateFastContext should be overridden, for element " << nElement);
359void SvXMLImport::InitCtor_()
399 mxNamespaceMap->Add(
"_office_libo",
403 if (mxNumberFormatsSupplier.is())
404 mpNumImport = std::make_unique<SvXMLNumFmtHelper>(mxNumberFormatsSupplier, GetComponentContext());
406 if (
mxModel.is() && !mxEventListener.is())
408 mxEventListener.set(
new SvXMLImportEventListener(
this));
409 mxModel->addEventListener(mxEventListener);
413SvXMLImport::SvXMLImport(
414 const css::uno::Reference< css::uno::XComponentContext >& xContext,
415 OUString
const & implementationName,
417 const css::uno::Sequence< OUString > & sSupportedServiceNames )
425 mnImportFlags( nImportFlags ),
427 mbIsFormsSupported( true ),
428 mbIsTableShapeSupported( false ),
429 mbNotifyMacroEventRead( false )
431 SAL_WARN_IF( !xContext.is(),
"xmloff.core",
"got no service manager" );
433 mxParser = xml::sax::FastParser::create( xContext );
434 setNamespaceHandler( maNamespaceHandler );
435 setTokenHandler( xTokenHandler );
436 if ( !bIsNSMapsInitialized )
438 initializeNamespaceMaps();
439 bIsNSMapsInitialized =
true;
441 registerNamespaces();
445void SvXMLImport::cleanup() noexcept
447 if (mxEventListener.is() &&
mxModel.is())
448 mxModel->removeEventListener(mxEventListener);
451 while (!maContexts.empty())
454 pStylesContext->dispose();
458 mxTextImport->dispose();
459 mxTextImport.clear();
463SvXMLImport::~SvXMLImport() noexcept
468bool SvXMLImport::addEmbeddedFont(
const css::uno::Reference< css::io::XInputStream >& stream,
469 const OUString& fontName,
const char* extra,
470 std::vector<unsigned char>
const & key,
bool eot)
472 if (!mxEmbeddedFontHelper)
474 return mxEmbeddedFontHelper->addEmbeddedFont(stream, fontName, extra, key, eot);
479 class setFastDocumentHandlerGuard
482 css::uno::Reference<css::xml::sax::XFastParser> mxParser;
484 setFastDocumentHandlerGuard(css::uno::Reference<css::xml::sax::XFastParser> Parser,
485 const css::uno::Reference<css::xml::sax::XFastDocumentHandler>& Handler)
486 : mxParser(
std::move(Parser))
488 mxParser->setFastDocumentHandler(Handler);
491 ~setFastDocumentHandlerGuard()
493 mxParser->setFastDocumentHandler(
nullptr);
499void SAL_CALL SvXMLImport::parseStream(
const xml::sax::InputSource& aInputSource )
501 setFastDocumentHandlerGuard aDocumentHandlerGuard(mxParser, mxFastDocumentHandler.is() ? mxFastDocumentHandler :
this);
502 mxParser->parseStream(aInputSource);
505void SAL_CALL SvXMLImport::setFastDocumentHandler(
const uno::Reference< xml::sax::XFastDocumentHandler >& Handler )
507 mxFastDocumentHandler = Handler;
510void SAL_CALL SvXMLImport::setTokenHandler(
const uno::Reference< xml::sax::XFastTokenHandler >& Handler )
512 mxParser->setTokenHandler( Handler );
515void SAL_CALL SvXMLImport::registerNamespace(
const OUString& NamespaceURL, sal_Int32 NamespaceToken )
517 mxParser->registerNamespace( NamespaceURL, NamespaceToken );
520OUString SAL_CALL SvXMLImport::getNamespaceURL(
const OUString& rPrefix )
522 return mxParser->getNamespaceURL( rPrefix );
525void SAL_CALL SvXMLImport::setErrorHandler(
const uno::Reference< xml::sax::XErrorHandler >& Handler )
527 mxParser->setErrorHandler( Handler );
530void SAL_CALL SvXMLImport::setEntityResolver(
const uno::Reference< xml::sax::XEntityResolver >& Resolver )
532 mxParser->setEntityResolver( Resolver );
535void SAL_CALL SvXMLImport::setLocale(
const lang::Locale& rLocale )
537 mxParser->setLocale( rLocale );
540void SAL_CALL SvXMLImport::setNamespaceHandler(
const uno::Reference< xml::sax::XFastNamespaceHandler >& Handler)
542 mxParser->setNamespaceHandler( Handler );
545void SAL_CALL SvXMLImport::setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements )
547 mxParser->setCustomEntityNames( replacements );
550void SAL_CALL SvXMLImport::startDocument()
552 SAL_INFO(
"xmloff.core",
"{ SvXMLImport::startDocument" );
553 if (mxGraphicStorageHandler.is() && mxEmbeddedResolver.is())
556 Reference< lang::XMultiServiceFactory >
xFactory( mxModel, UNO_QUERY );
562 if (!mxGraphicStorageHandler.is())
565 mxGraphicStorageHandler.set(
566 xFactory->createInstance(
"com.sun.star.document.ImportGraphicStorageHandler"),
568 mpImpl->mbOwnGraphicResolver = mxGraphicStorageHandler.is();
571 if( !mxEmbeddedResolver.is() )
574 mxEmbeddedResolver.set(
575 xFactory->createInstance(
"com.sun.star.document.ImportEmbeddedObjectResolver"),
577 mpImpl->mbOwnEmbeddedResolver = mxEmbeddedResolver.is();
580 catch( css::uno::Exception& )
585void SAL_CALL SvXMLImport::endDocument()
587 SAL_INFO(
"xmloff.core",
"} SvXMLImport::endDocument" );
592 mxTextImport->MapCrossRefHeadingFieldsHorribly();
594 if (mpImpl->mpRDFaHelper)
596 const uno::Reference<rdf::XRepositorySupplier> xRS(mxModel,
600 mpImpl->mpRDFaHelper->InsertRDFa( xRS );
605 if (mxImportInfo.is())
607 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
608 if (xPropertySetInfo.is())
610 if (
bool(mpProgressBarHelper))
615 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
616 xPropertySetInfo->hasPropertyByName(sProgressCurrent))
618 sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
619 sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
620 mxImportInfo->setPropertyValue(sProgressMax,
uno::Any(nProgressMax));
621 mxImportInfo->setPropertyValue(sProgressCurrent,
uno::Any(nProgressCurrent));
623 if (xPropertySetInfo->hasPropertyByName(sRepeat))
624 mxImportInfo->setPropertyValue(sRepeat, css::uno::Any(mpProgressBarHelper->GetRepeat()));
628 if (mxNumberStyles.is() && xPropertySetInfo->hasPropertyByName(sNumberStyles))
630 mxImportInfo->setPropertyValue(sNumberStyles,
Any(mxNumberStyles));
635 if( mxFontDecls.is() )
636 mxFontDecls->dispose();
639 if( mxAutoStyles.is() )
640 mxAutoStyles->dispose();
641 if( mxMasterStyles.is() )
642 mxMasterStyles->dispose();
646 if ( mxFormImport.is() )
647 mxFormImport->documentDone();
651 mxShapeImport =
nullptr;
653 if( mpImpl->mbOwnGraphicResolver )
655 Reference<lang::XComponent> xComp(mxGraphicStorageHandler, UNO_QUERY);
659 if( mpImpl->mbOwnEmbeddedResolver )
661 Reference< lang::XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
666 if (
bool( mpXMLErrors ) )
672std::optional<SvXMLNamespaceMap> SvXMLImport::processNSAttributes(
673 std::optional<SvXMLNamespaceMap> & rpNamespaceMap,
674 SvXMLImport *
const pImport,
675 const uno::Reference< xml::sax::XAttributeList >& xAttrList)
677 std::optional<SvXMLNamespaceMap> pRewindMap;
678 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
679 for( sal_Int16 i=0;
i < nAttrCount;
i++ )
681 const OUString& rAttrName = xAttrList->getNameByIndex( i );
682 if (pImport && rAttrName ==
"office:version" && !pImport->mpImpl->mxODFVersion)
684 pImport->mpImpl->mxODFVersion = xAttrList->getValueByIndex( i );
687 if (pImport->mpImpl->mStreamName ==
"content.xml"
688 && !pImport->IsODFVersionConsistent(*pImport->mpImpl->mxODFVersion))
690 throw xml::sax::SAXException(
"Inconsistent ODF versions in content.xml and manifest.xml!",
691 uno::Reference< uno::XInterface >(),
693 packages::zip::ZipIOException(
"Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
696 else if( ( rAttrName.getLength() >= 5 ) &&
697 ( rAttrName.startsWith(
GetXMLToken(XML_XMLNS) ) ) &&
698 ( rAttrName.getLength() == 5 ||
':' == rAttrName[5] ) )
702 pRewindMap = std::move(rpNamespaceMap);
703 rpNamespaceMap.emplace(*pRewindMap);
705 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
707 OUString aPrefix( ( rAttrName.getLength() == 5 )
709 : rAttrName.copy( 6 ) );
711 sal_uInt16 nKey = rpNamespaceMap->AddIfKnown( aPrefix, rAttrValue );
716 OUString aTestName( rAttrValue );
718 nKey = rpNamespaceMap->AddIfKnown( aPrefix, aTestName );
722 rpNamespaceMap->Add( aPrefix, rAttrValue );
730void SAL_CALL SvXMLImport::characters(
const OUString& rChars )
732 maContexts.top()->characters( rChars );
735void SAL_CALL SvXMLImport::processingInstruction(
const OUString&,
740void SAL_CALL SvXMLImport::setDocumentLocator(
const uno::Reference< xml::sax::XLocator >& rLocator )
742 mxLocator = rLocator;
746void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
747 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
749 SAL_INFO(
"xmloff.core",
"startFastElement " << SvXMLImport::getNameFromToken( Element ));
750 if ( Attribs.is() && !mpImpl->mxODFVersion)
755 if( aIter != rAttribList.
end() )
757 mpImpl->mxODFVersion = aIter.toString();
760 if ( mpImpl->mStreamName ==
"content.xml" && !IsODFVersionConsistent( *mpImpl->mxODFVersion ) )
762 throw xml::sax::SAXException(
"Inconsistent ODF versions in content.xml and manifest.xml!",
763 uno::Reference< uno::XInterface >(),
765 packages::zip::ZipIOException(
"Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
770 maNamespaceAttrList->Clear();
772 maNamespaceHandler->addNSDeclAttributes( maNamespaceAttrList );
773 std::optional<SvXMLNamespaceMap> pRewindMap = processNSAttributes(mxNamespaceMap,
this, maNamespaceAttrList);
776 const bool bRootContext = maContexts.empty();
777 if (!maContexts.empty())
780 SAL_INFO(
"xmloff.core",
"calling createFastChildContext on " <<
typeid(*pHandler.get()).name());
781 auto tmp = pHandler->createFastChildContext( Element, Attribs );
783 assert((tmp && xContext) || (!tmp && !xContext));
786 xContext.set( CreateFastContext( Element, Attribs ) );
788 SAL_INFO_IF(!xContext.is(),
"xmloff.core",
"No fast context for element " << getNameFromToken(Element));
789 if (bRootContext && !xContext)
791 OUString
aName = getNameFromToken(Element);
793 {
aName },
"Root element " +
aName +
" unknown", Reference<xml::sax::XLocator>() );
800 xContext->PutRewindMap(std::move(pRewindMap));
803 xContext->startFastElement( Element, Attribs );
806 maContexts.push(xContext);
809void SAL_CALL SvXMLImport::startUnknownElement (
const OUString & rNamespace,
const OUString & rName,
810 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
812 SAL_INFO(
"xmloff.core",
"startUnknownElement " << rNamespace <<
" " << rName);
814 const bool bRootContext = maContexts.empty();
815 if (!maContexts.empty())
818 SAL_INFO(
"xmloff.core",
"calling createUnknownChildContext on " <<
typeid(*pHandler.get()).name());
819 auto tmp = pHandler->createUnknownChildContext( rNamespace, rName, Attribs );
821 assert((tmp && xContext) || (!tmp && !xContext));
824 xContext.set( CreateFastContext( -1, Attribs ) );
826 SAL_WARN_IF(!xContext.is(),
"xmloff.core",
"No context for unknown-element " << rNamespace <<
" " << rName);
827 if (bRootContext && !xContext)
830 { rName },
"Root element " + rName +
" unknown", Reference<xml::sax::XLocator>() );
834 if (!maContexts.empty())
837 xContext = maContexts.top();
842 xContext->startUnknownElement( rNamespace, rName, Attribs );
843 maContexts.push(xContext);
846void SAL_CALL SvXMLImport::endFastElement (sal_Int32 Element)
848 SAL_INFO(
"xmloff.core",
"endFastElement " << SvXMLImport::getNameFromToken( Element ));
849 if (maContexts.empty())
851 SAL_WARN(
"xmloff.core",
"SvXMLImport::endFastElement: no context left");
857 std::optional<SvXMLNamespaceMap> pRewindMap = xContext->TakeRewindMap();
859 xContext->endFastElement( Element );
862 mxNamespaceMap = std::move(pRewindMap);
865void SAL_CALL SvXMLImport::endUnknownElement (
const OUString & rPrefix,
const OUString & rLocalName)
867 SAL_INFO(
"xmloff.core",
"endUnknownElement " << rPrefix <<
" " << rLocalName);
868 if (maContexts.empty())
870 SAL_WARN(
"xmloff.core",
"SvXMLImport::endUnknownElement: no context left");
876 xContext->endUnknownElement( rPrefix, rLocalName );
879uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
880 SvXMLImport::createFastChildContext (sal_Int32,
881 const uno::Reference< xml::sax::XFastAttributeList > &)
886uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
887 SvXMLImport::createUnknownChildContext (
const OUString &,
const OUString &,
888 const uno::Reference< xml::sax::XFastAttributeList > &)
893void SvXMLImport::SetStatistics(
const uno::Sequence< beans::NamedValue> &)
895 GetProgressBarHelper()->SetRepeat(
false);
896 GetProgressBarHelper()->SetReference(0);
900void SAL_CALL SvXMLImport::setTargetDocument(
const uno::Reference< lang::XComponent >& xDoc )
902 mxModel.set( xDoc, UNO_QUERY );
904 throw lang::IllegalArgumentException();
908 uno::Reference<document::XStorageBasedDocument>
const xSBDoc(mxModel, uno::UNO_QUERY);
909 uno::Reference<embed::XStorage>
const xStor(xSBDoc.is() ? xSBDoc->getDocumentStorage()
918 catch (uno::Exception
const&)
922 if (!mxEventListener.is())
924 mxEventListener.set(
new SvXMLImportEventListener(
this));
925 mxModel->addEventListener(mxEventListener);
928 SAL_WARN_IF(
bool(mpNumImport),
"xmloff.core",
"number format import already exists." );
933sal_Bool SAL_CALL SvXMLImport::filter(
const uno::Sequence< beans::PropertyValue >& )
938void SAL_CALL SvXMLImport::cancel( )
943void SAL_CALL SvXMLImport::initialize(
const uno::Sequence< uno::Any >& aArguments )
945 for(
const auto& rAny : aArguments )
947 Reference<XInterface> xValue;
950 uno::Reference<task::XStatusIndicator> xTmpStatusIndicator(
952 if( xTmpStatusIndicator.is() )
955 uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(xValue, UNO_QUERY);
956 if (xGraphicStorageHandler.is())
957 mxGraphicStorageHandler = xGraphicStorageHandler;
959 uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
961 if( xTmpObjectResolver.is() )
962 mxEmbeddedResolver = xTmpObjectResolver;
964 uno::Reference<beans::XPropertySet> xTmpPropSet( xValue, UNO_QUERY );
965 if( xTmpPropSet.is() )
967 mxImportInfo = xTmpPropSet;
968 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
969 if (xPropertySetInfo.is())
972 if (xPropertySetInfo->hasPropertyByName(sPropName))
974 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
975 aAny >>= mxNumberStyles;
978 sPropName =
"PrivateData";
979 if (xPropertySetInfo->hasPropertyByName(sPropName))
981 Reference < XInterface > xIfc;
982 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
992 sPropName =
"BaseURI";
993 if (xPropertySetInfo->hasPropertyByName(sPropName))
995 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
997 mpImpl->aBaseURL.SetURL( sBaseURI );
998 mpImpl->aDocBase.SetURL( sBaseURI );
1001 sPropName =
"StreamRelPath";
1002 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1004 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1008 sPropName =
"StreamName";
1009 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1011 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1014 if( !sBaseURI.isEmpty() && !
sName.isEmpty() )
1016 if( !sRelPath.isEmpty() )
1017 mpImpl->aBaseURL.insertName( sRelPath );
1018 mpImpl->aBaseURL.insertName( sName );
1020 mpImpl->mStreamName =
sName;
1022 sPropName =
"ShapePositionInHoriL2R";
1023 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1025 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1026 aAny >>= mpImpl->mbShapePositionInHoriL2R;
1028 sPropName =
"TextDocInOOoFileFormat";
1029 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1031 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1032 aAny >>= mpImpl->mbTextDocInOOoFileFormat;
1035 sPropName =
"SourceStorage";
1036 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1037 mxImportInfo->getPropertyValue(sPropName) >>= mpImpl->mxSourceStorage;
1042 uno::Reference<lang::XInitialization>
const xInit(mxParser, uno::UNO_QUERY_THROW);
1043 xInit->initialize( {
Any(OUString(
"IgnoreMissingNSDecl")) });
1047OUString SAL_CALL SvXMLImport::getImplementationName()
1049 return mpImpl->implementationName;
1052sal_Bool SAL_CALL SvXMLImport::supportsService(
const OUString& rServiceName )
1057uno::Sequence< OUString > SAL_CALL SvXMLImport::getSupportedServiceNames( )
1059 return mpImpl->maSupportedServiceNames;
1079#if !ENABLE_WASM_STRIP_CHART
1088 return new ::xmloff::OFormLayerXMLImport(*
this);
1095const Reference< container::XNameContainer > & SvXMLImport::GetGradientHelper()
1097 if( !mxGradientHelper.is() )
1101 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1102 if( xServiceFact.is() )
1106 mxGradientHelper.set( xServiceFact->createInstance(
1107 "com.sun.star.drawing.GradientTable" ), UNO_QUERY);
1109 catch( lang::ServiceNotRegisteredException& )
1115 return mxGradientHelper;
1118const Reference< container::XNameContainer > & SvXMLImport::GetHatchHelper()
1120 if( !mxHatchHelper.is() )
1124 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1125 if( xServiceFact.is() )
1129 mxHatchHelper.set( xServiceFact->createInstance(
1130 "com.sun.star.drawing.HatchTable" ), UNO_QUERY);
1132 catch( lang::ServiceNotRegisteredException& )
1138 return mxHatchHelper;
1141const Reference< container::XNameContainer > & SvXMLImport::GetBitmapHelper()
1143 if( !mxBitmapHelper.is() )
1147 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1148 if( xServiceFact.is() )
1152 mxBitmapHelper.set( xServiceFact->createInstance(
1153 "com.sun.star.drawing.BitmapTable" ), UNO_QUERY);
1155 catch( lang::ServiceNotRegisteredException& )
1161 return mxBitmapHelper;
1164const Reference< container::XNameContainer > & SvXMLImport::GetTransGradientHelper()
1166 if( !mxTransGradientHelper.is() )
1170 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1171 if( xServiceFact.is() )
1175 mxTransGradientHelper.set( xServiceFact->createInstance(
1176 "com.sun.star.drawing.TransparencyGradientTable" ), UNO_QUERY);
1178 catch( lang::ServiceNotRegisteredException& )
1184 return mxTransGradientHelper;
1187const Reference< container::XNameContainer > & SvXMLImport::GetMarkerHelper()
1189 if( !mxMarkerHelper.is() )
1193 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1194 if( xServiceFact.is() )
1198 mxMarkerHelper.set( xServiceFact->createInstance(
"com.sun.star.drawing.MarkerTable" ), UNO_QUERY);
1200 catch( lang::ServiceNotRegisteredException& )
1206 return mxMarkerHelper;
1209const Reference< container::XNameContainer > & SvXMLImport::GetDashHelper()
1211 if( !mxDashHelper.is() &&
mxModel.is() )
1213 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1214 if( xServiceFact.is() )
1218 mxDashHelper.set( xServiceFact->createInstance(
"com.sun.star.drawing.DashTable" ), UNO_QUERY);
1220 catch( lang::ServiceNotRegisteredException& )
1225 return mxDashHelper;
1228bool SvXMLImport::IsPackageURL( std::u16string_view rURL )
const
1233 if( (mnImportFlags & nTest) == nTest )
1239 size_t nLen = rURL.size();
1240 if( nLen > 0 &&
'/' == rURL[0] )
1243 else if( nLen > 1 &&
'.' == rURL[0] )
1245 if(
'.' == rURL[1] )
1249 else if(
'/' == rURL[1] )
1256 while( nPos < nLen )
1258 switch( rURL[nPos] )
1276uno::Reference<graphic::XGraphic> SvXMLImport::loadGraphicByURL(OUString
const & rURL)
1278 uno::Reference<graphic::XGraphic> xGraphic;
1280 if (mxGraphicStorageHandler.is())
1282 if (IsPackageURL(rURL))
1284 xGraphic = mxGraphicStorageHandler->loadGraphic(rURL);
1288 OUString
const & rAbsoluteURL = GetAbsoluteReference(rURL);
1290 Graphic aGraphic(aExternalLink);
1291 xGraphic = aGraphic.GetXGraphic();
1298uno::Reference<graphic::XGraphic> SvXMLImport::loadGraphicFromBase64(uno::Reference<io::XOutputStream>
const & rxOutputStream)
1300 uno::Reference<graphic::XGraphic> xGraphic;
1302 if (mxGraphicStorageHandler.is())
1304 xGraphic = mxGraphicStorageHandler->loadGraphicFromOutputStream(rxOutputStream);
1310Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64()
const
1312 Reference< XOutputStream > xOStm;
1313 Reference< document::XBinaryStreamResolver > xStmResolver(mxGraphicStorageHandler, UNO_QUERY);
1315 if( xStmResolver.is() )
1316 xOStm = xStmResolver->createOutputStream();
1321OUString SvXMLImport::ResolveEmbeddedObjectURL(
1322 const OUString& rURL,
1323 std::u16string_view rClassId )
1327 if( IsPackageURL( rURL ) )
1329 if ( mxEmbeddedResolver.is() )
1331 OUString sURL( rURL );
1332 if( !rClassId.empty() )
1334 sURL += OUString::Concat(
"!") + rClassId;
1336 sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( sURL );
1340 sRet = GetAbsoluteReference( rURL );
1345Reference< embed::XStorage >
const & SvXMLImport::GetSourceStorage()
const
1347 return mpImpl->mxSourceStorage;
1350Reference < XOutputStream >
1351 SvXMLImport::GetStreamForEmbeddedObjectURLFromBase64()
const
1353 Reference < XOutputStream > xOLEStream;
1355 if( mxEmbeddedResolver.is() )
1357 Reference< XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
1360 Any aAny = xNA->getByName(
"Obj12345678" );
1361 aAny >>= xOLEStream;
1368OUString SvXMLImport::ResolveEmbeddedObjectURLFromBase64()
1372 if( mxEmbeddedResolver.is() )
1374 sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL(
"Obj12345678" );
1381 const OUString& rName,
1382 const OUString& rDisplayName )
1384 if( !mpStyleMap.is() )
1387 if( mxImportInfo.is() )
1389 OUString sPrivateData(
"PrivateData" );
1390 Reference< beans::XPropertySetInfo > xPropertySetInfo =
1391 mxImportInfo->getPropertySetInfo();
1392 if( xPropertySetInfo.is() &&
1393 xPropertySetInfo->hasPropertyByName(sPrivateData) )
1395 Reference < XInterface > xIfc(
1396 static_cast< css::lang::XTypeProvider *
>( mpStyleMap.get() ) );
1397 mxImportInfo->setPropertyValue( sPrivateData,
Any(xIfc) );
1402 StyleMap::key_type aKey( nFamily, rName );
1403 StyleMap::value_type aValue( aKey, rDisplayName );
1404 ::std::pair<StyleMap::iterator,bool> aRes( mpStyleMap->insert( aValue ) );
1407 "duplicate style name of family " <<
static_cast<int>(nFamily) <<
": \"" << rName <<
"\"");
1411OUString SvXMLImport::GetStyleDisplayName(
XmlStyleFamily nFamily,
1412 const OUString& rName )
const
1414 OUString
sName( rName );
1415 if( mpStyleMap.is() && !rName.isEmpty() )
1417 StyleMap::key_type aKey( nFamily, rName );
1418 StyleMap::const_iterator aIter = mpStyleMap->find( aKey );
1419 if( aIter != mpStyleMap->end() )
1420 sName = (*aIter).second;
1425void SvXMLImport::SetViewSettings(
const css::uno::Sequence<css::beans::PropertyValue>&)
1429void SvXMLImport::SetConfigurationSettings(
const css::uno::Sequence<css::beans::PropertyValue>&)
1433void SvXMLImport::SetDocumentSpecificSettings(
const OUString&,
const uno::Sequence<beans::PropertyValue>&)
1439 if (!mpProgressBarHelper)
1441 mpProgressBarHelper = std::make_unique<ProgressBarHelper>(mxStatusIndicator,
false);
1443 if (mxImportInfo.is())
1445 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
1446 if (xPropertySetInfo.is())
1452 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1453 xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1454 xPropertySetInfo->hasPropertyByName(sProgressRange))
1457 sal_Int32 nProgressMax(0);
1458 sal_Int32 nProgressCurrent(0);
1459 sal_Int32 nProgressRange(0);
1460 aAny = mxImportInfo->getPropertyValue(sProgressRange);
1461 if (aAny >>= nProgressRange)
1462 mpProgressBarHelper->SetRange(nProgressRange);
1463 aAny = mxImportInfo->getPropertyValue(sProgressMax);
1464 if (aAny >>= nProgressMax)
1465 mpProgressBarHelper->SetReference(nProgressMax);
1466 aAny = mxImportInfo->getPropertyValue(sProgressCurrent);
1467 if (aAny >>= nProgressCurrent)
1468 mpProgressBarHelper->SetValue(nProgressCurrent);
1470 if (xPropertySetInfo->hasPropertyByName(sRepeat))
1472 uno::Any aAny = mxImportInfo->getPropertyValue(sRepeat);
1474 mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1476 SAL_WARN(
"xmloff.core",
"why is it no boolean?" );
1482 return mpProgressBarHelper.get();
1485void SvXMLImport::AddNumberStyle(sal_Int32 nKey,
const OUString& rName)
1487 if (!mxNumberStyles.is())
1489 if (mxNumberStyles.is())
1493 mxNumberStyles->insertByName(rName,
Any(nKey));
1495 catch ( uno::Exception& )
1501 SAL_WARN(
"xmloff.core",
"not possible to create NameContainer");
1507 if (!mpEventImportHelper)
1511 mpEventImportHelper = std::make_unique<XMLEventImportHelper>();
1513 mpEventImportHelper->RegisterFactory(sStarBasic,
1514 std::make_unique<XMLStarBasicContextFactory>());
1516 mpEventImportHelper->RegisterFactory(sScript,
1517 std::make_unique<XMLScriptContextFactory>());
1521 mpEventImportHelper->RegisterFactory(
"StarBasic",
1522 std::make_unique<XMLStarBasicContextFactory>());
1525 return *mpEventImportHelper;
1530 if (mxFontDecls.is())
1531 mxFontDecls->dispose();
1532 mxFontDecls = pFontDecls;
1544 if (pAutoStyles && mxNumberStyles.is())
1547 const uno::Sequence<OUString> aStyleNames = mxNumberStyles->getElementNames();
1548 for (
const auto& name : aStyleNames)
1550 uno::Any aAny(mxNumberStyles->getByName(name));
1555 *
this, name, xAttrList, nKey,
1556 GetDataStylesImport()->GetLanguageForKey(nKey), *pAutoStyles);
1561 if (mxAutoStyles.is())
1562 mxAutoStyles->dispose();
1563 mxAutoStyles = pAutoStyles;
1564 GetTextImport()->SetAutoStyles( pAutoStyles );
1565 GetShapeImport()->SetAutoStylesContext( pAutoStyles );
1566#if !ENABLE_WASM_STRIP_CHART
1567 GetChartImport()->SetAutoStylesContext( pAutoStyles );
1569 GetFormImport()->setAutoStyleContext( pAutoStyles );
1574 if (mxMasterStyles.is())
1576 mxMasterStyles = pMasterStyles;
1581 return mxFontDecls.get();
1586 return mxStyles.get();
1591 return mxAutoStyles.get();
1596 return mxFontDecls.get();
1601 return mxStyles.get();
1606 return mxAutoStyles.get();
1609OUString SvXMLImport::GetAbsoluteReference(
const OUString& rValue)
const
1611 if( rValue.isEmpty() || rValue[0] ==
'#' )
1615 if( mpImpl->aBaseURL.GetNewAbsURL( rValue, &aAbsURL ) )
1621bool SvXMLImport::IsODFVersionConsistent(
const OUString& aODFVersion )
1624 bool bResult =
true;
1626 if ( !aODFVersion.isEmpty() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
1632 uno::Reference<embed::XStorage>
const xStor(GetSourceStorage());
1635 uno::Reference< beans::XPropertySet > xStorProps( xStor, uno::UNO_QUERY_THROW );
1640 bool bRepairPackage =
false;
1643 xStorProps->getPropertyValue(
"RepairPackage" )
1645 }
catch ( uno::Exception& )
1649 if ( !bRepairPackage )
1651 OUString aStorVersion;
1652 xStorProps->getPropertyValue(
"Version" )
1659 if ( !aStorVersion.isEmpty() )
1660 bResult = aODFVersion == aStorVersion;
1662 xStorProps->setPropertyValue(
"Version",
1667 bool bInconsistent =
false;
1668 xStorProps->getPropertyValue(
"IsInconsistent" )
1670 bResult = !bInconsistent;
1675 catch( uno::Exception& )
1682void SvXMLImport::CreateNumberFormatsSupplier_()
1684 SAL_WARN_IF( mxNumberFormatsSupplier.is(),
"xmloff.core",
"number formats supplier already exists!" );
1686 mxNumberFormatsSupplier =
1687 uno::Reference< util::XNumberFormatsSupplier> (mxModel, uno::UNO_QUERY);
1690void SvXMLImport::CreateDataStylesImport_()
1692 SAL_WARN_IF(
bool(mpNumImport),
"xmloff.core",
"data styles import already exists!" );
1693 uno::Reference<util::XNumberFormatsSupplier> xNum =
1694 GetNumberFormatsSupplier();
1696 mpNumImport = std::make_unique<SvXMLNumFmtHelper>(xNum, GetComponentContext() );
1702 if( !mpImpl->hBatsFontConv )
1705 FontToSubsFontFlags::IMPORT );
1706 SAL_WARN_IF( !mpImpl->hBatsFontConv,
"xmloff.core",
"Got no symbol font converter" );
1708 if( mpImpl->hBatsFontConv )
1719 if( !mpImpl->hMathFontConv )
1722 FontToSubsFontFlags::IMPORT );
1723 SAL_WARN_IF( !mpImpl->hMathFontConv,
"xmloff.core",
"Got no symbol font converter" );
1725 if( mpImpl->hMathFontConv )
1733void SvXMLImport::SetError(
1735 const Sequence<OUString>& rMsgParams,
1736 const OUString& rExceptionMessage,
1737 const Reference<xml::sax::XLocator>& rLocator )
1741 mpXMLErrors = std::make_unique<XMLErrors>();
1745 mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage,
1746 rLocator.is() ? rLocator : mxLocator );
1749void SvXMLImport::SetError(
1751 const Sequence<OUString>& rMsgParams)
1753 SetError( nId, rMsgParams,
"",
nullptr );
1756void SvXMLImport::SetError(
1758 const OUString& rMsg1)
1760 Sequence<OUString>
aSeq { rMsg1 };
1764void SvXMLImport::DisposingModel()
1766 if( mxFontDecls.is() )
1767 mxFontDecls->dispose();
1769 mxStyles->dispose();
1770 if( mxAutoStyles.is() )
1771 mxAutoStyles->dispose();
1772 if( mxMasterStyles.is() )
1773 mxMasterStyles->dispose();
1776 mxEventListener.set(
nullptr);
1781 return mpImpl->maInterfaceToIdentifierMapper;
1784uno::Reference< uno::XComponentContext >
const &
1785SvXMLImport::GetComponentContext()
const
1787 return mpImpl->mxComponentContext;
1790OUString SvXMLImport::GetBaseURL()
const
1795OUString SvXMLImport::GetDocumentBase()
const
1801bool SvXMLImport::IsShapePositionInHoriL2R()
const
1803 return mpImpl->mbShapePositionInHoriL2R;
1806bool SvXMLImport::IsTextDocInOOoFileFormat()
const
1808 return mpImpl->mbTextDocInOOoFileFormat;
1811void SvXMLImport::initXForms()
1816bool SvXMLImport::getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild )
const
1819 OUString
const aBuildId(getBuildIdsProperty(mxImportInfo));
1820 if (!aBuildId.isEmpty())
1822 sal_Int32
nIndex = aBuildId.indexOf(
'$');
1826 sal_Int32 nIndexEnd = aBuildId.indexOf(
';', nIndex);
1827 rBuild = (nIndexEnd == -1)
1829 :
o3tl::toInt32(aBuildId.subView(nIndex + 1, nIndexEnd - nIndex - 1));
1836sal_uInt16 SvXMLImport::getGeneratorVersion()
const
1839 return mpImpl->getGeneratorVersion( *
this );
1843bool SvXMLImport::isGeneratorVersionOlderThan(
1844 sal_uInt16
const nOOoVersion, sal_uInt16
const nLOVersion)
1846 assert( (nLOVersion & LO_flag));
1847 assert(!(nOOoVersion & LO_flag));
1848 const sal_uInt16 nGeneratorVersion(getGeneratorVersion());
1849 return (nGeneratorVersion & LO_flag)
1850 ? nGeneratorVersion < nLOVersion
1851 : nGeneratorVersion < nOOoVersion;
1855OUString SvXMLImport::GetODFVersion()
const
1857 return mpImpl->mxODFVersion ? *mpImpl->mxODFVersion : OUString();
1860bool SvXMLImport::IsOOoXML()
const
1862 return mpImpl->mbIsOOoXML;
1865bool SvXMLImport::IsMSO()
const
1867 if (!mpImpl->mbIsMSO.has_value())
1869 uno::Reference<document::XDocumentPropertiesSupplier> xSupplier(GetModel(), uno::UNO_QUERY);
1872 uno::Reference<document::XDocumentProperties> xProps
1873 = xSupplier->getDocumentProperties();
1876 mpImpl->mbIsMSO = xProps->getGenerator().startsWith(
"MicrosoftOffice");
1881 return mpImpl->mbIsMSO.has_value() ? *mpImpl->mbIsMSO :
false;
1885void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface>
const & i_xIfc,
1886 OUString
const & i_rXmlId)
1888 if (i_rXmlId.isEmpty())
1892 const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
1896 const beans::StringPair mdref( mpImpl->mStreamName, i_rXmlId );
1898 xMeta->setMetadataReference(mdref);
1899 }
catch (lang::IllegalArgumentException &) {
1901 SAL_INFO(
"xmloff.core",
"SvXMLImport::SetXmlId: cannot set xml:id");
1904 }
catch (uno::Exception &) {
1910SvXMLImport::GetRDFaImportHelper()
1912 if (!mpImpl->mpRDFaHelper)
1914 mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*
this) );
1916 return *mpImpl->mpRDFaHelper;
1920SvXMLImport::AddRDFa(
const uno::Reference<rdf::XMetadatable>& i_xObject,
1921 OUString
const & i_rAbout,
1922 OUString
const & i_rProperty,
1923 OUString
const & i_rContent,
1924 OUString
const & i_rDatatype)
1929 rRDFaHelper.ParseAndAddRDFa(i_xObject,
1930 i_rAbout, i_rProperty, i_rContent, i_rDatatype);
1933bool SvXMLImport::embeddedFontAlreadyProcessed(
const OUString& url )
1935 if( embeddedFontUrlsKnown.count( url ) != 0 )
1937 embeddedFontUrlsKnown.insert( url );
1941const OUString & SvXMLImport::getNameFromToken( sal_Int32 nToken )
1943 return xTokenHandler->getIdentifier( nToken &
TOKEN_MASK );
1946OUString SvXMLImport::getPrefixAndNameFromToken( sal_Int32 nToken )
1950 auto aIter( aNamespaceMap.find( nNamespaceToken ) );
1951 if( aIter != aNamespaceMap.end() )
1952 rv = (*aIter).second.second +
" " + aIter->second.first +
":";
1953 return rv + xTokenHandler->getIdentifier( nToken &
TOKEN_MASK );
1956OUString SvXMLImport::getNamespacePrefixFromToken(sal_Int32 nToken,
const SvXMLNamespaceMap* pMap)
1959 auto aIter( aNamespaceMap.find( nNamespaceToken ) );
1960 if( aIter != aNamespaceMap.end() )
1965 if (!sRet.isEmpty())
1968 return (*aIter).second.first;
1974OUString SvXMLImport::getNamespaceURIFromToken( sal_Int32 nToken )
1977 auto aIter( aNamespaceMap.find( nNamespaceToken ) );
1978 if( aIter != aNamespaceMap.end() )
1979 return (*aIter).second.second;
1984OUString SvXMLImport::getNamespacePrefixFromURI(
const OUString& rURI )
1986 auto aIter( aNamespaceURIPrefixMap.find(rURI) );
1987 if( aIter != aNamespaceURIPrefixMap.end() )
1988 return (*aIter).second;
1993sal_Int32 SvXMLImport::getTokenFromName( std::u16string_view rName )
1997 return xTokenHandler->getTokenFromUTF8( aLocalNameSeq );
2000void SvXMLImport::initializeNamespaceMaps()
2002 auto mapTokenToNamespace = []( sal_Int32
nToken, sal_Int32 nPrefix, sal_Int32
nNamespace )
2008 assert( aNamespaceMap.find(nToken +1) == aNamespaceMap.end() &&
"cannot map two namespaces to the same token here");
2009 aNamespaceMap[
nToken + 1 ] = std::make_pair(
sPrefix, sNamespace );
2010 aNamespaceURIPrefixMap.emplace( sNamespace,
sPrefix );
2093void SvXMLImport::registerNamespaces()
2095 for(
auto const &aNamespaceEntry : aNamespaceMap )
2098 registerNamespace( aNamespaceEntry.second.second, aNamespaceEntry.first <<
NMSP_SHIFT );
2102void SvXMLImport::NotifyMacroEventRead()
2104 if (mbNotifyMacroEventRead)
2109 mbNotifyMacroEventRead =
true;
2120 const OUString& rPrefix = aNamespaceDefine.m_aPrefix;
2121 const OUString& rNamespaceURI = aNamespaceDefine.m_aNamespaceURI;
2123 if ( rPrefix.isEmpty() )
2126 sDecl =
"xmlns:" + rPrefix;
2127 rAttrList->AddAttribute( sDecl, rNamespaceURI );
2136 if ( rNamespacePrefix.isEmpty() )
2138 SvXMLImport::getNamespacePrefixFromURI( rNamespaceURI ), rNamespaceURI) );
2141 rNamespacePrefix, rNamespaceURI) );
2150: mrImport(
std::move( xImport )),
2151 mxFastAttributes( new
sax_fastparser::FastAttributeList( SvXMLImport::xTokenHandler.
get() ) )
2157 mrImport->setTargetDocument( xDoc );
2171 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
2176 SvXMLImport::processNSAttributes(
mrImport->mxNamespaceMap,
mrImport.get(), xAttrList);
2177 OUString aLocalName;
2178 sal_uInt16 nPrefix =
mrImport->mxNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
2179 sal_Int32 mnElement =
NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::getTokenFromName( aLocalName );
2182 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
2183 for( sal_Int16
i=0;
i < nAttrCount;
i++ )
2185 const OUString& rAttrName = xAttrList->getNameByIndex(
i );
2186 const OUString& rAttrValue = xAttrList->getValueByIndex(
i );
2187 if (rAttrName ==
"xmlns")
2189 sal_uInt16 nNamespaceKey =
mrImport->mxNamespaceMap->GetKeyByName(rAttrValue);
2192 nDefaultNamespace = nNamespaceKey;
2195 assert(
false &&
"unknown namespace");
2199 auto const nToken = SvXMLImport::getTokenFromName(rAttrName);
2214 OUString aLocalAttrName;
2215 OUString aNamespace;
2217 sal_uInt16
const nAttrPrefix =
mrImport->mxNamespaceMap->GetKeyByQName(
2221 auto const nToken = SvXMLImport::getTokenFromName(aLocalAttrName);
2240 OUString aLocalName;
2241 sal_uInt16 nPrefix =
mrImport->mxNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
2242 sal_Int32 mnElement =
NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::getTokenFromName(aLocalName);
2243 mrImport->endFastElement( mnElement );
2257 const OUString& aData)
2264 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
const uno::Reference< uno::XComponentContext > mxComponentContext
std::optional< bool > mbIsMSO
bool mbTextDocInOOoFileFormat
uno::Reference< embed::XStorage > mxSourceStorage
FontToSubsFontConverter hBatsFontConv
bool mbOwnGraphicResolver
std::unique_ptr< DocumentInfo > mpDocumentInfo
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