1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: csvtablebox.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // ============================================================================
33 #ifndef _SC_CSVTABLEBOX_HXX
34 #define _SC_CSVTABLEBOX_HXX
36 #include <vcl/ctrl.hxx>
37 #include <vcl/scrbar.hxx>
39 #include "csvcontrol.hxx"
40 #include "csvruler.hxx"
41 #include "csvgrid.hxx"
48 /* ============================================================================
49 Position: Positions between the characters (the dots in the ruler).
50 Character: The characters (the range from one position to the next).
51 Split: Positions which contain a split to divide characters into groups (columns).
52 Column: The range between two splits.
53 ============================================================================ */
55 /** The control in the CSV import dialog that contains a ruler and a data grid
56 to visualize and modify the current import settings. */
57 class SC_DLLPUBLIC ScCsvTableBox
: public ScCsvControl
60 ScCsvLayoutData maData
; /// Current layout data of the controls.
62 ScCsvRuler maRuler
; /// The ruler for fixed width mode.
63 ScCsvGrid maGrid
; /// Calc-like data table for fixed width mode.
64 ScrollBar maHScroll
; /// Horizontal scroll bar.
65 ScrollBar maVScroll
; /// Vertical scroll bar.
66 ScrollBarBox maScrollBox
; /// For the bottom right edge.
68 Link maUpdateTextHdl
; /// Updates all cell texts.
69 Link maColTypeHdl
; /// Handler for exporting the column type.
71 ScCsvColStateVec maFixColStates
; /// Column states in fixed width mode.
72 ScCsvColStateVec maSepColStates
; /// Column states in separators mode.
74 sal_Int32 mnFixedWidth
; /// Cached total width for fixed width mode.
76 bool mbFixedMode
; /// false = Separators, true = Fixed width.
78 // ------------------------------------------------------------------------
80 //UNUSED2009-05 explicit ScCsvTableBox( Window* pParent );
81 explicit ScCsvTableBox( Window
* pParent
, const ResId
& rResId
);
83 // common table box handling ----------------------------------------------
85 /** Sets the control to separators mode. */
86 void SetSeparatorsMode();
87 /** Sets the control to fixed width mode. */
88 void SetFixedWidthMode();
91 /** Initialisation on construction. */
92 SC_DLLPRIVATE
void Init();
93 /** Initializes the children controls (pos/size, scroll bars, ...). */
94 SC_DLLPRIVATE
void InitControls();
95 /** Initializes size and position data of horizontal scrollbar. */
96 SC_DLLPRIVATE
void InitHScrollBar();
97 /** Initializes size and position data of vertical scrollbar. */
98 SC_DLLPRIVATE
void InitVScrollBar();
100 /** Calculates and sets valid position offset nearest to nPos. */
101 SC_DLLPRIVATE
inline void ImplSetPosOffset( sal_Int32 nPos
)
102 { maData
.mnPosOffset
= Max( Min( nPos
, GetMaxPosOffset() ), sal_Int32( 0 ) ); }
103 /** Calculates and sets valid line offset nearest to nLine. */
104 SC_DLLPRIVATE
inline void ImplSetLineOffset( sal_Int32 nLine
)
105 { maData
.mnLineOffset
= Max( Min( nLine
, GetMaxLineOffset() ), sal_Int32( 0 ) ); }
106 /** Moves controls (not cursors!) so that nPos becomes visible. */
107 SC_DLLPRIVATE
void MakePosVisible( sal_Int32 nPos
);
109 // cell contents ----------------------------------------------------------
111 /** Fills all cells of all lines with the passed texts (Unicode strings). */
113 const String
* pTextLines
, const String
& rSepChars
,
114 sal_Unicode cTextSep
, bool bMergeSep
);
115 //UNUSED2009-05 /** Fills all cells of all lines with the passed texts (ByteStrings). */
116 //UNUSED2009-05 void SetByteStrings(
117 //UNUSED2009-05 const ByteString* pLineTexts, CharSet eCharSet,
118 //UNUSED2009-05 const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep );
120 // column settings --------------------------------------------------------
122 /** Reads UI strings for data types from the list box. */
123 void InitTypes( const ListBox
& rListBox
);
124 /** Returns the data type of the selected columns. */
125 inline sal_Int32
GetSelColumnType() const { return maGrid
.GetSelColumnType(); }
127 /** Fills the options object with current column data. */
128 void FillColumnData( ScAsciiOptions
& rOptions
) const;
130 // event handling ---------------------------------------------------------
132 /** Sets a new handler for "update cell texts" requests. */
133 inline void SetUpdateTextHdl( const Link
& rHdl
) { maUpdateTextHdl
= rHdl
; }
134 /** Returns the handler for "update cell texts" requests. */
135 inline const Link
& GetUpdateTextHdl() const { return maUpdateTextHdl
; }
136 /** Sets a new handler for "column selection changed" events. */
137 inline void SetColTypeHdl( const Link
& rHdl
) { maColTypeHdl
= rHdl
; }
138 /** Returns the handler for "column selection changed" events. */
139 inline const Link
& GetColTypeHdl() const { return maColTypeHdl
; }
142 virtual void Resize();
143 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
146 SC_DLLPRIVATE
DECL_LINK( CsvCmdHdl
, ScCsvControl
* );
147 SC_DLLPRIVATE
DECL_LINK( ScrollHdl
, ScrollBar
* );
148 SC_DLLPRIVATE
DECL_LINK( ScrollEndHdl
, ScrollBar
* );
150 // accessibility ----------------------------------------------------------
152 /** Creates and returns the accessible object of this control. */
153 virtual XAccessibleRef
CreateAccessible();
156 /** Creates a new accessible object. */
157 virtual ScAccessibleCsvControl
* ImplCreateAccessible();
161 // ============================================================================