20#include <osl/thread.h>
34#include <com/sun/star/awt/Rectangle.hpp>
35#include <com/sun/star/form/XFormsSupplier.hpp>
36#include <com/sun/star/frame/XModel.hpp>
37#include <com/sun/star/lang/XMultiServiceFactory.hpp>
38#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
39#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
40#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
46#include <com/sun/star/document/XDocumentProperties.hpp>
47#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
63 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
68SdXMLBodyContext_Impl::SdXMLBodyContext_Impl(
SdXMLImport& rImport ) :
73css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLBodyContext_Impl::createFastChildContext(
75 const uno::Reference< xml::sax::XFastAttributeList > & )
93 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
98SdXMLDocContext_Impl::SdXMLDocContext_Impl(
104uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLDocContext_Impl::createFastChildContext(
105 sal_Int32 nElement,
const uno::Reference< xml::sax::XFastAttributeList >& )
123 return GetSdImport().CreateMasterStylesContext();
132 return new SdXMLBodyContext_Impl(GetSdImport());
149 return GetSdImport().CreateStylesContext();
158 return GetSdImport().CreateAutoStylesContext();
164 return GetSdImport().CreateFontDeclsContext();
168 SAL_INFO(
"xmloff.draw",
"XML_ELEMENT(OFFICE, XML_META): should not have come here, maybe document is invalid?");
178class SdXMLFlatDocContext_Impl
183 const uno::Reference<document::XDocumentProperties>& i_xDocProps );
186 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
191SdXMLFlatDocContext_Impl::SdXMLFlatDocContext_Impl(
SdXMLImport& i_rImport,
192 const uno::Reference<document::XDocumentProperties>& i_xDocProps) :
194 SdXMLDocContext_Impl(i_rImport),
199uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLFlatDocContext_Impl::createFastChildContext(
200 sal_Int32 nElement,
const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
205 nElement, xAttrList );
207 return SdXMLDocContext_Impl::createFastChildContext(
208 nElement, xAttrList );
212extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
214 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
216 return cppu::acquire(
220extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
222 uno::Sequence<uno::Any>
const& )
227extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
229 uno::Sequence<uno::Any>
const& )
231 return cppu::acquire(
new SdXMLImport(pCtx,
"XMLDrawStylesImportOasis",
true,
236extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
238 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
240 return cppu::acquire(
new SdXMLImport(pCtx,
"XMLDrawContentImportOasis",
true,
246extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
248 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
250 return cppu::acquire(
254extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
256 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
258 return cppu::acquire(
262extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
264 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
266 return cppu::acquire(
new SdXMLImport(pCtx,
"XMLImpressStylesImportOasis",
false,
271extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
273 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
275 return cppu::acquire(
new SdXMLImport(pCtx,
"XMLImpressContentImportOasis",
false,
281extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
283 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
285 return cppu::acquire(
289extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
291 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
293 return cppu::acquire(
298 const css::uno::Reference< css::uno::XComponentContext >& xContext,
299 OUString
const & implementationName,
303 mnNewMasterPageCount(0),
309 GetNamespaceMap().Add(
314 GetNamespaceMap().Add(
323 SvXMLImport::setTargetDocument( xDoc );
325 uno::Reference< lang::XServiceInfo > xDocServices( GetModel(), uno::UNO_QUERY );
326 if( !xDocServices.is() )
327 throw lang::IllegalArgumentException();
329 mbIsDraw = !xDocServices->supportsService(
"com.sun.star.presentation.PresentationDocument");
332 uno::Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), uno::UNO_QUERY );
340 uno::Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), uno::UNO_QUERY);
341 if(xMasterPagesSupplier.is())
345 uno::Reference <drawing::XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), uno::UNO_QUERY);
346 if(!xDrawPagesSupplier.is())
347 throw lang::IllegalArgumentException();
351 throw lang::IllegalArgumentException();
355 uno::Reference< form::XFormsSupplier > xFormsSupp;
357 mbIsFormsSupported = xFormsSupp.is();
362 GetShapeImport()->enableHandleProgressBar();
364 uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
367 uno::Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
369 mbIsTableShapeSupported =
true;
378 static constexpr OUStringLiteral sOrganizerMode(
u"OrganizerMode");
379 bool bStyleOnly(
false);
381 css::beans::PropertyValue aPropValue;
382 if (
aArguments.hasElements() && (
aArguments[0] >>= aPropValue) && aPropValue.Name == sOrganizerMode)
384 aPropValue.Value >>= bStyleOnly;
388 uno::Reference< beans::XPropertySet > xInfoSet( getImportInfo() );
392 uno::Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
397 if( xInfoSetInfo->hasPropertyByName(
gsPreview ) )
400 if (xInfoSetInfo->hasPropertyByName(sOrganizerMode))
402 if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
410 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
419 pContext =
new SdXMLDocContext_Impl(*
this);
426 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
427 GetModel(), uno::UNO_QUERY_THROW);
429 pContext =
new SdXMLFlatDocContext_Impl( *
this, xDPS->getDocumentProperties());
442 const uno::Reference<xml::sax::XFastAttributeList>&)
448 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
449 GetModel(), uno::UNO_QUERY_THROW);
450 uno::Reference<document::XDocumentProperties>
const xDocProps(
451 !
mbLoadDoc ?
nullptr : xDPS->getDocumentProperties());
460 if(GetShapeImport()->GetStylesContext())
461 return GetShapeImport()->GetStylesContext();
466 return GetShapeImport()->GetStylesContext();
471 if(GetShapeImport()->GetAutoStylesContext())
472 return GetShapeImport()->GetAutoStylesContext();
477 return GetShapeImport()->GetAutoStylesContext();
491 SetFontDecls( pFSContext );
497 uno::Reference< beans::XPropertySet > xPropSet( GetModel(), uno::UNO_QUERY );
501 awt::Rectangle aVisArea( 0,0, 28000, 21000 );
503 for(
const auto& rViewProp : aViewProps )
505 const OUString& rName = rViewProp.Name;
508 if ( rName ==
"VisibleAreaTop" )
510 rValue >>= aVisArea.Y;
512 else if ( rName ==
"VisibleAreaLeft" )
514 rValue >>= aVisArea.X;
516 else if ( rName ==
"VisibleAreaWidth" )
518 rValue >>= aVisArea.Width;
520 else if ( rName ==
"VisibleAreaHeight" )
522 rValue >>= aVisArea.Height;
528 xPropSet->setPropertyValue(
"VisibleArea",
uno::Any( aVisArea ) );
530 catch(
const css::uno::Exception&)
540 uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
544 uno::Reference< beans::XPropertySet > xProps( xFac->createInstance(
"com.sun.star.document.Settings"), uno::UNO_QUERY );
548 uno::Reference< beans::XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
552 const uno::Sequence<beans::PropertyValue>*
pValues = &aConfigProps;
554 DocumentSettingsSerializer *pFilter;
555 pFilter =
dynamic_cast<DocumentSettingsSerializer *
>(xProps.get());
556 uno::Sequence<beans::PropertyValue> aFiltered;
559 aFiltered = pFilter->filterStreamsFromStorage( GetDocumentBase(), GetSourceStorage(), aConfigProps );
563 for(
const auto& rValue : *
pValues )
567 const OUString& rProperty = rValue.Name;
568 if( xInfo->hasPropertyByName( rProperty ) )
569 xProps->setPropertyValue( rProperty, rValue.Value );
571 catch(
const uno::Exception&)
573 SAL_INFO(
"xmloff.draw",
"#SdXMLImport::SetConfigurationSettings: Exception!" );
582 const uno::Sequence<beans::NamedValue> & i_rStats)
585 {
"ObjectCount",
nullptr };
587 SvXMLImport::SetStatistics(i_rStats);
590 for (
const auto& rStat : i_rStats) {
591 for (
const char** pStat =
s_stats; *pStat !=
nullptr; ++pStat) {
592 if (rStat.Name.equalsAscii(*pStat)) {
594 if (rStat.Value >>= val) {
597 SAL_WARN(
"xmloff.draw",
"SdXMLImport::SetStatistics: invalid entry");
605 GetProgressBarHelper()->SetReference(
nCount);
606 GetProgressBarHelper()->SetValue(0);
612 if( !rName.isEmpty() && !rText.isEmpty() )
618 if( !rName.isEmpty() && !rText.isEmpty() )
624 if( !rName.isEmpty() && (!rText.isEmpty() || !bFixed) )
637 HeaderFooterDeclMap::const_iterator aIter(
maHeaderDeclsMap.find( rName ) );
639 aRet = (*aIter).second;
647 HeaderFooterDeclMap::const_iterator aIter(
maFooterDeclsMap.find( rName ) );
649 aRet = (*aIter).second;
660 aDecl = (*aIter).second;
669 uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
672 uno::Reference< beans::XPropertySet > xProps( xFac->createInstance(
"com.sun.star.document.Settings"), uno::UNO_QUERY );
674 xProps->setPropertyValue(
"EmbedFonts",
uno::Any(
true ) );
const PropertyValue * pValues
void AddFooterDecl(const OUString &rName, const OUString &rText)
SvXMLStylesContext * CreateStylesContext()
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
rtl::Reference< SdXMLMasterStylesContext > mxMasterStylesContext
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
SvXMLImportContext * CreateFontDeclsContext()
static constexpr OUStringLiteral gsPreview
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
css::uno::Reference< css::container::XNameAccess > mxPageLayouts
OUString GetDateTimeDecl(const OUString &rName, bool &rbFixed, OUString &rDateTimeFormat)
HeaderFooterDeclMap maFooterDeclsMap
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats) override
SvXMLImportContext * CreateMasterStylesContext()
css::uno::Reference< css::container::XIndexAccess > mxDocMasterPages
HeaderFooterDeclMap maHeaderDeclsMap
css::uno::Reference< css::container::XIndexAccess > mxDocDrawPages
static constexpr OUStringLiteral gsPageLayouts
DateTimeDeclMap maDateTimeDeclsMap
SdXMLImport(const css::uno::Reference< css::uno::XComponentContext > &xContext, OUString const &implementationName, bool bIsDraw, SvXMLImportFlags nImportFlags)
void AddHeaderDecl(const OUString &rName, const OUString &rText)
virtual void NotifyContainsEmbeddedFont() override
void AddDateTimeDecl(const OUString &rName, const OUString &rText, bool bFixed, const OUString &rDateTimeFormat)
SvXMLStylesContext * CreateAutoStylesContext()
OUString GetHeaderDecl(const OUString &rName) const
OUString GetFooterDecl(const OUString &rName) const
css::uno::Reference< css::container::XNameAccess > mxDocStyleFamilies
This class deliberately does not support XWeak, to improve performance when loading large documents.
SvXMLImport & GetImport()
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
handles the top-level office:document-meta element of meta.xml documents
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Sequence< PropertyValue > aArguments
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
constexpr OUStringLiteral implementationName
Handling of tokens in XML:
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisMetaImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisSettingsImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisStylesImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisContentImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisSettingsImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisStylesImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisContentImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisMetaImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
OUString maStrDateTimeFormat
#define XML_ELEMENT(prefix, name)
constexpr sal_uInt16 XML_NAMESPACE_SMIL
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION