Hi, I have submitted a patch for review:
https://gerrit.libreoffice.org/3056 To pull it, you can do: git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/56/3056/1 fdo#61429: Stylist: save selection of "Hierarchical" entry This is unfortunately rather ugly because that one is "very special". (cherry picked from commit 44dd8b838b8dfa74b895a870a68200cf4f3574e0) Conflicts: sfx2/source/dialog/templdlg.cxx Change-Id: Ie2bc9ce2690fbc742b4510e453ca1ef310614256 --- M sfx2/source/dialog/templdlg.cxx M sfx2/source/inc/templdgi.hxx M svl/inc/svl/style.hrc 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index a81c27d..94e8082 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -753,6 +753,7 @@ bUpdateByExampleDisabled( sal_False ), bTreeDrag ( sal_True ), bHierarchical ( sal_False ), + m_bWantHierarchical ( sal_False ), bBindingUpdate ( sal_True ) { aFmtLb.SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST).toString()); @@ -1278,8 +1279,10 @@ } // if the tree view again, select family hierarchy - if(pTreeBox) + if (pTreeBox || m_bWantHierarchical) + { aFilterLb.SelectEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL).toString()); + } // show maximum 14 entries aFilterLb.SetDropDownLineCount( MAX_FILTER_ENTRIES ); @@ -1287,12 +1290,21 @@ } else { - if( nActFilter < aFilterLb.GetEntryCount() - 1) - aFilterLb.SelectEntryPos(nActFilter + 1); - else + if (m_bWantHierarchical) { nActFilter = 0; - aFilterLb.SelectEntryPos(1); + aFilterLb.SelectEntry(SfxResId( + STR_STYLE_FILTER_HIERARCHICAL).toString()); + } + else + { + if (nActFilter < aFilterLb.GetEntryCount() - 1) + aFilterLb.SelectEntryPos(nActFilter + 1); + else + { + nActFilter = 0; + aFilterLb.SelectEntryPos(1); + } } } @@ -1635,7 +1647,6 @@ //------------------------------------------------------------------------- - // Other filters; can be switched by the users or as a result of new or // editing, if the current document has been assigned a different filter. void SfxCommonTemplateDialog_Impl::FilterSelect( @@ -1646,14 +1657,7 @@ if( nEntry != nActFilter || bForce ) { nActFilter = nEntry; - SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); - SfxObjectShell *pDocShell = pViewFrame->GetObjectShell(); - if (pDocShell) - { - pDocShell->SetAutoStyleFilterIndex(nActFilter); - SaveFactoryStyleFilter( pDocShell, nActFilter ); - } - + SfxObjectShell *const pDocShell = SaveSelection(); SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool; pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): 0; if ( pOldStyleSheetPool != pStyleSheetPool ) @@ -1744,6 +1748,8 @@ { // Turn on treeView bHierarchical=sal_True; + m_bWantHierarchical = sal_True; + SaveSelection(); // fdo#61429 store "hierarchical" const String aSelectEntry( GetSelectedEntry()); aFmtLb.Hide(); @@ -1776,6 +1782,7 @@ aFmtLb.Show(); // If bHierarchical, then the family can have changed // minus one since hierarchical is inserted at the start + m_bWantHierarchical = sal_False; // before FilterSelect FilterSelect(pBox->GetSelectEntryPos() - 1, bHierarchical ); bHierarchical=sal_False; } @@ -1918,6 +1925,10 @@ sal_Int32 nDefault = -1; nFilter = aFactoryProps.getUnpackedValueOrDefault( DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"), nDefault ); + m_bWantHierarchical = + (nFilter & SFXSTYLEBIT_HIERARCHY) ? sal_True : sal_False; + nFilter &= ~SFXSTYLEBIT_HIERARCHY; // clear it + return nFilter; } @@ -1928,10 +1939,23 @@ OSL_ENSURE( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" ); Sequence< PropertyValue > lProps(1); lProps[0].Name = DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"); - lProps[0].Value = makeAny( i_nFilter );; + lProps[0].Value = makeAny( + i_nFilter | (m_bWantHierarchical ? SFXSTYLEBIT_HIERARCHY : 0)); xModuleManager->replaceByName( getModuleIdentifier( xModuleManager, i_pObjSh ), makeAny( lProps ) ); } +SfxObjectShell* SfxCommonTemplateDialog_Impl::SaveSelection() +{ + SfxViewFrame *const pViewFrame(pBindings->GetDispatcher_Impl()->GetFrame()); + SfxObjectShell *const pDocShell(pViewFrame->GetObjectShell()); + if (pDocShell) + { + pDocShell->SetAutoStyleFilterIndex(nActFilter); + SaveFactoryStyleFilter( pDocShell, nActFilter ); + } + return pDocShell; +} + //------------------------------------------------------------------------- IMPL_LINK( SfxCommonTemplateDialog_Impl, DropHdl, StyleTreeListBox_Impl *, pBox ) diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx index 2d92b71..c78ad47 100644 --- a/sfx2/source/inc/templdgi.hxx +++ b/sfx2/source/inc/templdgi.hxx @@ -165,6 +165,7 @@ bUpdateByExampleDisabled:1, bTreeDrag :1, bHierarchical :1, + m_bWantHierarchical :1, bBindingUpdate :1; DECL_LINK( FilterSelectHdl, ListBox * ); @@ -225,6 +226,7 @@ sal_Int32 LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh ); void SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter ); + SfxObjectShell * SaveSelection(); public: TYPEINFO(); diff --git a/svl/inc/svl/style.hrc b/svl/inc/svl/style.hrc index d498840..e12feed 100644 --- a/svl/inc/svl/style.hrc +++ b/svl/inc/svl/style.hrc @@ -21,6 +21,7 @@ #define SFXSTYLEBIT_AUTO 0x0000 // automatisch; Flags kommen von der Applikation #define SFXSTYLEBIT_HIDDEN 0x0200 // benutzte Vorlage (als Suchmaske) +#define SFXSTYLEBIT_HIERARCHY 0x1000 // hierarchical view - just for dialog #define SFXSTYLEBIT_READONLY 0x2000 // benutzte Vorlage (als Suchmaske) #define SFXSTYLEBIT_USED 0x4000 // benutzte Vorlage (als Suchmaske) #define SFXSTYLEBIT_USERDEF 0x8000 // benutzerdefinierte Vorlage -- To view, visit https://gerrit.libreoffice.org/3056 To unsubscribe, visit https://gerrit.libreoffice.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie2bc9ce2690fbc742b4510e453ca1ef310614256 Gerrit-PatchSet: 1 Gerrit-Project: core Gerrit-Branch: libreoffice-4-0 Gerrit-Owner: Michael Stahl <mst...@redhat.com> _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice