[Libreoffice-commits] .: 2 commits - sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Tue Aug 16 14:17:52 PDT 2011
sc/source/core/data/cell.cxx | 39 +++++++++++++++++++++------------------
sc/source/core/data/document.cxx | 2 +-
sc/source/core/data/table2.cxx | 2 +-
sc/source/ui/view/viewfun3.cxx | 5 +----
4 files changed, 24 insertions(+), 24 deletions(-)
New commits:
commit 74070a021389534b9e791980bd33ede45be9fd81
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Aug 16 23:12:50 2011 +0200
rework 04d2e6469529b6187900659517d6f6dd5ea2cca5
only update range names in formulas if the documents are different or
the sheets are different
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 1eb4433..4d030cc 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -131,7 +131,7 @@ ScBaseCell* lclCloneCell( const ScBaseCell& rSrcCell, ScDocument& rDestDoc, cons
return 0;
}
-void adjustRangeName(ScToken* pToken, ScDocument& aNewDoc, ScDocument* pOldDoc, ScAddress aNewPos, ScAddress aOldPos)
+void adjustRangeName(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldDoc, const ScAddress& aNewPos, const ScAddress& aOldPos)
{
bool bOldGlobal = static_cast<bool>(pToken->GetByte());
SCTAB aOldTab = aOldPos.Tab();
@@ -158,35 +158,35 @@ void adjustRangeName(ScToken* pToken, ScDocument& aNewDoc, ScDocument* pOldDoc,
//find corresponding range name in new document
//first search for local range name then global range names
SCTAB aNewTab = aNewPos.Tab();
- ScRangeName* pRangeName = aNewDoc.GetRangeName(aNewTab);
+ ScRangeName* pRangeName = rNewDoc.GetRangeName(aNewTab);
ScRangeData* pRangeData = NULL;
bool bNewGlobal = false;
//search local range names
if (pRangeName)
{
- pRangeData = pRangeName->findByUpperName(aRangeName.toAsciiUpperCase());
+ pRangeData = pRangeName->findByUpperName(ScGlobal::pCharClass->upper(aRangeName));
}
//search global range names
if (!pRangeData)
{
//even if it is not in the global scope we'll have a global range name
bNewGlobal = true;
- pRangeName = aNewDoc.GetRangeName();
+ pRangeName = rNewDoc.GetRangeName();
if (pRangeName)
- pRangeData = pRangeName->findByUpperName(aRangeName.toAsciiUpperCase());
+ pRangeData = pRangeName->findByUpperName(ScGlobal::pCharClass->upper(aRangeName));
}
//if no range name was found copy it
if (!pRangeData)
{
- pRangeData = new ScRangeData(*pOldRangeData, &aNewDoc);
- aNewDoc.GetRangeName()->insert(pRangeData);
+ pRangeData = new ScRangeData(*pOldRangeData, &rNewDoc);
+ rNewDoc.GetRangeName()->insert(pRangeData);
}
sal_Int32 nIndex = pRangeData->GetIndex();
pToken->SetIndex(nIndex);
pToken->SetByte(bNewGlobal);
}
-void adjustDBRange(ScToken* pToken, ScDocument& aNewDoc, ScDocument* pOldDoc)
+void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldDoc)
{
ScDBCollection* pOldDBCollection = pOldDoc->GetDBCollection();
if (!pOldDBCollection)
@@ -198,10 +198,10 @@ void adjustDBRange(ScToken* pToken, ScDocument& aNewDoc, ScDocument* pOldDoc)
rtl::OUString aDBName = pDBData->GetName();
//search in new document
- ScDBCollection* pNewDBCollection = aNewDoc.GetDBCollection();
+ ScDBCollection* pNewDBCollection = rNewDoc.GetDBCollection();
if (!pNewDBCollection)
{
- pNewDBCollection = new ScDBCollection(&aNewDoc);
+ pNewDBCollection = new ScDBCollection(&rNewDoc);
}
ScDBCollection::NamedDBs& aNewNamedDBs = pNewDBCollection->getNamedDBs();
ScDBData* pNewDBData = aNewNamedDBs.findByName(aDBName);
@@ -855,16 +855,19 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons
sal_Bool bClipMode = rCell.pDocument->IsClipboard();
//update ScNameTokens
- if (!pDocument->IsClipboard())
+ if (!pDocument->IsClipOrUndo() || rDoc.IsUndo())
{
- ScToken* pToken = NULL;
- while((pToken = static_cast<ScToken*>(pCode->GetNextName()))!= NULL)
+ if (!pDocument->IsClipboardSource() || aPos.Tab() != rCell.aPos.Tab())
{
- OpCode eOpCode = pToken->GetOpCode();
- if (eOpCode == ocName)
- adjustRangeName(pToken, rDoc, rCell.pDocument, aPos, rCell.aPos);
- else if (eOpCode == ocDBArea)
- adjustDBRange(pToken, rDoc, rCell.pDocument);
+ ScToken* pToken = NULL;
+ while((pToken = static_cast<ScToken*>(pCode->GetNextName()))!= NULL)
+ {
+ OpCode eOpCode = pToken->GetOpCode();
+ if (eOpCode == ocName)
+ adjustRangeName(pToken, rDoc, rCell.pDocument, aPos, rCell.aPos);
+ else if (eOpCode == ocDBArea)
+ adjustDBRange(pToken, rDoc, rCell.pDocument);
+ }
}
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index a11d0c6..3530631 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -465,7 +465,7 @@ void ScTable::CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
{
// copy content
//local range names need to be copied first for formula cells
- if (!pTable->mpRangeName)
+ if (!pTable->mpRangeName && mpRangeName)
pTable->mpRangeName = new ScRangeName(*mpRangeName);
SCCOL i;
commit d7791df329a6bcf315506bb2ec4e6cc0f07309b9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Aug 16 23:03:43 2011 +0200
GetLastSelected returns a table number and not a 1-based index
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 5513313..0f53226 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1661,7 +1661,7 @@ void ScDocument::InitUndoSelected( ScDocument* pSrcDoc, const ScMarkData& rTabSe
xPoolHelper = pSrcDoc->xPoolHelper;
String aString;
- for (SCTAB nTab = 0; nTab < rTabSelection.GetLastSelected(); nTab++)
+ for (SCTAB nTab = 0; nTab <= rTabSelection.GetLastSelected(); nTab++)
if ( rTabSelection.GetTableSelect( nTab ) )
{
ScTable* pTable = new ScTable(this, nTab, aString, bColInfo, bRowInfo);
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 03481f6..a3c1ab3 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1551,10 +1551,7 @@ bool ScViewFunc::PasteMultiRangesFromClip(
// Determine the first and last selected sheet numbers.
SCTAB nTab1 = aMark.GetFirstSelected();
- SCTAB nTab2 = nTab1;
- for (SCTAB i = nTab1+1; i < aMark.GetLastSelected(); ++i)
- if (aMark.GetTableSelect(i))
- nTab2 = i;
+ SCTAB nTab2 = aMark.GetLastSelected();
ScDocShellModificator aModificator(*pDocSh);
More information about the Libreoffice-commits
mailing list