Tag: cws_src680_oj17
User: oj      
Date: 06/03/10 02:26:42

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

Log:
 #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.96.1&r2=1.8.96.2
Delta lines:  +54 -32
---------------------
--- toolboxcontroller.cxx       9 Mar 2006 07:02:08 -0000       1.8.96.1
+++ toolboxcontroller.cxx       10 Mar 2006 10:26:39 -0000      1.8.96.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: toolboxcontroller.cxx,v $
  *
- *  $Revision: 1.8.96.1 $
+ *  $Revision: 1.8.96.2 $
  *
- *  last change: $Author: oj $ $Date: 2006/03/09 07:02:08 $
+ *  last change: $Author: oj $ $Date: 2006/03/10 10:26:39 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -96,7 +96,6 @@
 #include "UITools.hxx"
 #endif
 
-#include <memory>
 
 extern "C" void SAL_CALL createRegistryInfo_OToolboxController()
 {
@@ -151,19 +150,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,25 +189,46 @@
        // 
-----------------------------------------------------------------------------
        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;
 
+                        if ( pMenu->GetItemType(i) != MENUITEM_STRING )
+                        {
                ToolBox* pToolBox = 
static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+                            pToolBox->SetItemImage(m_nToolBoxId, 
pMenu->GetItemImage(nItemId));
+                            pToolBox->SetItemCommand( m_nToolBoxId, 
m_aCommandURL);
+                        }
+                        break;
+                    }
+                }
+            }
+        }
+       }
+    // 
-----------------------------------------------------------------------------
+    ::std::auto_ptr<PopupMenu> OToolboxController::getMenu()
+    {
                ::std::auto_ptr<PopupMenu> pMenu;
                if ( m_aStates.size() > 2 )
                {
                        pMenu.reset( new PopupMenu( ModuleRes( RID_MENU_APP_NEW 
) ) );
                        sal_Bool bIsWriterInstalled = 
SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER);
 
+            ToolBox* pToolBox = 
static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
                        sal_Bool bHighContrast = 
::dbaui::isHiContrast(pToolBox);
 
                        try
@@ -223,8 +242,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 +271,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
@@ -274,10 +294,12 @@
                {
                        if ( pMenu->GetItemType(pMenu->GetItemPos(nSelected)) 
!= MENUITEM_STRING )
                                pToolBox->SetItemImage(m_nToolBoxId, 
pMenu->GetItemImage(nSelected));
+
+            m_aCommandURL = pMenu->GetItemCommand(nSelected);
+            pToolBox->SetItemCommand( m_nToolBoxId, m_aCommandURL);
                        Reference<XDispatch> xDispatch = 
m_aListenerMap.find(m_aCommandURL)->second;
                        if ( xDispatch.is() )
                        {
-                m_aCommandURL = pMenu->GetItemCommand(nSelected);
                                URL aUrl;
                                Sequence < PropertyValue > aArgs;
                                aUrl.Complete = m_aCommandURL;




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

Reply via email to