diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-11-25 02:59:44 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-11-25 03:03:57 +0100 |
commit | 93e57ac549abc41bdc875b9cbe5869c251f879a7 (patch) | |
tree | b52b690b96ee413a58fba86a4c64497935aa034f /sc | |
parent | cc999eddee0dbff7cd90130c1f8b486517404103 (diff) |
style list should be sorted, fdo#51588
Change-Id: I771a17f2cc20602f2e6f8b18142eb990c473f2d4
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/conditio.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlgentry.cxx | 68 |
2 files changed, 45 insertions, 25 deletions
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index d9c5ec5e867c..740f5fb323c3 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1659,7 +1659,7 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const long nCurrentDate = aActDate - *(pFormatter->GetNullDate()); double nVal = mpDoc->GetValue(rPos); - long nCellDate = (long) ::rtl::Math::approxFloor(nVal); + long nCellDate = (long) ::rtl::math::approxFloor(nVal); Date aCellDate = *(pFormatter->GetNullDate()); aCellDate += (long) ::rtl::math::approxFloor(nVal); diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 05e93355371a..a1cac8329d24 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -29,6 +29,8 @@ #include "globstr.hrc" +#include <set> + ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScAddress& rPos): Control(pParent, ScResId( RID_COND_ENTRY ) ), mbActive(false), @@ -135,6 +137,27 @@ IMPL_LINK(ScCondFrmtEntry, EdModifyHdl, Edit*, pEdit) // //condition +// +namespace { + +void FillStlyeListBox( ScDocument* pDoc, ListBox& rLbStyle ) +{ + rLbStyle.SetSeparatorPos(0); + std::set<rtl::OUString> aStyleNames; + SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA ); + for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() ) + { + rtl::OUString aName = pStyle->GetName(); + aStyleNames.insert(aName); + } + for(std::set<rtl::OUString>::const_iterator itr = aStyleNames.begin(), itrEnd = aStyleNames.end(); + itr != itrEnd; ++itr) + { + rLbStyle.InsertEntry( *itr ); + } +} + +} ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry ): ScCondFrmtEntry( pParent, pDoc, rPos ), @@ -265,13 +288,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() ) - { - rtl::OUString aName = pStyle->GetName(); - maLbStyle.InsertEntry( aName ); - } + FillStlyeListBox( mpDoc, maLbStyle ); maLbStyle.SetSelectHdl( LINK( this, ScConditionFrmtEntry, StyleSelectHdl ) ); maLbCondType.SetSelectHdl( LINK( this, ScConditionFrmtEntry, ConditionTypeSelectHdl ) ); @@ -433,13 +450,28 @@ void StyleSelect( ListBox& rLbStyle, ScDocument* pDoc, SvxFontPrevWindow& rWdPre // Find the new style and add it into the style list boxes rtl::OUString aNewStyle; SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA ); - for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() ) + bool bFound = false; + for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle && !bFound; pStyle = aStyleIter.Next() ) { rtl::OUString aName = pStyle->GetName(); if ( rLbStyle.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND ) // all lists contain the same entries { - rLbStyle.InsertEntry(aName); - rLbStyle.SelectEntry(aName); + for( sal_uInt16 i = 1, n = rLbStyle.GetEntryCount(); i <= n && !bFound; ++i) + { + rtl::OUString aStyleName = ScGlobal::pCharClass->uppercase(rtl::OUString(rLbStyle.GetEntry(i))); + if( i == n ) + { + rLbStyle.InsertEntry(aName); + rLbStyle.SelectEntry(aName); + bFound = true; + } + else if( aStyleName > ScGlobal::pCharClass->uppercase(aName) ) + { + rLbStyle.InsertEntry(aName, i); + rLbStyle.SelectEntry(aName); + bFound = true; + } + } } } } @@ -488,16 +520,10 @@ ScFormulaFrmtEntry::ScFormulaFrmtEntry( Window* pParent, ScDocument* pDoc, const void ScFormulaFrmtEntry::Init() { - maLbStyle.SetSeparatorPos(0); maEdFormula.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) ); maEdFormula.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) ); - 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 ); - } + FillStlyeListBox( mpDoc, maLbStyle ); maLbStyle.SetSelectHdl( LINK( this, ScFormulaFrmtEntry, StyleSelectHdl ) ); } @@ -1155,13 +1181,7 @@ 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 ); - } + FillStlyeListBox( mpDoc, maLbStyle ); maLbStyle.SetSelectHdl( LINK( this, ScDateFrmtEntry, StyleSelectHdl ) ); } |