merged tag ooo/OOO330_m14
[LibreOffice.git] / sc / source / filter / inc / xlescher.hxx
blob921da6b8741b81e94d99fd35afc8c7128fbb9a6c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SC_XLESCHER_HXX
29 #define SC_XLESCHER_HXX
31 #include <tools/gen.hxx>
32 #include <vcl/mapunit.hxx>
33 #include "fapihelper.hxx"
34 #include "xladdress.hxx"
35 #include "xlstyle.hxx"
37 namespace com { namespace sun { namespace star {
38 namespace drawing { class XShape; }
39 namespace awt { class XControlModel; }
40 namespace script { struct ScriptEventDescriptor; }
41 } } }
43 class SdrObject;
44 class Rectangle;
45 class ScDocument;
46 class SvStream;
47 class XclImpStream;
48 class XclExpStream;
50 // Constants and Enumerations =================================================
52 // (0x001C) NOTE --------------------------------------------------------------
54 const sal_uInt16 EXC_ID_NOTE = 0x001C;
55 const sal_uInt16 EXC_NOTE_VISIBLE = 0x0002;
56 const sal_uInt16 EXC_NOTE5_MAXLEN = 2048;
58 // (0x005D) OBJ ---------------------------------------------------------------
60 const sal_uInt16 EXC_ID_OBJ = 0x005D;
62 const sal_uInt16 EXC_OBJ_INVALID_ID = 0;
64 // object types
65 const sal_uInt16 EXC_OBJTYPE_GROUP = 0;
66 const sal_uInt16 EXC_OBJTYPE_LINE = 1;
67 const sal_uInt16 EXC_OBJTYPE_RECTANGLE = 2;
68 const sal_uInt16 EXC_OBJTYPE_OVAL = 3;
69 const sal_uInt16 EXC_OBJTYPE_ARC = 4;
70 const sal_uInt16 EXC_OBJTYPE_CHART = 5;
71 const sal_uInt16 EXC_OBJTYPE_TEXT = 6;
72 const sal_uInt16 EXC_OBJTYPE_BUTTON = 7;
73 const sal_uInt16 EXC_OBJTYPE_PICTURE = 8;
74 const sal_uInt16 EXC_OBJTYPE_POLYGON = 9; // new in BIFF4
75 const sal_uInt16 EXC_OBJTYPE_CHECKBOX = 11; // new in BIFF5
76 const sal_uInt16 EXC_OBJTYPE_OPTIONBUTTON = 12;
77 const sal_uInt16 EXC_OBJTYPE_EDIT = 13;
78 const sal_uInt16 EXC_OBJTYPE_LABEL = 14;
79 const sal_uInt16 EXC_OBJTYPE_DIALOG = 15;
80 const sal_uInt16 EXC_OBJTYPE_SPIN = 16;
81 const sal_uInt16 EXC_OBJTYPE_SCROLLBAR = 17;
82 const sal_uInt16 EXC_OBJTYPE_LISTBOX = 18;
83 const sal_uInt16 EXC_OBJTYPE_GROUPBOX = 19;
84 const sal_uInt16 EXC_OBJTYPE_DROPDOWN = 20;
85 const sal_uInt16 EXC_OBJTYPE_NOTE = 25; // new in BIFF8
86 const sal_uInt16 EXC_OBJTYPE_DRAWING = 30;
87 const sal_uInt16 EXC_OBJTYPE_UNKNOWN = 0xFFFF; /// For internal use only.
89 // BIFF3-BIFF5 flags
90 const sal_uInt16 EXC_OBJ_HIDDEN = 0x0100;
91 const sal_uInt16 EXC_OBJ_VISIBLE = 0x0200;
92 const sal_uInt16 EXC_OBJ_PRINTABLE = 0x0400;
94 // BIFF5 line formatting
95 const sal_uInt8 EXC_OBJ_LINE_AUTOCOLOR = 64;
97 const sal_uInt8 EXC_OBJ_LINE_SOLID = 0;
98 const sal_uInt8 EXC_OBJ_LINE_DASH = 1;
99 const sal_uInt8 EXC_OBJ_LINE_DOT = 2;
100 const sal_uInt8 EXC_OBJ_LINE_DASHDOT = 3;
101 const sal_uInt8 EXC_OBJ_LINE_DASHDOTDOT = 4;
102 const sal_uInt8 EXC_OBJ_LINE_MEDTRANS = 5;
103 const sal_uInt8 EXC_OBJ_LINE_DARKTRANS = 6;
104 const sal_uInt8 EXC_OBJ_LINE_LIGHTTRANS = 7;
105 const sal_uInt8 EXC_OBJ_LINE_NONE = 255;
107 const sal_uInt8 EXC_OBJ_LINE_HAIR = 0;
108 const sal_uInt8 EXC_OBJ_LINE_THIN = 1;
109 const sal_uInt8 EXC_OBJ_LINE_MEDIUM = 2;
110 const sal_uInt8 EXC_OBJ_LINE_THICK = 3;
112 const sal_uInt8 EXC_OBJ_LINE_AUTO = 0x01;
114 const sal_uInt8 EXC_OBJ_ARROW_NONE = 0;
115 const sal_uInt8 EXC_OBJ_ARROW_OPEN = 1;
116 const sal_uInt8 EXC_OBJ_ARROW_FILLED = 2;
117 const sal_uInt8 EXC_OBJ_ARROW_OPENBOTH = 3;
118 const sal_uInt8 EXC_OBJ_ARROW_FILLEDBOTH = 4;
120 const sal_uInt8 EXC_OBJ_ARROW_NARROW = 0;
121 const sal_uInt8 EXC_OBJ_ARROW_MEDIUM = 1;
122 const sal_uInt8 EXC_OBJ_ARROW_WIDE = 2;
124 const sal_uInt8 EXC_OBJ_LINE_TL = 0;
125 const sal_uInt8 EXC_OBJ_LINE_TR = 1;
126 const sal_uInt8 EXC_OBJ_LINE_BR = 2;
127 const sal_uInt8 EXC_OBJ_LINE_BL = 3;
129 // BIFF5 fill formatting
130 const sal_uInt8 EXC_OBJ_FILL_AUTOCOLOR = 65;
132 const sal_uInt8 EXC_OBJ_FILL_AUTO = 0x01;
134 // BIFF5 frame formatting
135 const sal_uInt16 EXC_OBJ_FRAME_SHADOW = 0x0002;
137 // BIFF5 text objects
138 const sal_uInt8 EXC_OBJ_HOR_LEFT = 1;
139 const sal_uInt8 EXC_OBJ_HOR_CENTER = 2;
140 const sal_uInt8 EXC_OBJ_HOR_RIGHT = 3;
141 const sal_uInt8 EXC_OBJ_HOR_JUSTIFY = 4;
143 const sal_uInt8 EXC_OBJ_VER_TOP = 1;
144 const sal_uInt8 EXC_OBJ_VER_CENTER = 2;
145 const sal_uInt8 EXC_OBJ_VER_BOTTOM = 3;
146 const sal_uInt8 EXC_OBJ_VER_JUSTIFY = 4;
148 const sal_uInt16 EXC_OBJ_ORIENT_NONE = 0;
149 const sal_uInt16 EXC_OBJ_ORIENT_STACKED = 1; /// Stacked top to bottom.
150 const sal_uInt16 EXC_OBJ_ORIENT_90CCW = 2; /// 90 degr. counterclockwise.
151 const sal_uInt16 EXC_OBJ_ORIENT_90CW = 3; /// 90 degr. clockwise.
153 const sal_uInt16 EXC_OBJ_TEXT_AUTOSIZE = 0x0080;
154 const sal_uInt16 EXC_OBJ_TEXT_LOCKED = 0x0200;
156 const sal_Int32 EXC_OBJ_TEXT_MARGIN = 20000; /// Automatic text margin (EMUs).
158 // BIFF5 arc objects
159 const sal_uInt8 EXC_OBJ_ARC_TR = 0;
160 const sal_uInt8 EXC_OBJ_ARC_TL = 1;
161 const sal_uInt8 EXC_OBJ_ARC_BL = 2;
162 const sal_uInt8 EXC_OBJ_ARC_BR = 3;
164 // BIFF5 polygon objects
165 const sal_uInt16 EXC_OBJ_POLY_CLOSED = 0x0100;
167 // BIFF5 pictures/OLE objects
168 const sal_uInt16 EXC_OBJ_PIC_MANUALSIZE = 0x0001;
169 const sal_uInt16 EXC_OBJ_PIC_DDE = 0x0002;
170 const sal_uInt16 EXC_OBJ_PIC_SYMBOL = 0x0008;
171 const sal_uInt16 EXC_OBJ_PIC_CONTROL = 0x0010; /// Form control (BIFF8).
172 const sal_uInt16 EXC_OBJ_PIC_CTLSSTREAM = 0x0020; /// Data in Ctls stream (BIFF8).
173 const sal_uInt16 EXC_OBJ_PIC_AUTOLOAD = 0x0200; /// Auto-load form control (BIFF8).
175 // BIFF5 button objects
176 const sal_uInt16 EXC_OBJ_BUTTON_DEFAULT = 0x0001;
177 const sal_uInt16 EXC_OBJ_BUTTON_HELP = 0x0002;
178 const sal_uInt16 EXC_OBJ_BUTTON_CANCEL = 0x0004;
179 const sal_uInt16 EXC_OBJ_BUTTON_CLOSE = 0x0008;
181 // BIFF5 checkboxs, radio buttons
182 const sal_uInt16 EXC_OBJ_CHECKBOX_UNCHECKED = 0;
183 const sal_uInt16 EXC_OBJ_CHECKBOX_CHECKED = 1;
184 const sal_uInt16 EXC_OBJ_CHECKBOX_TRISTATE = 2;
185 const sal_uInt16 EXC_OBJ_CHECKBOX_FLAT = 0x0001;
187 // BIFF5 editbox objects
188 const sal_uInt16 EXC_OBJ_EDIT_TEXT = 0;
189 const sal_uInt16 EXC_OBJ_EDIT_INTEGER = 1;
190 const sal_uInt16 EXC_OBJ_EDIT_DOUBLE = 2;
191 const sal_uInt16 EXC_OBJ_EDIT_REFERENCE = 3;
192 const sal_uInt16 EXC_OBJ_EDIT_FORMULA = 4;
194 // BIFF5 scrollbars/spinbuttons
195 const sal_uInt16 EXC_OBJ_SCROLLBAR_MIN = 0;
196 const sal_uInt16 EXC_OBJ_SCROLLBAR_MAX = 30000;
198 const sal_uInt16 EXC_OBJ_SCROLLBAR_HOR = 0x0001;
200 const sal_uInt16 EXC_OBJ_SCROLLBAR_DEFFLAGS = 0x0001;
201 const sal_uInt16 EXC_OBJ_SCROLLBAR_FLAT = 0x0008;
203 // BIFF5 listboxes/dropdowns
204 const sal_uInt8 EXC_OBJ_LISTBOX_SINGLE = 0; /// Single selection.
205 const sal_uInt8 EXC_OBJ_LISTBOX_MULTI = 1; /// Multi selection.
206 const sal_uInt8 EXC_OBJ_LISTBOX_RANGE = 2; /// Range selection.
208 const sal_uInt16 EXC_OBJ_LISTBOX_EDIT = 0x0002;
209 const sal_uInt16 EXC_OBJ_LISTBOX_FLAT = 0x0008;
211 // BIFF5 dropdown listboxes
212 const sal_uInt16 EXC_OBJ_DROPDOWN_LISTBOX = 0; /// Listbox, text not editable.
213 const sal_uInt16 EXC_OBJ_DROPDOWN_COMBOBOX = 1; /// Dropdown listbox with editable text.
214 const sal_uInt16 EXC_OBJ_DROPDOWN_SIMPLE = 2; /// Dropdown button only, no text area.
215 const sal_uInt16 EXC_OBJ_DROPDOWN_MAX = 3;
216 const sal_uInt16 EXC_OBJ_DROPDOWN_FILTERED = 0x0008; /// Drowdown style: filtered.
218 // BIFF5 groupboxes
219 const sal_uInt16 EXC_OBJ_GROUPBOX_FLAT = 0x0001;
221 // BIFF8 sub records
222 const sal_uInt16 EXC_ID_OBJEND = 0x0000; /// End of OBJ.
223 const sal_uInt16 EXC_ID_OBJMACRO = 0x0004; /// Macro link.
224 const sal_uInt16 EXC_ID_OBJBUTTON = 0x0005; /// Button data.
225 const sal_uInt16 EXC_ID_OBJGMO = 0x0006; /// Group marker.
226 const sal_uInt16 EXC_ID_OBJCF = 0x0007; /// Clipboard format.
227 const sal_uInt16 EXC_ID_OBJFLAGS = 0x0008; /// Option flags.
228 const sal_uInt16 EXC_ID_OBJPICTFMLA = 0x0009; /// OLE link formula.
229 const sal_uInt16 EXC_ID_OBJCBLS = 0x000A; /// Check box/radio button data.
230 const sal_uInt16 EXC_ID_OBJRBO = 0x000B; /// Radio button group data.
231 const sal_uInt16 EXC_ID_OBJSBS = 0x000C; /// Scroll bar data.
232 const sal_uInt16 EXC_ID_OBJNTS = 0x000D; /// Note data.
233 const sal_uInt16 EXC_ID_OBJSBSFMLA = 0x000E; /// Scroll bar/list box/combo box cell link.
234 const sal_uInt16 EXC_ID_OBJGBODATA = 0x000F; /// Group box data.
235 const sal_uInt16 EXC_ID_OBJEDODATA = 0x0010; /// Edit box data.
236 const sal_uInt16 EXC_ID_OBJRBODATA = 0x0011; /// Radio button group data.
237 const sal_uInt16 EXC_ID_OBJCBLSDATA = 0x0012; /// Check box/radio button data.
238 const sal_uInt16 EXC_ID_OBJLBSDATA = 0x0013; /// List box/combo box data.
239 const sal_uInt16 EXC_ID_OBJCBLSFMLA = 0x0014; /// Check box/radio button cell link.
240 const sal_uInt16 EXC_ID_OBJCMO = 0x0015; /// Common object settings.
241 const sal_uInt16 EXC_ID_OBJUNKNOWN = 0xFFFF; /// For internal use only.
243 // BIFF8 OBJCMO: flags
244 const sal_uInt16 EXC_OBJCMO_PRINTABLE = 0x0010; /// Object printable.
245 const sal_uInt16 EXC_OBJCMO_AUTOLINE = 0x2000; /// Automatic line formatting.
246 const sal_uInt16 EXC_OBJCMO_AUTOFILL = 0x4000; /// Automatic fill formatting.
248 /** Value binding mode for cells linked to form controls. */
249 enum XclCtrlBindMode
251 EXC_CTRL_BINDCONTENT, /// Binds cell to content of control.
252 EXC_CTRL_BINDPOSITION /// Binds cell to position in control (e.g. listbox selection index).
255 // (0x007F) IMGDATA -----------------------------------------------------------
257 const sal_uInt16 EXC_ID3_IMGDATA = 0x007F;
258 const sal_uInt16 EXC_ID8_IMGDATA = 0x00E9;
260 const sal_uInt16 EXC_IMGDATA_WMF = 2;
261 const sal_uInt16 EXC_IMGDATA_BMP = 9;
263 const sal_uInt16 EXC_IMGDATA_WIN = 1;
264 const sal_uInt16 EXC_IMGDATA_MAC = 2;
266 const sal_uInt32 EXC_IMGDATA_MAXREC8 = 0x201C;
267 const sal_uInt32 EXC_IMGDATA_MAXCONT8 = 0x2014;
269 // (0x00A9) COORDLIST ---------------------------------------------------------
271 const sal_uInt16 EXC_ID_COORDLIST = 0x00A9;
273 // (0x00EB) MSODRAWINGGROUP ---------------------------------------------------
275 const sal_uInt16 EXC_ID_MSODRAWINGGROUP = 0x00EB;
277 // (0x00EC) MSODRAWING --------------------------------------------------------
279 const sal_uInt16 EXC_ID_MSODRAWING = 0x00EC;
281 // additional flags not extant in svx headers
282 const sal_uInt16 EXC_ESC_ANCHOR_POSLOCKED = 0x0001;
283 const sal_uInt16 EXC_ESC_ANCHOR_SIZELOCKED = 0x0002;
284 const sal_uInt16 EXC_ESC_ANCHOR_LOCKED = EXC_ESC_ANCHOR_POSLOCKED|EXC_ESC_ANCHOR_SIZELOCKED;
286 // (0x00ED) MSODRAWINGSELECTION -----------------------------------------------
288 const sal_uInt16 EXC_ID_MSODRAWINGSEL = 0x00ED;
290 // (0x01B6) TXO ---------------------------------------------------------------
292 const sal_uInt16 EXC_ID_TXO = 0x01B6;
294 // TXO constants are eqzal to BIFF5 OBJ text object flags
296 // Structs and classes ========================================================
298 /** Identifies a drawing object by sheet index and object identifier. */
299 struct XclObjId
301 SCTAB mnScTab; /// Calc sheet index.
302 sal_uInt16 mnObjId; /// Excel object identifier.
304 explicit XclObjId();
305 explicit XclObjId( SCTAB nScTab, sal_uInt16 nObjId );
308 bool operator==( const XclObjId& rL, const XclObjId& rR );
309 bool operator<( const XclObjId& rL, const XclObjId& rR );
311 // ----------------------------------------------------------------------------
313 /** Represents the position (anchor) of an object in a Calc document. */
314 struct XclObjAnchor : public XclRange
316 sal_uInt16 mnLX; /// X offset in left column (1/1024 of column width).
317 sal_uInt16 mnTY; /// Y offset in top row (1/256 of row height).
318 sal_uInt16 mnRX; /// X offset in right column (1/1024 of column width).
319 sal_uInt16 mnBY; /// Y offset in bottom row (1/256 of row height).
321 explicit XclObjAnchor();
323 /** Calculates a rectangle from the contained coordinates. */
324 Rectangle GetRect( const XclRoot& rRoot, SCTAB nScTab, MapUnit eMapUnit ) const;
325 /** Initializes the anchor coordinates for a sheet. */
326 void SetRect( const XclRoot& rRoot, SCTAB nScTab, const Rectangle& rRect, MapUnit eMapUnit );
328 /** Initializes the anchor coordinates for an embedded draw page. */
329 void SetRect( const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY,
330 const Rectangle& rRect, MapUnit eMapUnit, bool bDffAnchor );
333 template< typename StreamType >
334 StreamType& operator>>( StreamType& rStrm, XclObjAnchor& rAnchor )
336 return rStrm
337 >> rAnchor.maFirst.mnCol >> rAnchor.mnLX
338 >> rAnchor.maFirst.mnRow >> rAnchor.mnTY
339 >> rAnchor.maLast.mnCol >> rAnchor.mnRX
340 >> rAnchor.maLast.mnRow >> rAnchor.mnBY;
343 template< typename StreamType >
344 StreamType& operator<<( StreamType& rStrm, const XclObjAnchor& rAnchor )
346 return rStrm
347 << rAnchor.maFirst.mnCol << rAnchor.mnLX
348 << rAnchor.maFirst.mnRow << rAnchor.mnTY
349 << rAnchor.maLast.mnCol << rAnchor.mnRX
350 << rAnchor.maLast.mnRow << rAnchor.mnBY;
353 // ----------------------------------------------------------------------------
355 struct XclObjLineData
357 sal_uInt8 mnColorIdx;
358 sal_uInt8 mnStyle;
359 sal_uInt8 mnWidth;
360 sal_uInt8 mnAuto;
362 explicit XclObjLineData();
364 inline bool IsAuto() const { return ::get_flag( mnAuto, EXC_OBJ_LINE_AUTO ); }
365 inline bool IsVisible() const { return IsAuto() || (mnStyle != EXC_OBJ_LINE_NONE); }
368 XclImpStream& operator>>( XclImpStream& rStrm, XclObjLineData& rLineData );
370 // ----------------------------------------------------------------------------
372 struct XclObjFillData
374 sal_uInt8 mnBackColorIdx;
375 sal_uInt8 mnPattColorIdx;
376 sal_uInt8 mnPattern;
377 sal_uInt8 mnAuto;
379 explicit XclObjFillData();
381 inline bool IsAuto() const { return ::get_flag( mnAuto, EXC_OBJ_FILL_AUTO ); }
382 inline bool IsFilled() const { return IsAuto() || (mnPattern != EXC_PATT_NONE); }
385 XclImpStream& operator>>( XclImpStream& rStrm, XclObjFillData& rFillData );
387 // ----------------------------------------------------------------------------
389 struct XclObjTextData
391 sal_uInt16 mnTextLen;
392 sal_uInt16 mnFormatSize;
393 sal_uInt16 mnLinkSize;
394 sal_uInt16 mnDefFontIdx;
395 sal_uInt16 mnFlags;
396 sal_uInt16 mnOrient;
397 sal_uInt16 mnButtonFlags;
398 sal_uInt16 mnShortcut;
399 sal_uInt16 mnShortcutEA;
401 explicit XclObjTextData();
403 /** Reads text data from a BIFF3/BIFF4 OBJ record. */
404 void ReadObj3( XclImpStream& rStrm );
405 /** Reads text data from a BIFF5 OBJ record. */
406 void ReadObj5( XclImpStream& rStrm );
407 /** Reads text data from a BIFF8 TXO record. */
408 void ReadTxo8( XclImpStream& rStrm );
410 inline sal_uInt8 GetHorAlign() const { return ::extract_value< sal_uInt8 >( mnFlags, 1, 3 ); }
411 inline sal_uInt8 GetVerAlign() const { return ::extract_value< sal_uInt8 >( mnFlags, 4, 3 ); }
414 // ============================================================================
416 enum XclTbxEventType
418 EXC_TBX_EVENT_ACTION, /// XActionListener.actionPerformed
419 EXC_TBX_EVENT_MOUSE, /// XMouseListener.mouseReleased
420 EXC_TBX_EVENT_TEXT, /// XTextListener.textChanged
421 EXC_TBX_EVENT_VALUE, /// XAdjustmentListener.adjustmentValueChanged
422 EXC_TBX_EVENT_CHANGE /// XChangeListener.changed
425 // ----------------------------------------------------------------------------
427 /** Provides static helper functions for form controls. */
428 class XclControlHelper
430 public:
431 /** Returns the API control model from the passed API shape object. */
432 static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
433 GetControlModel( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
435 /** Fills the macro descriptor according to the passed macro name. */
436 static bool FillMacroDescriptor(
437 ::com::sun::star::script::ScriptEventDescriptor& rDescriptor,
438 XclTbxEventType eEventType,
439 const String& rXclMacroName,
440 SfxObjectShell* pDocShell = 0 );
441 /** Tries to extract an Excel macro name from the passed macro descriptor. */
442 static String ExtractFromMacroDescriptor(
443 const ::com::sun::star::script::ScriptEventDescriptor& rDescriptor,
444 XclTbxEventType eEventType );
447 // ============================================================================
449 #endif