Kaydet (Commit) aa028cab authored tarafından Markus Mohrhard's avatar Markus Mohrhard

update all style lists when a new style is added

Change-Id: Ib404958e2bc0e3bfe075d1c94f348e907ee004c8
üst 5b9bad74
...@@ -167,7 +167,8 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c ...@@ -167,7 +167,8 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
maEdVal2( this, NULL, NULL, ScResId( ED_VAL2 ) ), maEdVal2( this, NULL, NULL, ScResId( ED_VAL2 ) ),
maFtStyle( this, ScResId( FT_STYLE ) ), maFtStyle( this, ScResId( FT_STYLE ) ),
maLbStyle( this, ScResId( LB_STYLE ) ), maLbStyle( this, ScResId( LB_STYLE ) ),
maWdPreview( this, ScResId( WD_PREVIEW ) ) maWdPreview( this, ScResId( WD_PREVIEW ) ),
mbIsInStyleCreate(false)
{ {
FreeResource(); FreeResource();
...@@ -175,6 +176,8 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c ...@@ -175,6 +176,8 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
Init(); Init();
StartListening(*pDoc->GetStyleSheetPool(), true);
if(pFormatEntry) if(pFormatEntry)
{ {
OUString aStyleName = pFormatEntry->GetStyle(); OUString aStyleName = pFormatEntry->GetStyle();
...@@ -436,6 +439,35 @@ void ScConditionFrmtEntry::SetInactive() ...@@ -436,6 +439,35 @@ void ScConditionFrmtEntry::SetInactive()
namespace { 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 ) void StyleSelect( ListBox& rLbStyle, ScDocument* pDoc, SvxFontPrevWindow& rWdPreview )
{ {
if(rLbStyle.GetSelectEntryPos() == 0) if(rLbStyle.GetSelectEntryPos() == 0)
...@@ -503,7 +535,9 @@ void StyleSelect( ListBox& rLbStyle, ScDocument* pDoc, SvxFontPrevWindow& rWdPre ...@@ -503,7 +535,9 @@ void StyleSelect( ListBox& rLbStyle, ScDocument* pDoc, SvxFontPrevWindow& rWdPre
IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl) IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl)
{ {
mbIsInStyleCreate = true;
StyleSelect( maLbStyle, mpDoc, maWdPreview ); StyleSelect( maLbStyle, mpDoc, maWdPreview );
mbIsInStyleCreate = false;
return 0; return 0;
} }
...@@ -1189,11 +1223,14 @@ ScDateFrmtEntry::ScDateFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCon ...@@ -1189,11 +1223,14 @@ ScDateFrmtEntry::ScDateFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCon
maLbDateEntry( this, ScResId( LB_DATE_TYPE ) ), maLbDateEntry( this, ScResId( LB_DATE_TYPE ) ),
maFtStyle( this, ScResId( FT_STYLE ) ), maFtStyle( this, ScResId( FT_STYLE ) ),
maLbStyle( this, ScResId( LB_STYLE ) ), maLbStyle( this, ScResId( LB_STYLE ) ),
maWdPreview( this, ScResId( WD_PREVIEW ) ) maWdPreview( this, ScResId( WD_PREVIEW ) ),
mbIsInStyleCreate(false)
{ {
Init(); Init();
FreeResource(); FreeResource();
StartListening(*pDoc->GetStyleSheetPool(), sal_True);
if(pFormat) if(pFormat)
{ {
sal_Int32 nPos = static_cast<sal_Int32>(pFormat->GetDateType()); sal_Int32 nPos = static_cast<sal_Int32>(pFormat->GetDateType());
...@@ -1234,6 +1271,20 @@ void ScDateFrmtEntry::SetInactive() ...@@ -1234,6 +1271,20 @@ void ScDateFrmtEntry::SetInactive()
Deselect(); 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 ScFormatEntry* ScDateFrmtEntry::GetEntry() const
{ {
ScCondDateFormatEntry* pNewEntry = new ScCondDateFormatEntry(mpDoc); ScCondDateFormatEntry* pNewEntry = new ScCondDateFormatEntry(mpDoc);
...@@ -1250,7 +1301,9 @@ OUString ScDateFrmtEntry::GetExpressionString() ...@@ -1250,7 +1301,9 @@ OUString ScDateFrmtEntry::GetExpressionString()
IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl ) IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl )
{ {
mbIsInStyleCreate = true;
StyleSelect( maLbStyle, mpDoc, maWdPreview ); StyleSelect( maLbStyle, mpDoc, maWdPreview );
mbIsInStyleCreate = false;
return 0; return 0;
} }
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "conditio.hxx" #include "conditio.hxx"
#include <formula/funcutl.hxx> #include <formula/funcutl.hxx>
#include <svl/lstner.hxx>
class ScIconSetFrmtDataEntry; class ScIconSetFrmtDataEntry;
namespace condformat { namespace condformat {
...@@ -76,7 +78,7 @@ public: ...@@ -76,7 +78,7 @@ public:
virtual condformat::entry::ScCondFrmtEntryType GetType() = 0; virtual condformat::entry::ScCondFrmtEntryType GetType() = 0;
}; };
class ScConditionFrmtEntry : public ScCondFrmtEntry class ScConditionFrmtEntry : public ScCondFrmtEntry, public SfxListener
{ {
//cond format ui elements //cond format ui elements
ListBox maLbCondType; ListBox maLbCondType;
...@@ -85,6 +87,7 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry ...@@ -85,6 +87,7 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry
FixedText maFtStyle; FixedText maFtStyle;
ListBox maLbStyle; ListBox maLbStyle;
SvxFontPrevWindow maWdPreview; SvxFontPrevWindow maWdPreview;
bool mbIsInStyleCreate;
ScFormatEntry* createConditionEntry() const; ScFormatEntry* createConditionEntry() const;
...@@ -100,6 +103,9 @@ public: ...@@ -100,6 +103,9 @@ public:
virtual void SetActive(); virtual void SetActive();
virtual void SetInactive(); virtual void SetInactive();
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
using ScCondFrmtEntry::Notify;
virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::CONDITION; } virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::CONDITION; }
}; };
...@@ -219,7 +225,7 @@ public: ...@@ -219,7 +225,7 @@ public:
virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATABAR; } virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATABAR; }
}; };
class ScDateFrmtEntry : public ScCondFrmtEntry class ScDateFrmtEntry : public ScCondFrmtEntry, public SfxListener
{ {
public: public:
ScDateFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = NULL ); ScDateFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = NULL );
...@@ -228,6 +234,8 @@ public: ...@@ -228,6 +234,8 @@ public:
virtual void SetInactive(); virtual void SetInactive();
virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATE; } virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATE; }
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
using ScCondFrmtEntry::Notify;
protected: protected:
virtual OUString GetExpressionString(); virtual OUString GetExpressionString();
...@@ -240,6 +248,8 @@ private: ...@@ -240,6 +248,8 @@ private:
FixedText maFtStyle; FixedText maFtStyle;
ListBox maLbStyle; ListBox maLbStyle;
SvxFontPrevWindow maWdPreview; SvxFontPrevWindow maWdPreview;
bool mbIsInStyleCreate;
}; };
class ScIconSetFrmtEntry : public ScCondFrmtEntry class ScIconSetFrmtEntry : public ScCondFrmtEntry
......
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