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))
155uno::Reference<xml::sax::XFastContextHandler>
const &
163 switch (Element & 0xffff)
166 mpShape = std::make_shared<Shape>(
"com.sun.star.drawing.GraphicObjectShape" );
171 mpShape = std::make_shared<Shape>(
"com.sun.star.drawing.GraphicObjectShape" );
183uno::Reference<xml::sax::XFastContextHandler>
208uno::Reference<xml::sax::XFastContextHandler>
214 mpShape = std::make_shared<Shape>();
222uno::Reference<xml::sax::XFastContextHandler>
225 uno::Reference<xml::sax::XFastContextHandler> xResult;
228 switch (getNamespace( nStartToken ))
234 case NMSP_dmlDiagram:
237 case NMSP_dmlLockedCanvas:
260 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
264 if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(
chart) ||
265 Element == WPS_TOKEN(wsp) || Element == WPG_TOKEN(wgp) || Element == OOX_TOKEN(dmlPicture, pic))
273 OUString aOfficeDocumentFragmentPath = rFragmentHandlerRef->getFragmentPathFromFirstTypeFromOfficeDoc(
u"officeDocument" );
278 OUString aThemeFragmentPath = rFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc(
u"theme" );
280 if (!aThemeFragmentPath.isEmpty())
283 auto pTheme = std::make_shared<model::Theme>();
285 uno::Reference<xml::sax::XFastSAXSerializable> xDoc(
mxShapeFilterBase->importFragment(aThemeFragmentPath), uno::UNO_QUERY_THROW);
305 if (xContextHandler.is())
306 xContextHandler->startFastElement(Element, Attribs);
310(
const OUString & Namespace,
const OUString & Name,
311 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
318 if (xContextHandler.is())
319 xContextHandler->startUnknownElement(Namespace,
Name, Attribs);
326 if (xContextHandler.is())
327 xContextHandler->endFastElement(Element);
330 if (Element != (NMSP_wps | XML_wsp))
333 uno::Reference<lang::XServiceInfo> xServiceInfo(
mxSavedShape, uno::UNO_QUERY);
334 bool bTextFrame = xServiceInfo.is() && xServiceInfo->supportsService(
"com.sun.star.text.TextFrame");
335 bool bTextBox =
false;
338 uno::Reference<beans::XPropertySet> xPropertySet(
mxSavedShape, uno::UNO_QUERY);
339 if (xPropertySet.is())
340 xPropertySet->getPropertyValue(
"TextBox") >>= bTextBox;
342 if (bTextFrame || bTextBox)
348(
const OUString & Namespace,
349 const OUString & Name)
353 if (xContextHandler.is())
354 xContextHandler->endUnknownElement(Namespace,
Name);
357uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
360 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
362 uno::Reference< xml::sax::XFastContextHandler > xResult;
363 uno::Reference< xml::sax::XFastContextHandler > xContextHandler(
getContextHandler(Element));
365 if (xContextHandler.is())
366 xResult.set(xContextHandler->createFastChildContext
372uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
374(
const OUString & Namespace,
375 const OUString & Name,
376 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
380 if (xContextHandler.is())
381 return xContextHandler->createUnknownChildContext
382 (Namespace,
Name, Attribs);
384 return uno::Reference< xml::sax::XFastContextHandler >();
391 if (xContextHandler.is())
392 xContextHandler->characters(aChars);
395uno::Reference< drawing::XShape >
398 uno::Reference< drawing::XShape > xResult;
399 uno::Reference< drawing::XShapes > xShapes =
mxDrawPage;
406 if( std::shared_ptr< vml::ShapeBase > pShape =
mpDrawing->getShapes().takeLastShape() )
407 xResult = pShape->convertAndInsert( xShapes );
415 if (
mpShape->getExtDrawings().empty())
418 xResult =
mpShape->getXShape();
423 for (
auto const& extDrawing :
mpShape->getExtDrawings())
427 pShapePtr->setDiagramType();
429 pShapePtr->setDiagramDoms(
mpShape->getDiagramDoms());
432 if (
mpShape->getFontRefColorForNodes().isUsed())
437 mpShape->migrateDiagramHelperToNewShape(pShapePtr);
439 if (!
mpShape->getChildren().empty())
442 auto& aChildren = pShapePtr->getChildren();
444 aChildren.insert(aChildren.begin(), pBackground);
448 xResult = pShapePtr->getXShape();
461 xResult = pShape->getXShape();
473 xShapePtr->setServiceName(
"com.sun.star.drawing.temporaryForXMLImportOLE2Shape");
475 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);
591 pShape->getShapeStyleRefs()[XML_fontRef].maPhClr = rFontRefColor;
592 std::vector<oox::drawingml::ShapePtr>& vChildren = pShape->getChildren();
593 for (
auto const& child : vChildren)
Locked canvas is kind of a container for drawingml shapes: it can even contain group shapes.
virtual void SAL_CALL endFastElement(::sal_Int32 Element) override
void setPosition(const css::awt::Point &rPosition)
css::uno::Reference< XFastContextHandler > getWpgContext(sal_Int32 nElement)
void setDrawPage(const css::uno::Reference< css::drawing::XDrawPage > &the_value)
css::uno::Reference< XFastContextHandler > getChartShapeContext(::sal_Int32 Element)
css::uno::Reference< XFastContextHandler > getDrawingShapeContext()
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
rtl::Reference< drawingml::ChartGraphicDataContext > mxChartShapeContext
css::uno::Reference< XFastContextHandler > getLockedCanvasContext(sal_Int32 nElement)
void setSize(const css::awt::Size &rSize)
css::uno::Reference< css::document::XDocumentProperties > mxDocumentProperties
::rtl::Reference< ShapeFilterBase > mxShapeFilterBase
std::shared_ptr< vml::Drawing > mpDrawing
drawingml::ThemePtr mpThemePtr
css::uno::Reference< XFastContextHandler > getDiagramShapeContext()
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
drawingml::ShapePtr mpShape
css::uno::Reference< css::drawing::XShape > mxSavedShape
css::uno::Reference< XFastContextHandler > getContextHandler(sal_Int32 nElement=0)
OUString msRelationFragmentPath
rtl::Reference< vml::DrawingFragment > mxDrawingFragmentHandler
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
rtl::Reference< LockedCanvasContext > mxLockedCanvasContext
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
rtl::Reference< WpsContext > mxWpsContext
css::uno::Reference< XFastContextHandler > getWpsContext(sal_Int32 nStartElement, sal_Int32 nElement)
ShapeContextHandler(rtl::Reference< ShapeFilterBase > xFilterBase)
rtl::Reference< WpgContext > mxWpgContext
virtual ~ShapeContextHandler() override
sal_Int32 getStartToken() const
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
rtl::Reference< drawingml::DiagramGraphicDataContext > mxDiagramShapeContext
void setMediaDescriptor(const css::uno::Sequence< css::beans::PropertyValue > &rMediaDescriptor)
void setRelationFragmentPath(const OUString &the_value)
void setGraphicMapper(css::uno::Reference< css::graphic::XGraphicMapper > const &rGraphicMapper)
void applyFontRefColor(const oox::drawingml::ShapePtr &pShape, const oox::drawingml::Color &rFontRefColor)
Generic (i.e. not specific to PPTX) handler for the prerendered diagram parsing.
Wpg is the drawingML equivalent of v:group.
Wps is the drawingML equivalent of v:shape.
std::shared_ptr< Shape > ShapePtr
@ VMLDRAWING_WORD
Word: One shape per drawing.