Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : // ============================================================================
30 : :
31 : : #ifndef _SC_CSVTABLEBOX_HXX
32 : : #define _SC_CSVTABLEBOX_HXX
33 : :
34 : : #include <vcl/ctrl.hxx>
35 : : #include <vcl/scrbar.hxx>
36 : : #include "scdllapi.h"
37 : : #include "csvcontrol.hxx"
38 : : #include "csvruler.hxx"
39 : : #include "csvgrid.hxx"
40 : :
41 : :
42 : : class ListBox;
43 : : class ScAsciiOptions;
44 : :
45 : :
46 : : /* ============================================================================
47 : : Position: Positions between the characters (the dots in the ruler).
48 : : Character: The characters (the range from one position to the next).
49 : : Split: Positions which contain a split to divide characters into groups (columns).
50 : : Column: The range between two splits.
51 : : ============================================================================ */
52 : :
53 : : /** The control in the CSV import dialog that contains a ruler and a data grid
54 : : to visualize and modify the current import settings. */
55 [ # # ][ # # ]: 0 : class SC_DLLPUBLIC ScCsvTableBox : public ScCsvControl
[ # # ][ # # ]
[ # # ][ # # ]
56 : : {
57 : : private:
58 : : ScCsvLayoutData maData; /// Current layout data of the controls.
59 : :
60 : : ScCsvRuler maRuler; /// The ruler for fixed width mode.
61 : : ScCsvGrid maGrid; /// Calc-like data table for fixed width mode.
62 : : ScrollBar maHScroll; /// Horizontal scroll bar.
63 : : ScrollBar maVScroll; /// Vertical scroll bar.
64 : : ScrollBarBox maScrollBox; /// For the bottom right edge.
65 : :
66 : : Link maUpdateTextHdl; /// Updates all cell texts.
67 : : Link maColTypeHdl; /// Handler for exporting the column type.
68 : :
69 : : ScCsvColStateVec maFixColStates; /// Column states in fixed width mode.
70 : : ScCsvColStateVec maSepColStates; /// Column states in separators mode.
71 : :
72 : : sal_Int32 mnFixedWidth; /// Cached total width for fixed width mode.
73 : :
74 : : bool mbFixedMode; /// false = Separators, true = Fixed width.
75 : :
76 : : // ------------------------------------------------------------------------
77 : : public:
78 : : explicit ScCsvTableBox( Window* pParent, const ResId& rResId );
79 : :
80 : : /** Finishes initialization. Must be called after constructing a new object. */
81 : : void Init();
82 : :
83 : : // common table box handling ----------------------------------------------
84 : : public:
85 : : /** Sets the control to separators mode. */
86 : : void SetSeparatorsMode();
87 : : /** Sets the control to fixed width mode. */
88 : : void SetFixedWidthMode();
89 : :
90 : : private:
91 : : /** Initializes the children controls (pos/size, scroll bars, ...). */
92 : : SC_DLLPRIVATE void InitControls();
93 : : /** Initializes size and position data of horizontal scrollbar. */
94 : : SC_DLLPRIVATE void InitHScrollBar();
95 : : /** Initializes size and position data of vertical scrollbar. */
96 : : SC_DLLPRIVATE void InitVScrollBar();
97 : :
98 : : /** Calculates and sets valid position offset nearest to nPos. */
99 : 0 : SC_DLLPRIVATE inline void ImplSetPosOffset( sal_Int32 nPos )
100 : 0 : { maData.mnPosOffset = Max( Min( nPos, GetMaxPosOffset() ), sal_Int32( 0 ) ); }
101 : : /** Calculates and sets valid line offset nearest to nLine. */
102 : 0 : SC_DLLPRIVATE inline void ImplSetLineOffset( sal_Int32 nLine )
103 : 0 : { maData.mnLineOffset = Max( Min( nLine, GetMaxLineOffset() ), sal_Int32( 0 ) ); }
104 : : /** Moves controls (not cursors!) so that nPos becomes visible. */
105 : : SC_DLLPRIVATE void MakePosVisible( sal_Int32 nPos );
106 : :
107 : : // cell contents ----------------------------------------------------------
108 : : public:
109 : : /** Fills all cells of all lines with the passed texts (Unicode strings). */
110 : : void SetUniStrings(
111 : : const rtl::OUString* pTextLines, const String& rSepChars,
112 : : sal_Unicode cTextSep, bool bMergeSep );
113 : :
114 : : // column settings --------------------------------------------------------
115 : : public:
116 : : /** Reads UI strings for data types from the list box. */
117 : : void InitTypes( const ListBox& rListBox );
118 : : /** Returns the data type of the selected columns. */
119 : 0 : inline sal_Int32 GetSelColumnType() const { return maGrid.GetSelColumnType(); }
120 : :
121 : : /** Fills the options object with current column data. */
122 : : void FillColumnData( ScAsciiOptions& rOptions ) const;
123 : :
124 : : // event handling ---------------------------------------------------------
125 : : public:
126 : : /** Sets a new handler for "update cell texts" requests. */
127 : 0 : inline void SetUpdateTextHdl( const Link& rHdl ) { maUpdateTextHdl = rHdl; }
128 : : /** Returns the handler for "update cell texts" requests. */
129 : : inline const Link& GetUpdateTextHdl() const { return maUpdateTextHdl; }
130 : : /** Sets a new handler for "column selection changed" events. */
131 : 0 : inline void SetColTypeHdl( const Link& rHdl ) { maColTypeHdl = rHdl; }
132 : : /** Returns the handler for "column selection changed" events. */
133 : : inline const Link& GetColTypeHdl() const { return maColTypeHdl; }
134 : :
135 : : protected:
136 : : virtual void Resize();
137 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
138 : :
139 : : private:
140 : : SC_DLLPRIVATE DECL_LINK( CsvCmdHdl, ScCsvControl* );
141 : : SC_DLLPRIVATE DECL_LINK( ScrollHdl, ScrollBar* );
142 : : SC_DLLPRIVATE DECL_LINK( ScrollEndHdl, ScrollBar* );
143 : :
144 : : // accessibility ----------------------------------------------------------
145 : : public:
146 : : /** Creates and returns the accessible object of this control. */
147 : : virtual XAccessibleRef CreateAccessible();
148 : :
149 : : protected:
150 : : /** Creates a new accessible object. */
151 : : virtual ScAccessibleCsvControl* ImplCreateAccessible();
152 : : };
153 : :
154 : :
155 : : // ============================================================================
156 : :
157 : : #endif
158 : :
159 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|