update dev300-m58
[ooovba.git] / applied_patches / 0128-sc-natural-sort.diff
blobde2fe893306c88b06d02cd715f88452790bcb7dd
1 diff --git sc/inc/dbcolect.hxx sc/inc/dbcolect.hxx
2 index 543904e..48d314e 100644
3 --- sc/inc/dbcolect.hxx
4 +++ sc/inc/dbcolect.hxx
5 @@ -63,6 +63,7 @@ private:
6 BOOL bStripData;
7 // SortParam
8 BOOL bSortCaseSens;
9 + BOOL bSortNaturalSort;
10 BOOL bIncludePattern;
11 BOOL bSortInplace;
12 BOOL bSortUserDef;
13 diff --git sc/inc/sc.hrc sc/inc/sc.hrc
14 index 33d0240..85621ce 100644
15 --- sc/inc/sc.hrc
16 +++ sc/inc/sc.hrc
17 @@ -1127,6 +1127,7 @@
18 #define SID_SORT_CASESENS (SC_PARAM_START+2)
19 #define SID_SORT_ATTRIBS (SC_PARAM_START+3)
20 #define SID_SORT_USERDEF (SC_PARAM_START+4)
21 +#define SID_SORT_NATURALSORT (SC_PARAM_START+5)
23 // Resourcen -------------------------------------------------------------
25 diff --git sc/inc/sortparam.hxx sc/inc/sortparam.hxx
26 index 7ef0a80..bc0f863 100644
27 --- sc/inc/sortparam.hxx
28 +++ sc/inc/sortparam.hxx
29 @@ -52,6 +52,7 @@ struct SC_DLLPUBLIC ScSortParam
30 BOOL bHasHeader;
31 BOOL bByRow;
32 BOOL bCaseSens;
33 + BOOL bNaturalSort;
34 BOOL bUserDef;
35 USHORT nUserIndex;
36 BOOL bIncludePattern;
37 diff --git sc/sdi/scalc.sdi sc/sdi/scalc.sdi
38 index ad21670..0687d1f 100644
39 --- sc/sdi/scalc.sdi
40 +++ sc/sdi/scalc.sdi
41 @@ -1577,7 +1577,7 @@ SfxVoidItem DataSelect SID_DATA_SELECT
43 //--------------------------------------------------------------------------
44 SfxVoidItem DataSort SID_SORT
45 -(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)
46 +(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)
48 /* flags: */
49 AutoUpdate = FALSE,
50 diff --git sc/source/core/data/sortparam.cxx sc/source/core/data/sortparam.cxx
51 index dfab465..332772e 100644
52 --- sc/source/core/data/sortparam.cxx
53 +++ sc/source/core/data/sortparam.cxx
54 @@ -51,7 +51,7 @@ ScSortParam::ScSortParam()
56 ScSortParam::ScSortParam( const ScSortParam& r ) :
57 nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2),
58 - bHasHeader(r.bHasHeader),bByRow(r.bByRow),bCaseSens(r.bCaseSens),
59 + bHasHeader(r.bHasHeader),bByRow(r.bByRow),bCaseSens(r.bCaseSens),bNaturalSort(r.bNaturalSort),
60 bUserDef(r.bUserDef),nUserIndex(r.nUserIndex),bIncludePattern(r.bIncludePattern),
61 bInplace(r.bInplace),
62 nDestTab(r.nDestTab),nDestCol(r.nDestCol),nDestRow(r.nDestRow),
63 @@ -74,7 +74,7 @@ void ScSortParam::Clear()
64 nCompatHeader = 2;
65 nDestTab = 0;
66 nUserIndex = 0;
67 - bHasHeader=bCaseSens=bUserDef = FALSE;
68 + bHasHeader=bCaseSens=bUserDef=bNaturalSort = FALSE;
69 bByRow=bIncludePattern=bInplace = TRUE;
70 aCollatorLocale = ::com::sun::star::lang::Locale();
71 aCollatorAlgorithm.Erase();
72 @@ -97,6 +97,7 @@ ScSortParam& ScSortParam::operator=( const ScSortParam& r )
73 nRow2 = r.nRow2;
74 bHasHeader = r.bHasHeader;
75 bCaseSens = r.bCaseSens;
76 + bNaturalSort = r.bNaturalSort;
77 bByRow = r.bByRow;
78 bUserDef = r.bUserDef;
79 nUserIndex = r.nUserIndex;
80 @@ -138,6 +139,7 @@ BOOL ScSortParam::operator==( const ScSortParam& rOther ) const
81 && (bHasHeader == rOther.bHasHeader)
82 && (bByRow == rOther.bByRow)
83 && (bCaseSens == rOther.bCaseSens)
84 + && (bNaturalSort == rOther.bNaturalSort)
85 && (bUserDef == rOther.bUserDef)
86 && (nUserIndex == rOther.nUserIndex)
87 && (bIncludePattern == rOther.bIncludePattern)
88 diff --git sc/source/core/data/table3.cxx sc/source/core/data/table3.cxx
89 index 2d8f0d3..390f6b1 100644
90 --- sc/source/core/data/table3.cxx
91 +++ sc/source/core/data/table3.cxx
92 @@ -64,6 +64,143 @@
94 #include <vector>
96 +using namespace ::com::sun::star;
98 +namespace naturalsort {
100 +using namespace ::com::sun::star::i18n;
102 +/** Splits a given string into three parts: the prefix, number string, and
103 + the suffix.
105 + @param sWhole
106 + Original string to be split into pieces
108 + @param sPrefix
109 + Prefix string that consists of the part before the first number token
111 + @param sSuffix
112 + String after the last number token. This may still contain number strings.
114 + @param fNum
115 + Number converted from the middle number string
117 + @return Returns TRUE if a numeral element is found in a given string, or
118 + FALSE if no numeral element is found.
120 +bool SplitString( const rtl::OUString &sWhole,
121 + rtl::OUString &sPrefix, rtl::OUString &sSuffix, double &fNum )
123 + i18n::LocaleDataItem aLocaleItem = ScGlobal::pLocaleData->getLocaleItem();
125 + // Get prefix element
126 + rtl::OUString sEmpty, sUser = rtl::OUString::createFromAscii( "-" );
127 + ParseResult aPRPre = ScGlobal::pCharClass->parsePredefinedToken(
128 + KParseType::IDENTNAME, sWhole, 0,
129 + KParseTokens::ANY_LETTER, sUser, KParseTokens::ANY_LETTER, sUser );
130 + sPrefix = sWhole.copy( 0, aPRPre.EndPos );
132 + // Return FALSE if no numeral element is found
133 + if ( aPRPre.EndPos == sWhole.getLength() )
134 + return false;
136 + // Get numeral element
137 + sUser = aLocaleItem.decimalSeparator;
138 + ParseResult aPRNum = ScGlobal::pCharClass->parsePredefinedToken(
139 + KParseType::ANY_NUMBER, sWhole, aPRPre.EndPos,
140 + KParseTokens::ANY_NUMBER, sEmpty, KParseTokens::ANY_NUMBER, sUser );
142 + if ( aPRNum.EndPos == aPRPre.EndPos )
143 + return false;
145 + fNum = aPRNum.Value;
146 + sSuffix = sWhole.copy( aPRNum.EndPos );
148 + return true;
151 +/** Naturally compares two given strings.
153 + This is the main function that should be called externally. It returns
154 + either 1, 0, or -1 depending on the comparison result of given two strings.
156 + @param sInput1
157 + Input string 1
159 + @param sInput2
160 + Input string 2
162 + @param bCaseSens
163 + Boolean value for case sensitivity
165 + @param pData
166 + Pointer to user defined sort list
168 + @param pCW
169 + Pointer to collator wrapper for normal string comparison
171 + @return Returnes 1 if sInput1 is greater, 0 if sInput1 == sInput2, and -1 if
172 + sInput2 is greater.
174 +short Compare( const String &sInput1, const String &sInput2,
175 + const BOOL bCaseSens, const ScUserListData* pData, const CollatorWrapper *pCW )
177 + rtl::OUString sStr1( sInput1 ), sStr2( sInput2 ), sPre1, sSuf1, sPre2, sSuf2;
179 + do
181 + double nNum1, nNum2;
182 + BOOL bNumFound1 = SplitString( sStr1, sPre1, sSuf1, nNum1 );
183 + BOOL bNumFound2 = SplitString( sStr2, sPre2, sSuf2, nNum2 );
185 + short nPreRes; // Prefix comparison result
186 + if ( pData )
188 + if ( bCaseSens )
190 + if ( !bNumFound1 || !bNumFound2 )
191 + return static_cast<short>(pData->Compare( sStr1, sStr2 ));
192 + else
193 + nPreRes = pData->Compare( sPre1, sPre2 );
195 + else
197 + if ( !bNumFound1 || !bNumFound2 )
198 + return static_cast<short>(pData->ICompare( sStr1, sStr2 ));
199 + else
200 + nPreRes = pData->ICompare( sPre1, sPre2 );
202 + }
203 + else
205 + if ( !bNumFound1 || !bNumFound2 )
206 + return static_cast<short>(pCW->compareString( sStr1, sStr2 ));
207 + else
208 + nPreRes = static_cast<short>(pCW->compareString( sPre1, sPre2 ));
211 + // Prefix strings differ. Return immediately.
212 + if ( nPreRes != 0 ) return nPreRes;
214 + if ( nNum1 != nNum2 )
216 + if ( nNum1 < nNum2 ) return -1;
217 + return static_cast<short>( nNum1 > nNum2 );
220 + // The prefix and the first numerical elements are equal, but the suffix
221 + // strings may still differ. Stay in the loop.
223 + sStr1 = sSuf1;
224 + sStr2 = sSuf2;
226 + } while (true);
228 + return 0;
233 // STATIC DATA -----------------------------------------------------------
235 const USHORT nMaxSorts = 3; // maximale Anzahl Sortierkriterien in aSortParam
236 @@ -285,25 +422,40 @@ short ScTable::CompareCell( USHORT nSort,
237 ((ScStringCell*)pCell2)->GetString(aStr2);
238 else
239 GetString(nCell2Col, nCell2Row, aStr2);
240 - BOOL bUserDef = aSortParam.bUserDef;
242 + BOOL bUserDef = aSortParam.bUserDef; // custom sort order
243 + BOOL bNaturalSort = aSortParam.bNaturalSort; // natural sort
244 + BOOL bCaseSens = aSortParam.bCaseSens; // case sensitivity
246 if (bUserDef)
248 ScUserListData* pData =
249 - (ScUserListData*)(ScGlobal::GetUserList()->At(
250 - aSortParam.nUserIndex));
251 + static_cast<ScUserListData*>( (ScGlobal::GetUserList()->At(
252 + aSortParam.nUserIndex)) );
254 if (pData)
256 - if ( aSortParam.bCaseSens )
257 - nRes = sal::static_int_cast<short>( pData->Compare(aStr1, aStr2) );
258 + if ( bNaturalSort )
259 + nRes = naturalsort::Compare( aStr1, aStr2, bCaseSens, pData, pSortCollator );
260 else
261 - nRes = sal::static_int_cast<short>( pData->ICompare(aStr1, aStr2) );
263 + if ( bCaseSens )
264 + nRes = sal::static_int_cast<short>( pData->Compare(aStr1, aStr2) );
265 + else
266 + nRes = sal::static_int_cast<short>( pData->ICompare(aStr1, aStr2) );
269 else
270 bUserDef = FALSE;
273 if (!bUserDef)
274 - nRes = (short) pSortCollator->compareString( aStr1, aStr2 );
276 + if ( bNaturalSort )
277 + nRes = naturalsort::Compare( aStr1, aStr2, bCaseSens, NULL, pSortCollator );
278 + else
279 + nRes = static_cast<short>( pSortCollator->compareString( aStr1, aStr2 ) );
282 else if ( bStr1 ) // String <-> Zahl
283 nRes = 1; // Zahl vorne
284 diff --git sc/source/core/tool/dbcolect.cxx sc/source/core/tool/dbcolect.cxx
285 index a47a669..22642f4 100644
286 --- sc/source/core/tool/dbcolect.cxx
287 +++ sc/source/core/tool/dbcolect.cxx
288 @@ -105,6 +105,7 @@ ScDBData::ScDBData( const ScDBData& rData ) :
289 bKeepFmt (rData.bKeepFmt),
290 bStripData (rData.bStripData),
291 bSortCaseSens (rData.bSortCaseSens),
292 + bSortNaturalSort (rData.bSortNaturalSort),
293 bIncludePattern (rData.bIncludePattern),
294 bSortInplace (rData.bSortInplace),
295 bSortUserDef (rData.bSortUserDef),
296 @@ -198,6 +199,7 @@ ScDBData& ScDBData::operator= (const ScDBData& rData)
297 bKeepFmt = rData.bKeepFmt;
298 bStripData = rData.bStripData;
299 bSortCaseSens = rData.bSortCaseSens;
300 + bSortNaturalSort = rData.bSortNaturalSort;
301 bIncludePattern = rData.bIncludePattern;
302 bSortInplace = rData.bSortInplace;
303 nSortDestTab = rData.nSortDestTab;
304 @@ -449,6 +451,7 @@ void ScDBData::GetSortParam( ScSortParam& rSortParam ) const
305 rSortParam.bByRow = bByRow;
306 rSortParam.bHasHeader = bHasHeader;
307 rSortParam.bCaseSens = bSortCaseSens;
308 + rSortParam.bNaturalSort = bSortNaturalSort;
309 rSortParam.bInplace = bSortInplace;
310 rSortParam.nDestTab = nSortDestTab;
311 rSortParam.nDestCol = nSortDestCol;
312 @@ -469,6 +472,7 @@ void ScDBData::GetSortParam( ScSortParam& rSortParam ) const
313 void ScDBData::SetSortParam( const ScSortParam& rSortParam )
315 bSortCaseSens = rSortParam.bCaseSens;
316 + bSortNaturalSort = rSortParam.bNaturalSort;
317 bIncludePattern = rSortParam.bIncludePattern;
318 bSortInplace = rSortParam.bInplace;
319 nSortDestTab = rSortParam.nDestTab;
320 diff --git sc/source/ui/dbgui/tpsort.cxx sc/source/ui/dbgui/tpsort.cxx
321 index 5219593..d06627a 100644
322 --- sc/source/ui/dbgui/tpsort.cxx
323 +++ sc/source/ui/dbgui/tpsort.cxx
324 @@ -567,6 +567,7 @@ ScTabPageSortOptions::ScTabPageSortOptions( Window* pParent,
325 aBtnHeader ( this, ScResId( BTN_LABEL ) ),
326 aBtnFormats ( this, ScResId( BTN_FORMATS ) ),
327 aBtnCopyResult ( this, ScResId( BTN_COPYRESULT ) ),
328 + aBtnNaturalSort ( this, ScResId( BTN_NATURALSORT ) ),
329 aLbOutPos ( this, ScResId( LB_OUTAREA ) ),
330 aEdOutPos ( this, ScResId( ED_OUTAREA ) ),
331 aBtnSortUser ( this, ScResId( BTN_SORT_USER ) ),
332 @@ -578,7 +579,7 @@ ScTabPageSortOptions::ScTabPageSortOptions( Window* pParent,
333 aLineDirection ( this, ScResId( FL_DIRECTION ) ),
334 aBtnTopDown ( this, ScResId( BTN_TOP_DOWN ) ),
335 aBtnLeftRight ( this, ScResId( BTN_LEFT_RIGHT ) ),
336 - aFtAreaLabel ( this, ScResId( FT_AREA_LABEL ) ),
337 +// aFtAreaLabel ( this, ScResId( FT_AREA_LABEL ) ),
338 // aFtArea ( this, ScResId( FT_AREA ) ),
340 #if ENABLE_LAYOUT_EXPERIMENTAL
341 @@ -622,8 +623,8 @@ __EXPORT ScTabPageSortOptions::~ScTabPageSortOptions()
343 void ScTabPageSortOptions::Init()
345 - aStrAreaLabel = aFtAreaLabel.GetText();
346 - aStrAreaLabel.Append( (sal_Unicode) ' ' );
347 +// aStrAreaLabel = aFtAreaLabel.GetText();
348 +// aStrAreaLabel.Append( (sal_Unicode) ' ' );
350 // CollatorRessource has user-visible names for sort algorithms
351 pColRes = new CollatorRessource();
352 @@ -702,8 +703,8 @@ void ScTabPageSortOptions::Init()
353 theArea += ')';
355 //aFtArea.SetText( theArea );
356 - theArea.Insert( aStrAreaLabel, 0 );
357 - aFtAreaLabel.SetText( theArea );
358 + //theArea.Insert( aStrAreaLabel, 0 );
359 + //aFtAreaLabel.SetText( theArea );
361 aBtnHeader.SetText( aStrColLabel );
363 @@ -752,9 +753,10 @@ void __EXPORT ScTabPageSortOptions::Reset( const SfxItemSet& /* rArgSet */ )
364 aLbSortUser.SelectEntryPos( 0 );
367 - aBtnCase.Check ( rSortData.bCaseSens );
368 - aBtnFormats.Check ( rSortData.bIncludePattern );
369 - aBtnHeader.Check ( rSortData.bHasHeader );
370 + aBtnCase.Check ( rSortData.bCaseSens );
371 + aBtnFormats.Check ( rSortData.bIncludePattern );
372 + aBtnHeader.Check ( rSortData.bHasHeader );
373 + aBtnNaturalSort.Check ( rSortData.bNaturalSort );
375 if ( rSortData.bByRow )
377 @@ -820,6 +822,7 @@ BOOL __EXPORT ScTabPageSortOptions::FillItemSet( SfxItemSet& rArgSet )
378 theSortData.bByRow = aBtnTopDown.IsChecked();
379 theSortData.bHasHeader = aBtnHeader.IsChecked();
380 theSortData.bCaseSens = aBtnCase.IsChecked();
381 + theSortData.bNaturalSort = aBtnNaturalSort.IsChecked();
382 theSortData.bIncludePattern = aBtnFormats.IsChecked();
383 theSortData.bInplace = !aBtnCopyResult.IsChecked();
384 theSortData.nDestCol = theOutPos.Col();
385 diff --git sc/source/ui/inc/sortdlg.hrc sc/source/ui/inc/sortdlg.hrc
386 index f67927c..8d08628 100644
387 --- sc/source/ui/inc/sortdlg.hrc
388 +++ sc/source/ui/inc/sortdlg.hrc
389 @@ -66,7 +66,7 @@
390 #define LB_SORT_USER 2
391 #define LB_OUTAREA 3
392 #define ED_OUTAREA 4
393 -#define FT_AREA_LABEL 5
394 +//#define FT_AREA_LABEL 5
395 //#define FT_AREA 6
396 #define BTN_SORT_USER 7
397 #define BTN_CASESENSITIVE 8
398 @@ -81,6 +81,7 @@
399 #define LB_LANGUAGE 17
400 #define FT_ALGORITHM 18
401 #define LB_ALGORITHM 19
402 +#define BTN_NATURALSORT 20
404 //#define RID_SCDLG_SORT_WARNING
405 #define FT_TEXT 1
406 diff --git sc/source/ui/inc/tpsort.hxx sc/source/ui/inc/tpsort.hxx
407 index 5cb61ae..89573fa 100644
408 --- sc/source/ui/inc/tpsort.hxx
409 +++ sc/source/ui/inc/tpsort.hxx
410 @@ -53,7 +53,7 @@ class ScSortDlg;
411 struct ScSortParam;
413 //========================================================================
414 -// Kriterien
415 +// Kriterien (Sort Criteria)
417 class ScTabPageSortFields : public SfxTabPage
419 @@ -125,7 +125,7 @@ private:
422 //========================================================================
423 -// Sortieroptionen:
424 +// Sortieroptionen (Sort Options)
426 class ScDocument;
427 class ScRangeData;
428 @@ -167,6 +167,7 @@ private:
429 CheckBox aBtnCase;
430 CheckBox aBtnHeader;
431 CheckBox aBtnFormats;
432 + CheckBox aBtnNaturalSort;
434 CheckBox aBtnCopyResult;
435 ListBox aLbOutPos;
436 @@ -184,7 +185,7 @@ private:
437 RadioButton aBtnTopDown;
438 RadioButton aBtnLeftRight;
440 - FixedText aFtAreaLabel;
441 +// FixedText aFtAreaLabel;
442 // FixedInfo aFtArea;
443 LocalizedString aStrRowLabel;
444 LocalizedString aStrColLabel;
445 diff --git sc/source/ui/src/sortdlg.src sc/source/ui/src/sortdlg.src
446 index a068f0e..edb8b1e 100644
447 --- sc/source/ui/src/sortdlg.src
448 +++ sc/source/ui/src/sortdlg.src
449 @@ -154,9 +154,20 @@ TabPage RID_SCPAGE_SORT_OPTIONS
450 Text [ en-US ] = "Include ~formats" ;
451 TabStop = TRUE ;
453 + CheckBox BTN_NATURALSORT
455 + Pos = MAP_APPFONT ( 12 , 48 ) ;
456 + Size = MAP_APPFONT ( 242 , 10 ) ;
457 + Text [ de ] = "Enable ~natural sort" ;
458 + Text [ en-US ] = "Enable ~natural sort" ;
459 + Text [ cs ] = "Aktivovat přirozené třídění" ;
460 + Text [ sk ] = "Aktivovať prirodzené triedenie" ;
461 + TabStop = TRUE ;
462 + Text [ x-comment ] = " " ;
463 + };
464 CheckBox BTN_COPYRESULT
466 - Pos = MAP_APPFONT ( 12 , 48 ) ;
467 + Pos = MAP_APPFONT ( 12 , 62 ) ;
468 Size = MAP_APPFONT ( 242 , 10 ) ;
469 Text [ en-US ] = "~Copy sort results to:" ;
470 TabStop = TRUE ;
471 @@ -164,7 +175,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS
472 ListBox LB_OUTAREA
474 Border = TRUE ;
475 - Pos = MAP_APPFONT ( 20 , 59 ) ;
476 + Pos = MAP_APPFONT ( 20 , 73 ) ;
477 Size = MAP_APPFONT ( 93 , 90 ) ;
478 TabStop = TRUE ;
479 DropDown = TRUE ;
480 @@ -173,13 +184,13 @@ TabPage RID_SCPAGE_SORT_OPTIONS
482 Disable = TRUE ;
483 Border = TRUE ;
484 - Pos = MAP_APPFONT ( 119 , 59 ) ;
485 + Pos = MAP_APPFONT ( 119 , 73 ) ;
486 Size = MAP_APPFONT ( 132 , 12 ) ;
487 TabStop = TRUE ;
489 CheckBox BTN_SORT_USER
491 - Pos = MAP_APPFONT ( 12 , 75 ) ;
492 + Pos = MAP_APPFONT ( 12 , 89 ) ;
493 Size = MAP_APPFONT ( 242 , 10 ) ;
494 Text [ en-US ] = "Custom sort ~order" ;
495 TabStop = TRUE ;
496 @@ -188,21 +199,21 @@ TabPage RID_SCPAGE_SORT_OPTIONS
498 Disable = TRUE ;
499 Border = TRUE ;
500 - Pos = MAP_APPFONT ( 20 , 86 ) ;
501 + Pos = MAP_APPFONT ( 20 , 100 ) ;
502 Size = MAP_APPFONT ( 231 , 90 ) ;
503 TabStop = TRUE ;
504 DropDown = TRUE ;
506 FixedText FT_LANGUAGE
508 - Pos = MAP_APPFONT ( 12 , 104 ) ;
509 + Pos = MAP_APPFONT ( 12 , 118 ) ;
510 Size = MAP_APPFONT ( 101 , 8 ) ;
511 Text [ en-US ] = "~Language";
513 ListBox LB_LANGUAGE
515 Border = TRUE ;
516 - Pos = MAP_APPFONT ( 12 , 115 ) ;
517 + Pos = MAP_APPFONT ( 12 , 129 ) ;
518 Size = MAP_APPFONT ( 101 , 90 ) ;
519 TabStop = TRUE ;
520 DropDown = TRUE ;
521 @@ -210,44 +221,46 @@ TabPage RID_SCPAGE_SORT_OPTIONS
523 FixedText FT_ALGORITHM
525 - Pos = MAP_APPFONT ( 119 , 104 ) ;
526 + Pos = MAP_APPFONT ( 119 , 118 ) ;
527 Size = MAP_APPFONT ( 132 , 8 ) ;
528 Text [ en-US ] = "O~ptions";
530 ListBox LB_ALGORITHM
532 Border = TRUE ;
533 - Pos = MAP_APPFONT ( 119 , 115 ) ;
534 + Pos = MAP_APPFONT ( 119 , 129 ) ;
535 Size = MAP_APPFONT ( 132 , 90 ) ;
536 TabStop = TRUE ;
537 DropDown = TRUE ;
539 FixedLine FL_DIRECTION
541 - Pos = MAP_APPFONT ( 6 , 133 ) ;
542 + Pos = MAP_APPFONT ( 6 , 147 ) ;
543 Size = MAP_APPFONT ( 248 , 8 ) ;
544 Text [ en-US ] = "Direction" ;
546 RadioButton BTN_TOP_DOWN
548 - Pos = MAP_APPFONT ( 12 , 144 ) ;
549 + Pos = MAP_APPFONT ( 12 , 158 ) ;
550 Size = MAP_APPFONT ( 242 , 10 ) ;
551 Text [ en-US ] = "~Top to bottom (sort rows)" ;
552 TabStop = TRUE ;
554 RadioButton BTN_LEFT_RIGHT
556 - Pos = MAP_APPFONT ( 12 , 158 ) ;
557 + Pos = MAP_APPFONT ( 12 , 172 ) ;
558 Size = MAP_APPFONT ( 242 , 10 ) ;
559 Text [ en-US ] = "L~eft to right (sort columns)" ;
560 TabStop = TRUE ;
563 FixedText FT_AREA_LABEL
565 Pos = MAP_APPFONT ( 6 , 171 ) ;
566 Size = MAP_APPFONT ( 248 , 8 ) ;
567 Text [ en-US ] = "Data area:" ;
571 TabDialog RID_SCDLG_SORT
573 diff --git sc/source/ui/view/cellsh2.cxx sc/source/ui/view/cellsh2.cxx
574 index 90c6883..a54ea74 100644
575 --- sc/source/ui/view/cellsh2.cxx
576 +++ sc/source/ui/view/cellsh2.cxx
577 @@ -443,6 +443,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
578 aSortParam.bHasHeader = bHasHeader;
579 aSortParam.bByRow = TRUE;
580 aSortParam.bCaseSens = FALSE;
581 + aSortParam.bNaturalSort = FALSE;
582 aSortParam.bIncludePattern = TRUE;
583 aSortParam.bInplace = TRUE;
584 aSortParam.bDoSort[0] = TRUE;
585 @@ -494,6 +495,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
586 aSortParam.bHasHeader = ((const SfxBoolItem*)pItem)->GetValue();
587 if ( pArgs->GetItemState( SID_SORT_CASESENS, TRUE, &pItem ) == SFX_ITEM_SET )
588 aSortParam.bCaseSens = ((const SfxBoolItem*)pItem)->GetValue();
589 + if ( pArgs->GetItemState( SID_SORT_NATURALSORT, TRUE, &pItem ) == SFX_ITEM_SET )
590 + aSortParam.bNaturalSort = ((const SfxBoolItem*)pItem)->GetValue();
591 if ( pArgs->GetItemState( SID_SORT_ATTRIBS, TRUE, &pItem ) == SFX_ITEM_SET )
592 aSortParam.bIncludePattern = ((const SfxBoolItem*)pItem)->GetValue();
593 if ( pArgs->GetItemState( SID_SORT_USERDEF, TRUE, &pItem ) == SFX_ITEM_SET )
594 @@ -557,7 +560,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
596 pDlg = pFact->CreateScSortDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SORT );
597 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
598 - pDlg->SetCurPageId(1);
599 + pDlg->SetCurPageId(1); // 1=sort field tab 2=sort options tab
601 if ( pDlg->Execute() == RET_OK )
603 @@ -576,6 +579,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
604 rOutParam.bHasHeader ) );
605 rReq.AppendItem( SfxBoolItem( SID_SORT_CASESENS,
606 rOutParam.bCaseSens ) );
607 + rReq.AppendItem( SfxBoolItem( SID_SORT_NATURALSORT,
608 + rOutParam.bNaturalSort ) );
609 rReq.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
610 rOutParam.bIncludePattern ) );
611 USHORT nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;