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 <sal/log.hxx>
15 #include <oox/token/namespaces.hxx>
16 #include <oox/token/tokens.hxx>
17 
18 using namespace com::sun::star;
19 
20 namespace oox::shape
21 {
22 WpgContext::WpgContext(FragmentHandler2 const& rParent)
23  : FragmentHandler2(rParent)
24 {
25  mpShape = std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape");
26  mpShape->setWps(true);
27 }
28 
29 WpgContext::~WpgContext() = default;
30 
32  const oox::AttributeList& /*rAttribs*/)
33 {
34  switch (getBaseToken(nElementToken))
35  {
36  case XML_wgp:
37  case XML_cNvGrpSpPr:
38  case XML_grpSpPr:
40  case XML_wsp:
41  {
42  // Don't set default character height, Writer has its own way to set
43  // the default, and if we don't set it here, editeng properly inherits
44  // it.
45  oox::drawingml::ShapePtr pShape = std::make_shared<oox::drawingml::Shape>(
46  "com.sun.star.drawing.CustomShape", /*bDefaultHeight=*/false);
47  return new oox::drawingml::ShapeContext(*this, mpShape, pShape);
48  // return new oox::shape::WpsContext(*this, uno::Reference<drawing::XShape>(),
49  // mpShape, pShape);
50  }
51  case XML_pic:
53  *this, mpShape,
54  std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GraphicObjectShape"));
55  case XML_grpSp:
56  {
58  *this, mpShape,
59  std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape"));
60  }
61  case XML_graphicFrame:
62  {
63  auto pShape = std::make_shared<oox::drawingml::Shape>(
64  "com.sun.star.drawing.GraphicObjectShape");
65  pShape->setWps(true);
66  return new oox::drawingml::GraphicalObjectFrameContext(*this, mpShape, pShape,
67  /*bEmbedShapesInChart=*/true);
68  }
69  default:
70  SAL_WARN("oox", "WpgContext::createFastChildContext: unhandled element: "
71  << getBaseToken(nElementToken));
72  break;
73  }
74  return nullptr;
75 }
76 }
77 
78 /* 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:31
Provides access to attribute values of an element.
#define SAL_WARN(area, stream)
std::shared_ptr< Shape > ShapePtr
oox::drawingml::ShapePtr mpShape
Definition: WpgContext.hxx:31