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