[Libreoffice-commits] .: 2 commits - sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Nov 24 18:06:07 PST 2012
sc/source/core/data/conditio.cxx | 2
sc/source/ui/condformat/condformatdlgentry.cxx | 68 ++++++++++++++++---------
2 files changed, 45 insertions(+), 25 deletions(-)
New commits:
commit 93e57ac549abc41bdc875b9cbe5869c251f879a7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Nov 25 02:59:44 2012 +0100
style list should be sorted, fdo#51588
Change-Id: I771a17f2cc20602f2e6f8b18142eb990c473f2d4
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index d9c5ec5..740f5fb 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 05e9335..a1cac83 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 ) );
}
commit cc999eddee0dbff7cd90130c1f8b486517404103
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Nov 25 01:11:51 2012 +0100
approxFloor is better than just tuncating
Change-Id: I5c204de2dbf7448b8a8ab16e7178a5e1de900d28
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 28def93..d9c5ec5 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 = static_cast<long>(nVal);
+ long nCellDate = (long) ::rtl::Math::approxFloor(nVal);
Date aCellDate = *(pFormatter->GetNullDate());
aCellDate += (long) ::rtl::math::approxFloor(nVal);
More information about the Libreoffice-commits
mailing list