User: obo     
Date: 2006/07/10 08:24:00

Modified:
   dba/dbaccess/source/ui/browser/genericcontroller.cxx

Log:
 INTEGRATION: CWS qiq (1.68.10); FILE MERGED
 2006/07/04 14:34:44 fs 1.68.10.6: reverted a previous change which just worked 
around a bug in framework - now fixed this bug (#i66983#) properly
 2006/07/03 14:09:34 fs 1.68.10.5: bug in framework - order of status 
notification matters for check-items in toolboxes
 2006/06/27 12:16:50 fs 1.68.10.4: RESYNC: (1.68-1.69); FILE MERGED
 2006/06/19 10:10:33 fs 1.68.10.3: proper cache check
 2006/06/19 09:27:50 fs 1.68.10.2: during #i51143#: A FeatureState can now 
transport more than one state. In particular, it has typed bChecked and sTitle 
members, instead of the previous unchecked aState
 2006/05/12 13:47:00 fs 1.68.10.1: #i51143# refactoring of controller 
initialization, which allows accessing the load arguments even during Construct 
(and not only in the - later - impl_initialize)

File Changes:

Directory: /dba/dbaccess/source/ui/browser/
===========================================

File [changed]: genericcontroller.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/browser/genericcontroller.cxx?r1=1.69&r2=1.70
Delta lines:  +60 -47
---------------------
--- genericcontroller.cxx       20 Jun 2006 02:58:07 -0000      1.69
+++ genericcontroller.cxx       10 Jul 2006 15:23:57 -0000      1.70
@@ -237,7 +237,7 @@
        return VCLUnoHelper::GetInterface( getView() );
 }
 // 
-----------------------------------------------------------------------------
-void OGenericUnoController::impl_initialize(const Sequence< Any >& 
/*aArguments*/)
+void OGenericUnoController::impl_initialize()
 {
 }
 // -------------------------------------------------------------------------
@@ -283,6 +283,7 @@
                                throw 
Exception(::rtl::OUString::createFromAscii("Parent window is null"),*this);
                        }
 
+            m_aInitParameters.assign( aArguments );
                        Construct( pParentWin );
             if ( !getView() )
                 throw Exception(::rtl::OUString::createFromAscii("Window is 
null"),*this);
@@ -294,7 +295,8 @@
                ODataView* pView = getView();
                if ( (m_bReadOnly || m_bPreview) && pView )
                        pView->EnableInput(FALSE);
-               impl_initialize(aArguments);
+
+        impl_initialize();
        }
        catch(Exception& e)
        {
@@ -430,49 +432,54 @@
 };
 
 // -----------------------------------------------------------------------
+namespace
+{
+    typedef ::std::vector< Any >    States;
+
+    // ...................................................................
+    void    lcl_notifyMultipleStates( XStatusListener& _rListener, 
FeatureStateEvent& _rEvent, const States& _rStates )
+    {
+        for (   States::const_iterator state = _rStates.begin();
+                state != _rStates.end();
+                ++state
+            )
+        {
+            _rEvent.State = *state;
+            _rListener.statusChanged( _rEvent );
+        }
+    }
+
+    // ...................................................................
+    void    lcl_collectStates( const FeatureState& _rFeatureState, States& 
_out_rStates )
+    {
+        if ( !!_rFeatureState.bChecked )
+            _out_rStates.push_back( makeAny( 
(sal_Bool)*_rFeatureState.bChecked ) );
+        if ( !!_rFeatureState.sTitle )
+            _out_rStates.push_back( makeAny( *_rFeatureState.sTitle ) );
+        if ( _out_rStates.empty() )
+            _out_rStates.push_back( Any() );
+    }
+}
+
+// -----------------------------------------------------------------------
 void OGenericUnoController::ImplBroadcastFeatureState(const ::rtl::OUString& 
_rFeature, const Reference< XStatusListener > & xListener, sal_Bool 
_bIgnoreCache)
 {
        sal_uInt16 nFeat = m_aSupportedFeatures[ _rFeature ].nFeatureId;
        FeatureState aFeatState( GetState( nFeat ) );
 
        FeatureState& rCachedState = m_aStateCache[nFeat];      // creates if 
neccessary
-
-       if(!_bIgnoreCache)
+       if ( !_bIgnoreCache )
        {
                // check if we really need to notify the listeners : this 
method may be called much more often than needed, so check
                // the cached state of the feature
-               sal_Bool bAlreadyCached = (m_aStateCache.find(nFeat) != 
m_aStateCache.end());
-               if (bAlreadyCached && (rCachedState.bEnabled == 
aFeatState.bEnabled))
-               {       // the enabled flag hasn't changed, maybe the state ?
-                       if (rCachedState.aState.getValueTypeClass() == 
aFeatState.aState.getValueTypeClass())
-                       {       // at least the type of the state hasn't
-                               sal_Bool bEqualValue = sal_False;
-                               switch (rCachedState.aState.getValueTypeClass())
-                               {
-                                       case TypeClass_VOID:
-                                               bEqualValue = 
!aFeatState.aState.hasValue();
-                                               break;
-                                       case TypeClass_BOOLEAN:
-                                               bEqualValue = 
::comphelper::getBOOL(rCachedState.aState) == 
::comphelper::getBOOL(aFeatState.aState);
-                                               break;
-                                       case TypeClass_SHORT:
-                                               bEqualValue = 
::comphelper::getINT16(rCachedState.aState) == 
::comphelper::getINT16(aFeatState.aState);
-                                               break;
-                                       case TypeClass_LONG:
-                                               bEqualValue = 
::comphelper::getINT32(rCachedState.aState) == 
::comphelper::getINT32(aFeatState.aState);
-                                               break;
-                                       case TypeClass_STRING:
-                                               bEqualValue = 
::comphelper::getString(rCachedState.aState).equals(::comphelper::getString(aFeatState.aState));
-                                               break;
-                                       default:
-                                               
DBG_ERROR("OGenericUnoController::ImplBroadcastFeatureState : unknown state 
type (not implemented yet) !");
-                                               break;
-                               }
-                               if (bEqualValue)
+               sal_Bool bAlreadyCached = ( m_aStateCache.find(nFeat) != 
m_aStateCache.end() );
+               if ( bAlreadyCached )
+            if  (   ( rCachedState.bEnabled == aFeatState.bEnabled )
+                &&  ( rCachedState.bChecked == aFeatState.bChecked )
+                &&  ( rCachedState.sTitle == aFeatState.sTitle )
+                )
                                        return;
                        }
-               }
-       }
        rCachedState = aFeatState;
 
        FeatureStateEvent aEvent;
@@ -481,12 +488,14 @@
                m_xUrlTransformer->parseStrict(aEvent.FeatureURL);
        aEvent.Source           = (XDispatch*)this;
        aEvent.IsEnabled        = aFeatState.bEnabled;
-       aEvent.Requery          = aFeatState.bRequery;
-       aEvent.State            = aFeatState.aState;
+
+    // collect all states to be notified
+    States aStates;
+    lcl_collectStates( aFeatState, aStates );
 
        // a special listener ?
-       if (xListener.is())
-               xListener->statusChanged(aEvent);
+       if ( xListener.is() )
+        lcl_notifyMultipleStates( *xListener.get(), aEvent, aStates );
        else
        {       // no -> iterate through all listeners responsible for the URL
         StringBag aFeatureCommands;
@@ -509,10 +518,8 @@
                        DispatchTarget& rCurrent = *iterSearch;
                        if ( aFeatureCommands.find( rCurrent.aURL.Complete ) != 
aFeatureCommands.end() )
                        {
-                               aEvent.FeatureURL.Complete = 
rCurrent.aURL.Complete;
-                               if (m_xUrlTransformer.is())
-                                       
m_xUrlTransformer->parseStrict(aEvent.FeatureURL);
-                               rCurrent.xListener->statusChanged(aEvent);
+                               aEvent.FeatureURL = rCurrent.aURL;
+                lcl_notifyMultipleStates( *rCurrent.xListener.get(), aEvent, 
aStates );
                        }
                        ++iterSearch;
                }
@@ -730,10 +737,16 @@
 // -----------------------------------------------------------------------
 void OGenericUnoController::addStatusListener(const Reference< XStatusListener 
> & aListener, const URL& _rURL) throw(RuntimeException)
 {
+    // parse the ULR now and here, this saves later parsing in each 
notification round
+    URL aParsedURL( _rURL );
+       if ( m_xUrlTransformer.is() )
+               m_xUrlTransformer->parseStrict( aParsedURL );
+
        // remeber the listener together with the URL
-       m_arrStatusListener.insert(m_arrStatusListener.end(), 
DispatchTarget(_rURL, aListener));
+       m_arrStatusListener.insert( m_arrStatusListener.end(), DispatchTarget( 
aParsedURL, aListener ) );
+
        // initially broadcast the state
-       ImplBroadcastFeatureState(_rURL.Complete, aListener, sal_True);
+       ImplBroadcastFeatureState( aParsedURL.Complete, aListener, sal_True );
                // force the new state to be broadcasted to the new listener
 }
 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to