LibreOffice Module sc (master) 1
csvcontrol.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <scdllapi.h>
23#include <address.hxx>
24#include "csvsplits.hxx"
26#include <rtl/ref.hxx>
27#include <vcl/customweld.hxx>
29
30namespace com::sun::star::accessibility { class XAccessible; }
31
33const sal_Int32 CSV_MINCOLWIDTH = 8;
35const sal_Int32 CSV_MAXSTRLEN = 0x7FFF;
37const sal_uInt16 CSV_HDR_TRANSPARENCY = 85;
39const sal_Int32 CSV_SCROLL_DIST = 3;
40
42const sal_Int32 CSV_PREVIEW_LINES = 32; // maximum count of preview lines
44const sal_Int32 CSV_MAXCOLCOUNT = MAXCOLCOUNT;
45
47const sal_Int32 CSV_TYPE_DEFAULT = 0;
49const sal_Int32 CSV_TYPE_MULTI = -1;
51const sal_Int32 CSV_TYPE_NOSELECTION = -2;
52
53// External used column types.
61
64{
65 sal_Int32 mnIndex;
67
69 ScCsvExpData( sal_Int32 nIndex, sal_uInt8 nType ) :
70 mnIndex( nIndex ), mnType( nType ) {}
71};
72
73typedef ::std::vector< ScCsvExpData > ScCsvExpDataVec;
74
77{
85};
86
88enum class ScCsvDiff : sal_uInt32 {
89 Equal = 0x0000,
90 PosCount = 0x0001,
91 PosOffset = 0x0002,
92 HeaderWidth = 0x0004,
93 CharWidth = 0x0008,
94 LineCount = 0x0010,
95 LineOffset = 0x0020,
96 HeaderHeight = 0x0040,
97 LineHeight = 0x0080,
98 RulerCursor = 0x0100,
99 GridCursor = 0x0200,
100
103};
104namespace o3tl {
105 template<> struct typed_flags<ScCsvDiff> : is_typed_flags<ScCsvDiff, 0x03ff> {};
106}
107
108
112{
113 // horizontal settings
114 sal_Int32 mnPosCount;
115 sal_Int32 mnPosOffset;
116
117 sal_Int32 mnWinWidth;
118 sal_Int32 mnHdrWidth;
119 sal_Int32 mnCharWidth;
120
121 // vertical settings
122 sal_Int32 mnLineCount;
123 sal_Int32 mnLineOffset;
124
125 sal_Int32 mnWinHeight;
126 sal_Int32 mnHdrHeight;
127 sal_Int32 mnLineHeight;
128
129 // cursor settings
130 sal_Int32 mnPosCursor;
131 sal_Int32 mnColCursor;
132
133 mutable sal_Int32 mnNoRepaint;
134 bool mbAppRTL;
135
136 explicit ScCsvLayoutData();
137
140 ScCsvDiff GetDiff( const ScCsvLayoutData& rData ) const;
141};
142
143inline bool operator==( const ScCsvLayoutData& rData1, const ScCsvLayoutData& rData2 )
144{
145 return rData1.GetDiff( rData2 ) == ScCsvDiff::Equal;
146}
147
148inline bool operator!=( const ScCsvLayoutData& rData1, const ScCsvLayoutData& rData2 )
149{
150 return !(rData1 == rData2);
151}
152
159{
160 // misc
163
164 // modify horizontal dimensions
169
170 // modify vertical dimensions
175
176 // cursors/positions
180
181 // table contents
187
188 // splits
195
199{
200private:
202 sal_Int32 mnParam1;
203 sal_Int32 mnParam2;
204
205public:
206 explicit ScCsvCmd() : meType( CSVCMD_NONE ),
208
209 inline void Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 );
210
211 ScCsvCmdType GetType() const { return meType; }
212 sal_Int32 GetParam1() const { return mnParam1; }
213 sal_Int32 GetParam2() const { return mnParam2; }
214};
215
216inline void ScCsvCmd::Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 )
217{
218 meType = eType; mnParam1 = nParam1; mnParam2 = nParam2;
219}
220
223{
224private:
228
230
231protected:
233
234public:
235 explicit ScCsvControl(const ScCsvLayoutData& rData);
236 virtual ~ScCsvControl() override;
237
238 // event handling ---------------------------------------------------------
239
240 virtual void GetFocus() override;
241 virtual void LoseFocus() override;
242
244 void AccSendFocusEvent( bool bFocused );
246 void AccSendCaretEvent();
248 void AccSendVisibleEvent();
250 void AccSendSelectionEvent();
252 void AccSendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows = true );
254 void AccSendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
256 void AccSendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
257
258 ScAccessibleCsvControl* GetAccessible() { return mxAccessible.get(); }
259
260 // repaint helpers --------------------------------------------------------
261
263 void InvalidateGfx() { mbValidGfx = false; }
265 void ValidateGfx() { mbValidGfx = true; }
267 bool IsValidGfx() const { return mbValidGfx; }
268
271 void Repaint( bool bInvalidate = false );
273 void DisableRepaint();
275 void EnableRepaint();
277 bool IsNoRepaint() const { return mrData.mnNoRepaint > 0; }
278
279 // command handling -------------------------------------------------------
280
282 void SetCmdHdl( const Link<ScCsvControl&,void>& rHdl ) { maCmdHdl = rHdl; }
284 const ScCsvCmd& GetCmd() const { return maCmd; }
285
287 void Execute(
288 ScCsvCmdType eType,
289 sal_Int32 nParam1 = CSV_POS_INVALID,
290 sal_Int32 nParam2 = CSV_POS_INVALID );
291
292 // layout helpers ---------------------------------------------------------
293
295 const ScCsvLayoutData& GetLayoutData() const { return mrData; }
297 bool IsRTL() const { return mrData.mbAppRTL; }
298
300 sal_Int32 GetPosCount() const { return mrData.mnPosCount; }
302 sal_Int32 GetVisPosCount() const;
304 sal_Int32 GetFirstVisPos() const { return mrData.mnPosOffset; }
306 sal_Int32 GetLastVisPos() const { return GetFirstVisPos() + GetVisPosCount(); }
308 sal_Int32 GetMaxPosOffset() const;
309
311 bool IsValidSplitPos( sal_Int32 nPos ) const;
313 bool IsVisibleSplitPos( sal_Int32 nPos ) const;
314
316 sal_Int32 GetHdrWidth() const { return mrData.mnHdrWidth; }
318 sal_Int32 GetCharWidth() const { return mrData.mnCharWidth; }
320 sal_Int32 GetHdrX() const;
322 sal_Int32 GetFirstX() const;
324 sal_Int32 GetLastX() const;
326 sal_Int32 GetX( sal_Int32 nPos ) const;
328 sal_Int32 GetPosFromX( sal_Int32 nX ) const;
329
331 sal_Int32 GetLineCount() const { return mrData.mnLineCount; }
333 sal_Int32 GetVisLineCount() const;
335 sal_Int32 GetFirstVisLine() const { return mrData.mnLineOffset; }
337 sal_Int32 GetLastVisLine() const;
339 sal_Int32 GetMaxLineOffset() const;
340
342 bool IsValidLine( sal_Int32 nLine ) const;
344 bool IsVisibleLine( sal_Int32 nLine ) const;
345
347 sal_Int32 GetHdrHeight() const { return mrData.mnHdrHeight; }
349 sal_Int32 GetLineHeight() const { return mrData.mnLineHeight; }
351 sal_Int32 GetY( sal_Int32 nLine ) const;
353 sal_Int32 GetLineFromY( sal_Int32 nY ) const;
354
356 sal_Int32 GetRulerCursorPos() const { return mrData.mnPosCursor; }
358 sal_Int32 GetGridCursorPos() const { return mrData.mnColCursor; }
359
360 // static helpers ---------------------------------------------------------
361
363 static void ImplInvertRect( OutputDevice& rOutDev, const tools::Rectangle& rRect );
364
367 static ScMoveMode GetHorzDirection( sal_uInt16 nCode, bool bHomeEnd );
370 static ScMoveMode GetVertDirection( sal_uInt16 nCode, bool bHomeEnd );
371};
372
373/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SCCOL MAXCOLCOUNT
Definition: address.hxx:63
Accessible base class used for CSV controls.
Data for a CSV control command.
Definition: csvcontrol.hxx:199
sal_Int32 GetParam1() const
Definition: csvcontrol.hxx:212
sal_Int32 mnParam1
The command.
Definition: csvcontrol.hxx:202
ScCsvCmdType meType
Definition: csvcontrol.hxx:201
void Set(ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2)
Definition: csvcontrol.hxx:216
ScCsvCmdType GetType() const
Definition: csvcontrol.hxx:211
sal_Int32 GetParam2() const
Definition: csvcontrol.hxx:213
sal_Int32 mnParam2
First parameter.
Definition: csvcontrol.hxx:203
ScCsvCmd()
Second parameter.
Definition: csvcontrol.hxx:206
Base class for the CSV ruler and the data grid control.
Definition: csvcontrol.hxx:223
sal_Int32 GetFirstVisPos() const
Returns the first visible position.
Definition: csvcontrol.hxx:304
bool IsNoRepaint() const
Returns true, if controls will not repaint.
Definition: csvcontrol.hxx:277
sal_Int32 GetPosCount() const
Returns the number of available positions.
Definition: csvcontrol.hxx:300
bool mbValidGfx
Shared layout data.
Definition: csvcontrol.hxx:229
sal_Int32 GetRulerCursorPos() const
Returns the ruler cursor position.
Definition: csvcontrol.hxx:356
sal_Int32 GetGridCursorPos() const
Returns the data grid cursor position (not column index!).
Definition: csvcontrol.hxx:358
void InvalidateGfx()
Sets the graphic invalid (next Redraw() will not use cached graphic).
Definition: csvcontrol.hxx:263
bool IsRTL() const
Returns true, if the Right-to-Left layout mode is active.
Definition: csvcontrol.hxx:297
sal_Int32 GetCharWidth() const
Returns the width of one character column.
Definition: csvcontrol.hxx:318
void ValidateGfx()
Sets the graphic valid (next Redraw() will use cached graphic).
Definition: csvcontrol.hxx:265
sal_Int32 GetLineHeight() const
Returns the height of one line.
Definition: csvcontrol.hxx:349
ScCsvCmd maCmd
External command handler.
Definition: csvcontrol.hxx:226
sal_Int32 GetFirstVisLine() const
Returns index of first visible line.
Definition: csvcontrol.hxx:335
bool IsValidGfx() const
Returns true, if cached graphic is valid.
Definition: csvcontrol.hxx:267
sal_Int32 GetHdrWidth() const
Returns the width of the header column.
Definition: csvcontrol.hxx:316
Link< ScCsvControl &, void > maCmdHdl
Definition: csvcontrol.hxx:225
sal_Int32 GetLineCount() const
Returns the number of data lines.
Definition: csvcontrol.hxx:331
void SetCmdHdl(const Link< ScCsvControl &, void > &rHdl)
Sets a new command handler.
Definition: csvcontrol.hxx:282
sal_Int32 GetHdrHeight() const
Returns the height of the header line.
Definition: csvcontrol.hxx:347
rtl::Reference< ScAccessibleCsvControl > mxAccessible
Content of virtual devices valid?
Definition: csvcontrol.hxx:232
const ScCsvLayoutData & mrData
Data of last command.
Definition: csvcontrol.hxx:227
const ScCsvCmd & GetCmd() const
Returns data of the last command.
Definition: csvcontrol.hxx:284
sal_Int32 GetLastVisPos() const
Returns the last visible position.
Definition: csvcontrol.hxx:306
const ScCsvLayoutData & GetLayoutData() const
Returns a reference to the current layout data.
Definition: csvcontrol.hxx:295
ScAccessibleCsvControl * GetAccessible()
Definition: csvcontrol.hxx:258
ScMoveMode
Specifies which element should be used to perform an action.
Definition: csvcontrol.hxx:77
@ MOVE_NEXTPAGE
Previous page relative to current context.
Definition: csvcontrol.hxx:84
@ MOVE_LAST
First element in current context.
Definition: csvcontrol.hxx:80
@ MOVE_PREVPAGE
Successor of current element in current context.
Definition: csvcontrol.hxx:83
@ MOVE_FIRST
No action.
Definition: csvcontrol.hxx:79
@ MOVE_NEXT
Predecessor of current element in current context.
Definition: csvcontrol.hxx:82
@ MOVE_NONE
Definition: csvcontrol.hxx:78
@ MOVE_PREV
Last element in current context.
Definition: csvcontrol.hxx:81
const sal_Int32 CSV_TYPE_DEFAULT
Default column data type.
Definition: csvcontrol.hxx:47
::std::vector< ScCsvExpData > ScCsvExpDataVec
Definition: csvcontrol.hxx:73
const sal_Int32 CSV_SCROLL_DIST
Minimum distance to border for auto scroll.
Definition: csvcontrol.hxx:39
const sal_Int32 CSV_TYPE_NOSELECTION
No column selected.
Definition: csvcontrol.hxx:51
const sal_uInt8 SC_COL_TEXT
Definition: csvcontrol.hxx:55
const sal_Int32 CSV_MAXSTRLEN
Maximum length of a cell string.
Definition: csvcontrol.hxx:35
const sal_Int32 CSV_PREVIEW_LINES
TODO make string array dynamic.
Definition: csvcontrol.hxx:42
bool operator!=(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
Definition: csvcontrol.hxx:148
ScCsvDiff
Flags for comparison of old and new control layout data.
Definition: csvcontrol.hxx:88
const sal_Int32 CSV_MAXCOLCOUNT
Maximum count of columns.
Definition: csvcontrol.hxx:44
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
Definition: csvcontrol.hxx:143
const sal_uInt8 SC_COL_MDY
Definition: csvcontrol.hxx:56
const sal_Int32 CSV_TYPE_MULTI
Multi selection with different types.
Definition: csvcontrol.hxx:49
const sal_uInt8 SC_COL_YMD
Definition: csvcontrol.hxx:58
const sal_Int32 CSV_MINCOLWIDTH
Minimum character count for a column in separators mode.
Definition: csvcontrol.hxx:33
const sal_uInt8 SC_COL_STANDARD
Definition: csvcontrol.hxx:54
const sal_uInt8 SC_COL_DMY
Definition: csvcontrol.hxx:57
const sal_uInt8 SC_COL_ENGLISH
Definition: csvcontrol.hxx:60
const sal_uInt16 CSV_HDR_TRANSPARENCY
Transparency for header color of selected columns.
Definition: csvcontrol.hxx:37
ScCsvCmdType
Enumeration of possible commands to change any settings of the CSV controls.
Definition: csvcontrol.hxx:159
@ CSVCMD_SETCOLUMNTYPE
Update cell texts with current split settings. [-].
Definition: csvcontrol.hxx:184
@ CSVCMD_SETLINECOUNT
Change character pixel width. [width in pixel].
Definition: csvcontrol.hxx:171
@ CSVCMD_SETFIRSTIMPORTLINE
Send selected column type to external controls. [-].
Definition: csvcontrol.hxx:186
@ CSVCMD_SETHDRWIDTH
Change position offset (scroll pos). [position].
Definition: csvcontrol.hxx:167
@ CSVCMD_SETLINEHEIGHT
Change height of top header line. [height in pixel].
Definition: csvcontrol.hxx:174
@ CSVCMD_MOVEGRIDCURSOR
Move ruler cursor to new position. [position].
Definition: csvcontrol.hxx:178
@ CSVCMD_SETPOSCOUNT
Repaint all controls. [-].
Definition: csvcontrol.hxx:165
@ CSVCMD_REPAINT
No command. [-].
Definition: csvcontrol.hxx:162
@ CSVCMD_EXPORTCOLUMNTYPE
Change data type of selected columns. [column type].
Definition: csvcontrol.hxx:185
@ CSVCMD_MOVESPLIT
Inserts or removes a split. [position].
Definition: csvcontrol.hxx:192
@ CSVCMD_UPDATECELLTEXTS
Recalculate splits and cell texts. [-].
Definition: csvcontrol.hxx:183
@ CSVCMD_NEWCELLTEXTS
Move to make passed position visible (for mouse tracking). [position].
Definition: csvcontrol.hxx:182
@ CSVCMD_SETPOSOFFSET
Change position/column count. [character count].
Definition: csvcontrol.hxx:166
@ CSVCMD_REMOVESPLIT
Insert a split. [position].
Definition: csvcontrol.hxx:190
@ CSVCMD_NONE
Definition: csvcontrol.hxx:161
@ CSVCMD_SETCHARWIDTH
Change width of the header column. [width in pixel].
Definition: csvcontrol.hxx:168
@ CSVCMD_MAKEPOSVISIBLE
Move data grid cursor to new column. [position].
Definition: csvcontrol.hxx:179
@ CSVCMD_INSERTSPLIT
Set number of first imported line. [line index].
Definition: csvcontrol.hxx:189
@ CSVCMD_MOVERULERCURSOR
Change data line pixel height. [height in pixel}.
Definition: csvcontrol.hxx:177
@ CSVCMD_SETHDRHEIGHT
Change first visible line. [line index].
Definition: csvcontrol.hxx:173
@ CSVCMD_SETLINEOFFSET
Change number of data lines. [line count].
Definition: csvcontrol.hxx:172
@ CSVCMD_TOGGLESPLIT
Remove a split. [position].
Definition: csvcontrol.hxx:191
@ CSVCMD_REMOVEALLSPLITS
Move a split. [old position, new position].
Definition: csvcontrol.hxx:193
const sal_uInt8 SC_COL_SKIP
Definition: csvcontrol.hxx:59
const sal_Int32 CSV_POS_INVALID
Constant for an invalid ruler position.
Definition: csvsplits.hxx:29
DocumentType eType
sal_Int32 nIndex
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
ObjectFormatterData & mrData
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
Exported data of a column (data used in the dialog).
Definition: csvcontrol.hxx:64
ScCsvExpData()
External type of the column.
Definition: csvcontrol.hxx:68
sal_uInt8 mnType
Index of a column.
Definition: csvcontrol.hxx:66
sal_Int32 mnIndex
Definition: csvcontrol.hxx:65
ScCsvExpData(sal_Int32 nIndex, sal_uInt8 nType)
Definition: csvcontrol.hxx:69
A structure containing all layout data valid for both ruler and data grid (i.e.
Definition: csvcontrol.hxx:112
ScCsvLayoutData()
true = application in RTL mode.
Definition: csvcontrol.cxx:25
sal_Int32 mnPosCursor
Height of a data line.
Definition: csvcontrol.hxx:130
sal_Int32 mnPosOffset
Number of positions.
Definition: csvcontrol.hxx:115
sal_Int32 mnHdrWidth
Width of ruler and data grid.
Definition: csvcontrol.hxx:118
ScCsvDiff GetDiff(const ScCsvLayoutData &rData) const
Returns differences to rData.
Definition: csvcontrol.cxx:43
sal_Int32 mnLineOffset
Number of data lines.
Definition: csvcontrol.hxx:123
bool mbAppRTL
>0 = no repaint.
Definition: csvcontrol.hxx:134
sal_Int32 mnCharWidth
Width of the header column.
Definition: csvcontrol.hxx:119
sal_Int32 mnWinHeight
Index of first visible line (0-based).
Definition: csvcontrol.hxx:125
sal_Int32 mnHdrHeight
Height of entire data grid (incl. header).
Definition: csvcontrol.hxx:126
sal_Int32 mnNoRepaint
Position of grid column cursor.
Definition: csvcontrol.hxx:133
sal_Int32 mnLineCount
Pixel width of one character.
Definition: csvcontrol.hxx:122
sal_Int32 mnPosCount
Definition: csvcontrol.hxx:114
sal_Int32 mnWinWidth
Horizontal scroll offset.
Definition: csvcontrol.hxx:117
sal_Int32 mnColCursor
Position of ruler cursor.
Definition: csvcontrol.hxx:131
sal_Int32 mnLineHeight
Height of the header line.
Definition: csvcontrol.hxx:127
unsigned char sal_uInt8