xref: /aoo42x/main/sc/source/ui/inc/csvcontrol.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // ============================================================================
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #ifndef _SC_CSVCONTROL_HXX
31*cdf0e10cSrcweir #define _SC_CSVCONTROL_HXX
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <vcl/ctrl.hxx>
34*cdf0e10cSrcweir #include "scdllapi.h"
35*cdf0e10cSrcweir #include "global.hxx"
36*cdf0e10cSrcweir #include "address.hxx"
37*cdf0e10cSrcweir #include "csvsplits.hxx"
38*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir class ScAccessibleCsvControl;
42*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace accessibility {
43*cdf0e10cSrcweir     class XAccessible;
44*cdf0e10cSrcweir } } } }
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir // ============================================================================
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir /** Minimum character count for a column in separators mode. */
50*cdf0e10cSrcweir const sal_Int32 CSV_MINCOLWIDTH         = 8;
51*cdf0e10cSrcweir /** Maximum length of a cell string. */
52*cdf0e10cSrcweir const xub_StrLen CSV_MAXSTRLEN          = 0x7FFF;
53*cdf0e10cSrcweir /** Transparency for header color of selected columns. */
54*cdf0e10cSrcweir const sal_uInt16 CSV_HDR_TRANSPARENCY   = 85;
55*cdf0e10cSrcweir /** Minimum distance to border for auto scroll. */
56*cdf0e10cSrcweir const sal_Int32 CSV_SCROLL_DIST         = 3;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir //! TODO make string array dynamic
59*cdf0e10cSrcweir const sal_Int32 CSV_PREVIEW_LINES       = 32; // maximum count of preview lines
60*cdf0e10cSrcweir /** Maximum count of columns. */
61*cdf0e10cSrcweir const sal_Int32 CSV_MAXCOLCOUNT         = MAXCOLCOUNT;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir /** Default column data type. */
64*cdf0e10cSrcweir const sal_Int32 CSV_TYPE_DEFAULT        = 0;
65*cdf0e10cSrcweir /** Multi selection with different types. */
66*cdf0e10cSrcweir const sal_Int32 CSV_TYPE_MULTI          = -1;
67*cdf0e10cSrcweir /** No column selected. */
68*cdf0e10cSrcweir const sal_Int32 CSV_TYPE_NOSELECTION    = -2;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir // External used column types.
71*cdf0e10cSrcweir const sal_uInt8 SC_COL_STANDARD         = 1;
72*cdf0e10cSrcweir const sal_uInt8 SC_COL_TEXT             = 2;
73*cdf0e10cSrcweir const sal_uInt8 SC_COL_MDY              = 3;
74*cdf0e10cSrcweir const sal_uInt8 SC_COL_DMY              = 4;
75*cdf0e10cSrcweir const sal_uInt8 SC_COL_YMD              = 5;
76*cdf0e10cSrcweir const sal_uInt8 SC_COL_SKIP             = 9;
77*cdf0e10cSrcweir const sal_uInt8 SC_COL_ENGLISH          = 10;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir // ============================================================================
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir /** Exported data of a column (data used in the dialog). */
83*cdf0e10cSrcweir struct ScCsvExpData
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir     xub_StrLen                  mnIndex;        /// Index of a column.
86*cdf0e10cSrcweir     sal_uInt8                   mnType;         /// External type of the column.
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     inline                      ScCsvExpData() : mnIndex( 0 ), mnType( SC_COL_STANDARD ) {}
89*cdf0e10cSrcweir     inline                      ScCsvExpData( xub_StrLen nIndex, sal_uInt8 nType ) :
90*cdf0e10cSrcweir                                     mnIndex( nIndex ), mnType( nType ) {}
91*cdf0e10cSrcweir };
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir typedef ::std::vector< ScCsvExpData > ScCsvExpDataVec;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir // ============================================================================
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir /** Specifies which element should be used to perform an action. */
99*cdf0e10cSrcweir enum ScMoveMode
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir     MOVE_NONE,                  /// No action.
102*cdf0e10cSrcweir     MOVE_FIRST,                 /// First element in current context.
103*cdf0e10cSrcweir     MOVE_LAST,                  /// Last element in current context.
104*cdf0e10cSrcweir     MOVE_PREV,                  /// Predecessor of current element in current context.
105*cdf0e10cSrcweir     MOVE_NEXT,                  /// Successor of current element in current context.
106*cdf0e10cSrcweir     MOVE_PREVPAGE,              /// Previous page relative to current context.
107*cdf0e10cSrcweir     MOVE_NEXTPAGE               /// Next page relative to current context.
108*cdf0e10cSrcweir };
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir // ============================================================================
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir /** Flags for comparison of old and new control layout data. */
114*cdf0e10cSrcweir typedef sal_uInt32 ScCsvDiff;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_EQUAL          = 0x00000000;
117*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_POSCOUNT       = 0x00000001;
118*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_POSOFFSET      = 0x00000002;
119*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_HDRWIDTH       = 0x00000004;
120*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_CHARWIDTH      = 0x00000008;
121*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_LINECOUNT      = 0x00000010;
122*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_LINEOFFSET     = 0x00000020;
123*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_HDRHEIGHT      = 0x00000040;
124*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_LINEHEIGHT     = 0x00000080;
125*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_RULERCURSOR    = 0x00000100;
126*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_GRIDCURSOR     = 0x00000200;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_HORIZONTAL     = CSV_DIFF_POSCOUNT | CSV_DIFF_POSOFFSET | CSV_DIFF_HDRWIDTH | CSV_DIFF_CHARWIDTH;
129*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_VERTICAL       = CSV_DIFF_LINECOUNT | CSV_DIFF_LINEOFFSET | CSV_DIFF_HDRHEIGHT | CSV_DIFF_LINEHEIGHT;
130*cdf0e10cSrcweir const ScCsvDiff CSV_DIFF_CURSOR         = CSV_DIFF_RULERCURSOR | CSV_DIFF_GRIDCURSOR;
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir // ----------------------------------------------------------------------------
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir /** A structure containing all layout data valid for both ruler and data grid
136*cdf0e10cSrcweir     (i.e. scroll position or column width). */
137*cdf0e10cSrcweir struct ScCsvLayoutData
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir     // horizontal settings
140*cdf0e10cSrcweir     sal_Int32                   mnPosCount;         /// Number of positions.
141*cdf0e10cSrcweir     sal_Int32                   mnPosOffset;        /// Horizontal scroll offset.
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     sal_Int32                   mnWinWidth;         /// Width of ruler and data grid.
144*cdf0e10cSrcweir     sal_Int32                   mnHdrWidth;         /// Width of the header column.
145*cdf0e10cSrcweir     sal_Int32                   mnCharWidth;        /// Pixel width of one character.
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     // vertical settings
148*cdf0e10cSrcweir     sal_Int32                   mnLineCount;        /// Number of data lines.
149*cdf0e10cSrcweir     sal_Int32                   mnLineOffset;       /// Index of first visible line (0-based).
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     sal_Int32                   mnWinHeight;        /// Height of entire data grid (incl. header).
152*cdf0e10cSrcweir     sal_Int32                   mnHdrHeight;        /// Height of the header line.
153*cdf0e10cSrcweir     sal_Int32                   mnLineHeight;       /// Height of a data line.
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     // cursor settings
156*cdf0e10cSrcweir     sal_Int32                   mnPosCursor;        /// Position of ruler cursor.
157*cdf0e10cSrcweir     sal_Int32                   mnColCursor;        /// Position of grid column cursor.
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     mutable sal_Int32           mnNoRepaint;        /// >0 = no repaint.
160*cdf0e10cSrcweir     bool                        mbAppRTL;           /// true = application in RTL mode.
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     explicit                    ScCsvLayoutData();
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     /** Returns differences to rData.
165*cdf0e10cSrcweir         @descr  For each difference the appropriate bit is set in the returned value. */
166*cdf0e10cSrcweir     ScCsvDiff                   GetDiff( const ScCsvLayoutData& rData ) const;
167*cdf0e10cSrcweir };
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir inline bool operator==( const ScCsvLayoutData& rData1, const ScCsvLayoutData& rData2 )
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir     return rData1.GetDiff( rData2 ) == CSV_DIFF_EQUAL;
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir inline bool operator!=( const ScCsvLayoutData& rData1, const ScCsvLayoutData& rData2 )
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir     return !(rData1 == rData2);
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir // ============================================================================
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir /** Enumeration of possible commands to change any settings of the CSV controls.
183*cdf0e10cSrcweir     @descr  Controls have to send commands instead of changing their settings directly.
184*cdf0e10cSrcweir     This helps to keep the different controls consistent to each other.
185*cdf0e10cSrcweir     A command can contain 0 to 2 sal_Int32 parameters. In the description of each
186*cdf0e10cSrcweir     command the required parameters are swown in brackets. [-] means no parameter. */
187*cdf0e10cSrcweir enum ScCsvCmdType
188*cdf0e10cSrcweir {
189*cdf0e10cSrcweir     // misc
190*cdf0e10cSrcweir     CSVCMD_NONE,                /// No command. [-]
191*cdf0e10cSrcweir     CSVCMD_REPAINT,             /// Repaint all controls. [-]
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     // modify horizontal dimensions
194*cdf0e10cSrcweir     CSVCMD_SETPOSCOUNT,         /// Change position/column count. [character count]
195*cdf0e10cSrcweir     CSVCMD_SETPOSOFFSET,        /// Change position offset (scroll pos). [position]
196*cdf0e10cSrcweir     CSVCMD_SETHDRWIDTH,         /// Change width of the header column. [width in pixel]
197*cdf0e10cSrcweir     CSVCMD_SETCHARWIDTH,        /// Change character pixel width. [width in pixel]
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     // modify vertical dimensions
200*cdf0e10cSrcweir     CSVCMD_SETLINECOUNT,        /// Change number of data lines. [line count]
201*cdf0e10cSrcweir     CSVCMD_SETLINEOFFSET,       /// Change first visible line. [line index]
202*cdf0e10cSrcweir     CSVCMD_SETHDRHEIGHT,        /// Change height of top header line. [height in pixel]
203*cdf0e10cSrcweir     CSVCMD_SETLINEHEIGHT,       /// Change data line pixel height. [height in pixel}
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir     // cursors/positions
206*cdf0e10cSrcweir     CSVCMD_MOVERULERCURSOR,     /// Move ruler cursor to new position. [position]
207*cdf0e10cSrcweir     CSVCMD_MOVEGRIDCURSOR,      /// Move data grid cursor to new column. [position]
208*cdf0e10cSrcweir     CSVCMD_MAKEPOSVISIBLE,      /// Move to make passed position visible (for mouse tracking). [position]
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     // table contents
211*cdf0e10cSrcweir     CSVCMD_NEWCELLTEXTS,        /// Recalculate splits and cell texts. [-]
212*cdf0e10cSrcweir     CSVCMD_UPDATECELLTEXTS,     /// Update cell texts with current split settings. [-]
213*cdf0e10cSrcweir     CSVCMD_SETCOLUMNTYPE,       /// Change data type of selected columns. [column type]
214*cdf0e10cSrcweir     CSVCMD_EXPORTCOLUMNTYPE,    /// Send selected column type to external controls. [-]
215*cdf0e10cSrcweir     CSVCMD_SETFIRSTIMPORTLINE,  /// Set number of first imported line. [line index]
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     // splits
218*cdf0e10cSrcweir     CSVCMD_INSERTSPLIT,         /// Insert a split. [position]
219*cdf0e10cSrcweir     CSVCMD_REMOVESPLIT,         /// Remove a split. [position]
220*cdf0e10cSrcweir     CSVCMD_TOGGLESPLIT,         /// Inserts or removes a split. [position]
221*cdf0e10cSrcweir     CSVCMD_MOVESPLIT,           /// Move a split. [old position, new position]
222*cdf0e10cSrcweir     CSVCMD_REMOVEALLSPLITS      /// Remove all splits. [-]
223*cdf0e10cSrcweir };
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir // ----------------------------------------------------------------------------
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir /** Data for a CSV control command. The stored position data is aways character based,
229*cdf0e10cSrcweir     it's never a column index (required for internal consistency). */
230*cdf0e10cSrcweir class ScCsvCmd
231*cdf0e10cSrcweir {
232*cdf0e10cSrcweir private:
233*cdf0e10cSrcweir     ScCsvCmdType                meType;         /// The command.
234*cdf0e10cSrcweir     sal_Int32                   mnParam1;       /// First parameter.
235*cdf0e10cSrcweir     sal_Int32                   mnParam2;       /// Second parameter.
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir public:
238*cdf0e10cSrcweir     inline explicit             ScCsvCmd() : meType( CSVCMD_NONE ),
239*cdf0e10cSrcweir                                     mnParam1( CSV_POS_INVALID ), mnParam2( CSV_POS_INVALID ) {}
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir     inline void                 Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 );
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir     inline ScCsvCmdType         GetType() const     { return meType; }
244*cdf0e10cSrcweir     inline sal_Int32            GetParam1() const   { return mnParam1; }
245*cdf0e10cSrcweir     inline sal_Int32            GetParam2() const   { return mnParam2; }
246*cdf0e10cSrcweir };
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir inline void ScCsvCmd::Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 )
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir     meType = eType; mnParam1 = nParam1; mnParam2 = nParam2;
251*cdf0e10cSrcweir }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir // ============================================================================
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir /** Base class for the CSV ruler and the data grid control. Implements command handling. */
257*cdf0e10cSrcweir class SC_DLLPUBLIC ScCsvControl : public Control
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir protected:
260*cdf0e10cSrcweir     typedef ::std::vector< String >     StringVec;
261*cdf0e10cSrcweir     typedef ::std::vector< StringVec >  StringVecVec;
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir     typedef ::com::sun::star::uno::Reference<
264*cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > XAccessibleRef;
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir private:
267*cdf0e10cSrcweir     Link                        maCmdHdl;           /// External command handler.
268*cdf0e10cSrcweir     ScCsvCmd                    maCmd;              /// Data of last command.
269*cdf0e10cSrcweir     const ScCsvLayoutData&      mrData;             /// Shared layout data.
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     XAccessibleRef              mxAccessible;       /// The accessible object of the control.
272*cdf0e10cSrcweir     ScAccessibleCsvControl*     mpAccessible;       /// Pointer to the accessible implementation object.
273*cdf0e10cSrcweir     bool                        mbValidGfx;         /// Content of virtual devices valid?
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir     // ------------------------------------------------------------------------
276*cdf0e10cSrcweir public:
277*cdf0e10cSrcweir     explicit                    ScCsvControl( ScCsvControl& rParent );
278*cdf0e10cSrcweir     explicit                    ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, WinBits nStyle = 0 );
279*cdf0e10cSrcweir     explicit                    ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, const ResId& rResId );
280*cdf0e10cSrcweir     virtual                     ~ScCsvControl();
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir     // event handling ---------------------------------------------------------
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     virtual void                GetFocus();
285*cdf0e10cSrcweir     virtual void                LoseFocus();
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     /** Sends a GetFocus or LoseFocus event to the accessibility object. */
288*cdf0e10cSrcweir     void                        AccSendFocusEvent( bool bFocused );
289*cdf0e10cSrcweir     /** Sends a caret changed event to the accessibility object. */
290*cdf0e10cSrcweir     void                        AccSendCaretEvent();
291*cdf0e10cSrcweir     /** Sends a visible area changed event to the accessibility object. */
292*cdf0e10cSrcweir     void                        AccSendVisibleEvent();
293*cdf0e10cSrcweir     /** Sends a selection changed event to the accessibility object. */
294*cdf0e10cSrcweir     void                        AccSendSelectionEvent();
295*cdf0e10cSrcweir     /** Sends a table model changed event for changed cell contents to the accessibility object. */
296*cdf0e10cSrcweir     void                        AccSendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows = true );
297*cdf0e10cSrcweir     /** Sends a table model changed event for an inserted column to the accessibility object. */
298*cdf0e10cSrcweir     void                        AccSendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
299*cdf0e10cSrcweir     /** Sends a table model changed event for a removed column to the accessibility object. */
300*cdf0e10cSrcweir     void                        AccSendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     // repaint helpers --------------------------------------------------------
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     /** Sets the graphic invalid (next Redraw() will not use cached graphic). */
305*cdf0e10cSrcweir     inline void                 InvalidateGfx() { mbValidGfx = false; }
306*cdf0e10cSrcweir     /** Sets the graphic valid (next Redraw() will use cached graphic). */
307*cdf0e10cSrcweir     inline void                 ValidateGfx() { mbValidGfx = true; }
308*cdf0e10cSrcweir     /** Returns true, if cached graphic is valid. */
309*cdf0e10cSrcweir     inline bool                 IsValidGfx() const { return mbValidGfx; }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir     /** Repaints all controls.
312*cdf0e10cSrcweir         @param bInvalidate  true = invalidates graphics of this control (not all). */
313*cdf0e10cSrcweir     void                        Repaint( bool bInvalidate = false );
314*cdf0e10cSrcweir     /** Increases no-repaint counter (controls do not repaint until the last EnableRepaint()). */
315*cdf0e10cSrcweir     void                        DisableRepaint();
316*cdf0e10cSrcweir     /** Decreases no-repaint counter and repaints if counter reaches 0.
317*cdf0e10cSrcweir         @param bInvalidate  true = invalidates graphics of this control (not all). */
318*cdf0e10cSrcweir     void                        EnableRepaint( bool bInvalidate = false );
319*cdf0e10cSrcweir     /** Returns true, if controls will not repaint. */
320*cdf0e10cSrcweir     inline bool                 IsNoRepaint() const { return mrData.mnNoRepaint > 0; }
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir     // command handling -------------------------------------------------------
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir     /** Sets a new command handler. */
325*cdf0e10cSrcweir     inline void                 SetCmdHdl( const Link& rHdl ) { maCmdHdl = rHdl; }
326*cdf0e10cSrcweir     /** Returns the current command handler. */
327*cdf0e10cSrcweir     inline const Link&          GetCmdHdl() const { return maCmdHdl; }
328*cdf0e10cSrcweir     /** Returns data of the last command. */
329*cdf0e10cSrcweir     inline const ScCsvCmd&      GetCmd() const { return maCmd; }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir     /** Executes a command by calling command handler. */
332*cdf0e10cSrcweir     void                        Execute(
333*cdf0e10cSrcweir                                     ScCsvCmdType eType,
334*cdf0e10cSrcweir                                     sal_Int32 nParam1 = CSV_POS_INVALID,
335*cdf0e10cSrcweir                                     sal_Int32 nParam2 = CSV_POS_INVALID );
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     // layout helpers ---------------------------------------------------------
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir     /** Returns a reference to the current layout data. */
340*cdf0e10cSrcweir     inline const ScCsvLayoutData& GetLayoutData() const { return mrData; }
341*cdf0e10cSrcweir     /** Returns true, if the Right-to-Left layout mode is active. */
342*cdf0e10cSrcweir     inline bool                 IsRTL() const { return mrData.mbAppRTL; }
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir     /** Returns the number of available positions. */
345*cdf0e10cSrcweir     inline sal_Int32            GetPosCount() const { return mrData.mnPosCount; }
346*cdf0e10cSrcweir     /** Returns the number of visible positions. */
347*cdf0e10cSrcweir     sal_Int32                   GetVisPosCount() const;
348*cdf0e10cSrcweir     /** Returns the first visible position. */
349*cdf0e10cSrcweir     inline sal_Int32            GetFirstVisPos() const { return mrData.mnPosOffset; }
350*cdf0e10cSrcweir     /** Returns the last visible position. */
351*cdf0e10cSrcweir     inline sal_Int32            GetLastVisPos() const { return GetFirstVisPos() + GetVisPosCount(); }
352*cdf0e10cSrcweir     /** Returns highest possible position for first visible character. */
353*cdf0e10cSrcweir     sal_Int32                   GetMaxPosOffset() const;
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir     /** Returns true, if it is allowed to set a split at nPos. */
356*cdf0e10cSrcweir     bool                        IsValidSplitPos( sal_Int32 nPos ) const;
357*cdf0e10cSrcweir     /** Returns true, if nPos is an allowed AND visible split position. */
358*cdf0e10cSrcweir     bool                        IsVisibleSplitPos( sal_Int32 nPos ) const;
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir     /** Returns the width of the header column. */
361*cdf0e10cSrcweir     inline sal_Int32            GetHdrWidth() const { return mrData.mnHdrWidth; }
362*cdf0e10cSrcweir     /** Returns the width of one character column. */
363*cdf0e10cSrcweir     inline sal_Int32            GetCharWidth() const { return mrData.mnCharWidth; }
364*cdf0e10cSrcweir     /** Returns the start position of the header column. */
365*cdf0e10cSrcweir     sal_Int32                   GetHdrX() const;
366*cdf0e10cSrcweir     /** Returns the X position of the first pixel of the data area. */
367*cdf0e10cSrcweir     sal_Int32                   GetFirstX() const;
368*cdf0e10cSrcweir     /** Returns the X position of the last pixel of the data area. */
369*cdf0e10cSrcweir     sal_Int32                   GetLastX() const;
370*cdf0e10cSrcweir     /** Returns output X coordinate of the specified position. */
371*cdf0e10cSrcweir     sal_Int32                   GetX( sal_Int32 nPos ) const;
372*cdf0e10cSrcweir     /** Returns position from output coordinate. */
373*cdf0e10cSrcweir     sal_Int32                   GetPosFromX( sal_Int32 nX ) const;
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir     /** Returns the number of data lines. */
376*cdf0e10cSrcweir     inline sal_Int32            GetLineCount() const { return mrData.mnLineCount; }
377*cdf0e10cSrcweir     /** Returns the number of visible lines (including partly visible bottom line). */
378*cdf0e10cSrcweir     sal_Int32                   GetVisLineCount() const;
379*cdf0e10cSrcweir     /** Returns index of first visible line. */
380*cdf0e10cSrcweir     inline sal_Int32            GetFirstVisLine() const { return mrData.mnLineOffset; }
381*cdf0e10cSrcweir     /** Returns index of last visible line. */
382*cdf0e10cSrcweir     sal_Int32                   GetLastVisLine() const;
383*cdf0e10cSrcweir     /** Returns highest possible index for first line. */
384*cdf0e10cSrcweir     sal_Int32                   GetMaxLineOffset() const;
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir     /** Returns true, if nLine is a valid line index. */
387*cdf0e10cSrcweir     bool                        IsValidLine( sal_Int32 nLine ) const;
388*cdf0e10cSrcweir     /** Returns true, if nLine is a valid and visible line index. */
389*cdf0e10cSrcweir     bool                        IsVisibleLine( sal_Int32 nLine ) const;
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir     /** Returns the height of the header line. */
392*cdf0e10cSrcweir     inline sal_Int32            GetHdrHeight() const { return mrData.mnHdrHeight; }
393*cdf0e10cSrcweir     /** Returns the height of one line. */
394*cdf0e10cSrcweir     inline sal_Int32            GetLineHeight() const { return mrData.mnLineHeight; }
395*cdf0e10cSrcweir     /** Returns output Y coordinate of the specified line. */
396*cdf0e10cSrcweir     sal_Int32                   GetY( sal_Int32 nLine ) const;
397*cdf0e10cSrcweir     /** Returns line index from output coordinate. */
398*cdf0e10cSrcweir     sal_Int32                   GetLineFromY( sal_Int32 nY ) const;
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir     /** Returns the ruler cursor position. */
401*cdf0e10cSrcweir     inline sal_Int32            GetRulerCursorPos() const { return mrData.mnPosCursor; }
402*cdf0e10cSrcweir     /** Returns the data grid cursor position (not column index!). */
403*cdf0e10cSrcweir     inline sal_Int32            GetGridCursorPos() const { return mrData.mnColCursor; }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir     // static helpers ---------------------------------------------------------
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir     /** Inverts a rectangle in the specified output device. */
408*cdf0e10cSrcweir     static void                 ImplInvertRect( OutputDevice& rOutDev, const Rectangle& rRect );
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir     /** Returns direction code for the keys LEFT, RIGHT, HOME, END.
411*cdf0e10cSrcweir         @param bHomeEnd  false = ignore HOME and END key. */
412*cdf0e10cSrcweir     static ScMoveMode           GetHorzDirection( sal_uInt16 nCode, bool bHomeEnd );
413*cdf0e10cSrcweir     /** Returns direction code for the keys UP, DOWN, HOME, END, PAGE UP, PAGE DOWN.
414*cdf0e10cSrcweir         @param bHomeEnd  false = ignore HOME and END key. */
415*cdf0e10cSrcweir     static ScMoveMode           GetVertDirection( sal_uInt16 nCode, bool bHomeEnd );
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir     // accessibility ----------------------------------------------------------
418*cdf0e10cSrcweir public:
419*cdf0e10cSrcweir     /** Creates and returns the accessible object of this control. Do not overwrite in
420*cdf0e10cSrcweir         derived classes, use ImplCreateAccessible() instead. */
421*cdf0e10cSrcweir     virtual XAccessibleRef     CreateAccessible();
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir protected:
424*cdf0e10cSrcweir     /** Derived classes create a new accessible object here. */
425*cdf0e10cSrcweir     virtual ScAccessibleCsvControl* ImplCreateAccessible() = 0;
426*cdf0e10cSrcweir };
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir // ============================================================================
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir #endif
432*cdf0e10cSrcweir 
433