diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/globstr.hrc | 5 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlg.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlgentry.cxx | 145 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformathelper.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/inc/condformatdlg.hrc | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/condformatdlgentry.hxx | 27 | ||||
-rw-r--r-- | sc/source/ui/inc/condformathelper.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/src/condformatdlg.src | 25 | ||||
-rw-r--r-- | sc/source/ui/src/globstr.src | 4 |
9 files changed, 168 insertions, 60 deletions
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index ea2d87050601..4fc17bd9b9ee 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -612,9 +612,10 @@ #define STR_COND_ENDS_WITH 487 #define STR_COND_CONTAINS 488 #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 diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 8ef887c3a928..5212f6259ff4 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -91,6 +91,9 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum break; case condformat::ICONSET: 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) { case condformat::entry::FORMULA: case condformat::entry::CONDITION: + case condformat::entry::DATE: break; case condformat::entry::COLORSCALE2: case condformat::entry::COLORSCALE3: @@ -275,6 +279,14 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox) static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData(); itr->SetActive(); 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(); return 0; diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 817da0b999dc..05e93355371a 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -254,7 +254,6 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c void ScConditionFrmtEntry::Init() { - maLbStyle.SetSeparatorPos(0); maEdVal1.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) ); maEdVal2.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) ); maEdVal1.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) ); @@ -266,6 +265,7 @@ void ScConditionFrmtEntry::Init() maEdVal1.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) ); maEdVal2.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) ); + maLbStyle.SetSeparatorPos(0); SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA ); for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() ) { @@ -402,9 +402,11 @@ void ScConditionFrmtEntry::SetInactive() 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 SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA ); @@ -430,26 +432,32 @@ IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl) // Find the new style and add it into the style list boxes 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() ) { 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); - maLbStyle.SelectEntry(aName); + rLbStyle.InsertEntry(aName); + rLbStyle.SelectEntry(aName); } } } - rtl::OUString aStyleName = maLbStyle.GetSelectEntry(); - SfxStyleSheetBase* pStyleSheet = mpDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA ); + rtl::OUString aStyleName = rLbStyle.GetSelectEntry(); + SfxStyleSheetBase* pStyleSheet = pDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA ); if(pStyleSheet) { const SfxItemSet& rSet = pStyleSheet->GetItemSet(); - maWdPreview.Init( rSet ); + rWdPreview.Init( rSet ); } +} +} + +IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl) +{ + StyleSelect( maLbStyle, mpDoc, maWdPreview ); return 0; } @@ -495,51 +503,7 @@ void ScFormulaFrmtEntry::Init() IMPL_LINK_NOARG(ScFormulaFrmtEntry, StyleSelectHdl) { - if(maLbStyle.GetSelectEntryPos() == 0) - { - // 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 ); - } + StyleSelect( maLbStyle, mpDoc, maWdPreview ); return 0; } @@ -1169,4 +1133,75 @@ IMPL_LINK_NOARG( ScDataBarFrmtEntry, OptionBtnHdl ) 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: */ diff --git a/sc/source/ui/condformat/condformathelper.cxx b/sc/source/ui/condformat/condformathelper.cxx index 09eaa24859df..67a175dfb837 100644 --- a/sc/source/ui/condformat/condformathelper.cxx +++ b/sc/source/ui/condformat/condformathelper.cxx @@ -27,6 +27,8 @@ rtl::OUString getTextForType(ScCondFormatEntryType eType) return ScGlobal::GetRscString(STR_COND_FORMULA); case ICONSET: return ScGlobal::GetRscString(STR_COND_ICONSET); + case DATE: + return ScGlobal::GetRscString(STR_COND_DATE); default: break; } @@ -136,6 +138,9 @@ rtl::OUString ScCondFormatHelper::GetExpression(const ScConditionalFormat& rForm case condformat::ICONSET: aBuffer.append(getTextForType(ICONSET)); break; + case condformat::DATE: + aBuffer.append(getTextForType(DATE)); + break; } } return aBuffer.makeStringAndClear(); diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc index f631b53ac46b..b1ede3cdae66 100644 --- a/sc/source/ui/inc/condformatdlg.hrc +++ b/sc/source/ui/inc/condformatdlg.hrc @@ -67,4 +67,6 @@ #define LB_TYPE_COL_SCALE_MIN 42 #define LB_TYPE_COL_SCALE_MIDDLE 43 #define LB_TYPE_COL_SCALE_MAX 44 + +#define LB_DATE_TYPE 45 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx index 0abe83bcc428..b842ed26df39 100644 --- a/sc/source/ui/inc/condformatdlgentry.hxx +++ b/sc/source/ui/inc/condformatdlgentry.hxx @@ -21,7 +21,8 @@ enum ScCondFrmtEntryType FORMULA, COLORSCALE2, COLORSCALE3, - DATABAR + DATABAR, + DATE }; } @@ -74,7 +75,6 @@ public: class ScConditionFrmtEntry : public ScCondFrmtEntry { - //cond format ui elements ListBox maLbCondType; formula::RefEdit maEdVal1; @@ -216,4 +216,27 @@ public: 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: */ diff --git a/sc/source/ui/inc/condformathelper.hxx b/sc/source/ui/inc/condformathelper.hxx index c674df4fcf64..02d24e653dd8 100644 --- a/sc/source/ui/inc/condformathelper.hxx +++ b/sc/source/ui/inc/condformathelper.hxx @@ -19,7 +19,8 @@ enum ScCondFormatEntryType DATABAR, FORMULA, ICONSET, - COLLAPSED + DATE, + COLLAPSE }; class ScCondFormatHelper diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src index 8318cc1ebee3..ab988665a353 100644 --- a/sc/source/ui/src/condformatdlg.src +++ b/sc/source/ui/src/condformatdlg.src @@ -121,6 +121,7 @@ Control RID_COND_ENTRY "All Cells"; "Cell value is"; "Formula is"; + "Date is"; }; }; ListBox LB_CELLIS_TYPE @@ -309,6 +310,30 @@ Control RID_COND_ENTRY Size = MAP_APPFONT( 60, 14 ); 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: */ diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src index 226bb1ab920d..49e9176296ea 100644 --- a/sc/source/ui/src/globstr.src +++ b/sc/source/ui/src/globstr.src @@ -1911,6 +1911,10 @@ Resource RID_GLOBSTR { Text [ en-US ] = "Top Percent"; }; + String STR_COND_DATE + { + Text [ en-US ] = "Date is"; + }; String STR_COND_BOTTOM_PERCENT { Text [ en-US ] = "Bottom Percent"; |