Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / xlescher.hxx
blob913f667593eab3899be7acd997894f92d29a1a32
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 #pragma once
22 #include <tools/gen.hxx>
23 #include <tools/mapunit.hxx>
24 #include "xladdress.hxx"
25 #include "xlstyle.hxx"
26 #include "xistream.hxx"
28 namespace com::sun::star {
29 namespace drawing { class XShape; }
30 namespace awt { class XControlModel; }
31 namespace script { struct ScriptEventDescriptor; }
34 // Constants and Enumerations =================================================
36 // (0x001C) NOTE --------------------------------------------------------------
38 const sal_uInt16 EXC_ID_NOTE = 0x001C;
39 const sal_uInt16 EXC_NOTE_VISIBLE = 0x0002;
40 const sal_uInt16 EXC_NOTE5_MAXLEN = 2048;
42 // (0x005D) OBJ ---------------------------------------------------------------
44 const sal_uInt16 EXC_ID_OBJ = 0x005D;
46 const sal_uInt16 EXC_OBJ_INVALID_ID = 0;
48 // object types
49 const sal_uInt16 EXC_OBJTYPE_GROUP = 0;
50 const sal_uInt16 EXC_OBJTYPE_LINE = 1;
51 const sal_uInt16 EXC_OBJTYPE_RECTANGLE = 2;
52 const sal_uInt16 EXC_OBJTYPE_OVAL = 3;
53 const sal_uInt16 EXC_OBJTYPE_ARC = 4;
54 const sal_uInt16 EXC_OBJTYPE_CHART = 5;
55 const sal_uInt16 EXC_OBJTYPE_TEXT = 6;
56 const sal_uInt16 EXC_OBJTYPE_BUTTON = 7;
57 const sal_uInt16 EXC_OBJTYPE_PICTURE = 8;
58 const sal_uInt16 EXC_OBJTYPE_POLYGON = 9; // new in BIFF4
59 const sal_uInt16 EXC_OBJTYPE_CHECKBOX = 11; // new in BIFF5
60 const sal_uInt16 EXC_OBJTYPE_OPTIONBUTTON = 12;
61 const sal_uInt16 EXC_OBJTYPE_EDIT = 13;
62 const sal_uInt16 EXC_OBJTYPE_LABEL = 14;
63 const sal_uInt16 EXC_OBJTYPE_DIALOG = 15;
64 const sal_uInt16 EXC_OBJTYPE_SPIN = 16;
65 const sal_uInt16 EXC_OBJTYPE_SCROLLBAR = 17;
66 const sal_uInt16 EXC_OBJTYPE_LISTBOX = 18;
67 const sal_uInt16 EXC_OBJTYPE_GROUPBOX = 19;
68 const sal_uInt16 EXC_OBJTYPE_DROPDOWN = 20;
69 const sal_uInt16 EXC_OBJTYPE_NOTE = 25; // new in BIFF8
70 const sal_uInt16 EXC_OBJTYPE_DRAWING = 30;
71 const sal_uInt16 EXC_OBJTYPE_UNKNOWN = 0xFFFF; /// For internal use only.
73 // BIFF3-BIFF5 flags
74 const sal_uInt16 EXC_OBJ_HIDDEN = 0x0100;
75 const sal_uInt16 EXC_OBJ_VISIBLE = 0x0200;
76 const sal_uInt16 EXC_OBJ_PRINTABLE = 0x0400;
78 // BIFF5 line formatting
79 const sal_uInt8 EXC_OBJ_LINE_AUTOCOLOR = 64;
81 const sal_uInt8 EXC_OBJ_LINE_SOLID = 0;
82 const sal_uInt8 EXC_OBJ_LINE_DASH = 1;
83 const sal_uInt8 EXC_OBJ_LINE_DOT = 2;
84 const sal_uInt8 EXC_OBJ_LINE_DASHDOT = 3;
85 const sal_uInt8 EXC_OBJ_LINE_DASHDOTDOT = 4;
86 const sal_uInt8 EXC_OBJ_LINE_MEDTRANS = 5;
87 const sal_uInt8 EXC_OBJ_LINE_DARKTRANS = 6;
88 const sal_uInt8 EXC_OBJ_LINE_LIGHTTRANS = 7;
89 const sal_uInt8 EXC_OBJ_LINE_NONE = 255;
91 const sal_uInt8 EXC_OBJ_LINE_HAIR = 0;
92 const sal_uInt8 EXC_OBJ_LINE_THIN = 1;
93 const sal_uInt8 EXC_OBJ_LINE_MEDIUM = 2;
94 const sal_uInt8 EXC_OBJ_LINE_THICK = 3;
96 const sal_uInt8 EXC_OBJ_LINE_AUTO = 0x01;
98 const sal_uInt8 EXC_OBJ_ARROW_NONE = 0;
99 const sal_uInt8 EXC_OBJ_ARROW_OPEN = 1;
100 const sal_uInt8 EXC_OBJ_ARROW_FILLED = 2;
101 const sal_uInt8 EXC_OBJ_ARROW_OPENBOTH = 3;
102 const sal_uInt8 EXC_OBJ_ARROW_FILLEDBOTH = 4;
104 const sal_uInt8 EXC_OBJ_ARROW_NARROW = 0;
105 const sal_uInt8 EXC_OBJ_ARROW_MEDIUM = 1;
106 const sal_uInt8 EXC_OBJ_ARROW_WIDE = 2;
108 const sal_uInt8 EXC_OBJ_LINE_TL = 0;
109 const sal_uInt8 EXC_OBJ_LINE_TR = 1;
110 const sal_uInt8 EXC_OBJ_LINE_BR = 2;
111 const sal_uInt8 EXC_OBJ_LINE_BL = 3;
113 // BIFF5 fill formatting
114 const sal_uInt8 EXC_OBJ_FILL_AUTOCOLOR = 65;
116 const sal_uInt8 EXC_OBJ_FILL_AUTO = 0x01;
118 // BIFF5 frame formatting
119 const sal_uInt16 EXC_OBJ_FRAME_SHADOW = 0x0002;
121 // BIFF5 text objects
122 const sal_uInt8 EXC_OBJ_HOR_LEFT = 1;
123 const sal_uInt8 EXC_OBJ_HOR_CENTER = 2;
124 const sal_uInt8 EXC_OBJ_HOR_RIGHT = 3;
125 const sal_uInt8 EXC_OBJ_HOR_JUSTIFY = 4;
127 const sal_uInt8 EXC_OBJ_VER_TOP = 1;
128 const sal_uInt8 EXC_OBJ_VER_CENTER = 2;
129 const sal_uInt8 EXC_OBJ_VER_BOTTOM = 3;
130 const sal_uInt8 EXC_OBJ_VER_JUSTIFY = 4;
132 const sal_uInt16 EXC_OBJ_ORIENT_NONE = 0;
133 const sal_uInt16 EXC_OBJ_ORIENT_STACKED = 1; /// Stacked top to bottom.
134 const sal_uInt16 EXC_OBJ_ORIENT_90CCW = 2; /// 90 degr. counterclockwise.
135 const sal_uInt16 EXC_OBJ_ORIENT_90CW = 3; /// 90 degr. clockwise.
137 const sal_uInt16 EXC_OBJ_TEXT_AUTOSIZE = 0x0080;
138 const sal_uInt16 EXC_OBJ_TEXT_LOCKED = 0x0200;
140 const sal_Int32 EXC_OBJ_TEXT_MARGIN = 20000; /// Automatic text margin (EMUs).
142 // BIFF5 arc objects
143 const sal_uInt8 EXC_OBJ_ARC_TR = 0;
144 const sal_uInt8 EXC_OBJ_ARC_TL = 1;
145 const sal_uInt8 EXC_OBJ_ARC_BL = 2;
146 const sal_uInt8 EXC_OBJ_ARC_BR = 3;
148 // BIFF5 polygon objects
149 const sal_uInt16 EXC_OBJ_POLY_CLOSED = 0x0100;
151 // BIFF5 pictures/OLE objects
152 const sal_uInt16 EXC_OBJ_PIC_MANUALSIZE = 0x0001;
153 const sal_uInt16 EXC_OBJ_PIC_DDE = 0x0002;
154 const sal_uInt16 EXC_OBJ_PIC_SYMBOL = 0x0008;
155 const sal_uInt16 EXC_OBJ_PIC_CONTROL = 0x0010; /// Form control (BIFF8).
156 const sal_uInt16 EXC_OBJ_PIC_CTLSSTREAM = 0x0020; /// Data in Ctls stream (BIFF8).
157 const sal_uInt16 EXC_OBJ_PIC_AUTOLOAD = 0x0200; /// Auto-load form control (BIFF8).
159 // BIFF5 button objects
160 const sal_uInt16 EXC_OBJ_BUTTON_DEFAULT = 0x0001;
161 const sal_uInt16 EXC_OBJ_BUTTON_HELP = 0x0002;
162 const sal_uInt16 EXC_OBJ_BUTTON_CANCEL = 0x0004;
163 const sal_uInt16 EXC_OBJ_BUTTON_CLOSE = 0x0008;
165 // BIFF5 checkboxes, radio buttons
166 const sal_uInt16 EXC_OBJ_CHECKBOX_UNCHECKED = 0;
167 const sal_uInt16 EXC_OBJ_CHECKBOX_CHECKED = 1;
168 const sal_uInt16 EXC_OBJ_CHECKBOX_TRISTATE = 2;
169 const sal_uInt16 EXC_OBJ_CHECKBOX_FLAT = 0x0001;
171 // BIFF5 editbox objects
172 const sal_uInt16 EXC_OBJ_EDIT_TEXT = 0;
173 const sal_uInt16 EXC_OBJ_EDIT_INTEGER = 1;
174 const sal_uInt16 EXC_OBJ_EDIT_DOUBLE = 2;
175 const sal_uInt16 EXC_OBJ_EDIT_REFERENCE = 3;
176 const sal_uInt16 EXC_OBJ_EDIT_FORMULA = 4;
178 // BIFF5 scrollbars/spinbuttons
179 const sal_uInt16 EXC_OBJ_SCROLLBAR_MIN = 0;
180 const sal_uInt16 EXC_OBJ_SCROLLBAR_MAX = 30000;
182 const sal_uInt16 EXC_OBJ_SCROLLBAR_HOR = 0x0001;
184 const sal_uInt16 EXC_OBJ_SCROLLBAR_DEFFLAGS = 0x0001;
185 const sal_uInt16 EXC_OBJ_SCROLLBAR_FLAT = 0x0008;
187 // BIFF5 listboxes/dropdowns
188 const sal_uInt8 EXC_OBJ_LISTBOX_SINGLE = 0; /// Single selection.
189 const sal_uInt8 EXC_OBJ_LISTBOX_MULTI = 1; /// Multi selection.
190 const sal_uInt8 EXC_OBJ_LISTBOX_RANGE = 2; /// Range selection.
192 const sal_uInt16 EXC_OBJ_LISTBOX_EDIT = 0x0002;
193 const sal_uInt16 EXC_OBJ_LISTBOX_FLAT = 0x0008;
195 // BIFF5 dropdown listboxes
196 const sal_uInt16 EXC_OBJ_DROPDOWN_LISTBOX = 0; /// Listbox, text not editable.
197 const sal_uInt16 EXC_OBJ_DROPDOWN_COMBOBOX = 1; /// Dropdown listbox with editable text.
198 const sal_uInt16 EXC_OBJ_DROPDOWN_SIMPLE = 2; /// Dropdown button only, no text area.
199 const sal_uInt16 EXC_OBJ_DROPDOWN_MAX = 3;
200 const sal_uInt16 EXC_OBJ_DROPDOWN_FILTERED = 0x0008; /// Dropdown style: filtered.
202 // BIFF5 groupboxes
203 const sal_uInt16 EXC_OBJ_GROUPBOX_FLAT = 0x0001;
205 // BIFF8 sub records
206 const sal_uInt16 EXC_ID_OBJEND = 0x0000; /// End of OBJ.
207 const sal_uInt16 EXC_ID_OBJMACRO = 0x0004; /// Macro link.
208 const sal_uInt16 EXC_ID_OBJBUTTON = 0x0005; /// Button data.
209 const sal_uInt16 EXC_ID_OBJGMO = 0x0006; /// Group marker.
210 const sal_uInt16 EXC_ID_OBJCF = 0x0007; /// Clipboard format.
211 const sal_uInt16 EXC_ID_OBJFLAGS = 0x0008; /// Option flags.
212 const sal_uInt16 EXC_ID_OBJPICTFMLA = 0x0009; /// OLE link formula.
213 const sal_uInt16 EXC_ID_OBJCBLS = 0x000A; /// Check box/radio button data.
214 const sal_uInt16 EXC_ID_OBJRBO = 0x000B; /// Radio button group data.
215 const sal_uInt16 EXC_ID_OBJSBS = 0x000C; /// Scroll bar data.
216 const sal_uInt16 EXC_ID_OBJNTS = 0x000D; /// Note data.
217 const sal_uInt16 EXC_ID_OBJSBSFMLA = 0x000E; /// Scroll bar/list box/combo box cell link.
218 const sal_uInt16 EXC_ID_OBJGBODATA = 0x000F; /// Group box data.
219 const sal_uInt16 EXC_ID_OBJEDODATA = 0x0010; /// Edit box data.
220 const sal_uInt16 EXC_ID_OBJRBODATA = 0x0011; /// Radio button group data.
221 const sal_uInt16 EXC_ID_OBJCBLSDATA = 0x0012; /// Check box/radio button data.
222 const sal_uInt16 EXC_ID_OBJLBSDATA = 0x0013; /// List box/combo box data.
223 const sal_uInt16 EXC_ID_OBJCBLSFMLA = 0x0014; /// Check box/radio button cell link.
224 const sal_uInt16 EXC_ID_OBJCMO = 0x0015; /// Common object settings.
225 const sal_uInt16 EXC_ID_OBJUNKNOWN = 0xFFFF; /// For internal use only.
227 // BIFF8 OBJCMO: flags
228 const sal_uInt16 EXC_OBJCMO_PRINTABLE = 0x0010; /// Object printable.
229 const sal_uInt16 EXC_OBJCMO_AUTOLINE = 0x2000; /// Automatic line formatting.
230 const sal_uInt16 EXC_OBJCMO_AUTOFILL = 0x4000; /// Automatic fill formatting.
232 /** Value binding mode for cells linked to form controls. */
233 enum XclCtrlBindMode
235 EXC_CTRL_BINDCONTENT, /// Binds cell to content of control.
236 EXC_CTRL_BINDPOSITION /// Binds cell to position in control (e.g. listbox selection index).
239 // (0x007F) IMGDATA -----------------------------------------------------------
241 const sal_uInt16 EXC_ID3_IMGDATA = 0x007F;
242 const sal_uInt16 EXC_ID8_IMGDATA = 0x00E9;
244 const sal_uInt16 EXC_IMGDATA_WMF = 2;
245 const sal_uInt16 EXC_IMGDATA_BMP = 9;
247 const sal_uInt16 EXC_IMGDATA_WIN = 1;
248 const sal_uInt16 EXC_IMGDATA_MAC = 2;
250 const sal_uInt32 EXC_IMGDATA_MAXREC8 = 0x201C;
251 const sal_uInt32 EXC_IMGDATA_MAXCONT8 = 0x2014;
253 // (0x00A9) COORDLIST ---------------------------------------------------------
255 const sal_uInt16 EXC_ID_COORDLIST = 0x00A9;
257 // (0x00EB) MSODRAWINGGROUP ---------------------------------------------------
259 const sal_uInt16 EXC_ID_MSODRAWINGGROUP = 0x00EB;
261 // (0x00EC) MSODRAWING --------------------------------------------------------
263 const sal_uInt16 EXC_ID_MSODRAWING = 0x00EC;
265 // additional flags not extant in svx headers
266 const sal_uInt16 EXC_ESC_ANCHOR_POSLOCKED = 0x0001;
267 const sal_uInt16 EXC_ESC_ANCHOR_SIZELOCKED = 0x0002;
268 const sal_uInt16 EXC_ESC_ANCHOR_LOCKED = EXC_ESC_ANCHOR_POSLOCKED|EXC_ESC_ANCHOR_SIZELOCKED;
270 // (0x00ED) MSODRAWINGSELECTION -----------------------------------------------
272 const sal_uInt16 EXC_ID_MSODRAWINGSEL = 0x00ED;
274 // (0x01B6) TXO ---------------------------------------------------------------
276 const sal_uInt16 EXC_ID_TXO = 0x01B6;
278 // TXO constants are equal to BIFF5 OBJ text object flags
280 // Structs and classes ========================================================
282 /** Represents the position (anchor) of an object in a Calc document. */
283 struct XclObjAnchor : public XclRange
285 sal_uInt16 mnLX; /// X offset in left column (1/1024 of column width).
286 sal_uInt32 mnTY; /// Y offset in top row (1/256 of row height).
287 sal_uInt16 mnRX; /// X offset in right column (1/1024 of column width).
288 sal_uInt32 mnBY; /// Y offset in bottom row (1/256 of row height).
290 explicit XclObjAnchor();
292 /** Calculates a rectangle from the contained coordinates. */
293 tools::Rectangle GetRect( const XclRoot& rRoot, SCTAB nScTab, MapUnit eMapUnit ) const;
294 /** Initializes the anchor coordinates for a sheet. */
295 void SetRect( const XclRoot& rRoot, SCTAB nScTab, const tools::Rectangle& rRect, MapUnit eMapUnit );
297 /** Initializes the anchor coordinates for an embedded draw page. */
298 void SetRect( const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY,
299 const tools::Rectangle& rRect, MapUnit eMapUnit );
302 inline SvStream& operator>>( SvStream& rStrm, XclObjAnchor& rAnchor )
304 sal_uInt16 tmpFirstRow, tmpTY, tmpLastRow, tmpBY;
306 rStrm
307 .ReadUInt16( rAnchor.maFirst.mnCol ).ReadUInt16( rAnchor.mnLX )
308 .ReadUInt16( tmpFirstRow ).ReadUInt16( tmpTY )
309 .ReadUInt16( rAnchor.maLast.mnCol ).ReadUInt16( rAnchor.mnRX )
310 .ReadUInt16( tmpLastRow ).ReadUInt16( tmpBY );
312 rAnchor.maFirst.mnRow = static_cast<sal_uInt32> (tmpFirstRow);
313 rAnchor.mnTY = static_cast<sal_uInt32> (tmpTY);
314 rAnchor.maLast.mnRow = static_cast<sal_uInt32> (tmpLastRow);
315 rAnchor.mnBY = static_cast<sal_uInt32> (tmpBY);
317 return rStrm;
320 inline XclImpStream& operator>>( XclImpStream& rStrm, XclObjAnchor& rAnchor )
322 sal_uInt16 tmpFirstRow, tmpTY, tmpLastRow, tmpBY;
324 rAnchor.maFirst.mnCol = rStrm.ReaduInt16();
325 rAnchor.mnLX = rStrm.ReaduInt16();
326 tmpFirstRow = rStrm.ReaduInt16();
327 tmpTY = rStrm.ReaduInt16();
328 rAnchor.maLast.mnCol = rStrm.ReaduInt16();
329 rAnchor.mnRX = rStrm.ReaduInt16();
330 tmpLastRow = rStrm.ReaduInt16();
331 tmpBY = rStrm.ReaduInt16();
333 rAnchor.maFirst.mnRow = static_cast<sal_uInt32> (tmpFirstRow);
334 rAnchor.mnTY = static_cast<sal_uInt32> (tmpTY);
335 rAnchor.maLast.mnRow = static_cast<sal_uInt32> (tmpLastRow);
336 rAnchor.mnBY = static_cast<sal_uInt32> (tmpBY);
338 return rStrm;
341 inline SvStream& WriteXclObjAnchor( SvStream& rStrm, const XclObjAnchor& rAnchor )
343 return rStrm
344 .WriteUInt16( rAnchor.maFirst.mnCol ).WriteUInt16( rAnchor.mnLX )
345 .WriteUInt16( rAnchor.maFirst.mnRow ).WriteUInt16( rAnchor.mnTY )
346 .WriteUInt16( rAnchor.maLast.mnCol ).WriteUInt16( rAnchor.mnRX )
347 .WriteUInt16( rAnchor.maLast.mnRow).WriteUInt16(rAnchor.mnBY);
350 struct XclObjLineData
352 sal_uInt8 mnColorIdx;
353 sal_uInt8 mnStyle;
354 sal_uInt8 mnWidth;
355 sal_uInt8 mnAuto;
357 explicit XclObjLineData();
359 bool IsAuto() const { return ::get_flag( mnAuto, EXC_OBJ_LINE_AUTO ); }
360 bool IsVisible() const { return IsAuto() || (mnStyle != EXC_OBJ_LINE_NONE); }
363 XclImpStream& operator>>( XclImpStream& rStrm, XclObjLineData& rLineData );
365 struct XclObjFillData
367 sal_uInt8 mnBackColorIdx;
368 sal_uInt8 mnPattColorIdx;
369 sal_uInt8 mnPattern;
370 sal_uInt8 mnAuto;
372 explicit XclObjFillData();
374 bool IsAuto() const { return ::get_flag( mnAuto, EXC_OBJ_FILL_AUTO ); }
375 bool IsFilled() const { return IsAuto() || (mnPattern != EXC_PATT_NONE); }
378 XclImpStream& operator>>( XclImpStream& rStrm, XclObjFillData& rFillData );
380 struct XclObjTextData
382 sal_uInt16 mnTextLen;
383 sal_uInt16 mnFormatSize;
384 sal_uInt16 mnLinkSize;
385 sal_uInt16 mnDefFontIdx;
386 sal_uInt16 mnFlags;
387 sal_uInt16 mnOrient;
388 sal_uInt16 mnButtonFlags;
389 sal_uInt16 mnShortcut;
390 sal_uInt16 mnShortcutEA;
392 explicit XclObjTextData();
394 /** Reads text data from a BIFF3/BIFF4 OBJ record. */
395 void ReadObj3( XclImpStream& rStrm );
396 /** Reads text data from a BIFF5 OBJ record. */
397 void ReadObj5( XclImpStream& rStrm );
398 /** Reads text data from a BIFF8 TXO record. */
399 void ReadTxo8( XclImpStream& rStrm );
401 sal_uInt8 GetHorAlign() const { return ::extract_value< sal_uInt8 >( mnFlags, 1, 3 ); }
402 sal_uInt8 GetVerAlign() const { return ::extract_value< sal_uInt8 >( mnFlags, 4, 3 ); }
405 enum XclTbxEventType
407 EXC_TBX_EVENT_ACTION, /// XActionListener.actionPerformed
408 EXC_TBX_EVENT_MOUSE, /// XMouseListener.mouseReleased
409 EXC_TBX_EVENT_TEXT, /// XTextListener.textChanged
410 EXC_TBX_EVENT_VALUE, /// XAdjustmentListener.adjustmentValueChanged
411 EXC_TBX_EVENT_CHANGE /// XChangeListener.changed
414 /** Provides static helper functions for form controls. */
415 class XclControlHelper
417 public:
418 /** Returns the API control model from the passed API shape object. */
419 static css::uno::Reference< css::awt::XControlModel >
420 GetControlModel( css::uno::Reference< css::drawing::XShape > const & xShape );
422 /** Fills the macro descriptor according to the passed macro name. */
423 static bool FillMacroDescriptor(
424 css::script::ScriptEventDescriptor& rDescriptor,
425 XclTbxEventType eEventType,
426 const OUString& rXclMacroName,
427 SfxObjectShell* pDocShell );
428 /** Tries to extract an Excel macro name from the passed macro descriptor. */
429 static OUString ExtractFromMacroDescriptor(
430 const css::script::ScriptEventDescriptor& rDescriptor,
431 XclTbxEventType eEventType );
434 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */