diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-06-29 05:16:14 +0200 |
---|---|---|
committer | Bosdonnat Cedric <cedric.bosdonnat@free.fr> | 2013-07-01 13:37:31 +0000 |
commit | 8c69cc28fd6cb9ac22f1c896d6007d92dffe9012 (patch) | |
tree | 20ead40399675c0c5762378c9e7bd7a01e358adc | |
parent | 297363822d460321c0b3bdd4a8acc9f689f4661b (diff) |
update all style lists when a new style is added
Change-Id: Ib404958e2bc0e3bfe075d1c94f348e907ee004c8
(cherry picked from commit aa028cab4a72660c773a9eac0cd8a19a0d655c01)
Reviewed-on: https://gerrit.libreoffice.org/4616
Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
-rw-r--r-- | sc/source/ui/condformat/condformatdlgentry.cxx | 57 | ||||
-rw-r--r-- | sc/source/ui/inc/condformatdlgentry.hxx | 14 |
2 files changed, 67 insertions, 4 deletions
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 46feaa800240..e0f78a54802b 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -167,7 +167,8 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c maEdVal2( this, NULL, NULL, ScResId( ED_VAL2 ) ), maFtStyle( this, ScResId( FT_STYLE ) ), maLbStyle( this, ScResId( LB_STYLE ) ), - maWdPreview( this, ScResId( WD_PREVIEW ) ) + maWdPreview( this, ScResId( WD_PREVIEW ) ), + mbIsInStyleCreate(false) { FreeResource(); @@ -175,6 +176,8 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c Init(); + StartListening(*pDoc->GetStyleSheetPool(), true); + if(pFormatEntry) { OUString aStyleName = pFormatEntry->GetStyle(); @@ -436,6 +439,35 @@ void ScConditionFrmtEntry::SetInactive() namespace { +void UpdateStyleList(ListBox& rLbStyle, ScDocument* pDoc) +{ + OUString aSelectedStyle = rLbStyle.GetSelectEntry(); + for(sal_Int32 i = rLbStyle.GetEntryCount(); i >= 1; --i) + { + rLbStyle.RemoveEntry(i); + } + FillStyleListBox(pDoc, rLbStyle); + rLbStyle.SelectEntry(aSelectedStyle); +} + +} + +void ScConditionFrmtEntry::Notify(SfxBroadcaster&, const SfxHint& rHint) +{ + SfxStyleSheetHint* pHint = PTR_CAST(SfxStyleSheetHint, &rHint); + if(!pHint) + return; + + sal_uInt16 nHint = pHint->GetHint(); + if(nHint == SFX_STYLESHEET_MODIFIED) + { + if(!mbIsInStyleCreate) + UpdateStyleList(maLbStyle, mpDoc); + } +} + +namespace { + void StyleSelect( ListBox& rLbStyle, ScDocument* pDoc, SvxFontPrevWindow& rWdPreview ) { if(rLbStyle.GetSelectEntryPos() == 0) @@ -503,7 +535,9 @@ void StyleSelect( ListBox& rLbStyle, ScDocument* pDoc, SvxFontPrevWindow& rWdPre IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl) { + mbIsInStyleCreate = true; StyleSelect( maLbStyle, mpDoc, maWdPreview ); + mbIsInStyleCreate = false; return 0; } @@ -1189,11 +1223,14 @@ ScDateFrmtEntry::ScDateFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCon maLbDateEntry( this, ScResId( LB_DATE_TYPE ) ), maFtStyle( this, ScResId( FT_STYLE ) ), maLbStyle( this, ScResId( LB_STYLE ) ), - maWdPreview( this, ScResId( WD_PREVIEW ) ) + maWdPreview( this, ScResId( WD_PREVIEW ) ), + mbIsInStyleCreate(false) { Init(); FreeResource(); + StartListening(*pDoc->GetStyleSheetPool(), sal_True); + if(pFormat) { sal_Int32 nPos = static_cast<sal_Int32>(pFormat->GetDateType()); @@ -1234,6 +1271,20 @@ void ScDateFrmtEntry::SetInactive() Deselect(); } +void ScDateFrmtEntry::Notify( SfxBroadcaster&, const SfxHint& rHint ) +{ + SfxStyleSheetHint* pHint = PTR_CAST(SfxStyleSheetHint, &rHint); + if(!pHint) + return; + + sal_uInt16 nHint = pHint->GetHint(); + if(nHint == SFX_STYLESHEET_MODIFIED) + { + if(!mbIsInStyleCreate) + UpdateStyleList(maLbStyle, mpDoc); + } +} + ScFormatEntry* ScDateFrmtEntry::GetEntry() const { ScCondDateFormatEntry* pNewEntry = new ScCondDateFormatEntry(mpDoc); @@ -1250,7 +1301,9 @@ OUString ScDateFrmtEntry::GetExpressionString() IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl ) { + mbIsInStyleCreate = true; StyleSelect( maLbStyle, mpDoc, maWdPreview ); + mbIsInStyleCreate = false; return 0; } diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx index 7727d28be926..77054ab06a21 100644 --- a/sc/source/ui/inc/condformatdlgentry.hxx +++ b/sc/source/ui/inc/condformatdlgentry.hxx @@ -11,6 +11,8 @@ #include "conditio.hxx" #include <formula/funcutl.hxx> +#include <svl/lstner.hxx> + class ScIconSetFrmtDataEntry; namespace condformat { @@ -76,7 +78,7 @@ public: virtual condformat::entry::ScCondFrmtEntryType GetType() = 0; }; -class ScConditionFrmtEntry : public ScCondFrmtEntry +class ScConditionFrmtEntry : public ScCondFrmtEntry, public SfxListener { //cond format ui elements ListBox maLbCondType; @@ -85,6 +87,7 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry FixedText maFtStyle; ListBox maLbStyle; SvxFontPrevWindow maWdPreview; + bool mbIsInStyleCreate; ScFormatEntry* createConditionEntry() const; @@ -100,6 +103,9 @@ public: virtual void SetActive(); virtual void SetInactive(); + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + using ScCondFrmtEntry::Notify; + virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::CONDITION; } }; @@ -219,7 +225,7 @@ public: virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATABAR; } }; -class ScDateFrmtEntry : public ScCondFrmtEntry +class ScDateFrmtEntry : public ScCondFrmtEntry, public SfxListener { public: ScDateFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = NULL ); @@ -228,6 +234,8 @@ public: virtual void SetInactive(); virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATE; } + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + using ScCondFrmtEntry::Notify; protected: virtual OUString GetExpressionString(); @@ -240,6 +248,8 @@ private: FixedText maFtStyle; ListBox maLbStyle; SvxFontPrevWindow maWdPreview; + + bool mbIsInStyleCreate; }; class ScIconSetFrmtEntry : public ScCondFrmtEntry |