User: hr      
Date: 06/04/19 06:20:11

Modified:
 /dba/dbaccess/source/ui/control/
  toolboxcontroller.cxx

Log:
 INTEGRATION: CWS oj17 (1.8.96); FILE MERGED
 2006/04/11 06:55:30 oj 1.8.96.3: #i53480# change item text
 2006/03/10 10:26:39 oj 1.8.96.2: #i53480# change commandurl to selected entry
 2006/03/09 07:02:08 oj 1.8.96.1: #i53480# change commandurl to selected entry

File Changes:

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

File [changed]: toolboxcontroller.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/control/toolboxcontroller.cxx?r1=1.8&r2=1.9
Delta lines:  +67 -35
---------------------
--- toolboxcontroller.cxx       23 Sep 2005 12:24:30 -0000      1.8
+++ toolboxcontroller.cxx       19 Apr 2006 13:20:09 -0000      1.9
@@ -96,7 +96,6 @@
 #include "UITools.hxx"
 #endif
 
-#include <memory>
 
 extern "C" void SAL_CALL createRegistryInfo_OToolboxController()
 {
@@ -113,6 +112,20 @@
        using namespace ::com::sun::star::util;
        using namespace ::com::sun::star::ui;
 
+    namespace
+    {
+        void lcl_copy(Menu* _pMenu,USHORT _nMenuId,USHORT _nMenuPos,ToolBox* 
_pToolBox,USHORT _nToolId,const ::rtl::OUString& _sCommand)
+        {
+            if ( _pMenu->GetItemType(_nMenuPos) != MENUITEM_STRING )
+                _pToolBox->SetItemImage(_nToolId, 
_pMenu->GetItemImage(_nMenuId));
+            _pToolBox->SetItemCommand( _nToolId, _sCommand);
+            _pToolBox->SetHelpId(_nToolId, _pMenu->GetHelpId(_nMenuId));
+            _pToolBox->SetHelpText(_nToolId, _pMenu->GetHelpText(_nMenuId));
+            _pToolBox->SetQuickHelpText(_nToolId, 
_pMenu->GetTipHelpText(_nMenuId));
+            _pToolBox->SetItemText(_nToolId, _pMenu->GetItemText(_nMenuId));
+        }
+    }
+
        OToolboxController::OToolboxController(const Reference< 
XMultiServiceFactory >& _rxORB)
                : m_nToolBoxId(1)
        {
@@ -151,19 +164,18 @@
 
                if ( m_aCommandURL.equalsAscii(".uno:DBNewForm") )
                {
-                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewForm")),sal_True));
-                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewView")),sal_True));
-                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewViewSQL")),sal_True));
-                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewQuery")),sal_True));
-                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewQuerySql")),sal_True));
-                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewForm")),sal_True));
+                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewForm"))
           ,sal_True));
+                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewView"))
           ,sal_True));
+                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewViewSQL"))
        ,sal_True));
+                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewQuery"))
          ,sal_True));
+                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewQuerySql"))
       ,sal_True));
                        
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewReportAutoPilot")),sal_True));
-                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewTable")),sal_True));
+                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewTable"))
          ,sal_True));
                }
                else
                {
-                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Refresh")),sal_True));
-                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBRebuildData")),sal_True));
+                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Refresh"))
         ,sal_True));
+                       
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBRebuildData"))
   ,sal_True));
                }
 
                TCommandState::iterator aIter = m_aStates.begin();
@@ -191,26 +203,43 @@
        // 
-----------------------------------------------------------------------------
        void SAL_CALL OToolboxController::statusChanged( const 
FeatureStateEvent& Event ) throw ( RuntimeException )
        {
+        vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
                ::osl::MutexGuard aGuard(m_aMutex);     
                TCommandState::iterator aFind = m_aStates.find( 
Event.FeatureURL.Complete );
                if ( aFind != m_aStates.end() )
+        {
                        aFind->second = Event.IsEnabled;
-       }
-       // 
-----------------------------------------------------------------------------
-       Reference< ::com::sun::star::awt::XWindow > SAL_CALL 
OToolboxController::createPopupWindow() throw (RuntimeException)
+            if ( m_aCommandURL == aFind->first && !Event.IsEnabled )
        {
-               // execute the menu
-               vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
-               ::osl::MutexGuard aGuard(m_aMutex);     
+                ::std::auto_ptr<PopupMenu> pMenu = getMenu();
+                USHORT nCount = pMenu->GetItemCount();
+                for (USHORT i = 0; i < nCount; ++i)
+                {
+                    USHORT nItemId = pMenu->GetItemId(i);
+                    aFind = m_aStates.find(pMenu->GetItemCommand(nItemId));
+                    if ( aFind != m_aStates.end() && aFind->second )
+                    {
+                        m_aCommandURL = aFind->first;
 
                ToolBox* pToolBox = 
static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+                        lcl_copy(pMenu.get(),nItemId,i,pToolBox,m_nToolBoxId, 
m_aCommandURL);
+                        break;
+                    }
+                }
+            }
+        }
+       }
+    // 
-----------------------------------------------------------------------------
+    ::std::auto_ptr<PopupMenu> OToolboxController::getMenu()
+    {
                ::std::auto_ptr<PopupMenu> pMenu;
-               if ( m_aCommandURL.equalsAscii(".uno:DBNewForm") )
+               if ( m_aStates.size() > 2 )
                {
                        pMenu.reset( new PopupMenu( ModuleRes( RID_MENU_APP_NEW 
) ) );
                        sal_Bool bIsWriterInstalled = 
SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER);
 
-                       sal_Bool bHighContrast = 
::dbaui::isHiContrast(pToolBox);
+            ToolBox* pToolBox = 
static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+                       sal_Bool bHighContrast = isHighContrast();
 
                        try
                        {
@@ -223,8 +252,6 @@
                                if ( bHighContrast )
                                        nImageType |= 
ImageType::COLOR_HIGHCONTRAST;
 
-                               Reference< XDispatchProvider >  
xProvider(getFrameInterface(), UNO_QUERY);
-
                                Sequence< ::rtl::OUString> aSeq(1);
                                USHORT nCount = pMenu->GetItemCount();
                                for (USHORT nPos = 0; nPos < nCount; ++nPos)
@@ -254,14 +281,17 @@
                {
                        pMenu.reset( new PopupMenu( ModuleRes( 
RID_MENU_REFRESH_DATA ) ) );
                }
+        return pMenu;
+    }
+       // 
-----------------------------------------------------------------------------
+       Reference< ::com::sun::star::awt::XWindow > SAL_CALL 
OToolboxController::createPopupWindow() throw (RuntimeException)
+       {
+               // execute the menu
+               vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+               ::osl::MutexGuard aGuard(m_aMutex);     
 
-//        // show disabled entries?
-//        if ( !SvtMenuOptions().IsEntryHidingEnabled() )
-//            pMenu->RemoveDisabledEntries();
-//        else
-//            // force showing disabled entries. Due to #102790#, popup menus 
automatically
-//            // set the MENU_FLAG_HIDEDISABLEDENTRIES flag
-//            pMenu->SetMenuFlags( MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
+               ToolBox* pToolBox = 
static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+        ::std::auto_ptr<PopupMenu> pMenu = getMenu();
 
                USHORT nSelected = pMenu->Execute(pToolBox, 
pToolBox->GetItemRect( m_nToolBoxId ),POPUPMENU_EXECUTE_DOWN);
                // "cleanup" the toolbox state
@@ -272,18 +302,20 @@
 
                if ( nSelected )
                {
-                       if ( pMenu->GetItemType(pMenu->GetItemPos(nSelected)) 
!= MENUITEM_STRING )
-                               pToolBox->SetItemImage(m_nToolBoxId, 
pMenu->GetItemImage(nSelected));
+            m_aCommandURL = pMenu->GetItemCommand(nSelected);
+            
lcl_copy(pMenu.get(),nSelected,pMenu->GetItemPos(nSelected),pToolBox,m_nToolBoxId,
 m_aCommandURL);
+
                        Reference<XDispatch> xDispatch = 
m_aListenerMap.find(m_aCommandURL)->second;
                        if ( xDispatch.is() )
                        {
                                URL aUrl;
                                Sequence < PropertyValue > aArgs;
-                               aUrl.Complete = 
pMenu->GetItemCommand(nSelected);
+                               aUrl.Complete = m_aCommandURL;
                                OSL_ENSURE(aUrl.Complete.getLength(),"Command 
is empty!");
                                if ( getURLTransformer().is() )
                                        getURLTransformer()->parseStrict(aUrl);
                                xDispatch->dispatch(aUrl,aArgs);
+                
                        }
                }
                return Reference< ::com::sun::star::awt::XWindow >();




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

Reply via email to