[PATCH 3/7] Converted calls in defnamesbuffer.hxx and .cxx

Daniel Bankston daniel.dev.libreoffice at gmail.com
Wed Apr 11 10:55:37 PDT 2012


Converted calls to WorkbookHelper::createNamedRangeObject and ::createLocalNamedObject in defnamesbuffer.hxx and .cxx.
Made further adjustments/corrections to workbookhlper.hxx and .cxx.
---
 sc/source/filter/inc/defnamesbuffer.hxx |    6 +++-
 sc/source/filter/inc/workbookhelper.hxx |    4 +-
 sc/source/filter/oox/defnamesbuffer.cxx |   36 +++++++++++++++++++++---------
 sc/source/filter/oox/workbookhelper.cxx |   12 +++++-----
 4 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/sc/source/filter/inc/defnamesbuffer.hxx b/sc/source/filter/inc/defnamesbuffer.hxx
index 6704f19..654206c 100644
--- a/sc/source/filter/inc/defnamesbuffer.hxx
+++ b/sc/source/filter/inc/defnamesbuffer.hxx
@@ -30,6 +30,7 @@
 #define OOX_XLS_DEFINEDNAMESBUFFER_HXX
 
 #include "formulabase.hxx"
+#include "rangenam.hxx"
 
 namespace com { namespace sun { namespace star {
     namespace sheet { class XNamedRange; }
@@ -158,8 +159,9 @@ private:
     typedef ::std::auto_ptr< StreamDataSequence >   StreamDataSeqPtr;
     typedef ::std::auto_ptr< BiffInputStreamPos >   BiffStreamPosPtr;
 
-    ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange >
-                        mxNamedRange;       /// XNamedRange interface of the defined name.
+    //~ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange >
+                        //~ mxNamedRange;       /// XNamedRange interface of the defined name.
+    ScRangeData*        mpScRangeData       /// ScRangeData of the defined name.
     sal_Int32           mnTokenIndex;       /// Name index used in API token array.
     sal_Int16           mnCalcSheet;        /// Calc sheet index for sheet-local names.
     sal_Unicode         mcBuiltinId;        /// Identifier for built-in defined names.
diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx
index 44f045a..d96a414 100644
--- a/sc/source/filter/inc/workbookhelper.hxx
+++ b/sc/source/filter/inc/workbookhelper.hxx
@@ -190,7 +190,7 @@ public:
                             //~ const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens,
                             //~ sal_Int32 nIndex,
                             //~ sal_Int32 nNameFlags = 0 ) const;
-    ScRangeData createNamedRangeObject(
+    ScRangeData* createNamedRangeObject(
                             ::rtl::OUString& orName,
                             const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens,
                             sal_Int32 nIndex,
@@ -205,7 +205,7 @@ public:
                             //~ const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens,
                             //~ sal_Int32 nIndex,
                             //~ sal_Int32 nNameFlags = 0, sal_Int32 nTab = -1 ) const;
-    ScRangeData createLocalNamedRangeObject(
+    ScRangeData* createLocalNamedRangeObject(
                             ::rtl::OUString& orName,
                             const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens,
                             sal_Int32 nIndex,
diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx
index 9f63afc..ce309b6 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -394,9 +394,11 @@ void DefinedName::createNameObject( sal_Int32 nIndex )
 
     // create the name and insert it into the document, maCalcName will be changed to the resulting name
     if (maModel.mnSheet >= 0)
-        mxNamedRange = createLocalNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags, maModel.mnSheet );
+        //~ mxNamedRange = createLocalNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags, maModel.mnSheet );
+        mpScRangeData = createLocalNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags, maModel.mnSheet );
     else
-        mxNamedRange = createNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags );
+        //~ mxNamedRange = createNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags );
+        mpScRangeData = createLocalNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags, maModel.mnSheet );
     mnTokenIndex = nIndex;
 }
 
@@ -438,9 +440,12 @@ DefinedName::getTokens()
 
 void DefinedName::convertFormula()
 {
-    Reference< XFormulaTokens > xTokens( mxNamedRange, UNO_QUERY );
-    if( !xTokens.is() )
-        return;
+    //~ Reference< XFormulaTokens > xTokens( mxNamedRange, UNO_QUERY );
+    //~ if( !xTokens.is() )
+        //~ return;
+    ScTokenArray* pTokenArray = mpScRangeData->getCode();
+    Sequence< FormulaToken > = aFTokenSeq;
+    ScTokenConversion::ConvertToTokenSequence( this->getScDocument(), aFTokenSeq, *pTokenArray );
     // set built-in names (print ranges, repeated titles, filter ranges)
     if( !isGlobalName() ) switch( mcBuiltinId )
     {
@@ -448,7 +453,8 @@ void DefinedName::convertFormula()
         {
             Reference< XPrintAreas > xPrintAreas( getSheetFromDoc( mnCalcSheet ), UNO_QUERY );
             ApiCellRangeList aPrintRanges;
-            getFormulaParser().extractCellRangeList( aPrintRanges, xTokens->getTokens(), false, mnCalcSheet );
+            //~ getFormulaParser().extractCellRangeList( aPrintRanges, xTokens->getTokens(), false, mnCalcSheet );
+            getFormulaParser().extractCellRangeList( aPrintRanges, aFTokenSeq, false, mnCalcSheet );
             if( xPrintAreas.is() && !aPrintRanges.empty() )
                 xPrintAreas->setPrintAreas( ContainerHelper::vectorToSequence( aPrintRanges ) );
         }
@@ -457,7 +463,8 @@ void DefinedName::convertFormula()
         {
             Reference< XPrintAreas > xPrintAreas( getSheetFromDoc( mnCalcSheet ), UNO_QUERY );
             ApiCellRangeList aTitleRanges;
-            getFormulaParser().extractCellRangeList( aTitleRanges, xTokens->getTokens(), false, mnCalcSheet );
+            //~ getFormulaParser().extractCellRangeList( aTitleRanges, xTokens->getTokens(), false, mnCalcSheet );
+            getFormulaParser().extractCellRangeList( aTitleRanges, aFTokenSeq, false, mnCalcSheet );
             if( xPrintAreas.is() && !aTitleRanges.empty() )
             {
                 bool bHasRowTitles = false;
@@ -486,12 +493,19 @@ void DefinedName::convertFormula()
     }
 }
 
+//~ bool DefinedName::getAbsoluteRange( CellRangeAddress& orRange ) const
+//~ {
+    //~ /*  ScNamedRangeObj::XCellRangeReferrer::getReferredCells is buggy with
+        //~ relative references, so we extract an absolute reference by hand. */
+    //~ Reference< XFormulaTokens > xTokens( mxNamedRange, UNO_QUERY );
+    //~ return xTokens.is() && getFormulaParser().extractCellRange( orRange, xTokens->getTokens(), false );
+//~ }
 bool DefinedName::getAbsoluteRange( CellRangeAddress& orRange ) const
 {
-    /*  ScNamedRangeObj::XCellRangeReferrer::getReferredCells is buggy with
-        relative references, so we extract an absolute reference by hand. */
-    Reference< XFormulaTokens > xTokens( mxNamedRange, UNO_QUERY );
-    return xTokens.is() && getFormulaParser().extractCellRange( orRange, xTokens->getTokens(), false );
+    ScTokenArray* pTokenArray = mpScRangeData->getCode();
+    Sequence< FormulaToken > = aFTokenSeq;
+    ScTokenConversion::ConvertToTokenSequence( this->getScDocument(), aFTokenSeq, *pTokenArray );
+    return getFormulaParser().extractCellRange( orRange, aFTokenSeq, false );
 }
 
 // ============================================================================
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 6043c5d..3dbc478 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -166,10 +166,10 @@ public:
     Reference< XStyle > getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
     /** Creates and returns a defined name on-the-fly in the Calc document. */
     //~ Reference< XNamedRange > createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const;
-    ScRangeData createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const;
+    ScRangeData* createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const;
     /** Creates and returns a defined name on the-fly in the correct Calc sheet. */
     //~ Reference< XNamedRange > createLocalNamedRangeObject( OUString& orName, const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const;
-    ScRangeData createLocalNamedRangeObject( OUString& orName, Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const;
+    ScRangeData* createLocalNamedRangeObject( OUString& orName, Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const;
     /** Creates and returns a database range on-the-fly in the Calc document. */
     Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ) const;
     /** Creates and returns an unnamed database range on-the-fly in the Calc document. */
@@ -381,7 +381,7 @@ void lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUS
 }
 
 //~ Reference< XNamedRange > WorkbookGlobals::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
-ScRangeData WorkbookGlobals::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
+ScRangeData* WorkbookGlobals::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
 {
     // create the name and insert it into the Calc document
     Reference< XNamedRange > xNamedRange;
@@ -407,7 +407,7 @@ ScRangeData WorkbookGlobals::createNamedRangeObject( OUString& orName, const Seq
 }
 
 //~ Reference< XNamedRange > WorkbookGlobals::createLocalNamedRangeObject( OUString& orName, const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>&  rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
-ScRangeData WorkbookGlobals::createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>&  rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
+ScRangeData* WorkbookGlobals::createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>&  rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
 {
     // create the name and insert it into the Calc document
     Reference< XNamedRange > xNamedRange;
@@ -750,13 +750,13 @@ Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& rStyleName,
 }
 
 //~ Reference< XNamedRange > WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
-ScRangeData WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
+ScRangeData* WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
 {
     return mrBookGlob.createNamedRangeObject( orName, rTokens, nIndex, nNameFlags );
 }
 
 //~ Reference< XNamedRange > WorkbookHelper::createLocalNamedRangeObject( OUString& orName, const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
-ScRangeData WorkbookHelper::createLocalNamedRangeObject( OUString& orName, Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
+ScRangeData* WorkbookHelper::createLocalNamedRangeObject( OUString& orName, Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
 {
     return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab );
 }
-- 
1.7.1


--------------030003000301040704050906
Content-Type: text/x-patch;
 name="0004-Made-correction-to-defnamesbuffer.cxx-core.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0004-Made-correction-to-defnamesbuffer.cxx-core.patch"



More information about the LibreOffice mailing list