diff options
author | Eike Rathke <erack@redhat.com> | 2016-03-31 22:22:12 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-03-31 23:35:51 +0200 |
commit | 58f4f2491b4f1705ad7064131203b0854485fc43 (patch) | |
tree | a013b4d9b22bea6c8119c57f0924ab12a87b44a7 | |
parent | 30b10b1a589945b570445518163feb6eac8e95e1 (diff) |
add ScDocument::InsertNewRangeName() for sheet-local scope
Change-Id: Id7e13a31a092e83c9c7cf6334cced45a28000f98
-rw-r--r-- | sc/inc/document.hxx | 13 | ||||
-rw-r--r-- | sc/source/core/data/documen3.cxx | 10 |
2 files changed, 23 insertions, 0 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 8caca17a3260..4502a260a77a 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -569,6 +569,19 @@ public: */ bool InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr ); + /** + * Insert a new named expression to a sheet-local scope. + * + * @param nTab sheet for local scope. + * @param rName name for the expression. + * @param rPos base position. + * @param rExpr formula expression to be associated with the name. The + * current grammar is used to compile this expression. + * + * @return true if inserted successfully, false otherwise. + */ + bool InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPos, const OUString& rExpr ); + SCTAB GetMaxTableNumber() { return static_cast<SCTAB>(maTabs.size()) - 1; } ScRangePairList* GetColNameRanges() { return &xColNameRanges; } diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index bbc0c4228343..c6ae38fb3ac1 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -222,6 +222,16 @@ bool ScDocument::InsertNewRangeName( const OUString& rName, const ScAddress& rPo return pGlobalNames->insert(pName); } +bool ScDocument::InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPos, const OUString& rExpr ) +{ + ScRangeName* pLocalNames = GetRangeName(nTab); + if (!pLocalNames) + return false; + + ScRangeData* pName = new ScRangeData(this, rName, rExpr, rPos, ScRangeData::Type::Name, GetGrammar()); + return pLocalNames->insert(pName); +} + const ScRangeData* ScDocument::GetRangeAtBlock( const ScRange& rBlock, OUString* pName ) const { const ScRangeData* pData = nullptr; |