[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sfx2/source svl/inc

Michael Stahl mstahl at redhat.com
Wed Mar 27 05:25:28 PDT 2013


 sfx2/source/dialog/templdlg.cxx |   54 ++++++++++++++++++++++++++++------------
 sfx2/source/inc/templdgi.hxx    |    2 +
 svl/inc/svl/style.hrc           |    1 
 3 files changed, 42 insertions(+), 15 deletions(-)

New commits:
commit 5c5b6f1e9e3341726d6870af74912bb9db374b5f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Mar 26 11:33:09 2013 +0100

    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
    Reviewed-on: https://gerrit.libreoffice.org/3056
    Reviewed-by: Christoph Brill <egore911 at gmail.com>
    Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat at free.fr>
    Tested-by: Bosdonnat Cedric <cedric.bosdonnat at free.fr>

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 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Sfx
     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 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags)
             }
 
             // 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 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags)
         }
         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 @@ void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster& /*rBC*/, const SfxHint
 
 
 //-------------------------------------------------------------------------
-
 // 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 @@ void SfxCommonTemplateDialog_Impl::FilterSelect(
     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 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox *, pBox )
         {
             // 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 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox *, pBox )
         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 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell*
     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 @@ void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell* i_pOb
     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 @@ protected:
                                 bUpdateByExampleDisabled:1,
                                 bTreeDrag               :1,
                                 bHierarchical           :1,
+                                m_bWantHierarchical     :1,
                                 bBindingUpdate          :1;
 
     DECL_LINK( FilterSelectHdl, ListBox * );
@@ -225,6 +226,7 @@ protected:
 
     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


More information about the Libreoffice-commits mailing list