[Libreoffice-commits] .: 2 commits - sc/inc sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Thu Jul 12 23:39:30 PDT 2012
sc/inc/attarray.hxx | 3 +++
sc/inc/column.hxx | 1 +
sc/source/core/data/attarray.cxx | 15 +++++++++++++++
sc/source/core/data/column.cxx | 5 +++++
sc/source/core/data/table3.cxx | 6 ++----
sc/source/ui/dbgui/tpsort.cxx | 21 ++++++++++++++++++++-
6 files changed, 46 insertions(+), 5 deletions(-)
New commits:
commit 0234b73de28098fc1cd37b55471ef924d2b584cc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Jul 13 08:16:57 2012 +0200
don't use wrong sort direction in some cases
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 303d6c6..3dccaa0 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -227,6 +227,17 @@ sal_Bool ScTabPageSortFields::FillItemSet( SfxItemSet& rArgSet )
{
ScSortParam aNewSortData = aSortData;
+ if (pDlg)
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSort, sal_True, &pItem ) == SFX_ITEM_SET )
+ {
+ ScSortParam aTempData = static_cast<const ScSortItem*>(pItem)->GetSortData();
+ aTempData.maKeyState = aNewSortData.maKeyState;
+ aNewSortData = aTempData;
+ }
+ }
std::vector<sal_uInt16> nSortPos;
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
@@ -624,7 +635,8 @@ void ScTabPageSortOptions::Init()
// -----------------------------------------------------------------------
-SfxTabPage* ScTabPageSortOptions::Create( Window* pParent,
+SfxTabPage* ScTabPageSortOptions::Create(
+ Window* pParent,
const SfxItemSet& rArgSet )
{
return ( new ScTabPageSortOptions( pParent, rArgSet ) );
@@ -707,6 +719,13 @@ sal_Bool ScTabPageSortOptions::FillItemSet( SfxItemSet& rArgSet )
// Create local copy of ScParam
ScSortParam aNewSortData = aSortData;
+ if (pDlg)
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSort, sal_True, &pItem ) == SFX_ITEM_SET )
+ aNewSortData = static_cast<const ScSortItem*>(pItem)->GetSortData();
+ }
aNewSortData.bByRow = aBtnTopDown.IsChecked();
aNewSortData.bHasHeader = aBtnHeader.IsChecked();
aNewSortData.bCaseSens = aBtnCase.IsChecked();
commit 902082656655aeab559c0b5781907ff004179468
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Jul 13 08:17:26 2012 +0200
don't delete ScPatternAttr from doc pool for swap, i#118877
the original apache commit is quite ugly and should not be used!!
Change-Id: Id02d2cf474e49b97bfe285fe76867d1b1d944ec3
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 9b81440..6ce325a 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -131,6 +131,9 @@ public:
void SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool = false );
void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern,
bool bPutToPool = false, ScEditDataArray* pDataArray = NULL );
+
+ //swap two column patterns without adding and removing them from the pool
+ void SwapPattern( ScAttrArray& pArray2, SCROW nRow1, SCROW nRow2, const ScPatternAttr* pPattern1, const ScPatternAttr* pPattern2 );
void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle );
void ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache,
ScEditDataArray* pDataArray = NULL );
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 6f776e1..49ab814 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -307,6 +307,7 @@ public:
ScEditDataArray* pDataArray = NULL );
bool SetAttrEntries(ScAttrEntry* pData, SCSIZE nSize);
void SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr, bool bPutToPool = false );
+ void SwapPattern( ScColumn& rCol, SCROW nRow1, SCROW nRow2, const ScPatternAttr& rPatAttr1, const ScPatternAttr& rPatAttr2 );
void SetPatternArea( SCROW nStartRow, SCROW nEndRow,
const ScPatternAttr& rPatAttr, bool bPutToPool = false );
void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 6cf487f..e166ea2 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -483,6 +483,21 @@ void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPattern
#endif
}
+void ScAttrArray::SwapPattern( ScAttrArray& rArray2, SCROW nRow1, SCROW nRow2, const ScPatternAttr* pPattern1, const ScPatternAttr* pPattern2)
+{
+ if(!VALIDROW(nRow1) || !VALIDROW(nRow2))
+ return;
+
+ SCSIZE nIndex1 = 0;
+ SCSIZE nIndex2 = 0;
+ Search(nRow1, nIndex1);
+ rArray2.Search(nRow2, nIndex2);
+ pData[nIndex1].pPattern = pPattern1;
+ rArray2.pData[nIndex2].pPattern = pPattern2;
+
+ if (pDocument->IsStreamValid(nTab))
+ pDocument->SetStreamValid(nTab, false);
+}
void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle )
{
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index db99462..adc5eb2 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -652,6 +652,11 @@ void ScColumn::SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr, bool bPutT
pAttrArray->SetPattern( nRow, &rPatAttr, bPutToPool );
}
+void ScColumn::SwapPattern( ScColumn& rCol2, SCROW nRow1, SCROW nRow2, const ScPatternAttr& rPatAttr1, const ScPatternAttr& rPatAttr2 )
+{
+ pAttrArray->SwapPattern( *rCol2.pAttrArray, nRow1, nRow2, &rPatAttr1, &rPatAttr2 );
+}
+
void ScColumn::SetPatternArea( SCROW nStartRow, SCROW nEndRow,
const ScPatternAttr& rPatAttr, bool bPutToPool )
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 85354f3..6a140cd 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -571,8 +571,7 @@ void ScTable::SwapCol(SCCOL nCol1, SCCOL nCol2)
const ScPatternAttr* pPat2 = GetPattern(nCol2, nRow);
if (pPat1 != pPat2)
{
- SetPattern(nCol1, nRow, *pPat2, true);
- SetPattern(nCol2, nRow, *pPat1, true);
+ aCol[nCol1].SwapPattern(aCol[nCol2], nRow, nRow, *pPat1, *pPat2);
}
}
}
@@ -623,8 +622,7 @@ void ScTable::SwapRow(SCROW nRow1, SCROW nRow2)
const ScPatternAttr* pPat2 = GetPattern(nCol, nRow2);
if (pPat1 != pPat2)
{
- SetPattern(nCol, nRow1, *pPat2, true);
- SetPattern(nCol, nRow2, *pPat1, true);
+ aCol[nCol].SwapPattern(aCol[nCol], nRow1, nRow2, *pPat1, *pPat2);
}
}
}
More information about the Libreoffice-commits
mailing list