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