summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-05-18 02:16:42 (GMT)
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-05-18 02:16:42 (GMT)
commit2a755c0cd61b619ed14e023ad34fc7596eafdf34 (patch)
tree3014d428fa3ea16de2ff1c8d2565e0a6aeadea2f
parent3da4ab93e14bbe472ac0a6bce52616a93a2506d2 (diff)
Add sort options to the autofilter popup.
Change-Id: I217b41f966220b8b1ee9638d3f6a31a23dc4bf2e
-rw-r--r--sc/source/ui/inc/gridwin.hxx2
-rw-r--r--sc/source/ui/view/gridwin.cxx46
2 files changed, 47 insertions, 1 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 1b10ad0..8a64de9 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -304,7 +304,7 @@ protected:
virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
public:
- enum AutoFilterMode { Normal, Top10, Custom, Empty, NonEmpty };
+ enum AutoFilterMode { Normal, Top10, Custom, Empty, NonEmpty, SortAscending, SortDescending };
ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos );
~ScGridWindow();
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9bb8c63..40e8f38 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -129,6 +129,8 @@
#include "cliputil.hxx"
#include "queryentry.hxx"
#include "markdata.hxx"
+#include "checklistmenu.hrc"
+#include "strload.hxx"
#include <svx/sdrpagewindow.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx>
@@ -705,6 +707,13 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
// Populate the menu.
mpAutoFilterPopup->addMenuItem(
+ ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_ASC).GetString(),
+ true, new AutoFilterAction(this, SortAscending));
+ mpAutoFilterPopup->addMenuItem(
+ ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_DESC).GetString(),
+ true, new AutoFilterAction(this, SortDescending));
+ mpAutoFilterPopup->addSeparator();
+ mpAutoFilterPopup->addMenuItem(
SC_RESSTR(SCSTR_TOP10FILTER), true, new AutoFilterAction(this, Top10));
mpAutoFilterPopup->addMenuItem(
SC_RESSTR(SCSTR_FILTER_EMPTY), true, new AutoFilterAction(this, Empty));
@@ -746,6 +755,43 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
if (!pDBData)
return;
+ switch (eMode)
+ {
+ case SortAscending:
+ case SortDescending:
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ SCCOL nCol = rPos.Col();
+ ScSortParam aSortParam;
+ pDBData->GetSortParam(aSortParam);
+ if (nCol < aSortParam.nCol1 || nCol > aSortParam.nCol2)
+ // out of bound
+ return;
+
+ bool bHasHeader = pDoc->HasColHeader(
+ aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, nTab);
+
+ aSortParam.bHasHeader = bHasHeader;
+ aSortParam.bByRow = true;
+ aSortParam.bCaseSens = false;
+ aSortParam.bNaturalSort = false;
+ aSortParam.bIncludePattern = true;
+ aSortParam.bInplace = true;
+ aSortParam.maKeyState[0].bDoSort = true;
+ aSortParam.maKeyState[0].nField = nCol;
+ aSortParam.maKeyState[0].bAscending = (eMode == SortAscending);
+
+ for (size_t i = 1; i < aSortParam.GetSortKeyCount(); ++i)
+ aSortParam.maKeyState[i].bDoSort = false;
+
+ pViewData->GetViewShell()->UISort(aSortParam);
+ return;
+ }
+ default:
+ ;
+ }
+
if (eMode == Custom)
{
ScRange aRange;