Kaydet (Commit) 5c5b6f1e authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Bosdonnat Cedric

fdo#61429: Stylist: save selection of "Hierarchical" entry

This is unfortunately rather ugly because that one is "very special".

(cherry picked from commit 44dd8b83)

Conflicts:
	sfx2/source/dialog/templdlg.cxx

Change-Id: Ie2bc9ce2690fbc742b4510e453ca1ef310614256
Reviewed-on: https://gerrit.libreoffice.org/3056Reviewed-by: 's avatarChristoph Brill <egore911@gmail.com>
Reviewed-by: 's avatarBosdonnat Cedric <cedric.bosdonnat@free.fr>
Tested-by: 's avatarBosdonnat Cedric <cedric.bosdonnat@free.fr>
üst ddc9d165
...@@ -753,6 +753,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Sfx ...@@ -753,6 +753,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Sfx
bUpdateByExampleDisabled( sal_False ), bUpdateByExampleDisabled( sal_False ),
bTreeDrag ( sal_True ), bTreeDrag ( sal_True ),
bHierarchical ( sal_False ), bHierarchical ( sal_False ),
m_bWantHierarchical ( sal_False ),
bBindingUpdate ( sal_True ) bBindingUpdate ( sal_True )
{ {
aFmtLb.SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST).toString()); aFmtLb.SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST).toString());
...@@ -1278,8 +1279,10 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags) ...@@ -1278,8 +1279,10 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags)
} }
// if the tree view again, select family hierarchy // if the tree view again, select family hierarchy
if(pTreeBox) if (pTreeBox || m_bWantHierarchical)
{
aFilterLb.SelectEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL).toString()); aFilterLb.SelectEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL).toString());
}
// show maximum 14 entries // show maximum 14 entries
aFilterLb.SetDropDownLineCount( MAX_FILTER_ENTRIES ); aFilterLb.SetDropDownLineCount( MAX_FILTER_ENTRIES );
...@@ -1287,12 +1290,21 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags) ...@@ -1287,12 +1290,21 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags)
} }
else else
{ {
if( nActFilter < aFilterLb.GetEntryCount() - 1) if (m_bWantHierarchical)
aFilterLb.SelectEntryPos(nActFilter + 1);
else
{ {
nActFilter = 0; 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 ...@@ -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 // 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. // editing, if the current document has been assigned a different filter.
void SfxCommonTemplateDialog_Impl::FilterSelect( void SfxCommonTemplateDialog_Impl::FilterSelect(
...@@ -1646,14 +1657,7 @@ void SfxCommonTemplateDialog_Impl::FilterSelect( ...@@ -1646,14 +1657,7 @@ void SfxCommonTemplateDialog_Impl::FilterSelect(
if( nEntry != nActFilter || bForce ) if( nEntry != nActFilter || bForce )
{ {
nActFilter = nEntry; nActFilter = nEntry;
SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); SfxObjectShell *const pDocShell = SaveSelection();
SfxObjectShell *pDocShell = pViewFrame->GetObjectShell();
if (pDocShell)
{
pDocShell->SetAutoStyleFilterIndex(nActFilter);
SaveFactoryStyleFilter( pDocShell, nActFilter );
}
SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool; SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool;
pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): 0; pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): 0;
if ( pOldStyleSheetPool != pStyleSheetPool ) if ( pOldStyleSheetPool != pStyleSheetPool )
...@@ -1744,6 +1748,8 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox *, pBox ) ...@@ -1744,6 +1748,8 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox *, pBox )
{ {
// Turn on treeView // Turn on treeView
bHierarchical=sal_True; bHierarchical=sal_True;
m_bWantHierarchical = sal_True;
SaveSelection(); // fdo#61429 store "hierarchical"
const String aSelectEntry( GetSelectedEntry()); const String aSelectEntry( GetSelectedEntry());
aFmtLb.Hide(); aFmtLb.Hide();
...@@ -1776,6 +1782,7 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox *, pBox ) ...@@ -1776,6 +1782,7 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox *, pBox )
aFmtLb.Show(); aFmtLb.Show();
// If bHierarchical, then the family can have changed // If bHierarchical, then the family can have changed
// minus one since hierarchical is inserted at the start // minus one since hierarchical is inserted at the start
m_bWantHierarchical = sal_False; // before FilterSelect
FilterSelect(pBox->GetSelectEntryPos() - 1, bHierarchical ); FilterSelect(pBox->GetSelectEntryPos() - 1, bHierarchical );
bHierarchical=sal_False; bHierarchical=sal_False;
} }
...@@ -1918,6 +1925,10 @@ sal_Int32 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell* ...@@ -1918,6 +1925,10 @@ sal_Int32 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell*
sal_Int32 nDefault = -1; sal_Int32 nDefault = -1;
nFilter = aFactoryProps.getUnpackedValueOrDefault( DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"), nDefault ); nFilter = aFactoryProps.getUnpackedValueOrDefault( DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"), nDefault );
m_bWantHierarchical =
(nFilter & SFXSTYLEBIT_HIERARCHY) ? sal_True : sal_False;
nFilter &= ~SFXSTYLEBIT_HIERARCHY; // clear it
return nFilter; return nFilter;
} }
...@@ -1928,10 +1939,23 @@ void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell* i_pOb ...@@ -1928,10 +1939,23 @@ void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell* i_pOb
OSL_ENSURE( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" ); OSL_ENSURE( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
Sequence< PropertyValue > lProps(1); Sequence< PropertyValue > lProps(1);
lProps[0].Name = DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"); 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 ) ); 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 ) IMPL_LINK( SfxCommonTemplateDialog_Impl, DropHdl, StyleTreeListBox_Impl *, pBox )
......
...@@ -165,6 +165,7 @@ protected: ...@@ -165,6 +165,7 @@ protected:
bUpdateByExampleDisabled:1, bUpdateByExampleDisabled:1,
bTreeDrag :1, bTreeDrag :1,
bHierarchical :1, bHierarchical :1,
m_bWantHierarchical :1,
bBindingUpdate :1; bBindingUpdate :1;
DECL_LINK( FilterSelectHdl, ListBox * ); DECL_LINK( FilterSelectHdl, ListBox * );
...@@ -225,6 +226,7 @@ protected: ...@@ -225,6 +226,7 @@ protected:
sal_Int32 LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh ); sal_Int32 LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh );
void SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter ); void SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter );
SfxObjectShell * SaveSelection();
public: public:
TYPEINFO(); TYPEINFO();
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define SFXSTYLEBIT_AUTO 0x0000 // automatisch; Flags kommen von der Applikation #define SFXSTYLEBIT_AUTO 0x0000 // automatisch; Flags kommen von der Applikation
#define SFXSTYLEBIT_HIDDEN 0x0200 // benutzte Vorlage (als Suchmaske) #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_READONLY 0x2000 // benutzte Vorlage (als Suchmaske)
#define SFXSTYLEBIT_USED 0x4000 // benutzte Vorlage (als Suchmaske) #define SFXSTYLEBIT_USED 0x4000 // benutzte Vorlage (als Suchmaske)
#define SFXSTYLEBIT_USERDEF 0x8000 // benutzerdefinierte Vorlage #define SFXSTYLEBIT_USERDEF 0x8000 // benutzerdefinierte Vorlage
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment