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