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