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

ui part for conditional date formats

Change-Id: I96893aaa016e6947d354aac4d7bc88da693095da
üst ee1af679
...@@ -612,9 +612,10 @@ ...@@ -612,9 +612,10 @@
#define STR_COND_ENDS_WITH 487 #define STR_COND_ENDS_WITH 487
#define STR_COND_CONTAINS 488 #define STR_COND_CONTAINS 488
#define STR_COND_NOT_CONTAINS 489 #define STR_COND_NOT_CONTAINS 489
#define STR_COND_DATE 490
#define STR_ERR_CONDFORMAT_PROTECTED 490 #define STR_ERR_CONDFORMAT_PROTECTED 491
#define STR_COUNT 491 #define STR_COUNT 492
#endif #endif
...@@ -91,6 +91,9 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum ...@@ -91,6 +91,9 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
break; break;
case condformat::ICONSET: case condformat::ICONSET:
break; break;
case condformat::DATE:
maEntries.push_back(new ScDateFrmtEntry( this, mpDoc, static_cast<const ScCondDateFormatEntry*>( pEntry ) ) );
break;
} }
} }
} }
...@@ -249,6 +252,7 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox) ...@@ -249,6 +252,7 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox)
{ {
case condformat::entry::FORMULA: case condformat::entry::FORMULA:
case condformat::entry::CONDITION: case condformat::entry::CONDITION:
case condformat::entry::DATE:
break; break;
case condformat::entry::COLORSCALE2: case condformat::entry::COLORSCALE2:
case condformat::entry::COLORSCALE3: case condformat::entry::COLORSCALE3:
...@@ -275,6 +279,14 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox) ...@@ -275,6 +279,14 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox)
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData(); static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
itr->SetActive(); itr->SetActive();
break; break;
case 3:
if(itr->GetType() == condformat::entry::DATE)
return 0;
maEntries.replace( itr, new ScDateFrmtEntry( this, mpDoc ));
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
itr->SetActive();
break;
} }
RecalcAll(); RecalcAll();
return 0; return 0;
......
...@@ -254,7 +254,6 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c ...@@ -254,7 +254,6 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
void ScConditionFrmtEntry::Init() void ScConditionFrmtEntry::Init()
{ {
maLbStyle.SetSeparatorPos(0);
maEdVal1.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) ); maEdVal1.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) );
maEdVal2.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) ); maEdVal2.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) );
maEdVal1.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) ); maEdVal1.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) );
...@@ -266,6 +265,7 @@ void ScConditionFrmtEntry::Init() ...@@ -266,6 +265,7 @@ void ScConditionFrmtEntry::Init()
maEdVal1.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) ); maEdVal1.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) );
maEdVal2.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) ); maEdVal2.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) );
maLbStyle.SetSeparatorPos(0);
SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA ); SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() ) for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
{ {
...@@ -402,9 +402,11 @@ void ScConditionFrmtEntry::SetInactive() ...@@ -402,9 +402,11 @@ void ScConditionFrmtEntry::SetInactive()
Deselect(); Deselect();
} }
IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl) namespace {
void StyleSelect( ListBox& rLbStyle, ScDocument* pDoc, SvxFontPrevWindow& rWdPreview )
{ {
if(maLbStyle.GetSelectEntryPos() == 0) if(rLbStyle.GetSelectEntryPos() == 0)
{ {
// call new style dialog // call new style dialog
SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA ); SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA );
...@@ -430,26 +432,32 @@ IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl) ...@@ -430,26 +432,32 @@ IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl)
// Find the new style and add it into the style list boxes // Find the new style and add it into the style list boxes
rtl::OUString aNewStyle; rtl::OUString aNewStyle;
SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA ); SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() ) for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
{ {
rtl::OUString aName = pStyle->GetName(); rtl::OUString aName = pStyle->GetName();
if ( maLbStyle.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND ) // all lists contain the same entries if ( rLbStyle.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND ) // all lists contain the same entries
{ {
maLbStyle.InsertEntry(aName); rLbStyle.InsertEntry(aName);
maLbStyle.SelectEntry(aName); rLbStyle.SelectEntry(aName);
} }
} }
} }
rtl::OUString aStyleName = maLbStyle.GetSelectEntry(); rtl::OUString aStyleName = rLbStyle.GetSelectEntry();
SfxStyleSheetBase* pStyleSheet = mpDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA ); SfxStyleSheetBase* pStyleSheet = pDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
if(pStyleSheet) if(pStyleSheet)
{ {
const SfxItemSet& rSet = pStyleSheet->GetItemSet(); const SfxItemSet& rSet = pStyleSheet->GetItemSet();
maWdPreview.Init( rSet ); rWdPreview.Init( rSet );
} }
}
}
IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl)
{
StyleSelect( maLbStyle, mpDoc, maWdPreview );
return 0; return 0;
} }
...@@ -495,51 +503,7 @@ void ScFormulaFrmtEntry::Init() ...@@ -495,51 +503,7 @@ void ScFormulaFrmtEntry::Init()
IMPL_LINK_NOARG(ScFormulaFrmtEntry, StyleSelectHdl) IMPL_LINK_NOARG(ScFormulaFrmtEntry, StyleSelectHdl)
{ {
if(maLbStyle.GetSelectEntryPos() == 0) StyleSelect( maLbStyle, mpDoc, maWdPreview );
{
// call new style dialog
SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA );
SfxStringItem aRefItem( SID_STYLE_REFERENCE, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
// unlock the dispatcher so SID_STYLE_NEW can be executed
// (SetDispatcherLock would affect all Calc documents)
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
SfxDispatcher* pDisp = pViewShell->GetDispatcher();
sal_Bool bLocked = pDisp->IsLocked();
if (bLocked)
pDisp->Lock(false);
// Execute the "new style" slot, complete with undo and all necessary updates.
// The return value (SfxUInt16Item) is ignored, look for new styles instead.
pDisp->Execute( SID_STYLE_NEW, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL,
&aFamilyItem,
&aRefItem,
0L );
if (bLocked)
pDisp->Lock(sal_True);
// Find the new style and add it into the style list boxes
rtl::OUString aNewStyle;
SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
{
rtl::OUString aName = pStyle->GetName();
if ( maLbStyle.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND ) // all lists contain the same entries
{
maLbStyle.InsertEntry(aName);
maLbStyle.SelectEntry(aName);
}
}
}
rtl::OUString aStyleName = maLbStyle.GetSelectEntry();
SfxStyleSheetBase* pStyleSheet = mpDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
if(pStyleSheet)
{
const SfxItemSet& rSet = pStyleSheet->GetItemSet();
maWdPreview.Init( rSet );
}
return 0; return 0;
} }
...@@ -1169,4 +1133,75 @@ IMPL_LINK_NOARG( ScDataBarFrmtEntry, OptionBtnHdl ) ...@@ -1169,4 +1133,75 @@ IMPL_LINK_NOARG( ScDataBarFrmtEntry, OptionBtnHdl )
return 0; return 0;
} }
ScDateFrmtEntry::ScDateFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat ):
ScCondFrmtEntry( pParent, pDoc, ScAddress() ),
maLbDateEntry( this, ScResId( LB_DATE_TYPE ) ),
maFtStyle( this, ScResId( FT_STYLE ) ),
maLbStyle( this, ScResId( LB_STYLE ) ),
maWdPreview( this, ScResId( WD_PREVIEW ) )
{
Init();
FreeResource();
if(pFormat)
{
sal_Int32 nPos = static_cast<sal_Int32>(pFormat->GetDateType());
maLbDateEntry.SelectEntryPos(nPos);
}
}
void ScDateFrmtEntry::Init()
{
maLbDateEntry.SelectEntryPos(0);
maLbType.SelectEntryPos(3);
maLbStyle.SetSeparatorPos(0);
SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
{
rtl::OUString aName = pStyle->GetName();
maLbStyle.InsertEntry( aName );
}
maLbStyle.SetSelectHdl( LINK( this, ScDateFrmtEntry, StyleSelectHdl ) );
}
void ScDateFrmtEntry::SetActive()
{
maLbDateEntry.Show();
maFtStyle.Show();
maWdPreview.Show();
Select();
}
void ScDateFrmtEntry::SetInactive()
{
maLbDateEntry.Show();
maFtStyle.Show();
maWdPreview.Show();
Deselect();
}
ScFormatEntry* ScDateFrmtEntry::GetEntry() const
{
ScCondDateFormatEntry* pNewEntry = new ScCondDateFormatEntry(mpDoc);
condformat::ScCondFormatDateType eType = static_cast<condformat::ScCondFormatDateType>(maLbDateEntry.GetSelectEntryPos());
pNewEntry->SetDateType(eType);
pNewEntry->SetStyleName(maLbStyle.GetSelectEntry());
return pNewEntry;
}
rtl::OUString ScDateFrmtEntry::GetExpressionString()
{
return ScCondFormatHelper::GetExpression(DATE, 0);
}
IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl )
{
StyleSelect( maLbStyle, mpDoc, maWdPreview );
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -27,6 +27,8 @@ rtl::OUString getTextForType(ScCondFormatEntryType eType) ...@@ -27,6 +27,8 @@ rtl::OUString getTextForType(ScCondFormatEntryType eType)
return ScGlobal::GetRscString(STR_COND_FORMULA); return ScGlobal::GetRscString(STR_COND_FORMULA);
case ICONSET: case ICONSET:
return ScGlobal::GetRscString(STR_COND_ICONSET); return ScGlobal::GetRscString(STR_COND_ICONSET);
case DATE:
return ScGlobal::GetRscString(STR_COND_DATE);
default: default:
break; break;
} }
...@@ -136,6 +138,9 @@ rtl::OUString ScCondFormatHelper::GetExpression(const ScConditionalFormat& rForm ...@@ -136,6 +138,9 @@ rtl::OUString ScCondFormatHelper::GetExpression(const ScConditionalFormat& rForm
case condformat::ICONSET: case condformat::ICONSET:
aBuffer.append(getTextForType(ICONSET)); aBuffer.append(getTextForType(ICONSET));
break; break;
case condformat::DATE:
aBuffer.append(getTextForType(DATE));
break;
} }
} }
return aBuffer.makeStringAndClear(); return aBuffer.makeStringAndClear();
......
...@@ -67,4 +67,6 @@ ...@@ -67,4 +67,6 @@
#define LB_TYPE_COL_SCALE_MIN 42 #define LB_TYPE_COL_SCALE_MIN 42
#define LB_TYPE_COL_SCALE_MIDDLE 43 #define LB_TYPE_COL_SCALE_MIDDLE 43
#define LB_TYPE_COL_SCALE_MAX 44 #define LB_TYPE_COL_SCALE_MAX 44
#define LB_DATE_TYPE 45
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -21,7 +21,8 @@ enum ScCondFrmtEntryType ...@@ -21,7 +21,8 @@ enum ScCondFrmtEntryType
FORMULA, FORMULA,
COLORSCALE2, COLORSCALE2,
COLORSCALE3, COLORSCALE3,
DATABAR DATABAR,
DATE
}; };
} }
...@@ -74,7 +75,6 @@ public: ...@@ -74,7 +75,6 @@ public:
class ScConditionFrmtEntry : public ScCondFrmtEntry class ScConditionFrmtEntry : public ScCondFrmtEntry
{ {
//cond format ui elements //cond format ui elements
ListBox maLbCondType; ListBox maLbCondType;
formula::RefEdit maEdVal1; formula::RefEdit maEdVal1;
...@@ -216,4 +216,27 @@ public: ...@@ -216,4 +216,27 @@ public:
virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATABAR; } virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATABAR; }
}; };
class ScDateFrmtEntry : public ScCondFrmtEntry
{
public:
ScDateFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = NULL );
virtual ScFormatEntry* GetEntry() const;
virtual void SetActive();
virtual void SetInactive();
virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATE; }
protected:
virtual rtl::OUString GetExpressionString();
private:
void Init();
DECL_LINK( StyleSelectHdl, void* );
ListBox maLbDateEntry;
FixedText maFtStyle;
ListBox maLbStyle;
SvxFontPrevWindow maWdPreview;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -19,7 +19,8 @@ enum ScCondFormatEntryType ...@@ -19,7 +19,8 @@ enum ScCondFormatEntryType
DATABAR, DATABAR,
FORMULA, FORMULA,
ICONSET, ICONSET,
COLLAPSED DATE,
COLLAPSE
}; };
class ScCondFormatHelper class ScCondFormatHelper
......
...@@ -121,6 +121,7 @@ Control RID_COND_ENTRY ...@@ -121,6 +121,7 @@ Control RID_COND_ENTRY
"All Cells"; "All Cells";
"Cell value is"; "Cell value is";
"Formula is"; "Formula is";
"Date is";
}; };
}; };
ListBox LB_CELLIS_TYPE ListBox LB_CELLIS_TYPE
...@@ -309,6 +310,30 @@ Control RID_COND_ENTRY ...@@ -309,6 +310,30 @@ Control RID_COND_ENTRY
Size = MAP_APPFONT( 60, 14 ); Size = MAP_APPFONT( 60, 14 );
Text [ en-US ] = "More options ..."; Text [ en-US ] = "More options ...";
}; };
ListBox LB_DATE_TYPE
{
Pos = MAP_APPFONT( 100, 15 );
Size = MAP_APPFONT( 100, 60 );
Border = TRUE;
DropDown = TRUE;
DDExtraWidth = TRUE;
StringList [ en-US ] =
{
"Today";
"Yesterday";
"Tomorrow";
"Last 7 days";
"This week";
"Last week";
"Next week";
"This month";
"Last month";
"Next month";
"This year";
"Last year";
"Next year";
};
};
}; };
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1911,6 +1911,10 @@ Resource RID_GLOBSTR ...@@ -1911,6 +1911,10 @@ Resource RID_GLOBSTR
{ {
Text [ en-US ] = "Top Percent"; Text [ en-US ] = "Top Percent";
}; };
String STR_COND_DATE
{
Text [ en-US ] = "Date is";
};
String STR_COND_BOTTOM_PERCENT String STR_COND_BOTTOM_PERCENT
{ {
Text [ en-US ] = "Bottom Percent"; Text [ en-US ] = "Bottom Percent";
......
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