LibreOffice Module sc (master)  1
drawingfragment.hxx
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  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #pragma once
21 
22 #include <memory>
24 #include <oox/ole/axcontrol.hxx>
25 #include <oox/drawingml/shape.hxx>
26 #include <oox/ole/vbaproject.hxx>
27 #include <oox/vml/vmldrawing.hxx>
29 #include <oox/vml/vmltextbox.hxx>
30 #include "drawingbase.hxx"
31 #include "excelhandlers.hxx"
32 
33 namespace oox::ole {
34  struct AxFontData;
35 }
36 
37 namespace oox::xls {
38 
39 // DrawingML
40 
42 {
43 public:
44  explicit ShapeMacroAttacher( const OUString& rMacroName,
45  const css::uno::Reference< css::drawing::XShape >& rxShape );
46 
47 private:
48  virtual void attachMacro( const OUString& rMacroUrl ) override;
49 
50 private:
51  css::uno::Reference< css::drawing::XShape > mxShape;
52 };
53 
54 class Shape final : public ::oox::drawingml::Shape, public WorksheetHelper
55 {
56 public:
57  explicit Shape(
58  const WorksheetHelper& rHelper,
59  const AttributeList& rAttribs,
60  const char* pcServiceName );
61 
62 private:
63  virtual void finalizeXShape(
64  ::oox::core::XmlFilterBase& rFilter,
65  const css::uno::Reference< css::drawing::XShapes >& rxShapes ) override;
66 
67  OUString maMacroName;
68 };
69 
72 {
73 public:
74  explicit GroupShapeContext(
75  const ::oox::core::FragmentHandler2& rParent,
76  const WorksheetHelper& rHelper,
77  const ::oox::drawingml::ShapePtr& rxParentShape,
78  const ::oox::drawingml::ShapePtr& rxShape );
79 
80  static ::oox::core::ContextHandlerRef
82  ::oox::core::FragmentHandler2& rParent,
83  const WorksheetHelper& rHelper,
84  sal_Int32 nElement,
85  const AttributeList& rAttribs,
86  const ::oox::drawingml::ShapePtr& rxParentShape,
87  ::oox::drawingml::ShapePtr* pxShape = nullptr );
88 
89 private:
90  virtual ::oox::core::ContextHandlerRef
92  sal_Int32 nElement,
93  const ::oox::AttributeList& rAttribs ) override;
94 };
95 
98 {
99 public:
100  explicit DrawingFragment(
101  const WorksheetHelper& rHelper,
102  const OUString& rFragmentPath );
103 
104 private:
105  virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
106  virtual void onCharacters( const OUString& rChars ) override;
107  virtual void onEndElement() override;
108 
109  typedef ::std::unique_ptr< ShapeAnchor > ShapeAnchorRef;
110 
111  css::uno::Reference< css::drawing::XShapes >
114  ShapeAnchorRef mxAnchor;
115 };
116 
117 // VML
118 
120 {
121 public:
122  explicit VmlControlMacroAttacher( const OUString& rMacroName,
123  const css::uno::Reference< css::container::XIndexContainer >& rxCtrlFormIC,
124  sal_Int32 nCtrlIndex, sal_Int32 nCtrlType, sal_Int32 nDropStyle );
125 
126 private:
127  virtual void attachMacro( const OUString& rMacroUrl ) override;
128 
129 private:
130  css::uno::Reference< css::container::XIndexContainer > mxCtrlFormIC;
131  sal_Int32 mnCtrlIndex;
132  sal_Int32 mnCtrlType;
133  sal_Int32 mnDropStyle;
134 };
135 
136 class VmlDrawing final : public ::oox::vml::Drawing, public WorksheetHelper
137 {
138 public:
139  explicit VmlDrawing( const WorksheetHelper& rHelper );
140 
142  const ::oox::vml::ShapeBase* getNoteShape( const ScAddress& rPos ) const;
143 
145  virtual bool isShapeSupported( const ::oox::vml::ShapeBase& rShape ) const override;
146 
148  virtual OUString getShapeBaseName( const ::oox::vml::ShapeBase& rShape ) const override;
149 
151  virtual bool convertClientAnchor(
152  css::awt::Rectangle& orShapeRect,
153  const OUString& rShapeAnchor ) const override;
154 
156  virtual css::uno::Reference< css::drawing::XShape >
158  const ::oox::vml::ShapeBase& rShape,
159  const css::uno::Reference< css::drawing::XShapes >& rxShapes,
160  const css::awt::Rectangle& rShapeRect ) const override;
161 
163  virtual void notifyXShapeInserted(
164  const css::uno::Reference< css::drawing::XShape >& rxShape,
165  const css::awt::Rectangle& rShapeRect,
166  const ::oox::vml::ShapeBase& rShape, bool bGroupChild ) override;
167 
168 private:
170  sal_uInt32 convertControlTextColor( const OUString& rTextColor ) const;
173  ::oox::ole::AxFontData& rAxFontData, sal_uInt32& rnOleTextColor,
174  const ::oox::vml::TextFontModel& rFontModel ) const;
177  void convertControlText(
178  ::oox::ole::AxFontData& rAxFontData, sal_uInt32& rnOleTextColor, OUString& rCaption,
179  const ::oox::vml::TextBox* pTextBox, sal_Int32 nTextHAlign ) const;
182  ::oox::ole::AxMorphDataModelBase& rAxModel,
183  const ::oox::vml::ShapeBase& rShape ) const;
184 
185 private:
188 };
189 
191 {
192 public:
193  explicit VmlDrawingFragment(
194  const WorksheetHelper& rHelper,
195  const OUString& rFragmentPath );
196 
197 private:
198  virtual void finalizeImport() override;
199 };
200 
201 } // namespace oox::xls
202 
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VmlDrawingFragment(const WorksheetHelper &rHelper, const OUString &rFragmentPath)
virtual OUString getShapeBaseName(const ::oox::vml::ShapeBase &rShape) const override
Returns additional base names for automatic shape name creation.
css::uno::Reference< css::drawing::XShape > mxShape
::oox::ole::ControlConverter maControlConv
Shape(const WorksheetHelper &rHelper, const AttributeList &rAttribs, const char *pcServiceName)
virtual bool isShapeSupported(const ::oox::vml::ShapeBase &rShape) const override
Filters cell note shapes.
Context handler for creation of shapes embedded in group shapes.
Fragment handler for a complete sheet drawing.
ShapeMacroAttacher(const OUString &rMacroName, const css::uno::Reference< css::drawing::XShape > &rxShape)
::oox::core::ContextHandlerRef createShapeContext(::oox::core::FragmentHandler2 &rParent, const WorksheetHelper &rHelper, sal_Int32 nElement, const AttributeList &rAttribs, const ::oox::drawingml::ShapePtr &rxParentShape,::oox::drawingml::ShapePtr *pxShape=nullptr)
virtual void finalizeXShape(::oox::core::XmlFilterBase &rFilter, const css::uno::Reference< css::drawing::XShapes > &rxShapes) override
virtual bool convertClientAnchor(css::awt::Rectangle &orShapeRect, const OUString &rShapeAnchor) const override
Calculates the shape rectangle from a cell anchor string.
const ::oox::vml::ShapeBase * getNoteShape(const ScAddress &rPos) const
Returns the drawing shape for a cell note at the specified position.
::oox::drawingml::ShapePtr mxShape
Drawing page of this sheet.
::std::unique_ptr< ShapeAnchor > ShapeAnchorRef
virtual void onEndElement() override
virtual void finalizeImport() override
css::uno::Reference< css::drawing::XShapes > mxDrawPage
virtual css::uno::Reference< css::drawing::XShape > createAndInsertClientXShape(const ::oox::vml::ShapeBase &rShape, const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const override
Creates a UNO control shape for legacy drawing controls.
css::uno::Reference< css::container::XIndexContainer > mxCtrlFormIC
DrawingFragment(const WorksheetHelper &rHelper, const OUString &rFragmentPath)
virtual void attachMacro(const OUString &rMacroUrl) override
Fragment handler derived from the WorksheetHelper helper class.
virtual void notifyXShapeInserted(const css::uno::Reference< css::drawing::XShape > &rxShape, const css::awt::Rectangle &rShapeRect, const ::oox::vml::ShapeBase &rShape, bool bGroupChild) override
Updates the bounding box covering all shapes of this drawing.
void convertControlBackground(::oox::ole::AxMorphDataModelBase &rAxModel, const ::oox::vml::ShapeBase &rShape) const
Converts the passed VML shape background formatting to ActiveX control formatting.
void convertControlText(::oox::ole::AxFontData &rAxFontData, sal_uInt32 &rnOleTextColor, OUString &rCaption, const ::oox::vml::TextBox *pTextBox, sal_Int32 nTextHAlign) const
Converts the caption, the font settings, and the horizontal alignment from the passed VML textbox to ...
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const ::oox::AttributeList &rAttribs) override
VmlControlMacroAttacher(const OUString &rMacroName, const css::uno::Reference< css::container::XIndexContainer > &rxCtrlFormIC, sal_Int32 nCtrlIndex, sal_Int32 nCtrlType, sal_Int32 nDropStyle)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
GroupShapeContext(const ::oox::core::FragmentHandler2 &rParent, const WorksheetHelper &rHelper, const ::oox::drawingml::ShapePtr &rxParentShape, const ::oox::drawingml::ShapePtr &rxShape)
void convertControlFontData(::oox::ole::AxFontData &rAxFontData, sal_uInt32 &rnOleTextColor, const ::oox::vml::TextFontModel &rFontModel) const
Converts the passed VML textbox font to an ActiveX form control font.
std::shared_ptr< Shape > ShapePtr
::oox::vml::TextFontModel maListBoxFont
VmlDrawing(const WorksheetHelper &rHelper)
ShapeAnchorRef mxAnchor
Current top-level shape.
virtual void onCharacters(const OUString &rChars) override
sal_uInt32 convertControlTextColor(const OUString &rTextColor) const
Converts the passed VML textbox text color to an OLE color.
virtual void attachMacro(const OUString &rMacroUrl) override