[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - include/sfx2 sfx2/source

Jim Raykowski raykowj at gmail.com
Tue Jun 5 07:05:46 UTC 2018


 include/sfx2/sidebar/FocusManager.hxx |    1 
 include/sfx2/sidebar/Sidebar.hxx      |    2 
 sfx2/source/dialog/templdlg.cxx       |   82 +++++++++++++++-------------------
 sfx2/source/inc/templdgi.hxx          |    2 
 sfx2/source/sidebar/FocusManager.cxx  |    5 ++
 sfx2/source/sidebar/Sidebar.cxx       |    5 +-
 sfx2/source/view/viewfrm.cxx          |    4 -
 7 files changed, 52 insertions(+), 49 deletions(-)

New commits:
commit 47ccfe2c92027458287bd91f9df891e319e08d04
Author: Jim Raykowski <raykowj at gmail.com>
Date:   Sun Apr 8 13:45:09 2018 -0800

    tdf#101915 move focus to sidebar styles panel
    
    Change-Id: I3a150761a401caf1e76b5ec0ee36e537c14df8e0
    Reviewed-on: https://gerrit.libreoffice.org/52612
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Heiko Tietze <tietze.heiko at gmail.com>
    (cherry picked from commit b5af679c74774036de323b687a3901bd8f97a09b)
    Reviewed-on: https://gerrit.libreoffice.org/55305

diff --git a/include/sfx2/sidebar/FocusManager.hxx b/include/sfx2/sidebar/FocusManager.hxx
index b9297f48aa7c..84464c4b475f 100644
--- a/include/sfx2/sidebar/FocusManager.hxx
+++ b/include/sfx2/sidebar/FocusManager.hxx
@@ -62,6 +62,7 @@ public:
         pressing the F6 key.
     */
     void GrabFocus();
+    void GrabFocusPanel();
 
     void SetDeckTitle(DeckTitleBar* pDeckTitleBar);
     void SetPanels(const SharedPanelContainer& rPanels);
diff --git a/include/sfx2/sidebar/Sidebar.hxx b/include/sfx2/sidebar/Sidebar.hxx
index edf184d707b7..c9feb77a54b6 100644
--- a/include/sfx2/sidebar/Sidebar.hxx
+++ b/include/sfx2/sidebar/Sidebar.hxx
@@ -39,7 +39,7 @@ public:
     */
     static void ShowPanel (
         const OUString& rsPanelId,
-        const css::uno::Reference<css::frame::XFrame>& rxFrame);
+        const css::uno::Reference<css::frame::XFrame>& rxFrame, bool bFocus = false);
 
     /** Switch to the deck that contains the specified panel and toggle
         the visibility of the panel (expanded and scrolled into the
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 3b9f53f6431c..ab6c3077cffa 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -639,12 +639,14 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl
     , pIdle(nullptr)
     , pStyleFamilies(nullptr)
     , pStyleSheetPool(nullptr)
-    , pTreeBox(nullptr)
     , pCurObjShell(nullptr)
     , xModuleManager(frame::ModuleManager::create(::comphelper::getProcessComponentContext()))
     , m_pDeletionWatcher(nullptr)
 
     , aFmtLb( VclPtr<SfxActionListBox>::Create(this, WB_BORDER | WB_TABSTOP | WB_SORT) )
+    , pTreeBox( VclPtr<StyleTreeListBox_Impl>::Create(this, WB_HASBUTTONS | WB_HASLINES |
+                                                      WB_BORDER | WB_TABSTOP | WB_HASLINESATROOT |
+                                                      WB_HASBUTTONSATROOT | WB_HIDESELECTION) )
     , aPreviewCheckbox( VclPtr<CheckBox>::Create( pW, WB_VCENTER ))
     , aFilterLb( VclPtr<ListBox>::Create(pW, WB_BORDER | WB_DROPDOWN | WB_TABSTOP) )
 
@@ -677,6 +679,10 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl
     vcl::Font aFont = aFmtLb->GetFont();
     aFont.SetWeight( WEIGHT_NORMAL );
     aFmtLb->SetFont( aFont );
+    pTreeBox->SetQuickSearch(true);
+    pTreeBox->SetNodeDefaultImages();
+    pTreeBox->SetOptimalImageIndent();
+    pTreeBox->SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST));
     aPreviewCheckbox->Check(officecfg::Office::Common::StylesAndFormatting::Preview::get());
     aPreviewCheckbox->SetText( SfxResId(STR_PREVIEW_CHECKBOX) );
 }
@@ -832,6 +838,9 @@ void SfxCommonTemplateDialog_Impl::Initialize()
     aFmtLb->SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl, TreeListApplyHdl ) );
     aFmtLb->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FmtSelectHdl ) );
     aFmtLb->SetSelectionMode(SelectionMode::Multiple);
+    pTreeBox->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FmtSelectHdl ) );
+    pTreeBox->SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl,  ApplyHdl ) );
+    pTreeBox->SetDropHdl( LINK( this, SfxCommonTemplateDialog_Impl,  DropHdl ) );
     aPreviewCheckbox->SetClickHdl( LINK(this, SfxCommonTemplateDialog_Impl, PreviewHdl));
 
 
@@ -895,7 +904,7 @@ void SfxCommonTemplateDialog_Impl::GetSelectedStyle() const
  */
 bool SfxCommonTemplateDialog_Impl::IsSafeForWaterCan() const
 {
-    if ( pTreeBox.get() != nullptr )
+    if ( pTreeBox->IsVisible() )
         return pTreeBox->FirstSelected() != nullptr;
     else
         return aFmtLb->GetSelectionCount() == 1;
@@ -922,7 +931,7 @@ void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr)
         EnableShow( false );
     }
 
-    if ( pTreeBox )
+    if ( pTreeBox->IsVisible() )
     {
         if ( !rStr.isEmpty() )
         {
@@ -977,7 +986,7 @@ void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr)
 OUString SfxCommonTemplateDialog_Impl::GetSelectedEntry() const
 {
     OUString aRet;
-    if ( pTreeBox )
+    if ( pTreeBox->IsVisible() )
     {
         SvTreeListEntry* pEntry = pTreeBox->FirstSelected();
         if ( pEntry )
@@ -997,7 +1006,7 @@ void SfxCommonTemplateDialog_Impl::EnableTreeDrag( bool bEnable )
     if ( pStyleSheetPool )
     {
         SfxStyleSheetBase* pStyle = pStyleSheetPool->First();
-        if ( pTreeBox )
+        if ( pTreeBox->IsVisible() )
         {
             if ( pStyle && pStyle->HasParentSupport() && bEnable )
                 pTreeBox->SetDragDropMode(DragDropMode::CTRL_MOVE);
@@ -1071,7 +1080,7 @@ void SfxCommonTemplateDialog_Impl::FillTreeBox()
 
 bool SfxCommonTemplateDialog_Impl::HasSelectedStyle() const
 {
-    return pTreeBox? pTreeBox->FirstSelected() != nullptr:
+    return pTreeBox->IsVisible()? pTreeBox->FirstSelected() != nullptr:
             aFmtLb->GetSelectionCount() != 0;
 }
 
@@ -1133,7 +1142,7 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
             }
 
             // if the tree view again, select family hierarchy
-            if (pTreeBox || m_bWantHierarchical)
+            if (pTreeBox->IsVisible() || m_bWantHierarchical)
             {
                 aFilterLb->SelectEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL));
                 EnableHierarchical(true);
@@ -1345,7 +1354,7 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
             nActFilter = pDocShell->GetAutoStyleFilterIndex();
 
          nAppFilter = pItem->GetValue();
-         if(!pTreeBox)
+         if(!pTreeBox->IsVisible())
          {
              UpdateStyles_Impl(StyleFlags::UpdateFamilyList);
          }
@@ -1361,7 +1370,7 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
             && nAppFilter != pItem->GetValue())
          {
              nAppFilter = pItem->GetValue();
-             if(!pTreeBox)
+             if(!pTreeBox->IsVisible())
                  UpdateStyles_Impl(StyleFlags::UpdateFamilyList);
              else
                  FillTreeBox();
@@ -1380,7 +1389,7 @@ IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, TimeOut, Timer *, void )
     if(!bDontUpdate)
     {
         bDontUpdate=true;
-        if(!pTreeBox)
+        if(!pTreeBox->IsVisible())
             UpdateStyles_Impl(StyleFlags::UpdateFamilyList);
         else
         {
@@ -1556,7 +1565,7 @@ bool SfxCommonTemplateDialog_Impl::Execute_Impl(
     if ( !pItem || aDeleted )
         return false;
 
-    if ( (nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId) && (pTreeBox || aFmtLb->GetSelectionCount() <= 1) )
+    if ( (nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId) && (pTreeBox->IsVisible() || aFmtLb->GetSelectionCount() <= 1) )
     {
         const SfxUInt16Item *pFilterItem = dynamic_cast< const SfxUInt16Item* >(pItem);
         OSL_ENSURE(pFilterItem, "SfxUINT16Item expected");
@@ -1591,31 +1600,16 @@ void SfxCommonTemplateDialog_Impl::EnableHierarchical(bool const bEnable)
             SaveSelection(); // fdo#61429 store "hierarchical"
             const OUString aSelectEntry( GetSelectedEntry());
             aFmtLb->Hide();
-
-            pTreeBox = VclPtr<StyleTreeListBox_Impl>::Create(
-                    this, WB_HASBUTTONS | WB_HASLINES |
-                    WB_BORDER | WB_TABSTOP | WB_HASLINESATROOT |
-                    WB_HASBUTTONSATROOT | WB_HIDESELECTION );
-            pTreeBox->SetQuickSearch(true);
             pTreeBox->SetFont( aFmtLb->GetFont() );
-
             pTreeBox->SetPosSizePixel(aFmtLb->GetPosPixel(), aFmtLb->GetSizePixel());
-            pTreeBox->SetNodeDefaultImages();
-            pTreeBox->SetSelectHdl(
-                LINK(this, SfxCommonTemplateDialog_Impl, FmtSelectHdl));
-            pTreeBox->SetDoubleClickHdl(
-                    LINK(this, SfxCommonTemplateDialog_Impl,  ApplyHdl));
-            pTreeBox->SetDropHdl(LINK(this, SfxCommonTemplateDialog_Impl,  DropHdl));
-            pTreeBox->SetOptimalImageIndent();
             FillTreeBox();
             SelectStyle(aSelectEntry);
-            pTreeBox->SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST));
             pTreeBox->Show();
         }
     }
     else
     {
-        pTreeBox.disposeAndClear();
+        pTreeBox->Hide();
         aFmtLb->Show();
         // If bHierarchical, then the family can have changed
         // minus one since hierarchical is inserted at the start
@@ -1801,7 +1795,7 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, DropHdl, StyleTreeListBox_Impl&, rBox,
 // Handler for the New-Buttons
 void SfxCommonTemplateDialog_Impl::NewHdl()
 {
-    if ( nActFamily != 0xffff && (pTreeBox || aFmtLb->GetSelectionCount() <= 1))
+    if ( nActFamily != 0xffff && (pTreeBox->IsVisible() || aFmtLb->GetSelectionCount() <= 1))
     {
         const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
         const SfxStyleFamily eFam=pItem->GetFamily();
@@ -1845,7 +1839,7 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
         bool bUsedStyle = false;     // one of the selected styles are used in the document?
 
         std::vector<SvTreeListEntry*> aList;
-        SvTreeListEntry* pEntry = pTreeBox ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
+        SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
         const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
 
         OUString aMsg = SfxResId(STR_DELETE_STYLE_USED)
@@ -1855,7 +1849,7 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
         {
             aList.push_back( pEntry );
             // check the style is used or not
-            const OUString aTemplName(pTreeBox ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry));
+            const OUString aTemplName(pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry));
 
             SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( aTemplName, pItem->GetFamily() );
 
@@ -1867,7 +1861,7 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
                 bUsedStyle = true;
             }
 
-            pEntry = pTreeBox ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry);
+            pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry);
         }
 
         bool aApproved = false;
@@ -1886,12 +1880,12 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
         {
             for (auto const& elem : aList)
             {
-                const OUString aTemplName(pTreeBox ? pTreeBox->GetEntryText(elem) : aFmtLb->GetEntryText(elem));
+                const OUString aTemplName(pTreeBox->IsVisible() ? pTreeBox->GetEntryText(elem) : aFmtLb->GetEntryText(elem));
                 bDontUpdate = true; // To prevent the Treelistbox to shut down while deleting
                 Execute_Impl( SID_STYLE_DELETE, aTemplName,
                               OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) );
 
-                if ( pTreeBox )
+                if ( pTreeBox->IsVisible() )
                 {
                     pTreeBox->RemoveParentKeepChildren(elem);
                     bDontUpdate = false;
@@ -1907,16 +1901,16 @@ void SfxCommonTemplateDialog_Impl::HideHdl()
 {
     if ( IsInitialized() && HasSelectedStyle() )
     {
-        SvTreeListEntry* pEntry = pTreeBox ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
+        SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
 
         while (pEntry)
         {
-            OUString aTemplName = pTreeBox ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry);
+            OUString aTemplName = pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry);
 
             Execute_Impl( SID_STYLE_HIDE, aTemplName,
                           OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) );
 
-            pEntry = pTreeBox ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry);
+            pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry);
         }
     }
 }
@@ -1926,16 +1920,16 @@ void SfxCommonTemplateDialog_Impl::ShowHdl()
 
     if ( IsInitialized() && HasSelectedStyle() )
     {
-        SvTreeListEntry* pEntry = pTreeBox ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
+        SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
 
         while (pEntry)
         {
-            OUString aTemplName = pTreeBox ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry);
+            OUString aTemplName = pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry);
 
             Execute_Impl( SID_STYLE_SHOW, aTemplName,
                           OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) );
 
-            pEntry = pTreeBox ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry);
+            pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry);
         }
     }
 }
@@ -1954,7 +1948,7 @@ void SfxCommonTemplateDialog_Impl::EnableDelete()
         if(nFilter == SfxStyleSearchBits::Auto)    // automatic
             nFilter = nAppFilter;
         const SfxStyleSheetBase *pStyle =
-            pStyleSheetPool->Find(aTemplName,eFam, pTreeBox? SfxStyleSearchBits::All : nFilter);
+            pStyleSheetPool->Find(aTemplName,eFam, pTreeBox->IsVisible()? SfxStyleSearchBits::All : nFilter);
 
         OSL_ENSURE(pStyle, "Style not found");
         if(pStyle && pStyle->IsUserDefined())
@@ -2292,7 +2286,7 @@ void SfxTemplateDialog_Impl::Resize()
         aFilterLb->SetPosPixel(aFilterPos);
         aFmtLb->SetPosPixel( aFmtPos );
         aPreviewCheckbox->SetPosPixel(aCheckBoxPos);
-        if(pTreeBox)
+        if(pTreeBox->IsVisible())
             pTreeBox->SetPosPixel(aFmtPos);
     }
     else
@@ -2301,7 +2295,7 @@ void SfxTemplateDialog_Impl::Resize()
     aFilterLb->SetSizePixel(aFilterSize);
     aFmtLb->SetSizePixel( aFmtSize );
     aPreviewCheckbox->SetSizePixel( aCheckBoxSize );
-    if(pTreeBox)
+    if(pTreeBox->IsVisible())
         pTreeBox->SetSizePixel(aFmtSize);
 }
 
@@ -2445,13 +2439,13 @@ void SfxCommonTemplateDialog_Impl::UpdateFamily_Impl()
     }
 
     bWaterDisabled = false;
-    bCanNew = pTreeBox || aFmtLb->GetSelectionCount() <= 1;
+    bCanNew = pTreeBox->IsVisible() || aFmtLb->GetSelectionCount() <= 1;
     bTreeDrag = true;
     bUpdateByExampleDisabled = false;
 
     if (pStyleSheetPool)
     {
-        if (!pTreeBox)
+        if (!pTreeBox->IsVisible())
             UpdateStyles_Impl(StyleFlags::UpdateFamily | StyleFlags::UpdateFamilyList);
         else
         {
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 9495ed73db8c..584a36d38cfe 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -183,12 +183,12 @@ protected:
     std::unique_ptr<SfxStyleFamilies> pStyleFamilies;
     std::array<std::unique_ptr<SfxTemplateItem>, MAX_FAMILIES> pFamilyState;
     SfxStyleSheetBasePool* pStyleSheetPool;
-    VclPtr<StyleTreeListBox_Impl> pTreeBox;
     SfxObjectShell* pCurObjShell;
     css::uno::Reference<css::frame::XModuleManager2> xModuleManager;
     DeletionWatcher* m_pDeletionWatcher;
 
     VclPtr<SfxActionListBox> aFmtLb;
+    VclPtr<StyleTreeListBox_Impl> pTreeBox;
     VclPtr<CheckBox> aPreviewCheckbox;
     VclPtr<ListBox> aFilterLb;
 
diff --git a/sfx2/source/sidebar/FocusManager.cxx b/sfx2/source/sidebar/FocusManager.cxx
index 9872e34817e6..acdb50f7739c 100644
--- a/sfx2/source/sidebar/FocusManager.cxx
+++ b/sfx2/source/sidebar/FocusManager.cxx
@@ -56,6 +56,11 @@ void FocusManager::GrabFocus()
     FocusDeckTitle();
 }
 
+void FocusManager::GrabFocusPanel()
+{
+    FocusPanel(0, false);
+}
+
 void FocusManager::Clear()
 {
     SetDeckTitle(nullptr);
diff --git a/sfx2/source/sidebar/Sidebar.cxx b/sfx2/source/sidebar/Sidebar.cxx
index dda31e4bbaec..7abf8ace8db8 100644
--- a/sfx2/source/sidebar/Sidebar.cxx
+++ b/sfx2/source/sidebar/Sidebar.cxx
@@ -27,7 +27,7 @@ namespace sfx2 { namespace sidebar {
 
 void Sidebar::ShowPanel (
     const OUString& rsPanelId,
-    const css::uno::Reference<frame::XFrame>& rxFrame)
+    const css::uno::Reference<frame::XFrame>& rxFrame, bool bFocus)
 {
     SidebarController* pController = SidebarController::GetSidebarControllerForFrame(rxFrame);
     if (!pController)
@@ -45,6 +45,9 @@ void Sidebar::ShowPanel (
     // All that is not necessary for the current use cases so lets
     // keep it simple for the time being.
     pController->OpenThenSwitchToDeck(xPanelDescriptor->msDeckId);
+
+    if (bFocus)
+        pController->GetFocusManager().GrabFocusPanel();
 }
 
 void Sidebar::TogglePanel (
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 8fe2079492c5..16634c0dd5e2 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -2932,8 +2932,8 @@ void SfxViewFrame::ChildWindowExecute( SfxRequest &rReq )
         // First make sure that the sidebar is visible
         ShowChildWindow(SID_SIDEBAR);
 
-        ::sfx2::sidebar::Sidebar::TogglePanel("StyleListPanel",
-                                              GetFrame().GetFrameInterface());
+        ::sfx2::sidebar::Sidebar::ShowPanel("StyleListPanel",
+                                            GetFrame().GetFrameInterface(), true);
         rReq.Done();
         return;
     }


More information about the Libreoffice-commits mailing list