20#include <com/sun/star/beans/XPropertySet.hpp>
21#include <com/sun/star/xml/dom/XDocument.hpp>
22#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
34#include <oox/token/namespaces.hxx>
35#include <oox/token/tokens.hxx>
45using namespace drawingml;
48 m_bFullWPGSUpport(false),
49 mxShapeFilterBase(
std::move(xFilterBase))
64 switch (nElement & 0xffff)
66 case XML_lockedCanvas:
84 switch (nElement & 0xffff)
88 std::unique_ptr<ContextHandler2Helper> pFragmentHandler(
90 mpShape = std::make_shared<Shape>(
"com.sun.star.drawing.OLE2Shape" );
109 uno::Reference<drawing::XShape> xShape;
111 if (!nElement || nElement == WPS_TOKEN(bodyPr))
115 switch (getBaseToken(nStartElement))
122 std::make_shared<oox::drawingml::Shape>(
123 "com.sun.star.drawing.CustomShape")));
139 switch (getBaseToken(nElement))
156uno::Reference<xml::sax::XFastContextHandler>
const &
164 switch (Element & 0xffff)
167 mpShape = std::make_shared<Shape>(
"com.sun.star.drawing.GraphicObjectShape" );
172 mpShape = std::make_shared<Shape>(
"com.sun.star.drawing.GraphicObjectShape" );
184uno::Reference<xml::sax::XFastContextHandler>
const &
211uno::Reference<xml::sax::XFastContextHandler>
const &
217 mpShape = std::make_shared<Shape>();
224uno::Reference<xml::sax::XFastContextHandler>
227 uno::Reference<xml::sax::XFastContextHandler> xResult;
230 switch (getNamespace( nStartToken ))
236 case NMSP_dmlDiagram:
239 case NMSP_dmlLockedCanvas:
262 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
266 if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(
chart) ||
267 Element == WPS_TOKEN(wsp) || Element == WPG_TOKEN(wgp) || Element == OOX_TOKEN(dmlPicture, pic))
276 OUString aOfficeDocumentFragmentPath = rFragmentHandlerRef->getFragmentPathFromFirstTypeFromOfficeDoc(
u"officeDocument" );
281 OUString aThemeFragmentPath = rFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc(
u"theme" );
283 if(!aThemeFragmentPath.isEmpty())
285 uno::Reference<xml::sax::XFastSAXSerializable> xDoc(
mxShapeFilterBase->importFragment(aThemeFragmentPath), uno::UNO_QUERY_THROW);
301 if (xContextHandler.is())
302 xContextHandler->startFastElement(Element, Attribs);
306(
const OUString & Namespace,
const OUString & Name,
307 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
314 if (xContextHandler.is())
315 xContextHandler->startUnknownElement(Namespace,
Name, Attribs);
322 if (xContextHandler.is())
323 xContextHandler->endFastElement(Element);
326 if (Element != (NMSP_wps | XML_wsp))
329 uno::Reference<lang::XServiceInfo> xServiceInfo(
mxSavedShape, uno::UNO_QUERY);
330 bool bTextFrame = xServiceInfo.is() && xServiceInfo->supportsService(
"com.sun.star.text.TextFrame");
331 bool bTextBox =
false;
334 uno::Reference<beans::XPropertySet> xPropertySet(
mxSavedShape, uno::UNO_QUERY);
335 if (xPropertySet.is())
336 xPropertySet->getPropertyValue(
"TextBox") >>= bTextBox;
338 if (bTextFrame || bTextBox)
344(
const OUString & Namespace,
345 const OUString & Name)
349 if (xContextHandler.is())
350 xContextHandler->endUnknownElement(Namespace,
Name);
353uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
356 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
358 uno::Reference< xml::sax::XFastContextHandler > xResult;
359 uno::Reference< xml::sax::XFastContextHandler > xContextHandler(
getContextHandler(Element));
361 if (xContextHandler.is())
362 xResult.set(xContextHandler->createFastChildContext
368uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
370(
const OUString & Namespace,
371 const OUString & Name,
372 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
376 if (xContextHandler.is())
377 return xContextHandler->createUnknownChildContext
378 (Namespace,
Name, Attribs);
380 return uno::Reference< xml::sax::XFastContextHandler >();
387 if (xContextHandler.is())
388 xContextHandler->characters(aChars);
391uno::Reference< drawing::XShape >
394 uno::Reference< drawing::XShape > xResult;
395 uno::Reference< drawing::XShapes > xShapes =
mxDrawPage;
402 if( std::shared_ptr< vml::ShapeBase > pShape =
mpDrawing->getShapes().takeLastShape() )
403 xResult = pShape->convertAndInsert( xShapes );
411 if (
mpShape->getExtDrawings().empty())
414 xResult =
mpShape->getXShape();
419 for (
auto const& extDrawing :
mpShape->getExtDrawings())
422 if (!pDiagramGraphicDataContext)
426 pShapePtr->setDiagramType();
428 pShapePtr->setDiagramDoms(
mpShape->getDiagramDoms());
433 mpShape->migrateDiagramHelperToNewShape(pShapePtr);
435 if (!
mpShape->getChildren().empty())
438 auto& aChildren = pShapePtr->getChildren();
440 aChildren.insert(aChildren.begin(), pBackground);
444 xResult = pShapePtr->getXShape();
457 xResult = pShape->getXShape();
467 if (pChartGraphicDataContext)
472 xShapePtr->setServiceName(
"com.sun.star.drawing.temporaryForXMLImportOLE2Shape");
474 xResult = xShapePtr->getXShape();
486 xResult = pShape->getXShape();
499 xResult = pShape->getXShape();
517 xResult.set(
mpShape->getXShape());
535 throw uno::RuntimeException();
536 uno::Reference<lang::XComponent> xComp(the_value, uno::UNO_QUERY_THROW);
const OUString & getFragmentPath() const
Returns the full path of the current fragment.
OUString getFragmentPathFromRelId(const OUString &rRelId) const
Returns the full fragment path for the passed relation identifier.
const ShapePtr & getShape() const
Locked canvas is kind of a container for drawingml shapes: it can even contain group shapes.
const oox::drawingml::ShapePtr & getShape() const
virtual void SAL_CALL endFastElement(::sal_Int32 Element) override
void setPosition(const css::awt::Point &rPosition)
void setDrawPage(const css::uno::Reference< css::drawing::XDrawPage > &the_value)
css::uno::Reference< XFastContextHandler > const & getLockedCanvasContext(sal_Int32 nElement)
virtual void SAL_CALL startUnknownElement(const OUString &Namespace, const OUString &Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
css::uno::Sequence< css::beans::PropertyValue > maMediaDescriptor
css::uno::Reference< XFastContextHandler > mxGraphicShapeContext
css::uno::Reference< XFastContextHandler > const & getWpgContext(sal_Int32 nElement)
css::uno::Reference< XFastContextHandler > mxChartShapeContext
css::uno::Reference< css::document::XDocumentProperties > mxDocumentProperties
::rtl::Reference< ShapeFilterBase > mxShapeFilterBase
css::uno::Reference< XFastContextHandler > const & getDiagramShapeContext()
css::uno::Reference< XFastContextHandler > const & getDrawingShapeContext()
std::shared_ptr< vml::Drawing > mpDrawing
css::uno::Reference< XFastContextHandler > const & getWpsContext(sal_Int32 nStartElement, sal_Int32 nElement)
drawingml::ThemePtr mpThemePtr
void setModel(const css::uno::Reference< css::frame::XModel > &the_value)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(const OUString &Namespace, const OUString &Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
css::uno::Reference< XFastContextHandler > mxDiagramShapeContext
drawingml::ShapePtr mpShape
css::uno::Reference< css::drawing::XShape > mxSavedShape
css::uno::Reference< XFastContextHandler > getContextHandler(sal_Int32 nElement=0)
OUString msRelationFragmentPath
css::uno::Reference< css::drawing::XShape > getShape()
css::awt::Point maPosition
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
css::uno::Reference< css::drawing::XDrawPage > mxDrawPage
std::stack< sal_uInt32 > mnStartTokenStack
css::uno::Reference< XFastContextHandler > const & getGraphicShapeContext(::sal_Int32 Element)
virtual void SAL_CALL endUnknownElement(const OUString &Namespace, const OUString &Name) override
ShapeContextHandler(rtl::Reference< ShapeFilterBase > xFilterBase)
css::uno::Reference< XFastContextHandler > const & getChartShapeContext(::sal_Int32 Element)
css::uno::Reference< XFastContextHandler > mxWpsContext
virtual ~ShapeContextHandler() override
sal_Int32 getStartToken() const
css::uno::Reference< XFastContextHandler > mxWpgContext
css::uno::Reference< XFastContextHandler > mxLockedCanvasContext
virtual void SAL_CALL characters(const OUString &aChars) override
void pushStartToken(sal_Int32 _starttoken)
void setDocumentProperties(const css::uno::Reference< css::document::XDocumentProperties > &xDocProps)
virtual void SAL_CALL startFastElement(::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
void setMediaDescriptor(const css::uno::Sequence< css::beans::PropertyValue > &rMediaDescriptor)
void setRelationFragmentPath(const OUString &the_value)
css::uno::Reference< XFastContextHandler > mxDrawingFragmentHandler
void setGraphicMapper(css::uno::Reference< css::graphic::XGraphicMapper > const &rGraphicMapper)
Generic (i.e. not specific to PPTX) handler for the prerendered diagram parsing.
Wpg is the drawingML equivalent of v:group.
const oox::drawingml::ShapePtr & getShape() const
Wps is the drawingML equivalent of v:shape.
std::shared_ptr< Shape > ShapePtr
@ VMLDRAWING_WORD
Word: One shape per drawing.