summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-09-15 12:14:58 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2010-09-15 14:09:38 +0200
commit879dfb1acaaffa5eb6a44c84561235ff55d2c8b3 (patch)
treeede5f1ed5fcb17b4bc9f84682a849bc68de372a9
parent8c929c317b4c69d1f5933a95e7c34c1d24f7fb8e (diff)
sc-natural-sort.diff: Add a 'Natural' variant of sorting
i#26565
-rw-r--r--sc/inc/dbcolect.hxx1
-rw-r--r--sc/inc/sc.hrc1
-rw-r--r--sc/inc/sortparam.hxx1
-rw-r--r--sc/sdi/scalc.sdi2
-rw-r--r--sc/source/core/data/sortparam.cxx6
-rw-r--r--sc/source/core/data/table3.cxx166
-rw-r--r--sc/source/core/tool/dbcolect.cxx4
-rw-r--r--sc/source/ui/dbgui/tpsort.cxx19
-rw-r--r--sc/source/ui/inc/sortdlg.hrc3
-rw-r--r--sc/source/ui/inc/tpsort.hxx7
-rw-r--r--sc/source/ui/src/sortdlg.src37
-rw-r--r--sc/source/ui/view/cellsh2.cxx7
12 files changed, 219 insertions, 35 deletions
diff --git a/sc/inc/dbcolect.hxx b/sc/inc/dbcolect.hxx
index 72356683d1a4..55f476aea296 100644
--- a/sc/inc/dbcolect.hxx
+++ b/sc/inc/dbcolect.hxx
@@ -60,6 +60,7 @@ private:
BOOL bStripData;
// SortParam
BOOL bSortCaseSens;
+ BOOL bSortNaturalSort;
BOOL bIncludePattern;
BOOL bSortInplace;
BOOL bSortUserDef;
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index c076bafcf6a3..cc9cc9b582a2 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -1124,6 +1124,7 @@
#define SID_SORT_CASESENS (SC_PARAM_START+2)
#define SID_SORT_ATTRIBS (SC_PARAM_START+3)
#define SID_SORT_USERDEF (SC_PARAM_START+4)
+#define SID_SORT_NATURALSORT (SC_PARAM_START+5)
// Resourcen -------------------------------------------------------------
diff --git a/sc/inc/sortparam.hxx b/sc/inc/sortparam.hxx
index 650293893678..9791939cde35 100644
--- a/sc/inc/sortparam.hxx
+++ b/sc/inc/sortparam.hxx
@@ -49,6 +49,7 @@ struct SC_DLLPUBLIC ScSortParam
BOOL bHasHeader;
BOOL bByRow;
BOOL bCaseSens;
+ BOOL bNaturalSort;
BOOL bUserDef;
USHORT nUserIndex;
BOOL bIncludePattern;
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 6d55f05874d7..9a5d959d9d5b 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -1574,7 +1574,7 @@ SfxVoidItem DataSelect SID_DATA_SELECT
//--------------------------------------------------------------------------
SfxVoidItem DataSort SID_SORT
-(SfxBoolItem ByRows SID_SORT_BYROW,SfxBoolItem HasHeader SID_SORT_HASHEADER,SfxBoolItem CaseSensitive SID_SORT_CASESENS,SfxBoolItem IncludeAttribs SID_SORT_ATTRIBS,SfxUInt16Item UserDefIndex SID_SORT_USERDEF,SfxInt32Item Col1 FN_PARAM_1,SfxBoolItem Ascending1 FN_PARAM_2,SfxInt32Item Col2 FN_PARAM_3,SfxBoolItem Ascending2 FN_PARAM_4,SfxInt32Item Col3 FN_PARAM_5,SfxBoolItem Ascending3 FN_PARAM_6)
+(SfxBoolItem ByRows SID_SORT_BYROW,SfxBoolItem HasHeader SID_SORT_HASHEADER,SfxBoolItem CaseSensitive SID_SORT_CASESENS,SfxBoolItem NaturalSort SID_SORT_NATURALSORT,SfxBoolItem IncludeAttribs SID_SORT_ATTRIBS,SfxUInt16Item UserDefIndex SID_SORT_USERDEF,SfxInt32Item Col1 FN_PARAM_1,SfxBoolItem Ascending1 FN_PARAM_2,SfxInt32Item Col2 FN_PARAM_3,SfxBoolItem Ascending2 FN_PARAM_4,SfxInt32Item Col3 FN_PARAM_5,SfxBoolItem Ascending3 FN_PARAM_6)
[
/* flags: */
AutoUpdate = FALSE,
diff --git a/sc/source/core/data/sortparam.cxx b/sc/source/core/data/sortparam.cxx
index 9e8d355e74fa..a3f6fe91133a 100644
--- a/sc/source/core/data/sortparam.cxx
+++ b/sc/source/core/data/sortparam.cxx
@@ -48,7 +48,7 @@ ScSortParam::ScSortParam()
ScSortParam::ScSortParam( const ScSortParam& r ) :
nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2),
- bHasHeader(r.bHasHeader),bByRow(r.bByRow),bCaseSens(r.bCaseSens),
+ bHasHeader(r.bHasHeader),bByRow(r.bByRow),bCaseSens(r.bCaseSens),bNaturalSort(r.bNaturalSort),
bUserDef(r.bUserDef),nUserIndex(r.nUserIndex),bIncludePattern(r.bIncludePattern),
bInplace(r.bInplace),
nDestTab(r.nDestTab),nDestCol(r.nDestCol),nDestRow(r.nDestRow),
@@ -71,7 +71,7 @@ void ScSortParam::Clear()
nCompatHeader = 2;
nDestTab = 0;
nUserIndex = 0;
- bHasHeader=bCaseSens=bUserDef = FALSE;
+ bHasHeader=bCaseSens=bUserDef=bNaturalSort = FALSE;
bByRow=bIncludePattern=bInplace = TRUE;
aCollatorLocale = ::com::sun::star::lang::Locale();
aCollatorAlgorithm.Erase();
@@ -94,6 +94,7 @@ ScSortParam& ScSortParam::operator=( const ScSortParam& r )
nRow2 = r.nRow2;
bHasHeader = r.bHasHeader;
bCaseSens = r.bCaseSens;
+ bNaturalSort = r.bNaturalSort;
bByRow = r.bByRow;
bUserDef = r.bUserDef;
nUserIndex = r.nUserIndex;
@@ -135,6 +136,7 @@ BOOL ScSortParam::operator==( const ScSortParam& rOther ) const
&& (bHasHeader == rOther.bHasHeader)
&& (bByRow == rOther.bByRow)
&& (bCaseSens == rOther.bCaseSens)
+ && (bNaturalSort == rOther.bNaturalSort)
&& (bUserDef == rOther.bUserDef)
&& (nUserIndex == rOther.nUserIndex)
&& (bIncludePattern == rOther.bIncludePattern)
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index bd6a2c92c442..edda2148dcb6 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -62,6 +62,143 @@
#include <vector>
+using namespace ::com::sun::star;
+
+namespace naturalsort {
+
+using namespace ::com::sun::star::i18n;
+
+/** Splits a given string into three parts: the prefix, number string, and
+ the suffix.
+
+ @param sWhole
+ Original string to be split into pieces
+
+ @param sPrefix
+ Prefix string that consists of the part before the first number token
+
+ @param sSuffix
+ String after the last number token. This may still contain number strings.
+
+ @param fNum
+ Number converted from the middle number string
+
+ @return Returns TRUE if a numeral element is found in a given string, or
+ FALSE if no numeral element is found.
+*/
+bool SplitString( const rtl::OUString &sWhole,
+ rtl::OUString &sPrefix, rtl::OUString &sSuffix, double &fNum )
+{
+ i18n::LocaleDataItem aLocaleItem = ScGlobal::pLocaleData->getLocaleItem();
+
+ // Get prefix element
+ rtl::OUString sEmpty, sUser = rtl::OUString::createFromAscii( "-" );
+ ParseResult aPRPre = ScGlobal::pCharClass->parsePredefinedToken(
+ KParseType::IDENTNAME, sWhole, 0,
+ KParseTokens::ANY_LETTER, sUser, KParseTokens::ANY_LETTER, sUser );
+ sPrefix = sWhole.copy( 0, aPRPre.EndPos );
+
+ // Return FALSE if no numeral element is found
+ if ( aPRPre.EndPos == sWhole.getLength() )
+ return false;
+
+ // Get numeral element
+ sUser = aLocaleItem.decimalSeparator;
+ ParseResult aPRNum = ScGlobal::pCharClass->parsePredefinedToken(
+ KParseType::ANY_NUMBER, sWhole, aPRPre.EndPos,
+ KParseTokens::ANY_NUMBER, sEmpty, KParseTokens::ANY_NUMBER, sUser );
+
+ if ( aPRNum.EndPos == aPRPre.EndPos )
+ return false;
+
+ fNum = aPRNum.Value;
+ sSuffix = sWhole.copy( aPRNum.EndPos );
+
+ return true;
+}
+
+/** Naturally compares two given strings.
+
+ This is the main function that should be called externally. It returns
+ either 1, 0, or -1 depending on the comparison result of given two strings.
+
+ @param sInput1
+ Input string 1
+
+ @param sInput2
+ Input string 2
+
+ @param bCaseSens
+ Boolean value for case sensitivity
+
+ @param pData
+ Pointer to user defined sort list
+
+ @param pCW
+ Pointer to collator wrapper for normal string comparison
+
+ @return Returnes 1 if sInput1 is greater, 0 if sInput1 == sInput2, and -1 if
+ sInput2 is greater.
+*/
+short Compare( const String &sInput1, const String &sInput2,
+ const BOOL bCaseSens, const ScUserListData* pData, const CollatorWrapper *pCW )
+{
+ rtl::OUString sStr1( sInput1 ), sStr2( sInput2 ), sPre1, sSuf1, sPre2, sSuf2;
+
+ do
+ {
+ double nNum1, nNum2;
+ BOOL bNumFound1 = SplitString( sStr1, sPre1, sSuf1, nNum1 );
+ BOOL bNumFound2 = SplitString( sStr2, sPre2, sSuf2, nNum2 );
+
+ short nPreRes; // Prefix comparison result
+ if ( pData )
+ {
+ if ( bCaseSens )
+ {
+ if ( !bNumFound1 || !bNumFound2 )
+ return static_cast<short>(pData->Compare( sStr1, sStr2 ));
+ else
+ nPreRes = pData->Compare( sPre1, sPre2 );
+ }
+ else
+ {
+ if ( !bNumFound1 || !bNumFound2 )
+ return static_cast<short>(pData->ICompare( sStr1, sStr2 ));
+ else
+ nPreRes = pData->ICompare( sPre1, sPre2 );
+ }
+ }
+ else
+ {
+ if ( !bNumFound1 || !bNumFound2 )
+ return static_cast<short>(pCW->compareString( sStr1, sStr2 ));
+ else
+ nPreRes = static_cast<short>(pCW->compareString( sPre1, sPre2 ));
+ }
+
+ // Prefix strings differ. Return immediately.
+ if ( nPreRes != 0 ) return nPreRes;
+
+ if ( nNum1 != nNum2 )
+ {
+ if ( nNum1 < nNum2 ) return -1;
+ return static_cast<short>( nNum1 > nNum2 );
+ }
+
+ // The prefix and the first numerical elements are equal, but the suffix
+ // strings may still differ. Stay in the loop.
+
+ sStr1 = sSuf1;
+ sStr2 = sSuf2;
+
+ } while (true);
+
+ return 0;
+}
+
+}
+
// STATIC DATA -----------------------------------------------------------
const USHORT nMaxSorts = 3; // maximale Anzahl Sortierkriterien in aSortParam
@@ -280,25 +417,40 @@ short ScTable::CompareCell( USHORT nSort,
((ScStringCell*)pCell2)->GetString(aStr2);
else
GetString(nCell2Col, nCell2Row, aStr2);
- BOOL bUserDef = aSortParam.bUserDef;
+
+ BOOL bUserDef = aSortParam.bUserDef; // custom sort order
+ BOOL bNaturalSort = aSortParam.bNaturalSort; // natural sort
+ BOOL bCaseSens = aSortParam.bCaseSens; // case sensitivity
+
if (bUserDef)
{
ScUserListData* pData =
- (ScUserListData*)(ScGlobal::GetUserList()->At(
- aSortParam.nUserIndex));
+ static_cast<ScUserListData*>( (ScGlobal::GetUserList()->At(
+ aSortParam.nUserIndex)) );
+
if (pData)
{
- if ( aSortParam.bCaseSens )
- nRes = sal::static_int_cast<short>( pData->Compare(aStr1, aStr2) );
+ if ( bNaturalSort )
+ nRes = naturalsort::Compare( aStr1, aStr2, bCaseSens, pData, pSortCollator );
else
- nRes = sal::static_int_cast<short>( pData->ICompare(aStr1, aStr2) );
+ {
+ if ( bCaseSens )
+ nRes = sal::static_int_cast<short>( pData->Compare(aStr1, aStr2) );
+ else
+ nRes = sal::static_int_cast<short>( pData->ICompare(aStr1, aStr2) );
+ }
}
else
bUserDef = FALSE;
}
if (!bUserDef)
- nRes = (short) pSortCollator->compareString( aStr1, aStr2 );
+ {
+ if ( bNaturalSort )
+ nRes = naturalsort::Compare( aStr1, aStr2, bCaseSens, NULL, pSortCollator );
+ else
+ nRes = static_cast<short>( pSortCollator->compareString( aStr1, aStr2 ) );
+ }
}
else if ( bStr1 ) // String <-> Zahl
nRes = 1; // Zahl vorne
diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx
index 7f94cb64c827..141389d76ec1 100644
--- a/sc/source/core/tool/dbcolect.cxx
+++ b/sc/source/core/tool/dbcolect.cxx
@@ -102,6 +102,7 @@ ScDBData::ScDBData( const ScDBData& rData ) :
bKeepFmt (rData.bKeepFmt),
bStripData (rData.bStripData),
bSortCaseSens (rData.bSortCaseSens),
+ bSortNaturalSort (rData.bSortNaturalSort),
bIncludePattern (rData.bIncludePattern),
bSortInplace (rData.bSortInplace),
bSortUserDef (rData.bSortUserDef),
@@ -196,6 +197,7 @@ ScDBData& ScDBData::operator= (const ScDBData& rData)
bKeepFmt = rData.bKeepFmt;
bStripData = rData.bStripData;
bSortCaseSens = rData.bSortCaseSens;
+ bSortNaturalSort = rData.bSortNaturalSort;
bIncludePattern = rData.bIncludePattern;
bSortInplace = rData.bSortInplace;
nSortDestTab = rData.nSortDestTab;
@@ -448,6 +450,7 @@ void ScDBData::GetSortParam( ScSortParam& rSortParam ) const
rSortParam.bByRow = bByRow;
rSortParam.bHasHeader = bHasHeader;
rSortParam.bCaseSens = bSortCaseSens;
+ rSortParam.bNaturalSort = bSortNaturalSort;
rSortParam.bInplace = bSortInplace;
rSortParam.nDestTab = nSortDestTab;
rSortParam.nDestCol = nSortDestCol;
@@ -468,6 +471,7 @@ void ScDBData::GetSortParam( ScSortParam& rSortParam ) const
void ScDBData::SetSortParam( const ScSortParam& rSortParam )
{
bSortCaseSens = rSortParam.bCaseSens;
+ bSortNaturalSort = rSortParam.bNaturalSort;
bIncludePattern = rSortParam.bIncludePattern;
bSortInplace = rSortParam.bInplace;
nSortDestTab = rSortParam.nDestTab;
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 18c1eb25664a..8fcea2a0e7e7 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -564,6 +564,7 @@ ScTabPageSortOptions::ScTabPageSortOptions( Window* pParent,
aBtnHeader ( this, ScResId( BTN_LABEL ) ),
aBtnFormats ( this, ScResId( BTN_FORMATS ) ),
aBtnCopyResult ( this, ScResId( BTN_COPYRESULT ) ),
+ aBtnNaturalSort ( this, ScResId( BTN_NATURALSORT ) ),
aLbOutPos ( this, ScResId( LB_OUTAREA ) ),
aEdOutPos ( this, ScResId( ED_OUTAREA ) ),
aBtnSortUser ( this, ScResId( BTN_SORT_USER ) ),
@@ -575,7 +576,7 @@ ScTabPageSortOptions::ScTabPageSortOptions( Window* pParent,
aLineDirection ( this, ScResId( FL_DIRECTION ) ),
aBtnTopDown ( this, ScResId( BTN_TOP_DOWN ) ),
aBtnLeftRight ( this, ScResId( BTN_LEFT_RIGHT ) ),
- aFtAreaLabel ( this, ScResId( FT_AREA_LABEL ) ),
+// aFtAreaLabel ( this, ScResId( FT_AREA_LABEL ) ),
// aFtArea ( this, ScResId( FT_AREA ) ),
//
#if ENABLE_LAYOUT_EXPERIMENTAL
@@ -619,8 +620,8 @@ __EXPORT ScTabPageSortOptions::~ScTabPageSortOptions()
void ScTabPageSortOptions::Init()
{
- aStrAreaLabel = aFtAreaLabel.GetText();
- aStrAreaLabel.Append( (sal_Unicode) ' ' );
+// aStrAreaLabel = aFtAreaLabel.GetText();
+// aStrAreaLabel.Append( (sal_Unicode) ' ' );
// CollatorRessource has user-visible names for sort algorithms
pColRes = new CollatorRessource();
@@ -699,8 +700,8 @@ void ScTabPageSortOptions::Init()
theArea += ')';
//aFtArea.SetText( theArea );
- theArea.Insert( aStrAreaLabel, 0 );
- aFtAreaLabel.SetText( theArea );
+ //theArea.Insert( aStrAreaLabel, 0 );
+ //aFtAreaLabel.SetText( theArea );
aBtnHeader.SetText( aStrColLabel );
}
@@ -749,9 +750,10 @@ void __EXPORT ScTabPageSortOptions::Reset( const SfxItemSet& /* rArgSet */ )
aLbSortUser.SelectEntryPos( 0 );
}
- aBtnCase.Check ( rSortData.bCaseSens );
- aBtnFormats.Check ( rSortData.bIncludePattern );
- aBtnHeader.Check ( rSortData.bHasHeader );
+ aBtnCase.Check ( rSortData.bCaseSens );
+ aBtnFormats.Check ( rSortData.bIncludePattern );
+ aBtnHeader.Check ( rSortData.bHasHeader );
+ aBtnNaturalSort.Check ( rSortData.bNaturalSort );
if ( rSortData.bByRow )
{
@@ -817,6 +819,7 @@ BOOL __EXPORT ScTabPageSortOptions::FillItemSet( SfxItemSet& rArgSet )
theSortData.bByRow = aBtnTopDown.IsChecked();
theSortData.bHasHeader = aBtnHeader.IsChecked();
theSortData.bCaseSens = aBtnCase.IsChecked();
+ theSortData.bNaturalSort = aBtnNaturalSort.IsChecked();
theSortData.bIncludePattern = aBtnFormats.IsChecked();
theSortData.bInplace = !aBtnCopyResult.IsChecked();
theSortData.nDestCol = theOutPos.Col();
diff --git a/sc/source/ui/inc/sortdlg.hrc b/sc/source/ui/inc/sortdlg.hrc
index 387690531cfd..d079ea560779 100644
--- a/sc/source/ui/inc/sortdlg.hrc
+++ b/sc/source/ui/inc/sortdlg.hrc
@@ -63,7 +63,7 @@
#define LB_SORT_USER 2
#define LB_OUTAREA 3
#define ED_OUTAREA 4
-#define FT_AREA_LABEL 5
+//#define FT_AREA_LABEL 5
//#define FT_AREA 6
#define BTN_SORT_USER 7
#define BTN_CASESENSITIVE 8
@@ -78,6 +78,7 @@
#define LB_LANGUAGE 17
#define FT_ALGORITHM 18
#define LB_ALGORITHM 19
+#define BTN_NATURALSORT 20
//#define RID_SCDLG_SORT_WARNING
#define FT_TEXT 1
diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx
index d1ba772a8ca2..6b7a11f10802 100644
--- a/sc/source/ui/inc/tpsort.hxx
+++ b/sc/source/ui/inc/tpsort.hxx
@@ -50,7 +50,7 @@ class ScSortDlg;
struct ScSortParam;
//========================================================================
-// Kriterien
+// Kriterien (Sort Criteria)
class ScTabPageSortFields : public SfxTabPage
{
@@ -122,7 +122,7 @@ private:
};
//========================================================================
-// Sortieroptionen:
+// Sortieroptionen (Sort Options)
class ScDocument;
class ScRangeData;
@@ -164,6 +164,7 @@ private:
CheckBox aBtnCase;
CheckBox aBtnHeader;
CheckBox aBtnFormats;
+ CheckBox aBtnNaturalSort;
CheckBox aBtnCopyResult;
ListBox aLbOutPos;
@@ -181,7 +182,7 @@ private:
RadioButton aBtnTopDown;
RadioButton aBtnLeftRight;
- FixedText aFtAreaLabel;
+// FixedText aFtAreaLabel;
// FixedInfo aFtArea;
LocalizedString aStrRowLabel;
LocalizedString aStrColLabel;
diff --git a/sc/source/ui/src/sortdlg.src b/sc/source/ui/src/sortdlg.src
index 3aca09211edd..1062eb58e1dc 100644
--- a/sc/source/ui/src/sortdlg.src
+++ b/sc/source/ui/src/sortdlg.src
@@ -151,17 +151,28 @@ TabPage RID_SCPAGE_SORT_OPTIONS
Text [ en-US ] = "Include ~formats" ;
TabStop = TRUE ;
};
- CheckBox BTN_COPYRESULT
+ CheckBox BTN_NATURALSORT
{
Pos = MAP_APPFONT ( 12 , 48 ) ;
Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text [ de ] = "Enable ~natural sort" ;
+ Text [ en-US ] = "Enable ~natural sort" ;
+ Text [ cs ] = "Aktivovat přirozené třídění" ;
+ Text [ sk ] = "Aktivovať prirodzené triedenie" ;
+ TabStop = TRUE ;
+ Text [ x-comment ] = " " ;
+ };
+ CheckBox BTN_COPYRESULT
+ {
+ Pos = MAP_APPFONT ( 12 , 62 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
Text [ en-US ] = "~Copy sort results to:" ;
TabStop = TRUE ;
};
ListBox LB_OUTAREA
{
Border = TRUE ;
- Pos = MAP_APPFONT ( 20 , 59 ) ;
+ Pos = MAP_APPFONT ( 20 , 73 ) ;
Size = MAP_APPFONT ( 93 , 90 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
@@ -170,13 +181,13 @@ TabPage RID_SCPAGE_SORT_OPTIONS
{
Disable = TRUE ;
Border = TRUE ;
- Pos = MAP_APPFONT ( 119 , 59 ) ;
+ Pos = MAP_APPFONT ( 119 , 73 ) ;
Size = MAP_APPFONT ( 132 , 12 ) ;
TabStop = TRUE ;
};
CheckBox BTN_SORT_USER
{
- Pos = MAP_APPFONT ( 12 , 75 ) ;
+ Pos = MAP_APPFONT ( 12 , 89 ) ;
Size = MAP_APPFONT ( 242 , 10 ) ;
Text [ en-US ] = "Custom sort ~order" ;
TabStop = TRUE ;
@@ -185,21 +196,21 @@ TabPage RID_SCPAGE_SORT_OPTIONS
{
Disable = TRUE ;
Border = TRUE ;
- Pos = MAP_APPFONT ( 20 , 86 ) ;
+ Pos = MAP_APPFONT ( 20 , 100 ) ;
Size = MAP_APPFONT ( 231 , 90 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
};
FixedText FT_LANGUAGE
{
- Pos = MAP_APPFONT ( 12 , 104 ) ;
+ Pos = MAP_APPFONT ( 12 , 118 ) ;
Size = MAP_APPFONT ( 101 , 8 ) ;
Text [ en-US ] = "~Language";
};
ListBox LB_LANGUAGE
{
Border = TRUE ;
- Pos = MAP_APPFONT ( 12 , 115 ) ;
+ Pos = MAP_APPFONT ( 12 , 129 ) ;
Size = MAP_APPFONT ( 101 , 90 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
@@ -207,44 +218,46 @@ TabPage RID_SCPAGE_SORT_OPTIONS
};
FixedText FT_ALGORITHM
{
- Pos = MAP_APPFONT ( 119 , 104 ) ;
+ Pos = MAP_APPFONT ( 119 , 118 ) ;
Size = MAP_APPFONT ( 132 , 8 ) ;
Text [ en-US ] = "O~ptions";
};
ListBox LB_ALGORITHM
{
Border = TRUE ;
- Pos = MAP_APPFONT ( 119 , 115 ) ;
+ Pos = MAP_APPFONT ( 119 , 129 ) ;
Size = MAP_APPFONT ( 132 , 90 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
};
FixedLine FL_DIRECTION
{
- Pos = MAP_APPFONT ( 6 , 133 ) ;
+ Pos = MAP_APPFONT ( 6 , 147 ) ;
Size = MAP_APPFONT ( 248 , 8 ) ;
Text [ en-US ] = "Direction" ;
};
RadioButton BTN_TOP_DOWN
{
- Pos = MAP_APPFONT ( 12 , 144 ) ;
+ Pos = MAP_APPFONT ( 12 , 158 ) ;
Size = MAP_APPFONT ( 242 , 10 ) ;
Text [ en-US ] = "~Top to bottom (sort rows)" ;
TabStop = TRUE ;
};
RadioButton BTN_LEFT_RIGHT
{
- Pos = MAP_APPFONT ( 12 , 158 ) ;
+ Pos = MAP_APPFONT ( 12 , 172 ) ;
Size = MAP_APPFONT ( 242 , 10 ) ;
Text [ en-US ] = "L~eft to right (sort columns)" ;
TabStop = TRUE ;
};
+/*
FixedText FT_AREA_LABEL
{
Pos = MAP_APPFONT ( 6 , 171 ) ;
Size = MAP_APPFONT ( 248 , 8 ) ;
Text [ en-US ] = "Data area:" ;
};
+*/
};
TabDialog RID_SCDLG_SORT
{
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 086160263739..c46d4c5558e5 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -438,6 +438,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
aSortParam.bHasHeader = bHasHeader;
aSortParam.bByRow = TRUE;
aSortParam.bCaseSens = FALSE;
+ aSortParam.bNaturalSort = FALSE;
aSortParam.bIncludePattern = TRUE;
aSortParam.bInplace = TRUE;
aSortParam.bDoSort[0] = TRUE;
@@ -489,6 +490,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
aSortParam.bHasHeader = ((const SfxBoolItem*)pItem)->GetValue();
if ( pArgs->GetItemState( SID_SORT_CASESENS, TRUE, &pItem ) == SFX_ITEM_SET )
aSortParam.bCaseSens = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_NATURALSORT, TRUE, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bNaturalSort = ((const SfxBoolItem*)pItem)->GetValue();
if ( pArgs->GetItemState( SID_SORT_ATTRIBS, TRUE, &pItem ) == SFX_ITEM_SET )
aSortParam.bIncludePattern = ((const SfxBoolItem*)pItem)->GetValue();
if ( pArgs->GetItemState( SID_SORT_USERDEF, TRUE, &pItem ) == SFX_ITEM_SET )
@@ -552,7 +555,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
pDlg = pFact->CreateScSortDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SORT );
DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
- pDlg->SetCurPageId(1);
+ pDlg->SetCurPageId(1); // 1=sort field tab 2=sort options tab
if ( pDlg->Execute() == RET_OK )
{
@@ -571,6 +574,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
rOutParam.bHasHeader ) );
rReq.AppendItem( SfxBoolItem( SID_SORT_CASESENS,
rOutParam.bCaseSens ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_NATURALSORT,
+ rOutParam.bNaturalSort ) );
rReq.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
rOutParam.bIncludePattern ) );
USHORT nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;