LCOV - code coverage report
Current view: top level - reportdesign/source/ui/dlg - CondFormat.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 263 0.4 %
Date: 2015-06-13 12:38:46 Functions: 2 34 5.9 %
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 :         disposeOnce();
     134           0 :     }
     135             : 
     136           0 :     void ConditionalFormattingDialog::dispose()
     137             :     {
     138           0 :         m_aConditions.clear();
     139           0 :         m_pConditionPlayground.clear();
     140           0 :         m_pScrollWindow.clear();
     141           0 :         m_pCondScroll.clear();
     142           0 :         ModalDialog::dispose();
     143           0 :     }
     144             : 
     145           0 :     void ConditionalFormattingDialog::impl_updateConditionIndicies()
     146             :     {
     147           0 :         sal_Int32 nIndex = 0;
     148           0 :         for (   Conditions::const_iterator cond = m_aConditions.begin();
     149           0 :                 cond != m_aConditions.end();
     150             :                 ++cond, ++nIndex
     151             :             )
     152             :         {
     153           0 :             (*cond)->setConditionIndex( nIndex, impl_getConditionCount() );
     154             :         }
     155           0 :     }
     156             : 
     157           0 :     void ConditionalFormattingDialog::impl_conditionCountChanged()
     158             :     {
     159           0 :         if ( m_aConditions.empty() )
     160           0 :             impl_addCondition_nothrow( 0 );
     161             : 
     162           0 :         impl_setPrefHeight(false);
     163             : 
     164           0 :         impl_updateScrollBarRange();
     165           0 :         impl_updateConditionIndicies();
     166           0 :         impl_layoutAll();
     167           0 :     }
     168             : 
     169           0 :     void ConditionalFormattingDialog::addCondition( size_t _nAddAfterIndex )
     170             :     {
     171             :         OSL_PRECOND( _nAddAfterIndex < impl_getConditionCount(), "ConditionalFormattingDialog::addCondition: illegal condition index!" );
     172           0 :         impl_addCondition_nothrow( _nAddAfterIndex + 1 );
     173           0 :     }
     174             : 
     175             : 
     176           0 :     void ConditionalFormattingDialog::deleteCondition( size_t _nCondIndex )
     177             :     {
     178           0 :         impl_deleteCondition_nothrow( _nCondIndex );
     179           0 :     }
     180             : 
     181             : 
     182           0 :     void ConditionalFormattingDialog::impl_addCondition_nothrow( size_t _nNewCondIndex )
     183             :     {
     184           0 :         UpdateLocker aLockUpdates( *this );
     185             : 
     186             :         try
     187             :         {
     188           0 :             if ( _nNewCondIndex > (size_t)m_xCopy->getCount() )
     189           0 :                 throw IllegalArgumentException();
     190             : 
     191           0 :             Reference< XFormatCondition > xCond = m_xCopy->createFormatCondition();
     192           0 :             ::comphelper::copyProperties(m_xCopy.get(),xCond.get());
     193           0 :             m_xCopy->insertByIndex( _nNewCondIndex, makeAny( xCond ) );
     194             : 
     195           0 :             VclPtrInstance<Condition> pCon( m_pConditionPlayground, *this, m_rController );
     196           0 :             pCon->setCondition( xCond );
     197           0 :             pCon->reorderWithinParent(_nNewCondIndex);
     198           0 :             m_aConditions.insert( m_aConditions.begin() + _nNewCondIndex, pCon );
     199             :         }
     200           0 :         catch( const Exception& )
     201             :         {
     202             :             DBG_UNHANDLED_EXCEPTION();
     203             :         }
     204             : 
     205           0 :         impl_conditionCountChanged();
     206             : 
     207           0 :         impl_ensureConditionVisible( _nNewCondIndex );
     208           0 :     }
     209             : 
     210             : 
     211           0 :     void ConditionalFormattingDialog::impl_focusCondition( size_t _nCondIndex )
     212             :     {
     213             :         OSL_PRECOND( _nCondIndex < impl_getConditionCount(),
     214             :             "ConditionalFormattingDialog::impl_focusCondition: illegal index!" );
     215             : 
     216           0 :         impl_ensureConditionVisible( _nCondIndex );
     217           0 :         m_aConditions[ _nCondIndex ]->GrabFocus();
     218           0 :     }
     219             : 
     220             : 
     221           0 :     void ConditionalFormattingDialog::impl_deleteCondition_nothrow( size_t _nCondIndex )
     222             :     {
     223           0 :         UpdateLocker aLockUpdates( *this );
     224             : 
     225             :         OSL_PRECOND( _nCondIndex < impl_getConditionCount(),
     226             :             "ConditionalFormattingDialog::impl_deleteCondition_nothrow: illegal index!" );
     227             : 
     228           0 :         bool bLastCondition = ( impl_getConditionCount() == 1 );
     229             : 
     230           0 :         bool bSetNewFocus = false;
     231           0 :         size_t nNewFocusIndex( _nCondIndex );
     232             :         try
     233             :         {
     234           0 :             if ( !bLastCondition )
     235           0 :                 m_xCopy->removeByIndex( _nCondIndex );
     236             : 
     237           0 :             Conditions::iterator pos = m_aConditions.begin() + _nCondIndex;
     238           0 :             if ( bLastCondition )
     239             :             {
     240           0 :                 Reference< XFormatCondition > xFormatCondition( m_xCopy->getByIndex( 0 ), UNO_QUERY_THROW );
     241           0 :                 xFormatCondition->setFormula( OUString() );
     242           0 :                 (*pos)->setCondition( xFormatCondition );
     243             :             }
     244             :             else
     245             :             {
     246           0 :                 bSetNewFocus = (*pos)->HasChildPathFocus();
     247           0 :                 m_bDeletingCondition = true;
     248           0 :                 m_aConditions.erase( pos );
     249           0 :                 m_bDeletingCondition = false;
     250             :             }
     251             : 
     252           0 :             if ( bSetNewFocus )
     253             :             {
     254           0 :                 if ( nNewFocusIndex >= impl_getConditionCount() )
     255           0 :                     nNewFocusIndex = impl_getConditionCount() - 1;
     256             :             }
     257             :         }
     258           0 :         catch( const Exception& )
     259             :         {
     260             :             DBG_UNHANDLED_EXCEPTION();
     261             :         }
     262             : 
     263           0 :         impl_conditionCountChanged();
     264           0 :         if ( bSetNewFocus )
     265           0 :             impl_focusCondition( nNewFocusIndex );
     266           0 :     }
     267             : 
     268             : 
     269           0 :     void ConditionalFormattingDialog::impl_moveCondition_nothrow( size_t _nCondIndex, bool _bMoveUp )
     270             :     {
     271           0 :         size_t nOldConditionIndex( _nCondIndex );
     272           0 :         size_t nNewConditionIndex( _bMoveUp ? _nCondIndex - 1 : _nCondIndex + 1 );
     273             : 
     274             :         // do this in two steps, so we don't become inconsistent if any of the UNO actions fails
     275           0 :         Any aMovedCondition;
     276             :         Condition *pMovedCondition;
     277             :         try
     278             :         {
     279           0 :             aMovedCondition = m_xCopy->getByIndex( (sal_Int32)nOldConditionIndex );
     280           0 :             m_xCopy->removeByIndex( (sal_Int32)nOldConditionIndex );
     281             : 
     282           0 :             Conditions::iterator aRemovePos( m_aConditions.begin() + nOldConditionIndex );
     283           0 :             pMovedCondition = *aRemovePos;
     284           0 :             m_aConditions.erase( aRemovePos );
     285             :         }
     286           0 :         catch( const Exception& )
     287             :         {
     288             :             DBG_UNHANDLED_EXCEPTION();
     289           0 :             return;
     290             :         }
     291             : 
     292             :         try
     293             :         {
     294           0 :             m_xCopy->insertByIndex( (sal_Int32)nNewConditionIndex, aMovedCondition );
     295           0 :             m_aConditions.insert( m_aConditions.begin() + nNewConditionIndex, pMovedCondition );
     296             :         }
     297           0 :         catch( const Exception& )
     298             :         {
     299             :             DBG_UNHANDLED_EXCEPTION();
     300             :         }
     301             : 
     302             :         // at least the two swapped conditions need to know their new index
     303           0 :         impl_updateConditionIndicies();
     304             : 
     305             :         // re-layout all conditions
     306           0 :         impl_layoutConditions();
     307             : 
     308             :         // ensure the moved condition is visible
     309           0 :         impl_ensureConditionVisible( nNewConditionIndex );
     310             :     }
     311             : 
     312           0 :     IMPL_LINK( ConditionalFormattingDialog, OnScroll, ScrollBar*, /*_pNotInterestedIn*/ )
     313             :     {
     314           0 :         size_t nFirstCondIndex( impl_getFirstVisibleConditionIndex() );
     315           0 :         size_t nFocusCondIndex = impl_getFocusedConditionIndex( nFirstCondIndex );
     316             : 
     317           0 :         impl_layoutConditions();
     318             : 
     319           0 :         if ( nFocusCondIndex < nFirstCondIndex )
     320           0 :             impl_focusCondition( nFirstCondIndex );
     321           0 :         else if ( nFocusCondIndex >= nFirstCondIndex + MAX_CONDITIONS )
     322           0 :             impl_focusCondition( nFirstCondIndex + MAX_CONDITIONS - 1 );
     323             : 
     324           0 :         return 0;
     325             :     }
     326             : 
     327           0 :     void ConditionalFormattingDialog::impl_layoutConditions()
     328             :     {
     329           0 :         if (m_aConditions.empty())
     330           0 :             return;
     331           0 :         long nConditionHeight = m_aConditions[0]->get_preferred_size().Height();
     332           0 :         Point aConditionPos(0, -1 * nConditionHeight * impl_getFirstVisibleConditionIndex());
     333           0 :         m_pConditionPlayground->SetPosPixel(aConditionPos);
     334             :     }
     335             : 
     336           0 :     void ConditionalFormattingDialog::impl_layoutAll()
     337             :     {
     338             :         // condition's positions
     339           0 :         impl_layoutConditions();
     340             : 
     341             :         // scrollbar visibility
     342           0 :         if ( !impl_needScrollBar() )
     343             :             // normalize the position, so it can, in all situations, be used as top index
     344           0 :             m_pCondScroll->SetThumbPos( 0 );
     345           0 :     }
     346             : 
     347           0 :     void ConditionalFormattingDialog::impl_initializeConditions()
     348             :     {
     349             :         try
     350             :         {
     351           0 :             sal_Int32 nCount = m_xCopy->getCount();
     352           0 :             for ( sal_Int32 i = 0; i < nCount ; ++i )
     353             :             {
     354           0 :                 VclPtrInstance<Condition> pCon( m_pConditionPlayground, *this, m_rController );
     355           0 :                 Reference< XFormatCondition > xCond( m_xCopy->getByIndex(i), UNO_QUERY );
     356           0 :                 pCon->reorderWithinParent(i);
     357           0 :                 pCon->setCondition( xCond );
     358           0 :                 pCon->updateToolbar( xCond.get() );
     359           0 :                 m_aConditions.push_back( pCon );
     360           0 :             }
     361             :         }
     362           0 :         catch(Exception&)
     363             :         {
     364             :             OSL_FAIL("Can not access format condition!");
     365             :         }
     366             : 
     367           0 :         impl_conditionCountChanged();
     368           0 :     }
     369             : 
     370           0 :     void ConditionalFormattingDialog::applyCommand(size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color& rColor)
     371             :     {
     372             :         OSL_PRECOND( _nCommandId, "ConditionalFormattingDialog::applyCommand: illegal command id!" );
     373             :         try
     374             :         {
     375           0 :             Reference< XReportControlFormat > xReportControlFormat( m_xCopy->getByIndex( _nCondIndex ), UNO_QUERY_THROW );
     376             : 
     377           0 :             Sequence< PropertyValue > aArgs(3);
     378             : 
     379           0 :             aArgs[0].Name = REPORTCONTROLFORMAT;
     380           0 :             aArgs[0].Value <<= xReportControlFormat;
     381             : 
     382           0 :             aArgs[1].Name = CURRENT_WINDOW;
     383           0 :             aArgs[1].Value <<= VCLUnoHelper::GetInterface(this);
     384             : 
     385           0 :             aArgs[2].Name = PROPERTY_FONTCOLOR;
     386           0 :             aArgs[2].Value <<= (sal_uInt32)rColor.GetColor();
     387             : 
     388             :             // we use this way to create undo actions
     389           0 :             m_rController.executeUnChecked(_nCommandId,aArgs);
     390           0 :             m_aConditions[ _nCondIndex ]->updateToolbar(xReportControlFormat);
     391             :         }
     392           0 :         catch( Exception& )
     393             :         {
     394             :             DBG_UNHANDLED_EXCEPTION();
     395             :         }
     396           0 :     }
     397             : 
     398             : 
     399           0 :     void ConditionalFormattingDialog::moveConditionUp( size_t _nCondIndex )
     400             :     {
     401             :         OSL_PRECOND( _nCondIndex > 0, "ConditionalFormattingDialog::moveConditionUp: cannot move up the first condition!" );
     402           0 :         if ( _nCondIndex > 0 )
     403           0 :             impl_moveCondition_nothrow( _nCondIndex, true );
     404           0 :     }
     405             : 
     406             : 
     407           0 :     void ConditionalFormattingDialog::moveConditionDown( size_t _nCondIndex )
     408             :     {
     409             :         OSL_PRECOND( _nCondIndex < impl_getConditionCount(), "ConditionalFormattingDialog::moveConditionDown: cannot move down the last condition!" );
     410           0 :         if ( _nCondIndex < impl_getConditionCount() )
     411           0 :             impl_moveCondition_nothrow( _nCondIndex, false );
     412           0 :     }
     413             : 
     414             : 
     415           0 :     OUString ConditionalFormattingDialog::getDataField() const
     416             :     {
     417           0 :         OUString sDataField;
     418             :         try
     419             :         {
     420           0 :             sDataField = m_xFormatConditions->getDataField();
     421             :         }
     422           0 :         catch( const Exception& )
     423             :         {
     424             :             DBG_UNHANDLED_EXCEPTION();
     425             :         }
     426           0 :         return sDataField;
     427             :     }
     428             : 
     429             : 
     430           0 :     short ConditionalFormattingDialog::Execute()
     431             :     {
     432           0 :         short nRet = ModalDialog::Execute();
     433           0 :         if ( nRet == RET_OK )
     434             :         {
     435           0 :             const OUString sUndoAction( ModuleRes( RID_STR_UNDO_CONDITIONAL_FORMATTING ) );
     436           0 :             const UndoContext aUndoContext( m_rController.getUndoManager(), sUndoAction );
     437             :             try
     438             :             {
     439           0 :                 sal_Int32 j(0), i(0);;
     440           0 :                 for (   Conditions::const_iterator cond = m_aConditions.begin();
     441           0 :                         cond != m_aConditions.end();
     442             :                         ++cond, ++i
     443             :                     )
     444             :                 {
     445           0 :                     Reference< XFormatCondition > xCond( m_xCopy->getByIndex(i), UNO_QUERY_THROW );
     446           0 :                     (*cond)->fillFormatCondition( xCond );
     447             : 
     448           0 :                     if ( (*cond)->isEmpty() )
     449           0 :                         continue;
     450             : 
     451           0 :                     Reference< XFormatCondition > xNewCond;
     452           0 :                     bool bAppend = j >= m_xFormatConditions->getCount();
     453           0 :                     if ( bAppend )
     454             :                     {
     455           0 :                         xNewCond = m_xFormatConditions->createFormatCondition();
     456           0 :                         m_xFormatConditions->insertByIndex( i, makeAny( xNewCond ) );
     457             :                     }
     458             :                     else
     459           0 :                         xNewCond.set( m_xFormatConditions->getByIndex(j), UNO_QUERY );
     460           0 :                     ++j;
     461             : 
     462           0 :                     ::comphelper::copyProperties(xCond.get(),xNewCond.get());
     463           0 :                 }
     464             : 
     465           0 :                 for ( sal_Int32 k = m_xFormatConditions->getCount()-1; k >= j; --k )
     466           0 :                     m_xFormatConditions->removeByIndex(k);
     467             : 
     468           0 :                 ::comphelper::copyProperties( m_xCopy.get(), m_xFormatConditions.get() );
     469             :             }
     470           0 :             catch ( const Exception& )
     471             :             {
     472             :                 DBG_UNHANDLED_EXCEPTION();
     473           0 :                 nRet = RET_NO;
     474           0 :             }
     475             :         }
     476           0 :         return nRet;
     477             :     }
     478             : 
     479             : 
     480           0 :     bool ConditionalFormattingDialog::PreNotify( NotifyEvent& _rNEvt )
     481             :     {
     482           0 :         switch ( _rNEvt.GetType() )
     483             :         {
     484             :             case MouseNotifyEvent::KEYINPUT:
     485             :             {
     486           0 :                 const KeyEvent* pKeyEvent( _rNEvt.GetKeyEvent() );
     487           0 :                 const vcl::KeyCode& rKeyCode = pKeyEvent->GetKeyCode();
     488           0 :                 if ( rKeyCode.IsMod1() && rKeyCode.IsMod2() )
     489             :                 {
     490           0 :                     if ( rKeyCode.GetCode() == 0x0508 )
     491             :                     {
     492           0 :                         impl_deleteCondition_nothrow( impl_getFocusedConditionIndex( 0 ) );
     493           0 :                         return true;
     494             :                     }
     495           0 :                     if ( rKeyCode.GetCode() == 0x0507 ) // +
     496             :                     {
     497           0 :                         impl_addCondition_nothrow( impl_getFocusedConditionIndex( impl_getConditionCount() - 1 ) + 1 );
     498           0 :                         return true;
     499             :                     }
     500             :                 }
     501           0 :                 break;
     502             :             }
     503             :             case MouseNotifyEvent::GETFOCUS:
     504             :             {
     505           0 :                 if ( m_bDeletingCondition )
     506           0 :                     break;
     507             : 
     508           0 :                 const vcl::Window* pGetFocusWindow( _rNEvt.GetWindow() );
     509             : 
     510             :                 // determine whether the new focus window is part of an (currently invisible) condition
     511           0 :                 const vcl::Window* pConditionCandidate = pGetFocusWindow->GetParent();
     512           0 :                 const vcl::Window* pPlaygroundCandidate = pConditionCandidate ? pConditionCandidate->GetParent() : NULL;
     513           0 :                 while   (   ( pPlaygroundCandidate )
     514           0 :                         &&  ( pPlaygroundCandidate != this )
     515           0 :                         &&  ( pPlaygroundCandidate != m_pConditionPlayground )
     516             :                         )
     517             :                 {
     518           0 :                     pConditionCandidate = pConditionCandidate->GetParent();
     519           0 :                     pPlaygroundCandidate = pConditionCandidate ? pConditionCandidate->GetParent() : NULL;
     520             :                 }
     521           0 :                 if (pConditionCandidate && pPlaygroundCandidate == m_pConditionPlayground)
     522             :                 {
     523           0 :                     impl_ensureConditionVisible( dynamic_cast< const Condition& >( *pConditionCandidate ).getConditionIndex() );
     524             :                 }
     525           0 :                 break;
     526             :             }
     527             :             default:
     528           0 :                 break;
     529             :         }
     530             : 
     531           0 :         return ModalDialog::PreNotify( _rNEvt );
     532             :     }
     533             : 
     534             : 
     535           0 :     size_t ConditionalFormattingDialog::impl_getFirstVisibleConditionIndex() const
     536             :     {
     537           0 :         return (size_t)m_pCondScroll->GetThumbPos();
     538             :     }
     539             : 
     540             : 
     541           0 :     size_t ConditionalFormattingDialog::impl_getLastVisibleConditionIndex() const
     542             :     {
     543           0 :         return ::std::min( impl_getFirstVisibleConditionIndex() + MAX_CONDITIONS, impl_getConditionCount() ) - 1;
     544             :     }
     545             : 
     546             : 
     547           0 :     size_t ConditionalFormattingDialog::impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const
     548             :     {
     549           0 :         size_t nIndex( 0 );
     550           0 :         for (   Conditions::const_iterator cond = m_aConditions.begin();
     551           0 :                 cond != m_aConditions.end();
     552             :                 ++cond, ++nIndex
     553             :             )
     554             :         {
     555           0 :             if ( (*cond)->HasChildPathFocus() )
     556           0 :                 return nIndex;
     557             :         }
     558           0 :         return _nFallBackIfNone;
     559             :     }
     560             : 
     561             : 
     562           0 :     void ConditionalFormattingDialog::impl_updateScrollBarRange()
     563             :     {
     564           0 :         long nMax = ( impl_getConditionCount() > MAX_CONDITIONS ) ? impl_getConditionCount() - MAX_CONDITIONS + 1 : 0;
     565             : 
     566           0 :         m_pCondScroll->SetRangeMin( 0 );
     567           0 :         m_pCondScroll->SetRangeMax( nMax );
     568           0 :         m_pCondScroll->SetVisibleSize( 1 );
     569           0 :     }
     570             : 
     571             : 
     572           0 :     void ConditionalFormattingDialog::impl_scrollTo( size_t _nTopCondIndex )
     573             :     {
     574             :         OSL_PRECOND( _nTopCondIndex + MAX_CONDITIONS <= impl_getConditionCount(),
     575             :             "ConditionalFormattingDialog::impl_scrollTo: illegal index!" );
     576           0 :         m_pCondScroll->SetThumbPos( _nTopCondIndex );
     577           0 :         OnScroll( m_pCondScroll );
     578           0 :     }
     579             : 
     580             : 
     581           0 :     void ConditionalFormattingDialog::impl_ensureConditionVisible( size_t _nCondIndex )
     582             :     {
     583             :         OSL_PRECOND( _nCondIndex < impl_getConditionCount(),
     584             :             "ConditionalFormattingDialog::impl_ensureConditionVisible: illegal index!" );
     585             : 
     586           0 :         if ( _nCondIndex < impl_getFirstVisibleConditionIndex() )
     587           0 :             impl_scrollTo( _nCondIndex );
     588           0 :         else if ( _nCondIndex > impl_getLastVisibleConditionIndex() )
     589           0 :             impl_scrollTo( _nCondIndex - MAX_CONDITIONS + 1 );
     590           0 :     }
     591             : 
     592             : 
     593           3 : } // rptui
     594             : 
     595             : 
     596             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11