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 
55 {
56 public:
57  explicit Shape(
58  const WorksheetHelper& rHelper,
59  const AttributeList& rAttribs,
60  const char* pcServiceName );
61 
62 protected:
63  virtual void finalizeXShape(
64  ::oox::core::XmlFilterBase& rFilter,
65  const css::uno::Reference< css::drawing::XShapes >& rxShapes ) override;
66 
67 private:
68  OUString maMacroName;
69 };
70 
73 {
74 public:
75  explicit GroupShapeContext(
76  const ::oox::core::FragmentHandler2& rParent,
77  const WorksheetHelper& rHelper,
78  const ::oox::drawingml::ShapePtr& rxParentShape,
79  const ::oox::drawingml::ShapePtr& rxShape );
80 
81  static ::oox::core::ContextHandlerRef
83  ::oox::core::FragmentHandler2& rParent,
84  const WorksheetHelper& rHelper,
85  sal_Int32 nElement,
86  const AttributeList& rAttribs,
87  const ::oox::drawingml::ShapePtr& rxParentShape,
88  ::oox::drawingml::ShapePtr* pxShape = nullptr );
89 
90 protected:
91  virtual ::oox::core::ContextHandlerRef
93  sal_Int32 nElement,
94  const ::oox::AttributeList& rAttribs ) override;
95 };
96 
99 {
100 public:
101  explicit DrawingFragment(
102  const WorksheetHelper& rHelper,
103  const OUString& rFragmentPath );
104 
105 protected:
106  virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
107  virtual void onCharacters( const OUString& rChars ) override;
108  virtual void onEndElement() override;
109 
110 private:
111  typedef ::std::unique_ptr< ShapeAnchor > ShapeAnchorRef;
112 
113  css::uno::Reference< css::drawing::XShapes >
116  ShapeAnchorRef mxAnchor;
117 };
118 
119 // VML
120 
122 {
123 public:
124  explicit VmlControlMacroAttacher( const OUString& rMacroName,
125  const css::uno::Reference< css::container::XIndexContainer >& rxCtrlFormIC,
126  sal_Int32 nCtrlIndex, sal_Int32 nCtrlType, sal_Int32 nDropStyle );
127 
128 private:
129  virtual void attachMacro( const OUString& rMacroUrl ) override;
130 
131 private:
132  css::uno::Reference< css::container::XIndexContainer > mxCtrlFormIC;
133  sal_Int32 mnCtrlIndex;
134  sal_Int32 mnCtrlType;
135  sal_Int32 mnDropStyle;
136 };
137 
139 {
140 public:
141  explicit VmlDrawing( const WorksheetHelper& rHelper );
142 
144  const ::oox::vml::ShapeBase* getNoteShape( const ScAddress& rPos ) const;
145 
147  virtual bool isShapeSupported( const ::oox::vml::ShapeBase& rShape ) const override;
148 
150  virtual OUString getShapeBaseName( const ::oox::vml::ShapeBase& rShape ) const override;
151 
153  virtual bool convertClientAnchor(
154  css::awt::Rectangle& orShapeRect,
155  const OUString& rShapeAnchor ) const override;
156 
158  virtual css::uno::Reference< css::drawing::XShape >
160  const ::oox::vml::ShapeBase& rShape,
161  const css::uno::Reference< css::drawing::XShapes >& rxShapes,
162  const css::awt::Rectangle& rShapeRect ) const override;
163 
165  virtual void notifyXShapeInserted(
166  const css::uno::Reference< css::drawing::XShape >& rxShape,
167  const css::awt::Rectangle& rShapeRect,
168  const ::oox::vml::ShapeBase& rShape, bool bGroupChild ) override;
169 
170 private:
172  sal_uInt32 convertControlTextColor( const OUString& rTextColor ) const;
175  ::oox::ole::AxFontData& rAxFontData, sal_uInt32& rnOleTextColor,
176  const ::oox::vml::TextFontModel& rFontModel ) const;
179  void convertControlText(
180  ::oox::ole::AxFontData& rAxFontData, sal_uInt32& rnOleTextColor, OUString& rCaption,
181  const ::oox::vml::TextBox* pTextBox, sal_Int32 nTextHAlign ) const;
184  ::oox::ole::AxMorphDataModelBase& rAxModel,
185  const ::oox::vml::ShapeBase& rShape ) const;
186 
187 private:
190 };
191 
193 {
194 public:
195  explicit VmlDrawingFragment(
196  const WorksheetHelper& rHelper,
197  const OUString& rFragmentPath );
198 
199 protected:
200  virtual void finalizeImport() override;
201 };
202 
203 } // namespace oox::xls
204 
205 /* 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