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: xlview.hxx,v $
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 ************************************************************************/
35 #include <tools/color.hxx>
37 #include "xladdress.hxx"
39 // Constants and enumerations =================================================
41 const sal_uInt16 EXC_ZOOM_MIN
= 10;
42 const sal_uInt16 EXC_ZOOM_MAX
= 400;
44 // (0x001D) SELECTION ---------------------------------------------------------
46 const sal_uInt16 EXC_ID_SELECTION
= 0x001D;
48 // (0x003D) WINDOW1 -----------------------------------------------------------
50 const sal_uInt16 EXC_ID_WINDOW1
= 0x003D;
52 const sal_uInt16 EXC_WIN1_HIDDEN
= 0x0001;
53 const sal_uInt16 EXC_WIN1_MINIMIZED
= 0x0002;
54 const sal_uInt16 EXC_WIN1_HOR_SCROLLBAR
= 0x0008;
55 const sal_uInt16 EXC_WIN1_VER_SCROLLBAR
= 0x0010;
56 const sal_uInt16 EXC_WIN1_TABBAR
= 0x0020;
58 // (0x003E, 0x023E) WINDOW2 ---------------------------------------------------
60 const sal_uInt16 EXC_ID2_WINDOW2
= 0x003E;
61 const sal_uInt16 EXC_ID_WINDOW2
= 0x023E;
63 const sal_uInt16 EXC_WIN2_SHOWFORMULAS
= 0x0001;
64 const sal_uInt16 EXC_WIN2_SHOWGRID
= 0x0002;
65 const sal_uInt16 EXC_WIN2_SHOWHEADINGS
= 0x0004;
66 const sal_uInt16 EXC_WIN2_FROZEN
= 0x0008;
67 const sal_uInt16 EXC_WIN2_SHOWZEROS
= 0x0010;
68 const sal_uInt16 EXC_WIN2_DEFGRIDCOLOR
= 0x0020;
69 const sal_uInt16 EXC_WIN2_MIRRORED
= 0x0040;
70 const sal_uInt16 EXC_WIN2_SHOWOUTLINE
= 0x0080;
71 const sal_uInt16 EXC_WIN2_FROZENNOSPLIT
= 0x0100;
72 const sal_uInt16 EXC_WIN2_SELECTED
= 0x0200;
73 const sal_uInt16 EXC_WIN2_DISPLAYED
= 0x0400;
74 const sal_uInt16 EXC_WIN2_PAGEBREAKMODE
= 0x0800;
76 const sal_uInt16 EXC_WIN2_NORMALZOOM_DEF
= 100; /// Default zoom for normal view.
77 const sal_uInt16 EXC_WIN2_PAGEZOOM_DEF
= 60; /// Default zoom for pagebreak preview.
79 // (0x0041) PANE --------------------------------------------------------------
81 const sal_uInt16 EXC_ID_PANE
= 0x0041;
83 const sal_uInt8 EXC_PANE_BOTTOMRIGHT
= 0; /// Bottom-right pane.
84 const sal_uInt8 EXC_PANE_TOPRIGHT
= 1; /// Right, or top-right pane.
85 const sal_uInt8 EXC_PANE_BOTTOMLEFT
= 2; /// Bottom, or bottom-left pane.
86 const sal_uInt8 EXC_PANE_TOPLEFT
= 3; /// Single, top, left, or top-left pane.
88 // (0x00A0) SCL ---------------------------------------------------------------
90 const sal_uInt16 EXC_ID_SCL
= 0x00A0;
92 // (0x0862) SHEETEXT ----------------------------------------------------------
94 const sal_uInt16 EXC_ID_SHEETEXT
= 0x0862; /// header id for sheetext
95 const sal_uInt8 EXC_SHEETEXT_TABCOLOR
= 0x7F; /// mask for tab color
96 const sal_uInt16 EXC_COLOR_NOTABBG
= 0x7F; /// Excel ignores Tab color when set to this value...
97 // Structs ====================================================================
99 /** Contains all view settings for the entire document. */
100 struct XclDocViewData
102 sal_uInt16 mnWinX
; /// X position of the document window (twips).
103 sal_uInt16 mnWinY
; /// Y position of the document window (twips).
104 sal_uInt16 mnWinWidth
; /// Width of the document window (twips).
105 sal_uInt16 mnWinHeight
; /// Height of the document window (twips).
106 sal_uInt16 mnFlags
; /// Additional flags.
107 sal_uInt16 mnDisplXclTab
; /// Displayed (active) sheet.
108 sal_uInt16 mnFirstVisXclTab
; /// First visible sheet.
109 sal_uInt16 mnXclSelectCnt
; /// Number of selected sheets.
110 sal_uInt16 mnTabBarWidth
; /// Width of sheet tabbar (1/1000 of window width).
112 explicit XclDocViewData();
115 // ----------------------------------------------------------------------------
117 /** Contains all settings for a selection in a single pane of a sheet. */
118 struct XclSelectionData
120 XclAddress maXclCursor
; /// Cell cursor position.
121 XclRangeList maXclSelection
; /// Selected cell ranges.
122 sal_uInt16 mnCursorIdx
; /// Index of cursor in selection list.
124 inline explicit XclSelectionData() : mnCursorIdx( 0 ) {}
127 typedef ScfRef
< XclSelectionData
> XclSelectionDataRef
;
129 // ----------------------------------------------------------------------------
131 /** Contains all view settings for a single sheet. */
132 struct XclTabViewData
134 typedef ::std::map
< sal_uInt8
, XclSelectionDataRef
> XclSelectionMap
;
136 XclSelectionMap maSelMap
; /// Selections of all panes.
137 Color maGridColor
; /// Grid color.
138 XclAddress maFirstXclPos
; /// First visible cell.
139 XclAddress maSecondXclPos
; /// First visible cell in additional panes.
140 sal_uInt16 mnSplitX
; /// Split X position, or number of frozen columns.
141 sal_uInt16 mnSplitY
; /// Split Y position, or number of frozen rows.
142 sal_uInt16 mnNormalZoom
; /// Zoom factor for normal view.
143 sal_uInt16 mnPageZoom
; /// Zoom factor for pagebreak preview.
144 sal_uInt16 mnCurrentZoom
; /// Zoom factor for current view.
145 sal_uInt8 mnActivePane
; /// Active pane (with cell cursor).
146 bool mbSelected
; /// true = Sheet is selected.
147 bool mbDisplayed
; /// true = Sheet is displayed (active).
148 bool mbMirrored
; /// true = Mirrored (right-to-left) sheet.
149 bool mbFrozenPanes
; /// true = Frozen panes; false = split window.
150 bool mbPageMode
; /// true = Pagebreak preview; false = Normal view.
151 bool mbDefGridColor
; /// true = Default grid color.
152 bool mbShowFormulas
; /// true = Show formulas instead of results.
153 bool mbShowGrid
; /// true = Show cell grid.
154 bool mbShowHeadings
; /// true = Show column/row headings.
155 bool mbShowZeros
; /// true = Show zero value zells.
156 bool mbShowOutline
; /// true = Show outlines.
157 Color maTabBgColor
; /// Tab Color default = (COL_AUTO )
158 bool IsDefaultTabBgColor() const { return maTabBgColor
== Color(COL_AUTO
) ? TRUE
: FALSE
; };
159 sal_uInt32 mnTabBgColorId
; /// pallette color id
161 explicit XclTabViewData();
164 /** Sets Excel default view settings. */
167 /** Returns true, if the window is split in any direction. */
168 bool IsSplit() const;
169 /** Returns true, if the specified pane (EXC_PANE_*) is available. */
170 bool HasPane( sal_uInt8 nPaneId
) const;
172 /** Returns the selection data, if available, otherwise 0. */
173 const XclSelectionData
* GetSelectionData( sal_uInt8 nPane
) const;
174 /** Returns read/write access to the selection data of the specified pane. */
175 XclSelectionData
& CreateSelectionData( sal_uInt8 nPane
);
178 // ============================================================================