[Libreoffice-commits] .: 3 commits - sc/inc sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Thu Jan 5 09:41:47 PST 2012
sc/inc/rangenam.hxx | 1
sc/inc/reftokenhelper.hxx | 1
sc/source/core/tool/rangenam.cxx | 9 +++++
sc/source/core/tool/reftokenhelper.cxx | 54 ---------------------------------
sc/source/core/tool/token.cxx | 10 +-----
sc/source/ui/inc/namemgrtable.hxx | 4 +-
sc/source/ui/namedlg/namedlg.cxx | 2 -
sc/source/ui/namedlg/namemgrtable.cxx | 7 ++--
sc/source/ui/namedlg/namepast.cxx | 5 ++-
9 files changed, 25 insertions(+), 68 deletions(-)
New commits:
commit 5b8deb57c6782b77fcf180ef6097f71b6e1b07d2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Jan 5 18:35:05 2012 +0100
simplify code a bit
diff --git a/sc/inc/reftokenhelper.hxx b/sc/inc/reftokenhelper.hxx
index c076f34..9119e3e 100644
--- a/sc/inc/reftokenhelper.hxx
+++ b/sc/inc/reftokenhelper.hxx
@@ -58,7 +58,6 @@ public:
const sal_Unicode cSep, ::formula::FormulaGrammar::Grammar eGrammar);
static bool getRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, bool bExternal = false);
- static bool getAbsRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, const ScAddress& rPos, bool bExternal = false);
static void getRangeListFromTokens(ScRangeList& rRangeList, const ::std::vector<ScTokenRef>& pTokens);
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index 364556c..2a32e12 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -146,25 +146,6 @@ void singleRefToAddr(const ScSingleRefData& rRef, ScAddress& rAddr)
rAddr.SetTab(rRef.nTab);
}
-//returns an absolute address in reference to rPos
-void singleRefToAbsAddr(const ScSingleRefData& rRef, ScAddress& rAddr, const ScAddress& rPos)
-{
- if (rRef.IsColRel())
- rAddr.SetCol(rRef.nRelCol + rPos.Col());
- else
- rAddr.SetCol(rRef.nCol);
-
- if (rRef.IsRowRel())
- rAddr.SetRow(rRef.nRelRow + rPos.Row());
- else
- rAddr.SetRow(rRef.nRow);
-
- if (rRef.IsTabRel())
- rAddr.SetTab(rRef.nRelTab + rPos.Tab());
- else
- rAddr.SetTab(rRef.nTab);
-}
-
}
bool ScRefTokenHelper::getRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, bool bExternal)
@@ -202,41 +183,6 @@ bool ScRefTokenHelper::getRangeFromToken(ScRange& rRange, const ScTokenRef& pTok
return false;
}
-bool ScRefTokenHelper::getAbsRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, const ScAddress& rPos, bool bExternal)
-{
- StackVar eType = pToken->GetType();
- switch (pToken->GetType())
- {
- case svSingleRef:
- case svExternalSingleRef:
- {
- if ((eType == svExternalSingleRef && !bExternal) ||
- (eType == svSingleRef && bExternal))
- return false;
-
- const ScSingleRefData& rRefData = pToken->GetSingleRef();
- singleRefToAbsAddr(rRefData, rRange.aStart, rPos);
- rRange.aEnd = rRange.aStart;
- return true;
- }
- case svDoubleRef:
- case svExternalDoubleRef:
- {
- if ((eType == svExternalDoubleRef && !bExternal) ||
- (eType == svDoubleRef && bExternal))
- return false;
-
- const ScComplexRefData& rRefData = pToken->GetDoubleRef();
- singleRefToAbsAddr(rRefData.Ref1, rRange.aStart, rPos);
- singleRefToAbsAddr(rRefData.Ref2, rRange.aEnd, rPos);
- return true;
- }
- default:
- ; // do nothing
- }
- return false;
-}
-
void ScRefTokenHelper::getRangeListFromTokens(ScRangeList& rRangeList, const vector<ScTokenRef>& rTokens)
{
vector<ScTokenRef>::const_iterator itr = rTokens.begin(), itrEnd = rTokens.end();
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 8196b8a..83be799 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1823,7 +1823,6 @@ namespace {
void GetExternalTableData(const ScDocument* pOldDoc, const ScDocument* pNewDoc, const SCTAB nTab, rtl::OUString& rTabName, sal_uInt16& rFileId)
{
rtl::OUString aFileName = pOldDoc->GetFileURL();;
- std::cout << aFileName << std::endl;
rFileId = pNewDoc->GetExternalRefManager()->getExternalFileId(aFileName);
rTabName = pOldDoc->GetCopyTabName(nTab);
if (rTabName.isEmpty())
@@ -1839,7 +1838,9 @@ bool IsInCopyRange( const ScRange& rRange, const ScDocument* pClipDoc )
bool SkipReference(ScToken* pToken, const ScAddress& rPos, const ScDocument* pOldDoc, bool bRangeName)
{
ScRange aRange;
- if (!ScRefTokenHelper::getAbsRangeFromToken(aRange, pToken, rPos))
+
+ pToken->CalcAbsIfRel(rPos);
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, pToken))
return true;
if (bRangeName && aRange.aStart.Tab() == rPos.Tab())
commit ac7f046d27b4e47361f44efe252fca867a0a1d02
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Jan 5 18:28:05 2012 +0100
remove unneeded debug statements
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6ef4346..8196b8a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -52,9 +52,6 @@
#include "externalrefmgr.hxx"
#include "document.hxx"
-#include <iostream>
-#include <rtl/oustringostreaminserter.hxx>
-
using ::std::vector;
#include <com/sun/star/sheet/ComplexReference.hpp>
@@ -1831,13 +1828,11 @@ void GetExternalTableData(const ScDocument* pOldDoc, const ScDocument* pNewDoc,
rTabName = pOldDoc->GetCopyTabName(nTab);
if (rTabName.isEmpty())
pOldDoc->GetName(nTab, rTabName);
- std::cout << "TabName: " << rTabName << std::endl;
}
bool IsInCopyRange( const ScRange& rRange, const ScDocument* pClipDoc )
{
ScClipParam& rClipParam = const_cast<ScDocument*>(pClipDoc)->GetClipParam();
- std::cout << "Col: " << rRange.aStart.Col() << "Row: " << rRange.aStart.Row() << "Tab: " << rRange.aStart.Tab() << std::endl;
return rClipParam.maRanges.In(rRange);
}
commit cb76b35b60b3194e45627edc293e3ce7a652941f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Jan 5 18:26:25 2012 +0100
handle relative refs in name dialogs correctly
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 4b4f8d9..0e8de43 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -135,6 +135,7 @@ public:
sal_uInt32 GetUnoType() const;
SC_DLLPUBLIC void GetSymbol( String& rSymbol, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
SC_DLLPUBLIC void GetSymbol( rtl::OUString& rSymbol, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
+ SC_DLLPUBLIC void GetSymbol( rtl::OUString& rSymbol, const ScAddress& rPos, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
void UpdateSymbol( rtl::OUStringBuffer& rBuffer, const ScAddress&,
const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT );
void UpdateReference( UpdateRefMode eUpdateRefMode,
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index a471512..8ebcc76 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -277,6 +277,15 @@ void ScRangeData::GetSymbol( OUString& rSymbol, const FormulaGrammar::Grammar eG
rSymbol = aStr;
}
+void ScRangeData::GetSymbol( OUString& rSymbol, const ScAddress& rPos, const FormulaGrammar::Grammar eGrammar ) const
+{
+ String aStr;
+ ScCompiler aComp(pDoc, rPos, *pCode);
+ aComp.SetGrammar(eGrammar);
+ aComp.CreateStringFromTokenArray( aStr );
+ rSymbol = aStr;
+}
+
void ScRangeData::UpdateSymbol( rtl::OUStringBuffer& rBuffer, const ScAddress& rPos,
const FormulaGrammar::Grammar eGrammar )
{
diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx
index 3023e29..3646164 100644
--- a/sc/source/ui/inc/namemgrtable.hxx
+++ b/sc/source/ui/inc/namemgrtable.hxx
@@ -31,6 +31,7 @@
#include <vcl/ctrl.hxx>
#include "scresid.hxx"
+#include "address.hxx"
#include <vector>
#include <boost/ptr_container/ptr_map.hpp>
@@ -71,6 +72,7 @@ private:
// otherwise opening the dialog with a lot of range names is extremelly slow because
// we would calculate all formula strings during opening
std::map<SvLBoxEntry*, bool> maCalculatedFormulaEntries;
+ const ScAddress maPos;
void GetLine(ScRangeNameLine& aLine, SvLBoxEntry* pEntry);
void Init();
@@ -78,7 +80,7 @@ private:
const ScRangeData* findRangeData(const ScRangeNameLine& rLine);
public:
- ScRangeManagerTable( Window* pParent, boost::ptr_map<rtl::OUString, ScRangeName>& aTabRangeNames );
+ ScRangeManagerTable( Window* pParent, boost::ptr_map<rtl::OUString, ScRangeName>& aTabRangeNames, const ScAddress& rPos );
virtual ~ScRangeManagerTable();
void addEntry( const ScRangeNameLine& rLine, bool bSetCurEntry = true );
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index a485986..56c50e8 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -144,7 +144,7 @@ void ScNameDlg::Init()
//init UI
maFtInfo.SetStyle(WB_VCENTER);
- mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, maRangeMap);
+ mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, maRangeMap, maCursorPos);
mpRangeManagerTable->SetSelectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
mpRangeManagerTable->SetDeselectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index 7f8eb6b..b9164d3 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -57,11 +57,12 @@ String createEntryString(const ScRangeNameLine& rLine)
return aRet;
}
-ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap ):
+ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap, const ScAddress& rPos ):
SvTabListBox( pWindow, WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP ),
maHeaderBar( pWindow, WB_BUTTONSTYLE | WB_BOTTOMBORDER ),
maGlobalString( ScGlobal::GetRscString(STR_GLOBAL_SCOPE)),
- mrRangeMap( rRangeMap )
+ mrRangeMap( rRangeMap ),
+ maPos( rPos )
{
Size aBoxSize( pWindow->GetOutputSizePixel() );
@@ -172,7 +173,7 @@ void ScRangeManagerTable::CheckForFormulaString()
GetLine( aLine, pEntry);
const ScRangeData* pData = findRangeData( aLine );
rtl::OUString aFormulaString;
- pData->GetSymbol(aFormulaString);
+ pData->GetSymbol(aFormulaString, maPos);
SetEntryText(aFormulaString, pEntry, 1);
maCalculatedFormulaEntries.insert( std::pair<SvLBoxEntry*, bool>(pEntry, true) );
}
diff --git a/sc/source/ui/namedlg/namepast.cxx b/sc/source/ui/namedlg/namepast.cxx
index 4193955..68a406f 100644
--- a/sc/source/ui/namedlg/namepast.cxx
+++ b/sc/source/ui/namedlg/namepast.cxx
@@ -38,6 +38,7 @@
#include "docsh.hxx"
#include "miscdlgs.hrc"
#include "rangenam.hxx"
+#include "viewdata.hxx"
//==================================================================
@@ -62,7 +63,9 @@ ScNamePasteDlg::ScNamePasteDlg( Window * pParent, ScDocShell* pShell, bool )
aRangeMap.insert(aTemp, new ScRangeName(*itr->second));
}
- mpTable = new ScRangeManagerTable(&maCtrl, aRangeMap);
+ ScViewData* pViewData = pShell->GetViewData();
+ ScAddress aPos(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
+ mpTable = new ScRangeManagerTable(&maCtrl, aRangeMap, aPos);
maBtnPaste.SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl) );
maBtnPasteAll.SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl));
More information about the Libreoffice-commits
mailing list