LibreOffice Module oox (master)  1
WpgContext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  */
9 
10 #include "WpgContext.hxx"
11 #include "WpsContext.hxx"
12 #include <sal/log.hxx>
16 #include <oox/token/namespaces.hxx>
17 #include <oox/token/tokens.hxx>
18 
19 using namespace com::sun::star;
20 
21 namespace oox::shape
22 {
23 WpgContext::WpgContext(FragmentHandler2 const& rParent, oox::drawingml::ShapePtr pMaster)
24  : FragmentHandler2(rParent)
25  , m_bFullWPGSupport(false)
26 {
27  mpShape = std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape");
28  mpShape->setWps(true);
29  if (pMaster)
30  pMaster->addChild(mpShape);
31 }
32 
33 WpgContext::~WpgContext() = default;
34 
36  const oox::AttributeList& /*rAttribs*/)
37 {
38  switch (getBaseToken(nElementToken))
39  {
40  case XML_wgp:
41  case XML_cNvGrpSpPr:
42  case XML_grpSpPr:
44  case XML_wsp:
45  {
47  {
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,
51  pShape);
52  }
53  else
54  {
55  // Don't set default character height, Writer has its own way to set
56  // the default, and if we don't set it here, editeng properly inherits
57  // it.
58  oox::drawingml::ShapePtr pShape = std::make_shared<oox::drawingml::Shape>(
59  "com.sun.star.drawing.CustomShape", /*bDefaultHeight=*/false);
60  return new oox::drawingml::ShapeContext(*this, mpShape, pShape);
61  }
62  }
63  case XML_pic:
65  *this, mpShape,
66  std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GraphicObjectShape"));
67  case XML_grpSp:
68  {
70  {
72  pWPGShape->setFullWPGSupport(m_bFullWPGSupport);
73  return pWPGShape;
74  }
75  else
76  {
78  *this, mpShape,
79  std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape"));
80  }
81  }
82  case XML_graphicFrame:
83  {
84  auto pShape = std::make_shared<oox::drawingml::Shape>(
85  "com.sun.star.drawing.GraphicObjectShape");
86  pShape->setWps(true);
87  return new oox::drawingml::GraphicalObjectFrameContext(*this, mpShape, pShape,
88  /*bEmbedShapesInChart=*/true);
89  }
90  default:
91  SAL_WARN("oox", "WpgContext::createFastChildContext: unhandled element: "
92  << getBaseToken(nElementToken));
93  break;
94  }
95  return nullptr;
96 }
97 }
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElementToken, const oox::AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.
Definition: WpgContext.cxx:35
Provides access to attribute values of an element.
Wps is the drawingML equivalent of v:shape.
Definition: WpsContext.hxx:25
#define SAL_WARN(area, stream)
std::shared_ptr< Shape > ShapePtr
oox::drawingml::ShapePtr mpShape
Definition: WpgContext.hxx:32
Wpg is the drawingML equivalent of v:group.
Definition: WpgContext.hxx:19