26#include <com/sun/star/document/XImporter.hpp>
27#include <com/sun/star/uno/XComponentContext.hpp>
28#include <com/sun/star/util/XModifiable2.hpp>
50 css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastHandler;
54 XMLEmbeddedObjectImportContext_Impl( SvXMLImport& rImport,
55 const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& rHandler );
59 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
63 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
67 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
72XMLEmbeddedObjectImportContext_Impl::XMLEmbeddedObjectImportContext_Impl(
74 const Reference< XFastDocumentHandler >& rHandler ) :
76 mxFastHandler( rHandler )
78 assert(mxFastHandler);
81css::uno::Reference< css::xml::sax::XFastContextHandler > XMLEmbeddedObjectImportContext_Impl::createFastChildContext(
83 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
85 return new XMLEmbeddedObjectImportContext_Impl(GetImport(), mxFastHandler);
88void XMLEmbeddedObjectImportContext_Impl::startFastElement(
90 const Reference< XFastAttributeList >& xAttrList )
92 mxFastHandler->startFastElement( nElement, xAttrList );
95void XMLEmbeddedObjectImportContext_Impl::endFastElement(sal_Int32 nElement)
97 mxFastHandler->endFastElement( nElement );
100void XMLEmbeddedObjectImportContext_Impl::characters(
const OUString& rChars )
102 mxFastHandler->characters( rChars );
111 Sequence<Any> aArgs( 0 );
113 Reference< XComponentContext > xContext(
GetImport().GetComponentContext() );
115 Reference<XInterface> xFilter =
116 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
sFilterService, aArgs, xContext);
127 Reference < XModifiable2 > xModifiable2( rComp, UNO_QUERY_THROW );
128 xModifiable2->disableSetModified();
134 Reference < XImporter > xImporter(
mxFastHandler, UNO_QUERY );
135 xImporter->setTargetDocument( rComp );
142 pFastHandler->GetNamespaceMap() =
GetImport().GetNamespaceMap();
146 SvXMLImport& rImport, sal_Int32 nElement,
147 const Reference< XFastAttributeList >& xAttrList ) :
163 switch (aIter.getToken())
166 sMime = aIter.toString();
173 std::u16string_view sClass;
174 static std::u16string_view
const prefixes[] = {
175 u"application/vnd.oasis.openoffice.",
176 u"application/x-vnd.oasis.openoffice.",
177 u"application/vnd.oasis.opendocument.",
178 u"application/x-vnd.oasis.opendocument."};
179 for (
auto const &
p: prefixes)
187 if( !sClass.empty() )
189 static const std::tuple<XMLTokenEnum, OUString, SvGUID>
aServiceMap[] = {
198 for (
auto const& [eClass, sMatchingFilterService, rCLASSID] :
aServiceMap)
219 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
228 const Reference< XFastAttributeList >& rAttrList )
247 Reference < XModifiable2 > xModifiable2(
xComp, UNO_QUERY_THROW );
248 xModifiable2->enableSetModified();
249 xModifiable2->setModified(
true );
constexpr OUStringLiteral XML_IMPORT_FILTER_CALC
constexpr OUStringLiteral XML_IMPORT_FILTER_DRAW
constexpr OUStringLiteral XML_IMPORT_FILTER_WRITER
constexpr OUStringLiteral XML_IMPORT_FILTER_CHART
constexpr OUStringLiteral XML_IMPORT_FILTER_IMPRESS
constexpr OUStringLiteral XML_IMPORT_FILTER_MATH
This class deliberately does not support XWeak, to improve performance when loading large documents.
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
SvXMLImport & GetImport()
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
virtual void SAL_CALL characters(const OUString &aChars) override
This method is called for all characters that are contained in the current element.
virtual void SAL_CALL characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
XMLEmbeddedObjectImportContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void SetComponent(css::uno::Reference< css::lang::XComponent > const &rComp)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual ~XMLEmbeddedObjectImportContext() override
css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastHandler
css::uno::Reference< css::lang::XComponent > xComp
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
#define SO3_SDRAW_CLASSID
#define SO3_SWWEB_CLASSID
#define SO3_SIMPRESS_CLASSID
#define SAL_WARN_IF(condition, area, stream)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
const std::pair< OUString, OUString > aServiceMap[]
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)