1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <progressmonitor.hxx>
22 #include <com/sun/star/awt/GradientStyle.hpp>
23 #include <com/sun/star/awt/RasterOperation.hpp>
24 #include <com/sun/star/awt/Gradient.hpp>
25 #include <com/sun/star/awt/XGraphics.hpp>
26 #include <com/sun/star/awt/PosSize.hpp>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <cppuhelper/typeprovider.hxx>
29 #include <cppuhelper/queryinterface.hxx>
30 #include <tools/debug.hxx>
33 #include <progressbar.hxx>
35 using namespace ::cppu
;
36 using namespace ::osl
;
37 using namespace ::com::sun::star::uno
;
38 using namespace ::com::sun::star::lang
;
39 using namespace ::com::sun::star::awt
;
44 namespace unocontrols
{
46 ProgressMonitor::ProgressMonitor( const css::uno::Reference
< XComponentContext
>& rxContext
)
47 : BaseContainerControl ( rxContext
)
49 // It's not allowed to work with member in this method (refcounter !!!)
50 // But with a HACK (++refcount) its "OK" :-(
53 // Create instances for fixedtext, button and progress ...
55 m_xTopic_Top
.set ( rxContext
->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME
, rxContext
), UNO_QUERY
);
56 m_xText_Top
.set ( rxContext
->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME
, rxContext
), UNO_QUERY
);
57 m_xTopic_Bottom
.set( rxContext
->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME
, rxContext
), UNO_QUERY
);
58 m_xText_Bottom
.set ( rxContext
->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME
, rxContext
), UNO_QUERY
);
59 m_xButton
.set ( rxContext
->getServiceManager()->createInstanceWithContext( BUTTON_SERVICENAME
, rxContext
), UNO_QUERY
);
60 m_xProgressBar
= new ProgressBar(rxContext
);
62 // ... cast controls to Reference< XControl > (for "setModel"!) ...
63 css::uno::Reference
< XControl
> xRef_Topic_Top ( m_xTopic_Top
, UNO_QUERY
);
64 css::uno::Reference
< XControl
> xRef_Text_Top ( m_xText_Top
, UNO_QUERY
);
65 css::uno::Reference
< XControl
> xRef_Topic_Bottom ( m_xTopic_Bottom
, UNO_QUERY
);
66 css::uno::Reference
< XControl
> xRef_Text_Bottom ( m_xText_Bottom
, UNO_QUERY
);
67 css::uno::Reference
< XControl
> xRef_Button ( m_xButton
, UNO_QUERY
);
70 xRef_Topic_Top
->setModel ( css::uno::Reference
< XControlModel
> ( rxContext
->getServiceManager()->createInstanceWithContext( FIXEDTEXT_MODELNAME
, rxContext
), UNO_QUERY
) );
71 xRef_Text_Top
->setModel ( css::uno::Reference
< XControlModel
> ( rxContext
->getServiceManager()->createInstanceWithContext( FIXEDTEXT_MODELNAME
, rxContext
), UNO_QUERY
) );
72 xRef_Topic_Bottom
->setModel ( css::uno::Reference
< XControlModel
> ( rxContext
->getServiceManager()->createInstanceWithContext( FIXEDTEXT_MODELNAME
, rxContext
), UNO_QUERY
) );
73 xRef_Text_Bottom
->setModel ( css::uno::Reference
< XControlModel
> ( rxContext
->getServiceManager()->createInstanceWithContext( FIXEDTEXT_MODELNAME
, rxContext
), UNO_QUERY
) );
74 xRef_Button
->setModel ( css::uno::Reference
< XControlModel
> ( rxContext
->getServiceManager()->createInstanceWithContext( BUTTON_MODELNAME
, rxContext
), UNO_QUERY
) );
75 // ProgressBar has no model !!!
77 // ... and add controls to basecontainercontrol!
78 addControl ( CONTROLNAME_TEXT
, xRef_Topic_Top
);
79 addControl ( CONTROLNAME_TEXT
, xRef_Text_Top
);
80 addControl ( CONTROLNAME_TEXT
, xRef_Topic_Bottom
);
81 addControl ( CONTROLNAME_TEXT
, xRef_Text_Bottom
);
82 addControl ( CONTROLNAME_BUTTON
, xRef_Button
);
83 addControl ( CONTROLNAME_PROGRESSBAR
, m_xProgressBar
.get() );
85 // FixedText make it automatically visible by himself ... but not the progressbar !!!
86 // it must be set explicitly
87 m_xProgressBar
->setVisible( true );
89 // Reset to defaults !!!
90 // (progressbar take automatically its own defaults)
91 m_xButton
->setLabel ( DEFAULT_BUTTONLABEL
);
92 m_xTopic_Top
->setText ( PROGRESSMONITOR_DEFAULT_TOPIC
);
93 m_xText_Top
->setText ( PROGRESSMONITOR_DEFAULT_TEXT
);
94 m_xTopic_Bottom
->setText ( PROGRESSMONITOR_DEFAULT_TOPIC
);
95 m_xText_Bottom
->setText ( PROGRESSMONITOR_DEFAULT_TEXT
);
100 ProgressMonitor::~ProgressMonitor()
106 Any SAL_CALL
ProgressMonitor::queryInterface( const Type
& rType
)
109 // Don't use mutex or guard in this method!!! Is a method of XInterface.
111 css::uno::Reference
< XInterface
> xDel
= BaseContainerControl::impl_getDelegator();
114 // If an delegator exist, forward question to his queryInterface.
115 // Delegator will ask his own queryAggregation!
116 aReturn
= xDel
->queryInterface( rType
);
120 // If an delegator unknown, forward question to own queryAggregation.
121 aReturn
= queryAggregation( rType
);
128 void SAL_CALL
ProgressMonitor::acquire() throw()
131 // Don't use mutex or guard in this method!!! Is a method of XInterface.
133 // Forward to baseclass
134 BaseControl::acquire();
138 void SAL_CALL
ProgressMonitor::release() throw()
141 // Don't use mutex or guard in this method!!! Is a method of XInterface.
143 // Forward to baseclass
144 BaseControl::release();
148 Sequence
< Type
> SAL_CALL
ProgressMonitor::getTypes()
150 static OTypeCollection
ourTypeCollection(
151 cppu::UnoType
<XLayoutConstrains
>::get(),
152 cppu::UnoType
<XButton
>::get(),
153 cppu::UnoType
<XProgressMonitor
>::get(),
154 BaseContainerControl::getTypes() );
156 return ourTypeCollection
.getTypes();
160 Any SAL_CALL
ProgressMonitor::queryAggregation( const Type
& aType
)
162 // Ask for my own supported interfaces ...
163 // Attention: XTypeProvider and XInterface are supported by OComponentHelper!
164 Any
aReturn ( ::cppu::queryInterface( aType
,
165 static_cast< XLayoutConstrains
* > ( this ) ,
166 static_cast< XButton
* > ( this ) ,
167 static_cast< XProgressMonitor
* > ( this )
171 // If searched interface not supported by this class ...
172 if ( !aReturn
.hasValue() )
174 // ... ask baseclasses.
175 aReturn
= BaseControl::queryAggregation( aType
);
182 void SAL_CALL
ProgressMonitor::addText(
183 const OUString
& rTopic
,
184 const OUString
& rText
,
185 sal_Bool bbeforeProgress
188 // Safe impossible cases
189 // Check valid call of this method.
190 DBG_ASSERT ( impl_debug_checkParameter ( rTopic
, rText
), "ProgressMonitor::addText()\nCall without valid parameters!\n");
191 DBG_ASSERT ( !(impl_searchTopic ( rTopic
, bbeforeProgress
) != nullptr ), "ProgressMonitor::addText()\nThe text already exist.\n" );
193 // Do nothing (in Release), if topic already exist.
194 if ( impl_searchTopic ( rTopic
, bbeforeProgress
) != nullptr )
199 // Else ... take memory for new item ...
200 IMPL_TextlistItem
* pTextItem
= new IMPL_TextlistItem
;
203 pTextItem
->sTopic
= rTopic
;
204 pTextItem
->sText
= rText
;
206 // Ready for multithreading
207 MutexGuard
aGuard ( m_aMutex
);
209 // ... and insert it in right list.
210 if ( bbeforeProgress
)
212 maTextlist_Top
.push_back( pTextItem
);
216 maTextlist_Bottom
.push_back( pTextItem
);
220 impl_rebuildFixedText ();
221 impl_recalcLayout ();
225 void SAL_CALL
ProgressMonitor::removeText ( const OUString
& rTopic
, sal_Bool bbeforeProgress
)
227 // Safe impossible cases
228 // Check valid call of this method.
229 DBG_ASSERT ( impl_debug_checkParameter ( rTopic
), "ProgressMonitor::removeText()\nCall without valid parameters!" );
231 // Search the topic ...
232 IMPL_TextlistItem
* pSearchItem
= impl_searchTopic ( rTopic
, bbeforeProgress
);
234 if ( pSearchItem
!= nullptr )
236 // Ready for multithreading
237 MutexGuard
aGuard ( m_aMutex
);
239 // ... delete item from right list ...
240 if ( bbeforeProgress
)
242 vector
< IMPL_TextlistItem
* >::iterator
243 itr
= find( maTextlist_Top
.begin(), maTextlist_Top
.end(), pSearchItem
);
244 if (itr
!= maTextlist_Top
.end())
245 maTextlist_Top
.erase(itr
);
249 vector
< IMPL_TextlistItem
* >::iterator
250 itr
= find( maTextlist_Bottom
.begin(), maTextlist_Bottom
.end(), pSearchItem
);
251 if (itr
!= maTextlist_Bottom
.end())
252 maTextlist_Bottom
.erase(itr
);
257 // ... and update window.
258 impl_rebuildFixedText ();
259 impl_recalcLayout ();
264 void SAL_CALL
ProgressMonitor::updateText (
265 const OUString
& rTopic
,
266 const OUString
& rText
,
267 sal_Bool bbeforeProgress
270 // Safe impossible cases
271 // Check valid call of this method.
272 DBG_ASSERT ( impl_debug_checkParameter ( rTopic
, rText
), "ProgressMonitor::updateText()\nCall without valid parameters!\n" );
275 IMPL_TextlistItem
* pSearchItem
= impl_searchTopic ( rTopic
, bbeforeProgress
);
277 if ( pSearchItem
!= nullptr )
279 // Ready for multithreading
280 MutexGuard
aGuard ( m_aMutex
);
282 // ... update text ...
283 pSearchItem
->sText
= rText
;
285 // ... and update window.
286 impl_rebuildFixedText ();
287 impl_recalcLayout ();
292 void SAL_CALL
ProgressMonitor::setForegroundColor ( sal_Int32 nColor
)
294 // Ready for multithreading
295 MutexGuard
aGuard ( m_aMutex
);
297 m_xProgressBar
->setForegroundColor ( nColor
);
301 void SAL_CALL
ProgressMonitor::setBackgroundColor ( sal_Int32 nColor
)
303 // Ready for multithreading
304 MutexGuard
aGuard ( m_aMutex
);
306 m_xProgressBar
->setBackgroundColor ( nColor
);
310 void SAL_CALL
ProgressMonitor::setValue ( sal_Int32 nValue
)
312 // Ready for multithreading
313 MutexGuard
aGuard ( m_aMutex
);
315 m_xProgressBar
->setValue ( nValue
);
319 void SAL_CALL
ProgressMonitor::setRange ( sal_Int32 nMin
, sal_Int32 nMax
)
321 // Ready for multithreading
322 MutexGuard
aGuard ( m_aMutex
);
324 m_xProgressBar
->setRange ( nMin
, nMax
);
328 sal_Int32 SAL_CALL
ProgressMonitor::getValue ()
330 // Ready for multithreading
331 MutexGuard
aGuard ( m_aMutex
);
333 return m_xProgressBar
->getValue ();
337 void SAL_CALL
ProgressMonitor::addActionListener ( const css::uno::Reference
< XActionListener
> & rListener
)
339 // Ready for multithreading
340 MutexGuard
aGuard ( m_aMutex
);
342 if ( m_xButton
.is () )
344 m_xButton
->addActionListener ( rListener
);
349 void SAL_CALL
ProgressMonitor::removeActionListener ( const css::uno::Reference
< XActionListener
> & rListener
)
351 // Ready for multithreading
352 MutexGuard
aGuard ( m_aMutex
);
354 if ( m_xButton
.is () )
356 m_xButton
->removeActionListener ( rListener
);
361 void SAL_CALL
ProgressMonitor::setLabel ( const OUString
& rLabel
)
363 // Ready for multithreading
364 MutexGuard
aGuard ( m_aMutex
);
366 if ( m_xButton
.is () )
368 m_xButton
->setLabel ( rLabel
);
373 void SAL_CALL
ProgressMonitor::setActionCommand ( const OUString
& rCommand
)
375 // Ready for multithreading
376 MutexGuard
aGuard ( m_aMutex
);
378 if ( m_xButton
.is () )
380 m_xButton
->setActionCommand ( rCommand
);
385 Size SAL_CALL
ProgressMonitor::getMinimumSize ()
387 return Size (PROGRESSMONITOR_DEFAULT_WIDTH
, PROGRESSMONITOR_DEFAULT_HEIGHT
);
391 Size SAL_CALL
ProgressMonitor::getPreferredSize ()
393 // Ready for multithreading
394 ClearableMutexGuard
aGuard ( m_aMutex
);
396 // get information about required place of child controls
397 css::uno::Reference
< XLayoutConstrains
> xTopicLayout_Top ( m_xTopic_Top
, UNO_QUERY
);
398 css::uno::Reference
< XLayoutConstrains
> xTopicLayout_Bottom ( m_xTopic_Bottom
, UNO_QUERY
);
399 css::uno::Reference
< XLayoutConstrains
> xButtonLayout ( m_xButton
, UNO_QUERY
);
401 Size aTopicSize_Top
= xTopicLayout_Top
->getPreferredSize ();
402 Size aTopicSize_Bottom
= xTopicLayout_Bottom
->getPreferredSize ();
403 Size aButtonSize
= xButtonLayout
->getPreferredSize ();
404 Rectangle aTempRectangle
= m_xProgressBar
->getPosSize();
405 Size
aProgressBarSize( aTempRectangle
.Width
, aTempRectangle
.Height
);
409 // calc preferred size of progressmonitor
410 sal_Int32 nWidth
= 3 * PROGRESSMONITOR_FREEBORDER
;
411 nWidth
+= aProgressBarSize
.Width
;
413 sal_Int32 nHeight
= 6 * PROGRESSMONITOR_FREEBORDER
;
414 nHeight
+= aTopicSize_Top
.Height
;
415 nHeight
+= aProgressBarSize
.Height
;
416 nHeight
+= aTopicSize_Bottom
.Height
;
417 nHeight
+= 2; // 1 for black line, 1 for white line = 3D-Line!
418 nHeight
+= aButtonSize
.Height
;
421 if ( nWidth
< PROGRESSMONITOR_DEFAULT_WIDTH
)
423 nWidth
= PROGRESSMONITOR_DEFAULT_WIDTH
;
425 if ( nHeight
< PROGRESSMONITOR_DEFAULT_HEIGHT
)
427 nHeight
= PROGRESSMONITOR_DEFAULT_HEIGHT
;
431 return Size ( nWidth
, nHeight
);
435 Size SAL_CALL
ProgressMonitor::calcAdjustedSize ( const Size
& /*rNewSize*/ )
437 return getPreferredSize ();
441 void SAL_CALL
ProgressMonitor::createPeer ( const css::uno::Reference
< XToolkit
> & rToolkit
, const css::uno::Reference
< XWindowPeer
> & rParent
)
445 BaseContainerControl::createPeer ( rToolkit
, rParent
);
447 // If user forget to call "setPosSize()", we have still a correct size.
448 // And a "MinimumSize" IS A "MinimumSize"!
449 // We change not the position of control at this point.
450 Size aDefaultSize
= getMinimumSize ();
451 setPosSize ( 0, 0, aDefaultSize
.Width
, aDefaultSize
.Height
, PosSize::SIZE
);
456 sal_Bool SAL_CALL
ProgressMonitor::setModel ( const css::uno::Reference
< XControlModel
> & /*rModel*/ )
463 css::uno::Reference
< XControlModel
> SAL_CALL
ProgressMonitor::getModel ()
466 // return (XControlModel*)this;
467 return css::uno::Reference
< XControlModel
> ();
471 void SAL_CALL
ProgressMonitor::dispose ()
473 // Ready for multithreading
474 MutexGuard
aGuard ( m_aMutex
);
476 // "removeControl()" control the state of a reference
477 css::uno::Reference
< XControl
> xRef_Topic_Top ( m_xTopic_Top
, UNO_QUERY
);
478 css::uno::Reference
< XControl
> xRef_Text_Top ( m_xText_Top
, UNO_QUERY
);
479 css::uno::Reference
< XControl
> xRef_Topic_Bottom ( m_xTopic_Bottom
, UNO_QUERY
);
480 css::uno::Reference
< XControl
> xRef_Text_Bottom ( m_xText_Bottom
, UNO_QUERY
);
481 css::uno::Reference
< XControl
> xRef_Button ( m_xButton
, UNO_QUERY
);
483 removeControl ( xRef_Topic_Top
);
484 removeControl ( xRef_Text_Top
);
485 removeControl ( xRef_Topic_Bottom
);
486 removeControl ( xRef_Text_Bottom
);
487 removeControl ( xRef_Button
);
488 removeControl ( m_xProgressBar
.get() );
490 // do'nt use "...->clear ()" or "... = XFixedText ()"
491 // when other hold a reference at this object !!!
492 xRef_Topic_Top
->dispose ();
493 xRef_Text_Top
->dispose ();
494 xRef_Topic_Bottom
->dispose ();
495 xRef_Text_Bottom
->dispose ();
496 xRef_Button
->dispose ();
497 m_xProgressBar
->dispose();
499 BaseContainerControl::dispose ();
503 void SAL_CALL
ProgressMonitor::setPosSize ( sal_Int32 nX
, sal_Int32 nY
, sal_Int32 nWidth
, sal_Int32 nHeight
, sal_Int16 nFlags
)
505 Rectangle aBasePosSize
= getPosSize ();
506 BaseContainerControl::setPosSize (nX
, nY
, nWidth
, nHeight
, nFlags
);
508 // if position or size changed
510 ( nWidth
!= aBasePosSize
.Width
) ||
511 ( nHeight
!= aBasePosSize
.Height
)
514 // calc new layout for controls
515 impl_recalcLayout ();
516 // clear background (!)
517 // [Children were repainted in "recalcLayout" by setPosSize() automatically!]
518 getPeer()->invalidate(2);
519 // and repaint the control
520 impl_paint ( 0, 0, impl_getGraphicsPeer() );
524 // impl but public method to register service
525 const Sequence
< OUString
> ProgressMonitor::impl_getStaticSupportedServiceNames()
527 return css::uno::Sequence
<OUString
>();
530 // impl but public method to register service
531 const OUString
ProgressMonitor::impl_getStaticImplementationName()
533 return OUString("stardiv.UnoControls.ProgressMonitor");
537 void ProgressMonitor::impl_paint ( sal_Int32 nX
, sal_Int32 nY
, const css::uno::Reference
< XGraphics
> & rGraphics
)
541 // Ready for multithreading
542 MutexGuard
aGuard ( m_aMutex
);
544 // paint shadowed border around the progressmonitor
545 rGraphics
->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW
);
546 rGraphics
->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY
);
547 rGraphics
->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX
, impl_getHeight()-1 );
549 rGraphics
->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT
);
550 rGraphics
->drawLine ( nX
, nY
, impl_getWidth(), nY
);
551 rGraphics
->drawLine ( nX
, nY
, nX
, impl_getHeight() );
554 rGraphics
->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW
);
555 rGraphics
->drawLine ( m_a3DLine
.X
, m_a3DLine
.Y
, m_a3DLine
.X
+m_a3DLine
.Width
, m_a3DLine
.Y
);
557 rGraphics
->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT
);
558 rGraphics
->drawLine ( m_a3DLine
.X
, m_a3DLine
.Y
+1, m_a3DLine
.X
+m_a3DLine
.Width
, m_a3DLine
.Y
+1 );
563 void ProgressMonitor::impl_recalcLayout ()
567 sal_Int32 nWidth_Button
;
568 sal_Int32 nHeight_Button
;
570 sal_Int32 nX_ProgressBar
;
571 sal_Int32 nY_ProgressBar
;
572 sal_Int32 nWidth_ProgressBar
;
573 sal_Int32 nHeight_ProgressBar
;
575 sal_Int32 nX_Text_Top
;
576 sal_Int32 nY_Text_Top
;
577 sal_Int32 nWidth_Text_Top
;
578 sal_Int32 nHeight_Text_Top
;
580 sal_Int32 nX_Topic_Top
;
581 sal_Int32 nY_Topic_Top
;
582 sal_Int32 nWidth_Topic_Top
;
583 sal_Int32 nHeight_Topic_Top
;
585 sal_Int32 nX_Text_Bottom
;
586 sal_Int32 nY_Text_Bottom
;
587 sal_Int32 nWidth_Text_Bottom
;
588 sal_Int32 nHeight_Text_Bottom
;
590 sal_Int32 nX_Topic_Bottom
;
591 sal_Int32 nY_Topic_Bottom
;
592 sal_Int32 nWidth_Topic_Bottom
;
593 sal_Int32 nHeight_Topic_Bottom
;
595 // Ready for multithreading
596 MutexGuard
aGuard ( m_aMutex
);
598 // get information about required place of child controls
599 css::uno::Reference
< XLayoutConstrains
> xTopicLayout_Top ( m_xTopic_Top
, UNO_QUERY
);
600 css::uno::Reference
< XLayoutConstrains
> xTextLayout_Top ( m_xText_Top
, UNO_QUERY
);
601 css::uno::Reference
< XLayoutConstrains
> xTopicLayout_Bottom ( m_xTopic_Bottom
, UNO_QUERY
);
602 css::uno::Reference
< XLayoutConstrains
> xTextLayout_Bottom ( m_xText_Bottom
, UNO_QUERY
);
603 css::uno::Reference
< XLayoutConstrains
> xButtonLayout ( m_xButton
, UNO_QUERY
);
605 Size aTopicSize_Top
= xTopicLayout_Top
->getPreferredSize ();
606 Size aTextSize_Top
= xTextLayout_Top
->getPreferredSize ();
607 Size aTopicSize_Bottom
= xTopicLayout_Bottom
->getPreferredSize ();
608 Size aTextSize_Bottom
= xTextLayout_Bottom
->getPreferredSize ();
609 Size aButtonSize
= xButtonLayout
->getPreferredSize ();
611 // calc position and size of child controls
612 // Button has preferred size!
613 nWidth_Button
= aButtonSize
.Width
;
614 nHeight_Button
= aButtonSize
.Height
;
616 // Left column before progressbar has preferred size and fixed position.
617 // But "Width" is oriented on left column below progressbar to!!! "max(...)"
618 nX_Topic_Top
= PROGRESSMONITOR_FREEBORDER
;
619 nY_Topic_Top
= PROGRESSMONITOR_FREEBORDER
;
620 nWidth_Topic_Top
= std::max( aTopicSize_Top
.Width
, aTopicSize_Bottom
.Width
);
621 nHeight_Topic_Top
= aTopicSize_Top
.Height
;
623 // Right column before progressbar has relative position to left column ...
624 // ... and a size as rest of dialog size!
625 nX_Text_Top
= nX_Topic_Top
+nWidth_Topic_Top
+PROGRESSMONITOR_FREEBORDER
;
626 nY_Text_Top
= nY_Topic_Top
;
627 nWidth_Text_Top
= std::max ( aTextSize_Top
.Width
, aTextSize_Bottom
.Width
);
628 // Fix size of this column to minimum!
629 sal_Int32 nSummaryWidth
= nWidth_Text_Top
+nWidth_Topic_Top
+(3*PROGRESSMONITOR_FREEBORDER
);
630 if ( nSummaryWidth
< PROGRESSMONITOR_DEFAULT_WIDTH
)
631 nWidth_Text_Top
= PROGRESSMONITOR_DEFAULT_WIDTH
-nWidth_Topic_Top
-(3*PROGRESSMONITOR_FREEBORDER
);
632 // Fix size of column to maximum!
633 if ( nSummaryWidth
> impl_getWidth() )
634 nWidth_Text_Top
= impl_getWidth()-nWidth_Topic_Top
-(3*PROGRESSMONITOR_FREEBORDER
);
635 nHeight_Text_Top
= nHeight_Topic_Top
;
637 // Position of progressbar is relative to columns before.
638 // Progressbar.Width = Dialog.Width !!!
639 // Progressbar.Height = Button.Height
640 nX_ProgressBar
= nX_Topic_Top
;
641 nY_ProgressBar
= nY_Topic_Top
+nHeight_Topic_Top
+PROGRESSMONITOR_FREEBORDER
;
642 nWidth_ProgressBar
= PROGRESSMONITOR_FREEBORDER
+nWidth_Topic_Top
+nWidth_Text_Top
;
643 nHeight_ProgressBar
= nHeight_Button
;
645 // Oriented by left column before progressbar.
646 nX_Topic_Bottom
= nX_Topic_Top
;
647 nY_Topic_Bottom
= nY_ProgressBar
+nHeight_ProgressBar
+PROGRESSMONITOR_FREEBORDER
;
648 nWidth_Topic_Bottom
= nWidth_Topic_Top
;
649 nHeight_Topic_Bottom
= aTopicSize_Bottom
.Height
;
651 // Oriented by right column before progressbar.
652 nX_Text_Bottom
= nX_Topic_Bottom
+nWidth_Topic_Bottom
+PROGRESSMONITOR_FREEBORDER
;
653 nY_Text_Bottom
= nY_Topic_Bottom
;
654 nWidth_Text_Bottom
= nWidth_Text_Top
;
655 nHeight_Text_Bottom
= nHeight_Topic_Bottom
;
657 // Oriented by progressbar.
658 nX_Button
= nX_ProgressBar
+nWidth_ProgressBar
-nWidth_Button
;
659 nY_Button
= nY_Topic_Bottom
+nHeight_Topic_Bottom
+PROGRESSMONITOR_FREEBORDER
;
661 // Calc offsets to center controls
665 nDx
= ( (2*PROGRESSMONITOR_FREEBORDER
)+nWidth_ProgressBar
);
666 nDy
= ( (6*PROGRESSMONITOR_FREEBORDER
)+nHeight_Topic_Top
+nHeight_ProgressBar
+nHeight_Topic_Bottom
+2+nHeight_Button
);
668 // At this point use original dialog size to center controls!
669 nDx
= (impl_getWidth ()/2)-(nDx
/2);
670 nDy
= (impl_getHeight()/2)-(nDy
/2);
681 // Set new position and size on all controls
682 css::uno::Reference
< XWindow
> xRef_Topic_Top ( m_xTopic_Top
, UNO_QUERY
);
683 css::uno::Reference
< XWindow
> xRef_Text_Top ( m_xText_Top
, UNO_QUERY
);
684 css::uno::Reference
< XWindow
> xRef_Topic_Bottom ( m_xTopic_Bottom
, UNO_QUERY
);
685 css::uno::Reference
< XWindow
> xRef_Text_Bottom ( m_xText_Bottom
, UNO_QUERY
);
686 css::uno::Reference
< XWindow
> xRef_Button ( m_xButton
, UNO_QUERY
);
688 xRef_Topic_Top
->setPosSize ( nDx
+nX_Topic_Top
, nDy
+nY_Topic_Top
, nWidth_Topic_Top
, nHeight_Topic_Top
, 15 );
689 xRef_Text_Top
->setPosSize ( nDx
+nX_Text_Top
, nDy
+nY_Text_Top
, nWidth_Text_Top
, nHeight_Text_Top
, 15 );
690 xRef_Topic_Bottom
->setPosSize ( nDx
+nX_Topic_Bottom
, nDy
+nY_Topic_Bottom
, nWidth_Topic_Bottom
, nHeight_Topic_Bottom
, 15 );
691 xRef_Text_Bottom
->setPosSize ( nDx
+nX_Text_Bottom
, nDy
+nY_Text_Bottom
, nWidth_Text_Bottom
, nHeight_Text_Bottom
, 15 );
692 xRef_Button
->setPosSize ( nDx
+nX_Button
, nDy
+nY_Button
, nWidth_Button
, nHeight_Button
, 15 );
693 m_xProgressBar
->setPosSize( nDx
+nX_ProgressBar
, nDy
+nY_ProgressBar
, nWidth_ProgressBar
, nHeight_ProgressBar
, 15 );
695 m_a3DLine
.X
= nDx
+nX_Topic_Top
;
696 m_a3DLine
.Y
= nDy
+nY_Topic_Bottom
+nHeight_Topic_Bottom
+(PROGRESSMONITOR_FREEBORDER
/2);
697 m_a3DLine
.Width
= nWidth_ProgressBar
;
698 m_a3DLine
.Height
= nHeight_ProgressBar
;
700 // All childcontrols make an implicit repaint in setPosSize()!
701 // Make it also for this 3D-line ...
702 css::uno::Reference
< XGraphics
> xGraphics
= impl_getGraphicsPeer ();
704 xGraphics
->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW
);
705 xGraphics
->drawLine ( m_a3DLine
.X
, m_a3DLine
.Y
, m_a3DLine
.X
+m_a3DLine
.Width
, m_a3DLine
.Y
);
707 xGraphics
->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT
);
708 xGraphics
->drawLine ( m_a3DLine
.X
, m_a3DLine
.Y
+1, m_a3DLine
.X
+m_a3DLine
.Width
, m_a3DLine
.Y
+1 );
712 void ProgressMonitor::impl_rebuildFixedText ()
714 // Ready for multithreading
715 MutexGuard
aGuard ( m_aMutex
);
717 // Rebuild fixedtext before progress
719 // Rebuild left site of text
720 if (m_xTopic_Top
.is())
722 OUString aCollectString
;
724 // Collect all topics from list and format text.
725 // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
726 for (IMPL_TextlistItem
* pSearchItem
: maTextlist_Top
)
728 aCollectString
+= pSearchItem
->sTopic
+ "\n";
731 m_xTopic_Top
->setText ( aCollectString
);
734 // Rebuild right site of text
735 if (m_xText_Top
.is())
737 OUString aCollectString
;
739 // Collect all topics from list and format text.
740 // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
741 for (IMPL_TextlistItem
* pSearchItem
: maTextlist_Top
)
743 aCollectString
+= pSearchItem
->sText
+ "\n";
746 m_xText_Top
->setText ( aCollectString
);
749 // Rebuild fixedtext below progress
751 // Rebuild left site of text
752 if (m_xTopic_Bottom
.is())
754 OUString aCollectString
;
756 // Collect all topics from list and format text.
757 // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
758 for (IMPL_TextlistItem
* pSearchItem
: maTextlist_Bottom
)
760 aCollectString
+= pSearchItem
->sTopic
+ "\n";
763 m_xTopic_Bottom
->setText ( aCollectString
);
766 // Rebuild right site of text
767 if (m_xText_Bottom
.is())
769 OUString aCollectString
;
771 // Collect all topics from list and format text.
772 // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
773 for (IMPL_TextlistItem
* pSearchItem
: maTextlist_Bottom
)
775 aCollectString
+= pSearchItem
->sText
+ "\n";
778 m_xText_Bottom
->setText ( aCollectString
);
783 void ProgressMonitor::impl_cleanMemory ()
785 // Ready for multithreading
786 MutexGuard
aGuard ( m_aMutex
);
788 // Delete all of lists.
790 for (IMPL_TextlistItem
* pSearchItem
: maTextlist_Top
)
794 maTextlist_Top
.clear();
796 for (IMPL_TextlistItem
* pSearchItem
: maTextlist_Bottom
)
800 maTextlist_Bottom
.clear();
804 IMPL_TextlistItem
* ProgressMonitor::impl_searchTopic ( const OUString
& rTopic
, bool bbeforeProgress
)
806 // Get right textlist for following operations.
807 ::std::vector
< IMPL_TextlistItem
* >* pTextList
;
809 // Ready for multithreading
810 ClearableMutexGuard
aGuard ( m_aMutex
);
812 if ( bbeforeProgress
)
814 pTextList
= &maTextlist_Top
;
818 pTextList
= &maTextlist_Bottom
;
824 // Search the topic in textlist.
825 size_t nPosition
= 0;
826 size_t nCount
= pTextList
->size();
828 for ( nPosition
= 0; nPosition
< nCount
; ++nPosition
)
830 IMPL_TextlistItem
* pSearchItem
= pTextList
->at( nPosition
);
832 if ( pSearchItem
->sTopic
== rTopic
)
834 // We have found this topic... return a valid pointer.
839 // We haven't found this topic... return a nonvalid pointer.
845 // addText, updateText
846 bool ProgressMonitor::impl_debug_checkParameter (
847 const OUString
& rTopic
,
848 const OUString
& rText
850 if ( rTopic
.isEmpty() ) return false; // ""
852 if ( rText
.isEmpty() ) return false; // ""
854 // Parameter OK ... return true.
859 bool ProgressMonitor::impl_debug_checkParameter ( const OUString
& rTopic
)
861 if ( rTopic
.isEmpty() ) return false; // ""
863 // Parameter OK ... return true.
867 } // namespace unocontrols
869 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */