Line data Source code
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 : #ifndef OOX_XLS_DRAWINGFRAGMENT_HXX
21 : #define OOX_XLS_DRAWINGFRAGMENT_HXX
22 :
23 : #include <com/sun/star/awt/Rectangle.hpp>
24 : #include <com/sun/star/awt/Size.hpp>
25 : #include "oox/drawingml/shapegroupcontext.hxx"
26 : #include "oox/ole/axcontrol.hxx"
27 : #include "oox/drawingml/shape.hxx"
28 : #include "oox/ole/vbaproject.hxx"
29 : #include "oox/vml/vmldrawing.hxx"
30 : #include "oox/vml/vmldrawingfragment.hxx"
31 : #include "oox/vml/vmltextbox.hxx"
32 : #include "drawingbase.hxx"
33 : #include "excelhandlers.hxx"
34 :
35 : namespace oox { namespace ole {
36 : struct AxFontData;
37 : class AxMorphDataModelBase;
38 : } }
39 :
40 : namespace oox {
41 : namespace xls {
42 :
43 :
44 : // DrawingML
45 :
46 :
47 0 : class ShapeMacroAttacher : public ::oox::ole::VbaMacroAttacherBase
48 : {
49 : public:
50 : explicit ShapeMacroAttacher( const OUString& rMacroName,
51 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape );
52 :
53 : private:
54 : virtual void attachMacro( const OUString& rMacroUrl ) SAL_OVERRIDE;
55 :
56 : private:
57 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape;
58 : };
59 :
60 28 : class Shape : public ::oox::drawingml::Shape, public WorksheetHelper
61 : {
62 : public:
63 : explicit Shape(
64 : const WorksheetHelper& rHelper,
65 : const AttributeList& rAttribs,
66 : const sal_Char* pcServiceName = 0 );
67 :
68 : protected:
69 : virtual void finalizeXShape(
70 : ::oox::core::XmlFilterBase& rFilter,
71 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes ) SAL_OVERRIDE;
72 :
73 : private:
74 : OUString maMacroName;
75 : };
76 :
77 : /** Context handler for creation of shapes embedded in group shapes. */
78 0 : class GroupShapeContext : public ::oox::drawingml::ShapeGroupContext, public WorksheetHelper
79 : {
80 : public:
81 : explicit GroupShapeContext(
82 : ::oox::core::ContextHandler2Helper& rParent,
83 : const WorksheetHelper& rHelper,
84 : const ::oox::drawingml::ShapePtr& rxParentShape,
85 : const ::oox::drawingml::ShapePtr& rxShape );
86 :
87 : static ::oox::core::ContextHandlerRef
88 : createShapeContext(
89 : ::oox::core::ContextHandler2Helper& rParent,
90 : const WorksheetHelper& rHelper,
91 : sal_Int32 nElement,
92 : const AttributeList& rAttribs,
93 : const ::oox::drawingml::ShapePtr& rxParentShape,
94 : ::oox::drawingml::ShapePtr* pxShape = 0 );
95 :
96 : protected:
97 : virtual ::oox::core::ContextHandlerRef
98 : onCreateContext(
99 : sal_Int32 nElement,
100 : const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE;
101 : };
102 :
103 : /** Fragment handler for a complete sheet drawing. */
104 32 : class DrawingFragment : public WorksheetFragmentBase
105 : {
106 : public:
107 : explicit DrawingFragment(
108 : const WorksheetHelper& rHelper,
109 : const OUString& rFragmentPath );
110 :
111 : protected:
112 : virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
113 : virtual void onCharacters( const OUString& rChars ) SAL_OVERRIDE;
114 : virtual void onEndElement() SAL_OVERRIDE;
115 :
116 : private:
117 : typedef ::std::auto_ptr< ShapeAnchor > ShapeAnchorRef;
118 :
119 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
120 : mxDrawPage; /// Drawing page of this sheet.
121 : ::oox::drawingml::ShapePtr mxShape; /// Current top-level shape.
122 : ShapeAnchorRef mxAnchor; /// Current anchor of top-level shape.
123 : };
124 :
125 :
126 : // VML
127 :
128 :
129 0 : class VmlControlMacroAttacher : public ::oox::ole::VbaMacroAttacherBase
130 : {
131 : public:
132 : explicit VmlControlMacroAttacher( const OUString& rMacroName,
133 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rxCtrlFormIC,
134 : sal_Int32 nCtrlIndex, sal_Int32 nCtrlType, sal_Int32 nDropStyle );
135 :
136 : private:
137 : virtual void attachMacro( const OUString& rMacroUrl ) SAL_OVERRIDE;
138 :
139 : private:
140 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > mxCtrlFormIC;
141 : sal_Int32 mnCtrlIndex;
142 : sal_Int32 mnCtrlType;
143 : sal_Int32 mnDropStyle;
144 : };
145 :
146 170 : class VmlDrawing : public ::oox::vml::Drawing, public WorksheetHelper
147 : {
148 : public:
149 : explicit VmlDrawing( const WorksheetHelper& rHelper );
150 :
151 : /** Returns the drawing shape for a cell note at the specified position. */
152 : const ::oox::vml::ShapeBase* getNoteShape( const ::com::sun::star::table::CellAddress& rPos ) const;
153 :
154 : /** Filters cell note shapes. */
155 : virtual bool isShapeSupported( const ::oox::vml::ShapeBase& rShape ) const SAL_OVERRIDE;
156 :
157 : /** Returns additional base names for automatic shape name creation. */
158 : virtual OUString getShapeBaseName( const ::oox::vml::ShapeBase& rShape ) const SAL_OVERRIDE;
159 :
160 : /** Calculates the shape rectangle from a cell anchor string. */
161 : virtual bool convertClientAnchor(
162 : ::com::sun::star::awt::Rectangle& orShapeRect,
163 : const OUString& rShapeAnchor ) const SAL_OVERRIDE;
164 :
165 : /** Creates a UNO control shape for legacy drawing controls. */
166 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
167 : createAndInsertClientXShape(
168 : const ::oox::vml::ShapeBase& rShape,
169 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
170 : const ::com::sun::star::awt::Rectangle& rShapeRect ) const SAL_OVERRIDE;
171 :
172 : /** Updates the bounding box covering all shapes of this drawing. */
173 : virtual void notifyXShapeInserted(
174 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
175 : const ::com::sun::star::awt::Rectangle& rShapeRect,
176 : const ::oox::vml::ShapeBase& rShape, bool bGroupChild ) SAL_OVERRIDE;
177 :
178 : private:
179 : /** Converts the passed VML textbox text color to an OLE color. */
180 : sal_uInt32 convertControlTextColor( const OUString& rTextColor ) const;
181 : /** Converts the passed VML textbox font to an ActiveX form control font. */
182 : void convertControlFontData(
183 : ::oox::ole::AxFontData& rAxFontData, sal_uInt32& rnOleTextColor,
184 : const ::oox::vml::TextFontModel& rFontModel ) const;
185 : /** Converts the caption, the font settings, and the horizontal alignment
186 : from the passed VML textbox to ActiveX form control settings. */
187 : void convertControlText(
188 : ::oox::ole::AxFontData& rAxFontData, sal_uInt32& rnOleTextColor, OUString& rCaption,
189 : const ::oox::vml::TextBox* pTextBox, sal_Int32 nTextHAlign ) const;
190 : /** Converts the passed VML shape background formatting to ActiveX control formatting. */
191 : void convertControlBackground(
192 : ::oox::ole::AxMorphDataModelBase& rAxModel,
193 : const ::oox::vml::ShapeBase& rShape ) const;
194 :
195 : private:
196 : ::oox::ole::ControlConverter maControlConv;
197 : ::oox::vml::TextFontModel maListBoxFont;
198 : };
199 :
200 6 : class VmlDrawingFragment : public ::oox::vml::DrawingFragment, public WorksheetHelper
201 : {
202 : public:
203 : explicit VmlDrawingFragment(
204 : const WorksheetHelper& rHelper,
205 : const OUString& rFragmentPath );
206 :
207 : protected:
208 : virtual void finalizeImport() SAL_OVERRIDE;
209 : };
210 :
211 : } // namespace xls
212 : } // namespace oox
213 :
214 : #endif
215 :
216 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|