1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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
;
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
>("com.sun.star.drawing.GroupShape");
28 mpShape
->setWps(true);
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
))
43 return new oox::drawingml::ShapePropertiesContext(*this, *mpShape
);
46 if (m_bFullWPGSupport
)
48 oox::drawingml::ShapePtr pShape
= std::make_shared
<oox::drawingml::Shape
>(
49 "com.sun.star.drawing.CustomShape", /*bDefaultHeight=*/false);
50 return new oox::shape::WpsContext(*this, uno::Reference
<drawing::XShape
>(), mpShape
,
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
57 oox::drawingml::ShapePtr pShape
= std::make_shared
<oox::drawingml::Shape
>(
58 "com.sun.star.drawing.CustomShape", /*bDefaultHeight=*/false);
59 return new oox::drawingml::ShapeContext(*this, mpShape
, pShape
);
62 return new oox::drawingml::GraphicShapeContext(
64 std::make_shared
<oox::drawingml::Shape
>("com.sun.star.drawing.GraphicObjectShape"));
67 if (m_bFullWPGSupport
)
69 rtl::Reference
<WpgContext
> pWPGShape
= new oox::shape::WpgContext(*this, mpShape
);
70 pWPGShape
->setFullWPGSupport(m_bFullWPGSupport
);
74 return new oox::drawingml::ShapeGroupContext(
76 std::make_shared
<oox::drawingml::Shape
>("com.sun.star.drawing.GroupShape"));
78 case XML_graphicFrame
:
80 auto pShape
= std::make_shared
<oox::drawingml::Shape
>(
81 "com.sun.star.drawing.GraphicObjectShape");
83 return new oox::drawingml::GraphicalObjectFrameContext(*this, mpShape
, pShape
,
84 /*bEmbedShapesInChart=*/true);
87 SAL_WARN("oox", "WpgContext::createFastChildContext: unhandled element: "
88 << getBaseToken(nElementToken
));
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */