LCOV - code coverage report
Current view: top level - UnoControls/source/controls - progressmonitor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 380 0.0 %
Date: 2012-08-25 Functions: 0 35 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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 "progressmonitor.hxx"
      21                 :            : 
      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 <cppuhelper/typeprovider.hxx>
      28                 :            : #include <tools/debug.hxx>
      29                 :            : #include <tools/solar.h>
      30                 :            : #include <algorithm>
      31                 :            : 
      32                 :            : #include "progressbar.hxx"
      33                 :            : 
      34                 :            : using namespace ::cppu                  ;
      35                 :            : using namespace ::osl                   ;
      36                 :            : using namespace ::rtl                   ;
      37                 :            : using namespace ::com::sun::star::uno   ;
      38                 :            : using namespace ::com::sun::star::lang  ;
      39                 :            : using namespace ::com::sun::star::awt   ;
      40                 :            : 
      41                 :            : using ::std::vector;
      42                 :            : using ::std::find;
      43                 :            : 
      44                 :            : namespace unocontrols{
      45                 :            : 
      46                 :            : //____________________________________________________________________________________________________________
      47                 :            : //  construct/destruct
      48                 :            : //____________________________________________________________________________________________________________
      49                 :            : 
      50                 :          0 : ProgressMonitor::ProgressMonitor( const Reference< XMultiServiceFactory >& xFactory )
      51                 :          0 :     : BaseContainerControl  ( xFactory  )
      52                 :            : {
      53                 :            :     // Its not allowed to work with member in this method (refcounter !!!)
      54                 :            :     // But with a HACK (++refcount) its "OK" :-(
      55                 :          0 :     ++m_refCount ;
      56                 :            : 
      57                 :            :     // Create instances for fixedtext, button and progress ...
      58                 :          0 :     m_xTopic_Top    = Reference< XFixedText >   ( xFactory->createInstance ( FIXEDTEXT_SERVICENAME ), UNO_QUERY ) ;
      59                 :          0 :     m_xText_Top     = Reference< XFixedText >   ( xFactory->createInstance ( FIXEDTEXT_SERVICENAME ), UNO_QUERY ) ;
      60                 :          0 :     m_xTopic_Bottom = Reference< XFixedText >   ( xFactory->createInstance ( FIXEDTEXT_SERVICENAME ), UNO_QUERY ) ;
      61                 :          0 :     m_xText_Bottom  = Reference< XFixedText >   ( xFactory->createInstance ( FIXEDTEXT_SERVICENAME ), UNO_QUERY ) ;
      62                 :          0 :     m_xButton       = Reference< XButton >      ( xFactory->createInstance ( BUTTON_SERVICENAME ), UNO_QUERY ) ;
      63                 :          0 :     m_xProgressBar  = Reference< XProgressBar > ( xFactory->createInstance ( SERVICENAME_PROGRESSBAR ), UNO_QUERY ) ;
      64                 :            : 
      65                 :            :     // ... cast controls to Reference< XControl >  (for "setModel"!) ...
      66                 :          0 :     Reference< XControl >   xRef_Topic_Top      ( m_xTopic_Top    , UNO_QUERY ) ;
      67                 :          0 :     Reference< XControl >   xRef_Text_Top       ( m_xText_Top     , UNO_QUERY ) ;
      68                 :          0 :     Reference< XControl >   xRef_Topic_Bottom   ( m_xTopic_Bottom , UNO_QUERY ) ;
      69                 :          0 :     Reference< XControl >   xRef_Text_Bottom    ( m_xText_Bottom  , UNO_QUERY ) ;
      70                 :          0 :     Reference< XControl >   xRef_Button         ( m_xButton       , UNO_QUERY ) ;
      71                 :          0 :     Reference< XControl >   xRef_ProgressBar    ( m_xProgressBar  , UNO_QUERY ) ;
      72                 :            : 
      73                 :            :     // ... set models ...
      74                 :          0 :     xRef_Topic_Top->setModel    ( Reference< XControlModel > ( xFactory->createInstance ( FIXEDTEXT_MODELNAME ), UNO_QUERY ) ) ;
      75                 :          0 :     xRef_Text_Top->setModel     ( Reference< XControlModel > ( xFactory->createInstance ( FIXEDTEXT_MODELNAME ), UNO_QUERY ) ) ;
      76                 :          0 :     xRef_Topic_Bottom->setModel ( Reference< XControlModel > ( xFactory->createInstance ( FIXEDTEXT_MODELNAME ), UNO_QUERY ) ) ;
      77                 :          0 :     xRef_Text_Bottom->setModel  ( Reference< XControlModel > ( xFactory->createInstance ( FIXEDTEXT_MODELNAME ), UNO_QUERY ) ) ;
      78                 :          0 :     xRef_Button->setModel       ( Reference< XControlModel > ( xFactory->createInstance ( BUTTON_MODELNAME ), UNO_QUERY ) ) ;
      79                 :            :     // ProgressBar has no model !!!
      80                 :            : 
      81                 :            :     // ... and add controls to basecontainercontrol!
      82                 :          0 :     addControl ( CONTROLNAME_TEXT, xRef_Topic_Top           ) ;
      83                 :          0 :     addControl ( CONTROLNAME_TEXT, xRef_Text_Top            ) ;
      84                 :          0 :     addControl ( CONTROLNAME_TEXT, xRef_Topic_Bottom        ) ;
      85                 :          0 :     addControl ( CONTROLNAME_TEXT, xRef_Text_Bottom         ) ;
      86                 :          0 :     addControl ( CONTROLNAME_BUTTON, xRef_Button            ) ;
      87                 :          0 :     addControl ( CONTROLNAME_PROGRESSBAR, xRef_ProgressBar  ) ;
      88                 :            : 
      89                 :            :     // FixedText make it automaticly visible by himself ... but not the progressbar !!!
      90                 :            :     // it must be set explicitly
      91                 :          0 :     Reference< XWindow > xWindowRef_ProgressBar( m_xProgressBar, UNO_QUERY );
      92                 :          0 :     xWindowRef_ProgressBar->setVisible( sal_True );
      93                 :            : 
      94                 :            :     // Reset to defaults !!!
      95                 :            :     // (progressbar take automaticly its own defaults)
      96                 :          0 :     m_xButton->setLabel      ( DEFAULT_BUTTONLABEL ) ;
      97                 :          0 :     m_xTopic_Top->setText    ( PROGRESSMONITOR_DEFAULT_TOPIC ) ;
      98                 :          0 :     m_xText_Top->setText     ( PROGRESSMONITOR_DEFAULT_TEXT ) ;
      99                 :          0 :     m_xTopic_Bottom->setText ( PROGRESSMONITOR_DEFAULT_TOPIC ) ;
     100                 :          0 :     m_xText_Bottom->setText  ( PROGRESSMONITOR_DEFAULT_TEXT ) ;
     101                 :            : 
     102                 :          0 :     --m_refCount ;
     103                 :          0 : }
     104                 :            : 
     105                 :          0 : ProgressMonitor::~ProgressMonitor()
     106                 :            : {
     107                 :          0 :     impl_cleanMemory () ;
     108                 :          0 : }
     109                 :            : 
     110                 :            : //____________________________________________________________________________________________________________
     111                 :            : //  XInterface
     112                 :            : //____________________________________________________________________________________________________________
     113                 :            : 
     114                 :          0 : Any SAL_CALL ProgressMonitor::queryInterface( const Type& rType ) throw( RuntimeException )
     115                 :            : {
     116                 :            :     // Attention:
     117                 :            :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
     118                 :          0 :     Any aReturn ;
     119                 :          0 :     Reference< XInterface > xDel = BaseContainerControl::impl_getDelegator();
     120                 :          0 :     if ( xDel.is() )
     121                 :            :     {
     122                 :            :         // If an delegator exist, forward question to his queryInterface.
     123                 :            :         // Delegator will ask his own queryAggregation!
     124                 :          0 :         aReturn = xDel->queryInterface( rType );
     125                 :            :     }
     126                 :            :     else
     127                 :            :     {
     128                 :            :         // If an delegator unknown, forward question to own queryAggregation.
     129                 :          0 :         aReturn = queryAggregation( rType );
     130                 :            :     }
     131                 :            : 
     132                 :          0 :     return aReturn ;
     133                 :            : }
     134                 :            : 
     135                 :            : //____________________________________________________________________________________________________________
     136                 :            : //  XInterface
     137                 :            : //____________________________________________________________________________________________________________
     138                 :            : 
     139                 :          0 : void SAL_CALL ProgressMonitor::acquire() throw()
     140                 :            : {
     141                 :            :     // Attention:
     142                 :            :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
     143                 :            : 
     144                 :            :     // Forward to baseclass
     145                 :          0 :     BaseControl::acquire();
     146                 :          0 : }
     147                 :            : 
     148                 :            : //____________________________________________________________________________________________________________
     149                 :            : //  XInterface
     150                 :            : //____________________________________________________________________________________________________________
     151                 :            : 
     152                 :          0 : void SAL_CALL ProgressMonitor::release() throw()
     153                 :            : {
     154                 :            :     // Attention:
     155                 :            :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
     156                 :            : 
     157                 :            :     // Forward to baseclass
     158                 :          0 :     BaseControl::release();
     159                 :          0 : }
     160                 :            : 
     161                 :            : //____________________________________________________________________________________________________________
     162                 :            : //  XTypeProvider
     163                 :            : //____________________________________________________________________________________________________________
     164                 :            : 
     165                 :          0 : Sequence< Type > SAL_CALL ProgressMonitor::getTypes() throw( RuntimeException )
     166                 :            : {
     167                 :            :     // Optimize this method !
     168                 :            :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     169                 :            :     // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
     170                 :            :     static OTypeCollection* pTypeCollection = NULL ;
     171                 :            : 
     172                 :          0 :     if ( pTypeCollection == NULL )
     173                 :            :     {
     174                 :            :         // Ready for multithreading; get global mutex for first call of this method only! see before
     175                 :          0 :         MutexGuard aGuard( Mutex::getGlobalMutex() );
     176                 :            : 
     177                 :            :         // Control these pointer again ... it can be, that another instance will be faster then these!
     178                 :          0 :         if ( pTypeCollection == NULL )
     179                 :            :         {
     180                 :            :             // Create a static typecollection ...
     181                 :          0 :             static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XLayoutConstrains >*)NULL )   ,
     182                 :          0 :                                                      ::getCppuType(( const Reference< XButton           >*)NULL )   ,
     183                 :          0 :                                                      ::getCppuType(( const Reference< XProgressMonitor  >*)NULL )   ,
     184                 :            :                                                      BaseContainerControl::getTypes()
     185                 :          0 :                                                    );
     186                 :            :             // ... and set his address to static pointer!
     187                 :          0 :             pTypeCollection = &aTypeCollection ;
     188                 :          0 :         }
     189                 :            :     }
     190                 :            : 
     191                 :          0 :     return pTypeCollection->getTypes();
     192                 :            : }
     193                 :            : 
     194                 :            : //____________________________________________________________________________________________________________
     195                 :            : //  XAggregation
     196                 :            : //____________________________________________________________________________________________________________
     197                 :            : 
     198                 :          0 : Any SAL_CALL ProgressMonitor::queryAggregation( const Type& aType ) throw( RuntimeException )
     199                 :            : {
     200                 :            :     // Ask for my own supported interfaces ...
     201                 :            :     // Attention: XTypeProvider and XInterface are supported by OComponentHelper!
     202                 :            :     Any aReturn ( ::cppu::queryInterface( aType ,
     203                 :            :                                           static_cast< XLayoutConstrains* > ( this ) ,
     204                 :            :                                           static_cast< XButton*           > ( this ) ,
     205                 :            :                                           static_cast< XProgressMonitor*  > ( this )
     206                 :            :                                         )
     207                 :          0 :                 );
     208                 :            : 
     209                 :            :     // If searched interface not supported by this class ...
     210                 :          0 :     if ( aReturn.hasValue() == sal_False )
     211                 :            :     {
     212                 :            :         // ... ask baseclasses.
     213                 :          0 :         aReturn = BaseControl::queryAggregation( aType );
     214                 :            :     }
     215                 :            : 
     216                 :          0 :     return aReturn ;
     217                 :            : }
     218                 :            : 
     219                 :            : //____________________________________________________________________________________________________________
     220                 :            : //  XProgressMonitor
     221                 :            : //____________________________________________________________________________________________________________
     222                 :            : 
     223                 :          0 : void SAL_CALL ProgressMonitor::addText(
     224                 :            :     const OUString& rTopic,
     225                 :            :     const OUString& rText,
     226                 :            :     sal_Bool bbeforeProgress
     227                 :            : ) throw( RuntimeException )
     228                 :            : {
     229                 :            :     // Safe impossible cases
     230                 :            :     // Check valid call of this method.
     231                 :            :     DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText, bbeforeProgress )   , "ProgressMonitor::addText()\nCall without valid parameters!\n") ;
     232                 :            :     DBG_ASSERT ( !(impl_searchTopic ( rTopic, bbeforeProgress ) != NULL )       , "ProgresMonitor::addText()\nThe text already exist.\n"        ) ;
     233                 :            : 
     234                 :            :     // Do nothing (in Release), if topic already exist.
     235                 :          0 :     if ( impl_searchTopic ( rTopic, bbeforeProgress ) != NULL )
     236                 :            :     {
     237                 :          0 :         return ;
     238                 :            :     }
     239                 :            : 
     240                 :            :     // Else ... take memory for new item ...
     241                 :          0 :     IMPL_TextlistItem*  pTextItem = new IMPL_TextlistItem ;
     242                 :            : 
     243                 :          0 :     if ( pTextItem != NULL )
     244                 :            :     {
     245                 :            :         // Set values ...
     246                 :          0 :         pTextItem->sTopic   = rTopic ;
     247                 :          0 :         pTextItem->sText    = rText ;
     248                 :            : 
     249                 :            :         // Ready for multithreading
     250                 :          0 :         MutexGuard aGuard ( m_aMutex ) ;
     251                 :            : 
     252                 :            :         // ... and insert it in right list.
     253                 :          0 :         if ( bbeforeProgress == sal_True )
     254                 :            :         {
     255                 :          0 :             maTextlist_Top.push_back( pTextItem );
     256                 :            :         }
     257                 :            :         else
     258                 :            :         {
     259                 :          0 :             maTextlist_Bottom.push_back( pTextItem );
     260                 :          0 :         }
     261                 :            :     }
     262                 :            : 
     263                 :            :     // ... update window
     264                 :          0 :     impl_rebuildFixedText   () ;
     265                 :          0 :     impl_recalcLayout       () ;
     266                 :            : }
     267                 :            : 
     268                 :            : //____________________________________________________________________________________________________________
     269                 :            : //  XProgressMonitor
     270                 :            : //____________________________________________________________________________________________________________
     271                 :            : 
     272                 :          0 : void SAL_CALL ProgressMonitor::removeText ( const OUString& rTopic, sal_Bool bbeforeProgress ) throw( RuntimeException )
     273                 :            : {
     274                 :            :     // Safe impossible cases
     275                 :            :     // Check valid call of this method.
     276                 :            :     DBG_ASSERT ( impl_debug_checkParameter ( rTopic, bbeforeProgress ), "ProgressMonitor::removeText()\nCall without valid parameters!\n" ) ;
     277                 :            : 
     278                 :            :     // Search the topic ...
     279                 :          0 :     IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress ) ;
     280                 :            : 
     281                 :          0 :     if ( pSearchItem != NULL )
     282                 :            :     {
     283                 :            :         // Ready for multithreading
     284                 :          0 :         MutexGuard aGuard ( m_aMutex ) ;
     285                 :            : 
     286                 :            :         // ... delete item from right list ...
     287                 :          0 :         if ( bbeforeProgress == sal_True )
     288                 :            :         {
     289                 :            :             vector< IMPL_TextlistItem* >::iterator
     290                 :          0 :                 itr = find( maTextlist_Top.begin(), maTextlist_Top.end(), pSearchItem );
     291                 :          0 :             if (itr != maTextlist_Top.end())
     292                 :          0 :                 maTextlist_Top.erase(itr);
     293                 :            :         }
     294                 :            :         else
     295                 :            :         {
     296                 :            :             vector< IMPL_TextlistItem* >::iterator
     297                 :          0 :                 itr = find( maTextlist_Bottom.begin(), maTextlist_Bottom.end(), pSearchItem );
     298                 :          0 :             if (itr != maTextlist_Bottom.end())
     299                 :          0 :                 maTextlist_Bottom.erase(itr);
     300                 :            :         }
     301                 :            : 
     302                 :          0 :         delete pSearchItem ;
     303                 :            : 
     304                 :            :         // ... and update window.
     305                 :          0 :         impl_rebuildFixedText   () ;
     306                 :          0 :         impl_recalcLayout       () ;
     307                 :            :     }
     308                 :          0 : }
     309                 :            : 
     310                 :            : //____________________________________________________________________________________________________________
     311                 :            : //  XProgressMonitor
     312                 :            : //____________________________________________________________________________________________________________
     313                 :            : 
     314                 :          0 : void SAL_CALL ProgressMonitor::updateText (
     315                 :            :     const OUString& rTopic,
     316                 :            :     const OUString& rText,
     317                 :            :     sal_Bool bbeforeProgress
     318                 :            : ) throw( RuntimeException )
     319                 :            : {
     320                 :            :     // Safe impossible cases
     321                 :            :     // Check valid call of this method.
     322                 :            :     DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText, bbeforeProgress ), "ProgressMonitor::updateText()\nCall without valid parameters!\n" ) ;
     323                 :            : 
     324                 :            :     // Search topic ...
     325                 :          0 :     IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress ) ;
     326                 :            : 
     327                 :          0 :     if ( pSearchItem != NULL )
     328                 :            :     {
     329                 :            :         // Ready for multithreading
     330                 :          0 :         MutexGuard aGuard ( m_aMutex ) ;
     331                 :            : 
     332                 :            :         // ... update text ...
     333                 :          0 :         pSearchItem->sText = rText ;
     334                 :            : 
     335                 :            :         // ... and update window.
     336                 :          0 :         impl_rebuildFixedText   () ;
     337                 :          0 :         impl_recalcLayout       () ;
     338                 :            :     }
     339                 :          0 : }
     340                 :            : 
     341                 :            : //____________________________________________________________________________________________________________
     342                 :            : //  XProgressBar
     343                 :            : //____________________________________________________________________________________________________________
     344                 :            : 
     345                 :          0 : void SAL_CALL ProgressMonitor::setForegroundColor ( sal_Int32 nColor ) throw( RuntimeException )
     346                 :            : {
     347                 :            :     // Ready for multithreading
     348                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     349                 :            : 
     350                 :          0 :     if ( m_xProgressBar.is () )
     351                 :            :     {
     352                 :          0 :         m_xProgressBar->setForegroundColor ( nColor ) ;
     353                 :          0 :     }
     354                 :          0 : }
     355                 :            : 
     356                 :            : //____________________________________________________________________________________________________________
     357                 :            : //  XProgressBar
     358                 :            : //____________________________________________________________________________________________________________
     359                 :            : 
     360                 :          0 : void SAL_CALL ProgressMonitor::setBackgroundColor ( sal_Int32 nColor ) throw( RuntimeException )
     361                 :            : {
     362                 :            :     // Ready for multithreading
     363                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     364                 :            : 
     365                 :          0 :     if ( m_xProgressBar.is () )
     366                 :            :     {
     367                 :          0 :         m_xProgressBar->setBackgroundColor ( nColor ) ;
     368                 :          0 :     }
     369                 :          0 : }
     370                 :            : 
     371                 :            : //____________________________________________________________________________________________________________
     372                 :            : //  XProgressBar
     373                 :            : //____________________________________________________________________________________________________________
     374                 :            : 
     375                 :          0 : void SAL_CALL ProgressMonitor::setValue ( sal_Int32 nValue ) throw( RuntimeException )
     376                 :            : {
     377                 :            :     // Ready for multithreading
     378                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     379                 :            : 
     380                 :          0 :     if ( m_xProgressBar.is () )
     381                 :            :     {
     382                 :          0 :         m_xProgressBar->setValue ( nValue ) ;
     383                 :          0 :     }
     384                 :          0 : }
     385                 :            : 
     386                 :            : //____________________________________________________________________________________________________________
     387                 :            : //  XProgressBar
     388                 :            : //____________________________________________________________________________________________________________
     389                 :            : 
     390                 :          0 : void SAL_CALL ProgressMonitor::setRange ( sal_Int32 nMin, sal_Int32 nMax ) throw( RuntimeException )
     391                 :            : {
     392                 :            :     // Ready for multithreading
     393                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     394                 :            : 
     395                 :          0 :     if ( m_xProgressBar.is () )
     396                 :            :     {
     397                 :          0 :         m_xProgressBar->setRange ( nMin, nMax ) ;
     398                 :          0 :     }
     399                 :          0 : }
     400                 :            : 
     401                 :            : //____________________________________________________________________________________________________________
     402                 :            : //  XProgressBar
     403                 :            : //____________________________________________________________________________________________________________
     404                 :            : 
     405                 :          0 : sal_Int32 SAL_CALL ProgressMonitor::getValue () throw( RuntimeException )
     406                 :            : {
     407                 :            :     // Ready for multithreading
     408                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     409                 :            : 
     410                 :          0 :     if (m_xProgressBar.is())
     411                 :            :     {
     412                 :          0 :         return m_xProgressBar->getValue () ;
     413                 :            :     }
     414                 :            : 
     415                 :          0 :     return 0 ;
     416                 :            : }
     417                 :            : 
     418                 :            : //____________________________________________________________________________________________________________
     419                 :            : //  XButton
     420                 :            : //____________________________________________________________________________________________________________
     421                 :            : 
     422                 :          0 : void SAL_CALL ProgressMonitor::addActionListener ( const Reference< XActionListener > & rListener ) throw( RuntimeException )
     423                 :            : {
     424                 :            :     // Ready for multithreading
     425                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     426                 :            : 
     427                 :          0 :     if ( m_xButton.is () )
     428                 :            :     {
     429                 :          0 :         m_xButton->addActionListener ( rListener ) ;
     430                 :          0 :     }
     431                 :          0 : }
     432                 :            : 
     433                 :            : //____________________________________________________________________________________________________________
     434                 :            : //  XButton
     435                 :            : //____________________________________________________________________________________________________________
     436                 :            : 
     437                 :          0 : void SAL_CALL ProgressMonitor::removeActionListener ( const Reference< XActionListener > & rListener ) throw( RuntimeException )
     438                 :            : {
     439                 :            :     // Ready for multithreading
     440                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     441                 :            : 
     442                 :          0 :     if ( m_xButton.is () )
     443                 :            :     {
     444                 :          0 :         m_xButton->removeActionListener ( rListener ) ;
     445                 :          0 :     }
     446                 :          0 : }
     447                 :            : 
     448                 :            : //____________________________________________________________________________________________________________
     449                 :            : //  XButton
     450                 :            : //____________________________________________________________________________________________________________
     451                 :            : 
     452                 :          0 : void SAL_CALL ProgressMonitor::setLabel ( const OUString& rLabel ) throw( RuntimeException )
     453                 :            : {
     454                 :            :     // Ready for multithreading
     455                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     456                 :            : 
     457                 :          0 :     if ( m_xButton.is () )
     458                 :            :     {
     459                 :          0 :         m_xButton->setLabel ( rLabel ) ;
     460                 :          0 :     }
     461                 :          0 : }
     462                 :            : 
     463                 :            : //____________________________________________________________________________________________________________
     464                 :            : //  XButton
     465                 :            : //____________________________________________________________________________________________________________
     466                 :            : 
     467                 :          0 : void SAL_CALL ProgressMonitor::setActionCommand ( const OUString& rCommand ) throw( RuntimeException )
     468                 :            : {
     469                 :            :     // Ready for multithreading
     470                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     471                 :            : 
     472                 :          0 :     if ( m_xButton.is () )
     473                 :            :     {
     474                 :          0 :         m_xButton->setActionCommand ( rCommand ) ;
     475                 :          0 :     }
     476                 :          0 : }
     477                 :            : 
     478                 :            : //____________________________________________________________________________________________________________
     479                 :            : //  XLayoutConstrains
     480                 :            : //____________________________________________________________________________________________________________
     481                 :            : 
     482                 :          0 : Size SAL_CALL ProgressMonitor::getMinimumSize () throw( RuntimeException )
     483                 :            : {
     484                 :          0 :     return Size (PROGRESSMONITOR_DEFAULT_WIDTH, PROGRESSMONITOR_DEFAULT_HEIGHT) ;
     485                 :            : }
     486                 :            : 
     487                 :            : //____________________________________________________________________________________________________________
     488                 :            : //  XLayoutConstrains
     489                 :            : //____________________________________________________________________________________________________________
     490                 :            : 
     491                 :          0 : Size SAL_CALL ProgressMonitor::getPreferredSize () throw( RuntimeException )
     492                 :            : {
     493                 :            :     // Ready for multithreading
     494                 :          0 :     ClearableMutexGuard aGuard ( m_aMutex ) ;
     495                 :            : 
     496                 :            :     // get information about required place of child controls
     497                 :          0 :     Reference< XLayoutConstrains >  xTopicLayout_Top        ( m_xTopic_Top      , UNO_QUERY ) ;
     498                 :          0 :     Reference< XLayoutConstrains >  xTopicLayout_Bottom     ( m_xTopic_Bottom   , UNO_QUERY ) ;
     499                 :          0 :     Reference< XLayoutConstrains >  xButtonLayout           ( m_xButton         , UNO_QUERY ) ;
     500                 :          0 :     Reference< XWindow >            xProgressBarWindow      ( m_xProgressBar    , UNO_QUERY ) ;
     501                 :            : 
     502                 :          0 :     Size        aTopicSize_Top      =   xTopicLayout_Top->getPreferredSize          ();
     503                 :          0 :     Size        aTopicSize_Bottom   =   xTopicLayout_Bottom->getPreferredSize       ();
     504                 :          0 :     Size        aButtonSize         =   xButtonLayout->getPreferredSize             ();
     505                 :          0 :     Rectangle   aTempRectangle      =   xProgressBarWindow->getPosSize              ();
     506                 :          0 :     Size        aProgressBarSize    =   Size( aTempRectangle.Width, aTempRectangle.Height );
     507                 :            : 
     508                 :          0 :     aGuard.clear () ;
     509                 :            : 
     510                 :            :     // calc preferred size of progressmonitor
     511                 :          0 :     sal_Int32   nWidth  =   0 ;
     512                 :          0 :     sal_Int32   nHeight =   0 ;
     513                 :            : 
     514                 :          0 :     nWidth   =  3 * PROGRESSMONITOR_FREEBORDER          ;
     515                 :          0 :     nWidth  +=  aProgressBarSize.Width  ;
     516                 :            : 
     517                 :          0 :     nHeight  =  6 * PROGRESSMONITOR_FREEBORDER          ;
     518                 :          0 :     nHeight +=  aTopicSize_Top.Height   ;
     519                 :          0 :     nHeight +=  aProgressBarSize.Height ;
     520                 :          0 :     nHeight +=  aTopicSize_Bottom.Height;
     521                 :          0 :     nHeight +=  2                       ;   // 1 for black line, 1 for white line = 3D-Line!
     522                 :          0 :     nHeight +=  aButtonSize.Height      ;
     523                 :            : 
     524                 :            :     // norm to minimum
     525                 :          0 :     if ( nWidth < PROGRESSMONITOR_DEFAULT_WIDTH )
     526                 :            :     {
     527                 :          0 :         nWidth = PROGRESSMONITOR_DEFAULT_WIDTH ;
     528                 :            :     }
     529                 :          0 :     if ( nHeight < PROGRESSMONITOR_DEFAULT_HEIGHT )
     530                 :            :     {
     531                 :          0 :         nHeight = PROGRESSMONITOR_DEFAULT_HEIGHT ;
     532                 :            :     }
     533                 :            : 
     534                 :            :     // return to caller
     535                 :          0 :     return Size ( nWidth, nHeight ) ;
     536                 :            : }
     537                 :            : 
     538                 :            : //____________________________________________________________________________________________________________
     539                 :            : //  XLayoutConstrains
     540                 :            : //____________________________________________________________________________________________________________
     541                 :            : 
     542                 :          0 : Size SAL_CALL ProgressMonitor::calcAdjustedSize ( const Size& /*rNewSize*/ ) throw( RuntimeException )
     543                 :            : {
     544                 :          0 :     return getPreferredSize () ;
     545                 :            : }
     546                 :            : 
     547                 :            : //____________________________________________________________________________________________________________
     548                 :            : //  XControl
     549                 :            : //____________________________________________________________________________________________________________
     550                 :            : 
     551                 :          0 : void SAL_CALL ProgressMonitor::createPeer ( const Reference< XToolkit > & rToolkit, const Reference< XWindowPeer > & rParent    ) throw( RuntimeException )
     552                 :            : {
     553                 :          0 :     if (!getPeer().is())
     554                 :            :     {
     555                 :          0 :         BaseContainerControl::createPeer ( rToolkit, rParent ) ;
     556                 :            : 
     557                 :            :         // If user forget to call "setPosSize()", we have still a correct size.
     558                 :            :         // And a "MinimumSize" IS A "MinimumSize"!
     559                 :            :         // We change not the position of control at this point.
     560                 :          0 :         Size aDefaultSize = getMinimumSize () ;
     561                 :          0 :         setPosSize ( 0, 0, aDefaultSize.Width, aDefaultSize.Height, PosSize::SIZE ) ;
     562                 :            :     }
     563                 :          0 : }
     564                 :            : 
     565                 :            : //____________________________________________________________________________________________________________
     566                 :            : //  XControl
     567                 :            : //____________________________________________________________________________________________________________
     568                 :            : 
     569                 :          0 : sal_Bool SAL_CALL ProgressMonitor::setModel ( const Reference< XControlModel > & /*rModel*/ ) throw( RuntimeException )
     570                 :            : {
     571                 :            :     // We have no model.
     572                 :          0 :     return sal_False ;
     573                 :            : }
     574                 :            : 
     575                 :            : //____________________________________________________________________________________________________________
     576                 :            : //  XControl
     577                 :            : //____________________________________________________________________________________________________________
     578                 :            : 
     579                 :          0 : Reference< XControlModel > SAL_CALL ProgressMonitor::getModel () throw( RuntimeException )
     580                 :            : {
     581                 :            :     // We have no model.
     582                 :            :     // return (XControlModel*)this ;
     583                 :          0 :     return Reference< XControlModel >  () ;
     584                 :            : }
     585                 :            : 
     586                 :            : //____________________________________________________________________________________________________________
     587                 :            : //  XComponent
     588                 :            : //____________________________________________________________________________________________________________
     589                 :            : 
     590                 :          0 : void SAL_CALL ProgressMonitor::dispose () throw( RuntimeException )
     591                 :            : {
     592                 :            :     // Ready for multithreading
     593                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     594                 :            : 
     595                 :            :     // "removeControl()" control the state of a reference
     596                 :          0 :     Reference< XControl >  xRef_Topic_Top       ( m_xTopic_Top      , UNO_QUERY ) ;
     597                 :          0 :     Reference< XControl >  xRef_Text_Top        ( m_xText_Top       , UNO_QUERY ) ;
     598                 :          0 :     Reference< XControl >  xRef_Topic_Bottom    ( m_xTopic_Bottom   , UNO_QUERY ) ;
     599                 :          0 :     Reference< XControl >  xRef_Text_Bottom     ( m_xText_Bottom    , UNO_QUERY ) ;
     600                 :          0 :     Reference< XControl >  xRef_Button          ( m_xButton         , UNO_QUERY ) ;
     601                 :          0 :     Reference< XControl >  xRef_ProgressBar     ( m_xProgressBar    , UNO_QUERY ) ;
     602                 :            : 
     603                 :          0 :     removeControl ( xRef_Topic_Top      ) ;
     604                 :          0 :     removeControl ( xRef_Text_Top       ) ;
     605                 :          0 :     removeControl ( xRef_Topic_Bottom   ) ;
     606                 :          0 :     removeControl ( xRef_Text_Bottom    ) ;
     607                 :          0 :     removeControl ( xRef_Button         ) ;
     608                 :          0 :     removeControl ( xRef_ProgressBar    ) ;
     609                 :            : 
     610                 :            :     // do'nt use "...->clear ()" or "... = XFixedText ()"
     611                 :            :     // when other hold a reference at this object !!!
     612                 :          0 :     xRef_Topic_Top->dispose     () ;
     613                 :          0 :     xRef_Text_Top->dispose      () ;
     614                 :          0 :     xRef_Topic_Bottom->dispose  () ;
     615                 :          0 :     xRef_Text_Bottom->dispose   () ;
     616                 :          0 :     xRef_Button->dispose        () ;
     617                 :          0 :     xRef_ProgressBar->dispose   () ;
     618                 :            : 
     619                 :          0 :     BaseContainerControl::dispose () ;
     620                 :          0 : }
     621                 :            : 
     622                 :            : //____________________________________________________________________________________________________________
     623                 :            : //  XWindow
     624                 :            : //____________________________________________________________________________________________________________
     625                 :            : 
     626                 :          0 : void SAL_CALL ProgressMonitor::setPosSize ( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags ) throw( RuntimeException )
     627                 :            : {
     628                 :          0 :     Rectangle   aBasePosSize = getPosSize () ;
     629                 :          0 :     BaseContainerControl::setPosSize (nX, nY, nWidth, nHeight, nFlags) ;
     630                 :            : 
     631                 :            :     // if position or size changed
     632                 :          0 :     if (
     633                 :            :         ( nWidth  != aBasePosSize.Width ) ||
     634                 :            :         ( nHeight != aBasePosSize.Height)
     635                 :            :        )
     636                 :            :     {
     637                 :            :         // calc new layout for controls
     638                 :          0 :         impl_recalcLayout () ;
     639                 :            :         // clear background (!)
     640                 :            :         // [Children were repainted in "recalcLayout" by setPosSize() automaticly!]
     641                 :          0 :         getPeer()->invalidate(2);
     642                 :            :         // and repaint the control
     643                 :          0 :         impl_paint ( 0, 0, impl_getGraphicsPeer() ) ;
     644                 :            :     }
     645                 :          0 : }
     646                 :            : 
     647                 :            : //____________________________________________________________________________________________________________
     648                 :            : //  impl but public method to register service
     649                 :            : //____________________________________________________________________________________________________________
     650                 :            : 
     651                 :          0 : const Sequence< OUString > ProgressMonitor::impl_getStaticSupportedServiceNames()
     652                 :            : {
     653                 :          0 :     MutexGuard aGuard( Mutex::getGlobalMutex() );
     654                 :          0 :     Sequence< OUString > seqServiceNames( 1 );
     655                 :          0 :     seqServiceNames.getArray() [0] = SERVICENAME_PROGRESSMONITOR;
     656                 :          0 :     return seqServiceNames ;
     657                 :            : }
     658                 :            : 
     659                 :            : //____________________________________________________________________________________________________________
     660                 :            : //  impl but public method to register service
     661                 :            : //____________________________________________________________________________________________________________
     662                 :            : 
     663                 :          0 : const OUString ProgressMonitor::impl_getStaticImplementationName()
     664                 :            : {
     665                 :          0 :     return OUString(IMPLEMENTATIONNAME_PROGRESSMONITOR);
     666                 :            : }
     667                 :            : 
     668                 :            : //____________________________________________________________________________________________________________
     669                 :            : //  protected method
     670                 :            : //____________________________________________________________________________________________________________
     671                 :            : 
     672                 :          0 : void ProgressMonitor::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics )
     673                 :            : {
     674                 :          0 :     if (rGraphics.is())
     675                 :            :     {
     676                 :            :         // Ready for multithreading
     677                 :          0 :         MutexGuard aGuard ( m_aMutex ) ;
     678                 :            : 
     679                 :            :         // paint shadowed border around the progressmonitor
     680                 :          0 :         rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW                                                              ) ;
     681                 :          0 :         rGraphics->drawLine     ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY                  ) ;
     682                 :          0 :         rGraphics->drawLine     ( impl_getWidth()-1, impl_getHeight()-1, nX               , impl_getHeight()-1  ) ;
     683                 :            : 
     684                 :          0 :         rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT                          ) ;
     685                 :          0 :         rGraphics->drawLine     ( nX, nY, impl_getWidth(), nY               ) ;
     686                 :          0 :         rGraphics->drawLine     ( nX, nY, nX             , impl_getHeight() ) ;
     687                 :            : 
     688                 :            :         // Paint 3D-line
     689                 :          0 :         rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW  ) ;
     690                 :          0 :         rGraphics->drawLine     ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ) ;
     691                 :            : 
     692                 :          0 :         rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT  ) ;
     693                 :          0 :         rGraphics->drawLine     ( m_a3DLine.X, m_a3DLine.Y+1, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y+1 ) ;
     694                 :            :     }
     695                 :          0 : }
     696                 :            : 
     697                 :            : //____________________________________________________________________________________________________________
     698                 :            : //  private method
     699                 :            : //____________________________________________________________________________________________________________
     700                 :            : 
     701                 :          0 : void ProgressMonitor::impl_recalcLayout ()
     702                 :            : {
     703                 :            :     sal_Int32   nX_Button               ;
     704                 :            :     sal_Int32   nY_Button               ;
     705                 :            :     sal_Int32   nWidth_Button           ;
     706                 :            :     sal_Int32   nHeight_Button          ;
     707                 :            : 
     708                 :            :     sal_Int32   nX_ProgressBar          ;
     709                 :            :     sal_Int32   nY_ProgressBar          ;
     710                 :            :     sal_Int32   nWidth_ProgressBar      ;
     711                 :            :     sal_Int32   nHeight_ProgressBar     ;
     712                 :            : 
     713                 :            :     sal_Int32   nX_Text_Top             ;
     714                 :            :     sal_Int32   nY_Text_Top             ;
     715                 :            :     sal_Int32   nWidth_Text_Top         ;
     716                 :            :     sal_Int32   nHeight_Text_Top        ;
     717                 :            : 
     718                 :            :     sal_Int32   nX_Topic_Top            ;
     719                 :            :     sal_Int32   nY_Topic_Top            ;
     720                 :            :     sal_Int32   nWidth_Topic_Top        ;
     721                 :            :     sal_Int32   nHeight_Topic_Top       ;
     722                 :            : 
     723                 :            :     sal_Int32   nX_Text_Bottom          ;
     724                 :            :     sal_Int32   nY_Text_Bottom          ;
     725                 :            :     sal_Int32   nWidth_Text_Bottom      ;
     726                 :            :     sal_Int32   nHeight_Text_Bottom     ;
     727                 :            : 
     728                 :            :     sal_Int32   nX_Topic_Bottom         ;
     729                 :            :     sal_Int32   nY_Topic_Bottom         ;
     730                 :            :     sal_Int32   nWidth_Topic_Bottom     ;
     731                 :            :     sal_Int32   nHeight_Topic_Bottom    ;
     732                 :            : 
     733                 :            :     // Ready for multithreading
     734                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     735                 :            : 
     736                 :            :     // get information about required place of child controls
     737                 :          0 :     Reference< XLayoutConstrains >  xTopicLayout_Top    ( m_xTopic_Top      , UNO_QUERY ) ;
     738                 :          0 :     Reference< XLayoutConstrains >  xTextLayout_Top     ( m_xText_Top       , UNO_QUERY ) ;
     739                 :          0 :     Reference< XLayoutConstrains >  xTopicLayout_Bottom ( m_xTopic_Bottom   , UNO_QUERY ) ;
     740                 :          0 :     Reference< XLayoutConstrains >  xTextLayout_Bottom  ( m_xText_Bottom    , UNO_QUERY ) ;
     741                 :          0 :     Reference< XLayoutConstrains >  xButtonLayout       ( m_xButton         , UNO_QUERY ) ;
     742                 :            : 
     743                 :          0 :     Size    aTopicSize_Top      =   xTopicLayout_Top->getPreferredSize      () ;
     744                 :          0 :     Size    aTextSize_Top       =   xTextLayout_Top->getPreferredSize       () ;
     745                 :          0 :     Size    aTopicSize_Bottom   =   xTopicLayout_Bottom->getPreferredSize   () ;
     746                 :          0 :     Size    aTextSize_Bottom    =   xTextLayout_Bottom->getPreferredSize    () ;
     747                 :          0 :     Size    aButtonSize         =   xButtonLayout->getPreferredSize         () ;
     748                 :            : 
     749                 :            :     // calc position and size of child controls
     750                 :            :     // Button has preferred size!
     751                 :          0 :     nWidth_Button           =   aButtonSize.Width   ;
     752                 :          0 :     nHeight_Button          =   aButtonSize.Height  ;
     753                 :            : 
     754                 :            :     // Left column before progressbar has preferred size and fixed position.
     755                 :            :     // But "Width" is oriented on left column below progressbar to!!! "max(...)"
     756                 :          0 :     nX_Topic_Top            =   PROGRESSMONITOR_FREEBORDER                              ;
     757                 :          0 :     nY_Topic_Top            =   PROGRESSMONITOR_FREEBORDER                              ;
     758                 :          0 :     nWidth_Topic_Top        =   Max ( aTopicSize_Top.Width, aTopicSize_Bottom.Width )   ;
     759                 :          0 :     nHeight_Topic_Top       =   aTopicSize_Top.Height                                   ;
     760                 :            : 
     761                 :            :     // Right column before progressbar has relativ position to left column ...
     762                 :            :     // ... and a size as rest of dialog size!
     763                 :          0 :     nX_Text_Top             =   nX_Topic_Top+nWidth_Topic_Top+PROGRESSMONITOR_FREEBORDER;
     764                 :          0 :     nY_Text_Top             =   nY_Topic_Top                                            ;
     765                 :          0 :     nWidth_Text_Top         =   Max ( aTextSize_Top.Width, aTextSize_Bottom.Width )     ;
     766                 :            :     // Fix size of this column to minimum!
     767                 :          0 :     sal_Int32 nSummaryWidth = nWidth_Text_Top+nWidth_Topic_Top+(3*PROGRESSMONITOR_FREEBORDER) ;
     768                 :          0 :     if ( nSummaryWidth < PROGRESSMONITOR_DEFAULT_WIDTH )
     769                 :          0 :         nWidth_Text_Top     =   PROGRESSMONITOR_DEFAULT_WIDTH-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER);
     770                 :            :     // Fix size of column to maximum!
     771                 :          0 :     if ( nSummaryWidth > impl_getWidth() )
     772                 :          0 :         nWidth_Text_Top     =   impl_getWidth()-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER) ;
     773                 :          0 :     nHeight_Text_Top        =   nHeight_Topic_Top                                               ;
     774                 :            : 
     775                 :            :     // Position of progressbar is relativ to columns before.
     776                 :            :     // Progressbar.Width  = Dialog.Width !!!
     777                 :            :     // Progressbar.Height = Button.Height
     778                 :          0 :     nX_ProgressBar          =   nX_Topic_Top                                                    ;
     779                 :          0 :     nY_ProgressBar          =   nY_Topic_Top+nHeight_Topic_Top+PROGRESSMONITOR_FREEBORDER       ;
     780                 :          0 :     nWidth_ProgressBar      =   PROGRESSMONITOR_FREEBORDER+nWidth_Topic_Top+nWidth_Text_Top     ;
     781                 :          0 :     nHeight_ProgressBar     =   nHeight_Button                                                  ;
     782                 :            : 
     783                 :            :     // Oriented by left column before progressbar.
     784                 :          0 :     nX_Topic_Bottom         =   nX_Topic_Top                                                    ;
     785                 :          0 :     nY_Topic_Bottom         =   nY_ProgressBar+nHeight_ProgressBar+PROGRESSMONITOR_FREEBORDER   ;
     786                 :          0 :     nWidth_Topic_Bottom     =   nWidth_Topic_Top                                                ;
     787                 :          0 :     nHeight_Topic_Bottom    =   aTopicSize_Bottom.Height                                        ;
     788                 :            : 
     789                 :            :     // Oriented by right column before progressbar.
     790                 :          0 :     nX_Text_Bottom          =   nX_Topic_Bottom+nWidth_Topic_Bottom+PROGRESSMONITOR_FREEBORDER  ;
     791                 :          0 :     nY_Text_Bottom          =   nY_Topic_Bottom                                                 ;
     792                 :          0 :     nWidth_Text_Bottom      =   nWidth_Text_Top                                                 ;
     793                 :          0 :     nHeight_Text_Bottom     =   nHeight_Topic_Bottom                                            ;
     794                 :            : 
     795                 :            :     // Oriented by progressbar.
     796                 :          0 :     nX_Button               =   nX_ProgressBar+nWidth_ProgressBar-nWidth_Button                 ;
     797                 :          0 :     nY_Button               =   nY_Topic_Bottom+nHeight_Topic_Bottom+PROGRESSMONITOR_FREEBORDER ;
     798                 :            : 
     799                 :            :     // Calc offsets to center controls
     800                 :            :     sal_Int32   nDx ;
     801                 :            :     sal_Int32   nDy ;
     802                 :            : 
     803                 :          0 :     nDx =   ( (2*PROGRESSMONITOR_FREEBORDER)+nWidth_ProgressBar                                                             ) ;
     804                 :          0 :     nDy =   ( (6*PROGRESSMONITOR_FREEBORDER)+nHeight_Topic_Top+nHeight_ProgressBar+nHeight_Topic_Bottom+2+nHeight_Button    ) ;
     805                 :            : 
     806                 :            :     // At this point use original dialog size to center controls!
     807                 :          0 :     nDx =   (impl_getWidth ()/2)-(nDx/2)    ;
     808                 :          0 :     nDy =   (impl_getHeight()/2)-(nDy/2)    ;
     809                 :            : 
     810                 :          0 :     if ( nDx<0 )
     811                 :            :     {
     812                 :          0 :         nDx=0 ;
     813                 :            :     }
     814                 :          0 :     if ( nDy<0 )
     815                 :            :     {
     816                 :          0 :         nDy=0 ;
     817                 :            :     }
     818                 :            : 
     819                 :            :     // Set new position and size on all controls
     820                 :          0 :     Reference< XWindow >  xRef_Topic_Top        ( m_xTopic_Top      , UNO_QUERY ) ;
     821                 :          0 :     Reference< XWindow >  xRef_Text_Top         ( m_xText_Top       , UNO_QUERY ) ;
     822                 :          0 :     Reference< XWindow >  xRef_Topic_Bottom     ( m_xTopic_Bottom   , UNO_QUERY ) ;
     823                 :          0 :     Reference< XWindow >  xRef_Text_Bottom      ( m_xText_Bottom    , UNO_QUERY ) ;
     824                 :          0 :     Reference< XWindow >  xRef_Button           ( m_xButton         , UNO_QUERY ) ;
     825                 :          0 :     Reference< XWindow >  xRef_ProgressBar      ( m_xProgressBar    , UNO_QUERY ) ;
     826                 :            : 
     827                 :          0 :     xRef_Topic_Top->setPosSize    ( nDx+nX_Topic_Top    , nDy+nY_Topic_Top    , nWidth_Topic_Top    , nHeight_Topic_Top    , 15 ) ;
     828                 :          0 :     xRef_Text_Top->setPosSize     ( nDx+nX_Text_Top     , nDy+nY_Text_Top     , nWidth_Text_Top     , nHeight_Text_Top     , 15 ) ;
     829                 :          0 :     xRef_Topic_Bottom->setPosSize ( nDx+nX_Topic_Bottom , nDy+nY_Topic_Bottom , nWidth_Topic_Bottom , nHeight_Topic_Bottom , 15 ) ;
     830                 :          0 :     xRef_Text_Bottom->setPosSize  ( nDx+nX_Text_Bottom  , nDy+nY_Text_Bottom  , nWidth_Text_Bottom  , nHeight_Text_Bottom  , 15 ) ;
     831                 :          0 :     xRef_Button->setPosSize       ( nDx+nX_Button       , nDy+nY_Button       , nWidth_Button       , nHeight_Button       , 15 ) ;
     832                 :          0 :     xRef_ProgressBar->setPosSize  ( nDx+nX_ProgressBar  , nDy+nY_ProgressBar  , nWidth_ProgressBar  , nHeight_ProgressBar  , 15 ) ;
     833                 :            : 
     834                 :          0 :     m_a3DLine.X      = nDx+nX_Topic_Top                                         ;
     835                 :          0 :     m_a3DLine.Y      = nDy+nY_Topic_Bottom+nHeight_Topic_Bottom+(PROGRESSMONITOR_FREEBORDER/2)  ;
     836                 :          0 :     m_a3DLine.Width  = nWidth_ProgressBar                                       ;
     837                 :          0 :     m_a3DLine.Height = nHeight_ProgressBar                                      ;
     838                 :            : 
     839                 :            :     // All childcontrols make an implicit repaint in setPosSize()!
     840                 :            :     // Make it also for this 3D-line ...
     841                 :          0 :     Reference< XGraphics >  xGraphics = impl_getGraphicsPeer () ;
     842                 :            : 
     843                 :          0 :     xGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW  ) ;
     844                 :          0 :     xGraphics->drawLine     ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ) ;
     845                 :            : 
     846                 :          0 :     xGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT  ) ;
     847                 :          0 :     xGraphics->drawLine     ( m_a3DLine.X, m_a3DLine.Y+1, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y+1 ) ;
     848                 :          0 : }
     849                 :            : 
     850                 :            : //____________________________________________________________________________________________________________
     851                 :            : //  private method
     852                 :            : //____________________________________________________________________________________________________________
     853                 :            : 
     854                 :          0 : void ProgressMonitor::impl_rebuildFixedText ()
     855                 :            : {
     856                 :            :     // Ready for multithreading
     857                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     858                 :            : 
     859                 :            :     // Rebuild fixedtext before progress
     860                 :            : 
     861                 :            :     // Rebuild left site of text
     862                 :          0 :     if (m_xTopic_Top.is())
     863                 :            :     {
     864                 :          0 :         OUString aCollectString ;
     865                 :            : 
     866                 :            :         // Collect all topics from list and format text.
     867                 :            :         // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
     868                 :          0 :         for ( size_t n = 0; n < maTextlist_Top.size(); ++n )
     869                 :            :         {
     870                 :          0 :             IMPL_TextlistItem* pSearchItem = maTextlist_Top[ n ];
     871                 :          0 :             aCollectString  +=  pSearchItem->sTopic ;
     872                 :          0 :             aCollectString  +=  "\n";
     873                 :            :         }
     874                 :          0 :         aCollectString  +=  "\0";   // It's better :-)
     875                 :            : 
     876                 :          0 :         m_xTopic_Top->setText ( aCollectString ) ;
     877                 :            :     }
     878                 :            : 
     879                 :            :     // Rebuild right site of text
     880                 :          0 :     if (m_xText_Top.is())
     881                 :            :     {
     882                 :          0 :         OUString        aCollectString  ;
     883                 :            : 
     884                 :            :         // Collect all topics from list and format text.
     885                 :            :         // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
     886                 :          0 :         for ( size_t n = 0; n < maTextlist_Top.size(); ++n )
     887                 :            :         {
     888                 :          0 :             IMPL_TextlistItem* pSearchItem = maTextlist_Top[ n ];
     889                 :          0 :             aCollectString  +=  pSearchItem->sText ;
     890                 :          0 :             aCollectString  +=  "\n";
     891                 :            :         }
     892                 :          0 :         aCollectString  +=  "\0";   // It's better :-)
     893                 :            : 
     894                 :          0 :         m_xText_Top->setText ( aCollectString ) ;
     895                 :            :     }
     896                 :            : 
     897                 :            :     // Rebuild fixedtext below progress
     898                 :            : 
     899                 :            :     // Rebuild left site of text
     900                 :          0 :     if (m_xTopic_Bottom.is())
     901                 :            :     {
     902                 :          0 :         OUString        aCollectString  ;
     903                 :            : 
     904                 :            :         // Collect all topics from list and format text.
     905                 :            :         // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
     906                 :          0 :         for ( size_t n = 0; n < maTextlist_Bottom.size(); ++n )
     907                 :            :         {
     908                 :          0 :             IMPL_TextlistItem* pSearchItem = maTextlist_Bottom[ n ];
     909                 :          0 :             aCollectString  +=  pSearchItem->sTopic ;
     910                 :          0 :             aCollectString  +=  "\n";
     911                 :            :         }
     912                 :          0 :         aCollectString  +=  "\0";   // It's better :-)
     913                 :            : 
     914                 :          0 :         m_xTopic_Bottom->setText ( aCollectString ) ;
     915                 :            :     }
     916                 :            : 
     917                 :            :     // Rebuild right site of text
     918                 :          0 :     if (m_xText_Bottom.is())
     919                 :            :     {
     920                 :          0 :         OUString        aCollectString  ;
     921                 :            : 
     922                 :            :         // Collect all topics from list and format text.
     923                 :            :         // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
     924                 :          0 :         for ( size_t n = 0; n < maTextlist_Bottom.size(); ++n )
     925                 :            :         {
     926                 :          0 :             IMPL_TextlistItem* pSearchItem = maTextlist_Bottom[ n ];
     927                 :          0 :             aCollectString  +=  pSearchItem->sText ;
     928                 :          0 :             aCollectString  +=  "\n";
     929                 :            :         }
     930                 :          0 :         aCollectString  +=  "\0";   // It's better :-)
     931                 :            : 
     932                 :          0 :         m_xText_Bottom->setText ( aCollectString ) ;
     933                 :          0 :     }
     934                 :          0 : }
     935                 :            : 
     936                 :            : //____________________________________________________________________________________________________________
     937                 :            : //  private method
     938                 :            : //____________________________________________________________________________________________________________
     939                 :            : 
     940                 :          0 : void ProgressMonitor::impl_cleanMemory ()
     941                 :            : {
     942                 :            :     // Ready for multithreading
     943                 :          0 :     MutexGuard aGuard ( m_aMutex ) ;
     944                 :            : 
     945                 :            :     // Delete all of lists.
     946                 :            : 
     947                 :          0 :     for ( size_t nPosition = 0; nPosition < maTextlist_Top.size() ; ++nPosition )
     948                 :            :     {
     949                 :          0 :         IMPL_TextlistItem* pSearchItem = maTextlist_Top[ nPosition ];
     950                 :          0 :         delete pSearchItem ;
     951                 :            :     }
     952                 :          0 :     maTextlist_Top.clear();
     953                 :            : 
     954                 :          0 :     for ( size_t nPosition = 0; nPosition < maTextlist_Bottom.size() ; ++nPosition )
     955                 :            :     {
     956                 :          0 :         IMPL_TextlistItem* pSearchItem = maTextlist_Bottom[ nPosition ];
     957                 :          0 :         delete pSearchItem ;
     958                 :            :     }
     959                 :          0 :     maTextlist_Bottom.clear();
     960                 :          0 : }
     961                 :            : 
     962                 :            : //____________________________________________________________________________________________________________
     963                 :            : //  private method
     964                 :            : //____________________________________________________________________________________________________________
     965                 :            : 
     966                 :          0 : IMPL_TextlistItem* ProgressMonitor::impl_searchTopic ( const OUString& rTopic, sal_Bool bbeforeProgress )
     967                 :            : {
     968                 :            :     // Get right textlist for following operations.
     969                 :            :     ::std::vector< IMPL_TextlistItem* >* pTextList ;
     970                 :            : 
     971                 :            :     // Ready for multithreading
     972                 :          0 :     ClearableMutexGuard aGuard ( m_aMutex ) ;
     973                 :            : 
     974                 :          0 :     if ( bbeforeProgress == sal_True )
     975                 :            :     {
     976                 :          0 :         pTextList = &maTextlist_Top    ;
     977                 :            :     }
     978                 :            :     else
     979                 :            :     {
     980                 :          0 :         pTextList = &maTextlist_Bottom ;
     981                 :            :     }
     982                 :            : 
     983                 :            :     // Switch off guard.
     984                 :          0 :     aGuard.clear () ;
     985                 :            : 
     986                 :            :     // Search the topic in textlist.
     987                 :          0 :     size_t nPosition    = 0;
     988                 :          0 :     size_t nCount       = pTextList->size();
     989                 :            : 
     990                 :          0 :     for ( nPosition = 0; nPosition < nCount ; ++nPosition )
     991                 :            :     {
     992                 :          0 :         IMPL_TextlistItem* pSearchItem = pTextList->at( nPosition );
     993                 :            : 
     994                 :          0 :         if ( pSearchItem->sTopic == rTopic )
     995                 :            :         {
     996                 :            :             // We have found this topic ... return a valid pointer.
     997                 :          0 :             return pSearchItem ;
     998                 :            :         }
     999                 :            :     }
    1000                 :            : 
    1001                 :            :     // We have'nt found this topic ... return a nonvalid pointer.
    1002                 :          0 :     return NULL ;
    1003                 :            : }
    1004                 :            : 
    1005                 :            : //____________________________________________________________________________________________________________
    1006                 :            : //  debug methods
    1007                 :            : //____________________________________________________________________________________________________________
    1008                 :            : 
    1009                 :            : #ifdef DBG_UTIL
    1010                 :            : 
    1011                 :            : // addText, updateText
    1012                 :            : sal_Bool ProgressMonitor::impl_debug_checkParameter (
    1013                 :            :     const OUString& rTopic,
    1014                 :            :     const OUString& rText,
    1015                 :            :     sal_Bool /*bbeforeProgress*/
    1016                 :            : ) {
    1017                 :            :     // Check "rTopic"
    1018                 :            :     if ( &rTopic        ==  NULL    ) return sal_False ;    // NULL-pointer for reference ???!!!
    1019                 :            :     if ( rTopic.isEmpty()       ) return sal_False ;    // ""
    1020                 :            : 
    1021                 :            :     // Check "rText"
    1022                 :            :     if ( &rText         ==  NULL    ) return sal_False ;    // NULL-pointer for reference ???!!!
    1023                 :            :     if ( rText.isEmpty()       ) return sal_False ;    // ""
    1024                 :            : 
    1025                 :            :     // "bbeforeProgress" is valid in everyway!
    1026                 :            : 
    1027                 :            :     // Parameter OK ... return sal_True.
    1028                 :            :     return sal_True ;
    1029                 :            : }
    1030                 :            : 
    1031                 :            : // removeText
    1032                 :            : sal_Bool ProgressMonitor::impl_debug_checkParameter ( const OUString& rTopic, sal_Bool /*bbeforeProgress*/ )
    1033                 :            : {
    1034                 :            :     // Check "rTopic"
    1035                 :            :     if ( &rTopic        ==  NULL    ) return sal_False ;    // NULL-pointer for reference ???!!!
    1036                 :            :     if ( rTopic.isEmpty()      ) return sal_False ;    // ""
    1037                 :            : 
    1038                 :            :     // "bbeforeProgress" is valid in everyway!
    1039                 :            : 
    1040                 :            :     // Parameter OK ... return sal_True.
    1041                 :            :     return sal_True ;
    1042                 :            : }
    1043                 :            : 
    1044                 :            : #endif  // #ifdef DBG_UTIL
    1045                 :            : 
    1046                 :            : }   // namespace unocontrols
    1047                 :            : 
    1048                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10