/src/libreoffice/oox/source/shape/WordprocessingCanvasContext.cxx
Line | Count | Source |
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 "WordprocessingCanvasContext.hxx" |
11 | | #include "WpsContext.hxx" |
12 | | #include "WpgContext.hxx" |
13 | | #include <drawingml/customshapeproperties.hxx> |
14 | | #include <drawingml/effectpropertiescontext.hxx> |
15 | | #include <drawingml/fillproperties.hxx> |
16 | | #include <drawingml/shapepropertiescontext.hxx> |
17 | | #include <oox/drawingml/connectorshapecontext.hxx> |
18 | | #include <oox/drawingml/drawingmltypes.hxx> |
19 | | #include <oox/drawingml/graphicshapecontext.hxx> |
20 | | #include <oox/drawingml/shape.hxx> |
21 | | #include <oox/drawingml/shapecontext.hxx> |
22 | | #include <oox/drawingml/shapegroupcontext.hxx> |
23 | | #include <oox/helper/attributelist.hxx> |
24 | | #include <oox/token/namespaces.hxx> |
25 | | #include <oox/token/tokens.hxx> |
26 | | #include <sal/log.hxx> |
27 | | #include <svx/svdoedge.hxx> |
28 | | #include <svx/svdobj.hxx> |
29 | | |
30 | | using namespace com::sun::star; |
31 | | |
32 | | namespace oox::shape |
33 | | { |
34 | | WordprocessingCanvasContext::WordprocessingCanvasContext(FragmentHandler2 const& rParent, |
35 | | const css::awt::Size& rSize) |
36 | 0 | : FragmentHandler2(rParent) |
37 | 0 | , m_bFullWPGSupport(true) |
38 | 0 | { |
39 | 0 | mpShapePtr = std::make_shared<oox::drawingml::Shape>(u"com.sun.star.drawing.GroupShape"_ustr); |
40 | 0 | mpShapePtr->setSize(rSize); |
41 | 0 | mpShapePtr->setWordprocessingCanvas(true); // will be "WordprocessingCanvas" in InteropGrabBag |
42 | 0 | mpShapePtr->setWps(true); |
43 | 0 | oox::drawingml::ShapePtr pBackground |
44 | 0 | = std::make_shared<oox::drawingml::Shape>(u"com.sun.star.drawing.CustomShape"_ustr); |
45 | 0 | pBackground->getCustomShapeProperties()->setShapePresetType(XML_rect); |
46 | 0 | pBackground->setSize(rSize); |
47 | 0 | pBackground->setWordprocessingCanvas(true); |
48 | 0 | pBackground->setWPGChild(true); |
49 | 0 | pBackground->setWps(true); |
50 | | // Fill and Line properties will follow in wpc:bg and wpc:whole child elements of wpc element |
51 | 0 | mpShapePtr->addChild(pBackground); |
52 | 0 | mpShapePtr->setChildSize(rSize); |
53 | 0 | } |
54 | | |
55 | 0 | WordprocessingCanvasContext::~WordprocessingCanvasContext() = default; |
56 | | |
57 | | ::oox::core::ContextHandlerRef |
58 | | WordprocessingCanvasContext::onCreateContext(sal_Int32 nElementToken, |
59 | | const ::oox::AttributeList& /*rAttribs*/) |
60 | 0 | { |
61 | 0 | switch (getBaseToken(nElementToken)) |
62 | 0 | { |
63 | 0 | case XML_wpc: |
64 | 0 | SAL_INFO("oox", "WordprocessingCanvasContext::createFastChildContext: wpc: " |
65 | 0 | << getBaseToken(nElementToken)); |
66 | 0 | break; |
67 | 0 | case XML_bg: //CT_BackgroundFormatting |
68 | 0 | return new oox::drawingml::ShapePropertiesContext(*this, |
69 | 0 | *(getShape()->getChildren().front())); |
70 | 0 | case XML_whole: // CT_WholeE2oFormatting |
71 | 0 | return new oox::drawingml::ShapePropertiesContext(*this, |
72 | 0 | *(getShape()->getChildren().front())); |
73 | 0 | case XML_wsp: // CT_WordprocessingShape |
74 | 0 | { |
75 | 0 | oox::drawingml::ShapePtr pShape = std::make_shared<oox::drawingml::Shape>( |
76 | 0 | u"com.sun.star.drawing.CustomShape"_ustr, /*bDefaultHeight=*/false); |
77 | 0 | return new oox::shape::WpsContext(*this, uno::Reference<drawing::XShape>(), mpShapePtr, |
78 | 0 | pShape); |
79 | 0 | } |
80 | 0 | case XML_pic: // CT_Picture |
81 | 0 | return new oox::drawingml::GraphicShapeContext( |
82 | 0 | *this, mpShapePtr, |
83 | 0 | std::make_shared<oox::drawingml::Shape>( |
84 | 0 | u"com.sun.star.drawing.GraphicObjectShape"_ustr)); |
85 | 0 | break; |
86 | 0 | case XML_graphicFrame: // CT_GraphicFrame |
87 | 0 | SAL_INFO("oox", |
88 | 0 | "WordprocessingCanvasContext::createFastChildContext: ToDo: graphicFrame: " |
89 | 0 | << getBaseToken(nElementToken)); |
90 | 0 | break; |
91 | 0 | case XML_wgp: // CT_WordprocessingGroup |
92 | 0 | { |
93 | 0 | rtl::Reference<WpgContext> pWPGContext = new oox::shape::WpgContext(*this, mpShapePtr); |
94 | 0 | pWPGContext->setFullWPGSupport(m_bFullWPGSupport); |
95 | 0 | return pWPGContext; |
96 | 0 | } |
97 | 0 | default: |
98 | | // includes case XML_contentPart |
99 | | // Word uses this for Ink, as <w14:contentPart r:id="rId4"> for example. Thereby rId4 is |
100 | | // a reference into the 'ink' folder in the docx package. Import of Ink is not |
101 | | // implemented yet. In general it refers to arbitrary XML source. |
102 | 0 | SAL_WARN("oox", |
103 | 0 | "WordprocessingCanvasContext::createFastChildContext: unhandled element:" |
104 | 0 | << getBaseToken(nElementToken)); |
105 | 0 | break; |
106 | 0 | } |
107 | 0 | return nullptr; |
108 | 0 | } |
109 | | } |
110 | | |
111 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |