summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/document.hxx5
-rw-r--r--sc/inc/sc.hrc1
-rw-r--r--sc/inc/sortparam.hxx1
-rw-r--r--sc/inc/table.hxx2
-rw-r--r--sc/sdi/scalc.sdi2
-rw-r--r--sc/source/core/data/document.cxx4
-rw-r--r--sc/source/core/data/sortparam.cxx9
-rw-r--r--sc/source/core/data/table1.cxx8
-rw-r--r--sc/source/ui/dbgui/tpsort.cxx4
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx3
-rw-r--r--sc/source/ui/inc/tpsort.hxx2
-rw-r--r--sc/source/ui/view/cellsh2.cxx5
-rw-r--r--sc/source/ui/view/gridwin.cxx1
-rw-r--r--sc/uiconfig/scalc/ui/sortoptionspage.ui32
14 files changed, 60 insertions, 19 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 3a53e6697e41..ed7bdab69488 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1253,13 +1253,16 @@ public:
If TRUE, do not adjust the top row.
@param bStickyLeftCol
If TRUE, do not adjust the left column.
+ @param bConsiderCellNotes
+ If TRUE, consider the presence of cell notes besides data.
@returns true if there is any data, false if not.
*/
bool ShrinkToUsedDataArea( bool& o_bShrunk,
SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
- bool bStickyTopRow = false, bool bStickyLeftCol = false ) const;
+ bool bStickyTopRow = false, bool bStickyLeftCol = false,
+ bool bConsiderCellNotes = false ) const;
/**
* Return the last non-empty row position in given columns that's no
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 31bd7d6fc7cd..0966da0fd61f 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -687,6 +687,7 @@
#define SID_SORT_ATTRIBS (SC_PARAM_START+3)
#define SID_SORT_USERDEF (SC_PARAM_START+4)
#define SID_SORT_NATURALSORT (SC_PARAM_START+5)
+#define SID_SORT_INCCOMMENTS (SC_PARAM_START+6)
// Sidebar -------------------------------------------------------------
diff --git a/sc/inc/sortparam.hxx b/sc/inc/sortparam.hxx
index 268b14c03c25..3351249c97dd 100644
--- a/sc/inc/sortparam.hxx
+++ b/sc/inc/sortparam.hxx
@@ -49,6 +49,7 @@ struct SC_DLLPUBLIC ScSortParam
bool bByRow;
bool bCaseSens;
bool bNaturalSort;
+ bool bIncludeComments;
bool bUserDef;
bool bIncludePattern;
bool bInplace;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e163233736c5..350dcbd4c1b5 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -504,7 +504,7 @@ public:
bool ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
- bool bStickyTopRow, bool bStickyLeftCol ) const;
+ bool bStickyTopRow, bool bStickyLeftCol, bool bConsiderCellNotes=false ) const;
SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index fee950c176a7..aff80507a625 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -1259,7 +1259,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 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)
+(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,SfxBoolItem IncludeComments SID_SORT_INCCOMMENTS)
[
AutoUpdate = FALSE,
FastCall = FALSE,
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index de7ee84908e8..c22ac0f1fa3c 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1093,7 +1093,7 @@ bool ScDocument::ShrinkToDataArea(SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow
bool ScDocument::ShrinkToUsedDataArea( bool& o_bShrunk, SCTAB nTab, SCCOL& rStartCol,
SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
- bool bStickyTopRow, bool bStickyLeftCol ) const
+ bool bStickyTopRow, bool bStickyLeftCol, bool bConsiderCellNotes ) const
{
if (!ValidTab(nTab) || nTab >= static_cast<SCTAB> (maTabs.size()) || !maTabs[nTab])
{
@@ -1101,7 +1101,7 @@ bool ScDocument::ShrinkToUsedDataArea( bool& o_bShrunk, SCTAB nTab, SCCOL& rStar
return false;
}
return maTabs[nTab]->ShrinkToUsedDataArea( o_bShrunk, rStartCol, rStartRow, rEndCol, rEndRow,
- bColumnsOnly, bStickyTopRow, bStickyLeftCol);
+ bColumnsOnly, bStickyTopRow, bStickyLeftCol, bConsiderCellNotes );
}
SCROW ScDocument::GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const
diff --git a/sc/source/core/data/sortparam.cxx b/sc/source/core/data/sortparam.cxx
index 0f7c158e6cb1..38439e5ef062 100644
--- a/sc/source/core/data/sortparam.cxx
+++ b/sc/source/core/data/sortparam.cxx
@@ -35,7 +35,7 @@ ScSortParam::ScSortParam()
ScSortParam::ScSortParam( const ScSortParam& r ) :
nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2),nUserIndex(r.nUserIndex),
bHasHeader(r.bHasHeader),bByRow(r.bByRow),bCaseSens(r.bCaseSens),
- bNaturalSort(r.bNaturalSort),bUserDef(r.bUserDef),
+ bNaturalSort(r.bNaturalSort),bIncludeComments(r.bIncludeComments),bUserDef(r.bUserDef),
bIncludePattern(r.bIncludePattern),bInplace(r.bInplace),
nDestTab(r.nDestTab),nDestCol(r.nDestCol),nDestRow(r.nDestRow),
maKeyState( r.maKeyState ),
@@ -56,6 +56,7 @@ void ScSortParam::Clear()
nDestTab = 0;
nUserIndex = 0;
bHasHeader=bCaseSens=bUserDef=bNaturalSort = false;
+ bIncludeComments = false;
bByRow=bIncludePattern=bInplace = true;
aCollatorLocale = css::lang::Locale();
aCollatorAlgorithm.clear();
@@ -79,6 +80,7 @@ ScSortParam& ScSortParam::operator=( const ScSortParam& r )
bByRow = r.bByRow;
bCaseSens = r.bCaseSens;
bNaturalSort = r.bNaturalSort;
+ bIncludeComments= r.bIncludeComments;
bUserDef = r.bUserDef;
bIncludePattern = r.bIncludePattern;
bInplace = r.bInplace;
@@ -122,6 +124,7 @@ bool ScSortParam::operator==( const ScSortParam& rOther ) const
&& (bByRow == rOther.bByRow)
&& (bCaseSens == rOther.bCaseSens)
&& (bNaturalSort == rOther.bNaturalSort)
+ && (bIncludeComments== rOther.bIncludeComments)
&& (bUserDef == rOther.bUserDef)
&& (nUserIndex == rOther.nUserIndex)
&& (bIncludePattern == rOther.bIncludePattern)
@@ -150,7 +153,7 @@ bool ScSortParam::operator==( const ScSortParam& rOther ) const
ScSortParam::ScSortParam( const ScSubTotalParam& rSub, const ScSortParam& rOld ) :
nCol1(rSub.nCol1),nRow1(rSub.nRow1),nCol2(rSub.nCol2),nRow2(rSub.nRow2),nUserIndex(rSub.nUserIndex),
bHasHeader(true),bByRow(true),bCaseSens(rSub.bCaseSens),bNaturalSort(rOld.bNaturalSort),
- bUserDef(rSub.bUserDef),bIncludePattern(rSub.bIncludePattern),
+ bIncludeComments(rOld.bIncludeComments),bUserDef(rSub.bUserDef),bIncludePattern(rSub.bIncludePattern),
bInplace(true),
nDestTab(0),nDestCol(0),nDestRow(0),
aCollatorLocale( rOld.aCollatorLocale ), aCollatorAlgorithm( rOld.aCollatorAlgorithm ),
@@ -193,7 +196,7 @@ ScSortParam::ScSortParam( const ScSubTotalParam& rSub, const ScSortParam& rOld )
ScSortParam::ScSortParam( const ScQueryParam& rParam, SCCOL nCol ) :
nCol1(nCol),nRow1(rParam.nRow1),nCol2(nCol),nRow2(rParam.nRow2),nUserIndex(0),
bHasHeader(rParam.bHasHeader),bByRow(true),bCaseSens(rParam.bCaseSens),
- bNaturalSort(false),
+ bNaturalSort(false),bIncludeComments(false),
//TODO: what about Locale and Algorithm?
bUserDef(false),bIncludePattern(false),
bInplace(true),
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 8f34af0d0581..7d3d94a26509 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -924,7 +924,8 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
}
bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
- SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly, bool bStickyTopRow, bool bStickyLeftCol ) const
+ SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly, bool bStickyTopRow, bool bStickyLeftCol,
+ bool bConsiderCellNotes ) const
{
o_bShrunk = false;
@@ -955,6 +956,8 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
{
if (aCol[rEndCol].IsEmptyBlock( rStartRow, rEndRow))
{
+ if (bConsiderCellNotes && !aCol[rEndCol].IsNotesEmptyBlock( rStartRow, rEndRow ))
+ break;
--rEndCol;
o_bShrunk = true;
}
@@ -968,6 +971,9 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
{
if (aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow))
{
+ if (bConsiderCellNotes && !aCol[rStartCol].IsNotesEmptyBlock( rStartRow, rEndRow ))
+ break;
+
++rStartCol;
o_bShrunk = true;
}
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 147a35e0020c..49088587cdd7 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -503,6 +503,7 @@ ScTabPageSortOptions::ScTabPageSortOptions( vcl::Window* pParent,
get(m_pBtnHeader, "header");
get(m_pBtnFormats, "formats");
get(m_pBtnNaturalSort, "naturalsort");
+ get(m_pBtnIncComments, "includenotes");
get(m_pBtnCopyResult, "copyresult");
get(m_pLbOutPos, "outarealb");
get(m_pEdOutPos, "outareaed");
@@ -535,6 +536,7 @@ void ScTabPageSortOptions::dispose()
m_pBtnHeader.clear();
m_pBtnFormats.clear();
m_pBtnNaturalSort.clear();
+ m_pBtnIncComments.clear();
m_pBtnCopyResult.clear();
m_pLbOutPos.clear();
m_pEdOutPos.clear();
@@ -656,6 +658,7 @@ void ScTabPageSortOptions::Reset( const SfxItemSet* /* rArgSet */ )
m_pBtnFormats->Check ( aSortData.bIncludePattern );
m_pBtnHeader->Check ( aSortData.bHasHeader );
m_pBtnNaturalSort->Check ( aSortData.bNaturalSort );
+ m_pBtnIncComments->Check ( aSortData.bIncludeComments );
if ( aSortData.bByRow )
{
@@ -720,6 +723,7 @@ bool ScTabPageSortOptions::FillItemSet( SfxItemSet* rArgSet )
aNewSortData.bHasHeader = m_pBtnHeader->IsChecked();
aNewSortData.bCaseSens = m_pBtnCase->IsChecked();
aNewSortData.bNaturalSort = m_pBtnNaturalSort->IsChecked();
+ aNewSortData.bIncludeComments= m_pBtnIncComments->IsChecked();
aNewSortData.bIncludePattern = m_pBtnFormats->IsChecked();
aNewSortData.bInplace = !m_pBtnCopyResult->IsChecked();
aNewSortData.nDestCol = theOutPos.Col();
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 73d5840842b7..f33efe8cf789 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -513,7 +513,8 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
// so empty leading cells will be sorted to the end.
bool bShrunk = false;
rDoc.ShrinkToUsedDataArea( bShrunk, nTab, aLocalParam.nCol1, aLocalParam.nRow1,
- aLocalParam.nCol2, aLocalParam.nRow2, false, aLocalParam.bByRow, !aLocalParam.bByRow);
+ aLocalParam.nCol2, aLocalParam.nRow2, false, aLocalParam.bByRow, !aLocalParam.bByRow,
+ aLocalParam.bIncludeComments );
SCROW nStartRow = aLocalParam.nRow1;
if (aLocalParam.bByRow && aLocalParam.bHasHeader && nStartRow < aLocalParam.nRow2)
diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx
index ca323ddf21cf..87cd6eb9e7eb 100644
--- a/sc/source/ui/inc/tpsort.hxx
+++ b/sc/source/ui/inc/tpsort.hxx
@@ -142,6 +142,8 @@ private:
VclPtr<RadioButton> m_pBtnTopDown;
VclPtr<RadioButton> m_pBtnLeftRight;
+ VclPtr<CheckBox> m_pBtnIncComments;
+
OUString aStrRowLabel;
OUString aStrColLabel;
OUString aStrUndefined;
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 67ffe2b7b4db..9f653391060d 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -379,6 +379,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
aSortParam.bByRow = true;
aSortParam.bCaseSens = false;
aSortParam.bNaturalSort = false;
+ aSortParam.bIncludeComments = false;
aSortParam.bIncludePattern = true;
aSortParam.bInplace = true;
aSortParam.maKeyState[0].bDoSort = true;
@@ -432,6 +433,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
aSortParam.bCaseSens = static_cast<const SfxBoolItem*>(pItem)->GetValue();
if ( pArgs->GetItemState( SID_SORT_NATURALSORT, true, &pItem ) == SfxItemState::SET )
aSortParam.bNaturalSort = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_INCCOMMENTS, true, &pItem ) == SfxItemState::SET )
+ aSortParam.bIncludeComments = static_cast<const SfxBoolItem*>(pItem)->GetValue();
if ( pArgs->GetItemState( SID_SORT_ATTRIBS, true, &pItem ) == SfxItemState::SET )
aSortParam.bIncludePattern = static_cast<const SfxBoolItem*>(pItem)->GetValue();
if ( pArgs->GetItemState( SID_SORT_USERDEF, true, &pItem ) == SfxItemState::SET )
@@ -516,6 +519,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
rOutParam.bCaseSens ) );
rReq.AppendItem( SfxBoolItem( SID_SORT_NATURALSORT,
rOutParam.bNaturalSort ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_INCCOMMENTS,
+ rOutParam.bIncludeComments ) );
rReq.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
rOutParam.bIncludePattern ) );
sal_uInt16 nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 96b4033060d0..e18f5b1d7acf 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -795,6 +795,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
aSortParam.bByRow = true;
aSortParam.bCaseSens = false;
aSortParam.bNaturalSort = false;
+ aSortParam.bIncludeComments = false;
aSortParam.bIncludePattern = true;
aSortParam.bInplace = true;
aSortParam.maKeyState[0].bDoSort = true;
diff --git a/sc/uiconfig/scalc/ui/sortoptionspage.ui b/sc/uiconfig/scalc/ui/sortoptionspage.ui
index 88873be8a760..6a1a1579400e 100644
--- a/sc/uiconfig/scalc/ui/sortoptionspage.ui
+++ b/sc/uiconfig/scalc/ui/sortoptionspage.ui
@@ -85,6 +85,20 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="includenotes">
+ <property name="label" translatable="yes">Include comments-only boundary column(s)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkCheckButton" id="copyresult">
<property name="label" translatable="yes">Copy sort results to:</property>
<property name="visible">True</property>
@@ -98,7 +112,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -118,7 +132,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -138,7 +152,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -155,7 +169,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
</packing>
</child>
<child>
@@ -175,7 +189,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
<property name="width">2</property>
</packing>
</child>
@@ -190,7 +204,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">9</property>
</packing>
</child>
<child>
@@ -204,7 +218,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">9</property>
</packing>
</child>
<child>
@@ -214,7 +228,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
@@ -224,7 +238,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>