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