LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - fieldwnd.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 751 0.0 %
Date: 2012-08-25 Functions: 0 121 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 801 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                 :            : 
      30                 :            : #include <comphelper/string.hxx>
      31                 :            : #include <vcl/virdev.hxx>
      32                 :            : #include <vcl/decoview.hxx>
      33                 :            : #include <vcl/svapp.hxx>
      34                 :            : #include <vcl/mnemonic.hxx>
      35                 :            : #include <vcl/help.hxx>
      36                 :            : 
      37                 :            : #include "fieldwnd.hxx"
      38                 :            : #include "pvlaydlg.hxx"
      39                 :            : #include "dpuiglobal.hxx"
      40                 :            : #include "AccessibleDataPilotControl.hxx"
      41                 :            : #include "scresid.hxx"
      42                 :            : #include "pivot.hrc"
      43                 :            : 
      44                 :            : using namespace com::sun::star;
      45                 :            : using ::rtl::OUString;
      46                 :            : using ::std::vector;
      47                 :            : using ::com::sun::star::uno::Reference;
      48                 :            : using ::com::sun::star::uno::WeakReference;
      49                 :            : using ::com::sun::star::accessibility::XAccessible;
      50                 :            : 
      51                 :            : const size_t INVALID_INDEX = static_cast<size_t>(-1);
      52                 :            : 
      53                 :          0 : ScDPFieldControlBase::FieldName::FieldName(const rtl::OUString& rText, bool bFits, sal_uInt8 nDupCount) :
      54                 :          0 :     maText(rText), mbFits(bFits), mnDupCount(nDupCount) {}
      55                 :            : 
      56                 :          0 : ScDPFieldControlBase::FieldName::FieldName(const FieldName& r) :
      57                 :          0 :     maText(r.maText), mbFits(r.mbFits), mnDupCount(r.mnDupCount) {}
      58                 :            : 
      59                 :          0 : rtl::OUString ScDPFieldControlBase::FieldName::getDisplayedText() const
      60                 :            : {
      61         [ #  # ]:          0 :     rtl::OUStringBuffer aBuf(maText);
      62         [ #  # ]:          0 :     if (mnDupCount > 0)
      63         [ #  # ]:          0 :         aBuf.append(static_cast<sal_Int32>(mnDupCount+1));
      64         [ #  # ]:          0 :     return aBuf.makeStringAndClear();
      65                 :            : }
      66                 :            : 
      67                 :          0 : ScDPFieldControlBase::ScrollBar::ScrollBar(Window* pParent, WinBits nStyle) :
      68                 :            :     ::ScrollBar(pParent, nStyle),
      69                 :          0 :     mpParent(pParent)
      70                 :            : {
      71                 :          0 : }
      72                 :            : 
      73                 :          0 : void ScDPFieldControlBase::ScrollBar::Command( const CommandEvent& rCEvt )
      74                 :            : {
      75                 :          0 :     mpParent->Command(rCEvt);
      76                 :          0 : }
      77                 :            : 
      78                 :          0 : ScDPFieldControlBase::ScDPFieldControlBase( ScDPLayoutDlg* pParent, const ResId& rResId, FixedText* pCaption ) :
      79                 :            :     Control(pParent, rResId),
      80                 :            :     mpDlg(pParent),
      81                 :            :     mpCaption(pCaption),
      82                 :            :     mnFieldSelected(0),
      83 [ #  # ][ #  # ]:          0 :     pAccessible(NULL)
                 [ #  # ]
      84                 :            : {
      85         [ #  # ]:          0 :     if (pCaption)
      86 [ #  # ][ #  # ]:          0 :         maName = MnemonicGenerator::EraseAllMnemonicChars( pCaption->GetText() );
         [ #  # ][ #  # ]
                 [ #  # ]
      87                 :          0 : }
      88                 :            : 
      89         [ #  # ]:          0 : ScDPFieldControlBase::~ScDPFieldControlBase()
      90                 :            : {
      91         [ #  # ]:          0 :     if (pAccessible)
      92                 :            :     {
      93         [ #  # ]:          0 :         com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
      94         [ #  # ]:          0 :         if (xTempAcc.is())
      95         [ #  # ]:          0 :             pAccessible->dispose();
      96                 :            :     }
      97         [ #  # ]:          0 : }
      98                 :            : 
      99                 :          0 : void ScDPFieldControlBase::UseMnemonic()
     100                 :            : {
     101                 :            :     // Now the FixedText has its mnemonic char. Grab the text and hide the
     102                 :            :     // FixedText to be able to handle tabstop and mnemonics separately.
     103         [ #  # ]:          0 :     if (mpCaption)
     104                 :            :     {
     105         [ #  # ]:          0 :         SetText(mpCaption->GetText());
     106                 :          0 :         mpCaption->Hide();
     107                 :            :     }
     108                 :            : 
     109                 :            :     // after reading the mnemonics, tab stop style bits can be updated
     110                 :          0 :     UpdateStyle();
     111                 :          0 : }
     112                 :            : 
     113                 :          0 : OUString ScDPFieldControlBase::GetName() const
     114                 :            : {
     115                 :          0 :     return maName;
     116                 :            : }
     117                 :            : 
     118                 :          0 : void ScDPFieldControlBase::SetName(const OUString& rName)
     119                 :            : {
     120                 :          0 :     maName = rName;
     121                 :          0 : }
     122                 :            : 
     123                 :          0 : bool ScDPFieldControlBase::IsExistingIndex( size_t nIndex ) const
     124                 :            : {
     125                 :          0 :     return nIndex < maFieldNames.size();
     126                 :            : }
     127                 :            : 
     128                 :          0 : void ScDPFieldControlBase::AddField( const rtl::OUString& rText, size_t nNewIndex )
     129                 :            : {
     130                 :            :     OSL_ENSURE( nNewIndex == maFieldNames.size(), "ScDPFieldWindow::AddField - invalid index" );
     131         [ #  # ]:          0 :     if( IsValidIndex( nNewIndex ) )
     132                 :            :     {
     133                 :          0 :         sal_uInt8 nDupCount = GetNextDupCount(rText);
     134         [ #  # ]:          0 :         maFieldNames.push_back(FieldName(rText, true, nDupCount));
     135         [ #  # ]:          0 :         if (pAccessible)
     136                 :            :         {
     137         [ #  # ]:          0 :             com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
     138         [ #  # ]:          0 :             if (xTempAcc.is())
     139         [ #  # ]:          0 :                 pAccessible->AddField(nNewIndex);
     140                 :            :             else
     141                 :          0 :                 pAccessible = NULL;
     142                 :            :         }
     143                 :            :     }
     144                 :          0 : }
     145                 :            : 
     146                 :          0 : bool ScDPFieldControlBase::AddField(
     147                 :            :     const rtl::OUString& rText, const Point& rPos, size_t& rnIndex, sal_uInt8& rnDupCount)
     148                 :            : {
     149                 :          0 :     size_t nNewIndex = 0;
     150 [ #  # ][ #  # ]:          0 :     if( GetFieldIndex( rPos, nNewIndex ) )
     151                 :            :     {
     152         [ #  # ]:          0 :         if( nNewIndex > maFieldNames.size() )
     153                 :          0 :             nNewIndex = maFieldNames.size();
     154                 :            : 
     155         [ #  # ]:          0 :         sal_uInt8 nDupCount = GetNextDupCount(rText);
     156 [ #  # ][ #  # ]:          0 :         maFieldNames.insert(maFieldNames.begin() + nNewIndex, FieldName(rText, true, nDupCount));
     157                 :          0 :         mnFieldSelected = nNewIndex;
     158         [ #  # ]:          0 :         ResetScrollBar();
     159         [ #  # ]:          0 :         Redraw();
     160                 :          0 :         rnIndex = nNewIndex;
     161                 :          0 :         rnDupCount = nDupCount;
     162                 :            : 
     163         [ #  # ]:          0 :         if (pAccessible)
     164                 :            :         {
     165         [ #  # ]:          0 :             com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
     166         [ #  # ]:          0 :             if (xTempAcc.is())
     167         [ #  # ]:          0 :                 pAccessible->AddField(nNewIndex);
     168                 :            :             else
     169                 :          0 :                 pAccessible = NULL;
     170                 :            :         }
     171                 :            : 
     172                 :          0 :         return true;
     173                 :            :     }
     174                 :            : 
     175                 :          0 :     return false;
     176                 :            : }
     177                 :            : 
     178                 :          0 : bool ScDPFieldControlBase::MoveField(size_t nCurPos, const Point& rPos, size_t& rnIndex)
     179                 :            : {
     180         [ #  # ]:          0 :     if (nCurPos >= maFieldNames.size())
     181                 :            :         // out-of-bound
     182                 :          0 :         return false;
     183                 :            : 
     184                 :          0 :     size_t nNewIndex = 0;
     185 [ #  # ][ #  # ]:          0 :     if (!GetFieldIndex(rPos, nNewIndex))
     186                 :          0 :         return false;
     187                 :            : 
     188         [ #  # ]:          0 :     if (nNewIndex == nCurPos)
     189                 :            :         // Nothing to do.
     190                 :          0 :         return true;
     191                 :            : 
     192                 :          0 :     FieldName aName = maFieldNames[nCurPos];
     193         [ #  # ]:          0 :     if (nNewIndex >= maFieldNames.size())
     194                 :            :     {
     195                 :            :         // Move to the back.
     196 [ #  # ][ #  # ]:          0 :         maFieldNames.erase(maFieldNames.begin()+nCurPos);
     197         [ #  # ]:          0 :         maFieldNames.push_back(aName);
     198                 :          0 :         rnIndex = maFieldNames.size()-1;
     199                 :            :     }
     200                 :            :     else
     201                 :            :     {
     202 [ #  # ][ #  # ]:          0 :         maFieldNames.erase(maFieldNames.begin()+nCurPos);
     203                 :          0 :         size_t nTmp = nNewIndex; // we need to keep the original index for accessible.
     204         [ #  # ]:          0 :         if (nNewIndex > nCurPos)
     205                 :          0 :             --nTmp;
     206                 :            : 
     207 [ #  # ][ #  # ]:          0 :         maFieldNames.insert(maFieldNames.begin()+nTmp, aName);
     208                 :          0 :         rnIndex = nTmp;
     209                 :            :     }
     210                 :            : 
     211         [ #  # ]:          0 :     ResetScrollBar();
     212         [ #  # ]:          0 :     Redraw();
     213                 :            : 
     214         [ #  # ]:          0 :     if (pAccessible)
     215                 :            :     {
     216         [ #  # ]:          0 :         uno::Reference<accessibility::XAccessible> xTempAcc = xAccessible;
     217         [ #  # ]:          0 :         if (xTempAcc.is())
     218         [ #  # ]:          0 :             pAccessible->MoveField(nCurPos, nNewIndex);
     219                 :            :         else
     220                 :          0 :             pAccessible = NULL;
     221                 :            :     }
     222                 :            : 
     223                 :          0 :     return true;
     224                 :            : }
     225                 :            : 
     226                 :          0 : bool ScDPFieldControlBase::AppendField(const rtl::OUString& rText, size_t& rnIndex)
     227                 :            : {
     228         [ #  # ]:          0 :     if (!IsValidIndex(maFieldNames.size()))
     229                 :          0 :         return false;
     230                 :            : 
     231                 :          0 :     sal_uInt8 nDupCount = GetNextDupCount(rText);
     232         [ #  # ]:          0 :     maFieldNames.push_back(FieldName(rText, true, nDupCount));
     233                 :          0 :     mnFieldSelected = maFieldNames.size() - 1;
     234                 :          0 :     ResetScrollBar();
     235                 :          0 :     Redraw();
     236                 :            : 
     237                 :          0 :     rnIndex = mnFieldSelected;
     238                 :          0 :     return true;
     239                 :            : }
     240                 :            : 
     241                 :          0 : void ScDPFieldControlBase::DelField( size_t nDelIndex )
     242                 :            : {
     243         [ #  # ]:          0 :     if ( IsExistingIndex(nDelIndex) )
     244                 :            :     {
     245         [ #  # ]:          0 :         if (pAccessible) // before decrement fieldcount
     246                 :            :         {
     247         [ #  # ]:          0 :             com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
     248         [ #  # ]:          0 :             if (xTempAcc.is())
     249         [ #  # ]:          0 :                 pAccessible->RemoveField(nDelIndex);
     250                 :            :             else
     251                 :          0 :                 pAccessible = NULL;
     252                 :            :         }
     253 [ #  # ][ #  # ]:          0 :         maFieldNames.erase( maFieldNames.begin() + nDelIndex );
     254         [ #  # ]:          0 :         if (mnFieldSelected >= maFieldNames.size())
     255                 :          0 :             mnFieldSelected = maFieldNames.size() - 1;
     256                 :            : 
     257                 :          0 :         ResetScrollBar();
     258                 :          0 :         Redraw();
     259                 :            :     }
     260                 :          0 : }
     261                 :            : 
     262                 :          0 : size_t ScDPFieldControlBase::GetFieldCount() const
     263                 :            : {
     264                 :          0 :     return maFieldNames.size();
     265                 :            : }
     266                 :            : 
     267                 :          0 : bool ScDPFieldControlBase::IsEmpty() const
     268                 :            : {
     269                 :          0 :     return maFieldNames.empty();
     270                 :            : }
     271                 :            : 
     272                 :          0 : void ScDPFieldControlBase::ClearFields()
     273                 :            : {
     274         [ #  # ]:          0 :     com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
     275 [ #  # ][ #  # ]:          0 :     if (!xTempAcc.is() && pAccessible)
                 [ #  # ]
     276                 :          0 :         pAccessible = NULL;
     277         [ #  # ]:          0 :     if (pAccessible)
     278         [ #  # ]:          0 :         for( size_t nIdx = maFieldNames.size(); nIdx > 0; --nIdx )
     279         [ #  # ]:          0 :             pAccessible->RemoveField( nIdx - 1 );
     280                 :            : 
     281                 :          0 :     maFieldNames.clear();
     282                 :          0 : }
     283                 :            : 
     284                 :          0 : void ScDPFieldControlBase::SetFieldText(const rtl::OUString& rText, size_t nIndex, sal_uInt8 nDupCount)
     285                 :            : {
     286         [ #  # ]:          0 :     if( IsExistingIndex( nIndex ) )
     287                 :            :     {
     288                 :          0 :         maFieldNames[nIndex] = FieldName(rText, true, nDupCount);
     289                 :          0 :         Redraw();
     290                 :            : 
     291         [ #  # ]:          0 :         if (pAccessible)
     292                 :            :         {
     293         [ #  # ]:          0 :             com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
     294         [ #  # ]:          0 :             if (xTempAcc.is())
     295         [ #  # ]:          0 :                 pAccessible->FieldNameChange(nIndex);
     296                 :            :             else
     297                 :          0 :                 pAccessible = NULL;
     298                 :            :         }
     299                 :            :     }
     300                 :          0 : }
     301                 :            : 
     302                 :          0 : rtl::OUString ScDPFieldControlBase::GetFieldText( size_t nIndex ) const
     303                 :            : {
     304         [ #  # ]:          0 :     if( IsExistingIndex( nIndex ) )
     305                 :          0 :         return maFieldNames[nIndex].maText;
     306                 :          0 :     return rtl::OUString();
     307                 :            : }
     308                 :            : 
     309                 :          0 : void ScDPFieldControlBase::GetExistingIndex( const Point& rPos, size_t& rnIndex )
     310                 :            : {
     311 [ #  # ][ #  # ]:          0 :     if( !maFieldNames.empty() && (GetFieldType() != TYPE_SELECT) && GetFieldIndex( rPos, rnIndex ) )
         [ #  # ][ #  # ]
     312                 :            :     {
     313         [ #  # ]:          0 :         if( rnIndex >= maFieldNames.size() )
     314                 :          0 :             rnIndex = maFieldNames.size() - 1;
     315                 :            :     }
     316                 :            :     else
     317                 :          0 :         rnIndex = 0;
     318                 :          0 : }
     319                 :            : 
     320                 :          0 : size_t ScDPFieldControlBase::GetSelectedField() const
     321                 :            : {
     322                 :          0 :     return mnFieldSelected;
     323                 :            : }
     324                 :            : 
     325                 :          0 : vector<ScDPFieldControlBase::FieldName>& ScDPFieldControlBase::GetFieldNames()
     326                 :            : {
     327                 :          0 :     return maFieldNames;
     328                 :            : }
     329                 :            : 
     330                 :          0 : const vector<ScDPFieldControlBase::FieldName>& ScDPFieldControlBase::GetFieldNames() const
     331                 :            : {
     332                 :          0 :     return maFieldNames;
     333                 :            : }
     334                 :            : 
     335                 :          0 : void ScDPFieldControlBase::Paint( const Rectangle& /* rRect */ )
     336                 :            : {
     337                 :            :     // hiding the caption is now done from StateChanged
     338                 :          0 :     Redraw();
     339                 :          0 : }
     340                 :            : 
     341                 :          0 : void ScDPFieldControlBase::DataChanged( const DataChangedEvent& rDCEvt )
     342                 :            : {
     343 [ #  # ][ #  # ]:          0 :     if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
                 [ #  # ]
     344                 :            :     {
     345                 :          0 :         Redraw();
     346                 :            :     }
     347                 :          0 :     Control::DataChanged( rDCEvt );
     348                 :          0 : }
     349                 :            : 
     350                 :          0 : void ScDPFieldControlBase::Command( const CommandEvent& rCEvt )
     351                 :            : {
     352         [ #  # ]:          0 :     if (rCEvt.GetCommand() == COMMAND_WHEEL)
     353                 :            :     {
     354                 :          0 :         const CommandWheelData* pData = rCEvt.GetWheelData();
     355 [ #  # ][ #  # ]:          0 :         if (pData->GetMode() == COMMAND_WHEEL_SCROLL && !pData->IsHorz())
                 [ #  # ]
     356                 :            :         {
     357                 :            :             // Handle vertical mouse wheel scrolls.
     358                 :          0 :             long nNotch = pData->GetNotchDelta(); // positive => up; negative => down
     359                 :          0 :             HandleWheelScroll(nNotch);
     360                 :            :         }
     361                 :            :     }
     362                 :          0 : }
     363                 :            : 
     364                 :          0 : void ScDPFieldControlBase::MouseButtonDown( const MouseEvent& rMEvt )
     365                 :            : {
     366         [ #  # ]:          0 :     if( rMEvt.IsLeft() )
     367                 :            :     {
     368                 :          0 :         size_t nIndex = 0;
     369 [ #  # ][ #  # ]:          0 :         if( GetFieldIndex( rMEvt.GetPosPixel(), nIndex ) && IsExistingIndex( nIndex ) )
         [ #  # ][ #  # ]
     370                 :            :         {
     371         [ #  # ]:          0 :             GrabFocusWithSel( nIndex );
     372                 :            : 
     373         [ #  # ]:          0 :             if( rMEvt.GetClicks() == 1 )
     374                 :            :             {
     375 [ #  # ][ #  # ]:          0 :                 PointerStyle ePtr = mpDlg->NotifyMouseButtonDown( GetFieldType(), nIndex );
     376         [ #  # ]:          0 :                 CaptureMouse();
     377         [ #  # ]:          0 :                 SetPointer( Pointer( ePtr ) );
     378                 :            :             }
     379                 :            :             else
     380 [ #  # ][ #  # ]:          0 :                 mpDlg->NotifyDoubleClick( GetFieldType(), nIndex );
     381                 :            :         }
     382                 :            :     }
     383                 :          0 : }
     384                 :            : 
     385                 :          0 : void ScDPFieldControlBase::MouseButtonUp( const MouseEvent& rMEvt )
     386                 :            : {
     387         [ #  # ]:          0 :     if( rMEvt.IsLeft() )
     388                 :            :     {
     389         [ #  # ]:          0 :         if( rMEvt.GetClicks() == 1 )
     390                 :            :         {
     391         [ #  # ]:          0 :             mpDlg->NotifyMouseButtonUp( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
     392         [ #  # ]:          0 :             SetPointer( Pointer( POINTER_ARROW ) );
     393                 :            :         }
     394                 :            : 
     395         [ #  # ]:          0 :         if( IsMouseCaptured() )
     396                 :          0 :             ReleaseMouse();
     397                 :            :     }
     398                 :          0 : }
     399                 :            : 
     400                 :          0 : void ScDPFieldControlBase::MouseMove( const MouseEvent& rMEvt )
     401                 :            : {
     402 [ #  # ][ #  # ]:          0 :     if( IsMouseCaptured() )
     403                 :            :     {
     404 [ #  # ][ #  # ]:          0 :         PointerStyle ePtr = mpDlg->NotifyMouseMove( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
     405         [ #  # ]:          0 :         SetPointer( Pointer( ePtr ) );
     406                 :            :     }
     407                 :          0 :     size_t nIndex = 0;
     408 [ #  # ][ #  # ]:          0 :     if( GetFieldIndex( rMEvt.GetPosPixel(), nIndex ) && IsShortenedText( nIndex ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     409                 :            :     {
     410         [ #  # ]:          0 :         Point aPos = OutputToScreenPixel( rMEvt.GetPosPixel() );
     411 [ #  # ][ #  # ]:          0 :         Rectangle   aRect( aPos, GetSizePixel() );
     412 [ #  # ][ #  # ]:          0 :         String aHelpText = GetFieldText(nIndex);
     413 [ #  # ][ #  # ]:          0 :         Help::ShowQuickHelp( this, aRect, aHelpText );
     414                 :            :     }
     415                 :          0 : }
     416                 :            : 
     417                 :          0 : void ScDPFieldControlBase::KeyInput( const KeyEvent& rKEvt )
     418                 :            : {
     419                 :          0 :     const KeyCode& rKeyCode = rKEvt.GetKeyCode();
     420                 :          0 :     sal_uInt16 nCode = rKeyCode.GetCode();
     421                 :          0 :     bool bKeyEvaluated = false;
     422                 :            : 
     423                 :          0 :     const FieldNames& rFields = GetFieldNames();
     424 [ #  # ][ #  # ]:          0 :     if( rKeyCode.IsMod1() && (GetFieldType() != TYPE_SELECT) )
                 [ #  # ]
     425                 :            :     {
     426                 :          0 :         bKeyEvaluated = true;
     427   [ #  #  #  #  :          0 :         switch( nCode )
                #  #  # ]
     428                 :            :         {
     429                 :          0 :             case KEY_UP:    MoveFieldRel( 0, -1 );              break;
     430                 :          0 :             case KEY_DOWN:  MoveFieldRel( 0, 1 );               break;
     431                 :          0 :             case KEY_LEFT:  MoveFieldRel( -1, 0 );              break;
     432                 :          0 :             case KEY_RIGHT: MoveFieldRel( 1, 0 );               break;
     433                 :          0 :             case KEY_HOME:  MoveField( 0 );                     break;
     434                 :          0 :             case KEY_END:   MoveField( rFields.size() - 1 );  break;
     435                 :          0 :             default:        bKeyEvaluated = false;
     436                 :            :         }
     437                 :            :     }
     438                 :            :     else
     439                 :            :     {
     440                 :          0 :         bKeyEvaluated = true;
     441   [ #  #  #  #  :          0 :         switch( nCode )
             #  #  #  # ]
     442                 :            :         {
     443                 :          0 :             case KEY_UP:    MoveSelection( 0, -1 ); break;
     444                 :          0 :             case KEY_DOWN:  MoveSelection( 0, 1 ); break;
     445                 :          0 :             case KEY_LEFT:  MoveSelection( -1, 0 ); break;
     446                 :          0 :             case KEY_RIGHT: MoveSelection( 1, 0 ); break;
     447                 :          0 :             case KEY_HOME:  SetSelectionHome();     break;
     448                 :          0 :             case KEY_END:   SetSelectionEnd();      break;
     449                 :            :             case KEY_DELETE:
     450                 :          0 :                 mpDlg->NotifyRemoveField( GetFieldType(), mnFieldSelected );
     451                 :          0 :             break;
     452                 :            :             default:
     453                 :          0 :                 bKeyEvaluated = false;
     454                 :            :         }
     455                 :            :     }
     456                 :            : 
     457         [ #  # ]:          0 :     if (bKeyEvaluated)
     458                 :            :     {
     459                 :          0 :         ScrollToShowSelection();
     460                 :          0 :         Redraw();
     461                 :            :     }
     462                 :            :     else
     463                 :          0 :         Control::KeyInput( rKEvt );
     464                 :          0 : }
     465                 :            : 
     466                 :          0 : void ScDPFieldControlBase::GetFocus()
     467                 :            : {
     468                 :          0 :     Control::GetFocus();
     469                 :          0 :     Redraw();
     470         [ #  # ]:          0 :     if( GetGetFocusFlags() & GETFOCUS_MNEMONIC )    // move field on shortcut
     471                 :            :     {
     472                 :          0 :         size_t nOldCount = GetFieldCount();
     473                 :          0 :         mpDlg->NotifyMoveFieldToEnd( GetFieldType() );
     474         [ #  # ]:          0 :         if (GetFieldCount() > nOldCount)
     475                 :            :             // Scroll to the end only when a new field is inserted.
     476                 :          0 :             ScrollToEnd();
     477                 :            :     }
     478                 :            :     else                                            // else change focus
     479                 :          0 :         mpDlg->NotifyFieldFocus( GetFieldType(), true );
     480                 :            : 
     481                 :          0 :     AccessibleSetFocus(true);
     482                 :          0 : }
     483                 :            : 
     484                 :          0 : void ScDPFieldControlBase::LoseFocus()
     485                 :            : {
     486                 :          0 :     Control::LoseFocus();
     487                 :          0 :     Redraw();
     488                 :          0 :     mpDlg->NotifyFieldFocus( GetFieldType(), false );
     489                 :            : 
     490                 :          0 :     AccessibleSetFocus(false);
     491                 :          0 : }
     492                 :            : 
     493                 :          0 : Reference<XAccessible> ScDPFieldControlBase::CreateAccessible()
     494                 :            : {
     495                 :            :     pAccessible =
     496         [ #  # ]:          0 :         new ScAccessibleDataPilotControl(GetAccessibleParentWindow()->GetAccessible(), this);
     497                 :            : 
     498         [ #  # ]:          0 :     com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xReturn = pAccessible;
     499                 :            : 
     500         [ #  # ]:          0 :     pAccessible->Init();
     501         [ #  # ]:          0 :     xAccessible = xReturn;
     502                 :            : 
     503                 :          0 :     return xReturn;
     504                 :            : }
     505                 :            : 
     506                 :          0 : void ScDPFieldControlBase::FieldFocusChanged(size_t nOldSelected, size_t nFieldSelected)
     507                 :            : {
     508         [ #  # ]:          0 :     if (!pAccessible)
     509                 :          0 :         return;
     510                 :            : 
     511         [ #  # ]:          0 :     com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
     512         [ #  # ]:          0 :     if (xTempAcc.is())
     513         [ #  # ]:          0 :         pAccessible->FieldFocusChange(nOldSelected, nFieldSelected);
     514                 :            :     else
     515                 :          0 :         pAccessible = NULL;
     516                 :            : }
     517                 :            : 
     518                 :          0 : void ScDPFieldControlBase::AccessibleSetFocus(bool bOn)
     519                 :            : {
     520         [ #  # ]:          0 :     if (!pAccessible)
     521                 :            :         return;
     522                 :            : 
     523         [ #  # ]:          0 :     com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
     524         [ #  # ]:          0 :     if (!xTempAcc.is())
     525                 :            :     {
     526                 :          0 :         pAccessible = NULL;
     527                 :            :         return;
     528                 :            :     }
     529                 :            : 
     530         [ #  # ]:          0 :     if (bOn)
     531         [ #  # ]:          0 :         pAccessible->GotFocus();
     532                 :            :     else
     533 [ #  # ][ #  # ]:          0 :         pAccessible->LostFocus();
     534                 :            : }
     535                 :            : 
     536                 :          0 : void ScDPFieldControlBase::UpdateStyle()
     537                 :            : {
     538                 :          0 :     WinBits nMask = ~(WB_TABSTOP | WB_NOTABSTOP);
     539         [ #  # ]:          0 :     SetStyle( (GetStyle() & nMask) | (IsEmpty() ? WB_NOTABSTOP : WB_TABSTOP) );
     540                 :          0 : }
     541                 :            : 
     542                 :          0 : void ScDPFieldControlBase::DrawBackground( OutputDevice& rDev )
     543                 :            : {
     544                 :          0 :     const StyleSettings& rStyleSet = GetSettings().GetStyleSettings();
     545                 :          0 :     Color aFaceColor = rStyleSet.GetFaceColor();
     546                 :          0 :     Color aWinColor = rStyleSet.GetWindowColor();
     547                 :          0 :     Color aWinTextColor = rStyleSet.GetWindowTextColor();
     548                 :            : 
     549                 :          0 :     Point aPos0;
     550         [ #  # ]:          0 :     Size aSize( GetSizePixel() );
     551                 :            : 
     552         [ #  # ]:          0 :     if (mpCaption)
     553                 :            :     {
     554         [ #  # ]:          0 :         rDev.SetLineColor( aWinTextColor );
     555         [ #  # ]:          0 :         rDev.SetFillColor( aWinColor );
     556                 :            :     }
     557                 :            :     else
     558                 :            :     {
     559         [ #  # ]:          0 :         rDev.SetLineColor( aFaceColor );
     560         [ #  # ]:          0 :         rDev.SetFillColor( aFaceColor );
     561                 :            :     }
     562 [ #  # ][ #  # ]:          0 :     rDev.DrawRect( Rectangle( aPos0, aSize ) );
     563                 :            : 
     564         [ #  # ]:          0 :     rDev.SetTextColor( aWinTextColor );
     565                 :            : 
     566                 :            :     /*  Draw the caption text. This needs some special handling, because we
     567                 :            :         support hard line breaks here. This part will draw each line of the
     568                 :            :         text for itself. */
     569                 :            : 
     570 [ #  # ][ #  # ]:          0 :     xub_StrLen nTokenCnt = comphelper::string::getTokenCount(GetText(), '\n');
         [ #  # ][ #  # ]
     571         [ #  # ]:          0 :     long nY = (aSize.Height() - nTokenCnt * rDev.GetTextHeight()) / 2;
     572         [ #  # ]:          0 :     for( xub_StrLen nToken = 0, nStringIx = 0; nToken < nTokenCnt; ++nToken )
     573                 :            :     {
     574 [ #  # ][ #  # ]:          0 :         String aLine( GetText().GetToken( 0, '\n', nStringIx ) );
                 [ #  # ]
     575         [ #  # ]:          0 :         Point aLinePos( (aSize.Width() - rDev.GetCtrlTextWidth( aLine )) / 2, nY );
     576         [ #  # ]:          0 :         rDev.DrawCtrlText( aLinePos, aLine );
     577         [ #  # ]:          0 :         nY += rDev.GetTextHeight();
     578         [ #  # ]:          0 :     }
     579                 :          0 : }
     580                 :            : 
     581                 :          0 : void ScDPFieldControlBase::DrawField(
     582                 :            :         OutputDevice& rDev, const Rectangle& rRect, FieldName& rText, bool bFocus )
     583                 :            : {
     584                 :          0 :     const StyleSettings& rStyleSet = GetSettings().GetStyleSettings();
     585                 :          0 :     Color aTextColor = rStyleSet.GetButtonTextColor();
     586                 :            : 
     587         [ #  # ]:          0 :     VirtualDevice aVirDev( rDev );
     588                 :            :     // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
     589         [ #  # ]:          0 :     aVirDev.EnableRTL( IsRTLEnabled() );
     590                 :            : 
     591         [ #  # ]:          0 :     rtl::OUString aText = rText.getDisplayedText();
     592                 :            : 
     593         [ #  # ]:          0 :     Size aDevSize( rRect.GetSize() );
     594                 :          0 :     long    nWidth       = aDevSize.Width();
     595                 :          0 :     long    nHeight      = aDevSize.Height();
     596 [ #  # ][ #  # ]:          0 :     long    nLabelWidth  = rDev.GetTextWidth( aText );
                 [ #  # ]
     597         [ #  # ]:          0 :     long    nLabelHeight = rDev.GetTextHeight();
     598                 :            : 
     599                 :            :     // #i31600# if text is too long, cut and add ellipsis
     600                 :          0 :     rText.mbFits = nLabelWidth + 6 <= nWidth;
     601         [ #  # ]:          0 :     if (!rText.mbFits)
     602                 :            :     {
     603                 :          0 :         sal_Int32 nMinLen = 0;
     604                 :          0 :         sal_Int32 nMaxLen = aText.getLength();
     605                 :          0 :         bool bFits = false;
     606 [ #  # ][ #  # ]:          0 :         do
                 [ #  # ]
     607                 :            :         {
     608                 :          0 :             sal_Int32 nCurrLen = (nMinLen + nMaxLen) / 2;
     609         [ #  # ]:          0 :             rtl::OUStringBuffer aBuf(rText.maText.copy(0, nCurrLen));
     610         [ #  # ]:          0 :             aBuf.appendAscii("...");
     611         [ #  # ]:          0 :             aText = aBuf.makeStringAndClear();
     612 [ #  # ][ #  # ]:          0 :             nLabelWidth = rDev.GetTextWidth( aText );
                 [ #  # ]
     613                 :          0 :             bFits = nLabelWidth + 6 <= nWidth;
     614         [ #  # ]:          0 :             (bFits ? nMinLen : nMaxLen) = nCurrLen;
     615                 :            :         }
     616                 :          0 :         while( !bFits || (nMinLen + 1 < nMaxLen) );
     617                 :            :     }
     618         [ #  # ]:          0 :     Point aLabelPos( (nWidth - nLabelWidth) / 2, ::std::max< long >( (nHeight - nLabelHeight) / 2, 3 ) );
     619                 :            : 
     620         [ #  # ]:          0 :     aVirDev.SetOutputSizePixel( aDevSize );
     621         [ #  # ]:          0 :     aVirDev.SetFont( rDev.GetFont() );
     622                 :          0 :     DecorationView aDecoView( &aVirDev );
     623 [ #  # ][ #  # ]:          0 :     aDecoView.DrawButton( Rectangle( Point( 0, 0 ), aDevSize ), bFocus ? BUTTON_DRAW_DEFAULT : 0 );
                 [ #  # ]
     624         [ #  # ]:          0 :     aVirDev.SetTextColor( aTextColor );
     625 [ #  # ][ #  # ]:          0 :     aVirDev.DrawText( aLabelPos, aText );
                 [ #  # ]
     626 [ #  # ][ #  # ]:          0 :     rDev.DrawBitmap( rRect.TopLeft(), aVirDev.GetBitmap( Point( 0, 0 ), aDevSize ) );
         [ #  # ][ #  # ]
     627                 :          0 : }
     628                 :            : 
     629                 :          0 : void ScDPFieldControlBase::AppendPaintable(Window* p)
     630                 :            : {
     631                 :          0 :     maPaintables.push_back(p);
     632                 :          0 : }
     633                 :            : 
     634                 :          0 : void ScDPFieldControlBase::DrawPaintables()
     635                 :            : {
     636 [ #  # ][ #  # ]:          0 :     Rectangle aRect(GetPosPixel(), GetSizePixel());
                 [ #  # ]
     637                 :          0 :     Paintables::iterator itr = maPaintables.begin(), itrEnd = maPaintables.end();
     638 [ #  # ][ #  # ]:          0 :     for (; itr != itrEnd; ++itr)
                 [ #  # ]
     639                 :            :     {
     640         [ #  # ]:          0 :         Window* p = *itr;
     641 [ #  # ][ #  # ]:          0 :         if (!p->IsVisible())
     642                 :          0 :             continue;
     643                 :            : 
     644         [ #  # ]:          0 :         p->Paint(aRect);
     645                 :            :     }
     646                 :          0 : }
     647                 :            : 
     648                 :          0 : void ScDPFieldControlBase::DrawInvertSelection()
     649                 :            : {
     650 [ #  # ][ #  # ]:          0 :     if (!HasFocus())
     651                 :            :         return;
     652                 :            : 
     653         [ #  # ]:          0 :     if (mnFieldSelected >= maFieldNames.size())
     654                 :            :         return;
     655                 :            : 
     656         [ #  # ]:          0 :     size_t nPos = GetDisplayPosition(mnFieldSelected);
     657         [ #  # ]:          0 :     if (nPos == INVALID_INDEX)
     658                 :            :         return;
     659                 :            : 
     660         [ #  # ]:          0 :     Size aFldSize = GetFieldSize();
     661                 :          0 :     long nFldWidth = aFldSize.Width();
     662                 :            :     long nSelWidth = std::min<long>(
     663 [ #  # ][ #  # ]:          0 :         GetTextWidth(maFieldNames[mnFieldSelected].getDisplayedText()) + 4, nFldWidth - 6);
         [ #  # ][ #  # ]
                 [ #  # ]
     664                 :            : 
     665         [ #  # ]:          0 :     Point aPos = GetFieldPosition(nPos);
     666                 :          0 :     aPos += Point((nFldWidth - nSelWidth) / 2, 3);
     667                 :          0 :     Size aSize(nSelWidth, aFldSize.Height() - 6);
     668                 :            : 
     669         [ #  # ]:          0 :     Rectangle aSel(aPos, aSize);
     670         [ #  # ]:          0 :     InvertTracking(aSel, SHOWTRACK_SMALL | SHOWTRACK_WINDOW);
     671                 :            : }
     672                 :            : 
     673                 :          0 : Size ScDPFieldControlBase::GetStdFieldBtnSize() const
     674                 :            : {
     675                 :          0 :     return mpDlg->GetStdFieldBtnSize();
     676                 :            : }
     677                 :            : 
     678                 :          0 : bool ScDPFieldControlBase::IsShortenedText( size_t nIndex ) const
     679                 :            : {
     680                 :          0 :     const FieldNames& rFields = GetFieldNames();
     681 [ #  # ][ #  # ]:          0 :     return (nIndex < rFields.size()) && !rFields[nIndex].mbFits;
     682                 :            : }
     683                 :            : 
     684                 :          0 : void ScDPFieldControlBase::MoveField( size_t nDestIndex )
     685                 :            : {
     686         [ #  # ]:          0 :     if (nDestIndex != mnFieldSelected)
     687                 :            :     {
     688                 :          0 :         std::swap(maFieldNames[nDestIndex], maFieldNames[mnFieldSelected]);
     689                 :          0 :         mnFieldSelected = nDestIndex;
     690                 :            :     }
     691                 :          0 : }
     692                 :            : 
     693                 :          0 : void ScDPFieldControlBase::MoveFieldRel( SCsCOL nDX, SCsROW nDY )
     694                 :            : {
     695                 :          0 :     MoveField( CalcNewFieldIndex( nDX, nDY ) );
     696                 :          0 : }
     697                 :            : 
     698                 :          0 : void ScDPFieldControlBase::SetSelection(size_t nIndex)
     699                 :            : {
     700                 :          0 :     FieldNames& rFields = GetFieldNames();
     701         [ #  # ]:          0 :     if (rFields.empty())
     702                 :          0 :         return;
     703                 :            : 
     704         [ #  # ]:          0 :     if (nIndex >= rFields.size())
     705                 :            :         // Prevent it from going out-of-bound.
     706                 :          0 :         nIndex = rFields.size() - 1;
     707                 :            : 
     708         [ #  # ]:          0 :     if( mnFieldSelected != nIndex )
     709                 :            :     {
     710                 :          0 :         size_t nOldSelected = mnFieldSelected;
     711                 :          0 :         mnFieldSelected = nIndex;
     712                 :          0 :         Redraw();
     713                 :            : 
     714         [ #  # ]:          0 :         if (HasFocus())
     715                 :          0 :             FieldFocusChanged(nOldSelected, mnFieldSelected);
     716                 :            :     }
     717                 :            : 
     718                 :          0 :     ScrollToShowSelection();
     719                 :            : }
     720                 :            : 
     721                 :          0 : void ScDPFieldControlBase::SetSelectionHome()
     722                 :            : {
     723                 :          0 :     const FieldNames& rFields = GetFieldNames();
     724         [ #  # ]:          0 :     if( !rFields.empty() )
     725                 :            :     {
     726                 :          0 :         SetSelection( 0 );
     727                 :            :     }
     728                 :          0 : }
     729                 :            : 
     730                 :          0 : void ScDPFieldControlBase::SetSelectionEnd()
     731                 :            : {
     732                 :          0 :     const FieldNames& rFields = GetFieldNames();
     733         [ #  # ]:          0 :     if( !rFields.empty() )
     734                 :            :     {
     735                 :          0 :         SetSelection( rFields.size() - 1 );
     736                 :            :     }
     737                 :          0 : }
     738                 :            : 
     739                 :          0 : void ScDPFieldControlBase::MoveSelection(SCsCOL nDX, SCsROW nDY)
     740                 :            : {
     741                 :          0 :     size_t nNewIndex = CalcNewFieldIndex( nDX, nDY );
     742                 :          0 :     SetSelection( nNewIndex );
     743                 :          0 : }
     744                 :            : 
     745                 :          0 : sal_uInt8 ScDPFieldControlBase::GetNextDupCount(const rtl::OUString& rFieldText) const
     746                 :            : {
     747                 :          0 :     sal_uInt8 nMax = 0;
     748                 :          0 :     FieldNames::const_iterator it = maFieldNames.begin(), itEnd = maFieldNames.end();
     749 [ #  # ][ #  # ]:          0 :     for (; it != itEnd; ++it)
     750                 :            :     {
     751         [ #  # ]:          0 :         if (it->maText != rFieldText)
     752                 :          0 :             continue;
     753                 :            : 
     754                 :          0 :         sal_uInt8 nNextUp = it->mnDupCount + 1;
     755         [ #  # ]:          0 :         if (nMax < nNextUp)
     756                 :          0 :             nMax = nNextUp;
     757                 :            :     }
     758                 :          0 :     return nMax;
     759                 :            : }
     760                 :            : 
     761                 :          0 : void ScDPFieldControlBase::SelectNext()
     762                 :            : {
     763                 :          0 :     SetSelection(mnFieldSelected + 1);
     764                 :          0 : }
     765                 :            : 
     766                 :          0 : void ScDPFieldControlBase::GrabFocusWithSel( size_t nIndex )
     767                 :            : {
     768                 :          0 :     SetSelection( nIndex );
     769         [ #  # ]:          0 :     if( !HasFocus() )
     770                 :          0 :         GrabFocus();
     771                 :          0 : }
     772                 :            : 
     773                 :            : //=============================================================================
     774                 :            : 
     775                 :          0 : ScDPHorFieldControl::ScDPHorFieldControl(
     776                 :            :     ScDPLayoutDlg* pDialog, const ResId& rResId, FixedText* pCaption) :
     777                 :            :     ScDPFieldControlBase(pDialog, rResId, pCaption),
     778                 :            :     maScroll(this, WB_HORZ | WB_DRAG),
     779                 :            :     mnFieldBtnRowCount(0),
     780         [ #  # ]:          0 :     mnFieldBtnColCount(0)
     781                 :            : {
     782         [ #  # ]:          0 :     maScroll.SetScrollHdl( LINK(this, ScDPHorFieldControl, ScrollHdl) );
     783         [ #  # ]:          0 :     maScroll.SetEndScrollHdl( LINK(this, ScDPHorFieldControl, EndScrollHdl) );
     784         [ #  # ]:          0 :     maScroll.Hide();
     785                 :            : 
     786         [ #  # ]:          0 :     AppendPaintable(&maScroll);
     787                 :          0 : }
     788                 :            : 
     789         [ #  # ]:          0 : ScDPHorFieldControl::~ScDPHorFieldControl()
     790                 :            : {
     791         [ #  # ]:          0 : }
     792                 :            : 
     793                 :          0 : Point ScDPHorFieldControl::GetFieldPosition( size_t nIndex )
     794                 :            : {
     795                 :          0 :     Point aPos;
     796                 :          0 :     Size aSize;
     797         [ #  # ]:          0 :     GetFieldBtnPosSize(nIndex, aPos, aSize);
     798                 :          0 :     return aPos;
     799                 :            : }
     800                 :            : 
     801                 :          0 : Size ScDPHorFieldControl::GetFieldSize() const
     802                 :            : {
     803                 :          0 :     return GetStdFieldBtnSize();
     804                 :            : }
     805                 :            : 
     806                 :          0 : bool ScDPHorFieldControl::GetFieldIndex( const Point& rPos, size_t& rnIndex )
     807                 :            : {
     808                 :          0 :     rnIndex = INVALID_INDEX;
     809 [ #  # ][ #  # ]:          0 :     if (rPos.X() < 0 || rPos.Y() < 0)
                 [ #  # ]
     810                 :          0 :         return false;
     811                 :            : 
     812         [ #  # ]:          0 :     Size aWndSize = GetSizePixel();
     813 [ #  # ][ #  # ]:          0 :     if (rPos.X() > aWndSize.Width() || rPos.Y() > aWndSize.Height())
                 [ #  # ]
     814                 :          0 :         return false;
     815                 :            : 
     816                 :          0 :     size_t nX = rPos.X();
     817                 :          0 :     size_t nY = rPos.Y();
     818                 :          0 :     size_t nW = aWndSize.Width();
     819                 :          0 :     size_t nH = aWndSize.Height();
     820                 :            : 
     821         [ #  # ]:          0 :     Size aFldSize = GetFieldSize();
     822                 :          0 :     size_t nCurX = OUTER_MARGIN_HOR + aFldSize.Width() + ROW_FIELD_BTN_GAP/2;
     823                 :          0 :     size_t nCurY = OUTER_MARGIN_VER + aFldSize.Height() + ROW_FIELD_BTN_GAP/2;
     824                 :          0 :     size_t nCol = 0;
     825                 :          0 :     size_t nRow = 0;
     826 [ #  # ][ #  # ]:          0 :     while (nX > nCurX && nCurX <= nW)
                 [ #  # ]
     827                 :            :     {
     828                 :          0 :         nCurX += aFldSize.Width() + ROW_FIELD_BTN_GAP;
     829                 :          0 :         ++nCol;
     830                 :            :     }
     831 [ #  # ][ #  # ]:          0 :     while (nY > nCurY && nCurY <= nH)
                 [ #  # ]
     832                 :            :     {
     833                 :          0 :         nCurY += aFldSize.Height() + ROW_FIELD_BTN_GAP;
     834                 :          0 :         ++nRow;
     835                 :            :     }
     836                 :            : 
     837                 :          0 :     size_t nOffset = maScroll.GetThumbPos();
     838                 :          0 :     nCol += nOffset; // convert to logical column ID.
     839                 :          0 :     rnIndex = nCol * mnFieldBtnRowCount + nRow;
     840                 :          0 :     size_t nFldCount = GetFieldCount();
     841         [ #  # ]:          0 :     if (rnIndex > nFldCount)
     842                 :          0 :         rnIndex = nFldCount;
     843         [ #  # ]:          0 :     return IsValidIndex(rnIndex);
     844                 :            : }
     845                 :            : 
     846                 :          0 : void ScDPHorFieldControl::Redraw()
     847                 :            : {
     848         [ #  # ]:          0 :     VirtualDevice   aVirDev;
     849                 :            :     // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
     850         [ #  # ]:          0 :     aVirDev.EnableRTL( IsRTLEnabled() );
     851 [ #  # ][ #  # ]:          0 :     aVirDev.SetMapMode( MAP_PIXEL );
                 [ #  # ]
     852                 :            : 
     853                 :          0 :     Point           aPos0;
     854         [ #  # ]:          0 :     Size            aSize( GetSizePixel() );
     855         [ #  # ]:          0 :     Font            aFont( GetFont() );         // Font vom Window
     856         [ #  # ]:          0 :     aFont.SetTransparent( true );
     857         [ #  # ]:          0 :     aVirDev.SetFont( aFont );
     858         [ #  # ]:          0 :     aVirDev.SetOutputSizePixel( aSize );
     859                 :            : 
     860         [ #  # ]:          0 :     DrawBackground( aVirDev );
     861                 :            : 
     862                 :          0 :     FieldNames& rFields = GetFieldNames();
     863                 :            :     {
     864                 :          0 :         long nScrollOffset = maScroll.GetThumbPos();
     865                 :          0 :         FieldNames::iterator itr = rFields.begin(), itrEnd = rFields.end();
     866         [ #  # ]:          0 :         if (nScrollOffset)
     867         [ #  # ]:          0 :             ::std::advance(itr, nScrollOffset*mnFieldBtnRowCount);
     868                 :            : 
     869 [ #  # ][ #  # ]:          0 :         for (size_t i = 0; itr != itrEnd; ++itr, ++i)
     870                 :            :         {
     871                 :          0 :             Point aFldPt;
     872                 :          0 :             Size aFldSize;
     873 [ #  # ][ #  # ]:          0 :             if (!GetFieldBtnPosSize(i, aFldPt, aFldSize))
     874                 :            :                 break;
     875                 :            : 
     876                 :          0 :             size_t nField = i + nScrollOffset*mnFieldBtnRowCount;
     877 [ #  # ][ #  # ]:          0 :             bool bFocus = HasFocus() && (nField == GetSelectedField());
                 [ #  # ]
     878 [ #  # ][ #  # ]:          0 :             DrawField(aVirDev, Rectangle(aFldPt, aFldSize), *itr, bFocus);
     879                 :            :         }
     880                 :            :     }
     881                 :            : 
     882 [ #  # ][ #  # ]:          0 :     DrawBitmap( aPos0, aVirDev.GetBitmap( aPos0, aSize ) );
                 [ #  # ]
     883         [ #  # ]:          0 :     DrawPaintables();
     884         [ #  # ]:          0 :     DrawInvertSelection();
     885 [ #  # ][ #  # ]:          0 :     UpdateStyle();
                 [ #  # ]
     886                 :          0 : }
     887                 :            : 
     888                 :          0 : void ScDPHorFieldControl::CalcSize()
     889                 :            : {
     890         [ #  # ]:          0 :     Size aWndSize = GetSizePixel();
     891                 :            : 
     892                 :          0 :     long nScrollSize = GetSettings().GetStyleSettings().GetScrollBarSize();
     893         [ #  # ]:          0 :     maScroll.SetSizePixel(Size(aWndSize.Width() - OUTER_MARGIN_HOR*2, nScrollSize));
     894         [ #  # ]:          0 :     maScroll.SetPosPixel(Point(OUTER_MARGIN_HOR, aWndSize.Height() - OUTER_MARGIN_VER - nScrollSize));
     895                 :            : 
     896                 :          0 :     long nTotalH = aWndSize.Height() - nScrollSize - OUTER_MARGIN_VER*2;
     897                 :          0 :     long nTotalW = aWndSize.Width() - OUTER_MARGIN_HOR*2;
     898         [ #  # ]:          0 :     mnFieldBtnRowCount = nTotalH / (GetFieldSize().Height() + ROW_FIELD_BTN_GAP);
     899         [ #  # ]:          0 :     mnFieldBtnColCount = (nTotalW + ROW_FIELD_BTN_GAP) / (GetFieldSize().Width() + ROW_FIELD_BTN_GAP);
     900                 :            : 
     901                 :          0 :     maScroll.SetLineSize(1);
     902         [ #  # ]:          0 :     maScroll.SetVisibleSize(mnFieldBtnColCount);
     903                 :          0 :     maScroll.SetPageSize(mnFieldBtnColCount);
     904         [ #  # ]:          0 :     maScroll.SetRange(Range(0, mnFieldBtnColCount));
     905                 :          0 : }
     906                 :            : 
     907                 :          0 : bool ScDPHorFieldControl::IsValidIndex(size_t /*nIndex*/) const
     908                 :            : {
     909                 :          0 :     return true;
     910                 :            : }
     911                 :            : 
     912                 :          0 : size_t ScDPHorFieldControl::CalcNewFieldIndex(SCsCOL nDX, SCsROW nDY) const
     913                 :            : {
     914                 :          0 :     size_t nSel = GetSelectedField();
     915                 :          0 :     size_t nFldCount = GetFieldCount();
     916                 :          0 :     SCsROW nRow = nSel % mnFieldBtnRowCount;
     917                 :          0 :     SCsCOL nCol = nSel / mnFieldBtnRowCount;
     918                 :            :     SCsCOL nColUpper = static_cast<SCsCOL>(ceil(
     919                 :          0 :         static_cast<double>(nFldCount) / static_cast<double>(mnFieldBtnRowCount)) - 1);
     920                 :          0 :     SCsROW nRowUpper = mnFieldBtnRowCount - 1;
     921                 :            : 
     922                 :          0 :     nCol += nDX;
     923         [ #  # ]:          0 :     if (nCol < 0)
     924                 :          0 :         nCol = 0;
     925         [ #  # ]:          0 :     else if (nColUpper < nCol)
     926                 :          0 :         nCol = nColUpper;
     927                 :          0 :     nRow += nDY;
     928         [ #  # ]:          0 :     if (nRow < 0)
     929                 :          0 :         nRow = 0;
     930         [ #  # ]:          0 :     else if (nRowUpper < nRow)
     931                 :          0 :         nRow = nRowUpper;
     932                 :            : 
     933                 :          0 :     nSel = nCol*mnFieldBtnRowCount + nRow;
     934         [ #  # ]:          0 :     if (nSel >= nFldCount)
     935                 :          0 :         nSel = nFldCount - 1;
     936                 :            : 
     937                 :          0 :     return nSel;
     938                 :            : }
     939                 :            : 
     940                 :          0 : size_t ScDPHorFieldControl::GetDisplayPosition(size_t nIndex) const
     941                 :            : {
     942                 :          0 :     size_t nColFirst = maScroll.GetThumbPos();
     943                 :          0 :     size_t nColLast = nColFirst + mnFieldBtnColCount - 1;
     944                 :          0 :     size_t nCol = nIndex / mnFieldBtnRowCount;
     945                 :          0 :     size_t nRow = nIndex % mnFieldBtnRowCount;
     946 [ #  # ][ #  # ]:          0 :     if (nCol < nColFirst || nColLast < nCol)
     947                 :            :         // index is outside the visible area.
     948                 :          0 :         return INVALID_INDEX;
     949                 :            : 
     950                 :          0 :     size_t nPos = (nCol - nColFirst)*mnFieldBtnRowCount + nRow;
     951                 :          0 :     return nPos;
     952                 :            : }
     953                 :            : 
     954                 :          0 : String ScDPHorFieldControl::GetDescription() const
     955                 :            : {
     956         [ #  # ]:          0 :     return ScResId(STR_ACC_DATAPILOT_COL_DESCR);
     957                 :            : }
     958                 :            : 
     959                 :          0 : void ScDPHorFieldControl::ScrollToEnd()
     960                 :            : {
     961                 :          0 :     maScroll.DoScroll(maScroll.GetRangeMax());
     962                 :          0 : }
     963                 :            : 
     964                 :          0 : void ScDPHorFieldControl::ScrollToShowSelection()
     965                 :            : {
     966                 :          0 :     size_t nLower = maScroll.GetThumbPos();
     967                 :          0 :     size_t nUpper = nLower + mnFieldBtnColCount - 1;
     968                 :          0 :     size_t nCol = GetSelectedField() / mnFieldBtnRowCount;
     969         [ #  # ]:          0 :     if (nCol < nLower)
     970                 :            :     {
     971                 :            :         // scroll to left.
     972                 :          0 :         maScroll.DoScroll(nCol);
     973                 :            :     }
     974         [ #  # ]:          0 :     else if (nUpper < nCol)
     975                 :            :     {
     976                 :            :         // scroll to right.
     977                 :          0 :         maScroll.DoScroll(nCol - mnFieldBtnColCount + 1);
     978                 :            :     }
     979                 :          0 : }
     980                 :            : 
     981                 :          0 : void ScDPHorFieldControl::ResetScrollBar()
     982                 :            : {
     983                 :          0 :     long nOldMax = maScroll.GetRangeMax();
     984                 :            :     long nNewMax = static_cast<long>(ceil(
     985                 :          0 :         static_cast<double>(GetFieldCount()) / static_cast<double>(mnFieldBtnRowCount)));
     986                 :            : 
     987         [ #  # ]:          0 :     if (nOldMax != nNewMax)
     988                 :            :     {
     989                 :          0 :         maScroll.SetRangeMax(nNewMax);
     990                 :          0 :         bool bShow = mnFieldBtnColCount*mnFieldBtnRowCount < GetFieldCount();
     991                 :          0 :         maScroll.Show(bShow);
     992                 :            :     }
     993                 :          0 : }
     994                 :            : 
     995                 :          0 : void ScDPHorFieldControl::HandleWheelScroll(long /*nNotch*/)
     996                 :            : {
     997                 :            :     // not handled for horizontal field controls.
     998                 :          0 : }
     999                 :            : 
    1000                 :          0 : bool ScDPHorFieldControl::GetFieldBtnPosSize(size_t nPos, Point& rPos, Size& rSize)
    1001                 :            : {
    1002         [ #  # ]:          0 :     if (nPos >= mnFieldBtnColCount*mnFieldBtnRowCount)
    1003                 :          0 :         return false;
    1004                 :            : 
    1005                 :          0 :     Point aPos = Point(OUTER_MARGIN_HOR, OUTER_MARGIN_VER);
    1006                 :          0 :     size_t nRow = nPos % mnFieldBtnRowCount;
    1007                 :          0 :     size_t nCol = nPos / mnFieldBtnRowCount;
    1008                 :            : 
    1009         [ #  # ]:          0 :     aPos.X() += nCol*(GetFieldSize().Width() + ROW_FIELD_BTN_GAP);
    1010         [ #  # ]:          0 :     aPos.Y() += nRow*(GetFieldSize().Height() + ROW_FIELD_BTN_GAP);
    1011                 :            : 
    1012                 :          0 :     rPos = aPos;
    1013         [ #  # ]:          0 :     rSize = GetFieldSize();
    1014                 :          0 :     return true;
    1015                 :            : }
    1016                 :            : 
    1017                 :          0 : void ScDPHorFieldControl::HandleScroll()
    1018                 :            : {
    1019                 :          0 :     Redraw();
    1020                 :          0 : }
    1021                 :            : 
    1022                 :          0 : IMPL_LINK_NOARG(ScDPHorFieldControl, ScrollHdl)
    1023                 :            : {
    1024                 :          0 :     HandleScroll();
    1025                 :          0 :     return 0;
    1026                 :            : }
    1027                 :            : 
    1028                 :          0 : IMPL_LINK_NOARG(ScDPHorFieldControl, EndScrollHdl)
    1029                 :            : {
    1030                 :          0 :     HandleScroll();
    1031                 :          0 :     return 0;
    1032                 :            : }
    1033                 :            : 
    1034                 :            : //=============================================================================
    1035                 :            : 
    1036                 :          0 : ScDPPageFieldControl::ScDPPageFieldControl(
    1037                 :            :     ScDPLayoutDlg* pDialog, const ResId& rResId, FixedText* pCaption) :
    1038                 :          0 :     ScDPHorFieldControl(pDialog, rResId, pCaption)
    1039                 :            : {
    1040                 :          0 : }
    1041                 :            : 
    1042                 :          0 : ScDPPageFieldControl::~ScDPPageFieldControl()
    1043                 :            : {
    1044         [ #  # ]:          0 : }
    1045                 :            : 
    1046                 :          0 : ScDPFieldType ScDPPageFieldControl::GetFieldType() const
    1047                 :            : {
    1048                 :          0 :     return TYPE_PAGE;
    1049                 :            : }
    1050                 :            : 
    1051                 :          0 : String ScDPPageFieldControl::GetDescription() const
    1052                 :            : {
    1053         [ #  # ]:          0 :     return ScResId(STR_ACC_DATAPILOT_PAGE_DESCR);
    1054                 :            : }
    1055                 :            : 
    1056                 :            : //=============================================================================
    1057                 :            : 
    1058                 :          0 : ScDPColFieldControl::ScDPColFieldControl(
    1059                 :            :     ScDPLayoutDlg* pDialog, const ResId& rResId, FixedText* pCaption) :
    1060                 :          0 :     ScDPHorFieldControl(pDialog, rResId, pCaption)
    1061                 :            : {
    1062                 :          0 : }
    1063                 :            : 
    1064                 :          0 : ScDPColFieldControl::~ScDPColFieldControl()
    1065                 :            : {
    1066         [ #  # ]:          0 : }
    1067                 :            : 
    1068                 :          0 : ScDPFieldType ScDPColFieldControl::GetFieldType() const
    1069                 :            : {
    1070                 :          0 :     return TYPE_COL;
    1071                 :            : }
    1072                 :            : 
    1073                 :          0 : String ScDPColFieldControl::GetDescription() const
    1074                 :            : {
    1075         [ #  # ]:          0 :     return ScResId(STR_ACC_DATAPILOT_COL_DESCR);
    1076                 :            : }
    1077                 :            : 
    1078                 :            : //=============================================================================
    1079                 :            : 
    1080                 :          0 : ScDPRowFieldControl::ScDPRowFieldControl(
    1081                 :            :     ScDPLayoutDlg* pDialog, const ResId& rResId, FixedText* pCaption ) :
    1082                 :            :     ScDPFieldControlBase( pDialog, rResId, pCaption ),
    1083                 :            :     maScroll(this, WB_VERT | WB_DRAG),
    1084         [ #  # ]:          0 :     mnColumnBtnCount(0)
    1085                 :            : {
    1086         [ #  # ]:          0 :     maScroll.SetScrollHdl( LINK(this, ScDPRowFieldControl, ScrollHdl) );
    1087         [ #  # ]:          0 :     maScroll.SetEndScrollHdl( LINK(this, ScDPRowFieldControl, EndScrollHdl) );
    1088         [ #  # ]:          0 :     maScroll.Show(false);
    1089                 :            : 
    1090         [ #  # ]:          0 :     AppendPaintable(&maScroll);
    1091                 :          0 : }
    1092                 :            : 
    1093         [ #  # ]:          0 : ScDPRowFieldControl::~ScDPRowFieldControl()
    1094                 :            : {
    1095         [ #  # ]:          0 : }
    1096                 :            : 
    1097                 :            : //-------------------------------------------------------------------
    1098                 :            : 
    1099                 :          0 : Point ScDPRowFieldControl::GetFieldPosition(size_t nIndex)
    1100                 :            : {
    1101                 :          0 :     Point aPos;
    1102                 :          0 :     Size aSize;
    1103         [ #  # ]:          0 :     GetFieldBtnPosSize(nIndex, aPos, aSize);
    1104                 :          0 :     return aPos;
    1105                 :            : }
    1106                 :            : 
    1107                 :          0 : Size ScDPRowFieldControl::GetFieldSize() const
    1108                 :            : {
    1109                 :          0 :     return GetStdFieldBtnSize();
    1110                 :            : }
    1111                 :            : 
    1112                 :          0 : bool ScDPRowFieldControl::GetFieldIndex( const Point& rPos, size_t& rnIndex )
    1113                 :            : {
    1114                 :          0 :     rnIndex = INVALID_INDEX;
    1115 [ #  # ][ #  # ]:          0 :     if (rPos.X() < 0 || rPos.Y() < 0)
                 [ #  # ]
    1116                 :          0 :         return false;
    1117                 :            : 
    1118                 :          0 :     long nFldH = GetFieldSize().Height();
    1119                 :          0 :     long nThreshold = OUTER_MARGIN_VER + nFldH + ROW_FIELD_BTN_GAP / 2;
    1120                 :            : 
    1121                 :          0 :     size_t nIndex = 0;
    1122         [ #  # ]:          0 :     for (; nIndex < mnColumnBtnCount; ++nIndex)
    1123                 :            :     {
    1124         [ #  # ]:          0 :         if (rPos.Y() < nThreshold)
    1125                 :          0 :             break;
    1126                 :            : 
    1127                 :          0 :         nThreshold += nFldH + ROW_FIELD_BTN_GAP;
    1128                 :            :     }
    1129                 :            : 
    1130         [ #  # ]:          0 :     if (nIndex >= mnColumnBtnCount)
    1131                 :          0 :         nIndex = mnColumnBtnCount - 1;
    1132                 :            : 
    1133                 :          0 :     nIndex += maScroll.GetThumbPos();
    1134                 :          0 :     rnIndex = nIndex;
    1135                 :          0 :     return IsValidIndex(rnIndex);
    1136                 :            : }
    1137                 :            : 
    1138                 :          0 : void ScDPRowFieldControl::Redraw()
    1139                 :            : {
    1140         [ #  # ]:          0 :     VirtualDevice   aVirDev;
    1141                 :            :     // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
    1142         [ #  # ]:          0 :     aVirDev.EnableRTL( IsRTLEnabled() );
    1143 [ #  # ][ #  # ]:          0 :     aVirDev.SetMapMode( MAP_PIXEL );
                 [ #  # ]
    1144                 :            : 
    1145                 :          0 :     Point aPos0;
    1146         [ #  # ]:          0 :     Size aWndSize = GetSizePixel();
    1147         [ #  # ]:          0 :     Font aFont = GetFont();
    1148         [ #  # ]:          0 :     aFont.SetTransparent(true);
    1149         [ #  # ]:          0 :     aVirDev.SetFont(aFont);
    1150         [ #  # ]:          0 :     aVirDev.SetOutputSizePixel(aWndSize);
    1151                 :            : 
    1152         [ #  # ]:          0 :     DrawBackground(aVirDev);
    1153                 :            : 
    1154                 :          0 :     FieldNames& rFields = GetFieldNames();
    1155                 :            :     {
    1156                 :          0 :         long nScrollOffset = maScroll.GetThumbPos();
    1157                 :          0 :         FieldNames::iterator itr = rFields.begin(), itrEnd = rFields.end();
    1158         [ #  # ]:          0 :         if (nScrollOffset)
    1159         [ #  # ]:          0 :             ::std::advance(itr, nScrollOffset);
    1160                 :            : 
    1161 [ #  # ][ #  # ]:          0 :         for (size_t i = 0; itr != itrEnd; ++itr, ++i)
    1162                 :            :         {
    1163                 :          0 :             Point aFldPt;
    1164                 :          0 :             Size aFldSize;
    1165 [ #  # ][ #  # ]:          0 :             if (!GetFieldBtnPosSize(i, aFldPt, aFldSize))
    1166                 :            :                 break;
    1167                 :            : 
    1168                 :          0 :             size_t nField = i + nScrollOffset;
    1169 [ #  # ][ #  # ]:          0 :             bool bFocus = HasFocus() && (nField == GetSelectedField());
                 [ #  # ]
    1170 [ #  # ][ #  # ]:          0 :             DrawField(aVirDev, Rectangle(aFldPt, aFldSize), *itr, bFocus);
    1171                 :            :         }
    1172                 :            :     }
    1173                 :            : 
    1174                 :            :     // Create a bitmap from the virtual device, and place that bitmap onto
    1175                 :            :     // this control.
    1176 [ #  # ][ #  # ]:          0 :     DrawBitmap(aPos0, aVirDev.GetBitmap(aPos0, aWndSize));
                 [ #  # ]
    1177                 :            : 
    1178         [ #  # ]:          0 :     DrawPaintables();
    1179         [ #  # ]:          0 :     DrawInvertSelection();
    1180 [ #  # ][ #  # ]:          0 :     UpdateStyle();
                 [ #  # ]
    1181                 :          0 : }
    1182                 :            : 
    1183                 :          0 : void ScDPRowFieldControl::CalcSize()
    1184                 :            : {
    1185         [ #  # ]:          0 :     Size aWndSize = GetSizePixel();
    1186                 :            : 
    1187                 :          0 :     long nTotal = aWndSize.Height() - OUTER_MARGIN_VER;
    1188         [ #  # ]:          0 :     mnColumnBtnCount = nTotal / (GetFieldSize().Height() + ROW_FIELD_BTN_GAP);
    1189                 :            : 
    1190                 :          0 :     long nScrollSize = GetSettings().GetStyleSettings().GetScrollBarSize();
    1191                 :            : 
    1192         [ #  # ]:          0 :     maScroll.SetSizePixel(Size(nScrollSize, aWndSize.Height() - OUTER_MARGIN_VER*2));
    1193         [ #  # ]:          0 :     maScroll.SetPosPixel(Point(aWndSize.Width() - nScrollSize - OUTER_MARGIN_HOR, OUTER_MARGIN_VER));
    1194                 :          0 :     maScroll.SetLineSize(1);
    1195         [ #  # ]:          0 :     maScroll.SetVisibleSize(mnColumnBtnCount);
    1196                 :          0 :     maScroll.SetPageSize(mnColumnBtnCount);
    1197         [ #  # ]:          0 :     maScroll.SetRange(Range(0, mnColumnBtnCount));
    1198         [ #  # ]:          0 :     maScroll.DoScroll(0);
    1199                 :            : 
    1200                 :          0 : }
    1201                 :            : 
    1202                 :          0 : bool ScDPRowFieldControl::IsValidIndex(size_t /*nIndex*/) const
    1203                 :            : {
    1204                 :            :     // This method is here in case we decide to impose an arbitrary upper
    1205                 :            :     // boundary on the number of fields.
    1206                 :          0 :     return true;
    1207                 :            : }
    1208                 :            : 
    1209                 :          0 : size_t ScDPRowFieldControl::CalcNewFieldIndex(SCsCOL /*nDX*/, SCsROW nDY) const
    1210                 :            : {
    1211                 :          0 :     size_t nNewField = GetSelectedField();
    1212                 :          0 :     nNewField += nDY;
    1213         [ #  # ]:          0 :     return IsExistingIndex(nNewField) ? nNewField : GetSelectedField();
    1214                 :            : }
    1215                 :            : 
    1216                 :          0 : size_t ScDPRowFieldControl::GetDisplayPosition(size_t nIndex) const
    1217                 :            : {
    1218                 :          0 :     size_t nLower = maScroll.GetThumbPos();
    1219                 :          0 :     size_t nUpper = nLower + mnColumnBtnCount;
    1220 [ #  # ][ #  # ]:          0 :     if (nLower <= nIndex && nIndex <= nUpper)
    1221                 :          0 :         return nIndex - nLower;
    1222                 :            : 
    1223                 :          0 :     return INVALID_INDEX;
    1224                 :            : }
    1225                 :            : 
    1226                 :            : //-------------------------------------------------------------------
    1227                 :            : 
    1228                 :          0 : String ScDPRowFieldControl::GetDescription() const
    1229                 :            : {
    1230         [ #  # ]:          0 :     return ScResId(STR_ACC_DATAPILOT_ROW_DESCR);
    1231                 :            : }
    1232                 :            : 
    1233                 :          0 : ScDPFieldType ScDPRowFieldControl::GetFieldType() const
    1234                 :            : {
    1235                 :          0 :     return TYPE_ROW;
    1236                 :            : }
    1237                 :            : 
    1238                 :          0 : void ScDPRowFieldControl::ScrollToEnd()
    1239                 :            : {
    1240                 :          0 :     maScroll.DoScroll(maScroll.GetRangeMax());
    1241                 :          0 : }
    1242                 :            : 
    1243                 :          0 : void ScDPRowFieldControl::ScrollToShowSelection()
    1244                 :            : {
    1245                 :          0 :     size_t nLower = maScroll.GetThumbPos();
    1246                 :          0 :     size_t nUpper = nLower + mnColumnBtnCount - 1;
    1247                 :          0 :     size_t nSel = GetSelectedField();
    1248         [ #  # ]:          0 :     if (nSel < nLower)
    1249                 :            :     {
    1250                 :            :         // scroll up
    1251                 :          0 :         maScroll.DoScroll(nSel);
    1252                 :            :     }
    1253         [ #  # ]:          0 :     else if (nUpper < nSel)
    1254                 :            :     {
    1255                 :            :         // scroll down
    1256                 :          0 :         size_t nD = nSel - nUpper;
    1257                 :          0 :         maScroll.DoScroll(nLower + nD);
    1258                 :            :     }
    1259                 :          0 : }
    1260                 :            : 
    1261                 :          0 : void ScDPRowFieldControl::ResetScrollBar()
    1262                 :            : {
    1263                 :          0 :     long nOldMax = maScroll.GetRangeMax();
    1264         [ #  # ]:          0 :     long nNewMax = std::max<long>(mnColumnBtnCount, GetFieldCount());
    1265                 :            : 
    1266         [ #  # ]:          0 :     if (nOldMax != nNewMax)
    1267                 :            :     {
    1268                 :          0 :         maScroll.SetRangeMax(nNewMax);
    1269                 :          0 :         maScroll.Show(GetFieldCount() > mnColumnBtnCount);
    1270                 :            :     }
    1271                 :          0 : }
    1272                 :            : 
    1273                 :          0 : void ScDPRowFieldControl::HandleWheelScroll(long nNotch)
    1274                 :            : {
    1275                 :          0 :     maScroll.DoScroll(maScroll.GetThumbPos() - nNotch);
    1276                 :          0 : }
    1277                 :            : 
    1278                 :          0 : bool ScDPRowFieldControl::GetFieldBtnPosSize(size_t nPos, Point& rPos, Size& rSize)
    1279                 :            : {
    1280         [ #  # ]:          0 :     if (nPos >= mnColumnBtnCount)
    1281                 :          0 :         return false;
    1282                 :            : 
    1283                 :          0 :     size_t nOffset = maScroll.GetThumbPos();
    1284         [ #  # ]:          0 :     if (nPos + nOffset >= GetFieldCount())
    1285                 :          0 :         return false;
    1286                 :            : 
    1287                 :          0 :     rSize = GetFieldSize();
    1288                 :          0 :     rPos = Point(OUTER_MARGIN_HOR, OUTER_MARGIN_VER);
    1289                 :          0 :     rPos.Y() += nPos * (rSize.Height() + ROW_FIELD_BTN_GAP);
    1290                 :          0 :     return true;
    1291                 :            : }
    1292                 :            : 
    1293                 :          0 : void ScDPRowFieldControl::HandleScroll()
    1294                 :            : {
    1295                 :          0 :     Redraw();
    1296                 :          0 : }
    1297                 :            : 
    1298                 :          0 : IMPL_LINK_NOARG(ScDPRowFieldControl, ScrollHdl)
    1299                 :            : {
    1300                 :          0 :     HandleScroll();
    1301                 :          0 :     return 0;
    1302                 :            : }
    1303                 :            : 
    1304                 :          0 : IMPL_LINK_NOARG(ScDPRowFieldControl, EndScrollHdl)
    1305                 :            : {
    1306                 :          0 :     HandleScroll();
    1307                 :          0 :     return 0;
    1308                 :            : }
    1309                 :            : 
    1310                 :            : //=============================================================================
    1311                 :            : 
    1312                 :          0 : ScDPSelectFieldControl::ScDPSelectFieldControl(
    1313                 :            :         ScDPLayoutDlg* pDialog, const ResId& rResId, FixedText* pCaption) :
    1314                 :          0 :     ScDPHorFieldControl(pDialog, rResId, pCaption)
    1315                 :            : {
    1316 [ #  # ][ #  # ]:          0 :     SetName(String(ScResId(STR_SELECT)));
         [ #  # ][ #  # ]
    1317                 :          0 : }
    1318                 :            : 
    1319                 :          0 : ScDPSelectFieldControl::~ScDPSelectFieldControl()
    1320                 :            : {
    1321         [ #  # ]:          0 : }
    1322                 :            : 
    1323                 :          0 : ScDPFieldType ScDPSelectFieldControl::GetFieldType() const
    1324                 :            : {
    1325                 :          0 :     return TYPE_SELECT;
    1326                 :            : }
    1327                 :            : 
    1328                 :          0 : String ScDPSelectFieldControl::GetDescription() const
    1329                 :            : {
    1330         [ #  # ]:          0 :     return ScResId(STR_ACC_DATAPILOT_SEL_DESCR);
    1331                 :            : }
    1332                 :            : 
    1333                 :            : //=============================================================================
    1334                 :            : 
    1335                 :          0 : ScDPDataFieldControl::ScDPDataFieldControl(
    1336                 :            :     ScDPLayoutDlg* pDialog, const ResId& rResId, FixedText* pCaption) :
    1337                 :          0 :     ScDPHorFieldControl(pDialog, rResId, pCaption)
    1338                 :            : {
    1339                 :          0 : }
    1340                 :            : 
    1341                 :          0 : ScDPDataFieldControl::~ScDPDataFieldControl()
    1342                 :            : {
    1343         [ #  # ]:          0 : }
    1344                 :            : 
    1345                 :          0 : ScDPFieldType ScDPDataFieldControl::GetFieldType() const
    1346                 :            : {
    1347                 :          0 :     return TYPE_DATA;
    1348                 :            : }
    1349                 :            : 
    1350                 :          0 : Size ScDPDataFieldControl::GetFieldSize() const
    1351                 :            : {
    1352         [ #  # ]:          0 :     Size aWndSize = GetSizePixel();
    1353                 :          0 :     long nFieldObjWidth = static_cast<long>(aWndSize.Width() / 2.0 - OUTER_MARGIN_HOR - DATA_FIELD_BTN_GAP/2);
    1354                 :          0 :     Size aFieldSize(nFieldObjWidth, FIELD_BTN_HEIGHT);
    1355                 :          0 :     return aFieldSize;
    1356                 :            : }
    1357                 :            : 
    1358                 :          0 : String ScDPDataFieldControl::GetDescription() const
    1359                 :            : {
    1360         [ #  # ]:          0 :     return ScResId(STR_ACC_DATAPILOT_DATA_DESCR);
    1361                 :            : }
    1362                 :            : 
    1363                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10