LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/dbgui - csvgrid.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 815 0.0 %
Date: 2012-12-17 Functions: 0 84 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "csvgrid.hxx"
      21             : 
      22             : #include <algorithm>
      23             : #include <memory>
      24             : 
      25             : #include <comphelper/string.hxx>
      26             : #include <svtools/colorcfg.hxx>
      27             : #include <svl/smplhint.hxx>
      28             : #include <sal/macros.h>
      29             : #include <tools/poly.hxx>
      30             : #include "scmod.hxx"
      31             : #include "asciiopt.hxx"
      32             : #include "impex.hxx"
      33             : #include "AccessibleCsvControl.hxx"
      34             : 
      35             : // *** edit engine ***
      36             : #include "scitems.hxx"
      37             : #include <editeng/eeitem.hxx>
      38             : 
      39             : 
      40             : #include <editeng/colritem.hxx>
      41             : #include <editeng/fhgtitem.hxx>
      42             : #include <editeng/fontitem.hxx>
      43             : #include <svl/itemset.hxx>
      44             : #include "editutil.hxx"
      45             : // *** edit engine ***
      46             : 
      47             : 
      48             : // ============================================================================
      49             : 
      50             : struct Func_SetType
      51             : {
      52             :     sal_Int32                   mnType;
      53           0 :     inline                      Func_SetType( sal_Int32 nType ) : mnType( nType ) {}
      54           0 :     inline void                 operator()( ScCsvColState& rState ) const
      55           0 :         { rState.mnType = mnType; }
      56             : };
      57             : 
      58             : struct Func_Select
      59             : {
      60             :     bool                        mbSelect;
      61           0 :     inline                      Func_Select( bool bSelect ) : mbSelect( bSelect ) {}
      62           0 :     inline void                 operator()( ScCsvColState& rState ) const
      63           0 :         { rState.Select( mbSelect ); }
      64             : };
      65             : 
      66             : 
      67             : // ============================================================================
      68             : 
      69           0 : ScCsvGrid::ScCsvGrid( ScCsvControl& rParent ) :
      70             :     ScCsvControl( rParent ),
      71             :     mpColorConfig( 0 ),
      72           0 :     mpEditEngine( new ScEditEngineDefaulter( EditEngine::CreatePool(), true ) ),
      73           0 :     maHeaderFont( GetFont() ),
      74             :     maColStates( 1 ),
      75             :     maTypeNames( 1 ),
      76             :     mnFirstImpLine( 0 ),
      77           0 :     mnRecentSelCol( CSV_COLUMN_INVALID )
      78             : {
      79           0 :     mpEditEngine->SetRefDevice( &maBackgrDev );
      80           0 :     mpEditEngine->SetRefMapMode( MapMode( MAP_PIXEL ) );
      81           0 :     maEdEngSize = mpEditEngine->GetPaperSize();
      82             : 
      83           0 :     maPopup.SetMenuFlags( maPopup.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
      84             : 
      85           0 :     EnableRTL( false ); // RTL
      86           0 :     InitFonts();
      87           0 :     ImplClearSplits();
      88           0 : }
      89             : 
      90           0 : ScCsvGrid::~ScCsvGrid()
      91             : {
      92             :     OSL_ENSURE(mpColorConfig, "the object hasn't been initialized properly");
      93           0 :     if (mpColorConfig)
      94           0 :         mpColorConfig->RemoveListener(this);
      95           0 : }
      96             : 
      97             : void
      98           0 : ScCsvGrid::Init()
      99             : {
     100             :     OSL_PRECOND(!mpColorConfig, "the object has already been initialized");
     101           0 :     mpColorConfig = &SC_MOD()->GetColorConfig();
     102           0 :     InitColors();
     103           0 :     mpColorConfig->AddListener(this);
     104           0 : }
     105             : 
     106             : // common grid handling -------------------------------------------------------
     107             : 
     108           0 : void ScCsvGrid::UpdateLayoutData()
     109             : {
     110           0 :     DisableRepaint();
     111           0 :     SetFont( maMonoFont );
     112           0 :     Execute( CSVCMD_SETCHARWIDTH, GetTextWidth( rtl::OUString( 'X' ) ) );
     113           0 :     Execute( CSVCMD_SETLINEHEIGHT, GetTextHeight() + 1 );
     114           0 :     SetFont( maHeaderFont );
     115           0 :     Execute( CSVCMD_SETHDRHEIGHT, GetTextHeight() + 1 );
     116           0 :     UpdateOffsetX();
     117           0 :     EnableRepaint();
     118           0 : }
     119             : 
     120           0 : void ScCsvGrid::UpdateOffsetX()
     121             : {
     122           0 :     sal_Int32 nLastLine = GetLastVisLine() + 1;
     123           0 :     sal_Int32 nDigits = 2;
     124           0 :     while( nLastLine /= 10 ) ++nDigits;
     125           0 :     nDigits = Max( nDigits, sal_Int32( 3 ) );
     126           0 :     Execute( CSVCMD_SETHDRWIDTH, GetTextWidth( rtl::OUString( '0' ) ) * nDigits );
     127           0 : }
     128             : 
     129           0 : void ScCsvGrid::ApplyLayout( const ScCsvLayoutData& rOldData )
     130             : {
     131           0 :     ScCsvDiff nDiff = GetLayoutData().GetDiff( rOldData );
     132           0 :     if( nDiff == CSV_DIFF_EQUAL ) return;
     133             : 
     134           0 :     DisableRepaint();
     135             : 
     136           0 :     if( nDiff & CSV_DIFF_RULERCURSOR )
     137             :     {
     138           0 :         ImplInvertCursor( rOldData.mnPosCursor );
     139           0 :         ImplInvertCursor( GetRulerCursorPos() );
     140             :     }
     141             : 
     142           0 :     if( nDiff & CSV_DIFF_POSCOUNT )
     143             :     {
     144           0 :         if( GetPosCount() < rOldData.mnPosCount )
     145             :         {
     146           0 :             SelectAll( false );
     147           0 :             maSplits.RemoveRange( GetPosCount(), rOldData.mnPosCount );
     148             :         }
     149             :         else
     150           0 :             maSplits.Remove( rOldData.mnPosCount );
     151           0 :         maSplits.Insert( GetPosCount() );
     152           0 :         maColStates.resize( maSplits.Count() - 1 );
     153             :     }
     154             : 
     155           0 :     if( nDiff & CSV_DIFF_LINEOFFSET )
     156             :     {
     157           0 :         Execute( CSVCMD_UPDATECELLTEXTS );
     158           0 :         UpdateOffsetX();
     159             :     }
     160             : 
     161           0 :     ScCsvDiff nHVDiff = nDiff & (CSV_DIFF_HORIZONTAL | CSV_DIFF_VERTICAL);
     162           0 :     if( nHVDiff == CSV_DIFF_POSOFFSET )
     163           0 :         ImplDrawHorzScrolled( rOldData.mnPosOffset );
     164           0 :     else if( nHVDiff != CSV_DIFF_EQUAL )
     165           0 :         InvalidateGfx();
     166             : 
     167           0 :     EnableRepaint();
     168             : 
     169           0 :     if( nDiff & (CSV_DIFF_POSOFFSET | CSV_DIFF_LINEOFFSET) )
     170           0 :         AccSendVisibleEvent();
     171             : }
     172             : 
     173           0 : void ScCsvGrid::SetFirstImportedLine( sal_Int32 nLine )
     174             : {
     175           0 :     ImplDrawFirstLineSep( false );
     176           0 :     mnFirstImpLine = nLine;
     177           0 :     ImplDrawFirstLineSep( true );
     178           0 :     ImplDrawGridDev();
     179           0 :     Repaint();
     180           0 : }
     181             : 
     182           0 : sal_Int32 ScCsvGrid::GetNoScrollCol( sal_Int32 nPos ) const
     183             : {
     184           0 :     sal_Int32 nNewPos = nPos;
     185           0 :     if( nNewPos != CSV_POS_INVALID )
     186             :     {
     187           0 :         if( nNewPos < GetFirstVisPos() + CSV_SCROLL_DIST )
     188             :         {
     189           0 :             sal_Int32 nScroll = (GetFirstVisPos() > 0) ? CSV_SCROLL_DIST : 0;
     190           0 :             nNewPos = GetFirstVisPos() + nScroll;
     191             :         }
     192           0 :         else if( nNewPos > GetLastVisPos() - CSV_SCROLL_DIST - 1L )
     193             :         {
     194           0 :             sal_Int32 nScroll = (GetFirstVisPos() < GetMaxPosOffset()) ? CSV_SCROLL_DIST : 0;
     195           0 :             nNewPos = GetLastVisPos() - nScroll - 1;
     196             :         }
     197             :     }
     198           0 :     return nNewPos;
     199             : }
     200             : 
     201           0 : void ScCsvGrid::InitColors()
     202             : {
     203             :     OSL_PRECOND(mpColorConfig, "the object hasn't been initialized properly");
     204           0 :     if ( !mpColorConfig )
     205           0 :         return;
     206           0 :     maBackColor.SetColor( static_cast< sal_uInt32 >( mpColorConfig->GetColorValue( ::svtools::DOCCOLOR ).nColor ) );
     207           0 :     maGridColor.SetColor( static_cast< sal_uInt32 >( mpColorConfig->GetColorValue( ::svtools::CALCGRID ).nColor ) );
     208           0 :     maGridPBColor.SetColor( static_cast< sal_uInt32 >( mpColorConfig->GetColorValue( ::svtools::CALCPAGEBREAK ).nColor ) );
     209           0 :     maAppBackColor.SetColor( static_cast< sal_uInt32 >( mpColorConfig->GetColorValue( ::svtools::APPBACKGROUND ).nColor ) );
     210           0 :     maTextColor.SetColor( static_cast< sal_uInt32 >( mpColorConfig->GetColorValue( ::svtools::FONTCOLOR ).nColor ) );
     211             : 
     212           0 :     const StyleSettings& rSett = GetSettings().GetStyleSettings();
     213           0 :     maHeaderBackColor = rSett.GetFaceColor();
     214           0 :     maHeaderGridColor = rSett.GetDarkShadowColor();
     215           0 :     maHeaderTextColor = rSett.GetButtonTextColor();
     216           0 :     maSelectColor = rSett.GetActiveColor();
     217             : 
     218           0 :     InvalidateGfx();
     219             : }
     220             : 
     221           0 : void ScCsvGrid::InitFonts()
     222             : {
     223           0 :     maMonoFont = OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US, 0 );
     224           0 :     maMonoFont.SetSize( Size( maMonoFont.GetSize().Width(), maHeaderFont.GetSize().Height() ) );
     225             : 
     226             :     /* *** Set edit engine defaults ***
     227             :         maMonoFont for Latin script, smaller default font for Asian and Complex script. */
     228             : 
     229             :     // get default fonts
     230           0 :     SvxFontItem aLatinItem( EE_CHAR_FONTINFO );
     231           0 :     SvxFontItem aAsianItem( EE_CHAR_FONTINFO_CJK );
     232           0 :     SvxFontItem aComplexItem( EE_CHAR_FONTINFO_CTL );
     233           0 :     ::GetDefaultFonts( aLatinItem, aAsianItem, aComplexItem );
     234             : 
     235             :     // create item set for defaults
     236           0 :     SfxItemSet aDefSet( mpEditEngine->GetEmptyItemSet() );
     237           0 :     EditEngine::SetFontInfoInItemSet( aDefSet, maMonoFont );
     238           0 :     aDefSet.Put( aAsianItem );
     239           0 :     aDefSet.Put( aComplexItem );
     240             : 
     241             :     // set Asian/Complex font size to height of character in Latin font
     242           0 :     sal_uLong nFontHt = static_cast< sal_uLong >( maMonoFont.GetSize().Height() );
     243           0 :     aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CJK ) );
     244           0 :     aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CTL ) );
     245             : 
     246             :     // copy other items from default font
     247           0 :     const SfxPoolItem& rWeightItem = aDefSet.Get( EE_CHAR_WEIGHT );
     248           0 :     aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
     249           0 :     aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
     250           0 :     const SfxPoolItem& rItalicItem = aDefSet.Get( EE_CHAR_ITALIC );
     251           0 :     aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
     252           0 :     aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
     253           0 :     const SfxPoolItem& rLangItem = aDefSet.Get( EE_CHAR_LANGUAGE );
     254           0 :     aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
     255           0 :     aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
     256             : 
     257           0 :     mpEditEngine->SetDefaults( aDefSet );
     258           0 :     InvalidateGfx();
     259           0 : }
     260             : 
     261           0 : void ScCsvGrid::InitSizeData()
     262             : {
     263           0 :     maWinSize = GetSizePixel();
     264           0 :     maBackgrDev.SetOutputSizePixel( maWinSize );
     265           0 :     maGridDev.SetOutputSizePixel( maWinSize );
     266           0 :     InvalidateGfx();
     267           0 : }
     268             : 
     269             : 
     270             : // split handling -------------------------------------------------------------
     271             : 
     272           0 : void ScCsvGrid::InsertSplit( sal_Int32 nPos )
     273             : {
     274           0 :     if( ImplInsertSplit( nPos ) )
     275             :     {
     276           0 :         DisableRepaint();
     277           0 :         Execute( CSVCMD_EXPORTCOLUMNTYPE );
     278           0 :         Execute( CSVCMD_UPDATECELLTEXTS );
     279           0 :         sal_uInt32 nColIx = GetColumnFromPos( nPos );
     280           0 :         ImplDrawColumn( nColIx - 1 );
     281           0 :         ImplDrawColumn( nColIx );
     282           0 :         ValidateGfx();  // performance: do not redraw all columns
     283           0 :         EnableRepaint();
     284             :     }
     285           0 : }
     286             : 
     287           0 : void ScCsvGrid::RemoveSplit( sal_Int32 nPos )
     288             : {
     289           0 :     if( ImplRemoveSplit( nPos ) )
     290             :     {
     291           0 :         DisableRepaint();
     292           0 :         Execute( CSVCMD_EXPORTCOLUMNTYPE );
     293           0 :         Execute( CSVCMD_UPDATECELLTEXTS );
     294           0 :         ImplDrawColumn( GetColumnFromPos( nPos ) );
     295           0 :         ValidateGfx();  // performance: do not redraw all columns
     296           0 :         EnableRepaint();
     297             :     }
     298           0 : }
     299             : 
     300           0 : void ScCsvGrid::MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos )
     301             : {
     302           0 :     sal_uInt32 nColIx = GetColumnFromPos( nPos );
     303           0 :     if( nColIx != CSV_COLUMN_INVALID )
     304             :     {
     305           0 :         DisableRepaint();
     306           0 :         if( (GetColumnPos( nColIx - 1 ) < nNewPos) && (nNewPos < GetColumnPos( nColIx + 1 )) )
     307             :         {
     308             :             // move a split in the range between 2 others -> keep selection state of both columns
     309           0 :             maSplits.Remove( nPos );
     310           0 :             maSplits.Insert( nNewPos );
     311           0 :             Execute( CSVCMD_UPDATECELLTEXTS );
     312           0 :             ImplDrawColumn( nColIx - 1 );
     313           0 :             ImplDrawColumn( nColIx );
     314           0 :             ValidateGfx();  // performance: do not redraw all columns
     315           0 :             AccSendTableUpdateEvent( nColIx - 1, nColIx );
     316             :         }
     317             :         else
     318             :         {
     319           0 :             ImplRemoveSplit( nPos );
     320           0 :             ImplInsertSplit( nNewPos );
     321           0 :             Execute( CSVCMD_EXPORTCOLUMNTYPE );
     322           0 :             Execute( CSVCMD_UPDATECELLTEXTS );
     323             :         }
     324           0 :         EnableRepaint();
     325             :     }
     326           0 : }
     327             : 
     328           0 : void ScCsvGrid::RemoveAllSplits()
     329             : {
     330           0 :     DisableRepaint();
     331           0 :     ImplClearSplits();
     332           0 :     Execute( CSVCMD_EXPORTCOLUMNTYPE );
     333           0 :     Execute( CSVCMD_UPDATECELLTEXTS );
     334           0 :     EnableRepaint();
     335           0 : }
     336             : 
     337           0 : void ScCsvGrid::SetSplits( const ScCsvSplits& rSplits )
     338             : {
     339           0 :     DisableRepaint();
     340           0 :     ImplClearSplits();
     341           0 :     sal_uInt32 nCount = rSplits.Count();
     342           0 :     for( sal_uInt32 nIx = 0; nIx < nCount; ++nIx )
     343           0 :         maSplits.Insert( rSplits[ nIx ] );
     344           0 :     maColStates.clear();
     345           0 :     maColStates.resize( maSplits.Count() - 1 );
     346           0 :     Execute( CSVCMD_EXPORTCOLUMNTYPE );
     347           0 :     Execute( CSVCMD_UPDATECELLTEXTS );
     348           0 :     EnableRepaint();
     349           0 : }
     350             : 
     351           0 : bool ScCsvGrid::ImplInsertSplit( sal_Int32 nPos )
     352             : {
     353           0 :     sal_uInt32 nColIx = GetColumnFromPos( nPos );
     354           0 :     bool bRet = (nColIx < GetColumnCount()) && maSplits.Insert( nPos );
     355           0 :     if( bRet )
     356             :     {
     357           0 :         ScCsvColState aState( GetColumnType( nColIx ) );
     358           0 :         aState.Select( IsSelected( nColIx ) && IsSelected( nColIx + 1 ) );
     359           0 :         maColStates.insert( maColStates.begin() + nColIx + 1, aState );
     360           0 :         AccSendInsertColumnEvent( nColIx + 1, nColIx + 1 );
     361           0 :         AccSendTableUpdateEvent( nColIx, nColIx );
     362             :     }
     363           0 :     return bRet;
     364             : }
     365             : 
     366           0 : bool ScCsvGrid::ImplRemoveSplit( sal_Int32 nPos )
     367             : {
     368           0 :     bool bRet = maSplits.Remove( nPos );
     369           0 :     if( bRet )
     370             :     {
     371           0 :         sal_uInt32 nColIx = GetColumnFromPos( nPos );
     372           0 :         bool bSel = IsSelected( nColIx ) || IsSelected( nColIx + 1 );
     373           0 :         maColStates.erase( maColStates.begin() + nColIx + 1 );
     374           0 :         maColStates[ nColIx ].Select( bSel );
     375           0 :         AccSendRemoveColumnEvent( nColIx + 1, nColIx + 1 );
     376           0 :         AccSendTableUpdateEvent( nColIx, nColIx );
     377             :     }
     378           0 :     return bRet;
     379             : }
     380             : 
     381           0 : void ScCsvGrid::ImplClearSplits()
     382             : {
     383           0 :     sal_uInt32 nColumns = GetColumnCount();
     384           0 :     maSplits.Clear();
     385           0 :     maSplits.Insert( 0 );
     386           0 :     maSplits.Insert( GetPosCount() );
     387           0 :     maColStates.resize( 1 );
     388           0 :     InvalidateGfx();
     389           0 :     AccSendRemoveColumnEvent( 1, nColumns - 1 );
     390           0 : }
     391             : 
     392             : // columns/column types -------------------------------------------------------
     393             : 
     394           0 : sal_uInt32 ScCsvGrid::GetFirstVisColumn() const
     395             : {
     396           0 :     return GetColumnFromPos( GetFirstVisPos() );
     397             : }
     398             : 
     399           0 : sal_uInt32 ScCsvGrid::GetLastVisColumn() const
     400             : {
     401           0 :     return GetColumnFromPos( Min( GetLastVisPos(), GetPosCount() ) - 1 );
     402             : }
     403             : 
     404           0 : bool ScCsvGrid::IsValidColumn( sal_uInt32 nColIndex ) const
     405             : {
     406           0 :     return nColIndex < GetColumnCount();
     407             : }
     408             : 
     409           0 : bool ScCsvGrid::IsVisibleColumn( sal_uInt32 nColIndex ) const
     410             : {
     411           0 :     return  IsValidColumn( nColIndex ) &&
     412           0 :             (GetColumnPos( nColIndex ) < GetLastVisPos()) &&
     413           0 :             (GetFirstVisPos() < GetColumnPos( nColIndex + 1 ));
     414             : }
     415             : 
     416           0 : sal_Int32 ScCsvGrid::GetColumnX( sal_uInt32 nColIndex ) const
     417             : {
     418           0 :     return GetX( GetColumnPos( nColIndex ) );
     419             : }
     420             : 
     421           0 : sal_uInt32 ScCsvGrid::GetColumnFromX( sal_Int32 nX ) const
     422             : {
     423           0 :     sal_Int32 nPos = (nX - GetFirstX()) / GetCharWidth() + GetFirstVisPos();
     424           0 :     return ((GetFirstVisPos() <= nPos) && (nPos <= GetLastVisPos())) ?
     425           0 :         GetColumnFromPos( nPos ) : CSV_COLUMN_INVALID;
     426             : }
     427             : 
     428           0 : sal_uInt32 ScCsvGrid::GetColumnFromPos( sal_Int32 nPos ) const
     429             : {
     430           0 :     return maSplits.UpperBound( nPos );
     431             : }
     432             : 
     433           0 : sal_Int32 ScCsvGrid::GetColumnWidth( sal_uInt32 nColIndex ) const
     434             : {
     435           0 :     return IsValidColumn( nColIndex ) ? (GetColumnPos( nColIndex + 1 ) - GetColumnPos( nColIndex )) : 0;
     436             : }
     437             : 
     438           0 : void ScCsvGrid::SetColumnStates( const ScCsvColStateVec& rStates )
     439             : {
     440           0 :     maColStates = rStates;
     441           0 :     maColStates.resize( maSplits.Count() - 1 );
     442           0 :     Execute( CSVCMD_EXPORTCOLUMNTYPE );
     443           0 :     AccSendTableUpdateEvent( 0, GetColumnCount(), false );
     444           0 :     AccSendSelectionEvent();
     445           0 : }
     446             : 
     447           0 : sal_Int32 ScCsvGrid::GetColumnType( sal_uInt32 nColIndex ) const
     448             : {
     449           0 :     return IsValidColumn( nColIndex ) ? maColStates[ nColIndex ].mnType : CSV_TYPE_NOSELECTION;
     450             : }
     451             : 
     452           0 : void ScCsvGrid::SetColumnType( sal_uInt32 nColIndex, sal_Int32 nColType )
     453             : {
     454           0 :     if( IsValidColumn( nColIndex ) )
     455             :     {
     456           0 :         maColStates[ nColIndex ].mnType = nColType;
     457           0 :         AccSendTableUpdateEvent( nColIndex, nColIndex, false );
     458             :     }
     459           0 : }
     460             : 
     461           0 : sal_Int32 ScCsvGrid::GetSelColumnType() const
     462             : {
     463           0 :     sal_uInt32 nColIx = GetFirstSelected();
     464           0 :     if( nColIx == CSV_COLUMN_INVALID )
     465           0 :         return CSV_TYPE_NOSELECTION;
     466             : 
     467           0 :     sal_Int32 nType = GetColumnType( nColIx );
     468           0 :     while( (nColIx != CSV_COLUMN_INVALID) && (nType != CSV_TYPE_MULTI) )
     469             :     {
     470           0 :         if( nType != GetColumnType( nColIx ) )
     471           0 :             nType = CSV_TYPE_MULTI;
     472           0 :         nColIx = GetNextSelected( nColIx );
     473             :     }
     474           0 :     return nType;
     475             : }
     476             : 
     477           0 : void ScCsvGrid::SetSelColumnType( sal_Int32 nType )
     478             : {
     479           0 :     if( (nType != CSV_TYPE_MULTI) && (nType != CSV_TYPE_NOSELECTION) )
     480             :     {
     481           0 :         for( sal_uInt32 nColIx = GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = GetNextSelected( nColIx ) )
     482           0 :             SetColumnType( nColIx, nType );
     483           0 :         Repaint( true );
     484           0 :         Execute( CSVCMD_EXPORTCOLUMNTYPE );
     485             :     }
     486           0 : }
     487             : 
     488           0 : void ScCsvGrid::SetTypeNames( const StringVec& rTypeNames )
     489             : {
     490             :     OSL_ENSURE( !rTypeNames.empty(), "ScCsvGrid::SetTypeNames - vector is empty" );
     491           0 :     maTypeNames = rTypeNames;
     492           0 :     Repaint( true );
     493             : 
     494           0 :     maPopup.Clear();
     495           0 :     sal_uInt32 nCount = maTypeNames.size();
     496             :     sal_uInt32 nIx;
     497             :     sal_uInt16 nItemId;
     498           0 :     for( nIx = 0, nItemId = 1; nIx < nCount; ++nIx, ++nItemId )
     499           0 :         maPopup.InsertItem( nItemId, maTypeNames[ nIx ] );
     500             : 
     501           0 :     ::std::for_each( maColStates.begin(), maColStates.end(), Func_SetType( CSV_TYPE_DEFAULT ) );
     502           0 : }
     503             : 
     504           0 : const String& ScCsvGrid::GetColumnTypeName( sal_uInt32 nColIndex ) const
     505             : {
     506           0 :     sal_uInt32 nTypeIx = static_cast< sal_uInt32 >( GetColumnType( nColIndex ) );
     507           0 :     return (nTypeIx < maTypeNames.size()) ? maTypeNames[ nTypeIx ] : EMPTY_STRING;
     508             : }
     509             : 
     510           0 : static sal_uInt8 lcl_GetExtColumnType( sal_Int32 nIntType )
     511             : {
     512             :     static sal_uInt8 pExtTypes[] =
     513             :         { SC_COL_STANDARD, SC_COL_TEXT, SC_COL_DMY, SC_COL_MDY, SC_COL_YMD, SC_COL_ENGLISH, SC_COL_SKIP };
     514             :     static sal_Int32 nExtTypeCount = SAL_N_ELEMENTS(pExtTypes);
     515           0 :     return pExtTypes[ ((0 <= nIntType) && (nIntType < nExtTypeCount)) ? nIntType : 0 ];
     516             : }
     517             : 
     518           0 : void ScCsvGrid::FillColumnDataSep( ScAsciiOptions& rOptions ) const
     519             : {
     520           0 :     sal_uInt32 nCount = GetColumnCount();
     521           0 :     ScCsvExpDataVec aDataVec;
     522             : 
     523           0 :     for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
     524             :     {
     525           0 :         if( GetColumnType( nColIx ) != CSV_TYPE_DEFAULT )
     526             :             // 1-based column index
     527             :             aDataVec.push_back( ScCsvExpData(
     528             :                 static_cast< sal_Int32 >( nColIx + 1 ),
     529           0 :                 lcl_GetExtColumnType( GetColumnType( nColIx ) ) ) );
     530             :     }
     531           0 :     rOptions.SetColumnInfo( aDataVec );
     532           0 : }
     533             : 
     534           0 : void ScCsvGrid::FillColumnDataFix( ScAsciiOptions& rOptions ) const
     535             : {
     536           0 :     sal_uInt32 nCount = Min( GetColumnCount(), static_cast<sal_uInt32>(MAXCOLCOUNT) );
     537           0 :     ScCsvExpDataVec aDataVec( nCount + 1 );
     538             : 
     539           0 :     for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
     540             :     {
     541           0 :         ScCsvExpData& rData = aDataVec[ nColIx ];
     542           0 :         rData.mnIndex = static_cast< sal_Int32 >( GetColumnPos( nColIx ) );
     543           0 :         rData.mnType = lcl_GetExtColumnType( GetColumnType( nColIx ) );
     544             :     }
     545           0 :     aDataVec[ nCount ].mnIndex = SAL_MAX_INT32;
     546           0 :     aDataVec[ nCount ].mnType = SC_COL_SKIP;
     547           0 :     rOptions.SetColumnInfo( aDataVec );
     548           0 : }
     549             : 
     550           0 : void ScCsvGrid::ScrollVertRel( ScMoveMode eDir )
     551             : {
     552           0 :     sal_Int32 nLine = GetFirstVisLine();
     553           0 :     switch( eDir )
     554             :     {
     555           0 :         case MOVE_PREV:     --nLine;                        break;
     556           0 :         case MOVE_NEXT:     ++nLine;                        break;
     557           0 :         case MOVE_FIRST:    nLine = 0;                      break;
     558           0 :         case MOVE_LAST:     nLine = GetMaxLineOffset();     break;
     559           0 :         case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 2; break;
     560           0 :         case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 2; break;
     561             :         default:
     562             :         {
     563             :             // added to avoid warnings
     564             :         }
     565             :     }
     566           0 :     Execute( CSVCMD_SETLINEOFFSET, nLine );
     567           0 : }
     568             : 
     569           0 : void ScCsvGrid::ExecutePopup( const Point& rPos )
     570             : {
     571           0 :     sal_uInt16 nItemId = maPopup.Execute( this, rPos );
     572           0 :     if( nItemId )   // 0 = cancelled
     573           0 :         Execute( CSVCMD_SETCOLUMNTYPE, maPopup.GetItemPos( nItemId ) );
     574           0 : }
     575             : 
     576             : 
     577             : // selection handling ---------------------------------------------------------
     578             : 
     579           0 : bool ScCsvGrid::IsSelected( sal_uInt32 nColIndex ) const
     580             : {
     581           0 :     return IsValidColumn( nColIndex ) && maColStates[ nColIndex ].IsSelected();
     582             : }
     583             : 
     584           0 : sal_uInt32 ScCsvGrid::GetFirstSelected() const
     585             : {
     586           0 :     return IsSelected( 0 ) ? 0 : GetNextSelected( 0 );
     587             : }
     588             : 
     589           0 : sal_uInt32 ScCsvGrid::GetNextSelected( sal_uInt32 nFromIndex ) const
     590             : {
     591           0 :     sal_uInt32 nColCount = GetColumnCount();
     592           0 :     for( sal_uInt32 nColIx = nFromIndex + 1; nColIx < nColCount; ++nColIx )
     593           0 :         if( IsSelected( nColIx ) )
     594           0 :             return nColIx;
     595           0 :     return CSV_COLUMN_INVALID;
     596             : }
     597             : 
     598           0 : void ScCsvGrid::Select( sal_uInt32 nColIndex, bool bSelect )
     599             : {
     600           0 :     if( IsValidColumn( nColIndex ) )
     601             :     {
     602           0 :         maColStates[ nColIndex ].Select( bSelect );
     603           0 :         ImplDrawColumnSelection( nColIndex );
     604           0 :         Repaint();
     605           0 :         Execute( CSVCMD_EXPORTCOLUMNTYPE );
     606           0 :         if( bSelect )
     607           0 :             mnRecentSelCol = nColIndex;
     608           0 :         AccSendSelectionEvent();
     609             :     }
     610           0 : }
     611             : 
     612           0 : void ScCsvGrid::ToggleSelect( sal_uInt32 nColIndex )
     613             : {
     614           0 :     Select( nColIndex, !IsSelected( nColIndex ) );
     615           0 : }
     616             : 
     617           0 : void ScCsvGrid::SelectRange( sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect )
     618             : {
     619           0 :     if( nColIndex1 == CSV_COLUMN_INVALID )
     620           0 :         Select( nColIndex2 );
     621           0 :     else if( nColIndex2 == CSV_COLUMN_INVALID )
     622           0 :         Select( nColIndex1 );
     623           0 :     else if( nColIndex1 > nColIndex2 )
     624             :     {
     625           0 :         SelectRange( nColIndex2, nColIndex1, bSelect );
     626           0 :         if( bSelect )
     627           0 :             mnRecentSelCol = nColIndex1;
     628             :     }
     629           0 :     else if( IsValidColumn( nColIndex1 ) && IsValidColumn( nColIndex2 ) )
     630             :     {
     631           0 :         for( sal_uInt32 nColIx = nColIndex1; nColIx <= nColIndex2; ++nColIx )
     632             :         {
     633           0 :             maColStates[ nColIx ].Select( bSelect );
     634           0 :             ImplDrawColumnSelection( nColIx );
     635             :         }
     636           0 :         Repaint();
     637           0 :         Execute( CSVCMD_EXPORTCOLUMNTYPE );
     638           0 :         if( bSelect )
     639           0 :             mnRecentSelCol = nColIndex1;
     640           0 :         AccSendSelectionEvent();
     641             :     }
     642           0 : }
     643             : 
     644           0 : void ScCsvGrid::SelectAll( bool bSelect )
     645             : {
     646           0 :     SelectRange( 0, GetColumnCount() - 1, bSelect );
     647           0 : }
     648             : 
     649           0 : void ScCsvGrid::MoveCursor( sal_uInt32 nColIndex )
     650             : {
     651           0 :     DisableRepaint();
     652           0 :     if( IsValidColumn( nColIndex ) )
     653             :     {
     654           0 :         sal_Int32 nPosBeg = GetColumnPos( nColIndex );
     655           0 :         sal_Int32 nPosEnd = GetColumnPos( nColIndex + 1 );
     656           0 :         sal_Int32 nMinPos = Max( nPosBeg - CSV_SCROLL_DIST, sal_Int32( 0 ) );
     657           0 :         sal_Int32 nMaxPos = Min( nPosEnd - GetVisPosCount() + CSV_SCROLL_DIST + sal_Int32( 1 ), nMinPos );
     658           0 :         if( nPosBeg - CSV_SCROLL_DIST + 1 <= GetFirstVisPos() )
     659           0 :             Execute( CSVCMD_SETPOSOFFSET, nMinPos );
     660           0 :         else if( nPosEnd + CSV_SCROLL_DIST >= GetLastVisPos() )
     661           0 :             Execute( CSVCMD_SETPOSOFFSET, nMaxPos );
     662             :     }
     663           0 :     Execute( CSVCMD_MOVEGRIDCURSOR, GetColumnPos( nColIndex ) );
     664           0 :     EnableRepaint();
     665           0 : }
     666             : 
     667           0 : void ScCsvGrid::MoveCursorRel( ScMoveMode eDir )
     668             : {
     669           0 :     if( GetFocusColumn() != CSV_COLUMN_INVALID )
     670             :     {
     671           0 :         switch( eDir )
     672             :         {
     673             :             case MOVE_FIRST:
     674           0 :                 MoveCursor( 0 );
     675           0 :             break;
     676             :             case MOVE_LAST:
     677           0 :                 MoveCursor( GetColumnCount() - 1 );
     678           0 :             break;
     679             :             case MOVE_PREV:
     680           0 :                 if( GetFocusColumn() > 0 )
     681           0 :                     MoveCursor( GetFocusColumn() - 1 );
     682           0 :             break;
     683             :             case MOVE_NEXT:
     684           0 :                 if( GetFocusColumn() < GetColumnCount() - 1 )
     685           0 :                     MoveCursor( GetFocusColumn() + 1 );
     686           0 :             break;
     687             :             default:
     688             :             {
     689             :                 // added to avoid warnings
     690             :             }
     691             :         }
     692             :     }
     693           0 : }
     694             : 
     695           0 : void ScCsvGrid::ImplClearSelection()
     696             : {
     697           0 :     ::std::for_each( maColStates.begin(), maColStates.end(), Func_Select( false ) );
     698           0 :     ImplDrawGridDev();
     699           0 : }
     700             : 
     701           0 : void ScCsvGrid::DoSelectAction( sal_uInt32 nColIndex, sal_uInt16 nModifier )
     702             : {
     703           0 :     if( !(nModifier & KEY_MOD1) )
     704           0 :         ImplClearSelection();
     705           0 :     if( nModifier & KEY_SHIFT )             // SHIFT always expands
     706           0 :         SelectRange( mnRecentSelCol, nColIndex );
     707           0 :     else if( !(nModifier & KEY_MOD1) )      // no SHIFT/CTRL always selects 1 column
     708           0 :         Select( nColIndex );
     709           0 :     else if( IsTracking() )                 // CTRL in tracking does not toggle
     710           0 :         Select( nColIndex, mbMTSelecting );
     711             :     else                                    // CTRL only toggles
     712           0 :         ToggleSelect( nColIndex );
     713           0 :     Execute( CSVCMD_MOVEGRIDCURSOR, GetColumnPos( nColIndex ) );
     714           0 : }
     715             : 
     716             : 
     717             : // cell contents --------------------------------------------------------------
     718             : 
     719           0 : void ScCsvGrid::ImplSetTextLineSep(
     720             :         sal_Int32 nLine, const rtl::OUString& rTextLine,
     721             :         const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep )
     722             : {
     723           0 :     if( nLine < GetFirstVisLine() ) return;
     724             : 
     725           0 :     sal_uInt32 nLineIx = nLine - GetFirstVisLine();
     726           0 :     while( maTexts.size() <= nLineIx )
     727           0 :         maTexts.push_back( StringVec() );
     728           0 :     StringVec& rStrVec = maTexts[ nLineIx ];
     729           0 :     rStrVec.clear();
     730             : 
     731             :     // scan for separators
     732           0 :     String aCellText;
     733           0 :     const sal_Unicode* pSepChars = rSepChars.GetBuffer();
     734           0 :     const sal_Unicode* pChar = rTextLine.getStr();
     735           0 :     sal_uInt32 nColIx = 0;
     736             : 
     737           0 :     while( *pChar && (nColIx < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT)) )
     738             :     {
     739             :         // scan for next cell text
     740           0 :         bool bIsQuoted = false;
     741           0 :         bool bOverflowCell = false;
     742             :         pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText,
     743           0 :                 cTextSep, pSepChars, bMergeSep, bIsQuoted, bOverflowCell );
     744             :         /* TODO: signal overflow somewhere in UI */
     745             : 
     746             :         // update column width
     747           0 :         sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + sal_Int32( 1 ) );
     748           0 :         if( IsValidColumn( nColIx ) )
     749             :         {
     750             :             // expand existing column
     751           0 :             sal_Int32 nDiff = nWidth - GetColumnWidth( nColIx );
     752           0 :             if( nDiff > 0 )
     753             :             {
     754           0 :                 Execute( CSVCMD_SETPOSCOUNT, GetPosCount() + nDiff );
     755           0 :                 for( sal_uInt32 nSplitIx = GetColumnCount() - 1; nSplitIx > nColIx; --nSplitIx )
     756             :                 {
     757           0 :                     sal_Int32 nPos = maSplits[ nSplitIx ];
     758           0 :                     maSplits.Remove( nPos );
     759           0 :                     maSplits.Insert( nPos + nDiff );
     760             :                 }
     761             :             }
     762             :         }
     763             :         else
     764             :         {
     765             :             // append new column
     766           0 :             sal_Int32 nLastPos = GetPosCount();
     767           0 :             Execute( CSVCMD_SETPOSCOUNT, nLastPos + nWidth );
     768           0 :             ImplInsertSplit( nLastPos );
     769             :         }
     770             : 
     771           0 :         if( aCellText.Len() <= CSV_MAXSTRLEN )
     772           0 :             rStrVec.push_back( aCellText );
     773             :         else
     774           0 :             rStrVec.push_back( aCellText.Copy( 0, CSV_MAXSTRLEN ) );
     775           0 :         ++nColIx;
     776             :     }
     777           0 :     InvalidateGfx();
     778             : }
     779             : 
     780           0 : void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const rtl::OUString& rTextLine )
     781             : {
     782           0 :     if( nLine < GetFirstVisLine() ) return;
     783             : 
     784           0 :     sal_Int32 nChars = rTextLine.getLength();
     785           0 :     if( nChars > GetPosCount() )
     786           0 :         Execute( CSVCMD_SETPOSCOUNT, nChars );
     787             : 
     788           0 :     sal_uInt32 nLineIx = nLine - GetFirstVisLine();
     789           0 :     while( maTexts.size() <= nLineIx )
     790           0 :         maTexts.push_back( StringVec() );
     791             : 
     792           0 :     StringVec& rStrVec = maTexts[ nLineIx ];
     793           0 :     rStrVec.clear();
     794           0 :     sal_uInt32 nColCount = GetColumnCount();
     795           0 :     sal_Int32 nStrLen = rTextLine.getLength();
     796           0 :     sal_Int32 nStrIx = 0;
     797           0 :     for( sal_uInt32 nColIx = 0; (nColIx < nColCount) && (nStrIx < nStrLen); ++nColIx )
     798             :     {
     799           0 :         sal_Int32 nColWidth = GetColumnWidth( nColIx );
     800           0 :         sal_Int32 nLen = std::min( std::min( nColWidth, static_cast<sal_Int32>(CSV_MAXSTRLEN) ), nStrLen - nStrIx);
     801           0 :         rStrVec.push_back( rTextLine.copy( nStrIx, nLen ) );
     802           0 :         nStrIx = nStrIx + nColWidth;
     803             :     }
     804           0 :     InvalidateGfx();
     805             : }
     806             : 
     807           0 : const String& ScCsvGrid::GetCellText( sal_uInt32 nColIndex, sal_Int32 nLine ) const
     808             : {
     809           0 :     if( nLine < GetFirstVisLine() ) return EMPTY_STRING;
     810             : 
     811           0 :     sal_uInt32 nLineIx = nLine - GetFirstVisLine();
     812           0 :     if( nLineIx >= maTexts.size() ) return EMPTY_STRING;
     813             : 
     814           0 :     const StringVec& rStrVec = maTexts[ nLineIx ];
     815           0 :     if( nColIndex >= rStrVec.size() ) return EMPTY_STRING;
     816             : 
     817           0 :     return rStrVec[ nColIndex ];
     818             : }
     819             : 
     820             : 
     821             : // event handling -------------------------------------------------------------
     822             : 
     823           0 : void ScCsvGrid::Resize()
     824             : {
     825           0 :     ScCsvControl::Resize();
     826           0 :     InitSizeData();
     827           0 :     Execute( CSVCMD_UPDATECELLTEXTS );
     828           0 : }
     829             : 
     830           0 : void ScCsvGrid::GetFocus()
     831             : {
     832           0 :     ScCsvControl::GetFocus();
     833           0 :     Execute( CSVCMD_MOVEGRIDCURSOR, GetNoScrollCol( GetGridCursorPos() ) );
     834           0 :     Repaint();
     835           0 : }
     836             : 
     837           0 : void ScCsvGrid::LoseFocus()
     838             : {
     839           0 :     ScCsvControl::LoseFocus();
     840           0 :     Repaint();
     841           0 : }
     842             : 
     843           0 : void ScCsvGrid::MouseButtonDown( const MouseEvent& rMEvt )
     844             : {
     845           0 :     DisableRepaint();
     846           0 :     if( !HasFocus() )
     847           0 :         GrabFocus();
     848             : 
     849           0 :     Point aPos( rMEvt.GetPosPixel() );
     850           0 :     sal_uInt32 nColIx = GetColumnFromX( aPos.X() );
     851             : 
     852           0 :     if( rMEvt.IsLeft() )
     853             :     {
     854           0 :         if( (GetFirstX() > aPos.X()) || (aPos.X() > GetLastX()) )   // in header column
     855             :         {
     856           0 :             if( aPos.Y() <= GetHdrHeight() )
     857           0 :                 SelectAll();
     858             :         }
     859           0 :         else if( IsValidColumn( nColIx ) )
     860             :         {
     861           0 :             DoSelectAction( nColIx, rMEvt.GetModifier() );
     862           0 :             mnMTCurrCol = nColIx;
     863           0 :             mbMTSelecting = IsSelected( nColIx );
     864           0 :             StartTracking( STARTTRACK_BUTTONREPEAT );
     865             :         }
     866             :     }
     867           0 :     EnableRepaint();
     868           0 : }
     869             : 
     870           0 : void ScCsvGrid::Tracking( const TrackingEvent& rTEvt )
     871             : {
     872           0 :     if( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingRepeat() )
     873             :     {
     874           0 :         DisableRepaint();
     875           0 :         const MouseEvent& rMEvt = rTEvt.GetMouseEvent();
     876             : 
     877           0 :         sal_Int32 nPos = (rMEvt.GetPosPixel().X() - GetFirstX()) / GetCharWidth() + GetFirstVisPos();
     878             :         // on mouse tracking: keep position valid
     879           0 :         nPos = Max( Min( nPos, GetPosCount() - sal_Int32( 1 ) ), sal_Int32( 0 ) );
     880           0 :         Execute( CSVCMD_MAKEPOSVISIBLE, nPos );
     881             : 
     882           0 :         sal_uInt32 nColIx = GetColumnFromPos( nPos );
     883           0 :         if( mnMTCurrCol != nColIx )
     884             :         {
     885           0 :             DoSelectAction( nColIx, rMEvt.GetModifier() );
     886           0 :             mnMTCurrCol = nColIx;
     887             :         }
     888           0 :         EnableRepaint();
     889             :     }
     890           0 : }
     891             : 
     892           0 : void ScCsvGrid::KeyInput( const KeyEvent& rKEvt )
     893             : {
     894           0 :     const KeyCode& rKCode = rKEvt.GetKeyCode();
     895           0 :     sal_uInt16 nCode = rKCode.GetCode();
     896           0 :     bool bShift = rKCode.IsShift() == sal_True;
     897           0 :     bool bMod1 = rKCode.IsMod1() == sal_True;
     898             : 
     899           0 :     if( !rKCode.IsMod2() )
     900             :     {
     901           0 :         ScMoveMode eHDir = GetHorzDirection( nCode, !bMod1 );
     902           0 :         ScMoveMode eVDir = GetVertDirection( nCode, bMod1 );
     903             : 
     904           0 :         if( eHDir != MOVE_NONE )
     905             :         {
     906           0 :             DisableRepaint();
     907           0 :             MoveCursorRel( eHDir );
     908           0 :             if( !bMod1 )
     909           0 :                 ImplClearSelection();
     910           0 :             if( bShift )
     911           0 :                 SelectRange( mnRecentSelCol, GetFocusColumn() );
     912           0 :             else if( !bMod1 )
     913           0 :                 Select( GetFocusColumn() );
     914           0 :             EnableRepaint();
     915             :         }
     916           0 :         else if( eVDir != MOVE_NONE )
     917           0 :             ScrollVertRel( eVDir );
     918           0 :         else if( nCode == KEY_SPACE )
     919             :         {
     920           0 :             if( !bMod1 )
     921           0 :                 ImplClearSelection();
     922           0 :             if( bShift )
     923           0 :                 SelectRange( mnRecentSelCol, GetFocusColumn() );
     924           0 :             else if( bMod1 )
     925           0 :                 ToggleSelect( GetFocusColumn() );
     926             :             else
     927           0 :                 Select( GetFocusColumn() );
     928             :         }
     929           0 :         else if( !bShift && bMod1 )
     930             :         {
     931           0 :             if( nCode == KEY_A )
     932           0 :                 SelectAll();
     933           0 :             else if( (KEY_1 <= nCode) && (nCode <= KEY_9) )
     934             :             {
     935           0 :                 sal_uInt32 nType = nCode - KEY_1;
     936           0 :                 if( nType < maTypeNames.size() )
     937           0 :                     Execute( CSVCMD_SETCOLUMNTYPE, nType );
     938             :             }
     939             :         }
     940             :     }
     941             : 
     942           0 :     if( rKCode.GetGroup() != KEYGROUP_CURSOR )
     943           0 :         ScCsvControl::KeyInput( rKEvt );
     944           0 : }
     945             : 
     946           0 : void ScCsvGrid::Command( const CommandEvent& rCEvt )
     947             : {
     948           0 :     switch( rCEvt.GetCommand() )
     949             :     {
     950             :         case COMMAND_CONTEXTMENU:
     951             :         {
     952           0 :             if( rCEvt.IsMouseEvent() )
     953             :             {
     954           0 :                 Point aPos( rCEvt.GetMousePosPixel() );
     955           0 :                 sal_uInt32 nColIx = GetColumnFromX( aPos.X() );
     956           0 :                 if( IsValidColumn( nColIx ) && (GetFirstX() <= aPos.X()) && (aPos.X() <= GetLastX()) )
     957             :                 {
     958           0 :                     if( !IsSelected( nColIx ) )
     959           0 :                         DoSelectAction( nColIx, 0 );    // focus & select
     960           0 :                     ExecutePopup( aPos );
     961             :                 }
     962             :             }
     963             :             else
     964             :             {
     965           0 :                 sal_uInt32 nColIx = GetFocusColumn();
     966           0 :                 if( !IsSelected( nColIx ) )
     967           0 :                     Select( nColIx );
     968           0 :                 sal_Int32 nX1 = Max( GetColumnX( nColIx ), GetFirstX() );
     969           0 :                 sal_Int32 nX2 = Min( GetColumnX( nColIx + 1 ), GetWidth() );
     970           0 :                 ExecutePopup( Point( (nX1 + nX2) / 2, GetHeight() / 2 ) );
     971             :             }
     972             :         }
     973           0 :         break;
     974             :         case COMMAND_WHEEL:
     975             :         {
     976           0 :             Point aPoint;
     977           0 :             Rectangle aRect( aPoint, maWinSize );
     978           0 :             if( aRect.IsInside( rCEvt.GetMousePosPixel() ) )
     979             :             {
     980           0 :                 const CommandWheelData* pData = rCEvt.GetWheelData();
     981           0 :                 if( pData && (pData->GetMode() == COMMAND_WHEEL_SCROLL) && !pData->IsHorz() )
     982           0 :                     Execute( CSVCMD_SETLINEOFFSET, GetFirstVisLine() - pData->GetNotchDelta() );
     983             :             }
     984             :         }
     985           0 :         break;
     986             :         default:
     987           0 :             ScCsvControl::Command( rCEvt );
     988             :     }
     989           0 : }
     990             : 
     991           0 : void ScCsvGrid::DataChanged( const DataChangedEvent& rDCEvt )
     992             : {
     993           0 :     if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     994             :     {
     995           0 :         InitColors();
     996           0 :         InitFonts();
     997           0 :         UpdateLayoutData();
     998           0 :         Execute( CSVCMD_UPDATECELLTEXTS );
     999             :     }
    1000           0 :     ScCsvControl::DataChanged( rDCEvt );
    1001           0 : }
    1002             : 
    1003           0 : void ScCsvGrid::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
    1004             : {
    1005           0 :     InitColors();
    1006           0 :     Repaint();
    1007           0 : }
    1008             : 
    1009             : 
    1010             : // painting -------------------------------------------------------------------
    1011             : 
    1012           0 : void ScCsvGrid::Paint( const Rectangle& )
    1013             : {
    1014           0 :     Repaint();
    1015           0 : }
    1016             : 
    1017           0 : void ScCsvGrid::ImplRedraw()
    1018             : {
    1019           0 :     if( IsVisible() )
    1020             :     {
    1021           0 :         if( !IsValidGfx() )
    1022             :         {
    1023           0 :             ValidateGfx();
    1024           0 :             ImplDrawBackgrDev();
    1025           0 :             ImplDrawGridDev();
    1026             :         }
    1027           0 :         DrawOutDev( Point(), maWinSize, Point(), maWinSize, maGridDev );
    1028           0 :         ImplDrawTrackingRect( GetFocusColumn() );
    1029             :     }
    1030           0 : }
    1031             : 
    1032           0 : EditEngine* ScCsvGrid::GetEditEngine()
    1033             : {
    1034           0 :     return mpEditEngine.get();
    1035             : }
    1036             : 
    1037           0 : void ScCsvGrid::ImplSetColumnClipRegion( OutputDevice& rOutDev, sal_uInt32 nColIndex )
    1038             : {
    1039             :     rOutDev.SetClipRegion( Region( Rectangle(
    1040           0 :         Max( GetColumnX( nColIndex ), GetFirstX() ) + 1, 0,
    1041           0 :         Min( GetColumnX( nColIndex + 1 ), GetLastX() ), GetHeight() - 1 ) ) );
    1042           0 : }
    1043             : 
    1044           0 : void ScCsvGrid::ImplDrawColumnHeader( OutputDevice& rOutDev, sal_uInt32 nColIndex, Color aFillColor )
    1045             : {
    1046           0 :     sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
    1047           0 :     sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
    1048           0 :     sal_Int32 nHdrHt = GetHdrHeight();
    1049             : 
    1050           0 :     rOutDev.SetLineColor();
    1051           0 :     rOutDev.SetFillColor( aFillColor );
    1052           0 :     rOutDev.DrawRect( Rectangle( nX1, 0, nX2, nHdrHt ) );
    1053             : 
    1054           0 :     rOutDev.SetFont( maHeaderFont );
    1055           0 :     rOutDev.SetTextColor( maHeaderTextColor );
    1056           0 :     rOutDev.SetTextFillColor();
    1057           0 :     rOutDev.DrawText( Point( nX1 + 1, 0 ), GetColumnTypeName( nColIndex ) );
    1058             : 
    1059           0 :     rOutDev.SetLineColor( maHeaderGridColor );
    1060           0 :     rOutDev.DrawLine( Point( nX1, nHdrHt ), Point( nX2, nHdrHt ) );
    1061           0 :     rOutDev.DrawLine( Point( nX2, 0 ), Point( nX2, nHdrHt ) );
    1062           0 : }
    1063             : 
    1064           0 : void ScCsvGrid::ImplDrawCellText( const Point& rPos, const String& rText )
    1065             : {
    1066           0 :     String aPlainText( rText );
    1067           0 :     aPlainText.SearchAndReplaceAll( '\t', ' ' );
    1068           0 :     aPlainText.SearchAndReplaceAll( '\n', ' ' );
    1069           0 :     mpEditEngine->SetPaperSize( maEdEngSize );
    1070             : 
    1071             :     /*  #i60296# If string contains mixed script types, the space character
    1072             :         U+0020 may be drawn with a wrong width (from non-fixed-width Asian or
    1073             :         Complex font). Now we draw every non-space portion separately. */
    1074           0 :     xub_StrLen nTokenCount = comphelper::string::getTokenCount(aPlainText, ' ');
    1075           0 :     xub_StrLen nCharIx = 0;
    1076           0 :     for( xub_StrLen nToken = 0; nToken < nTokenCount; ++nToken )
    1077             :     {
    1078           0 :         xub_StrLen nBeginIx = nCharIx;
    1079           0 :         String aToken = aPlainText.GetToken( 0, ' ', nCharIx );
    1080           0 :         if( aToken.Len() > 0 )
    1081             :         {
    1082           0 :             sal_Int32 nX = rPos.X() + GetCharWidth() * nBeginIx;
    1083           0 :             mpEditEngine->SetText( aToken );
    1084           0 :             mpEditEngine->Draw( &maBackgrDev, Point( nX, rPos.Y() ) );
    1085             :         }
    1086           0 :     }
    1087             : 
    1088           0 :     nCharIx = 0;
    1089           0 :     while( (nCharIx = rText.Search( '\t', nCharIx )) != STRING_NOTFOUND )
    1090             :     {
    1091           0 :         sal_Int32 nX1 = rPos.X() + GetCharWidth() * nCharIx;
    1092           0 :         sal_Int32 nX2 = nX1 + GetCharWidth() - 2;
    1093           0 :         sal_Int32 nY = rPos.Y() + GetLineHeight() / 2;
    1094           0 :         Color aColor( maTextColor );
    1095           0 :         maBackgrDev.SetLineColor( aColor );
    1096           0 :         maBackgrDev.DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
    1097           0 :         maBackgrDev.DrawLine( Point( nX2 - 2, nY - 2 ), Point( nX2, nY ) );
    1098           0 :         maBackgrDev.DrawLine( Point( nX2 - 2, nY + 2 ), Point( nX2, nY ) );
    1099           0 :         ++nCharIx;
    1100             :     }
    1101           0 :     nCharIx = 0;
    1102           0 :     while( (nCharIx = rText.Search( '\n', nCharIx )) != STRING_NOTFOUND )
    1103             :     {
    1104           0 :         sal_Int32 nX1 = rPos.X() + GetCharWidth() * nCharIx;
    1105           0 :         sal_Int32 nX2 = nX1 + GetCharWidth() - 2;
    1106           0 :         sal_Int32 nY = rPos.Y() + GetLineHeight() / 2;
    1107           0 :         Color aColor( maTextColor );
    1108           0 :         maBackgrDev.SetLineColor( aColor );
    1109           0 :         maBackgrDev.DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
    1110           0 :         maBackgrDev.DrawLine( Point( nX1 + 2, nY - 2 ), Point( nX1, nY ) );
    1111           0 :         maBackgrDev.DrawLine( Point( nX1 + 2, nY + 2 ), Point( nX1, nY ) );
    1112           0 :         maBackgrDev.DrawLine( Point( nX2, nY - 2 ), Point( nX2, nY ) );
    1113           0 :         ++nCharIx;
    1114           0 :     }
    1115           0 : }
    1116             : 
    1117           0 : void ScCsvGrid::ImplDrawFirstLineSep( bool bSet )
    1118             : {
    1119           0 :     if( IsVisibleLine( mnFirstImpLine ) && (mnFirstImpLine != GetFirstVisLine() ) )
    1120             :     {
    1121           0 :         sal_Int32 nY = GetY( mnFirstImpLine );
    1122           0 :         sal_Int32 nX = Min( GetColumnX( GetLastVisColumn() + 1 ), GetLastX() );
    1123           0 :         maBackgrDev.SetLineColor( bSet ? maGridPBColor : maGridColor );
    1124           0 :         maBackgrDev.DrawLine( Point( GetFirstX() + 1, nY ), Point( nX, nY ) );
    1125             :     }
    1126           0 : }
    1127             : 
    1128           0 : void ScCsvGrid::ImplDrawColumnBackgr( sal_uInt32 nColIndex )
    1129             : {
    1130           0 :     if( !IsVisibleColumn( nColIndex ) )
    1131           0 :         return;
    1132             : 
    1133           0 :     ImplSetColumnClipRegion( maBackgrDev, nColIndex );
    1134             : 
    1135             :     // grid
    1136           0 :     maBackgrDev.SetLineColor();
    1137           0 :     maBackgrDev.SetFillColor( maBackColor );
    1138           0 :     sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
    1139           0 :     sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
    1140           0 :     sal_Int32 nY2 = GetY( GetLastVisLine() + 1 );
    1141           0 :     sal_Int32 nHdrHt = GetHdrHeight();
    1142           0 :     Rectangle aRect( nX1, nHdrHt, nX2, nY2 );
    1143           0 :     maBackgrDev.DrawRect( aRect );
    1144           0 :     maBackgrDev.SetLineColor( maGridColor );
    1145           0 :     maBackgrDev.DrawGrid( aRect, Size( 1, GetLineHeight() ), GRID_HORZLINES );
    1146           0 :     maBackgrDev.DrawLine( Point( nX2, nHdrHt ), Point( nX2, nY2 ) );
    1147           0 :     ImplDrawFirstLineSep( true );
    1148             : 
    1149             :     // cell texts
    1150           0 :     mpEditEngine->SetDefaultItem( SvxColorItem( maTextColor, EE_CHAR_COLOR ) );
    1151           0 :     size_t nLineCount = ::std::min( static_cast< size_t >( GetLastVisLine() - GetFirstVisLine() + 1 ), maTexts.size() );
    1152             :     // #i67432# cut string to avoid edit engine performance problems with very large strings
    1153           0 :     sal_Int32 nFirstVisPos = ::std::max( GetColumnPos( nColIndex ), GetFirstVisPos() );
    1154           0 :     sal_Int32 nLastVisPos = ::std::min( GetColumnPos( nColIndex + 1 ), GetLastVisPos() );
    1155           0 :     xub_StrLen nStrPos = static_cast< xub_StrLen >( nFirstVisPos - GetColumnPos( nColIndex ) );
    1156           0 :     xub_StrLen nStrLen = static_cast< xub_StrLen >( nLastVisPos - nFirstVisPos + 1 );
    1157           0 :     sal_Int32 nStrX = GetX( nFirstVisPos );
    1158           0 :     for( size_t nLine = 0; nLine < nLineCount; ++nLine )
    1159             :     {
    1160           0 :         StringVec& rStrVec = maTexts[ nLine ];
    1161           0 :         if( (nColIndex < rStrVec.size()) && (rStrVec[ nColIndex ].Len() > nStrPos) )
    1162             :         {
    1163           0 :             String aText( rStrVec[ nColIndex ], nStrPos, nStrLen );
    1164           0 :             ImplDrawCellText( Point( nStrX, GetY( GetFirstVisLine() + nLine ) ), aText );
    1165             :         }
    1166             :     }
    1167             : 
    1168             :     // header
    1169           0 :     ImplDrawColumnHeader( maBackgrDev, nColIndex, maHeaderBackColor );
    1170             : 
    1171           0 :     maBackgrDev.SetClipRegion();
    1172             : }
    1173             : 
    1174           0 : void ScCsvGrid::ImplDrawRowHeaders()
    1175             : {
    1176           0 :     maBackgrDev.SetLineColor();
    1177           0 :     maBackgrDev.SetFillColor( maAppBackColor );
    1178           0 :     Point aPoint( GetHdrX(), 0 );
    1179           0 :     Rectangle aRect( aPoint, Size( GetHdrWidth() + 1, GetHeight() ) );
    1180           0 :     maBackgrDev.DrawRect( aRect );
    1181             : 
    1182           0 :     maBackgrDev.SetFillColor( maHeaderBackColor );
    1183           0 :     aRect.Bottom() = GetY( GetLastVisLine() + 1 );
    1184           0 :     maBackgrDev.DrawRect( aRect );
    1185             : 
    1186             :     // line numbers
    1187           0 :     maBackgrDev.SetFont( maHeaderFont );
    1188           0 :     maBackgrDev.SetTextColor( maHeaderTextColor );
    1189           0 :     maBackgrDev.SetTextFillColor();
    1190           0 :     sal_Int32 nLastLine = GetLastVisLine();
    1191           0 :     for( sal_Int32 nLine = GetFirstVisLine(); nLine <= nLastLine; ++nLine )
    1192             :     {
    1193           0 :         String aText( String::CreateFromInt32( nLine + 1 ) );
    1194           0 :         sal_Int32 nX = GetHdrX() + (GetHdrWidth() - maBackgrDev.GetTextWidth( aText )) / 2;
    1195           0 :         maBackgrDev.DrawText( Point( nX, GetY( nLine ) ), aText );
    1196           0 :     }
    1197             : 
    1198             :     // grid
    1199           0 :     maBackgrDev.SetLineColor( maHeaderGridColor );
    1200           0 :     if( IsRTL() )
    1201             :     {
    1202           0 :         maBackgrDev.DrawLine( Point( 0, 0 ), Point( 0, GetHeight() - 1 ) );
    1203           0 :         maBackgrDev.DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
    1204             :     }
    1205             :     else
    1206           0 :         maBackgrDev.DrawLine( aRect.TopRight(), aRect.BottomRight() );
    1207           0 :     aRect.Top() = GetHdrHeight();
    1208           0 :     maBackgrDev.DrawGrid( aRect, Size( 1, GetLineHeight() ), GRID_HORZLINES );
    1209           0 : }
    1210             : 
    1211           0 : void ScCsvGrid::ImplDrawBackgrDev()
    1212             : {
    1213           0 :     maBackgrDev.SetLineColor();
    1214           0 :     maBackgrDev.SetFillColor( maAppBackColor );
    1215             :     maBackgrDev.DrawRect( Rectangle(
    1216           0 :         Point( GetFirstX() + 1, 0 ), Size( GetWidth() - GetHdrWidth(), GetHeight() ) ) );
    1217             : 
    1218           0 :     sal_uInt32 nLastCol = GetLastVisColumn();
    1219           0 :     for( sal_uInt32 nColIx = GetFirstVisColumn(); nColIx <= nLastCol; ++nColIx )
    1220           0 :         ImplDrawColumnBackgr( nColIx );
    1221             : 
    1222           0 :     ImplDrawRowHeaders();
    1223           0 : }
    1224             : 
    1225           0 : void ScCsvGrid::ImplDrawColumnSelection( sal_uInt32 nColIndex )
    1226             : {
    1227           0 :     ImplInvertCursor( GetRulerCursorPos() );
    1228           0 :     ImplSetColumnClipRegion( maGridDev, nColIndex );
    1229           0 :     maGridDev.DrawOutDev( Point(), maWinSize, Point(), maWinSize, maBackgrDev );
    1230             : 
    1231           0 :     if( IsSelected( nColIndex ) )
    1232             :     {
    1233           0 :         sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
    1234           0 :         sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
    1235             : 
    1236             :         // header
    1237           0 :         Rectangle aRect( nX1, 0, nX2, GetHdrHeight() );
    1238           0 :         maGridDev.SetLineColor();
    1239           0 :         if( maHeaderBackColor.IsDark() )
    1240             :             // redraw with light gray background in dark mode
    1241           0 :             ImplDrawColumnHeader( maGridDev, nColIndex, COL_LIGHTGRAY );
    1242             :         else
    1243             :         {
    1244             :             // use transparent active color
    1245           0 :             maGridDev.SetFillColor( maSelectColor );
    1246           0 :             maGridDev.DrawTransparent( PolyPolygon( Polygon( aRect ) ), CSV_HDR_TRANSPARENCY );
    1247             :         }
    1248             : 
    1249             :         // column selection
    1250           0 :         aRect = Rectangle( nX1, GetHdrHeight() + 1, nX2, GetY( GetLastVisLine() + 1 ) - 1 );
    1251           0 :         ImplInvertRect( maGridDev, aRect );
    1252             :     }
    1253             : 
    1254           0 :     maGridDev.SetClipRegion();
    1255           0 :     ImplInvertCursor( GetRulerCursorPos() );
    1256           0 : }
    1257             : 
    1258           0 : void ScCsvGrid::ImplDrawGridDev()
    1259             : {
    1260           0 :     maGridDev.DrawOutDev( Point(), maWinSize, Point(), maWinSize, maBackgrDev );
    1261           0 :     sal_uInt32 nLastCol = GetLastVisColumn();
    1262           0 :     for( sal_uInt32 nColIx = GetFirstVisColumn(); nColIx <= nLastCol; ++nColIx )
    1263           0 :         ImplDrawColumnSelection( nColIx );
    1264           0 : }
    1265             : 
    1266           0 : void ScCsvGrid::ImplDrawColumn( sal_uInt32 nColIndex )
    1267             : {
    1268           0 :     ImplDrawColumnBackgr( nColIndex );
    1269           0 :     ImplDrawColumnSelection( nColIndex );
    1270           0 : }
    1271             : 
    1272           0 : void ScCsvGrid::ImplDrawHorzScrolled( sal_Int32 nOldPos )
    1273             : {
    1274           0 :     sal_Int32 nPos = GetFirstVisPos();
    1275           0 :     if( !IsValidGfx() || (nPos == nOldPos) )
    1276             :         return;
    1277           0 :     if( Abs( nPos - nOldPos ) > GetVisPosCount() / 2 )
    1278             :     {
    1279           0 :         ImplDrawBackgrDev();
    1280           0 :         ImplDrawGridDev();
    1281             :         return;
    1282             :     }
    1283             : 
    1284           0 :     Point aSrc, aDest;
    1285             :     sal_uInt32 nFirstColIx, nLastColIx;
    1286           0 :     if( nPos < nOldPos )
    1287             :     {
    1288           0 :         aSrc = Point( GetFirstX() + 1, 0 );
    1289           0 :         aDest = Point( GetFirstX() + GetCharWidth() * (nOldPos - nPos) + 1, 0 );
    1290           0 :         nFirstColIx = GetColumnFromPos( nPos );
    1291           0 :         nLastColIx = GetColumnFromPos( nOldPos );
    1292             :     }
    1293             :     else
    1294             :     {
    1295           0 :         aSrc = Point( GetFirstX() + GetCharWidth() * (nPos - nOldPos) + 1, 0 );
    1296           0 :         aDest = Point( GetFirstX() + 1, 0 );
    1297           0 :         nFirstColIx = GetColumnFromPos( Min( nOldPos + GetVisPosCount(), GetPosCount() ) - 1 );
    1298           0 :         nLastColIx = GetColumnFromPos( Min( nPos + GetVisPosCount(), GetPosCount() ) - 1 );
    1299             :     }
    1300             : 
    1301           0 :     ImplInvertCursor( GetRulerCursorPos() + (nPos - nOldPos) );
    1302           0 :     Rectangle aRectangle( GetFirstX(), 0, GetLastX(), GetHeight() - 1 );
    1303           0 :     Region aClipReg( aRectangle );
    1304           0 :     maBackgrDev.SetClipRegion( aClipReg );
    1305           0 :     maBackgrDev.CopyArea( aDest, aSrc, maWinSize );
    1306           0 :     maBackgrDev.SetClipRegion();
    1307           0 :     maGridDev.SetClipRegion( aClipReg );
    1308           0 :     maGridDev.CopyArea( aDest, aSrc, maWinSize );
    1309           0 :     maGridDev.SetClipRegion();
    1310           0 :     ImplInvertCursor( GetRulerCursorPos() );
    1311             : 
    1312           0 :     for( sal_uInt32 nColIx = nFirstColIx; nColIx <= nLastColIx; ++nColIx )
    1313           0 :         ImplDrawColumn( nColIx );
    1314             : 
    1315           0 :     sal_Int32 nLastX = GetX( GetPosCount() ) + 1;
    1316           0 :     if( nLastX <= GetLastX() )
    1317             :     {
    1318           0 :         Rectangle aRect( nLastX, 0, GetLastX(), GetHeight() - 1 );
    1319           0 :         maBackgrDev.SetLineColor();
    1320           0 :         maBackgrDev.SetFillColor( maAppBackColor );
    1321           0 :         maBackgrDev.DrawRect( aRect );
    1322           0 :         maGridDev.SetLineColor();
    1323           0 :         maGridDev.SetFillColor( maAppBackColor );
    1324           0 :         maGridDev.DrawRect( aRect );
    1325           0 :     }
    1326             : }
    1327             : 
    1328           0 : void ScCsvGrid::ImplInvertCursor( sal_Int32 nPos )
    1329             : {
    1330           0 :     if( IsVisibleSplitPos( nPos ) )
    1331             :     {
    1332           0 :         sal_Int32 nX = GetX( nPos ) - 1;
    1333           0 :         Rectangle aRect( Point( nX, 0 ), Size( 3, GetHdrHeight() ) );
    1334           0 :         ImplInvertRect( maGridDev, aRect );
    1335           0 :         aRect.Top() = GetHdrHeight() + 1;
    1336           0 :         aRect.Bottom() = GetY( GetLastVisLine() + 1 );
    1337           0 :         ImplInvertRect( maGridDev, aRect );
    1338             :     }
    1339           0 : }
    1340             : 
    1341           0 : void ScCsvGrid::ImplDrawTrackingRect( sal_uInt32 nColIndex )
    1342             : {
    1343           0 :     if( HasFocus() && IsVisibleColumn( nColIndex ) )
    1344             :     {
    1345           0 :         sal_Int32 nX1 = Max( GetColumnX( nColIndex ), GetFirstX() ) + 1;
    1346           0 :         sal_Int32 nX2 = Min( GetColumnX( nColIndex + 1 ) - sal_Int32( 1 ), GetLastX() );
    1347           0 :         sal_Int32 nY2 = Min( GetY( GetLastVisLine() + 1 ), GetHeight() ) - 1;
    1348           0 :         InvertTracking( Rectangle( nX1, 0, nX2, nY2 ), SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
    1349             :     }
    1350           0 : }
    1351             : 
    1352             : 
    1353             : // accessibility ==============================================================
    1354             : 
    1355           0 : ScAccessibleCsvControl* ScCsvGrid::ImplCreateAccessible()
    1356             : {
    1357           0 :     std::auto_ptr<ScAccessibleCsvControl> pControl(new ScAccessibleCsvGrid( *this ));
    1358           0 :     pControl->Init();
    1359           0 :     return pControl.release();
    1360             : }
    1361             : 
    1362             : 
    1363             : // ============================================================================
    1364             : 
    1365             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10