Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hello, everyone,

I have attached my patches for EasyHack 48140. I have taken baby steps, so this just the first part of completing EasyHack 48140. I changed WorkbookHelper::createNamedRangeObject and createLocalNamedRangeObject to return ScRangeData* instead of Reference<XNamedRanged>, and then I adjusted all callers. You will notice I commented the old code out instead of deleting it. I did this as this is just partial update for the EasyHack.

I was able to successfully make sc with these changes. "make -sr slowcheck" was also successful. My own manual tests were also successful. I tested by running calc and opening xlsx spreadsheets containing ranges with names. I also created names for ranges and created names for cells in those spreadsheets. I referred to those ranges and cells by name in other cells.

Although my tests were successful, I still fear that there is something that I may have missed due to my current beginner level of understanding of the sc model. I am eager to see what suggestions you all may have.

When I have more time, I later plan to make similar changes to the database ranges and eventually remove all UNO calls in these methods where possible. (School semester is still in for me and quite busy as it nears the end.)


Respectfully,

Daniel Bankston
From d781c5735dc2bdb50d95301897c11d56c47b969e Mon Sep 17 00:00:00 2001
From: Daniel Bankston <daniel.dev.libreoffice@gmail.com>
Date: Fri, 6 Apr 2012 10:18:44 -0500
Subject: [PATCH 1/7] Changing return types from Reference< XNamedRange > to ScRangeData

---
 sc/source/filter/inc/workbookhelper.hxx |   18 ++++++++++++++----
 sc/source/filter/oox/workbookhelper.cxx |   20 ++++++++++++--------
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx
index 7a52984..5e94b55 100644
--- a/sc/source/filter/inc/workbookhelper.hxx
+++ b/sc/source/filter/inc/workbookhelper.hxx
@@ -183,8 +183,13 @@ public:
     /** Creates and returns a defined name on-the-fly in the Calc document.
         The name will not be buffered in the global defined names buffer.
         @param orName  (in/out-parameter) Returns the resulting used name. */
-    ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange >
-                        createNamedRangeObject(
+    //~ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange >
+                        //~ createNamedRangeObject(
+                            //~ ::rtl::OUString& orName,
+                            //~ const ::com::sun::star::uno::Sequence< 
::com::sun::star::sheet::FormulaToken>& rTokens,
+                            //~ sal_Int32 nIndex,
+                            //~ sal_Int32 nNameFlags = 0 ) const;
+    ScRangeData createNamedRangeObject(
                             ::rtl::OUString& orName,
                             const ::com::sun::star::uno::Sequence< 
::com::sun::star::sheet::FormulaToken>& rTokens,
                             sal_Int32 nIndex,
@@ -193,8 +198,13 @@ public:
     /** Creates and returns a defined name on-the-fly in the sheet.
         The name will not be buffered in the global defined names buffer.
         @param orName  (in/out-parameter) Returns the resulting used name. */
-    ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange >
-                        createLocalNamedRangeObject(
+    //~ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange >
+                        //~ createLocalNamedRangeObject(
+                            //~ ::rtl::OUString& orName,
+                            //~ 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(
                             ::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/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 5a872c2..eae64ad 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -378,7 +378,8 @@ void lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUS
         throw RuntimeException();
 }
 
-Reference< XNamedRange > WorkbookGlobals::createNamedRangeObject( OUString& orName, const 
Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
+//~ 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
 {
     // create the name and insert it into the Calc document
     Reference< XNamedRange > xNamedRange;
@@ -393,16 +394,18 @@ Reference< XNamedRange > WorkbookGlobals::createNamedRangeObject( OUString& 
orNa
         ScDocument& rDoc =  getScDocument();
         ScRangeName* pNames = rDoc.GetRangeName();
         lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
-        xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY );
+        //~ xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY );
     }
     catch( Exception& )
     {
     }
-    OSL_ENSURE( xNamedRange.is(), "WorkbookGlobals::createNamedRangeObject - cannot create defined 
name" );
-    return xNamedRange;
+    //~ OSL_ENSURE( xNamedRange.is(), "WorkbookGlobals::createNamedRangeObject - cannot create 
defined name" );
+    //~ return xNamedRange;
+    return pNames;
 }
 
-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
+//~ 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
 {
     // create the name and insert it into the Calc document
     Reference< XNamedRange > xNamedRange;
@@ -421,13 +424,14 @@ Reference< XNamedRange > WorkbookGlobals::createLocalNamedRangeObject( 
OUString&
         ScDocument& rDoc =  getScDocument();
         ScRangeName* pNames = rDoc.GetRangeName( nTab );
         lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
-        xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY );
+        //~ xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY );
     }
     catch( Exception& )
     {
     }
-    OSL_ENSURE( xNamedRange.is(), "WorkbookGlobals::createLocalNamedRangeObject - cannot create 
defined name" );
-    return xNamedRange;
+    //~ OSL_ENSURE( xNamedRange.is(), "WorkbookGlobals::createLocalNamedRangeObject - cannot 
create defined name" );
+    //~ return xNamedRange;
+    return pNames;
 }
 
 Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const 
CellRangeAddress& rRangeAddr ) const
-- 
1.7.1

From 9998615daf5a5bdd407f8d1fe8a6ae449265c6fb Mon Sep 17 00:00:00 2001
From: Daniel Bankston <daniel.dev.libreoffice@gmail.com>
Date: Fri, 6 Apr 2012 11:00:10 -0500
Subject: [PATCH 2/7] More return type changes.

---
 sc/source/filter/inc/workbookhelper.hxx |    1 +
 sc/source/filter/oox/workbookhelper.cxx |   12 ++++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx
index 5e94b55..44f045a 100644
--- a/sc/source/filter/inc/workbookhelper.hxx
+++ b/sc/source/filter/inc/workbookhelper.hxx
@@ -33,6 +33,7 @@
 #include <rtl/ref.hxx>
 #include "oox/helper/storagebase.hxx"
 #include "biffhelper.hxx"
+#include "rangenam.hxx"
 
 namespace com { namespace sun { namespace star {
     namespace container { class XNameAccess; }
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index eae64ad..6043c5d 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -165,9 +165,11 @@ public:
     /** Returns the specified cell or page style from the Calc document. */
     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;
+    //~ 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;
     /** 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;
+    //~ 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;
     /** 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. */
@@ -747,12 +749,14 @@ Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& 
rStyleName,
     return mrBookGlob.getStyleObject( rStyleName, bPageStyle );
 }
 
-Reference< XNamedRange > WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< 
FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
+//~ 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
 {
     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
+//~ 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
 {
     return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab );
 }
-- 
1.7.1

From 7aef64826d3ff0ad9c4276ea1ba4145b8f850693 Mon Sep 17 00:00:00 2001
From: Daniel Bankston <daniel.dev.libreoffice@gmail.com>
Date: Wed, 11 Apr 2012 12:55:37 -0500
Subject: [PATCH 3/7] Converted calls in defnamesbuffer.hxx and .cxx

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

From 38508cdb27738c31c9e5bacb5714d306e5c8e596 Mon Sep 17 00:00:00 2001
From: Daniel Bankston <daniel.dev.libreoffice@gmail.com>
Date: Wed, 11 Apr 2012 13:15:05 -0500
Subject: [PATCH 4/7] Made correction to defnamesbuffer.cxx.

---
 sc/source/filter/oox/defnamesbuffer.cxx |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx
index ce309b6..f6955f5 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -398,7 +398,7 @@ void DefinedName::createNameObject( sal_Int32 nIndex )
         mpScRangeData = createLocalNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags, 
maModel.mnSheet );
     else
         //~ mxNamedRange = createNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags );
-        mpScRangeData = createLocalNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags, 
maModel.mnSheet );
+        mpScRangeData = createNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags );
     mnTokenIndex = nIndex;
 }
 
-- 
1.7.1

From f0872f39d41173643c47cd50b13c0e3972616067 Mon Sep 17 00:00:00 2001
From: Daniel Bankston <daniel.dev.libreoffice@gmail.com>
Date: Fri, 13 Apr 2012 19:12:39 -0500
Subject: [PATCH 5/7] Continuing converting.

---
 sc/source/filter/inc/defnamesbuffer.hxx  |    2 +-
 sc/source/filter/inc/sheetdatabuffer.hxx |    2 +-
 sc/source/filter/oox/defnamesbuffer.cxx  |   13 ++++++++-----
 sc/source/filter/oox/sheetdatabuffer.cxx |   15 +++++++++------
 sc/source/filter/oox/workbookhelper.cxx  |   19 +++++++++++--------
 5 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/sc/source/filter/inc/defnamesbuffer.hxx b/sc/source/filter/inc/defnamesbuffer.hxx
index 654206c..398380f 100644
--- a/sc/source/filter/inc/defnamesbuffer.hxx
+++ b/sc/source/filter/inc/defnamesbuffer.hxx
@@ -161,7 +161,7 @@ private:
 
     //~ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange >
                         //~ mxNamedRange;       /// XNamedRange interface of the defined name.
-    ScRangeData*        mpScRangeData       /// ScRangeData 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/sheetdatabuffer.hxx b/sc/source/filter/inc/sheetdatabuffer.hxx
index dcf42bc..8efaa43 100644
--- a/sc/source/filter/inc/sheetdatabuffer.hxx
+++ b/sc/source/filter/inc/sheetdatabuffer.hxx
@@ -35,7 +35,7 @@
 #include "worksheethelper.hxx"
 
 namespace com { namespace sun { namespace star {
-    namespace sheet { class XNamedRange; }
+    //~ namespace sheet { class XNamedRange; }
     namespace util { struct DateTime; }
 } } }
 
diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx
index f6955f5..ff8310e 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -44,6 +44,8 @@
 #include "externallinkbuffer.hxx"
 #include "formulaparser.hxx"
 #include "worksheetbuffer.hxx"
+#include "tokenarray.hxx"
+#include "tokenuno.hxx"
 
 namespace oox {
 namespace xls {
@@ -443,9 +445,10 @@ void DefinedName::convertFormula()
     //~ Reference< XFormulaTokens > xTokens( mxNamedRange, UNO_QUERY );
     //~ if( !xTokens.is() )
         //~ return;
-    ScTokenArray* pTokenArray = mpScRangeData->getCode();
-    Sequence< FormulaToken > = aFTokenSeq;
-    ScTokenConversion::ConvertToTokenSequence( this->getScDocument(), aFTokenSeq, *pTokenArray );
+    const ScTokenArray* pTokenArray = mpScRangeData->GetCode();
+    Sequence< FormulaToken > aFTokenSeq;
+    ScDocument* pDocTest = &this->getScDocument();
+    (void)ScTokenConversion::ConvertToTokenSequence( *pDocTest, aFTokenSeq, *pTokenArray );
     // set built-in names (print ranges, repeated titles, filter ranges)
     if( !isGlobalName() ) switch( mcBuiltinId )
     {
@@ -502,8 +505,8 @@ void DefinedName::convertFormula()
 //~ }
 bool DefinedName::getAbsoluteRange( CellRangeAddress& orRange ) const
 {
-    ScTokenArray* pTokenArray = mpScRangeData->getCode();
-    Sequence< FormulaToken > = aFTokenSeq;
+    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/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 4abf946..29d6dfe 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -588,15 +588,18 @@ void SheetDataBuffer::createSharedFormula( const BinAddress& rMapKey, const 
ApiT
         append( static_cast< sal_Int32 >( getSheetIndex() + 1 ) ).
         append( sal_Unicode( '_' ) ).append( rMapKey.mnRow ).
         append( sal_Unicode( '_' ) ).append( rMapKey.mnCol ).makeStringAndClear();
-    Reference< XNamedRange > xNamedRange = createNamedRangeObject( aName, rTokens, 0 );
-    OSL_ENSURE( xNamedRange.is(), "SheetDataBuffer::createSharedFormula - cannot create shared 
formula" );
-    PropertySet aNameProps( xNamedRange );
-    aNameProps.setProperty( PROP_IsSharedFormula, true );
+    //~ Reference< XNamedRange > xNamedRange = createNamedRangeObject( aName, rTokens, 0 );
+    //~ OSL_ENSURE( xNamedRange.is(), "SheetDataBuffer::createSharedFormula - cannot create shared 
formula" );
+    ScRangeData* pScRangeData = createNamedRangeObject( aName, rTokens, 0 );
+    //~ PropertySet aNameProps( xNamedRange );
+    //~ aNameProps.setProperty( PROP_IsSharedFormula, true );
 
     // get and store the token index of the defined name
     OSL_ENSURE( maSharedFormulas.count( rMapKey ) == 0, "SheetDataBuffer::createSharedFormula - 
shared formula exists already" );
-    sal_Int32 nTokenIndex = 0;
-    if( aNameProps.getProperty( nTokenIndex, PROP_TokenIndex ) && (nTokenIndex >= 0) ) try
+    //~ sal_Int32 nTokenIndex = 0;
+    //~ if( aNameProps.getProperty( nTokenIndex, PROP_TokenIndex ) && (nTokenIndex >= 0) ) try
+    sal_Int32 nTokenIndex = static_cast< sal_Int32 >( pScRangeData->GetIndex() );
+    if( nTokenIndex >= 0 ) try
     {
         // store the token index in the map
         maSharedFormulas[ rMapKey ] = nTokenIndex;
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 3dbc478..1d46c52 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -169,7 +169,7 @@ public:
     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, const 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. */
@@ -360,7 +360,7 @@ Reference< XStyle > WorkbookGlobals::getStyleObject( const OUString& rStyleName,
     OSL_ENSURE( xStyle.is(), "WorkbookGlobals::getStyleObject - cannot access style object" );
     return xStyle;
 }
-void lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUString& rName, 
const Sequence<FormulaToken>& rTokens, sal_Int16 nIndex, sal_Int32 nUnoType )
+ScRangeData* lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUString& 
rName, const Sequence<FormulaToken>& rTokens, sal_Int16 nIndex, sal_Int32 nUnoType )
 {
     bool bDone = false;
     sal_uInt16 nNewType = RT_NAME;
@@ -378,6 +378,7 @@ void lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUS
         bDone = true;
     if (!bDone)
         throw RuntimeException();
+    return pNew;
 }
 
 //~ Reference< XNamedRange > WorkbookGlobals::createNamedRangeObject( OUString& orName, const 
Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
@@ -385,6 +386,7 @@ ScRangeData* WorkbookGlobals::createNamedRangeObject( OUString& orName, const Se
 {
     // create the name and insert it into the Calc document
     Reference< XNamedRange > xNamedRange;
+    ScRangeData* pScRangeData;
     if( !orName.isEmpty() ) try
     {
         // find an unused name
@@ -395,7 +397,7 @@ ScRangeData* WorkbookGlobals::createNamedRangeObject( OUString& orName, const Se
         // create the named range
         ScDocument& rDoc =  getScDocument();
         ScRangeName* pNames = rDoc.GetRangeName();
-        lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
+        pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, 
nNameFlags );
         //~ xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY );
     }
     catch( Exception& )
@@ -403,14 +405,15 @@ ScRangeData* WorkbookGlobals::createNamedRangeObject( OUString& orName, const 
Se
     }
     //~ OSL_ENSURE( xNamedRange.is(), "WorkbookGlobals::createNamedRangeObject - cannot create 
defined name" );
     //~ return xNamedRange;
-    return pNames;
+    return pScRangeData;
 }
 
 //~ 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;
+    ScRangeData* pScRangeData;
     if( !orName.isEmpty() ) try
     {
         // find an unused name
@@ -425,7 +428,7 @@ ScRangeData* WorkbookGlobals::createLocalNamedRangeObject( OUString& orName, con
         // create the named range
         ScDocument& rDoc =  getScDocument();
         ScRangeName* pNames = rDoc.GetRangeName( nTab );
-        lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
+        pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, 
nNameFlags );
         //~ xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY );
     }
     catch( Exception& )
@@ -433,7 +436,7 @@ ScRangeData* WorkbookGlobals::createLocalNamedRangeObject( OUString& orName, con
     }
     //~ OSL_ENSURE( xNamedRange.is(), "WorkbookGlobals::createLocalNamedRangeObject - cannot 
create defined name" );
     //~ return xNamedRange;
-    return pNames;
+    return pScRangeData;
 }
 
 Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const 
CellRangeAddress& rRangeAddr ) const
@@ -756,7 +759,7 @@ ScRangeData* WorkbookHelper::createNamedRangeObject( OUString& orName, const Seq
 }
 
 //~ 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, const Sequence< 
FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
 {
     return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab );
 }
-- 
1.7.1

From 8150d5e936eee259f40899ee7907138255699af3 Mon Sep 17 00:00:00 2001
From: Daniel Bankston <daniel.dev.libreoffice@gmail.com>
Date: Fri, 13 Apr 2012 19:46:22 -0500
Subject: [PATCH 6/7] can't build

---
 sc/source/filter/oox/defnamesbuffer.cxx |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx
index ff8310e..9cdb96e 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -445,10 +445,9 @@ void DefinedName::convertFormula()
     //~ Reference< XFormulaTokens > xTokens( mxNamedRange, UNO_QUERY );
     //~ if( !xTokens.is() )
         //~ return;
-    const ScTokenArray* pTokenArray = mpScRangeData->GetCode();
+    ScTokenArray* pTokenArray = mpScRangeData->GetCode();
     Sequence< FormulaToken > aFTokenSeq;
-    ScDocument* pDocTest = &this->getScDocument();
-    (void)ScTokenConversion::ConvertToTokenSequence( *pDocTest, aFTokenSeq, *pTokenArray );
+    (void)ScTokenConversion::ConvertToTokenSequence( this->getScDocument(), aFTokenSeq, 
*pTokenArray );
     // set built-in names (print ranges, repeated titles, filter ranges)
     if( !isGlobalName() ) switch( mcBuiltinId )
     {
-- 
1.7.1

From 1a7f6e2ae10f16a44e303e18277339acfafcf402 Mon Sep 17 00:00:00 2001
From: Daniel Bankston <daniel.dev.libreoffice@gmail.com>
Date: Sat, 14 Apr 2012 21:42:57 -0500
Subject: [PATCH 7/7] Added SC_DLLPUBLIC to ScTokenConversion::ConvertToTokenSequence

---
 sc/inc/tokenuno.hxx |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sc/inc/tokenuno.hxx b/sc/inc/tokenuno.hxx
index 36486c4..a3d8732 100644
--- a/sc/inc/tokenuno.hxx
+++ b/sc/inc/tokenuno.hxx
@@ -53,7 +53,7 @@ public:
                         ScDocument& rDoc,
                         ScTokenArray& rTokenArray,
                         const com::sun::star::uno::Sequence< com::sun::star::sheet::FormulaToken 
& rSequence );
-    static bool ConvertToTokenSequence(
+    static SC_DLLPUBLIC bool ConvertToTokenSequence(
                         ScDocument& rDoc,
                         com::sun::star::uno::Sequence< com::sun::star::sheet::FormulaToken >& 
rSequence,
                         const ScTokenArray& rTokenArray );
-- 
1.7.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.