dbaccess/source/ui/app/AppDetailView.cxx |   24 +++++++++++++++++-------
 dbaccess/source/ui/app/AppDetailView.hxx |    4 +++-
 2 files changed, 20 insertions(+), 8 deletions(-)

New commits:
commit 6ad2f463784a24c566477cdd60ae729651bb8564
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Aug 8 14:06:49 2020 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Aug 10 10:24:30 2020 +0200

    restore removing the entries which are not enabled currently
    
    Change-Id: If24474e362aa80a3a0240a6ab899aa9e71066aef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100389
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/dbaccess/source/ui/app/AppDetailView.cxx 
b/dbaccess/source/ui/app/AppDetailView.cxx
index 2f77244699d3..e6e318c661d4 100644
--- a/dbaccess/source/ui/app/AppDetailView.cxx
+++ b/dbaccess/source/ui/app/AppDetailView.cxx
@@ -51,10 +51,11 @@ using namespace ::com::sun::star::beans;
 using ::com::sun::star::util::URL;
 using ::com::sun::star::sdb::application::NamedDatabaseObject;
 
-TaskEntry::TaskEntry( const char* _pAsciiUNOCommand, const char* _pHelpID, 
const char* pTitleResourceID )
+TaskEntry::TaskEntry( const char* _pAsciiUNOCommand, const char* _pHelpID, 
const char* pTitleResourceID, bool _bHideWhenDisabled )
     :sUNOCommand( OUString::createFromAscii( _pAsciiUNOCommand ) )
     ,pHelpID( _pHelpID )
     ,sTitle( DBA_RES(pTitleResourceID) )
+    ,bHideWhenDisabled( _bHideWhenDisabled )
 {
 }
 
@@ -341,9 +342,7 @@ void OApplicationDetailView::impl_createPage( ElementType 
_eType, const Referenc
     Resize();
 }
 
-namespace {
-
-void impl_fillTaskPaneData(ElementType _eType, TaskPaneData& _rData)
+void OApplicationDetailView::impl_fillTaskPaneData(ElementType _eType, 
TaskPaneData& _rData) const
 {
     TaskEntryList& rList( _rData.aTasks );
     rList.clear(); rList.reserve( 4 );
@@ -353,7 +352,7 @@ void impl_fillTaskPaneData(ElementType _eType, 
TaskPaneData& _rData)
     case E_TABLE:
         rList.emplace_back( ".uno:DBNewTable", 
RID_STR_TABLES_HELP_TEXT_DESIGN, RID_STR_NEW_TABLE );
         rList.emplace_back( ".uno:DBNewTableAutoPilot", 
RID_STR_TABLES_HELP_TEXT_WIZARD, RID_STR_NEW_TABLE_AUTO );
-        rList.emplace_back( ".uno:DBNewView", RID_STR_VIEWS_HELP_TEXT_DESIGN, 
RID_STR_NEW_VIEW );
+        rList.emplace_back( ".uno:DBNewView", RID_STR_VIEWS_HELP_TEXT_DESIGN, 
RID_STR_NEW_VIEW, true );
         _rData.pTitleId = RID_STR_TABLES_CONTAINER;
         break;
 
@@ -364,7 +363,7 @@ void impl_fillTaskPaneData(ElementType _eType, 
TaskPaneData& _rData)
         break;
 
     case E_REPORT:
-        rList.emplace_back( ".uno:DBNewReport", RID_STR_REPORT_HELP_TEXT, 
RID_STR_NEW_REPORT );
+        rList.emplace_back( ".uno:DBNewReport", RID_STR_REPORT_HELP_TEXT, 
RID_STR_NEW_REPORT, true );
         rList.emplace_back( ".uno:DBNewReportAutoPilot", 
RID_STR_REPORTS_HELP_TEXT_WIZARD, RID_STR_NEW_REPORT_AUTO );
         _rData.pTitleId = RID_STR_REPORTS_CONTAINER;
         break;
@@ -379,8 +378,19 @@ void impl_fillTaskPaneData(ElementType _eType, 
TaskPaneData& _rData)
     default:
         OSL_FAIL( "OApplicationDetailView::impl_fillTaskPaneData: illegal 
element type!" );
     }
-}
 
+    // remove the entries which are not enabled currently
+    for (TaskEntryList::iterator pTask = rList.begin(); pTask != rList.end();)
+    {
+        if  (   pTask->bHideWhenDisabled
+            &&  
!getBorderWin().getView()->getCommandController().isCommandEnabled( 
pTask->sUNOCommand )
+            )
+            pTask = rList.erase( pTask );
+        else
+        {
+            ++pTask;
+        }
+    }
 }
 
 const TaskPaneData& OApplicationDetailView::impl_getTaskPaneData( ElementType 
_eType )
diff --git a/dbaccess/source/ui/app/AppDetailView.hxx 
b/dbaccess/source/ui/app/AppDetailView.hxx
index bca1145f2010..a00e7f4ba642 100644
--- a/dbaccess/source/ui/app/AppDetailView.hxx
+++ b/dbaccess/source/ui/app/AppDetailView.hxx
@@ -47,11 +47,12 @@ namespace dbaui
         OUString        sUNOCommand;
         const char*     pHelpID;
         OUString        sTitle;
+        bool            bHideWhenDisabled;
             // TODO: we should be consistent in the task pane and the 
menus/toolbars:
             // If an entry is disabled in the latter, it should also be 
disabled in the former.
             // If an entry is *hidden* in the former, it should also be hidden 
in the latter.
 
-        TaskEntry( const char* _pAsciiUNOCommand, const char* pHelpID, const 
char* pTitleResourceID );
+        TaskEntry( const char* _pAsciiUNOCommand, const char* pHelpID, const 
char* pTitleResourceID, bool _bHideWhenDisabled = false );
     };
     typedef std::vector< TaskEntry >  TaskEntryList;
 
@@ -313,6 +314,7 @@ namespace dbaui
                             );
 
         const TaskPaneData& impl_getTaskPaneData( ElementType _eType );
+        void                impl_fillTaskPaneData( ElementType _eType, 
TaskPaneData& _rData ) const;
     };
 }
 #endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILVIEW_HXX
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to