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