LCOV - code coverage report
Current view: top level - reportdesign/source/ui/dlg - CondFormat.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 256 0.4 %
Date: 2014-11-03 Functions: 2 33 6.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "CondFormat.hxx"
      21             : #include "CondFormat.hrc"
      22             : 
      23             : #include "uistrings.hrc"
      24             : #include "RptResId.hrc"
      25             : #include "rptui_slotid.hrc"
      26             : #include "ModuleHelper.hxx"
      27             : #include "helpids.hrc"
      28             : #include "UITools.hxx"
      29             : #include "ReportController.hxx"
      30             : #include "Condition.hxx"
      31             : 
      32             : #include <com/sun/star/beans/XPropertySet.hpp>
      33             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      34             : 
      35             : #include <toolkit/helper/vclunohelper.hxx>
      36             : 
      37             : #include <vcl/msgbox.hxx>
      38             : #include <vcl/settings.hxx>
      39             : 
      40             : #include <tools/debug.hxx>
      41             : #include <tools/diagnose_ex.h>
      42             : 
      43             : #include <comphelper/property.hxx>
      44             : 
      45             : #include <algorithm>
      46             : #include "UndoActions.hxx"
      47             : 
      48             : 
      49             : namespace rptui
      50             : {
      51             : 
      52             : 
      53             :     using ::com::sun::star::uno::Reference;
      54             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      55             :     using ::com::sun::star::uno::UNO_QUERY;
      56             :     using ::com::sun::star::uno::Exception;
      57             :     using ::com::sun::star::lang::IllegalArgumentException;
      58             :     using ::com::sun::star::uno::Sequence;
      59             :     using ::com::sun::star::beans::PropertyValue;
      60             :     using ::com::sun::star::uno::Any;
      61             : 
      62             :     using namespace ::com::sun::star::report;
      63             : 
      64             : 
      65             :     // UpdateLocker
      66             : 
      67             :     class UpdateLocker
      68             :     {
      69             :         vcl::Window& m_rWindow;
      70             : 
      71             :     public:
      72           0 :         UpdateLocker( vcl::Window& _rWindow )
      73           0 :             :m_rWindow( _rWindow )
      74             :         {
      75           0 :             _rWindow.SetUpdateMode( false );
      76           0 :         }
      77           0 :         ~UpdateLocker()
      78             :         {
      79           0 :             m_rWindow.SetUpdateMode( true );
      80           0 :         }
      81             :     };
      82             : 
      83           0 :     void ConditionalFormattingDialog::impl_setPrefHeight(bool bFirst)
      84             :     {
      85           0 :         if (!m_bConstructed && !bFirst)
      86           0 :             return;
      87             : 
      88             :         //allow dialog to resize itself
      89           0 :         size_t nCount = impl_getConditionCount();
      90           0 :         if (nCount)
      91             :         {
      92           0 :             long nHeight = m_aConditions[0]->get_preferred_size().Height();
      93           0 :             size_t nVisibleConditions = ::std::min(nCount, MAX_CONDITIONS);
      94           0 :             nHeight *= nVisibleConditions;
      95           0 :             if (nHeight != m_pScrollWindow->get_height_request())
      96             :             {
      97           0 :                 m_pScrollWindow->set_height_request(nHeight);
      98           0 :                 if (!isCalculatingInitialLayoutSize() && !bFirst)
      99           0 :                     setOptimalLayoutSize();
     100             :             }
     101             :         }
     102             :     }
     103             : 
     104             :     // class ConditionalFormattingDialog
     105           0 :     ConditionalFormattingDialog::ConditionalFormattingDialog(
     106             :             vcl::Window* _pParent, const Reference< XReportControlModel >& _rxFormatConditions, ::rptui::OReportController& _rController )
     107             :         :ModalDialog( _pParent, "CondFormat", "modules/dbreport/ui/condformatdialog.ui" )
     108             :         ,m_rController( _rController )
     109             :         ,m_xFormatConditions( _rxFormatConditions )
     110             :         ,m_bDeletingCondition( false )
     111           0 :         ,m_bConstructed( false )
     112             :     {
     113           0 :         get(m_pConditionPlayground, "condPlaygroundDrawingarea");
     114           0 :         get(m_pScrollWindow, "scrolledwindow");
     115           0 :         m_pScrollWindow->setUserManagedScrolling(true);
     116           0 :         m_pCondScroll = &(m_pScrollWindow->getVertScrollBar());
     117             : 
     118             :         OSL_ENSURE( m_xFormatConditions.is(), "ConditionalFormattingDialog::ConditionalFormattingDialog: ReportControlModel is NULL -> Prepare for GPF!" );
     119             : 
     120           0 :         m_xCopy.set( m_xFormatConditions->createClone(), UNO_QUERY_THROW );
     121             : 
     122           0 :         m_pCondScroll->SetScrollHdl( LINK( this, ConditionalFormattingDialog, OnScroll ) );
     123             : 
     124           0 :         impl_initializeConditions();
     125             : 
     126           0 :         impl_setPrefHeight(true);
     127             : 
     128           0 :         m_bConstructed = true;
     129           0 :     }
     130             : 
     131           0 :     ConditionalFormattingDialog::~ConditionalFormattingDialog()
     132             :     {
     133           0 :         m_aConditions.clear();
     134           0 :     }
     135             : 
     136           0 :     void ConditionalFormattingDialog::impl_updateConditionIndicies()
     137             :     {
     138           0 :         sal_Int32 nIndex = 0;
     139           0 :         for (   Conditions::const_iterator cond = m_aConditions.begin();
     140           0 :                 cond != m_aConditions.end();
     141             :                 ++cond, ++nIndex
     142             :             )
     143             :         {
     144           0 :             (*cond)->setConditionIndex( nIndex, impl_getConditionCount() );
     145             :         }
     146           0 :     }
     147             : 
     148           0 :     void ConditionalFormattingDialog::impl_conditionCountChanged()
     149             :     {
     150           0 :         if ( m_aConditions.empty() )
     151           0 :             impl_addCondition_nothrow( 0 );
     152             : 
     153           0 :         impl_setPrefHeight(false);
     154             : 
     155           0 :         impl_updateScrollBarRange();
     156           0 :         impl_updateConditionIndicies();
     157           0 :         impl_layoutAll();
     158           0 :     }
     159             : 
     160           0 :     void ConditionalFormattingDialog::addCondition( size_t _nAddAfterIndex )
     161             :     {
     162             :         OSL_PRECOND( _nAddAfterIndex < impl_getConditionCount(), "ConditionalFormattingDialog::addCondition: illegal condition index!" );
     163           0 :         impl_addCondition_nothrow( _nAddAfterIndex + 1 );
     164           0 :     }
     165             : 
     166             : 
     167           0 :     void ConditionalFormattingDialog::deleteCondition( size_t _nCondIndex )
     168             :     {
     169           0 :         impl_deleteCondition_nothrow( _nCondIndex );
     170           0 :     }
     171             : 
     172             : 
     173           0 :     void ConditionalFormattingDialog::impl_addCondition_nothrow( size_t _nNewCondIndex )
     174             :     {
     175           0 :         UpdateLocker aLockUpdates( *this );
     176             : 
     177             :         try
     178             :         {
     179           0 :             if ( _nNewCondIndex > (size_t)m_xCopy->getCount() )
     180           0 :                 throw IllegalArgumentException();
     181             : 
     182           0 :             Reference< XFormatCondition > xCond = m_xCopy->createFormatCondition();
     183           0 :             ::comphelper::copyProperties(m_xCopy.get(),xCond.get());
     184           0 :             m_xCopy->insertByIndex( _nNewCondIndex, makeAny( xCond ) );
     185             : 
     186           0 :             ConditionPtr pCon( new Condition( m_pConditionPlayground, *this, m_rController ) );
     187           0 :             pCon->setCondition( xCond );
     188           0 :             pCon->reorderWithinParent(_nNewCondIndex);
     189           0 :             m_aConditions.insert( m_aConditions.begin() + _nNewCondIndex, pCon );
     190             :         }
     191           0 :         catch( const Exception& )
     192             :         {
     193             :             DBG_UNHANDLED_EXCEPTION();
     194             :         }
     195             : 
     196           0 :         impl_conditionCountChanged();
     197             : 
     198           0 :         impl_ensureConditionVisible( _nNewCondIndex );
     199           0 :     }
     200             : 
     201             : 
     202           0 :     void ConditionalFormattingDialog::impl_focusCondition( size_t _nCondIndex )
     203             :     {
     204             :         OSL_PRECOND( _nCondIndex < impl_getConditionCount(),
     205             :             "ConditionalFormattingDialog::impl_focusCondition: illegal index!" );
     206             : 
     207           0 :         impl_ensureConditionVisible( _nCondIndex );
     208           0 :         m_aConditions[ _nCondIndex ]->GrabFocus();
     209           0 :     }
     210             : 
     211             : 
     212           0 :     void ConditionalFormattingDialog::impl_deleteCondition_nothrow( size_t _nCondIndex )
     213             :     {
     214           0 :         UpdateLocker aLockUpdates( *this );
     215             : 
     216             :         OSL_PRECOND( _nCondIndex < impl_getConditionCount(),
     217             :             "ConditionalFormattingDialog::impl_deleteCondition_nothrow: illegal index!" );
     218             : 
     219           0 :         bool bLastCondition = ( impl_getConditionCount() == 1 );
     220             : 
     221           0 :         bool bSetNewFocus = false;
     222           0 :         size_t nNewFocusIndex( _nCondIndex );
     223             :         try
     224             :         {
     225           0 :             if ( !bLastCondition )
     226           0 :                 m_xCopy->removeByIndex( _nCondIndex );
     227             : 
     228           0 :             Conditions::iterator pos = m_aConditions.begin() + _nCondIndex;
     229           0 :             if ( bLastCondition )
     230             :             {
     231           0 :                 Reference< XFormatCondition > xFormatCondition( m_xCopy->getByIndex( 0 ), UNO_QUERY_THROW );
     232           0 :                 xFormatCondition->setFormula( OUString() );
     233           0 :                 (*pos)->setCondition( xFormatCondition );
     234             :             }
     235             :             else
     236             :             {
     237           0 :                 bSetNewFocus = (*pos)->HasChildPathFocus();
     238           0 :                 m_bDeletingCondition = true;
     239           0 :                 m_aConditions.erase( pos );
     240           0 :                 m_bDeletingCondition = false;
     241             :             }
     242             : 
     243           0 :             if ( bSetNewFocus )
     244             :             {
     245           0 :                 if ( nNewFocusIndex >= impl_getConditionCount() )
     246           0 :                     nNewFocusIndex = impl_getConditionCount() - 1;
     247             :             }
     248             :         }
     249           0 :         catch( const Exception& )
     250             :         {
     251             :             DBG_UNHANDLED_EXCEPTION();
     252             :         }
     253             : 
     254           0 :         impl_conditionCountChanged();
     255           0 :         if ( bSetNewFocus )
     256           0 :             impl_focusCondition( nNewFocusIndex );
     257           0 :     }
     258             : 
     259             : 
     260           0 :     void ConditionalFormattingDialog::impl_moveCondition_nothrow( size_t _nCondIndex, bool _bMoveUp )
     261             :     {
     262           0 :         size_t nOldConditionIndex( _nCondIndex );
     263           0 :         size_t nNewConditionIndex( _bMoveUp ? _nCondIndex - 1 : _nCondIndex + 1 );
     264             : 
     265             :         // do this in two steps, so we don't become inconsistent if any of the UNO actions fails
     266           0 :         Any aMovedCondition;
     267           0 :         ConditionPtr pMovedCondition;
     268             :         try
     269             :         {
     270           0 :             aMovedCondition = m_xCopy->getByIndex( (sal_Int32)nOldConditionIndex );
     271           0 :             m_xCopy->removeByIndex( (sal_Int32)nOldConditionIndex );
     272             : 
     273           0 :             Conditions::iterator aRemovePos( m_aConditions.begin() + nOldConditionIndex );
     274           0 :             pMovedCondition = *aRemovePos;
     275           0 :             m_aConditions.erase( aRemovePos );
     276             :         }
     277           0 :         catch( const Exception& )
     278             :         {
     279             :             DBG_UNHANDLED_EXCEPTION();
     280           0 :             return;
     281             :         }
     282             : 
     283             :         try
     284             :         {
     285           0 :             m_xCopy->insertByIndex( (sal_Int32)nNewConditionIndex, aMovedCondition );
     286           0 :             m_aConditions.insert( m_aConditions.begin() + nNewConditionIndex, pMovedCondition );
     287             :         }
     288           0 :         catch( const Exception& )
     289             :         {
     290             :             DBG_UNHANDLED_EXCEPTION();
     291             :         }
     292             : 
     293             :         // at least the two swapped conditions need to know their new index
     294           0 :         impl_updateConditionIndicies();
     295             : 
     296             :         // re-layout all conditions
     297           0 :         impl_layoutConditions();
     298             : 
     299             :         // ensure the moved condition is visible
     300           0 :         impl_ensureConditionVisible( nNewConditionIndex );
     301             :     }
     302             : 
     303           0 :     IMPL_LINK( ConditionalFormattingDialog, OnScroll, ScrollBar*, /*_pNotInterestedIn*/ )
     304             :     {
     305           0 :         size_t nFirstCondIndex( impl_getFirstVisibleConditionIndex() );
     306           0 :         size_t nFocusCondIndex = impl_getFocusedConditionIndex( nFirstCondIndex );
     307             : 
     308           0 :         impl_layoutConditions();
     309             : 
     310           0 :         if ( nFocusCondIndex < nFirstCondIndex )
     311           0 :             impl_focusCondition( nFirstCondIndex );
     312           0 :         else if ( nFocusCondIndex >= nFirstCondIndex + MAX_CONDITIONS )
     313           0 :             impl_focusCondition( nFirstCondIndex + MAX_CONDITIONS - 1 );
     314             : 
     315           0 :         return 0;
     316             :     }
     317             : 
     318           0 :     void ConditionalFormattingDialog::impl_layoutConditions()
     319             :     {
     320           0 :         if (m_aConditions.empty())
     321           0 :             return;
     322           0 :         long nConditionHeight = m_aConditions[0]->get_preferred_size().Height();
     323           0 :         Point aConditionPos(0, -1 * nConditionHeight * impl_getFirstVisibleConditionIndex());
     324           0 :         m_pConditionPlayground->SetPosPixel(aConditionPos);
     325             :     }
     326             : 
     327           0 :     void ConditionalFormattingDialog::impl_layoutAll()
     328             :     {
     329             :         // condition's positions
     330           0 :         impl_layoutConditions();
     331             : 
     332             :         // scrollbar visibility
     333           0 :         if ( !impl_needScrollBar() )
     334             :             // normalize the position, so it can, in all situations, be used as top index
     335           0 :             m_pCondScroll->SetThumbPos( 0 );
     336           0 :     }
     337             : 
     338           0 :     void ConditionalFormattingDialog::impl_initializeConditions()
     339             :     {
     340             :         try
     341             :         {
     342           0 :             sal_Int32 nCount = m_xCopy->getCount();
     343           0 :             for ( sal_Int32 i = 0; i < nCount ; ++i )
     344             :             {
     345           0 :                 ConditionPtr pCon( new Condition( m_pConditionPlayground, *this, m_rController ) );
     346           0 :                 Reference< XFormatCondition > xCond( m_xCopy->getByIndex(i), UNO_QUERY );
     347           0 :                 pCon->reorderWithinParent(i);
     348           0 :                 pCon->setCondition( xCond );
     349           0 :                 pCon->updateToolbar( xCond.get() );
     350           0 :                 m_aConditions.push_back( pCon );
     351           0 :             }
     352             :         }
     353           0 :         catch(Exception&)
     354             :         {
     355             :             OSL_FAIL("Can not access format condition!");
     356             :         }
     357             : 
     358           0 :         impl_conditionCountChanged();
     359           0 :     }
     360             : 
     361           0 :     void ConditionalFormattingDialog::applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color _aColor )
     362             :     {
     363             :         OSL_PRECOND( _nCommandId, "ConditionalFormattingDialog::applyCommand: illegal command id!" );
     364             :         try
     365             :         {
     366           0 :             Reference< XReportControlFormat > xReportControlFormat( m_xCopy->getByIndex( _nCondIndex ), UNO_QUERY_THROW );
     367             : 
     368           0 :             Sequence< PropertyValue > aArgs(3);
     369             : 
     370           0 :             aArgs[0].Name = REPORTCONTROLFORMAT;
     371           0 :             aArgs[0].Value <<= xReportControlFormat;
     372             : 
     373           0 :             aArgs[1].Name = CURRENT_WINDOW;
     374           0 :             aArgs[1].Value <<= VCLUnoHelper::GetInterface(this);
     375             : 
     376           0 :             aArgs[2].Name = PROPERTY_FONTCOLOR;
     377           0 :             aArgs[2].Value <<= (sal_uInt32)_aColor.GetColor();
     378             : 
     379             :             // we use this way to create undo actions
     380           0 :             m_rController.executeUnChecked(_nCommandId,aArgs);
     381           0 :             m_aConditions[ _nCondIndex ]->updateToolbar(xReportControlFormat);
     382             :         }
     383           0 :         catch( Exception& )
     384             :         {
     385             :             DBG_UNHANDLED_EXCEPTION();
     386             :         }
     387           0 :     }
     388             : 
     389             : 
     390           0 :     void ConditionalFormattingDialog::moveConditionUp( size_t _nCondIndex )
     391             :     {
     392             :         OSL_PRECOND( _nCondIndex > 0, "ConditionalFormattingDialog::moveConditionUp: cannot move up the first condition!" );
     393           0 :         if ( _nCondIndex > 0 )
     394           0 :             impl_moveCondition_nothrow( _nCondIndex, true );
     395           0 :     }
     396             : 
     397             : 
     398           0 :     void ConditionalFormattingDialog::moveConditionDown( size_t _nCondIndex )
     399             :     {
     400             :         OSL_PRECOND( _nCondIndex < impl_getConditionCount(), "ConditionalFormattingDialog::moveConditionDown: cannot move down the last condition!" );
     401           0 :         if ( _nCondIndex < impl_getConditionCount() )
     402           0 :             impl_moveCondition_nothrow( _nCondIndex, false );
     403           0 :     }
     404             : 
     405             : 
     406           0 :     OUString ConditionalFormattingDialog::getDataField() const
     407             :     {
     408           0 :         OUString sDataField;
     409             :         try
     410             :         {
     411           0 :             sDataField = m_xFormatConditions->getDataField();
     412             :         }
     413           0 :         catch( const Exception& )
     414             :         {
     415             :             DBG_UNHANDLED_EXCEPTION();
     416             :         }
     417           0 :         return sDataField;
     418             :     }
     419             : 
     420             : 
     421           0 :     short ConditionalFormattingDialog::Execute()
     422             :     {
     423           0 :         short nRet = ModalDialog::Execute();
     424           0 :         if ( nRet == RET_OK )
     425             :         {
     426           0 :             const OUString sUndoAction( ModuleRes( RID_STR_UNDO_CONDITIONAL_FORMATTING ) );
     427           0 :             const UndoContext aUndoContext( m_rController.getUndoManager(), sUndoAction );
     428             :             try
     429             :             {
     430           0 :                 sal_Int32 j(0), i(0);;
     431           0 :                 for (   Conditions::const_iterator cond = m_aConditions.begin();
     432           0 :                         cond != m_aConditions.end();
     433             :                         ++cond, ++i
     434             :                     )
     435             :                 {
     436           0 :                     Reference< XFormatCondition > xCond( m_xCopy->getByIndex(i), UNO_QUERY_THROW );
     437           0 :                     (*cond)->fillFormatCondition( xCond );
     438             : 
     439           0 :                     if ( (*cond)->isEmpty() )
     440           0 :                         continue;
     441             : 
     442           0 :                     Reference< XFormatCondition > xNewCond;
     443           0 :                     bool bAppend = j >= m_xFormatConditions->getCount();
     444           0 :                     if ( bAppend )
     445             :                     {
     446           0 :                         xNewCond = m_xFormatConditions->createFormatCondition();
     447           0 :                         m_xFormatConditions->insertByIndex( i, makeAny( xNewCond ) );
     448             :                     }
     449             :                     else
     450           0 :                         xNewCond.set( m_xFormatConditions->getByIndex(j), UNO_QUERY );
     451           0 :                     ++j;
     452             : 
     453           0 :                     ::comphelper::copyProperties(xCond.get(),xNewCond.get());
     454           0 :                 }
     455             : 
     456           0 :                 for ( sal_Int32 k = m_xFormatConditions->getCount()-1; k >= j; --k )
     457           0 :                     m_xFormatConditions->removeByIndex(k);
     458             : 
     459           0 :                 ::comphelper::copyProperties( m_xCopy.get(), m_xFormatConditions.get() );
     460             :             }
     461           0 :             catch ( const Exception& )
     462             :             {
     463             :                 DBG_UNHANDLED_EXCEPTION();
     464           0 :                 nRet = RET_NO;
     465           0 :             }
     466             :         }
     467           0 :         return nRet;
     468             :     }
     469             : 
     470             : 
     471           0 :     bool ConditionalFormattingDialog::PreNotify( NotifyEvent& _rNEvt )
     472             :     {
     473           0 :         switch ( _rNEvt.GetType() )
     474             :         {
     475             :         case EVENT_KEYINPUT:
     476             :         {
     477           0 :             const KeyEvent* pKeyEvent( _rNEvt.GetKeyEvent() );
     478           0 :             const vcl::KeyCode& rKeyCode = pKeyEvent->GetKeyCode();
     479           0 :             if ( rKeyCode.IsMod1() && rKeyCode.IsMod2() )
     480             :             {
     481           0 :                 if ( rKeyCode.GetCode() == 0x0508 )
     482             :                 {
     483           0 :                     impl_deleteCondition_nothrow( impl_getFocusedConditionIndex( 0 ) );
     484           0 :                     return true;
     485             :                 }
     486           0 :                 if ( rKeyCode.GetCode() == 0x0507 ) // +
     487             :                 {
     488           0 :                     impl_addCondition_nothrow( impl_getFocusedConditionIndex( impl_getConditionCount() - 1 ) + 1 );
     489           0 :                     return true;
     490             :                 }
     491             :             }
     492             :         }
     493           0 :         break;
     494             :         case EVENT_GETFOCUS:
     495             :         {
     496           0 :             if ( m_bDeletingCondition )
     497           0 :                 break;
     498             : 
     499           0 :             const vcl::Window* pGetFocusWindow( _rNEvt.GetWindow() );
     500             : 
     501             :             // determine whether the new focus window is part of an (currently invisible) condition
     502           0 :             const vcl::Window* pConditionCandidate = pGetFocusWindow->GetParent();
     503           0 :             const vcl::Window* pPlaygroundCandidate = pConditionCandidate ? pConditionCandidate->GetParent() : NULL;
     504           0 :             while   (   ( pPlaygroundCandidate )
     505           0 :                     &&  ( pPlaygroundCandidate != this )
     506           0 :                     &&  ( pPlaygroundCandidate != m_pConditionPlayground )
     507             :                     )
     508             :             {
     509           0 :                 pConditionCandidate = pConditionCandidate->GetParent();
     510           0 :                 pPlaygroundCandidate = pConditionCandidate ? pConditionCandidate->GetParent() : NULL;
     511             :             }
     512           0 :             if (pConditionCandidate && pPlaygroundCandidate == m_pConditionPlayground)
     513             :             {
     514           0 :                 impl_ensureConditionVisible( dynamic_cast< const Condition& >( *pConditionCandidate ).getConditionIndex() );
     515             :             }
     516             :         }
     517           0 :         break;
     518             :         }
     519             : 
     520           0 :         return ModalDialog::PreNotify( _rNEvt );
     521             :     }
     522             : 
     523             : 
     524           0 :     size_t ConditionalFormattingDialog::impl_getFirstVisibleConditionIndex() const
     525             :     {
     526           0 :         return (size_t)m_pCondScroll->GetThumbPos();
     527             :     }
     528             : 
     529             : 
     530           0 :     size_t ConditionalFormattingDialog::impl_getLastVisibleConditionIndex() const
     531             :     {
     532           0 :         return ::std::min( impl_getFirstVisibleConditionIndex() + MAX_CONDITIONS, impl_getConditionCount() ) - 1;
     533             :     }
     534             : 
     535             : 
     536           0 :     size_t ConditionalFormattingDialog::impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const
     537             :     {
     538           0 :         size_t nIndex( 0 );
     539           0 :         for (   Conditions::const_iterator cond = m_aConditions.begin();
     540           0 :                 cond != m_aConditions.end();
     541             :                 ++cond, ++nIndex
     542             :             )
     543             :         {
     544           0 :             if ( (*cond)->HasChildPathFocus() )
     545           0 :                 return nIndex;
     546             :         }
     547           0 :         return _nFallBackIfNone;
     548             :     }
     549             : 
     550             : 
     551           0 :     void ConditionalFormattingDialog::impl_updateScrollBarRange()
     552             :     {
     553           0 :         long nMax = ( impl_getConditionCount() > MAX_CONDITIONS ) ? impl_getConditionCount() - MAX_CONDITIONS + 1 : 0;
     554             : 
     555           0 :         m_pCondScroll->SetRangeMin( 0 );
     556           0 :         m_pCondScroll->SetRangeMax( nMax );
     557           0 :         m_pCondScroll->SetVisibleSize( 1 );
     558           0 :     }
     559             : 
     560             : 
     561           0 :     void ConditionalFormattingDialog::impl_scrollTo( size_t _nTopCondIndex )
     562             :     {
     563             :         OSL_PRECOND( _nTopCondIndex + MAX_CONDITIONS <= impl_getConditionCount(),
     564             :             "ConditionalFormattingDialog::impl_scrollTo: illegal index!" );
     565           0 :         m_pCondScroll->SetThumbPos( _nTopCondIndex );
     566           0 :         OnScroll( m_pCondScroll );
     567           0 :     }
     568             : 
     569             : 
     570           0 :     void ConditionalFormattingDialog::impl_ensureConditionVisible( size_t _nCondIndex )
     571             :     {
     572             :         OSL_PRECOND( _nCondIndex < impl_getConditionCount(),
     573             :             "ConditionalFormattingDialog::impl_ensureConditionVisible: illegal index!" );
     574             : 
     575           0 :         if ( _nCondIndex < impl_getFirstVisibleConditionIndex() )
     576           0 :             impl_scrollTo( _nCondIndex );
     577           0 :         else if ( _nCondIndex > impl_getLastVisibleConditionIndex() )
     578           0 :             impl_scrollTo( _nCondIndex - MAX_CONDITIONS + 1 );
     579           0 :     }
     580             : 
     581             : 
     582           6 : } // rptui
     583             : 
     584             : 
     585             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10