summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-03-26 11:33:09 +0100
committerBosdonnat Cedric <cedric.bosdonnat@free.fr>2013-03-27 12:25:07 +0000
commit5c5b6f1e9e3341726d6870af74912bb9db374b5f (patch)
tree9fd2ea8ae64e0340a2f366fdf8dad19cc637fb2f
parentddc9d165930f475cbcef21603656835fba7ba35b (diff)
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@gmail.com> Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr> Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
-rw-r--r--sfx2/source/dialog/templdlg.cxx54
-rw-r--r--sfx2/source/inc/templdgi.hxx2
-rw-r--r--svl/inc/svl/style.hrc1
3 files changed, 42 insertions, 15 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index a81c27dd5350..94e8082212c4 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 2d92b719ae67..c78ad47be16e 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 d4988400083a..e12feed67208 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