1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
23 #include <oox/drawingml/shapegroupcontext.hxx>
24 #include <oox/drawingml/color.hxx>
25 #include <oox/ole/axcontrol.hxx>
26 #include <oox/drawingml/shape.hxx>
27 #include <oox/ole/vbaproject.hxx>
28 #include <oox/vml/vmldrawing.hxx>
29 #include <oox/vml/vmldrawingfragment.hxx>
30 #include <oox/vml/vmltextbox.hxx>
31 #include "drawingbase.hxx"
32 #include "excelhandlers.hxx"
42 class ShapeMacroAttacher final
: public ::oox::ole::VbaMacroAttacherBase
45 explicit ShapeMacroAttacher( const OUString
& rMacroName
,
46 const css::uno::Reference
< css::drawing::XShape
>& rxShape
);
49 virtual void attachMacro( const OUString
& rMacroUrl
) override
;
52 css::uno::Reference
< css::drawing::XShape
> mxShape
;
55 class Shape final
: public ::oox::drawingml::Shape
, public WorksheetHelper
59 const WorksheetHelper
& rHelper
,
60 const AttributeList
& rAttribs
,
61 const char* pcServiceName
);
64 virtual void finalizeXShape(
65 ::oox::core::XmlFilterBase
& rFilter
,
66 const css::uno::Reference
< css::drawing::XShapes
>& rxShapes
) override
;
71 /** Context handler for creation of shapes embedded in group shapes. */
72 class GroupShapeContext final
: public ::oox::drawingml::ShapeGroupContext
, public WorksheetHelper
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
);
81 static ::oox::core::ContextHandlerRef
83 ::oox::core::FragmentHandler2
& rParent
,
84 const WorksheetHelper
& rHelper
,
86 const AttributeList
& rAttribs
,
87 const ::oox::drawingml::ShapePtr
& rxParentShape
,
88 ::oox::drawingml::ShapePtr
* pxShape
= nullptr );
91 virtual ::oox::core::ContextHandlerRef
94 const ::oox::AttributeList
& rAttribs
) override
;
97 /** Fragment handler for a complete sheet drawing. */
98 class DrawingFragment final
: public WorksheetFragmentBase
101 explicit DrawingFragment(
102 const WorksheetHelper
& rHelper
,
103 const OUString
& rFragmentPath
);
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
;
110 typedef ::std::unique_ptr
< ShapeAnchor
> ShapeAnchorRef
;
112 css::uno::Reference
< css::drawing::XShapes
>
113 mxDrawPage
; /// Drawing page of this sheet.
114 ::oox::drawingml::ShapePtr mxShape
; /// Current top-level shape.
115 ShapeAnchorRef mxAnchor
; /// Current anchor of top-level shape.
116 // for SmartArt. Apply the colors in rFontRefColor (from clrScheme) to all shapes in pShape,
117 // the group object which represents the SmartArt.
118 void applyFontRefColor(const oox::drawingml::ShapePtr
& pShape
,
119 const oox::drawingml::Color
& rFontRefColor
);
124 class VmlControlMacroAttacher final
: public ::oox::ole::VbaMacroAttacherBase
127 explicit VmlControlMacroAttacher( const OUString
& rMacroName
,
128 const css::uno::Reference
< css::container::XIndexContainer
>& rxCtrlFormIC
,
129 sal_Int32 nCtrlIndex
, sal_Int32 nCtrlType
, sal_Int32 nDropStyle
);
132 virtual void attachMacro( const OUString
& rMacroUrl
) override
;
135 css::uno::Reference
< css::container::XIndexContainer
> mxCtrlFormIC
;
136 sal_Int32 mnCtrlIndex
;
137 sal_Int32 mnCtrlType
;
138 sal_Int32 mnDropStyle
;
141 class VmlDrawing final
: public ::oox::vml::Drawing
, public WorksheetHelper
144 explicit VmlDrawing( const WorksheetHelper
& rHelper
);
146 /** Returns the drawing shape for a cell note at the specified position. */
147 const ::oox::vml::ShapeBase
* getNoteShape( const ScAddress
& rPos
) const;
149 /** Filters cell note shapes. */
150 virtual bool isShapeSupported( const ::oox::vml::ShapeBase
& rShape
) const override
;
152 /** Returns additional base names for automatic shape name creation. */
153 virtual OUString
getShapeBaseName( const ::oox::vml::ShapeBase
& rShape
) const override
;
155 /** Calculates the shape rectangle from a cell anchor string. */
156 virtual bool convertClientAnchor(
157 css::awt::Rectangle
& orShapeRect
,
158 const OUString
& rShapeAnchor
) const override
;
160 /** Creates a UNO control shape for legacy drawing controls. */
161 virtual css::uno::Reference
< css::drawing::XShape
>
162 createAndInsertClientXShape(
163 const ::oox::vml::ShapeBase
& rShape
,
164 const css::uno::Reference
< css::drawing::XShapes
>& rxShapes
,
165 const css::awt::Rectangle
& rShapeRect
) const override
;
167 /** Updates the bounding box covering all shapes of this drawing. */
168 virtual void notifyXShapeInserted(
169 const css::uno::Reference
< css::drawing::XShape
>& rxShape
,
170 const css::awt::Rectangle
& rShapeRect
,
171 const ::oox::vml::ShapeBase
& rShape
, bool bGroupChild
) override
;
174 /** Converts the passed VML textbox text color to an OLE color. */
175 sal_uInt32
convertControlTextColor( std::u16string_view aTextColor
) const;
176 /** Converts the passed VML textbox font to an ActiveX form control font. */
177 void convertControlFontData(
178 ::oox::ole::AxFontData
& rAxFontData
, sal_uInt32
& rnOleTextColor
,
179 const ::oox::vml::TextFontModel
& rFontModel
) const;
180 /** Converts the caption, the font settings, and the horizontal alignment
181 from the passed VML textbox to ActiveX form control settings. */
182 void convertControlText(
183 ::oox::ole::AxFontData
& rAxFontData
, sal_uInt32
& rnOleTextColor
, OUString
& rCaption
,
184 const ::oox::vml::TextBox
* pTextBox
, sal_Int32 nTextHAlign
) const;
185 /** Converts the passed VML shape background formatting to ActiveX control formatting. */
186 void convertControlBackground(
187 ::oox::ole::AxMorphDataModelBase
& rAxModel
,
188 const ::oox::vml::ShapeBase
& rShape
) const;
191 ::oox::ole::ControlConverter maControlConv
;
192 ::oox::vml::TextFontModel maListBoxFont
;
195 class VmlDrawingFragment final
: public ::oox::vml::DrawingFragment
, public WorksheetHelper
198 explicit VmlDrawingFragment(
199 const WorksheetHelper
& rHelper
,
200 const OUString
& rFragmentPath
);
203 virtual void finalizeImport() override
;
206 } // namespace oox::xls
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */