Resolves tdf#131155 - Keep frequently used options on sort criteria tab
* Row/Column header moved
* Sort by row/column moved
* Extra variables removed
* UI tests adjusted to read/set sort direction and header from first tab
Change-Id: I9fc0406806256f289d52e45b096e392067768eaa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130843
Tested-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
diff --git a/sc/qa/uitest/conditional_format/tdf81696.py b/sc/qa/uitest/conditional_format/tdf81696.py
index 6b9bb79..0fca31e 100644
--- a/sc/qa/uitest/conditional_format/tdf81696.py
+++ b/sc/qa/uitest/conditional_format/tdf81696.py
@@ -28,7 +28,7 @@ class tdf81696(UITestCase):
#Open sort dialog by DATA - SORT,Just sort it by Column A, ascending. (it's default)
with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
xTabs = xDialog.getChild("tabcontrol")
xleftright = xDialog.getChild("leftright")
xleftright = xDialog.getChild("rbLeftRight")
select_pos(xTabs, "0")
#verify
diff --git a/sc/qa/uitest/sort/naturalSort.py b/sc/qa/uitest/sort/naturalSort.py
index ca8384d..6d9dd3e 100644
--- a/sc/qa/uitest/sort/naturalSort.py
+++ b/sc/qa/uitest/sort/naturalSort.py
@@ -85,12 +85,13 @@ class CalcNaturalSorting(UITestCase):
#Open sort dialog by DATA - SORT
with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
xTabs = xDialog.getChild("tabcontrol")
xleftright = xDialog.getChild("leftright")
select_pos(xTabs, "1")
xNatural = xDialog.getChild("naturalsort")
xleftright.executeAction("CLICK", tuple())
if (get_state_as_dict(xNatural)["Selected"]) == "false":
xNatural.executeAction("CLICK", tuple())
select_pos(xTabs, "0")
xleftright = xDialog.getChild("rbLeftRight")
xleftright.executeAction("CLICK", tuple())
#Verify
self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW-1")
diff --git a/sc/qa/uitest/sort/sorting.py b/sc/qa/uitest/sort/sorting.py
index 1064582..a3c9015 100644
--- a/sc/qa/uitest/sort/sorting.py
+++ b/sc/qa/uitest/sort/sorting.py
@@ -58,7 +58,7 @@ class CalcSorting(UITestCase):
xTabs = xDialog.getChild("tabcontrol")
select_pos(xTabs, "1")
#Verify that option "Range contains column labels" is set
xHeader = xDialog.getChild("header")
xHeader = xDialog.getChild("cbHeader")
self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true")
#Cancel dialog
#Select Range A1:B5
@@ -100,7 +100,7 @@ class CalcSorting(UITestCase):
xTabs = xDialog.getChild("tabcontrol")
select_pos(xTabs, "1")
#Verify that option "Range contains column labels" is not set
xHeader = xDialog.getChild("header")
xHeader = xDialog.getChild("cbHeader")
self.assertEqual(get_state_as_dict(xHeader)["Selected"], "false")
#Cancel dialog
diff --git a/sc/qa/uitest/sort/tdf49531.py b/sc/qa/uitest/sort/tdf49531.py
index 08f94cd..98d705b 100644
--- a/sc/qa/uitest/sort/tdf49531.py
+++ b/sc/qa/uitest/sort/tdf49531.py
@@ -31,14 +31,14 @@ class tdf49531(UITestCase):
xTabs = xDialog.getChild("tabcontrol")
select_pos(xTabs, "1")
xNatural = xDialog.getChild("naturalsort")
xtopdown = xDialog.getChild("topdown")
xHeader = xDialog.getChild("header")
if (get_state_as_dict(xNatural)["Selected"]) == "true":
xNatural.executeAction("CLICK", tuple())
select_pos(xTabs, "0")
xtopdown = xDialog.getChild("rbTopDown")
xHeader = xDialog.getChild("cbHeader")
if (get_state_as_dict(xHeader)["Selected"]) == "true":
xHeader.executeAction("CLICK", tuple())
xtopdown.executeAction("CLICK", tuple())
select_pos(xTabs, "0")
xSortKey1 = xDialog.getChild("sortlb")
xAsc = xDialog.getChild("up")
select_by_text(xSortKey1, "B")
diff --git a/sc/qa/uitest/sort/tdf53482.py b/sc/qa/uitest/sort/tdf53482.py
index f96c780..fbcbac0 100644
--- a/sc/qa/uitest/sort/tdf53482.py
+++ b/sc/qa/uitest/sort/tdf53482.py
@@ -29,7 +29,7 @@ class tdf53482(UITestCase):
xTabs = xDialog.getChild("tabcontrol")
select_pos(xTabs, "1")
#3. On Options tab, tick 'Range contains column labels'
xHeader = xDialog.getChild("header")
xHeader = xDialog.getChild("cbHeader")
xHeader.executeAction("CLICK", tuple())
if (get_state_as_dict(xHeader)["Selected"]) == "false":
xHeader.executeAction("CLICK", tuple())
@@ -60,14 +60,13 @@ class tdf53482(UITestCase):
#2. Click Data menu, Sort
with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
xTabs = xDialog.getChild("tabcontrol")
select_pos(xTabs, "1")
select_pos(xTabs, "0")
#3. On Options tab, tick 'Range contains column labels'
xHeader = xDialog.getChild("header")
xHeader = xDialog.getChild("cbHeader")
xHeader.executeAction("CLICK", tuple())
if (get_state_as_dict(xHeader)["Selected"]) == "false":
xHeader.executeAction("CLICK", tuple())
#4. On Sort Criteria tab, set appropriate criteria
select_pos(xTabs, "0")
xDown = xDialog.getChild("down")
xDown.executeAction("CLICK", tuple())
#5. Click Ok
diff --git a/sc/qa/uitest/sort/tdf57465.py b/sc/qa/uitest/sort/tdf57465.py
index eefb3fd..bd7efaa 100644
--- a/sc/qa/uitest/sort/tdf57465.py
+++ b/sc/qa/uitest/sort/tdf57465.py
@@ -23,17 +23,15 @@ class tdf57465(UITestCase):
with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
xTabs = xDialog.getChild("tabcontrol")
select_pos(xTabs, "1")
select_pos(xTabs, "0")
xHeader = xDialog.getChild("header")
xHeader = xDialog.getChild("cbHeader")
if (get_state_as_dict(xHeader)["Selected"]) == 'true':
xHeader.executeAction("CLICK", tuple())
xLeftRight = xDialog.getChild("leftright")
xLeftRight = xDialog.getChild("rbLeftRight")
xLeftRight.executeAction("CLICK", tuple())
select_pos(xTabs, "0")
self.assertEqual("1", get_state_as_dict(xDialog.getChild("sortlb"))['DisplayText'])
diff --git a/sc/qa/uitest/sort/tdf91305.py b/sc/qa/uitest/sort/tdf91305.py
index 6292cd9f..ebc452d 100644
--- a/sc/qa/uitest/sort/tdf91305.py
+++ b/sc/qa/uitest/sort/tdf91305.py
@@ -31,8 +31,8 @@ class tdf91305(UITestCase):
#Open sort dialog by DATA - SORT
with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
xTabs = xDialog.getChild("tabcontrol")
xleftright = xDialog.getChild("leftright")
select_pos(xTabs, "1")
xleftright = xDialog.getChild("rbLeftRight")
select_pos(xTabs, "0")
xleftright.executeAction("CLICK", tuple())
#verify
self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa")
@@ -41,11 +41,10 @@ class tdf91305(UITestCase):
#Open sort dialog by DATA - SORT
with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
xTabs = xDialog.getChild("tabcontrol")
xleftright = xDialog.getChild("leftright")
xleftright = xDialog.getChild("rbLeftRight")
xdown = xDialog.getChild("down")
select_pos(xTabs, "1")
xleftright.executeAction("CLICK", tuple())
select_pos(xTabs, "0")
xleftright.executeAction("CLICK", tuple())
xdown.executeAction("CLICK", tuple())
self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff")
self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc")
diff --git a/sc/qa/uitest/sort/tdf99208.py b/sc/qa/uitest/sort/tdf99208.py
index e272484..9e3115d 100644
--- a/sc/qa/uitest/sort/tdf99208.py
+++ b/sc/qa/uitest/sort/tdf99208.py
@@ -30,17 +30,18 @@ class tdf99208(UITestCase):
xTabs = xDialog.getChild("tabcontrol")
select_pos(xTabs, "1")
xNatural = xDialog.getChild("naturalsort")
xtopdown = xDialog.getChild("topdown")
xHeader = xDialog.getChild("header")
xFormats = xDialog.getChild("formats")
if (get_state_as_dict(xNatural)["Selected"]) == "false":
xNatural.executeAction("CLICK", tuple())
if (get_state_as_dict(xHeader)["Selected"]) == "false":
xHeader.executeAction("CLICK", tuple())
if (get_state_as_dict(xFormats)["Selected"]) == "false":
xFormats.executeAction("CLICK", tuple())
xtopdown.executeAction("CLICK", tuple())
select_pos(xTabs, "0")
xtopdown = xDialog.getChild("rbTopDown")
xHeader = xDialog.getChild("cbHeader")
if (get_state_as_dict(xHeader)["Selected"]) == "false":
xHeader.executeAction("CLICK", tuple())
xtopdown.executeAction("CLICK", tuple())
xSortKey1 = xDialog.getChild("sortlb")
xAsc = xDialog.getChild("up")
select_by_text(xSortKey1, "FODMAP")
diff --git a/sc/source/ui/dbgui/sortdlg.cxx b/sc/source/ui/dbgui/sortdlg.cxx
index 4c5f5c1..22af223 100644
--- a/sc/source/ui/dbgui/sortdlg.cxx
+++ b/sc/source/ui/dbgui/sortdlg.cxx
@@ -25,8 +25,6 @@
ScSortDlg::ScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet)
: SfxTabDialogController(pParent, "modules/scalc/ui/sortdialog.ui", "SortDialog", pArgSet)
, bIsHeaders(false)
, bIsByRows(false)
{
AddTabPage("criteria", ScTabPageSortFields::Create, nullptr);
AddTabPage("options", ScTabPageSortOptions::Create, nullptr);
diff --git a/sc/source/ui/dbgui/sortkeydlg.cxx b/sc/source/ui/dbgui/sortkeydlg.cxx
index d927439..5992807 100644
--- a/sc/source/ui/dbgui/sortkeydlg.cxx
+++ b/sc/source/ui/dbgui/sortkeydlg.cxx
@@ -11,6 +11,9 @@
#include <sortkeydlg.hxx>
#include <vcl/svapp.hxx>
#include <scresid.hxx>
#include <strings.hrc>
ScSortKeyItem::ScSortKeyItem(weld::Container* pParent)
: m_xBuilder(Application::CreateBuilder(pParent, "modules/scalc/ui/sortkey.ui"))
, m_xFrame(m_xBuilder->weld_frame("SortKeyFrame"))
@@ -23,6 +26,9 @@ ScSortKeyItem::ScSortKeyItem(weld::Container* pParent)
// tdf#136155 let the other elements in the dialog determine the width of the
// combobox
m_xLbSort->set_size_request(m_xLbSort->get_approximate_digit_width() * 12, -1);
// keep the UI static when switching the labels
const sal_Int32 nChars = std::max( ScResId(SCSTR_COLUMN).getLength(), ScResId(SCSTR_ROW).getLength() ) + 2; // +2 to avoid cut-off labels on kf5/gen
m_xLabel->set_size_request( m_xLabel->get_approximate_digit_width() * nChars, -1);
}
ScSortKeyItem::~ScSortKeyItem()
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 0cbd1c3..9fa0070 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -76,16 +76,20 @@ ScTabPageSortFields::ScTabPageSortFields(weld::Container* pPage, weld::DialogCon
aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
aStrColumn ( ScResId( SCSTR_COLUMN ) ),
aStrRow ( ScResId( SCSTR_ROW ) ),
aStrRowLabel ( ScResId( SCSTR_ROW_LABEL ) ),
aStrColLabel ( ScResId( SCSTR_COL_LABEL ) ),
nWhichSort ( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
pViewData ( nullptr ),
aSortData ( rArgSet.Get( nWhichSort ).GetSortData() ),
nFieldCount ( 0 ),
// show actual size of the sorting keys without limiting them to the default size
nSortKeyCount(std::max(aSortData.GetSortKeyCount(), static_cast<sal_uInt16>(DEFSORT))),
bHasHeader ( false ),
bSortByRows ( false )
nSortKeyCount(std::max(aSortData.GetSortKeyCount(), static_cast<sal_uInt16>(DEFSORT)))
, m_xTop(m_xBuilder->weld_container("TopWindow"))
, m_xBtnHeader(m_xBuilder->weld_check_button("cbHeader"))
, m_xBtnTopDown(m_xBuilder->weld_radio_button("rbTopDown"))
, m_xBtnLeftRight(m_xBuilder->weld_radio_button("rbLeftRight"))
, m_xScrolledWindow(m_xBuilder->weld_scrolled_window("SortCriteriaPage"))
, m_xBox(m_xBuilder->weld_container("SortKeyWindow"))
, m_aSortWin(m_xBox.get())
@@ -111,6 +115,31 @@ ScTabPageSortFields::~ScTabPageSortFields()
void ScTabPageSortFields::Init()
{
// Check whether the field that is passed on is a database field:
ScDocument* pDoc = pViewData ? &pViewData->GetDocument() : nullptr;
if ( pDoc )
{
ScDBCollection* pDBColl = pDoc->GetDBCollection();
const SCTAB nCurTab = pViewData->GetTabNo();
if ( pDBColl )
{
ScDBData* pDBData
= pDBColl->GetDBAtArea( nCurTab,
aSortData.nCol1, aSortData.nRow1,
aSortData.nCol2, aSortData.nRow2 );
if ( pDBData )
{
m_xBtnHeader->set_active(pDBData->HasHeader());
}
}
}
m_xBtnHeader->set_label(aStrColLabel);
Link<weld::Toggleable&,void> aLink = LINK(this, ScTabPageSortFields, SortDirHdl );
m_xBtnTopDown->connect_toggled( aLink );
m_xBtnLeftRight->connect_toggled( aLink );
m_xBtnHeader->connect_toggled( aLink );
const ScSortItem& rSortItem = GetItemSet().Get( nWhichSort );
pViewData = rSortItem.GetViewData();
@@ -133,8 +162,9 @@ std::unique_ptr<SfxTabPage> ScTabPageSortFields::Create(weld::Container* pPage,
void ScTabPageSortFields::Reset( const SfxItemSet* /* rArgSet */ )
{
bSortByRows = aSortData.bByRow;
bHasHeader = aSortData.bHasHeader;
m_xBtnHeader->set_active( aSortData.bHasHeader );
m_xBtnTopDown->set_active( aSortData.bByRow );
m_xBtnLeftRight->set_active( !aSortData.bByRow );
if (m_aSortWin.m_aSortKeyItems[0]->m_xLbSort->get_count() == 0)
FillFieldLists(0);
@@ -201,12 +231,6 @@ void ScTabPageSortFields::Reset( const SfxItemSet* /* rArgSet */ )
m_aSortWin.m_aSortKeyItems[i]->DisableField();
}
if (ScSortDlg* pDlg = static_cast<ScSortDlg*>(GetDialogController()))
{
pDlg->SetByRows ( bSortByRows );
pDlg->SetHeaders( bHasHeader );
}
// Make sure that there is always a last undefined sort key
if (m_aSortWin.m_aSortKeyItems[nSortKeyCount - 1]->m_xLbSort->get_active() > 0)
SetLastSortKey( nSortKeyCount );
@@ -226,6 +250,9 @@ bool ScTabPageSortFields::FillItemSet( SfxItemSet* rArgSet )
aNewSortData = aTempData;
}
}
aNewSortData.bByRow = m_xBtnTopDown->get_active();
aNewSortData.bHasHeader = m_xBtnHeader->get_active();
std::vector<sal_Int32> nSortPos;
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
@@ -240,27 +267,11 @@ bool ScTabPageSortFields::FillItemSet( SfxItemSet* rArgSet )
if ( nSortPos[0] > 0 )
{
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
{
aNewSortData.maKeyState[i].bDoSort = (nSortPos[i] > 0);
// If the "OK" was selected on the Options page while the sort
// direction was changed, then the first field (i.e. nFieldArr[0])
// of the respective direction is chosen as the sorting criterion:
ScSortDlg* pDlg = static_cast<ScSortDlg*>(GetDialogController());
if ( pDlg && bSortByRows != pDlg->GetByRows() )
{
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
aNewSortData.maKeyState[i].nField = 0;
}
else
{
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
aNewSortData.maKeyState[i].nField = nFieldArr[nSortPos[i]];
}
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
aNewSortData.maKeyState[i].nField = nFieldArr[nSortPos[i]];
aNewSortData.maKeyState[i].bAscending = m_aSortWin.m_aSortKeyItems[i]->m_xBtnUp->get_active();
// bHasHeader is in ScTabPageSortOptions::FillItemSet, where it belongs
}
}
else
{
@@ -278,36 +289,14 @@ void ScTabPageSortFields::ActivatePage( const SfxItemSet& rSet )
{
// Refresh local copy with shared data
aSortData = rSet.Get( SCITEM_SORTDATA ).GetSortData();
ScSortDlg* pDlg = static_cast<ScSortDlg*>(GetDialogController());
if (!pDlg)
return;
if ( bHasHeader == pDlg->GetHeaders() && bSortByRows == pDlg->GetByRows() )
return;
std::vector<sal_uInt16> nCurSel;
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
nCurSel.push_back( m_aSortWin.m_aSortKeyItems[i]->m_xLbSort->get_active() );
bHasHeader = pDlg->GetHeaders();
bSortByRows = pDlg->GetByRows();
FillFieldLists(0);
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
m_aSortWin.m_aSortKeyItems[i]->m_xLbSort->set_active(nCurSel[i]);
m_xBtnHeader->set_active( aSortData.bHasHeader );
m_xBtnTopDown->set_active( aSortData.bByRow );
m_xBtnLeftRight->set_active( !aSortData.bByRow );
}
DeactivateRC ScTabPageSortFields::DeactivatePage( SfxItemSet* pSetP )
{
if (ScSortDlg* pDlg = static_cast<ScSortDlg*>(GetDialogController()))
{
if ( bHasHeader != pDlg->GetHeaders() )
pDlg->SetHeaders( bHasHeader );
if ( bSortByRows != pDlg->GetByRows() )
pDlg->SetByRows( bSortByRows );
}
if ( pSetP )
FillItemSet( pSetP );
@@ -336,7 +325,7 @@ void ScTabPageSortFields::FillFieldLists( sal_uInt16 nStartField )
nFieldArr.clear();
nFieldArr.push_back(0);
if ( bSortByRows )
if ( aSortData.bByRow )
{
OUString aFieldName;
SCCOL nMaxCol = rDoc.ClampToAllocatedColumns(nTab, aSortData.nCol2);
@@ -345,7 +334,7 @@ void ScTabPageSortFields::FillFieldLists( sal_uInt16 nStartField )
for ( col=nFirstSortCol; col<=nMaxCol && i<SC_MAXFIELDS(rDoc.GetSheetLimits()); col++ )
{
aFieldName = rDoc.GetString(col, nFirstSortRow, nTab);
if ( !bHasHeader || aFieldName.isEmpty() )
if ( !aSortData.bHasHeader || aFieldName.isEmpty() )
aFieldName = ScColToAlpha( col );
nFieldArr.push_back( col );
@@ -364,7 +353,7 @@ void ScTabPageSortFields::FillFieldLists( sal_uInt16 nStartField )
for ( row=nFirstSortRow; row<=nMaxRow && i<SC_MAXFIELDS(rDoc.GetSheetLimits()); row++ )
{
aFieldName = rDoc.GetString(nFirstSortCol, row, nTab);
if ( !bHasHeader || aFieldName.isEmpty() )
if ( !aSortData.bHasHeader || aFieldName.isEmpty() )
aFieldName = OUString::number( row+1);
nFieldArr.push_back( row );
@@ -421,6 +410,30 @@ void ScTabPageSortFields::SetLastSortKey( sal_uInt16 nItem )
// Handler:
IMPL_LINK_NOARG(ScTabPageSortFields, SortDirHdl, weld::Toggleable&, void)
{
if ( (m_xBtnTopDown->get_active() != aSortData.bByRow) || (m_xBtnHeader->get_active() != aSortData.bHasHeader))
{
if (m_xBtnTopDown->get_active())
m_xBtnHeader->set_label(aStrColLabel);
else
m_xBtnHeader->set_label(aStrRowLabel);
aSortData.bByRow = m_xBtnTopDown->get_active();
aSortData.bHasHeader = m_xBtnHeader->get_active();
// remember selection
std::vector<sal_uInt16> nCurSel;
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
nCurSel.push_back( m_aSortWin.m_aSortKeyItems[i]->m_xLbSort->get_active() );
FillFieldLists(0);
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
m_aSortWin.m_aSortKeyItems[i]->m_xLbSort->set_active(nCurSel[i]);
}
}
IMPL_LINK( ScTabPageSortFields, SelectHdl, weld::ComboBox&, rLb, void )
{
OUString aSelEntry = rLb.get_active_text();
@@ -478,15 +491,12 @@ void ScTabPageSortFields::AddSortKey( sal_uInt16 nItem )
ScTabPageSortOptions::ScTabPageSortOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet)
: SfxTabPage(pPage, pController, "modules/scalc/ui/sortoptionspage.ui", "SortOptionsPage", &rArgSet)
, aStrRowLabel(ScResId(SCSTR_ROW_LABEL))
, aStrColLabel(ScResId(SCSTR_COL_LABEL))
, aStrUndefined(ScResId(SCSTR_UNDEFINED))
, nWhichSort(rArgSet.GetPool()->GetWhich(SID_SORT))
, aSortData(rArgSet.Get(nWhichSort).GetSortData())
, pViewData(nullptr)
, pDoc(nullptr)
, m_xBtnCase(m_xBuilder->weld_check_button("case"))
, m_xBtnHeader(m_xBuilder->weld_check_button("header"))
, m_xBtnFormats(m_xBuilder->weld_check_button("formats"))
, m_xBtnNaturalSort(m_xBuilder->weld_check_button("naturalsort"))
, m_xBtnCopyResult(m_xBuilder->weld_check_button("copyresult"))
@@ -497,8 +507,6 @@ ScTabPageSortOptions::ScTabPageSortOptions(weld::Container* pPage, weld::DialogC
, m_xLbLanguage(new SvxLanguageBox(m_xBuilder->weld_combo_box("language")))
, m_xFtAlgorithm(m_xBuilder->weld_label("algorithmft"))
, m_xLbAlgorithm(m_xBuilder->weld_combo_box("algorithmlb"))
, m_xBtnTopDown(m_xBuilder->weld_radio_button("topdown"))
, m_xBtnLeftRight(m_xBuilder->weld_radio_button("leftright"))
, m_xBtnIncComments(m_xBuilder->weld_check_button("includenotes"))
, m_xBtnIncImages(m_xBuilder->weld_check_button("includeimages"))
{
@@ -520,8 +528,6 @@ void ScTabPageSortOptions::Init()
m_xLbOutPos->connect_changed( LINK( this, ScTabPageSortOptions, SelOutPosHdl ) );
m_xBtnCopyResult->connect_toggled( LINK( this, ScTabPageSortOptions, EnableHdl ) );
m_xBtnSortUser->connect_toggled( LINK( this, ScTabPageSortOptions, EnableHdl ) );
m_xBtnTopDown->connect_toggled( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
m_xBtnLeftRight->connect_toggled( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
m_xLbLanguage->connect_changed( LINK( this, ScTabPageSortOptions, FillAlgorHdl ) );
pViewData = rSortItem.GetViewData();
@@ -531,8 +537,6 @@ void ScTabPageSortOptions::Init()
if ( pViewData && pDoc )
{
ScDBCollection* pDBColl = pDoc->GetDBCollection();
const SCTAB nCurTab = pViewData->GetTabNo();
const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
m_xLbOutPos->clear();
@@ -550,22 +554,6 @@ void ScTabPageSortOptions::Init()
m_xLbOutPos->set_active(0);
m_xEdOutPos->set_text(OUString());
// Check whether the field that is passed on is a database field:
if ( pDBColl )
{
ScDBData* pDBData
= pDBColl->GetDBAtArea( nCurTab,
aSortData.nCol1, aSortData.nRow1,
aSortData.nCol2, aSortData.nRow2 );
if ( pDBData )
{
m_xBtnHeader->set_active(pDBData->HasHeader());
}
}
m_xBtnHeader->set_label(aStrColLabel);
}
FillUserSortListBox();
@@ -598,22 +586,10 @@ void ScTabPageSortOptions::Reset( const SfxItemSet* /* rArgSet */ )
m_xBtnCase->set_active( aSortData.bCaseSens );
m_xBtnFormats->set_active( aSortData.aDataAreaExtras.mbCellFormats );
m_xBtnHeader->set_active( aSortData.bHasHeader );
m_xBtnNaturalSort->set_active( aSortData.bNaturalSort );
m_xBtnIncComments->set_active( aSortData.aDataAreaExtras.mbCellNotes );
m_xBtnIncImages->set_active( aSortData.aDataAreaExtras.mbCellDrawObjects );
if ( aSortData.bByRow )
{
m_xBtnTopDown->set_active(true);
m_xBtnHeader->set_label( aStrColLabel );
}
else
{
m_xBtnLeftRight->set_active(true);
m_xBtnHeader->set_label( aStrRowLabel );
}
LanguageType eLang = LanguageTag::convertToLanguageType( aSortData.aCollatorLocale, false);
if ( eLang == LANGUAGE_DONTKNOW )
eLang = LANGUAGE_SYSTEM;
@@ -661,8 +637,6 @@ bool ScTabPageSortOptions::FillItemSet( SfxItemSet* rArgSet )
if (const ScSortItem* pSortItem = pExample->GetItemIfSet(nWhichSort))
aNewSortData = pSortItem->GetSortData();
}
aNewSortData.bByRow = m_xBtnTopDown->get_active();
aNewSortData.bHasHeader = m_xBtnHeader->get_active();
aNewSortData.bCaseSens = m_xBtnCase->get_active();
aNewSortData.bNaturalSort = m_xBtnNaturalSort->get_active();
aNewSortData.aDataAreaExtras.mbCellNotes = m_xBtnIncComments->get_active();
@@ -706,21 +680,6 @@ void ScTabPageSortOptions::ActivatePage( const SfxItemSet& rSet )
ScSortDlg* pDlg = static_cast<ScSortDlg*>(GetDialogController());
if (!pDlg)
return;
if ( m_xBtnHeader->get_active() != pDlg->GetHeaders() )
{
m_xBtnHeader->set_active( pDlg->GetHeaders() );
}
if ( m_xBtnTopDown->get_active() != pDlg->GetByRows() )
{
m_xBtnTopDown->set_active( pDlg->GetByRows() );
m_xBtnLeftRight->set_active( !pDlg->GetByRows() );
}
m_xBtnHeader->set_label( (pDlg->GetByRows())
? aStrColLabel
: aStrRowLabel );
}
DeactivateRC ScTabPageSortOptions::DeactivatePage( SfxItemSet* pSetP )
@@ -764,13 +723,6 @@ DeactivateRC ScTabPageSortOptions::DeactivatePage( SfxItemSet* pSetP )
}
}
ScSortDlg* pDlg = static_cast<ScSortDlg*>(GetDialogController());
if (pDlg && bPosInputOk)
{
pDlg->SetHeaders( m_xBtnHeader->get_active() );
pDlg->SetByRows ( m_xBtnTopDown->get_active() );
}
if ( pSetP && bPosInputOk )
FillItemSet( pSetP );
@@ -834,14 +786,6 @@ IMPL_LINK(ScTabPageSortOptions, SelOutPosHdl, weld::ComboBox&, rLb, void)
}
}
IMPL_LINK_NOARG(ScTabPageSortOptions, SortDirHdl, weld::Toggleable&, void)
{
if (m_xBtnTopDown->get_active())
m_xBtnHeader->set_label(aStrColLabel);
else
m_xBtnHeader->set_label(aStrRowLabel);
}
void ScTabPageSortOptions::EdOutPosModHdl()
{
OUString theCurPosStr = m_xEdOutPos->get_text();
diff --git a/sc/source/ui/inc/sortdlg.hxx b/sc/source/ui/inc/sortdlg.hxx
index ae58ef3..10d4268 100644
--- a/sc/source/ui/inc/sortdlg.hxx
+++ b/sc/source/ui/inc/sortdlg.hxx
@@ -26,15 +26,6 @@ class ScSortDlg : public SfxTabDialogController
{
public:
ScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet);
void SetHeaders( bool bHeaders ) { bIsHeaders = bHeaders; }
void SetByRows ( bool bByRows ) { bIsByRows = bByRows; }
bool GetHeaders() const { return bIsHeaders; }
bool GetByRows () const { return bIsByRows; }
private:
bool bIsHeaders;
bool bIsByRows;
};
class ScSortWarningDlg : public weld::GenericDialogController
diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx
index 39043e0..655f3a7 100644
--- a/sc/source/ui/inc/tpsort.hxx
+++ b/sc/source/ui/inc/tpsort.hxx
@@ -61,6 +61,8 @@ private:
OUString aStrUndefined;
OUString aStrColumn;
OUString aStrRow;
OUString aStrRowLabel;
OUString aStrColLabel;
TypedWhichId<ScSortItem> nWhichSort;
ScViewData* pViewData;
@@ -69,9 +71,10 @@ private:
sal_uInt16 nFieldCount;
sal_uInt16 nSortKeyCount;
bool bHasHeader;
bool bSortByRows;
std::unique_ptr<weld::Container> m_xTop;
std::unique_ptr<weld::CheckButton> m_xBtnHeader;
std::unique_ptr<weld::RadioButton> m_xBtnTopDown;
std::unique_ptr<weld::RadioButton> m_xBtnLeftRight;
std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow;
std::unique_ptr<weld::Container> m_xBox;
ScSortKeyWindow m_aSortWin;
@@ -87,6 +90,8 @@ private:
// Handler ------------------------
DECL_LINK(SelectHdl, weld::ComboBox&, void);
DECL_LINK(ScrollToEndHdl, Timer*, void);
DECL_LINK(SortDirHdl, weld::Toggleable&, void);
};
// Sort Options
@@ -107,8 +112,6 @@ protected:
virtual DeactivateRC DeactivatePage ( SfxItemSet* pSet ) override;
private:
OUString aStrRowLabel;
OUString aStrColLabel;
OUString aStrUndefined;
TypedWhichId<ScSortItem> nWhichSort;
@@ -121,7 +124,6 @@ private:
std::unique_ptr<CollatorWrapper> m_xColWrap;
std::unique_ptr<weld::CheckButton> m_xBtnCase;
std::unique_ptr<weld::CheckButton> m_xBtnHeader;
std::unique_ptr<weld::CheckButton> m_xBtnFormats;
std::unique_ptr<weld::CheckButton> m_xBtnNaturalSort;
std::unique_ptr<weld::CheckButton> m_xBtnCopyResult;
@@ -132,8 +134,6 @@ private:
std::unique_ptr<SvxLanguageBox> m_xLbLanguage;
std::unique_ptr<weld::Label> m_xFtAlgorithm;
std::unique_ptr<weld::ComboBox> m_xLbAlgorithm;
std::unique_ptr<weld::RadioButton> m_xBtnTopDown;
std::unique_ptr<weld::RadioButton> m_xBtnLeftRight;
std::unique_ptr<weld::CheckButton> m_xBtnIncComments;
std::unique_ptr<weld::CheckButton> m_xBtnIncImages;
@@ -145,7 +145,6 @@ private:
DECL_LINK( EnableHdl, weld::Toggleable&, void );
DECL_LINK( SelOutPosHdl, weld::ComboBox&, void );
void EdOutPosModHdl();
DECL_LINK( SortDirHdl, weld::Toggleable&, void );
void FillAlgor();
DECL_LINK( FillAlgorHdl, weld::ComboBox&, void );
};
diff --git a/sc/uiconfig/scalc/ui/sortcriteriapage.ui b/sc/uiconfig/scalc/ui/sortcriteriapage.ui
index 7662f42..df7e232 100644
--- a/sc/uiconfig/scalc/ui/sortcriteriapage.ui
+++ b/sc/uiconfig/scalc/ui/sortcriteriapage.ui
@@ -2,36 +2,168 @@
<!-- Generated with glade 3.38.2 -->
<interface domain="sc">
<requires lib="gtk+" version="3.20"/>
<object class="GtkScrolledWindow" id="SortCriteriaPage">
<object class="GtkBox" id="TopWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="hscrollbar-policy">never</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkViewport" id="viewport2">
<object class="GtkScrolledWindow" id="SortCriteriaPage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkBox" id="SortKeyWindow">
<object class="GtkViewport" id="viewport2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="SortKeyWindow">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="SortCriteriaPage-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="sortcriteriapage|extended_tip|SortCriteriaPage">Specify the sorting options for the selected range.</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="border-width">6</property>
<property name="label-xalign">0</property>
<property name="shadow-type">none</property>
<child>
<!-- n-columns=2 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">6</property>
<property name="margin-top">3</property>
<property name="row-spacing">3</property>
<property name="column-spacing">3</property>
<child>
<object class="GtkRadioButton" id="rbTopDown">
<property name="label" translatable="yes" context="sortcriteriapage|topdown">Top to bottom (sort rows)</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="rbLeftRight">
<property name="label" translatable="yes" context="sortcriteriapage|leftright">Left to right (sort columns)</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">rbTopDown</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbDirection">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="sortcriteriapage|lbDirection">Direction:</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="cbHeader">
<property name="label" translatable="yes" context="sortcriteriapage|header">Range contains...</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbHeader">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="sortcriteriapage|lbHeader">Headers:</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="lbOptions">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="sortcriteriapage|lbOptions">Sort Options</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="SortCriteriaPage-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="sortcriteriapage|extended_tip|SortCriteriaPage">Specify the sorting options for the selected range.</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>
diff --git a/sc/uiconfig/scalc/ui/sortkey.ui b/sc/uiconfig/scalc/ui/sortkey.ui
index 87695eb..62b7813 100644
--- a/sc/uiconfig/scalc/ui/sortkey.ui
+++ b/sc/uiconfig/scalc/ui/sortkey.ui
@@ -80,7 +80,8 @@
<object class="GtkLabel" id="lbColRow">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="no">Column/Row:</property>
<property name="label">Column/Row:</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">0</property>
diff --git a/sc/uiconfig/scalc/ui/sortoptionspage.ui b/sc/uiconfig/scalc/ui/sortoptionspage.ui
index d7918df..13a23bf 100644
--- a/sc/uiconfig/scalc/ui/sortoptionspage.ui
+++ b/sc/uiconfig/scalc/ui/sortoptionspage.ui
@@ -15,12 +15,13 @@
<property name="label-xalign">0</property>
<property name="shadow-type">none</property>
<child>
<!-- n-columns=2 n-rows=12 -->
<!-- n-columns=2 n-rows=11 -->
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">12</property>
<property name="margin-top">6</property>
<property name="margin-bottom">12</property>
<property name="row-spacing">6</property>
<property name="column-spacing">12</property>
<child>
@@ -43,25 +44,6 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="header">
<property name="label" translatable="yes" context="sortoptionspage|header">Range contains...</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="header-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="sortoptionspage|extended_tip|header">Omits the first row or the first column in the selection from the sort.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="formats">
<property name="label" translatable="yes" context="sortoptionspage|formats">Include formats</property>
<property name="visible">True</property>
@@ -77,7 +59,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
@@ -96,7 +78,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -110,7 +92,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -124,7 +106,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -146,7 +128,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
@@ -167,7 +149,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
@@ -189,7 +171,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
@@ -211,7 +193,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">8</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -231,7 +213,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">9</property>
<property name="top-attach">8</property>
<property name="width">2</property>
</packing>
</child>
@@ -246,7 +228,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">10</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -260,7 +242,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -275,7 +257,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
@@ -297,7 +279,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
@@ -321,9 +303,6 @@
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="label">
@@ -343,78 +322,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
<property name="shadow-type">none</property>
<child>
<!-- n-columns=1 n-rows=2 -->
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">12</property>
<property name="margin-top">6</property>
<child>
<object class="GtkRadioButton" id="topdown">
<property name="label" translatable="yes" context="sortoptionspage|topdown">_Top to bottom (sort rows)</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="topdown-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="sortoptionspage|extended_tip|topdown">Sorts rows by the values in the active columns of the selected range.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="leftright">
<property name="label" translatable="yes" context="sortoptionspage|leftright">L_eft to right (sort columns)</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<property name="group">topdown</property>
<child internal-child="accessible">
<object class="AtkObject" id="leftright-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="sortoptionspage|extended_tip|leftright">Sorts columns by the values in the active rows of the selected range.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="sortoptionspage|label1">Direction</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="SortOptionsPage-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="sortoptionspage|extended_tip|SortOptionsPage">Sets additional sorting options.</property>