fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / inc / xeescher.hxx
blob56b183a39e822fe5c2c3a64060ae7db7cb2cae1d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XEESCHER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XEESCHER_HXX
23 #include <vcl/graph.hxx>
24 #include <filter/msfilter/escherex.hxx>
25 #include "xcl97rec.hxx"
26 #include "xlescher.hxx"
27 #include <com/sun/star/chart/XChartDocument.hpp>
28 #include <svx/sdtaitm.hxx>
29 #include <rtl/ustring.hxx>
30 #include <memory>
32 class ScPostIt;
34 namespace com { namespace sun { namespace star {
35 namespace script { struct ScriptEventDescriptor; }
36 } } }
38 // DFF client anchor ==========================================================
40 /** Base class for DFF client anchor atoms used in spreadsheets. */
41 class XclExpDffAnchorBase : public EscherExClientAnchor_Base, protected XclExpRoot
43 public:
44 /** Constructs a dummy client anchor. */
45 explicit XclExpDffAnchorBase( const XclExpRoot& rRoot, sal_uInt16 nFlags = 0 );
47 /** Sets the flags according to the passed SdrObject. */
48 void SetFlags( const SdrObject& rSdrObj );
49 /** Sets the anchor position and flags according to the passed SdrObject. */
50 void SetSdrObject( const SdrObject& rSdrObj );
52 /** Writes the DFF client anchor structure with the current anchor position. */
53 void WriteDffData( EscherEx& rEscherEx ) const;
55 /** Called from SVX DFF converter.
56 @param rRect The object anchor rectangle to be exported (in twips). */
57 virtual void WriteData( EscherEx& rEscherEx, const Rectangle& rRect ) SAL_OVERRIDE;
59 private:
60 virtual void ImplSetFlags( const SdrObject& rSdrObj );
61 virtual void ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
63 protected: // for access in derived classes
64 XclObjAnchor maAnchor; /// The client anchor data.
65 sal_uInt16 mnFlags; /// Flags for DFF stream export.
68 /** Represents the position (anchor) of an object in a Calc sheet. */
69 class XclExpDffSheetAnchor : public XclExpDffAnchorBase
71 public:
72 explicit XclExpDffSheetAnchor( const XclExpRoot& rRoot );
74 private:
75 virtual void ImplSetFlags( const SdrObject& rSdrObj ) SAL_OVERRIDE;
76 virtual void ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit ) SAL_OVERRIDE;
78 private:
79 SCTAB mnScTab; /// Calc sheet index.
82 /** Represents the position (anchor) of a shape in an embedded draw page. */
83 class XclExpDffEmbeddedAnchor : public XclExpDffAnchorBase
85 public:
86 explicit XclExpDffEmbeddedAnchor( const XclExpRoot& rRoot,
87 const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY );
89 private:
90 virtual void ImplSetFlags( const SdrObject& rSdrObj ) SAL_OVERRIDE;
91 virtual void ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit ) SAL_OVERRIDE;
93 private:
94 Size maPageSize;
95 sal_Int32 mnScaleX;
96 sal_Int32 mnScaleY;
99 /** Represents the position (anchor) of a note object. */
100 class XclExpDffNoteAnchor : public XclExpDffAnchorBase
102 public:
103 explicit XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect );
106 /** Represents the position (anchor) of a cell dropdown object. */
107 class XclExpDffDropDownAnchor : public XclExpDffAnchorBase
109 public:
110 explicit XclExpDffDropDownAnchor( const XclExpRoot& rRoot, const ScAddress& rScPos );
113 // MSODRAWING* records ========================================================
115 /** Base class for records holding DFF stream fragments. */
116 class XclExpMsoDrawingBase : public XclExpRecord
118 public:
119 explicit XclExpMsoDrawingBase( XclEscherEx& rEscherEx, sal_uInt16 nRecId );
121 private:
122 virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
124 protected:
125 XclEscherEx& mrEscherEx; /// Reference to the DFF converter containing the DFF stream.
126 sal_uInt32 mnFragmentKey; /// The key of the DFF stream fragment to be written by this record.
129 /** The MSODRAWINGGROUP record contains the DGGCONTAINER with global DFF data
130 such as the picture container.
132 class XclExpMsoDrawingGroup : public XclExpMsoDrawingBase
134 public:
135 explicit XclExpMsoDrawingGroup( XclEscherEx& rEscherEx );
138 /** One or more MSODRAWING records contain the DFF stream data for a drawing
139 shape.
141 class XclExpMsoDrawing : public XclExpMsoDrawingBase
143 public:
144 explicit XclExpMsoDrawing( XclEscherEx& rEscherEx );
147 /** Provides export of bitmap data to an IMGDATA record. */
148 class XclExpImgData : public XclExpRecordBase
150 public:
151 explicit XclExpImgData( const Graphic& rGraphic, sal_uInt16 nRecId );
153 /** Writes the BITMAP record. */
154 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
155 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
157 private:
158 Graphic maGraphic; /// The VCL graphic.
159 sal_uInt16 mnRecId; /// Record identifier for the IMGDATA record.
162 /** Helper class for form controils to manage spreadsheet links . */
163 class XclExpControlHelper : protected XclExpRoot
165 public:
166 explicit XclExpControlHelper( const XclExpRoot& rRoot );
167 virtual ~XclExpControlHelper();
169 protected:
170 /** Tries to get spreadsheet cell link and source range link from the passed shape. */
171 void ConvertSheetLinks(
172 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
174 /** Returns the Excel token array of the cell link, or 0, if no link present. */
175 inline const XclTokenArray* GetCellLinkTokArr() const { return mxCellLink.get(); }
176 /** Returns the Excel token array of the source range, or 0, if no link present. */
177 inline const XclTokenArray* GetSourceRangeTokArr() const { return mxSrcRange.get(); }
178 /** Returns the number of entries in the source range, or 0, if no source set. */
179 inline sal_uInt16 GetSourceEntryCount() const { return mnEntryCount; }
181 /** Writes a formula with special style only valid in OBJ records. */
182 static void WriteFormula( XclExpStream& rStrm, const XclTokenArray& rTokArr );
183 /** Writes a formula subrecord with special style only valid in OBJ records. */
184 static void WriteFormulaSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId, const XclTokenArray& rTokArr );
186 private:
187 XclTokenArrayRef mxCellLink; /// Formula for linked cell.
188 XclTokenArrayRef mxSrcRange; /// Formula for source data range.
189 sal_uInt16 mnEntryCount; /// Number of entries in source range.
192 class XclMacroHelper : public XclExpControlHelper
194 protected:
195 XclTokenArrayRef mxMacroLink; /// Token array containing a link to an attached macro.
197 public:
198 explicit XclMacroHelper( const XclExpRoot& rRoot );
199 virtual ~XclMacroHelper();
200 /** Writes an ftMacro subrecord containing a macro link, or nothing, if no macro present. */
201 void WriteMacroSubRec( XclExpStream& rStrm );
202 /** Sets the name of a macro for object of passed type
203 @return true = The passed event descriptor was valid, macro name has been found. */
204 bool SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent, const XclTbxEventType& nEventType );
206 /** Sets the name of a macro
207 @return true = The passed macro name has been found. */
208 bool SetMacroLink( const OUString& rMacro );
211 class XclExpShapeObj : public XclObjAny, public XclMacroHelper
213 public:
214 explicit XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
215 virtual ~XclExpShapeObj();
216 private:
217 virtual void WriteSubRecs( XclExpStream& rStrm ) SAL_OVERRIDE;
220 //delete for exporting OCX
221 //#if EXC_EXP_OCX_CTRL
223 /** Represents an OBJ record for an OCX form control. */
224 class XclExpOcxControlObj : public XclObj, public XclExpControlHelper
226 public:
227 explicit XclExpOcxControlObj(
228 XclExpObjectManager& rObjMgr,
229 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
230 const Rectangle* pChildAnchor,
231 const OUString& rClassName,
232 sal_uInt32 nStrmStart, sal_uInt32 nStrmSize );
234 private:
235 virtual void WriteSubRecs( XclExpStream& rStrm ) SAL_OVERRIDE;
237 private:
238 OUString maClassName; /// Class name of the control.
239 sal_uInt32 mnStrmStart; /// Start position in 'Ctls' stream.
240 sal_uInt32 mnStrmSize; /// Size in 'Ctls' stream.
243 //#else
245 /** Represents an OBJ record for an TBX form control. */
246 class XclExpTbxControlObj : public XclObj, public XclMacroHelper
248 public:
249 explicit XclExpTbxControlObj(
250 XclExpObjectManager& rObjMgr,
251 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
252 const Rectangle* pChildAnchor );
254 /** Sets the name of a macro attached to this control.
255 @return true = The passed event descriptor was valid, macro name has been found. */
256 bool SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent );
258 private:
259 virtual void WriteSubRecs( XclExpStream& rStrm ) SAL_OVERRIDE;
261 /** Writes a subrecord containing a cell link, or nothing, if no link present. */
262 void WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId );
263 /** Writes the ftSbs sub structure containing scrollbar data. */
264 void WriteSbs( XclExpStream& rStrm );
266 private:
267 ScfInt16Vec maMultiSel; /// Indexes of all selected entries in a multi selection.
268 XclTbxEventType meEventType; /// Type of supported macro event.
269 sal_Int32 mnHeight; /// Height of the control.
270 sal_uInt16 mnState; /// Checked/unchecked state.
271 sal_Int16 mnLineCount; /// Combobox dropdown line count.
272 sal_Int16 mnSelEntry; /// Selected entry in combobox (1-based).
273 sal_uInt16 mnScrollValue; /// Scrollbar: Current value.
274 sal_uInt16 mnScrollMin; /// Scrollbar: Minimum value.
275 sal_uInt16 mnScrollMax; /// Scrollbar: Maximum value.
276 sal_uInt16 mnScrollStep; /// Scrollbar: Single step.
277 sal_uInt16 mnScrollPage; /// Scrollbar: Page step.
278 bool mbFlatButton; /// False = 3D button style; True = Flat button style.
279 bool mbFlatBorder; /// False = 3D border style; True = Flat border style.
280 bool mbMultiSel; /// true = Multi selection in listbox.
281 bool mbScrollHor; /// Scrollbar: true = horizontal.
284 //#endif
286 class XclExpChart;
288 /** A chart object. This is the drawing object wrapper for the chart data. */
289 class XclExpChartObj : public XclObj, protected XclExpRoot
291 public:
292 typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDocument > XChartDocRef;
293 typedef ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > XShapeRef;
294 explicit XclExpChartObj(
295 XclExpObjectManager& rObjMgr,
296 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
297 const Rectangle* pChildAnchor );
298 virtual ~XclExpChartObj();
300 /** Writes the OBJ record and the entire chart substream. */
301 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
302 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
304 const css::uno::Reference<css::chart::XChartDocument>& GetChartDoc() const;
306 private:
307 typedef std::shared_ptr< XclExpChart > XclExpChartRef;
308 XclExpChartRef mxChart; /// The chart itself (BOF/EOF substream data).
309 XShapeRef mxShape;
310 XChartDocRef mxChartDoc;
313 /** Represents a NOTE record containing the relevant data of a cell note.
315 NOTE records differ significantly in various BIFF versions. This class
316 encapsulates all needed actions for each supported BIFF version.
317 BIFF5/BIFF7: Stores the note text and generates a single or multiple NOTE
318 records on saving.
319 BIFF8: Creates the Escher object containing the drawing information and the
320 note text.
322 class XclExpNote : public XclExpRecord
324 public:
325 /** Constructs a NOTE record from the passed note object and/or the text.
326 @descr The additional text will be separated from the note text with
327 an empty line.
328 @param rScPos The Calc cell address of the note.
329 @param pScNote The Calc note object. May be 0 to create a note from rAddText only.
330 @param rAddText Additional text appended to the note text. */
331 explicit XclExpNote(
332 const XclExpRoot& rRoot,
333 const ScAddress& rScPos,
334 const ScPostIt* pScNote,
335 const OUString& rAddText );
337 /** Writes the NOTE record, if the respective Escher object is present. */
338 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
340 void WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm );
342 const XclExpString& GetAuthor() const { return maAuthor; }
343 private:
344 /** Writes the body of the NOTE record. */
345 virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
347 private:
348 XclExpString maAuthor; /// Name of the author.
349 OUString maOrigNoteText; /// Original main text of the note.
350 OString maNoteText; /// Main text of the note (<=BIFF7).
351 XclExpStringRef mpNoteContents; /// Text and formatting data (OOXML)
352 ScAddress maScPos; /// Calc cell address of the note.
353 sal_uInt16 mnObjId; /// Escher object ID (BIFF8).
354 bool mbVisible; /// true = permanently visible.
355 SdrTextHorzAdjust meTHA; /// text horizontal adjust
356 SdrTextVertAdjust meTVA; /// text vertical adjust
357 bool mbAutoScale; /// Auto scale text
358 bool mbLocked; /// Position & Size locked
359 bool mbAutoFill; /// Auto Fill Style
360 bool mbAutoLine; /// Auto Line Style
361 bool mbColHidden; /// Column containing the comment is hidden
362 bool mbRowHidden; /// Row containing the comment is hidden
363 Rectangle maCommentFrom; /// From and From Offset
364 Rectangle maCommentTo; /// To and To Offsets
367 class XclExpComments : public XclExpRecord
369 public:
370 typedef XclExpRecordList< XclExpNote >
371 XclExpNoteList;
373 XclExpComments( SCTAB nTab, XclExpNoteList& rNotes );
375 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
377 private:
378 SCTAB mnTab;
379 XclExpNoteList& mrNotes;
382 // object manager =============================================================
384 class XclExpObjectManager : public XclExpRoot
386 public:
387 explicit XclExpObjectManager( const XclExpRoot& rRoot );
388 virtual ~XclExpObjectManager();
390 /** Creates a new DFF client anchor object. Caller takes ownership! May be
391 overwritten in derived classes. */
392 virtual XclExpDffAnchorBase* CreateDffAnchor() const;
394 /** Creates and returns the MSODRAWINGGROUP record containing global DFF
395 data in the DGGCONTAINER. */
396 std::shared_ptr< XclExpRecordBase > CreateDrawingGroup();
398 /** Initializes the object manager for a new sheet. */
399 void StartSheet();
401 /** Processes a drawing page and returns the record block containing all
402 related records (MSODRAWING, OBJ, TXO, charts, etc.). */
403 std::shared_ptr< XclExpRecordBase > ProcessDrawing( SdrPage* pSdrPage );
404 /** Processes a collection of UNO shapes and returns the record block
405 containing all related records (MSODRAWING, OBJ, TXO, charts, etc.). */
406 std::shared_ptr< XclExpRecordBase > ProcessDrawing( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes );
408 /** Finalizes the object manager after conversion of all sheets. */
409 void EndDocument();
411 inline XclEscherEx& GetEscherEx() { return *mxEscherEx; }
412 XclExpMsoDrawing* GetMsodrawingPerSheet();
413 bool HasObj() const;
414 sal_uInt16 AddObj( XclObj* pObjRec );
415 XclObj* RemoveLastObj();
417 protected:
418 explicit XclExpObjectManager( const XclExpObjectManager& rParent );
420 private:
421 void InitStream( bool bTempFile );
423 private:
424 std::shared_ptr< ::utl::TempFile > mxTempFile;
425 std::shared_ptr< SvStream > mxDffStrm;
426 std::shared_ptr< XclEscherEx > mxEscherEx;
427 std::shared_ptr< XclExpObjList > mxObjList;
430 class XclExpEmbeddedObjectManager : public XclExpObjectManager
432 public:
433 explicit XclExpEmbeddedObjectManager(
434 const XclExpObjectManager& rParent,
435 const Size& rPageSize,
436 sal_Int32 nScaleX, sal_Int32 nScaleY );
438 /** Creates a new DFF client anchor object for embedded objects according
439 to the scaling data passed to the constructor. Caller takes ownership! */
440 virtual XclExpDffAnchorBase* CreateDffAnchor() const SAL_OVERRIDE;
442 private:
443 Size maPageSize;
444 sal_Int32 mnScaleX;
445 sal_Int32 mnScaleY;
448 #endif
450 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */