24#include <com/sun/star/drawing/XLayerManager.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/frame/XModel.hpp>
27#include <com/sun/star/xml/sax/XAttributeList.hpp>
28#include <com/sun/star/drawing/XLayerSupplier.hpp>
38using namespace ::
cppu;
54 SdXMLLayerContext( SvXMLImport& rImport,
const Reference< XFastAttributeList >& xAttrList,
const Reference< XNameAccess >& xLayerManager );
58 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
62 css::uno::Reference< css::container::XNameAccess > mxLayerManager;
64 OUStringBuffer sDescriptionBuffer;
65 OUStringBuffer sTitleBuffer;
72SdXMLLayerContext::SdXMLLayerContext( SvXMLImport& rImport,
const Reference< XFastAttributeList >& xAttrList,
const Reference< XNameAccess >& xLayerManager )
74, mxLayerManager( xLayerManager )
78 OUString sValue = aIter.toString();
79 switch(aIter.getToken())
97css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLLayerContext::createFastChildContext(
99 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
114void SdXMLLayerContext::endFastElement(sal_Int32 )
116 SAL_WARN_IF(
msName.isEmpty(),
"xmloff",
"xmloff::SdXMLLayerContext::EndElement(), draw:layer element without draw:name!" );
122 Reference< XPropertySet > xLayer;
124 if( mxLayerManager->hasByName( msName ) )
126 mxLayerManager->getByName( msName ) >>= xLayer;
127 SAL_WARN_IF( !xLayer.is(),
"xmloff",
"xmloff::SdXMLLayerContext::EndElement(), failed to get existing XLayer!" );
131 Reference< XLayerManager > xLayerManager( mxLayerManager, UNO_QUERY );
132 if( xLayerManager.is() )
133 xLayer = xLayerManager->insertNewByIndex( xLayerManager->getCount() );
134 SAL_WARN_IF( !xLayer.is(),
"xmloff",
"xmloff::SdXMLLayerContext::EndElement(), failed to create new XLayer!" );
137 xLayer->setPropertyValue(
"Name",
Any( msName ) );
142 xLayer->setPropertyValue(
"Title",
Any( sTitleBuffer.makeStringAndClear() ) );
143 xLayer->setPropertyValue(
"Description",
Any( sDescriptionBuffer.makeStringAndClear() ) );
144 bool bIsVisible(
true );
145 bool bIsPrintable(
true );
146 if ( !msDisplay.isEmpty() )
148 bIsVisible = (msDisplay ==
"always") || (msDisplay ==
"screen");
149 bIsPrintable = (msDisplay ==
"always") || (msDisplay ==
"printer");
151 xLayer->setPropertyValue(
"IsVisible",
Any( bIsVisible ) );
152 xLayer->setPropertyValue(
"IsPrintable",
Any( bIsPrintable ) );
153 bool bIsLocked(
false );
154 if ( !msProtected.isEmpty() )
155 bIsLocked = (msProtected ==
"true");
156 xLayer->setPropertyValue(
"IsLocked",
Any( bIsLocked ) );
160 if (msName ==
"DrawnInSlideshow")
162 xLayer->setPropertyValue(
"IsVisible",
Any(
true));
163 xLayer->setPropertyValue(
"IsPrintable",
Any(
true));
164 xLayer->setPropertyValue(
"IsLocked",
Any(
false));
178 Reference< XLayerSupplier > xLayerSupplier( rImport.GetModel(), UNO_QUERY );
179 SAL_WARN_IF( !xLayerSupplier.is(),
"xmloff",
"xmloff::SdXMLLayerSetContext::SdXMLLayerSetContext(), XModel is not supporting XLayerSupplier!" );
180 if( xLayerSupplier.is() )
190 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
SdXMLLayerSetContext(SvXMLImport &rImport)
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 ~SdXMLLayerSetContext() override
css::uno::Reference< css::container::XNameAccess > mxLayerManager
This class deliberately does not support XWeak, to improve performance when loading large documents.
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
Import all text into a string buffer.
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_WARN_IF(condition, area, stream)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)