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