Tag: cws_dev300_dba31c
User: fs      
Date: 2008-09-03 12:04:03+0000
Modified:
   dba/dbaccess/source/ui/app/AppController.cxx
   dba/dbaccess/source/ui/app/AppController.hxx
   dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx
   dba/dbaccess/source/ui/app/AppDetailPageHelper.hxx
   dba/dbaccess/source/ui/app/IApplicationController.hxx

Log:
 #i93424# reworked the handling/notification of selection/changes of a 
DBTreeListBox

File Changes:

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

File [changed]: AppController.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.cxx?r1=1.65.2.1&r2=1.65.2.2
Delta lines:  +50 -43
---------------------
--- AppController.cxx   2008-09-03 11:56:14+0000        1.65.2.1
+++ AppController.cxx   2008-09-03 12:04:00+0000        1.65.2.2
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: AppController.cxx,v $
- * $Revision: 1.65.2.1 $
+ * $Revision: 1.65.2.2 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -2286,68 +2286,59 @@
         DBG_UNHANDLED_EXCEPTION();
        }
 }
-// 
-----------------------------------------------------------------------------
-void OApplicationController::onEntryDeSelect(SvTreeListBox& /*_rTree*/)
-{
-    SelectionGuard aSelGuard( *m_pSelectionNotifier );
 
-    InvalidateAll();
-}
 // 
-----------------------------------------------------------------------------
-void OApplicationController::onEntrySelect(SvLBoxEntry* _pEntry)
+void OApplicationController::onSelectionChanged()
 {
        InvalidateAll();
 
-       OApplicationView* pView = getContainer();
-       if ( pView )
-       {
         SelectionGuard aSelGuard( *m_pSelectionNotifier );
 
+       OApplicationView* pView = getContainer();
+    if ( !pView )
+        return;
+
+    if ( pView->getSelectionCount() == 1 )
+    {
         const ElementType eType = pView->getElementType();
-       if ( _pEntry && pView->isALeafSelected() )
+           if ( pView->isALeafSelected() )
            {
-            const ::rtl::OUString sName = pView->getQualifiedName( _pEntry );
-            selectEntry(eType,sName);
+            const ::rtl::OUString sName = pView->getQualifiedName( NULL /* 
means 'first selected' */ );
+            showPreviewFor( eType, sName );
         }
        }
 }
 // 
-----------------------------------------------------------------------------
-void OApplicationController::selectEntry(const ElementType _eType,const 
::rtl::OUString& _sName)
+void OApplicationController::showPreviewFor(const ElementType _eType,const 
::rtl::OUString& _sName)
 {
     OApplicationView* pView = getContainer();
-    Reference< XContent> xContent;
+    if ( !pView )
+        return;
+
        try
        {
                switch( _eType )
                {
                        case E_FORM:
                        case E_REPORT:
-                               if ( _sName.getLength() )
                                {
-                                       Reference< XHierarchicalNameAccess > 
xContainer(getElements(_eType),UNO_QUERY);
-                                       if ( xContainer.is() && 
xContainer->hasByHierarchicalName(_sName) )
-                                               
xContent.set(xContainer->getByHierarchicalName(_sName),UNO_QUERY);
+                               Reference< XHierarchicalNameAccess > 
xContainer( getElements( _eType ), UNO_QUERY_THROW );
+                Reference< XContent> xContent( 
xContainer->getByHierarchicalName( _sName ), UNO_QUERY_THROW );
+                   pView->showPreview( xContent );
                                }
                                break;
+
+            case E_TABLE:
                        case E_QUERY:
-                if ( pView->isPreviewEnabled() )
                 {
                     SharedConnection xConnection( ensureConnection() );
                                        if ( xConnection.is() )
-                                               
pView->showPreview(getDatabaseName(),xConnection,_sName,sal_False);
+                                               pView->showPreview( 
getDatabaseName(), xConnection, _sName, _eType == E_TABLE );
                 }
                                return;
-                       case E_TABLE:
-                               {
-                    SharedConnection xConnection( ensureConnection() );
-                                       if ( xConnection.is() )
-                                       {
-                                               
pView->showPreview(getDatabaseName(),xConnection,_sName,_eType == E_TABLE);
-                                               return;
-                                       }
-                               }
-                               break;
+
             default:
+                OSL_ENSURE( false, "OApplicationController::showPreviewFor: 
unexpected element type!" );
                 break;
                }
        }
@@ -2359,8 +2350,6 @@
        {
         DBG_UNHANDLED_EXCEPTION();
        }
-
-       pView->showPreview(xContent);
 }
 
 
//------------------------------------------------------------------------------
@@ -2378,21 +2367,21 @@
        return 0L;
 }
 // 
-----------------------------------------------------------------------------
-void OApplicationController::onCutEntry(SvLBoxEntry* /*_pEntry*/)
+void OApplicationController::onCutEntry()
 {
 }
 // 
-----------------------------------------------------------------------------
-void OApplicationController::onCopyEntry(SvLBoxEntry* /*_pEntry*/)
+void OApplicationController::onCopyEntry()
 {
        Execute(ID_BROWSER_COPY,Sequence<PropertyValue>());
 }
 // 
-----------------------------------------------------------------------------
-void OApplicationController::onPasteEntry(SvLBoxEntry* /*_pEntry*/)
+void OApplicationController::onPasteEntry()
 {
        Execute(ID_BROWSER_PASTE,Sequence<PropertyValue>());
 }
 // 
-----------------------------------------------------------------------------
-void OApplicationController::onDeleteEntry(SvLBoxEntry* /*_pEntry*/)
+void OApplicationController::onDeleteEntry()
 {
        ElementType eType = getContainer()->getElementType();
        sal_uInt16 nId = 0;
@@ -3034,7 +3023,25 @@
     Sequence< NamedDatabaseObject > aCurrentSelection;
     const ElementType eType( getContainer()->getElementType() );
     if ( eType != E_NONE )
+    {
         getContainer()->describeCurrentSelectionForType( eType, 
aCurrentSelection );
+        if ( aCurrentSelection.getLength() == 0 )
+        {   // if no objects are selected, add an entry to the sequence which 
describes the overall category
+            // which is selected currently
+            aCurrentSelection.realloc(1);
+            aCurrentSelection[0].Name = getDatabaseName();
+            switch ( eType )
+            {
+            case E_TABLE:   aCurrentSelection[0].Type = 
DatabaseObjectContainer::TABLES;   break;
+            case E_QUERY:   aCurrentSelection[0].Type = 
DatabaseObjectContainer::QUERIES;  break;
+            case E_FORM:    aCurrentSelection[0].Type = 
DatabaseObjectContainer::FORMS;    break;
+            case E_REPORT:  aCurrentSelection[0].Type = 
DatabaseObjectContainer::REPORTS;  break;
+            default:
+                OSL_ENSURE( false, "OApplicationController::getSelection: 
unexpected current element type!" );
+                break;
+            }
+        }
+    }
     return makeAny( aCurrentSelection );
 }
 // 
-----------------------------------------------------------------------------

File [changed]: AppController.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.hxx?r1=1.32&r2=1.32.2.1
Delta lines:  +9 -10
--------------------
--- AppController.hxx   2008-08-19 09:54:47+0000        1.32
+++ AppController.hxx   2008-09-03 12:04:01+0000        1.32.2.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: AppController.hxx,v $
- * $Revision: 1.32 $
+ * $Revision: 1.32.2.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -407,9 +407,9 @@
         */
         ::rtl::OUString getCurrentlySelectedName(sal_Int32& _rnCommandType) 
const;
 
-        /** select the give entry
+        /** shows the preview for the given entry
         */
-        void selectEntry(const ElementType _eType,const ::rtl::OUString& 
_sName);
+        void showPreviewFor( const ElementType _eType,const ::rtl::OUString& 
_sName );
 
         /** called when we just connected to a new, non-NULL model
 
@@ -524,12 +524,11 @@
         // IApplicationController
                virtual bool onEntryDoubleClick(SvTreeListBox& _rTree);
                virtual sal_Bool onContainerSelect(ElementType _eType);
-               virtual void onEntrySelect(SvLBoxEntry* _pEntry);
-               virtual void onEntryDeSelect(SvTreeListBox& _rTree);
-               virtual void onCutEntry(SvLBoxEntry* _pEntry);
-               virtual void onCopyEntry(SvLBoxEntry* _pEntry);
-               virtual void onPasteEntry(SvLBoxEntry* _pEntry);
-               virtual void onDeleteEntry(SvLBoxEntry* _pEntry);
+               virtual void onSelectionChanged();
+               virtual void onCutEntry();
+               virtual void onCopyEntry();
+               virtual void onPasteEntry();
+               virtual void onDeleteEntry();
                virtual void previewChanged( sal_Int32 _nMode);
                virtual void containerFound( const 
::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& 
_xContainer);
 

File [changed]: AppDetailPageHelper.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx?r1=1.33.38.1&r2=1.33.38.2
Delta lines:  +26 -45
---------------------
--- AppDetailPageHelper.cxx     2008-09-03 11:56:14+0000        1.33.38.1
+++ AppDetailPageHelper.cxx     2008-09-03 12:04:01+0000        1.33.38.2
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: AppDetailPageHelper.cxx,v $
- * $Revision: 1.33.38.1 $
+ * $Revision: 1.33.38.2 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -351,10 +351,10 @@
        {
                if ( m_pLists[i] )
                {
-            m_pLists[i]->clearCurrentSelectionEntry();
+            m_pLists[i]->clearCurrentSelection();
                        m_pLists[i]->Hide();
                        ::std::auto_ptr<DBTreeListBox> aTemp(m_pLists[i]);
-            m_pLists[i]->clearCurrentSelectionEntry();
+            m_pLists[i]->clearCurrentSelection();   // why a second time?
                        m_pLists[i] = NULL;
                }
 
@@ -379,9 +379,7 @@
        int nPos = getVisibleControlIndex();
        if ( nPos < E_ELEMENT_TYPE_COUNT )
        {
-               m_pLists[nPos]->lockAutoSelect();
                m_pLists[nPos]->SelectAll(TRUE);
-               m_pLists[nPos]->unlockAutoSelect();
        }
 }
 // 
-----------------------------------------------------------------------------
@@ -907,8 +905,7 @@
 
        _pTreeView->SetDoubleClickHdl(LINK(this, OAppDetailPageHelper, 
OnEntryDoubleClick));
        _pTreeView->SetEnterKeyHdl(LINK(this, OAppDetailPageHelper, 
OnEntryDoubleClick));
-       _pTreeView->SetSelectHdl(LINK(this, OAppDetailPageHelper, 
OnEntrySelectHdl));
-       _pTreeView->SetDeselectHdl(LINK(this, OAppDetailPageHelper, 
OnDeSelectHdl));
+       _pTreeView->SetSelChangeHdl(LINK(this, OAppDetailPageHelper, 
OnEntrySelChange));
 
        _pTreeView->setCutHandler(LINK(this, OAppDetailPageHelper, OnCutEntry));
        _pTreeView->setCopyHandler(LINK(this, OAppDetailPageHelper, 
OnCopyEntry));
@@ -1066,48 +1063,33 @@
     return bHandled ? 1L : 0L;
 }
 // 
-----------------------------------------------------------------------------
-IMPL_LINK(OAppDetailPageHelper, OnDeSelectHdl, SvTreeListBox*, _pTree)
+IMPL_LINK(OAppDetailPageHelper, OnEntrySelChange, void*, /*NOINTERESTEDIN*/)
 {
-    OSL_ENSURE( _pTree, "OAppDetailPageHelper, OnDeSelectHdl: invalid 
callback!" );
-       if ( _pTree != NULL )
-        getBorderWin().getView()->getAppController().onEntryDeSelect( *_pTree 
);
+       getBorderWin().getView()->getAppController().onSelectionChanged();
        return 1L;
 }
 // 
-----------------------------------------------------------------------------
-IMPL_LINK(OAppDetailPageHelper, OnEntrySelectHdl, SvLBoxEntry*, _pEntry)
+IMPL_LINK( OAppDetailPageHelper, OnCutEntry, void*, /*NOINTERESTEDIN*/ )
 {
-       if ( 1 == getSelectionCount() )
-       {
-               
getBorderWin().getView()->getAppController().onEntrySelect(_pEntry);
-       }
-       else
-       {
-               showPreview(NULL);
-       }
-       return 1L;
-}
-// 
-----------------------------------------------------------------------------
-IMPL_LINK( OAppDetailPageHelper, OnCutEntry, SvLBoxEntry*, _pEntry )
-{
-       getBorderWin().getView()->getAppController().onCutEntry(_pEntry);
+       getBorderWin().getView()->getAppController().onCutEntry();
        return 1L;
 }
 // 
-----------------------------------------------------------------------------
-IMPL_LINK( OAppDetailPageHelper, OnCopyEntry, SvLBoxEntry*, _pEntry )
+IMPL_LINK( OAppDetailPageHelper, OnCopyEntry, void*, /*NOINTERESTEDIN*/ )
 {
-       getBorderWin().getView()->getAppController().onCopyEntry(_pEntry);
+       getBorderWin().getView()->getAppController().onCopyEntry();
        return 1L;
 }
 // 
-----------------------------------------------------------------------------
-IMPL_LINK( OAppDetailPageHelper, OnPasteEntry, SvLBoxEntry*, _pEntry )
+IMPL_LINK( OAppDetailPageHelper, OnPasteEntry, void*, /*NOINTERESTEDIN*/ )
 {
-       getBorderWin().getView()->getAppController().onPasteEntry(_pEntry);
+       getBorderWin().getView()->getAppController().onPasteEntry();
        return 1L;
 }
 // 
-----------------------------------------------------------------------------
-IMPL_LINK( OAppDetailPageHelper, OnDeleteEntry, SvLBoxEntry*, _pEntry )
+IMPL_LINK( OAppDetailPageHelper, OnDeleteEntry, void*, /*NOINTERESTEDIN*/ )
 {
-       getBorderWin().getView()->getAppController().onDeleteEntry(_pEntry);
+       getBorderWin().getView()->getAppController().onDeleteEntry();
        return 1L;
 }
 // 
-----------------------------------------------------------------------------
@@ -1182,16 +1164,12 @@
                m_aTBPreview.SetItemText(SID_DB_APP_DISABLE_PREVIEW, 
m_aMenu->GetItemText(nSelectedAction));
                Resize();
 
+        // simulate a selectionChanged event at the controller, to force the 
preview to be updated
                if ( isPreviewEnabled() )
                {
-                       DBTreeListBox* pTree = getCurrentView();
-                       if ( pTree )
-                       {
-                               SvLBoxEntry* pEntry = pTree->GetSelectedEntry();
-                               if ( pEntry )
+            if ( getCurrentView() && getCurrentView()->FirstSelected() )
                                {
-                                       
getBorderWin().getView()->getAppController().onEntrySelect(pEntry);
-                               }
+                           
getBorderWin().getView()->getAppController().onSelectionChanged();
                        }
                }
                else
@@ -1255,9 +1233,12 @@
                        {
                                m_aPreview.Hide();
                                m_aDocumentInfo.Hide();
-                               DBTreeListBox* pTreeView = getCurrentView();
-                               if ( pTreeView )
-                                       pTreeView->clearCurrentSelectionEntry();
+
+                // Why the below code? It might have side effects, as the tree 
view needs to know
+                // its current selection for other purposes than the preview, 
too.
+//                             DBTreeListBox* pTreeView = getCurrentView();
+//                             if ( pTreeView )
+//                                     pTreeView->clearCurrentSelection();
                        }
                }
                catch( const Exception& )

File [changed]: AppDetailPageHelper.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailPageHelper.hxx?r1=1.15&r2=1.15.40.1
Delta lines:  +7 -9
-------------------
--- AppDetailPageHelper.hxx     2008-06-25 12:36:50+0000        1.15
+++ AppDetailPageHelper.hxx     2008-09-03 12:04:01+0000        1.15.40.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: AppDetailPageHelper.hxx,v $
- * $Revision: 1.15 $
+ * $Revision: 1.15.40.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -196,14 +196,12 @@
                DBTreeListBox* createSimpleTree( ULONG _nHelpId, const Image& 
_rImage, const Image& _rImageHC );
 
                DECL_LINK( OnEntryDoubleClick,                  SvTreeListBox* 
);
-               DECL_LINK( OnDeSelectHdl,                               
SvTreeListBox* );
+               DECL_LINK( OnEntrySelChange,                    void* );
 
-               DECL_LINK( OnEntrySelectHdl,                    SvLBoxEntry* );
-
-               DECL_LINK( OnCutEntry,                                  
SvLBoxEntry* );
-               DECL_LINK( OnCopyEntry,                                 
SvLBoxEntry* );
-               DECL_LINK( OnPasteEntry,                                
SvLBoxEntry* );
-               DECL_LINK( OnDeleteEntry,                               
SvLBoxEntry* );
+               DECL_LINK( OnCutEntry,                                  void* );
+               DECL_LINK( OnCopyEntry,                                 void* );
+               DECL_LINK( OnPasteEntry,                                void* );
+               DECL_LINK( OnDeleteEntry,                               void* );
 
                DECL_LINK(PreviewChangeHdl, void*);
                // click a TB slot

File [changed]: IApplicationController.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/IApplicationController.hxx?r1=1.2&r2=1.2.40.1
Delta lines:  +10 -24
---------------------
--- IApplicationController.hxx  2008-06-25 12:39:06+0000        1.2
+++ IApplicationController.hxx  2008-09-03 12:04:01+0000        1.2.40.1
@@ -7,7 +7,7 @@
 *
 * $RCSfile: IApplicationController.hxx,v $
 *
-* $Revision: 1.2 $
+* $Revision: 1.2.40.1 $
 *
 * This file is part of OpenOffice.org.
 *
@@ -71,37 +71,23 @@
                        @param  _pEntry
                                the selected entry
                */
-               virtual void onEntrySelect(SvLBoxEntry* _pEntry) = 0;
+               virtual void onSelectionChanged() = 0;
 
-        /** called when an entry in a tree view has been de-selected
-                       @param  _pTree
-                               The tree list box.
-               */
-               virtual void onEntryDeSelect(SvTreeListBox& _rTree) = 0;
-
-        /** called when a "Cut" command is executed for a tree view entry
-                       @param  _pEntry
-                               The entry which was cutted.
+        /** called when a "Cut" command is executed in a tree view
                */
-               virtual void onCutEntry(SvLBoxEntry* _pEntry) = 0;
+               virtual void onCutEntry() = 0;
 
-        /** called when a "Copy" command is executed for a tree view entry
-                       @param  _pEntry
-                               The entry which was cutted.
+        /** called when a "Copy" command is executed in a tree view
                */
-               virtual void onCopyEntry(SvLBoxEntry* _pEntry) = 0;
+               virtual void onCopyEntry() = 0;
 
-        /** called when a "Paste" command is executed for a tree view entry
-                       @param  _pEntry
-                               The entry which was cutted.
+        /** called when a "Paste" command is executed in a tree view
                */
-               virtual void onPasteEntry(SvLBoxEntry* _pEntry) = 0;
+               virtual void onPasteEntry() = 0;
 
-        /** called when a "Delete" command is executed for a tree view entry
-                       @param  _pEntry
-                               The entry which was cutted.
+        /** called when a "Delete" command is executed in a tree view
                */
-               virtual void onDeleteEntry(SvLBoxEntry* _pEntry) = 0;
+               virtual void onDeleteEntry() = 0;
 
         /// called when the preview mode was changed
                virtual void previewChanged( sal_Int32 _nMode ) = 0;




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

Reply via email to