LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - csvcontrol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 142 0.0 %
Date: 2012-08-25 Functions: 0 39 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 98 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "csvcontrol.hxx"
      30                 :            : #include <vcl/svapp.hxx>
      31                 :            : #include "AccessibleCsvControl.hxx"
      32                 :            : 
      33                 :            : 
      34                 :            : // ============================================================================
      35                 :            : 
      36                 :          0 : ScCsvLayoutData::ScCsvLayoutData() :
      37                 :            :     mnPosCount( 1 ),
      38                 :            :     mnPosOffset( 0 ),
      39                 :            :     mnWinWidth( 1 ),
      40                 :            :     mnHdrWidth( 0 ),
      41                 :            :     mnCharWidth( 1 ),
      42                 :            :     mnLineCount( 1 ),
      43                 :            :     mnLineOffset( 0 ),
      44                 :            :     mnWinHeight( 1 ),
      45                 :            :     mnHdrHeight( 0 ),
      46                 :            :     mnLineHeight( 1 ),
      47                 :            :     mnPosCursor( CSV_POS_INVALID ),
      48                 :            :     mnColCursor( 0 ),
      49                 :            :     mnNoRepaint( 0 ),
      50                 :          0 :     mbAppRTL( !!Application::GetSettings().GetLayoutRTL() )
      51                 :            : {
      52                 :          0 : }
      53                 :            : 
      54                 :          0 : ScCsvDiff ScCsvLayoutData::GetDiff( const ScCsvLayoutData& rData ) const
      55                 :            : {
      56                 :          0 :     ScCsvDiff nRet = CSV_DIFF_EQUAL;
      57         [ #  # ]:          0 :     if( mnPosCount != rData.mnPosCount )        nRet |= CSV_DIFF_POSCOUNT;
      58         [ #  # ]:          0 :     if( mnPosOffset != rData.mnPosOffset )      nRet |= CSV_DIFF_POSOFFSET;
      59         [ #  # ]:          0 :     if( mnHdrWidth != rData.mnHdrWidth )        nRet |= CSV_DIFF_HDRWIDTH;
      60         [ #  # ]:          0 :     if( mnCharWidth != rData.mnCharWidth )      nRet |= CSV_DIFF_CHARWIDTH;
      61         [ #  # ]:          0 :     if( mnLineCount != rData.mnLineCount )      nRet |= CSV_DIFF_LINECOUNT;
      62         [ #  # ]:          0 :     if( mnLineOffset != rData.mnLineOffset )    nRet |= CSV_DIFF_LINEOFFSET;
      63         [ #  # ]:          0 :     if( mnHdrHeight != rData.mnHdrHeight )      nRet |= CSV_DIFF_HDRHEIGHT;
      64         [ #  # ]:          0 :     if( mnLineHeight != rData.mnLineHeight )    nRet |= CSV_DIFF_LINEHEIGHT;
      65         [ #  # ]:          0 :     if( mnPosCursor != rData.mnPosCursor )      nRet |= CSV_DIFF_RULERCURSOR;
      66         [ #  # ]:          0 :     if( mnColCursor != rData.mnColCursor )      nRet |= CSV_DIFF_GRIDCURSOR;
      67                 :          0 :     return nRet;
      68                 :            : }
      69                 :            : 
      70                 :            : 
      71                 :            : // ============================================================================
      72                 :            : 
      73                 :          0 : ScCsvControl::ScCsvControl( ScCsvControl& rParent ) :
      74                 :            :     Control( &rParent, WB_TABSTOP | WB_NODIALOGCONTROL ),
      75                 :          0 :     mrData( rParent.GetLayoutData() ),
      76                 :            :     mpAccessible( NULL ),
      77         [ #  # ]:          0 :     mbValidGfx( false )
      78                 :            : {
      79                 :          0 : }
      80                 :            : 
      81                 :          0 : ScCsvControl::ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, const ResId& rResId ) :
      82                 :            :     Control( pParent, rResId ),
      83                 :            :     mrData( rData ),
      84                 :            :     mpAccessible( NULL ),
      85         [ #  # ]:          0 :     mbValidGfx( false )
      86                 :            : {
      87                 :          0 : }
      88                 :            : 
      89                 :          0 : ScCsvControl::~ScCsvControl()
      90                 :            : {
      91         [ #  # ]:          0 :     if( mpAccessible )
      92         [ #  # ]:          0 :         mpAccessible->dispose();
      93         [ #  # ]:          0 : }
      94                 :            : 
      95                 :            : 
      96                 :            : // event handling -------------------------------------------------------------
      97                 :            : 
      98                 :          0 : void ScCsvControl::GetFocus()
      99                 :            : {
     100                 :          0 :     Control::GetFocus();
     101                 :          0 :     AccSendFocusEvent( true );
     102                 :          0 : }
     103                 :            : 
     104                 :          0 : void ScCsvControl::LoseFocus()
     105                 :            : {
     106                 :          0 :     Control::LoseFocus();
     107                 :          0 :     AccSendFocusEvent( false );
     108                 :          0 : }
     109                 :            : 
     110                 :          0 : void ScCsvControl::AccSendFocusEvent( bool bFocused )
     111                 :            : {
     112         [ #  # ]:          0 :     if( mpAccessible )
     113                 :          0 :         mpAccessible->SendFocusEvent( bFocused );
     114                 :          0 : }
     115                 :            : 
     116                 :          0 : void ScCsvControl::AccSendCaretEvent()
     117                 :            : {
     118         [ #  # ]:          0 :     if( mpAccessible )
     119                 :          0 :         mpAccessible->SendCaretEvent();
     120                 :          0 : }
     121                 :            : 
     122                 :          0 : void ScCsvControl::AccSendVisibleEvent()
     123                 :            : {
     124         [ #  # ]:          0 :     if( mpAccessible )
     125                 :          0 :         mpAccessible->SendVisibleEvent();
     126                 :          0 : }
     127                 :            : 
     128                 :          0 : void ScCsvControl::AccSendSelectionEvent()
     129                 :            : {
     130         [ #  # ]:          0 :     if( mpAccessible )
     131                 :          0 :         mpAccessible->SendSelectionEvent();
     132                 :          0 : }
     133                 :            : 
     134                 :          0 : void ScCsvControl::AccSendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows )
     135                 :            : {
     136         [ #  # ]:          0 :     if( mpAccessible )
     137                 :          0 :         mpAccessible->SendTableUpdateEvent( nFirstColumn, nLastColumn, bAllRows );
     138                 :          0 : }
     139                 :            : 
     140                 :          0 : void ScCsvControl::AccSendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
     141                 :            : {
     142         [ #  # ]:          0 :     if( mpAccessible )
     143                 :          0 :         mpAccessible->SendInsertColumnEvent( nFirstColumn, nLastColumn );
     144                 :          0 : }
     145                 :            : 
     146                 :          0 : void ScCsvControl::AccSendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
     147                 :            : {
     148         [ #  # ]:          0 :     if( mpAccessible )
     149                 :          0 :         mpAccessible->SendRemoveColumnEvent( nFirstColumn, nLastColumn );
     150                 :          0 : }
     151                 :            : 
     152                 :            : 
     153                 :            : // repaint helpers ------------------------------------------------------------
     154                 :            : 
     155                 :          0 : void ScCsvControl::Repaint( bool bInvalidate )
     156                 :            : {
     157         [ #  # ]:          0 :     if( bInvalidate )
     158                 :          0 :         InvalidateGfx();
     159         [ #  # ]:          0 :     if( !IsNoRepaint() )
     160                 :          0 :         Execute( CSVCMD_REPAINT );
     161                 :          0 : }
     162                 :            : 
     163                 :          0 : void ScCsvControl::DisableRepaint()
     164                 :            : {
     165                 :          0 :     ++mrData.mnNoRepaint;
     166                 :          0 : }
     167                 :            : 
     168                 :          0 : void ScCsvControl::EnableRepaint( bool bInvalidate )
     169                 :            : {
     170                 :            :     OSL_ENSURE( IsNoRepaint(), "ScCsvControl::EnableRepaint - invalid call" );
     171                 :          0 :     --mrData.mnNoRepaint;
     172                 :          0 :     Repaint( bInvalidate );
     173                 :          0 : }
     174                 :            : 
     175                 :            : 
     176                 :            : // command handling -----------------------------------------------------------
     177                 :            : 
     178                 :          0 : void ScCsvControl::Execute( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 )
     179                 :            : {
     180                 :          0 :     maCmd.Set( eType, nParam1, nParam2 );
     181                 :          0 :     maCmdHdl.Call( this );
     182                 :          0 : }
     183                 :            : 
     184                 :            : 
     185                 :            : // layout helpers -------------------------------------------------------------
     186                 :            : 
     187                 :          0 : sal_Int32 ScCsvControl::GetVisPosCount() const
     188                 :            : {
     189                 :          0 :     return (mrData.mnWinWidth - GetHdrWidth()) / GetCharWidth();
     190                 :            : }
     191                 :            : 
     192                 :          0 : sal_Int32 ScCsvControl::GetMaxPosOffset() const
     193                 :            : {
     194                 :          0 :     return Max( GetPosCount() - GetVisPosCount() + 2L, 0L );
     195                 :            : }
     196                 :            : 
     197                 :          0 : bool ScCsvControl::IsValidSplitPos( sal_Int32 nPos ) const
     198                 :            : {
     199 [ #  # ][ #  # ]:          0 :     return (0 < nPos) && (nPos < GetPosCount() );
     200                 :            : }
     201                 :            : 
     202                 :          0 : bool ScCsvControl::IsVisibleSplitPos( sal_Int32 nPos ) const
     203                 :            : {
     204 [ #  # ][ #  # ]:          0 :     return IsValidSplitPos( nPos ) && (GetFirstVisPos() <= nPos) && (nPos <= GetLastVisPos());
                 [ #  # ]
     205                 :            : }
     206                 :            : 
     207                 :          0 : sal_Int32 ScCsvControl::GetHdrX() const
     208                 :            : {
     209         [ #  # ]:          0 :     return IsRTL() ? (mrData.mnWinWidth - GetHdrWidth()) : 0;
     210                 :            : }
     211                 :            : 
     212                 :          0 : sal_Int32 ScCsvControl::GetFirstX() const
     213                 :            : {
     214         [ #  # ]:          0 :     return IsRTL() ? 0 : GetHdrWidth();
     215                 :            : }
     216                 :            : 
     217                 :          0 : sal_Int32 ScCsvControl::GetLastX() const
     218                 :            : {
     219         [ #  # ]:          0 :     return mrData.mnWinWidth - (IsRTL() ? GetHdrWidth() : 0) - 1;
     220                 :            : }
     221                 :            : 
     222                 :          0 : sal_Int32 ScCsvControl::GetX( sal_Int32 nPos ) const
     223                 :            : {
     224                 :          0 :     return GetFirstX() + (nPos - GetFirstVisPos()) * GetCharWidth();
     225                 :            : }
     226                 :            : 
     227                 :          0 : sal_Int32 ScCsvControl::GetPosFromX( sal_Int32 nX ) const
     228                 :            : {
     229                 :          0 :     return (nX - GetFirstX() + GetCharWidth() / 2) / GetCharWidth() + GetFirstVisPos();
     230                 :            : }
     231                 :            : 
     232                 :          0 : sal_Int32 ScCsvControl::GetVisLineCount() const
     233                 :            : {
     234                 :          0 :     return (mrData.mnWinHeight - GetHdrHeight() - 2) / GetLineHeight() + 1;
     235                 :            : }
     236                 :            : 
     237                 :          0 : sal_Int32 ScCsvControl::GetLastVisLine() const
     238                 :            : {
     239                 :          0 :     return Min( GetFirstVisLine() + GetVisLineCount(), GetLineCount() ) - 1;
     240                 :            : }
     241                 :            : 
     242                 :          0 : sal_Int32 ScCsvControl::GetMaxLineOffset() const
     243                 :            : {
     244                 :          0 :     return Max( GetLineCount() - GetVisLineCount() + 1L, 0L );
     245                 :            : }
     246                 :            : 
     247                 :          0 : bool ScCsvControl::IsValidLine( sal_Int32 nLine ) const
     248                 :            : {
     249 [ #  # ][ #  # ]:          0 :     return (0 <= nLine) && (nLine < GetLineCount());
     250                 :            : }
     251                 :            : 
     252                 :          0 : bool ScCsvControl::IsVisibleLine( sal_Int32 nLine ) const
     253                 :            : {
     254 [ #  # ][ #  # ]:          0 :     return IsValidLine( nLine ) && (GetFirstVisLine() <= nLine) && (nLine <= GetLastVisLine());
                 [ #  # ]
     255                 :            : }
     256                 :            : 
     257                 :          0 : sal_Int32 ScCsvControl::GetY( sal_Int32 nLine ) const
     258                 :            : {
     259                 :          0 :     return GetHdrHeight() + (nLine - GetFirstVisLine()) * GetLineHeight();
     260                 :            : }
     261                 :            : 
     262                 :          0 : sal_Int32 ScCsvControl::GetLineFromY( sal_Int32 nY ) const
     263                 :            : {
     264                 :          0 :     return (nY - GetHdrHeight()) / GetLineHeight() + GetFirstVisLine();
     265                 :            : }
     266                 :            : 
     267                 :            : 
     268                 :            : // static helpers -------------------------------------------------------------
     269                 :            : 
     270                 :          0 : void ScCsvControl::ImplInvertRect( OutputDevice& rOutDev, const Rectangle& rRect )
     271                 :            : {
     272                 :          0 :     rOutDev.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_RASTEROP );
     273         [ #  # ]:          0 :     rOutDev.SetLineColor( Color( COL_BLACK ) );
     274         [ #  # ]:          0 :     rOutDev.SetFillColor( Color( COL_BLACK ) );
     275                 :          0 :     rOutDev.SetRasterOp( ROP_INVERT );
     276                 :          0 :     rOutDev.DrawRect( rRect );
     277                 :          0 :     rOutDev.Pop();
     278                 :          0 : }
     279                 :            : 
     280                 :          0 : ScMoveMode ScCsvControl::GetHorzDirection( sal_uInt16 nCode, bool bHomeEnd )
     281                 :            : {
     282      [ #  #  # ]:          0 :     switch( nCode )
     283                 :            :     {
     284                 :          0 :         case KEY_LEFT:  return MOVE_PREV;
     285                 :          0 :         case KEY_RIGHT: return MOVE_NEXT;
     286                 :            :     }
     287         [ #  # ]:          0 :     if( bHomeEnd ) switch( nCode )
              [ #  #  # ]
     288                 :            :     {
     289                 :          0 :         case KEY_HOME:  return MOVE_FIRST;
     290                 :          0 :         case KEY_END:   return MOVE_LAST;
     291                 :            :     }
     292                 :          0 :     return MOVE_NONE;
     293                 :            : }
     294                 :            : 
     295                 :          0 : ScMoveMode ScCsvControl::GetVertDirection( sal_uInt16 nCode, bool bHomeEnd )
     296                 :            : {
     297   [ #  #  #  #  :          0 :     switch( nCode )
                      # ]
     298                 :            :     {
     299                 :          0 :         case KEY_UP:        return MOVE_PREV;
     300                 :          0 :         case KEY_DOWN:      return MOVE_NEXT;
     301                 :          0 :         case KEY_PAGEUP:    return MOVE_PREVPAGE;
     302                 :          0 :         case KEY_PAGEDOWN:  return MOVE_NEXTPAGE;
     303                 :            :     }
     304         [ #  # ]:          0 :     if( bHomeEnd ) switch( nCode )
              [ #  #  # ]
     305                 :            :     {
     306                 :          0 :         case KEY_HOME:      return MOVE_FIRST;
     307                 :          0 :         case KEY_END:       return MOVE_LAST;
     308                 :            :     }
     309                 :          0 :     return MOVE_NONE;
     310                 :            : }
     311                 :            : 
     312                 :            : 
     313                 :            : // accessibility --------------------------------------------------------------
     314                 :            : 
     315                 :          0 : ScCsvControl::XAccessibleRef ScCsvControl::CreateAccessible()
     316                 :            : {
     317                 :          0 :     mpAccessible = ImplCreateAccessible();
     318         [ #  # ]:          0 :     mxAccessible = mpAccessible;
     319                 :          0 :     return mxAccessible;
     320                 :            : }
     321                 :            : 
     322                 :            : 
     323                 :            : // ============================================================================
     324                 :            : 
     325                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10