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

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4                 :            :  *
       5                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :            :  * the License or as specified alternatively below. You may obtain a copy of
       8                 :            :  * the License at http://www.mozilla.org/MPL/
       9                 :            :  *
      10                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :            :  * for the specific language governing rights and limitations under the
      13                 :            :  * License.
      14                 :            :  *
      15                 :            :  * Major Contributor(s):
      16                 :            :  *  Copyright (C) 2012 Albert Thuswaldner <albert.thuswaldner@gmail.com> (initial developer)
      17                 :            :  *
      18                 :            :  * All Rights Reserved.
      19                 :            :  *
      20                 :            :  * For minor contributions see the git repository.
      21                 :            :  *
      22                 :            :  * Alternatively, the contents of this file may be used under the terms of
      23                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26                 :            :  * instead of those above.
      27                 :            :  */
      28                 :            : 
      29                 :            : #include "sortkeydlg.hxx"
      30                 :            : #include "sortdlg.hxx"
      31                 :            : #include "sortdlg.hrc"
      32                 :            : 
      33                 :            : // =======================================================================
      34                 :            : 
      35                 :          0 : ScSortKeyItem::ScSortKeyItem( Window* pParent ) :
      36                 :            :     //
      37                 :            :     aFlSort        ( pParent, ScResId( FL_SORT  ) ),
      38                 :            :     aLbSort        ( pParent, ScResId( LB_SORT  ) ),
      39                 :            :     aBtnUp         ( pParent, ScResId( BTN_UP   ) ),
      40                 :          0 :     aBtnDown       ( pParent, ScResId( BTN_DOWN ) )
      41                 :            : {
      42                 :          0 : }
      43                 :            : 
      44                 :            : // -----------------------------------------------------------------------
      45                 :            : 
      46                 :          0 : void ScSortKeyItem::DisableField()
      47                 :            : {
      48                 :          0 :     aFlSort.Disable();
      49                 :          0 :     aLbSort.Disable();
      50                 :          0 :     aBtnUp.Disable();
      51                 :          0 :     aBtnDown.Disable();
      52                 :          0 : }
      53                 :            : 
      54                 :            : // -----------------------------------------------------------------------
      55                 :            : 
      56                 :          0 : void ScSortKeyItem::EnableField()
      57                 :            : {
      58                 :          0 :     aFlSort.Enable();
      59                 :          0 :     aLbSort.Enable();
      60                 :          0 :     aBtnUp.Enable();
      61                 :          0 :     aBtnDown.Enable();
      62                 :          0 : }
      63                 :            : 
      64                 :            : // =======================================================================
      65                 :            : 
      66                 :          0 : ScSortKeyWindow::ScSortKeyWindow( Window* pParent, const ResId& rResId, ScSortKeyItems& rSortKeyItems ) :
      67                 :            :     Window( pParent, rResId ),
      68                 :            :     //
      69                 :            :     aFlSort        ( this, ScResId( FL_SORT  ) ),
      70                 :            :     aLbSort        ( this, ScResId( LB_SORT  ) ),
      71                 :            :     aBtnUp         ( this, ScResId( BTN_UP   ) ),
      72                 :            :     aBtnDown       ( this, ScResId( BTN_DOWN ) ),
      73                 :            :     //
      74                 :            :     nScrollPos     ( 0 ),
      75                 :          0 :     mrSortKeyItems( rSortKeyItems )
      76                 :            : {
      77                 :          0 :     aFlSort.Hide();
      78                 :          0 :     aLbSort.Hide();
      79                 :          0 :     aBtnUp.Hide();
      80                 :          0 :     aBtnDown.Hide();
      81                 :            : 
      82                 :          0 :     nItemHeight = aBtnDown.GetPosPixel().Y() + aBtnDown.GetSizePixel().Height();
      83                 :          0 : }
      84                 :            : 
      85                 :            : // -----------------------------------------------------------------------
      86                 :            : 
      87                 :          0 : ScSortKeyWindow::~ScSortKeyWindow()
      88                 :            : {
      89                 :          0 :     mrSortKeyItems.clear();
      90                 :          0 : }
      91                 :            : 
      92                 :            : // -----------------------------------------------------------------------
      93                 :            : 
      94                 :          0 : void ScSortKeyWindow::AddSortKey( sal_uInt16 nItemNumber )
      95                 :            : {
      96                 :          0 :     ScSortKeyItem* pSortKeyItem = new ScSortKeyItem( this );
      97                 :            : 
      98                 :            :     // Set Sort key number
      99                 :          0 :     String aLine = pSortKeyItem->aFlSort.GetText();
     100                 :          0 :     aLine += String::CreateFromInt32( nItemNumber );
     101                 :          0 :     pSortKeyItem->aFlSort.SetText( aLine );
     102                 :            : 
     103                 :          0 :     mrSortKeyItems.push_back( pSortKeyItem );
     104                 :            : 
     105                 :          0 :     Window* pWindows[] = {  &aFlSort, &aLbSort, &aBtnUp, &aBtnDown, NULL };
     106                 :            : 
     107                 :            :     Window* pNewWindows[] = { &pSortKeyItem->aFlSort, &pSortKeyItem->aLbSort,
     108                 :          0 :                               &pSortKeyItem->aBtnUp,  &pSortKeyItem->aBtnDown, NULL };
     109                 :          0 :     Window** pCurrent = pWindows;
     110                 :          0 :     Window** pNewCurrent = pNewWindows;
     111                 :          0 :     while ( *pCurrent )
     112                 :            :     {
     113                 :          0 :         Size aSize = (*pCurrent)->GetSizePixel();
     114                 :          0 :         Point aPos = (*pCurrent)->GetPosPixel();
     115                 :          0 :         aPos.Y() += ( nItemNumber - 1 ) * GetItemHeight();
     116                 :          0 :         aPos.Y() += nScrollPos;
     117                 :          0 :         (*pNewCurrent)->SetPosSizePixel( aPos, aSize );
     118                 :          0 :         (*pNewCurrent)->Show();
     119                 :          0 :         pCurrent++;
     120                 :          0 :         pNewCurrent++;
     121                 :          0 :     }
     122                 :          0 : }
     123                 :            : 
     124                 :            : // -----------------------------------------------------------------------
     125                 :            : 
     126                 :          0 : void ScSortKeyWindow::DoScroll( sal_Int32 nNewPos )
     127                 :            : {
     128                 :          0 :     nScrollPos += nNewPos;
     129                 :          0 :     ScSortKeyItems::iterator pIter;
     130                 :          0 :     for ( pIter = mrSortKeyItems.begin(); pIter != mrSortKeyItems.end(); ++pIter )
     131                 :            :     {
     132                 :          0 :         Window* pNewWindows[] = { &pIter->aFlSort, &pIter->aLbSort,
     133                 :          0 :                                   &pIter->aBtnUp,  &pIter->aBtnDown, NULL };
     134                 :            : 
     135                 :          0 :         Window** pCurrent = pNewWindows;
     136                 :          0 :         while ( *pCurrent )
     137                 :            :         {
     138                 :          0 :             Point aPos = (*pCurrent)->GetPosPixel();
     139                 :          0 :             aPos.Y() += nNewPos;
     140                 :          0 :             (*pCurrent)->SetPosPixel( aPos );
     141                 :          0 :             pCurrent++;
     142                 :            :         }
     143                 :            :     }
     144                 :          0 : }
     145                 :            : 
     146                 :            : // =======================================================================
     147                 :            : 
     148                 :          0 : ScSortKeyCtrl::ScSortKeyCtrl( Window* pParent, const ScResId& rResId, ScSortKeyItems& rItems ):
     149                 :            :     Control( pParent, rResId),
     150                 :            :     //
     151                 :          0 :     aSortWin    ( this, ResId( WIN_MANAGESORTKEY, *rResId.GetResMgr() ), rItems ),
     152                 :          0 :     aVertScroll ( this, ResId( SB_SORT, *rResId.GetResMgr() ) ),
     153                 :          0 :     nThumbPos   ( 0 )
     154                 :            : {
     155                 :          0 :     aVertScroll.EnableDrag();
     156                 :          0 :     aVertScroll.Show();
     157                 :            : 
     158                 :          0 :     FreeResource();
     159                 :            : 
     160                 :          0 :     aVertScroll.SetRangeMin( 0 );
     161                 :          0 :     sal_Int32 nScrollOffset = aSortWin.GetItemHeight();
     162                 :          0 :     sal_Int32 nVisibleItems = aSortWin.GetSizePixel().Height() / nScrollOffset;
     163                 :          0 :     aVertScroll.SetRangeMax( nVisibleItems );
     164                 :          0 :     aVertScroll.SetPageSize( nVisibleItems - 1 );
     165                 :          0 :     aVertScroll.SetVisibleSize( nVisibleItems );
     166                 :            : 
     167                 :          0 :     Link aScrollLink = LINK( this, ScSortKeyCtrl, ScrollHdl );
     168                 :          0 :     aVertScroll.SetScrollHdl( aScrollLink );
     169                 :          0 : }
     170                 :            : 
     171                 :            : // -----------------------------------------------------------------------
     172                 :            : 
     173                 :          0 : ScSortKeyCtrl::~ScSortKeyCtrl()
     174                 :            : {
     175                 :          0 : }
     176                 :            : 
     177                 :            : // -----------------------------------------------------------------------
     178                 :            : 
     179                 :          0 : IMPL_LINK( ScSortKeyCtrl, ScrollHdl, ScrollBar*, pScrollBar )
     180                 :            : {
     181                 :          0 :     sal_Int32 nOffset = aSortWin.GetItemHeight();
     182                 :          0 :     nOffset *= ( nThumbPos - pScrollBar->GetThumbPos() );
     183                 :          0 :     nThumbPos = pScrollBar->GetThumbPos();
     184                 :          0 :     aSortWin.DoScroll( nOffset );
     185                 :          0 :     return 0;
     186                 :            : }
     187                 :            : 
     188                 :            : // -----------------------------------------------------------------------
     189                 :            : 
     190                 :          0 : void ScSortKeyCtrl::AddSortKey( sal_uInt16 nItem )
     191                 :            : {
     192                 :          0 :     aVertScroll.SetRangeMax( nItem );
     193                 :          0 :     aVertScroll.DoScroll( nItem );
     194                 :          0 :     aSortWin.AddSortKey( nItem );
     195                 :          0 : }
     196                 :            : 
     197                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10