tdf#131098 docx export: write fill property of graphic
[LibreOffice.git] / oox / source / shape / WpgContext.cxx
blob3d0e2a58b819d4f66196dd11a2c5e05f1abb6e0b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "WpgContext.hxx"
11 #include "WpsContext.hxx"
12 #include <sal/log.hxx>
13 #include <drawingml/shapepropertiescontext.hxx>
14 #include <oox/drawingml/shapegroupcontext.hxx>
15 #include <oox/drawingml/graphicshapecontext.hxx>
16 #include <oox/token/namespaces.hxx>
17 #include <oox/token/tokens.hxx>
19 using namespace com::sun::star;
21 namespace oox::shape
23 WpgContext::WpgContext(FragmentHandler2 const& rParent, const oox::drawingml::ShapePtr& pMaster)
24 : FragmentHandler2(rParent)
25 , m_bFullWPGSupport(false)
27 mpShape = std::make_shared<oox::drawingml::Shape>(u"com.sun.star.drawing.GroupShape"_ustr);
28 mpShape->setWps(true);
29 if (pMaster)
30 pMaster->addChild(mpShape);
33 WpgContext::~WpgContext() = default;
35 oox::core::ContextHandlerRef WpgContext::onCreateContext(sal_Int32 nElementToken,
36 const oox::AttributeList& /*rAttribs*/)
38 switch (getBaseToken(nElementToken))
40 case XML_wgp:
41 case XML_cNvGrpSpPr:
42 case XML_grpSpPr:
43 return new oox::drawingml::ShapePropertiesContext(*this, *mpShape);
44 case XML_wsp:
46 if (m_bFullWPGSupport)
48 return new oox::shape::WpsContext(*this, uno::Reference<drawing::XShape>(), mpShape,
49 std::make_shared<oox::drawingml::Shape>(
50 u"com.sun.star.drawing.CustomShape"_ustr,
51 /*bDefaultHeight=*/false));
54 // Don't set default character height, Writer has its own way to set
55 // the default, and if we don't set it here, editeng properly inherits
56 // it.
57 return new oox::drawingml::ShapeContext(
58 *this, mpShape,
59 std::make_shared<oox::drawingml::Shape>(u"com.sun.star.drawing.CustomShape"_ustr,
60 /*bDefaultHeight=*/false));
62 case XML_pic:
63 return new oox::drawingml::GraphicShapeContext(
64 *this, mpShape,
65 std::make_shared<oox::drawingml::Shape>(
66 u"com.sun.star.drawing.GraphicObjectShape"_ustr));
67 case XML_grpSp:
69 if (m_bFullWPGSupport)
71 rtl::Reference<WpgContext> pWPGShape = new oox::shape::WpgContext(*this, mpShape);
72 pWPGShape->setFullWPGSupport(m_bFullWPGSupport);
73 return pWPGShape;
76 return new oox::drawingml::ShapeGroupContext(
77 *this, mpShape,
78 std::make_shared<oox::drawingml::Shape>(u"com.sun.star.drawing.GroupShape"_ustr));
80 case XML_graphicFrame:
82 auto pShape = std::make_shared<oox::drawingml::Shape>(
83 u"com.sun.star.drawing.GraphicObjectShape"_ustr);
84 pShape->setWps(true);
85 return new oox::drawingml::GraphicalObjectFrameContext(*this, mpShape, pShape,
86 /*bEmbedShapesInChart=*/true);
88 default:
89 SAL_WARN("oox", "WpgContext::createFastChildContext: unhandled element: "
90 << getBaseToken(nElementToken));
91 break;
93 return nullptr;
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */