xref: /AOO41X/main/sc/source/ui/dbgui/csvtablebox.cxx (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 // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // ============================================================================
33*cdf0e10cSrcweir #include "csvtablebox.hxx"
34*cdf0e10cSrcweir #include <tools/debug.hxx>
35*cdf0e10cSrcweir #include <vcl/lstbox.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir // ause
38*cdf0e10cSrcweir #include "editutil.hxx"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir // ============================================================================
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir //UNUSED2009-05 ScCsvTableBox::ScCsvTableBox( Window* pParent ) :
43*cdf0e10cSrcweir //UNUSED2009-05     ScCsvControl( pParent, maData, WB_BORDER | WB_TABSTOP | WB_DIALOGCONTROL ),
44*cdf0e10cSrcweir //UNUSED2009-05     maRuler( *this ),
45*cdf0e10cSrcweir //UNUSED2009-05     maGrid( *this ),
46*cdf0e10cSrcweir //UNUSED2009-05     maHScroll( this, WB_HORZ | WB_DRAG ),
47*cdf0e10cSrcweir //UNUSED2009-05     maVScroll( this, WB_VERT | WB_DRAG ),
48*cdf0e10cSrcweir //UNUSED2009-05     maScrollBox( this )
49*cdf0e10cSrcweir //UNUSED2009-05 {
50*cdf0e10cSrcweir //UNUSED2009-05     Init();
51*cdf0e10cSrcweir //UNUSED2009-05 }
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir ScCsvTableBox::ScCsvTableBox( Window* pParent, const ResId& rResId ) :
54*cdf0e10cSrcweir     ScCsvControl( pParent, maData, rResId ),
55*cdf0e10cSrcweir     maRuler( *this ),
56*cdf0e10cSrcweir     maGrid( *this ),
57*cdf0e10cSrcweir     maHScroll( this, WB_HORZ | WB_DRAG ),
58*cdf0e10cSrcweir     maVScroll( this, WB_VERT | WB_DRAG ),
59*cdf0e10cSrcweir     maScrollBox( this )
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir     Init();
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir // common table box handling --------------------------------------------------
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir void ScCsvTableBox::SetSeparatorsMode()
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir     if( mbFixedMode )
70*cdf0e10cSrcweir     {
71*cdf0e10cSrcweir         // rescue data for fixed width mode
72*cdf0e10cSrcweir         mnFixedWidth = GetPosCount();
73*cdf0e10cSrcweir         maFixColStates = maGrid.GetColumnStates();
74*cdf0e10cSrcweir         // switch to separators mode
75*cdf0e10cSrcweir         mbFixedMode = false;
76*cdf0e10cSrcweir         // reset and reinitialize controls
77*cdf0e10cSrcweir         DisableRepaint();
78*cdf0e10cSrcweir         Execute( CSVCMD_SETLINEOFFSET, 0 );
79*cdf0e10cSrcweir         Execute( CSVCMD_SETPOSCOUNT, 1 );
80*cdf0e10cSrcweir         Execute( CSVCMD_NEWCELLTEXTS );
81*cdf0e10cSrcweir         maGrid.SetColumnStates( maSepColStates );
82*cdf0e10cSrcweir         InitControls();
83*cdf0e10cSrcweir         EnableRepaint();
84*cdf0e10cSrcweir     }
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir void ScCsvTableBox::SetFixedWidthMode()
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir     if( !mbFixedMode )
90*cdf0e10cSrcweir     {
91*cdf0e10cSrcweir         // rescue data for separators mode
92*cdf0e10cSrcweir         maSepColStates = maGrid.GetColumnStates();
93*cdf0e10cSrcweir         // switch to fixed width mode
94*cdf0e10cSrcweir         mbFixedMode = true;
95*cdf0e10cSrcweir         // reset and reinitialize controls
96*cdf0e10cSrcweir         DisableRepaint();
97*cdf0e10cSrcweir         Execute( CSVCMD_SETLINEOFFSET, 0 );
98*cdf0e10cSrcweir         Execute( CSVCMD_SETPOSCOUNT, mnFixedWidth );
99*cdf0e10cSrcweir         maGrid.SetSplits( maRuler.GetSplits() );
100*cdf0e10cSrcweir         maGrid.SetColumnStates( maFixColStates );
101*cdf0e10cSrcweir         InitControls();
102*cdf0e10cSrcweir         EnableRepaint();
103*cdf0e10cSrcweir     }
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir void ScCsvTableBox::Init()
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir     mbFixedMode = false;
109*cdf0e10cSrcweir     mnFixedWidth = 1;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     maHScroll.EnableRTL( false ); // #107812# RTL
112*cdf0e10cSrcweir     maHScroll.SetLineSize( 1 );
113*cdf0e10cSrcweir     maVScroll.SetLineSize( 1 );
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     Link aLink = LINK( this, ScCsvTableBox, CsvCmdHdl );
116*cdf0e10cSrcweir     SetCmdHdl( aLink );
117*cdf0e10cSrcweir     maRuler.SetCmdHdl( aLink );
118*cdf0e10cSrcweir     maGrid.SetCmdHdl( aLink );
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     aLink = LINK( this, ScCsvTableBox, ScrollHdl );
121*cdf0e10cSrcweir     maHScroll.SetScrollHdl( aLink );
122*cdf0e10cSrcweir     maVScroll.SetScrollHdl( aLink );
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     aLink = LINK( this, ScCsvTableBox, ScrollEndHdl );
125*cdf0e10cSrcweir     maHScroll.SetEndScrollHdl( aLink );
126*cdf0e10cSrcweir     maVScroll.SetEndScrollHdl( aLink );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     InitControls();
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir void ScCsvTableBox::InitControls()
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir     maGrid.UpdateLayoutData();
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     long nScrollBarSize = GetSettings().GetStyleSettings().GetScrollBarSize();
136*cdf0e10cSrcweir     Size aWinSize = CalcOutputSize( GetSizePixel() );
137*cdf0e10cSrcweir     long nDataWidth = aWinSize.Width() - nScrollBarSize;
138*cdf0e10cSrcweir     long nDataHeight = aWinSize.Height() - nScrollBarSize;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     maData.mnWinWidth = nDataWidth;
141*cdf0e10cSrcweir     maData.mnWinHeight = nDataHeight;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     if( mbFixedMode )
144*cdf0e10cSrcweir     {
145*cdf0e10cSrcweir         // ruler sets height internally
146*cdf0e10cSrcweir         maRuler.SetPosSizePixel( 0, 0, nDataWidth, 0 );
147*cdf0e10cSrcweir         sal_Int32 nY = maRuler.GetSizePixel().Height();
148*cdf0e10cSrcweir         maData.mnWinHeight -= nY;
149*cdf0e10cSrcweir         maGrid.SetPosSizePixel( 0, nY, nDataWidth, maData.mnWinHeight );
150*cdf0e10cSrcweir     }
151*cdf0e10cSrcweir     else
152*cdf0e10cSrcweir         maGrid.SetPosSizePixel( 0, 0, nDataWidth, nDataHeight );
153*cdf0e10cSrcweir     maGrid.Show();
154*cdf0e10cSrcweir     maRuler.Show( mbFixedMode );
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     // scrollbars always visible
157*cdf0e10cSrcweir     maHScroll.SetPosSizePixel( 0, nDataHeight, nDataWidth, nScrollBarSize );
158*cdf0e10cSrcweir     InitHScrollBar();
159*cdf0e10cSrcweir     maHScroll.Show();
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     // scrollbars always visible
162*cdf0e10cSrcweir     maVScroll.SetPosSizePixel( nDataWidth, 0, nScrollBarSize, nDataHeight );
163*cdf0e10cSrcweir     InitVScrollBar();
164*cdf0e10cSrcweir     maVScroll.Show();
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     bool bScrBox = maHScroll.IsVisible() && maVScroll.IsVisible();
167*cdf0e10cSrcweir     if( bScrBox )
168*cdf0e10cSrcweir         maScrollBox.SetPosSizePixel( nDataWidth, nDataHeight, nScrollBarSize, nScrollBarSize );
169*cdf0e10cSrcweir     maScrollBox.Show( bScrBox );
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     // let the controls self-adjust to visible area
172*cdf0e10cSrcweir     Execute( CSVCMD_SETPOSOFFSET, GetFirstVisPos() );
173*cdf0e10cSrcweir     Execute( CSVCMD_SETLINEOFFSET, GetFirstVisLine() );
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir void ScCsvTableBox::InitHScrollBar()
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir     maHScroll.SetRange( Range( 0, GetPosCount() + 2 ) );
179*cdf0e10cSrcweir     maHScroll.SetVisibleSize( GetVisPosCount() );
180*cdf0e10cSrcweir     maHScroll.SetPageSize( GetVisPosCount() * 3 / 4 );
181*cdf0e10cSrcweir     maHScroll.SetThumbPos( GetFirstVisPos() );
182*cdf0e10cSrcweir }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir void ScCsvTableBox::InitVScrollBar()
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir     maVScroll.SetRange( Range( 0, GetLineCount() + 1 ) );
187*cdf0e10cSrcweir     maVScroll.SetVisibleSize( GetVisLineCount() );
188*cdf0e10cSrcweir     maVScroll.SetPageSize( GetVisLineCount() - 2 );
189*cdf0e10cSrcweir     maVScroll.SetThumbPos( GetFirstVisLine() );
190*cdf0e10cSrcweir }
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir void ScCsvTableBox::MakePosVisible( sal_Int32 nPos )
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir     if( (0 <= nPos) && (nPos < GetPosCount()) )
195*cdf0e10cSrcweir     {
196*cdf0e10cSrcweir         if( nPos - CSV_SCROLL_DIST + 1 <= GetFirstVisPos() )
197*cdf0e10cSrcweir             Execute( CSVCMD_SETPOSOFFSET, nPos - CSV_SCROLL_DIST );
198*cdf0e10cSrcweir         else if( nPos + CSV_SCROLL_DIST >= GetLastVisPos() )
199*cdf0e10cSrcweir             Execute( CSVCMD_SETPOSOFFSET, nPos - GetVisPosCount() + CSV_SCROLL_DIST );
200*cdf0e10cSrcweir     }
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir // cell contents --------------------------------------------------------------
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir void ScCsvTableBox::SetUniStrings(
207*cdf0e10cSrcweir         const String* pTextLines, const String& rSepChars,
208*cdf0e10cSrcweir         sal_Unicode cTextSep, bool bMergeSep )
209*cdf0e10cSrcweir {
210*cdf0e10cSrcweir     // assuming that pTextLines is a string array with size CSV_PREVIEW_LINES
211*cdf0e10cSrcweir     // -> will be dynamic sometime
212*cdf0e10cSrcweir     DisableRepaint();
213*cdf0e10cSrcweir     sal_Int32 nEndLine = GetFirstVisLine() + CSV_PREVIEW_LINES;
214*cdf0e10cSrcweir     const String* pString = pTextLines;
215*cdf0e10cSrcweir     for( sal_Int32 nLine = GetFirstVisLine(); nLine < nEndLine; ++nLine, ++pString )
216*cdf0e10cSrcweir     {
217*cdf0e10cSrcweir         if( mbFixedMode )
218*cdf0e10cSrcweir             maGrid.ImplSetTextLineFix( nLine, *pString );
219*cdf0e10cSrcweir         else
220*cdf0e10cSrcweir             maGrid.ImplSetTextLineSep( nLine, *pString, rSepChars, cTextSep, bMergeSep );
221*cdf0e10cSrcweir     }
222*cdf0e10cSrcweir     EnableRepaint();
223*cdf0e10cSrcweir }
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir //UNUSED2009-05 void ScCsvTableBox::SetByteStrings(
226*cdf0e10cSrcweir //UNUSED2009-05         const ByteString* pTextLines, CharSet eCharSet,
227*cdf0e10cSrcweir //UNUSED2009-05         const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep )
228*cdf0e10cSrcweir //UNUSED2009-05 {
229*cdf0e10cSrcweir //UNUSED2009-05     // assuming that pTextLines is a string array with size CSV_PREVIEW_LINES
230*cdf0e10cSrcweir //UNUSED2009-05     // -> will be dynamic sometime
231*cdf0e10cSrcweir //UNUSED2009-05     DisableRepaint();
232*cdf0e10cSrcweir //UNUSED2009-05     sal_Int32 nEndLine = GetFirstVisLine() + CSV_PREVIEW_LINES;
233*cdf0e10cSrcweir //UNUSED2009-05     const ByteString* pString = pTextLines;
234*cdf0e10cSrcweir //UNUSED2009-05     for( sal_Int32 nLine = GetFirstVisLine(); nLine < nEndLine; ++nLine, ++pString )
235*cdf0e10cSrcweir //UNUSED2009-05     {
236*cdf0e10cSrcweir //UNUSED2009-05         if( mbFixedMode )
237*cdf0e10cSrcweir //UNUSED2009-05             maGrid.ImplSetTextLineFix( nLine, String( *pString, eCharSet ) );
238*cdf0e10cSrcweir //UNUSED2009-05         else
239*cdf0e10cSrcweir //UNUSED2009-05             maGrid.ImplSetTextLineSep( nLine, String( *pString, eCharSet ), rSepChars, cTextSep, bMergeSep );
240*cdf0e10cSrcweir //UNUSED2009-05     }
241*cdf0e10cSrcweir //UNUSED2009-05     EnableRepaint();
242*cdf0e10cSrcweir //UNUSED2009-05 }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir // column settings ------------------------------------------------------------
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir void ScCsvTableBox::InitTypes( const ListBox& rListBox )
248*cdf0e10cSrcweir {
249*cdf0e10cSrcweir     sal_uInt16 nTypeCount = rListBox.GetEntryCount();
250*cdf0e10cSrcweir     StringVec aTypeNames( nTypeCount );
251*cdf0e10cSrcweir     for( sal_uInt16 nIndex = 0; nIndex < nTypeCount; ++nIndex )
252*cdf0e10cSrcweir         aTypeNames[ nIndex ] = rListBox.GetEntry( nIndex );
253*cdf0e10cSrcweir     maGrid.SetTypeNames( aTypeNames );
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir void ScCsvTableBox::FillColumnData( ScAsciiOptions& rOptions ) const
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir     if( mbFixedMode )
259*cdf0e10cSrcweir         maGrid.FillColumnDataFix( rOptions );
260*cdf0e10cSrcweir     else
261*cdf0e10cSrcweir         maGrid.FillColumnDataSep( rOptions );
262*cdf0e10cSrcweir }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir // event handling -------------------------------------------------------------
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir void ScCsvTableBox::Resize()
268*cdf0e10cSrcweir {
269*cdf0e10cSrcweir     ScCsvControl::Resize();
270*cdf0e10cSrcweir     InitControls();
271*cdf0e10cSrcweir }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir void ScCsvTableBox::DataChanged( const DataChangedEvent& rDCEvt )
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir     if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
276*cdf0e10cSrcweir         InitControls();
277*cdf0e10cSrcweir     ScCsvControl::DataChanged( rDCEvt );
278*cdf0e10cSrcweir }
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir IMPL_LINK( ScCsvTableBox, CsvCmdHdl, ScCsvControl*, pCtrl )
281*cdf0e10cSrcweir {
282*cdf0e10cSrcweir     DBG_ASSERT( pCtrl, "ScCsvTableBox::CsvCmdHdl - missing sender" );
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     const ScCsvCmd& rCmd = pCtrl->GetCmd();
285*cdf0e10cSrcweir     ScCsvCmdType eType = rCmd.GetType();
286*cdf0e10cSrcweir     sal_Int32 nParam1 = rCmd.GetParam1();
287*cdf0e10cSrcweir     sal_Int32 nParam2 = rCmd.GetParam2();
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir     bool bFound = true;
290*cdf0e10cSrcweir     switch( eType )
291*cdf0e10cSrcweir     {
292*cdf0e10cSrcweir         case CSVCMD_REPAINT:
293*cdf0e10cSrcweir             if( !IsNoRepaint() )
294*cdf0e10cSrcweir             {
295*cdf0e10cSrcweir                 maGrid.ImplRedraw();
296*cdf0e10cSrcweir                 maRuler.ImplRedraw();
297*cdf0e10cSrcweir                 InitHScrollBar();
298*cdf0e10cSrcweir                 InitVScrollBar();
299*cdf0e10cSrcweir             }
300*cdf0e10cSrcweir         break;
301*cdf0e10cSrcweir         case CSVCMD_MAKEPOSVISIBLE:
302*cdf0e10cSrcweir             MakePosVisible( nParam1 );
303*cdf0e10cSrcweir         break;
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir         case CSVCMD_NEWCELLTEXTS:
306*cdf0e10cSrcweir             if( mbFixedMode )
307*cdf0e10cSrcweir                 Execute( CSVCMD_UPDATECELLTEXTS );
308*cdf0e10cSrcweir             else
309*cdf0e10cSrcweir             {
310*cdf0e10cSrcweir                 DisableRepaint();
311*cdf0e10cSrcweir                 ScCsvColStateVec aStates( maGrid.GetColumnStates() );
312*cdf0e10cSrcweir                 sal_Int32 nPos = GetFirstVisPos();
313*cdf0e10cSrcweir                 Execute( CSVCMD_SETPOSCOUNT, 1 );
314*cdf0e10cSrcweir                 Execute( CSVCMD_UPDATECELLTEXTS );
315*cdf0e10cSrcweir                 Execute( CSVCMD_SETPOSOFFSET, nPos );
316*cdf0e10cSrcweir                 maGrid.SetColumnStates( aStates );
317*cdf0e10cSrcweir                 EnableRepaint();
318*cdf0e10cSrcweir             }
319*cdf0e10cSrcweir         break;
320*cdf0e10cSrcweir         case CSVCMD_UPDATECELLTEXTS:
321*cdf0e10cSrcweir             maUpdateTextHdl.Call( this );
322*cdf0e10cSrcweir         break;
323*cdf0e10cSrcweir         case CSVCMD_SETCOLUMNTYPE:
324*cdf0e10cSrcweir             maGrid.SetSelColumnType( nParam1 );
325*cdf0e10cSrcweir         break;
326*cdf0e10cSrcweir         case CSVCMD_EXPORTCOLUMNTYPE:
327*cdf0e10cSrcweir             maColTypeHdl.Call( this );
328*cdf0e10cSrcweir         break;
329*cdf0e10cSrcweir         case CSVCMD_SETFIRSTIMPORTLINE:
330*cdf0e10cSrcweir             maGrid.SetFirstImportedLine( nParam1 );
331*cdf0e10cSrcweir         break;
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir         case CSVCMD_INSERTSPLIT:
334*cdf0e10cSrcweir             DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::InsertSplit - invalid call" );
335*cdf0e10cSrcweir             if( maRuler.GetSplitCount() + 1 < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT) )
336*cdf0e10cSrcweir             {
337*cdf0e10cSrcweir                 maRuler.InsertSplit( nParam1 );
338*cdf0e10cSrcweir                 maGrid.InsertSplit( nParam1 );
339*cdf0e10cSrcweir             }
340*cdf0e10cSrcweir         break;
341*cdf0e10cSrcweir         case CSVCMD_REMOVESPLIT:
342*cdf0e10cSrcweir             DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::RemoveSplit - invalid call" );
343*cdf0e10cSrcweir             maRuler.RemoveSplit( nParam1 );
344*cdf0e10cSrcweir             maGrid.RemoveSplit( nParam1 );
345*cdf0e10cSrcweir         break;
346*cdf0e10cSrcweir         case CSVCMD_TOGGLESPLIT:
347*cdf0e10cSrcweir             Execute( maRuler.HasSplit( nParam1 ) ? CSVCMD_REMOVESPLIT : CSVCMD_INSERTSPLIT, nParam1 );
348*cdf0e10cSrcweir         break;
349*cdf0e10cSrcweir         case CSVCMD_MOVESPLIT:
350*cdf0e10cSrcweir             DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::MoveSplit - invalid call" );
351*cdf0e10cSrcweir             maRuler.MoveSplit( nParam1, nParam2 );
352*cdf0e10cSrcweir             maGrid.MoveSplit( nParam1, nParam2 );
353*cdf0e10cSrcweir         break;
354*cdf0e10cSrcweir         case CSVCMD_REMOVEALLSPLITS:
355*cdf0e10cSrcweir             DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::RemoveAllSplits - invalid call" );
356*cdf0e10cSrcweir             maRuler.RemoveAllSplits();
357*cdf0e10cSrcweir             maGrid.RemoveAllSplits();
358*cdf0e10cSrcweir         break;
359*cdf0e10cSrcweir         default:
360*cdf0e10cSrcweir             bFound = false;
361*cdf0e10cSrcweir     }
362*cdf0e10cSrcweir     if( bFound )
363*cdf0e10cSrcweir         return 0;
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     const ScCsvLayoutData aOldData( maData );
366*cdf0e10cSrcweir     switch( eType )
367*cdf0e10cSrcweir     {
368*cdf0e10cSrcweir         case CSVCMD_SETPOSCOUNT:
369*cdf0e10cSrcweir             maData.mnPosCount = Max( nParam1, sal_Int32( 1 ) );
370*cdf0e10cSrcweir             ImplSetPosOffset( GetFirstVisPos() );
371*cdf0e10cSrcweir         break;
372*cdf0e10cSrcweir         case CSVCMD_SETPOSOFFSET:
373*cdf0e10cSrcweir             ImplSetPosOffset( nParam1 );
374*cdf0e10cSrcweir         break;
375*cdf0e10cSrcweir         case CSVCMD_SETHDRWIDTH:
376*cdf0e10cSrcweir             maData.mnHdrWidth = Max( nParam1, sal_Int32( 0 ) );
377*cdf0e10cSrcweir             ImplSetPosOffset( GetFirstVisPos() );
378*cdf0e10cSrcweir         break;
379*cdf0e10cSrcweir         case CSVCMD_SETCHARWIDTH:
380*cdf0e10cSrcweir             maData.mnCharWidth = Max( nParam1, sal_Int32( 1 ) );
381*cdf0e10cSrcweir             ImplSetPosOffset( GetFirstVisPos() );
382*cdf0e10cSrcweir         break;
383*cdf0e10cSrcweir         case CSVCMD_SETLINECOUNT:
384*cdf0e10cSrcweir             maData.mnLineCount = Max( nParam1, sal_Int32( 1 ) );
385*cdf0e10cSrcweir             ImplSetLineOffset( GetFirstVisLine() );
386*cdf0e10cSrcweir         break;
387*cdf0e10cSrcweir         case CSVCMD_SETLINEOFFSET:
388*cdf0e10cSrcweir             ImplSetLineOffset( nParam1 );
389*cdf0e10cSrcweir         break;
390*cdf0e10cSrcweir         case CSVCMD_SETHDRHEIGHT:
391*cdf0e10cSrcweir             maData.mnHdrHeight = Max( nParam1, sal_Int32( 0 ) );
392*cdf0e10cSrcweir             ImplSetLineOffset( GetFirstVisLine() );
393*cdf0e10cSrcweir         break;
394*cdf0e10cSrcweir         case CSVCMD_SETLINEHEIGHT:
395*cdf0e10cSrcweir             maData.mnLineHeight = Max( nParam1, sal_Int32( 1 ) );
396*cdf0e10cSrcweir             ImplSetLineOffset( GetFirstVisLine() );
397*cdf0e10cSrcweir         break;
398*cdf0e10cSrcweir         case CSVCMD_MOVERULERCURSOR:
399*cdf0e10cSrcweir             maData.mnPosCursor = IsVisibleSplitPos( nParam1 ) ? nParam1 : CSV_POS_INVALID;
400*cdf0e10cSrcweir         break;
401*cdf0e10cSrcweir         case CSVCMD_MOVEGRIDCURSOR:
402*cdf0e10cSrcweir             maData.mnColCursor = ((0 <= nParam1) && (nParam1 < GetPosCount())) ? nParam1 : CSV_POS_INVALID;
403*cdf0e10cSrcweir         break;
404*cdf0e10cSrcweir         default:
405*cdf0e10cSrcweir         {
406*cdf0e10cSrcweir             // added to avoid warnings
407*cdf0e10cSrcweir         }
408*cdf0e10cSrcweir     }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir     if( maData != aOldData )
411*cdf0e10cSrcweir     {
412*cdf0e10cSrcweir         DisableRepaint();
413*cdf0e10cSrcweir         maRuler.ApplyLayout( aOldData );
414*cdf0e10cSrcweir         maGrid.ApplyLayout( aOldData );
415*cdf0e10cSrcweir         EnableRepaint();
416*cdf0e10cSrcweir     }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir     return 0;
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir IMPL_LINK( ScCsvTableBox, ScrollHdl, ScrollBar*, pScrollBar )
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir     DBG_ASSERT( pScrollBar, "ScCsvTableBox::ScrollHdl - missing sender" );
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir     if( pScrollBar == &maHScroll )
426*cdf0e10cSrcweir         Execute( CSVCMD_SETPOSOFFSET, pScrollBar->GetThumbPos() );
427*cdf0e10cSrcweir     else if( pScrollBar == &maVScroll )
428*cdf0e10cSrcweir         Execute( CSVCMD_SETLINEOFFSET, pScrollBar->GetThumbPos() );
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir     return 0;
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir IMPL_LINK( ScCsvTableBox, ScrollEndHdl, ScrollBar*, pScrollBar )
434*cdf0e10cSrcweir {
435*cdf0e10cSrcweir     DBG_ASSERT( pScrollBar, "ScCsvTableBox::ScrollEndHdl - missing sender" );
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir     if( pScrollBar == &maHScroll )
438*cdf0e10cSrcweir     {
439*cdf0e10cSrcweir         if( GetRulerCursorPos() != CSV_POS_INVALID )
440*cdf0e10cSrcweir             Execute( CSVCMD_MOVERULERCURSOR, maRuler.GetNoScrollPos( GetRulerCursorPos() ) );
441*cdf0e10cSrcweir         if( GetGridCursorPos() != CSV_POS_INVALID )
442*cdf0e10cSrcweir             Execute( CSVCMD_MOVEGRIDCURSOR, maGrid.GetNoScrollCol( GetGridCursorPos() ) );
443*cdf0e10cSrcweir     }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir     return 0;
446*cdf0e10cSrcweir }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir // accessibility --------------------------------------------------------------
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir ScCsvTableBox::XAccessibleRef ScCsvTableBox::CreateAccessible()
452*cdf0e10cSrcweir {
453*cdf0e10cSrcweir     // do not use the ScCsvControl mechanism, return default accessible object
454*cdf0e10cSrcweir     return Control::CreateAccessible();
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir ScAccessibleCsvControl* ScCsvTableBox::ImplCreateAccessible()
458*cdf0e10cSrcweir {
459*cdf0e10cSrcweir     return NULL;    // not used, see CreateAccessible()
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir // ============================================================================
464*cdf0e10cSrcweir 
465