Line data Source code
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 : #ifndef _SC_CSVTABLEBOX_HXX
21 : #define _SC_CSVTABLEBOX_HXX
22 :
23 : #include <vcl/ctrl.hxx>
24 : #include <vcl/scrbar.hxx>
25 : #include "scdllapi.h"
26 : #include "csvcontrol.hxx"
27 : #include "csvruler.hxx"
28 : #include "csvgrid.hxx"
29 :
30 :
31 : class ListBox;
32 : class ScAsciiOptions;
33 :
34 :
35 : /* ============================================================================
36 : Position: Positions between the characters (the dots in the ruler).
37 : Character: The characters (the range from one position to the next).
38 : Split: Positions which contain a split to divide characters into groups (columns).
39 : Column: The range between two splits.
40 : ============================================================================ */
41 :
42 : /** The control in the CSV import dialog that contains a ruler and a data grid
43 : to visualize and modify the current import settings. */
44 0 : class SC_DLLPUBLIC ScCsvTableBox : public ScCsvControl
45 : {
46 : private:
47 : ScCsvLayoutData maData; /// Current layout data of the controls.
48 :
49 : ScCsvRuler maRuler; /// The ruler for fixed width mode.
50 : ScCsvGrid maGrid; /// Calc-like data table for fixed width mode.
51 : ScrollBar maHScroll; /// Horizontal scroll bar.
52 : ScrollBar maVScroll; /// Vertical scroll bar.
53 : ScrollBarBox maScrollBox; /// For the bottom right edge.
54 :
55 : Link maUpdateTextHdl; /// Updates all cell texts.
56 : Link maColTypeHdl; /// Handler for exporting the column type.
57 :
58 : ScCsvColStateVec maFixColStates; /// Column states in fixed width mode.
59 : ScCsvColStateVec maSepColStates; /// Column states in separators mode.
60 :
61 : sal_Int32 mnFixedWidth; /// Cached total width for fixed width mode.
62 :
63 : bool mbFixedMode; /// false = Separators, true = Fixed width.
64 :
65 :
66 : public:
67 : explicit ScCsvTableBox( Window* pParent, WinBits nBits );
68 :
69 : /** Finishes initialization. Must be called after constructing a new object. */
70 : void Init();
71 :
72 : // common table box handling ----------------------------------------------
73 : public:
74 : /** Sets the control to separators mode. */
75 : void SetSeparatorsMode();
76 : /** Sets the control to fixed width mode. */
77 : void SetFixedWidthMode();
78 :
79 : private:
80 : /** Initializes the children controls (pos/size, scroll bars, ...). */
81 : SAL_DLLPRIVATE void InitControls();
82 : /** Initializes size and position data of horizontal scrollbar. */
83 : SAL_DLLPRIVATE void InitHScrollBar();
84 : /** Initializes size and position data of vertical scrollbar. */
85 : SAL_DLLPRIVATE void InitVScrollBar();
86 :
87 : /** Calculates and sets valid position offset nearest to nPos. */
88 0 : SAL_DLLPRIVATE inline void ImplSetPosOffset( sal_Int32 nPos )
89 0 : { maData.mnPosOffset = std::max( std::min( nPos, GetMaxPosOffset() ), sal_Int32( 0 ) ); }
90 : /** Calculates and sets valid line offset nearest to nLine. */
91 0 : SAL_DLLPRIVATE inline void ImplSetLineOffset( sal_Int32 nLine )
92 0 : { maData.mnLineOffset = std::max( std::min( nLine, GetMaxLineOffset() ), sal_Int32( 0 ) ); }
93 : /** Moves controls (not cursors!) so that nPos becomes visible. */
94 : SAL_DLLPRIVATE void MakePosVisible( sal_Int32 nPos );
95 :
96 : // cell contents ----------------------------------------------------------
97 : public:
98 : /** Fills all cells of all lines with the passed texts (Unicode strings). */
99 : void SetUniStrings(
100 : const OUString* pTextLines, const OUString& rSepChars,
101 : sal_Unicode cTextSep, bool bMergeSep );
102 :
103 : // column settings --------------------------------------------------------
104 : public:
105 : /** Reads UI strings for data types from the list box. */
106 : void InitTypes( const ListBox& rListBox );
107 : /** Returns the data type of the selected columns. */
108 0 : inline sal_Int32 GetSelColumnType() const { return maGrid.GetSelColumnType(); }
109 :
110 : /** Fills the options object with current column data. */
111 : void FillColumnData( ScAsciiOptions& rOptions ) const;
112 :
113 : // event handling ---------------------------------------------------------
114 : public:
115 : /** Sets a new handler for "update cell texts" requests. */
116 0 : inline void SetUpdateTextHdl( const Link& rHdl ) { maUpdateTextHdl = rHdl; }
117 : /** Returns the handler for "update cell texts" requests. */
118 : inline const Link& GetUpdateTextHdl() const { return maUpdateTextHdl; }
119 : /** Sets a new handler for "column selection changed" events. */
120 0 : inline void SetColTypeHdl( const Link& rHdl ) { maColTypeHdl = rHdl; }
121 : /** Returns the handler for "column selection changed" events. */
122 : inline const Link& GetColTypeHdl() const { return maColTypeHdl; }
123 :
124 : protected:
125 : virtual void Resize() SAL_OVERRIDE;
126 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
127 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
128 :
129 : private:
130 : SAL_DLLPRIVATE DECL_LINK( CsvCmdHdl, ScCsvControl* );
131 : SAL_DLLPRIVATE DECL_LINK( ScrollHdl, ScrollBar* );
132 : SAL_DLLPRIVATE DECL_LINK( ScrollEndHdl, ScrollBar* );
133 :
134 : // accessibility ----------------------------------------------------------
135 : public:
136 : /** Creates and returns the accessible object of this control. */
137 : virtual XAccessibleRef CreateAccessible() SAL_OVERRIDE;
138 :
139 : protected:
140 : /** Creates a new accessible object. */
141 : virtual ScAccessibleCsvControl* ImplCreateAccessible() SAL_OVERRIDE;
142 : };
143 :
144 :
145 : #endif
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|