summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-03-26 11:33:09 +0100
committerMichael Stahl <mstahl@redhat.com>2013-03-26 11:49:56 +0100
commit44dd8b838b8dfa74b895a870a68200cf4f3574e0 (patch)
treed0e3fa2607c21661f17a232ebd0f30a599069e57
parent80996c374b4ff2514b2e952cfd572ae499b481a1 (diff)
fdo#61429: Stylist: save selection of "Hierarchical" entry
This is unfortunately rather ugly because that one is "very special". Change-Id: Ie2bc9ce2690fbc742b4510e453ca1ef310614256
-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 d6d1af302798..1b98850a5936 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -744,6 +744,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());
@@ -1232,8 +1233,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 );
@@ -1241,12 +1244,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);
+ }
}
}
@@ -1590,7 +1602,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(
@@ -1601,14 +1612,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 )
@@ -1700,6 +1704,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();
@@ -1732,6 +1738,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;
}
@@ -1874,6 +1881,10 @@ sal_Int32 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell*
sal_Int32 nDefault = -1;
nFilter = aFactoryProps.getUnpackedValueOrDefault( "ooSetupFactoryStyleFilter", nDefault );
+ m_bWantHierarchical =
+ (nFilter & SFXSTYLEBIT_HIERARCHY) ? sal_True : sal_False;
+ nFilter &= ~SFXSTYLEBIT_HIERARCHY; // clear it
+
return nFilter;
}
@@ -1884,10 +1895,23 @@ void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell* i_pOb
OSL_ENSURE( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
Sequence< PropertyValue > lProps(1);
lProps[0].Name = "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 b5fdbd9c85c6..fe6e046de5b7 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -164,6 +164,7 @@ protected:
bUpdateByExampleDisabled:1,
bTreeDrag :1,
bHierarchical :1,
+ m_bWantHierarchical :1,
bBindingUpdate :1;
DECL_LINK( FilterSelectHdl, ListBox * );
@@ -224,6 +225,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 63552fc0cbce..83c71532e4f1 100644
--- a/svl/inc/svl/style.hrc
+++ b/svl/inc/svl/style.hrc
@@ -22,6 +22,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