summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-28 11:23:11 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-29 10:06:50 +0200
commit0bb2985071780ab3c83e576b1f57841fd037eaba (patch)
tree393761a66fc7e08e5b6990f64cda3fcf6db705ba /sw/source/core
parentbc86f6d3583965dd369d0ae73a5d647c43ae38e9 (diff)
no need to store SwSortKey separately on the heap
Change-Id: Ib05e02a6c9c239f590508c7e71667d7ecca64f79 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116366 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/doc/docsort.cxx18
-rw-r--r--sw/source/core/doc/sortopt.cxx5
-rw-r--r--sw/source/core/unocore/unoobj.cxx42
3 files changed, 31 insertions, 34 deletions
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index 3c2f8c1f019c..090385d6c419 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -121,8 +121,8 @@ int SwSortElement::keycompare(const SwSortElement& rCmp, sal_uInt16 nKey) const
// The actual comparison
const SwSortElement *pOrig, *pCmp;
- const SwSortKey* pSrtKey = pOptions->aKeys[ nKey ].get();
- if( pSrtKey->eSortOrder == SwSortOrder::Ascending )
+ const SwSortKey& rSrtKey = pOptions->aKeys[ nKey ];
+ if( rSrtKey.eSortOrder == SwSortOrder::Ascending )
{
pOrig = this;
pCmp = &rCmp;
@@ -133,7 +133,7 @@ int SwSortElement::keycompare(const SwSortElement& rCmp, sal_uInt16 nKey) const
pCmp = this;
}
- if( pSrtKey->bIsNumeric )
+ if( rSrtKey.bIsNumeric )
{
double n1 = pOrig->GetValue( nKey );
double n2 = pCmp->GetValue( nKey );
@@ -142,12 +142,12 @@ int SwSortElement::keycompare(const SwSortElement& rCmp, sal_uInt16 nKey) const
}
else
{
- if( !pLastAlgorithm || *pLastAlgorithm != pSrtKey->sSortType )
+ if( !pLastAlgorithm || *pLastAlgorithm != rSrtKey.sSortType )
{
if( pLastAlgorithm )
- *pLastAlgorithm = pSrtKey->sSortType;
+ *pLastAlgorithm = rSrtKey.sSortType;
else
- pLastAlgorithm = new OUString( pSrtKey->sSortType );
+ pLastAlgorithm = new OUString( rSrtKey.sSortType );
pSortCollator->loadCollatorAlgorithm( *pLastAlgorithm,
*pLocale,
pOptions->bIgnoreCase ? SW_COLLATOR_IGNORES : 0 );
@@ -196,7 +196,7 @@ OUString SwSortTextElement::GetKey(sal_uInt16 nId) const
const OUString& rStr = pTextNd->GetText();
sal_Unicode nDeli = pOptions->cDeli;
- sal_uInt16 nDCount = pOptions->aKeys[nId]->nColumnId, i = 1;
+ sal_uInt16 nDCount = pOptions->aKeys[nId].nColumnId, i = 1;
sal_Int32 nStart = 0;
// Find the delimiter
@@ -228,7 +228,7 @@ SwSortBoxElement::SwSortBoxElement( sal_uInt16 nRC )
OUString SwSortBoxElement::GetKey(sal_uInt16 nKey) const
{
const FndBox_* pFndBox;
- sal_uInt16 nCol = pOptions->aKeys[nKey]->nColumnId-1;
+ sal_uInt16 nCol = pOptions->aKeys[nKey].nColumnId-1;
if( SwSortDirection::Rows == pOptions->eDirection )
pFndBox = pBox->GetBox(nCol, nRow); // Sort rows
@@ -260,7 +260,7 @@ OUString SwSortBoxElement::GetKey(sal_uInt16 nKey) const
double SwSortBoxElement::GetValue( sal_uInt16 nKey ) const
{
const FndBox_* pFndBox;
- sal_uInt16 nCol = pOptions->aKeys[nKey]->nColumnId-1;
+ sal_uInt16 nCol = pOptions->aKeys[nKey].nColumnId-1;
if( SwSortDirection::Rows == pOptions->eDirection )
pFndBox = pBox->GetBox(nCol, nRow); // Sort rows
diff --git a/sw/source/core/doc/sortopt.cxx b/sw/source/core/doc/sortopt.cxx
index 06ac058568af..b5fc62ba845d 100644
--- a/sw/source/core/doc/sortopt.cxx
+++ b/sw/source/core/doc/sortopt.cxx
@@ -45,16 +45,13 @@ SwSortOptions::SwSortOptions()
}
SwSortOptions::SwSortOptions(const SwSortOptions& rOpt) :
+ aKeys( rOpt.aKeys ),
eDirection( rOpt.eDirection ),
cDeli( rOpt.cDeli ),
nLanguage( rOpt.nLanguage ),
bTable( rOpt.bTable ),
bIgnoreCase( rOpt.bIgnoreCase )
{
- for(auto const & pKey : rOpt.aKeys)
- {
- aKeys.push_back( std::make_unique<SwSortKey>(*pKey) );
- }
}
SwSortOptions::~SwSortOptions()
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index eeff66995bd3..56ad0c297eec 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -2588,21 +2588,21 @@ bool SwUnoCursorHelper::ConvertSortProperties(
rSortOpt.cDeli = ' ';
rSortOpt.eDirection = SwSortDirection::Columns; //!! UI text may be contrary though !!
- std::unique_ptr<SwSortKey> pKey1(new SwSortKey);
- pKey1->nColumnId = USHRT_MAX;
- pKey1->bIsNumeric = true;
- pKey1->eSortOrder = SwSortOrder::Ascending;
-
- std::unique_ptr<SwSortKey> pKey2(new SwSortKey);
- pKey2->nColumnId = USHRT_MAX;
- pKey2->bIsNumeric = true;
- pKey2->eSortOrder = SwSortOrder::Ascending;
-
- std::unique_ptr<SwSortKey> pKey3(new SwSortKey);
- pKey3->nColumnId = USHRT_MAX;
- pKey3->bIsNumeric = true;
- pKey3->eSortOrder = SwSortOrder::Ascending;
- SwSortKey* aKeys[3] = {pKey1.get(), pKey2.get(), pKey3.get()};
+ SwSortKey aKey1;
+ aKey1.nColumnId = USHRT_MAX;
+ aKey1.bIsNumeric = true;
+ aKey1.eSortOrder = SwSortOrder::Ascending;
+
+ SwSortKey aKey2;
+ aKey2.nColumnId = USHRT_MAX;
+ aKey2.bIsNumeric = true;
+ aKey2.eSortOrder = SwSortOrder::Ascending;
+
+ SwSortKey aKey3;
+ aKey3.nColumnId = USHRT_MAX;
+ aKey3.bIsNumeric = true;
+ aKey3.eSortOrder = SwSortOrder::Ascending;
+ SwSortKey* aKeys[3] = {&aKey1, &aKey2, &aKey3};
bool bOldSortdescriptor(false);
bool bNewSortdescriptor(false);
@@ -2813,17 +2813,17 @@ bool SwUnoCursorHelper::ConvertSortProperties(
bRet = false;
}
- if (pKey1->nColumnId != USHRT_MAX)
+ if (aKey1.nColumnId != USHRT_MAX)
{
- rSortOpt.aKeys.push_back(std::move(pKey1));
+ rSortOpt.aKeys.push_back(aKey1);
}
- if (pKey2->nColumnId != USHRT_MAX)
+ if (aKey2.nColumnId != USHRT_MAX)
{
- rSortOpt.aKeys.push_back(std::move(pKey2));
+ rSortOpt.aKeys.push_back(aKey2);
}
- if (pKey3->nColumnId != USHRT_MAX)
+ if (aKey3.nColumnId != USHRT_MAX)
{
- rSortOpt.aKeys.push_back(std::move(pKey3));
+ rSortOpt.aKeys.push_back(aKey3);
}
return bRet && !rSortOpt.aKeys.empty();