Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_XEESCHER_HXX
30 : : #define SC_XEESCHER_HXX
31 : :
32 : : #include <vcl/graph.hxx>
33 : : #include <filter/msfilter/escherex.hxx>
34 : : #include "xcl97rec.hxx"
35 : : #include "xlescher.hxx"
36 : : #include <com/sun/star/chart/XChartDocument.hpp>
37 : : #include "svx/sdtaitm.hxx"
38 : : #include <boost/shared_ptr.hpp>
39 : :
40 : : class ScPostIt;
41 : :
42 : : namespace com { namespace sun { namespace star {
43 : : namespace script { struct ScriptEventDescriptor; }
44 : : } } }
45 : :
46 : : // DFF client anchor ==========================================================
47 : :
48 : : /** Base class for DFF client anchor atoms used in spreadsheets. */
49 [ # # ][ # # ]: 0 : class XclExpDffAnchorBase : public EscherExClientAnchor_Base, protected XclExpRoot
50 : : {
51 : : public:
52 : : /** Constructs a dummy client anchor. */
53 : : explicit XclExpDffAnchorBase( const XclExpRoot& rRoot, sal_uInt16 nFlags = 0 );
54 : :
55 : : /** Sets the flags according to the passed SdrObject. */
56 : : void SetFlags( const SdrObject& rSdrObj );
57 : : /** Sets the anchor position and flags according to the passed SdrObject. */
58 : : void SetSdrObject( const SdrObject& rSdrObj );
59 : :
60 : : /** Writes the DFF client anchor structure with the current anchor position. */
61 : : void WriteDffData( EscherEx& rEscherEx ) const;
62 : :
63 : : /** Called from SVX DFF converter.
64 : : @param rRect The object anchor rectangle to be exported (in twips). */
65 : : virtual void WriteData( EscherEx& rEscherEx, const Rectangle& rRect );
66 : :
67 : : private:
68 : : virtual void ImplSetFlags( const SdrObject& rSdrObj );
69 : : virtual void ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
70 : :
71 : : protected: // for access in derived classes
72 : : XclObjAnchor maAnchor; /// The client anchor data.
73 : : sal_uInt16 mnFlags; /// Flags for DFF stream export.
74 : : };
75 : :
76 : : // ----------------------------------------------------------------------------
77 : :
78 : : /** Represents the position (anchor) of an object in a Calc sheet. */
79 [ # # ]: 0 : class XclExpDffSheetAnchor : public XclExpDffAnchorBase
80 : : {
81 : : public:
82 : : explicit XclExpDffSheetAnchor( const XclExpRoot& rRoot );
83 : :
84 : : private:
85 : : virtual void ImplSetFlags( const SdrObject& rSdrObj );
86 : : virtual void ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
87 : :
88 : : private:
89 : : SCTAB mnScTab; /// Calc sheet index.
90 : : };
91 : :
92 : : // ----------------------------------------------------------------------------
93 : :
94 : : /** Represents the position (anchor) of a shape in an embedded draw page. */
95 [ # # ]: 0 : class XclExpDffEmbeddedAnchor : public XclExpDffAnchorBase
96 : : {
97 : : public:
98 : : explicit XclExpDffEmbeddedAnchor( const XclExpRoot& rRoot,
99 : : const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY );
100 : :
101 : : private:
102 : : virtual void ImplSetFlags( const SdrObject& rSdrObj );
103 : : virtual void ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
104 : :
105 : : private:
106 : : Size maPageSize;
107 : : sal_Int32 mnScaleX;
108 : : sal_Int32 mnScaleY;
109 : : };
110 : :
111 : : // ----------------------------------------------------------------------------
112 : :
113 : : /** Represents the position (anchor) of a note object. */
114 [ # # ]: 0 : class XclExpDffNoteAnchor : public XclExpDffAnchorBase
115 : : {
116 : : public:
117 : : explicit XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect );
118 : : };
119 : :
120 : : // ----------------------------------------------------------------------------
121 : :
122 : : /** Represents the position (anchor) of a cell dropdown object. */
123 [ # # ]: 0 : class XclExpDffDropDownAnchor : public XclExpDffAnchorBase
124 : : {
125 : : public:
126 : : explicit XclExpDffDropDownAnchor( const XclExpRoot& rRoot, const ScAddress& rScPos );
127 : : };
128 : :
129 : : // MSODRAWING* records ========================================================
130 : :
131 : : /** Base class for records holding DFF stream fragments. */
132 [ # # ]: 0 : class XclExpMsoDrawingBase : public XclExpRecord
133 : : {
134 : : public:
135 : : explicit XclExpMsoDrawingBase( XclEscherEx& rEscherEx, sal_uInt16 nRecId );
136 : :
137 : : private:
138 : : virtual void WriteBody( XclExpStream& rStrm );
139 : :
140 : : protected:
141 : : XclEscherEx& mrEscherEx; /// Reference to the DFF converter containing the DFF stream.
142 : : sal_uInt32 mnFragmentKey; /// The key of the DFF stream fragment to be written by this record.
143 : : };
144 : :
145 : : // ----------------------------------------------------------------------------
146 : :
147 : : /** The MSODRAWINGGROUP record contains the DGGCONTAINER with global DFF data
148 : : such as the picture container.
149 : : */
150 [ # # ]: 0 : class XclExpMsoDrawingGroup : public XclExpMsoDrawingBase
151 : : {
152 : : public:
153 : : explicit XclExpMsoDrawingGroup( XclEscherEx& rEscherEx );
154 : : };
155 : :
156 : : // ----------------------------------------------------------------------------
157 : :
158 : : /** One or more MSODRAWING records contain the DFF stream data for a drawing
159 : : shape.
160 : : */
161 [ # # ]: 0 : class XclExpMsoDrawing : public XclExpMsoDrawingBase
162 : : {
163 : : public:
164 : : explicit XclExpMsoDrawing( XclEscherEx& rEscherEx );
165 : : };
166 : :
167 : : // ============================================================================
168 : :
169 : : /** Provides export of bitmap data to an IMGDATA record. */
170 [ # # ][ # # ]: 0 : class XclExpImgData : public XclExpRecordBase
171 : : {
172 : : public:
173 : : explicit XclExpImgData( const Graphic& rGraphic, sal_uInt16 nRecId );
174 : :
175 : : /** Writes the BITMAP record. */
176 : : virtual void Save( XclExpStream& rStrm );
177 : : virtual void SaveXml( XclExpXmlStream& rStrm );
178 : :
179 : : private:
180 : : Graphic maGraphic; /// The VCL graphic.
181 : : sal_uInt16 mnRecId; /// Record identifier for the IMGDATA record.
182 : : };
183 : :
184 : : // ============================================================================
185 : :
186 : : /** Helper class for form controils to manage spreadsheet links . */
187 : : class XclExpControlHelper : protected XclExpRoot
188 : : {
189 : : public:
190 : : explicit XclExpControlHelper( const XclExpRoot& rRoot );
191 : : virtual ~XclExpControlHelper();
192 : :
193 : : protected:
194 : : /** Tries to get spreadsheet cell link and source range link from the passed shape. */
195 : : void ConvertSheetLinks(
196 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
197 : :
198 : :
199 : : /** Returns the Excel token array of the cell link, or 0, if no link present. */
200 : 0 : inline const XclTokenArray* GetCellLinkTokArr() const { return mxCellLink.get(); }
201 : : /** Returns the Excel token array of the source range, or 0, if no link present. */
202 : 0 : inline const XclTokenArray* GetSourceRangeTokArr() const { return mxSrcRange.get(); }
203 : : /** Returns the number of entries in the source range, or 0, if no source set. */
204 : 0 : inline sal_uInt16 GetSourceEntryCount() const { return mnEntryCount; }
205 : :
206 : : /** Writes a formula with special style only valid in OBJ records. */
207 : : void WriteFormula( XclExpStream& rStrm, const XclTokenArray& rTokArr ) const;
208 : : /** Writes a formula subrecord with special style only valid in OBJ records. */
209 : : void WriteFormulaSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId, const XclTokenArray& rTokArr ) const;
210 : :
211 : : private:
212 : : XclTokenArrayRef mxCellLink; /// Formula for linked cell.
213 : : XclTokenArrayRef mxSrcRange; /// Formula for source data range.
214 : : sal_uInt16 mnEntryCount; /// Number of entries in source range.
215 : : };
216 : :
217 : : class XclMacroHelper : public XclExpControlHelper
218 : : {
219 : : protected:
220 : : XclTokenArrayRef mxMacroLink; /// Token array containing a link to an attached macro.
221 : :
222 : : public:
223 : : explicit XclMacroHelper( const XclExpRoot& rRoot );
224 : : virtual ~XclMacroHelper();
225 : : /** Writes an ftMacro subrecord containing a macro link, or nothing, if no macro present. */
226 : : void WriteMacroSubRec( XclExpStream& rStrm );
227 : : /** Sets the name of a macro for object of passed type
228 : : @return true = The passed event descriptor was valid, macro name has been found. */
229 : : bool SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent, const XclTbxEventType& nEventType );
230 : :
231 : : /** Sets the name of a macro
232 : : @return true = The passed macro name has been found. */
233 : : bool SetMacroLink( const String& rMacro );
234 : : };
235 : :
236 : : class XclExpShapeObj : public XclObjAny, public XclMacroHelper
237 : : {
238 : : public:
239 : : explicit XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
240 : : virtual ~XclExpShapeObj();
241 : : private:
242 : : virtual void WriteSubRecs( XclExpStream& rStrm );
243 : : };
244 : :
245 : : // ----------------------------------------------------------------------------
246 : :
247 : : #if EXC_EXP_OCX_CTRL
248 : :
249 : : /** Represents an OBJ record for an OCX form control. */
250 : : class XclExpOcxControlObj : public XclObj, public XclExpControlHelper
251 : : {
252 : : public:
253 : : explicit XclExpOcxControlObj(
254 : : XclExpObjectManager& rObjMgr,
255 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
256 : : const Rectangle* pChildAnchor,
257 : : const String& rClassName,
258 : : sal_uInt32 nStrmStart, sal_uInt32 nStrmSize );
259 : :
260 : : private:
261 : : virtual void WriteSubRecs( XclExpStream& rStrm );
262 : :
263 : : private:
264 : : String maClassName; /// Class name of the control.
265 : : sal_uInt32 mnStrmStart; /// Start position in 'Ctls' stream.
266 : : sal_uInt32 mnStrmSize; /// Size in 'Ctls' stream.
267 : : };
268 : :
269 : : #else
270 : :
271 : : /** Represents an OBJ record for an TBX form control. */
272 [ # # ][ # # ]: 0 : class XclExpTbxControlObj : public XclObj, public XclMacroHelper
273 : : {
274 : : public:
275 : : explicit XclExpTbxControlObj(
276 : : XclExpObjectManager& rObjMgr,
277 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
278 : : const Rectangle* pChildAnchor );
279 : :
280 : : /** Sets the name of a macro attached to this control.
281 : : @return true = The passed event descriptor was valid, macro name has been found. */
282 : : bool SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent );
283 : :
284 : : private:
285 : : virtual void WriteSubRecs( XclExpStream& rStrm );
286 : :
287 : : /** Writes a subrecord containing a cell link, or nothing, if no link present. */
288 : : void WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId );
289 : : /** Writes the ftSbs sub structure containing scrollbar data. */
290 : : void WriteSbs( XclExpStream& rStrm );
291 : :
292 : : private:
293 : : ScfInt16Vec maMultiSel; /// Indexes of all selected entries in a multi selection.
294 : : XclTbxEventType meEventType; /// Type of supported macro event.
295 : : sal_Int32 mnHeight; /// Height of the control.
296 : : sal_uInt16 mnState; /// Checked/unchecked state.
297 : : sal_Int16 mnLineCount; /// Combobox dropdown line count.
298 : : sal_Int16 mnSelEntry; /// Selected entry in combobox (1-based).
299 : : sal_uInt16 mnScrollValue; /// Scrollbar: Current value.
300 : : sal_uInt16 mnScrollMin; /// Scrollbar: Minimum value.
301 : : sal_uInt16 mnScrollMax; /// Scrollbar: Maximum value.
302 : : sal_uInt16 mnScrollStep; /// Scrollbar: Single step.
303 : : sal_uInt16 mnScrollPage; /// Scrollbar: Page step.
304 : : bool mbFlatButton; /// False = 3D button style; True = Flat button style.
305 : : bool mbFlatBorder; /// False = 3D border style; True = Flat border style.
306 : : bool mbMultiSel; /// true = Multi selection in listbox.
307 : : bool mbScrollHor; /// Scrollbar: true = horizontal.
308 : : };
309 : :
310 : : #endif
311 : :
312 : : // ----------------------------------------------------------------------------
313 : :
314 : : class XclExpChart;
315 : :
316 : : /** A chart object. This is the drawing object wrapper for the chart data. */
317 : : class XclExpChartObj : public XclObj, protected XclExpRoot
318 : : {
319 : : public:
320 : : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDocument > XChartDocRef;
321 : : typedef ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > XShapeRef;
322 : : explicit XclExpChartObj(
323 : : XclExpObjectManager& rObjMgr,
324 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
325 : : const Rectangle* pChildAnchor );
326 : : virtual ~XclExpChartObj();
327 : :
328 : : /** Writes the OBJ record and the entire chart substream. */
329 : : virtual void Save( XclExpStream& rStrm );
330 : : virtual void SaveXml( XclExpXmlStream& rStrm );
331 : : virtual void WriteChartObj( sax_fastparser::FSHelperPtr pDrawing, XclExpXmlStream& rStrm );
332 : : void WriteShapeTransformation( sax_fastparser::FSHelperPtr pFS, const XShapeRef& rXShape, sal_Bool bFlipH = false, sal_Bool bFlipV = false, sal_Int32 nRotation = 0 );
333 : :
334 : : private:
335 : : typedef boost::shared_ptr< XclExpChart > XclExpChartRef;
336 : : XclExpChartRef mxChart; /// The chart itself (BOF/EOF substream data).
337 : : XShapeRef mxShape;
338 : : XChartDocRef mxChartDoc;
339 : : };
340 : :
341 : : // ============================================================================
342 : :
343 : : /** Represents a NOTE record containing the relevant data of a cell note.
344 : :
345 : : NOTE records differ significantly in various BIFF versions. This class
346 : : encapsulates all needed actions for each supported BIFF version.
347 : : BIFF5/BIFF7: Stores the note text and generates a single or multiple NOTE
348 : : records on saving.
349 : : BIFF8: Creates the Escher object containing the drawing information and the
350 : : note text.
351 : : */
352 [ # # ][ # # ]: 0 : class XclExpNote : public XclExpRecord
[ # # ]
353 : : {
354 : : public:
355 : : /** Constructs a NOTE record from the passed note object and/or the text.
356 : : @descr The additional text will be separated from the note text with
357 : : an empty line.
358 : : @param rScPos The Calc cell address of the note.
359 : : @param pScNote The Calc note object. May be 0 to create a note from rAddText only.
360 : : @param rAddText Additional text appended to the note text. */
361 : : explicit XclExpNote(
362 : : const XclExpRoot& rRoot,
363 : : const ScAddress& rScPos,
364 : : const ScPostIt* pScNote,
365 : : const String& rAddText );
366 : :
367 : : /** Writes the NOTE record, if the respective Escher object is present. */
368 : : virtual void Save( XclExpStream& rStrm );
369 : :
370 : : void WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm );
371 : :
372 : 0 : const XclExpString& GetAuthor() const { return maAuthor; }
373 : : private:
374 : : /** Writes the body of the NOTE record. */
375 : : virtual void WriteBody( XclExpStream& rStrm );
376 : :
377 : : private:
378 : : XclExpString maAuthor; /// Name of the author.
379 : : String maOrigNoteText; /// Original main text of the note.
380 : : rtl::OString maNoteText; /// Main text of the note (<=BIFF7).
381 : : XclExpStringRef mpNoteContents; /// Text and formatting data (OOXML)
382 : : ScAddress maScPos; /// Calc cell address of the note.
383 : : sal_uInt16 mnObjId; /// Escher object ID (BIFF8).
384 : : bool mbVisible; /// true = permanently visible.
385 : : SdrTextHorzAdjust meTHA; /// text horizontal adjust
386 : : SdrTextVertAdjust meTVA; /// text vertical adjust
387 : : bool mbAutoScale; /// Auto scale text
388 : : bool mbLocked; /// Position & Size locked
389 : : bool mbAutoFill; /// Auto Fill Style
390 : : bool mbAutoLine; /// Auto Line Style
391 : : bool mbColHidden; /// Column containing the comment is hidden
392 : : bool mbRowHidden; /// Row containing the comment is hidden
393 : : Rectangle maCommentFrom; /// From and From Offset
394 : : Rectangle maCommentTo; /// To and To Offsets
395 : : };
396 : :
397 : : // ============================================================================
398 : :
399 [ # # ]: 0 : class XclExpComments : public XclExpRecord
400 : : {
401 : : public:
402 : : typedef XclExpRecordList< XclExpNote >
403 : : XclExpNoteList;
404 : :
405 : : XclExpComments( SCTAB nTab, XclExpNoteList& rNotes );
406 : :
407 : : virtual void SaveXml( XclExpXmlStream& rStrm );
408 : :
409 : : private:
410 : : SCTAB mnTab;
411 : : XclExpNoteList& mrNotes;
412 : : };
413 : :
414 : : // object manager =============================================================
415 : :
416 : : class XclExpObjectManager : public XclExpRoot
417 : : {
418 : : public:
419 : : explicit XclExpObjectManager( const XclExpRoot& rRoot );
420 : : virtual ~XclExpObjectManager();
421 : :
422 : : /** Creates a new DFF client anchor object. Caller takes ownership! May be
423 : : overwritten in derived classes. */
424 : : virtual XclExpDffAnchorBase* CreateDffAnchor() const;
425 : :
426 : : /** Creates and returns the MSODRAWINGGROUP record containing global DFF
427 : : data in the DGGCONTAINER. */
428 : : boost::shared_ptr< XclExpRecordBase > CreateDrawingGroup();
429 : :
430 : : /** Initializes the object manager for a new sheet. */
431 : : void StartSheet();
432 : :
433 : : /** Processes a drawing page and returns the record block containing all
434 : : related records (MSODRAWING, OBJ, TXO, charts, etc.). */
435 : : boost::shared_ptr< XclExpRecordBase > ProcessDrawing( SdrPage* pSdrPage );
436 : : /** Processes a collection of UNO shapes and returns the record block
437 : : containing all related records (MSODRAWING, OBJ, TXO, charts, etc.). */
438 : : boost::shared_ptr< XclExpRecordBase > ProcessDrawing( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes );
439 : :
440 : : /** Finalizes the object manager after conversion of all sheets. */
441 : : void EndDocument();
442 : :
443 : 0 : inline XclEscherEx& GetEscherEx() { return *mxEscherEx; }
444 : : XclExpMsoDrawing* GetMsodrawingPerSheet();
445 : : bool HasObj() const;
446 : : sal_uInt16 AddObj( XclObj* pObjRec );
447 : : XclObj* RemoveLastObj();
448 : :
449 : : protected:
450 : : explicit XclExpObjectManager( const XclExpObjectManager& rParent );
451 : :
452 : : private:
453 : : void InitStream( bool bTempFile );
454 : :
455 : : private:
456 : : boost::shared_ptr< ::utl::TempFile > mxTempFile;
457 : : boost::shared_ptr< SvStream > mxDffStrm;
458 : : boost::shared_ptr< XclEscherEx > mxEscherEx;
459 : : boost::shared_ptr< XclExpObjList > mxObjList;
460 : : };
461 : :
462 : : // ----------------------------------------------------------------------------
463 : :
464 [ # # ]: 0 : class XclExpEmbeddedObjectManager : public XclExpObjectManager
465 : : {
466 : : public:
467 : : explicit XclExpEmbeddedObjectManager(
468 : : const XclExpObjectManager& rParent,
469 : : const Size& rPageSize,
470 : : sal_Int32 nScaleX, sal_Int32 nScaleY );
471 : :
472 : : /** Creates a new DFF client anchor object for embedded objects according
473 : : to the scaling data passed to the constructor. Caller takes ownership! */
474 : : virtual XclExpDffAnchorBase* CreateDffAnchor() const;
475 : :
476 : : private:
477 : : Size maPageSize;
478 : : sal_Int32 mnScaleX;
479 : : sal_Int32 mnScaleY;
480 : : };
481 : :
482 : : // ============================================================================
483 : :
484 : : #endif
485 : :
486 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|