[Libreoffice-commits] .: 4 commits - sc/inc sc/Module_sc.mk sc/qa sc/source test/inc test/Library_subsequenttest.mk test/Package_inc.mk test/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Tue Apr 17 12:02:25 PDT 2012


 sc/Module_sc.mk                               |    1 
 sc/inc/tokenuno.hxx                           |    2 
 sc/qa/extras/sctablesheetobj.cxx              |    6 ++
 sc/qa/unit/data/contentCSV/shared-formula.csv |    9 +++
 sc/qa/unit/data/xlsx/shared-formula.xlsx      |binary
 sc/qa/unit/subsequent_filters-test.cxx        |   32 +++++++++++++
 sc/source/filter/inc/defnamesbuffer.hxx       |    4 -
 sc/source/filter/inc/sheetdatabuffer.hxx      |    1 
 sc/source/filter/inc/workbookhelper.hxx       |    7 +-
 sc/source/filter/oox/defnamesbuffer.cxx       |   24 +++++-----
 sc/source/filter/oox/sheetdatabuffer.cxx      |   10 +---
 sc/source/filter/oox/workbookhelper.cxx       |   29 +++++-------
 test/Library_subsequenttest.mk                |    1 
 test/Package_inc.mk                           |    1 
 test/inc/test/sheet/xprintareas.hxx           |   59 +++++++++++++++++++++++++
 test/source/sheet/xprintareas.cxx             |   61 ++++++++++++++++++++++++++
 16 files changed, 206 insertions(+), 41 deletions(-)

New commits:
commit 32bd4c6c4b2ff3835cfb7af50e88be6004dd7852
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Apr 17 20:58:05 2012 +0200

    enable sctablesheetobj again

diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 8f51646..b6a42e1 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -61,6 +61,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
     CppunitTest_sc_macros_test \
     CppunitTest_sc_namedrangeobj \
     CppunitTest_sc_namedrangesobj \
+    CppunitTest_sc_tablesheetobj \
     CppunitTest_sc_tablesheetsobj \
 ))
 
commit a48195f4c24cd20a79514b608a1eae40baff9ed1
Author: Artur Dorda <artur.dorda+libo at gmail.com>
Date:   Sun Apr 15 02:20:16 2012 +0200

    transferring java XPrintAreas to c++

diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx
index 0f1d79a..28b4d2b 100644
--- a/sc/qa/extras/sctablesheetobj.cxx
+++ b/sc/qa/extras/sctablesheetobj.cxx
@@ -29,6 +29,7 @@
 #include <test/unoapi_test.hxx>
 #include <test/util/xreplaceable.hxx>
 #include <test/util/xsearchable.hxx>
+#include <test/sheet/xprintareas.hxx>
 
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
 #include <com/sun/star/sheet/XSpreadsheet.hpp>
@@ -36,7 +37,7 @@
 namespace sc_apitest
 {
 
-class ScTableSheetObj : public UnoApiTest, apitest::XSearchable, apitest::XReplaceable
+class ScTableSheetObj : public UnoApiTest, apitest::XSearchable, apitest::XReplaceable, apitest::XPrintAreas
 {
 public:
     ScTableSheetObj();
@@ -49,6 +50,9 @@ public:
     CPPUNIT_TEST(testFindFirst);
     CPPUNIT_TEST(testReplaceAll);
     CPPUNIT_TEST(testCreateReplaceDescriptor);
+    // XPrintAreas
+    CPPUNIT_TEST(testSetAndGetPrintTitleColumns);
+    CPPUNIT_TEST(testSetAndGetPrintTitleRows);
     CPPUNIT_TEST_SUITE_END();
 
 private:
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 070c6d1..7d865f8 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -79,6 +79,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
     test/source/sheet/xdatapilottable2 \
     test/source/sheet/xnamedrange \
     test/source/sheet/xnamedranges \
+    test/source/sheet/xprintareas \
     test/source/sheet/xspreadsheetdocument \
     test/source/sheet/xspreadsheets2 \
     test/source/util/xreplaceable \
diff --git a/test/Package_inc.mk b/test/Package_inc.mk
index 62c3fa4..160d7b0 100644
--- a/test/Package_inc.mk
+++ b/test/Package_inc.mk
@@ -46,6 +46,7 @@ $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilottable.hxx,te
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilottable2.hxx,test/sheet/xdatapilottable2.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilotfieldgrouping.hxx,test/sheet/xdatapilotfieldgrouping.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/datapilotfield.hxx,test/sheet/datapilotfield.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xprintareas.hxx,test/sheet/xprintareas.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xspreadsheetdocument.hxx,test/sheet/xspreadsheetdocument.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xspreadsheets2.hxx,test/sheet/xspreadsheets2.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/util/xreplaceable.hxx,test/util/xreplaceable.hxx))
diff --git a/test/inc/test/sheet/xprintareas.hxx b/test/inc/test/sheet/xprintareas.hxx
new file mode 100644
index 0000000..08f5348
--- /dev/null
+++ b/test/inc/test/sheet/xprintareas.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Artur Dorda <artur.dorda+libo at gmail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+ #include <com/sun/star/sheet/XPrintAreas.hpp>
+ #include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XPrintAreas
+{
+public:
+    virtual uno::Reference< uno::XInterface > init() = 0;
+
+    void testSetAndGetPrintTitleColumns();   //getter and setter in one test case
+    void testSetAndGetPrintTitleRows();
+
+    void testGetPrintAreas();           // returns a sequence containing all print areas of the sheet.
+    void testSetPrintAreas();           // sets the print areas of the sheet.
+    void testGetTitleColumns();         // returns the range that is specified as title columns range.
+    void testSetTitleColumns();         // specifies a range of columns as title columns range.
+    void testGetTitleRows();            // returns the range that is specified as title rows range.
+    void testSetTitleRows();            // specifies a range of rows as title rows range.
+
+protected:
+    ~XPrintAreas() {}
+
+
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xprintareas.cxx b/test/source/sheet/xprintareas.cxx
new file mode 100644
index 0000000..407aed9
--- /dev/null
+++ b/test/source/sheet/xprintareas.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Artur Dorda <artur.dorda+libo at gmail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xprintareas.hxx>
+#include <com/sun/star/sheet/XPrintAreas.hpp>
+
+#include "cppunit/extensions/HelperMacros.h"
+#include <rtl/oustringostreaminserter.hxx>
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+    void XPrintAreas::testSetAndGetPrintTitleColumns()
+    {
+        uno::Reference< sheet::XPrintAreas > xPrintAreas(init(), UNO_QUERY_THROW);
+        sal_Bool testState = true;
+        xPrintAreas->setPrintTitleColumns(testState);
+
+        CPPUNIT_ASSERT_MESSAGE("Wrong attribution at PrintTitleColumns", xPrintAreas->getPrintTitleColumns() == testState);
+
+    }
+
+    void XPrintAreas::testSetAndGetPrintTitleRows()
+    {
+        uno::Reference< sheet::XPrintAreas > xPrintAreas(init(), UNO_QUERY_THROW);
+        sal_Bool testState = true;
+        xPrintAreas->setPrintTitleRows(testState);
+
+        CPPUNIT_ASSERT_MESSAGE("Wrong attribution at PrintTitleRows", xPrintAreas->getPrintTitleRows() == testState);
+    }
+
+    // the rest is right now in progress...
+
+
+}
commit 738ff483a5f5627aa482ec944c66f8ebcf201b39
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Apr 17 20:42:27 2012 +0200

    add a simple test case for shared formula import
    
    Thanks to Kohei for the test document
    
    Please only change this file with Excel and check after changing it that
    it still contains shared formulas in all places.

diff --git a/sc/qa/unit/data/contentCSV/shared-formula.csv b/sc/qa/unit/data/contentCSV/shared-formula.csv
new file mode 100644
index 0000000..0719398
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/shared-formula.csv
@@ -0,0 +1,9 @@
+1
+2
+3
+4
+5
+6
+7
+8
+9
diff --git a/sc/qa/unit/data/xlsx/shared-formula.xlsx b/sc/qa/unit/data/xlsx/shared-formula.xlsx
new file mode 100644
index 0000000..d1b4f52
Binary files /dev/null and b/sc/qa/unit/data/xlsx/shared-formula.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index f7d5d2b..8476b85 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -118,6 +118,9 @@ public:
     void testBugFixesXLSX();
     void testBrokenQuotesCSV();
 
+    //change this test file only in excel and not in calc
+    void testSharedFormulaXLSX();
+
     //misc tests unrelated to the import filters
     void testPasswordNew();
     void testPasswordOld();
@@ -142,6 +145,8 @@ public:
 #if 0
     CPPUNIT_TEST(testBrokenQuotesCSV);
 #endif
+    CPPUNIT_TEST(testSharedFormulaXLSX);
+
     //disable testPassword on MacOSX due to problems with libsqlite3
     //also crashes on DragonFly due to problems with nss/nspr headers
 #if !defined(MACOSX) && !defined(DRAGONFLY) && !defined(WNT)
@@ -667,6 +672,33 @@ void ScFiltersTest::testBrokenQuotesCSV()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testSharedFormulaXLSX()
+{
+    const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("shared-formula."));
+    rtl::OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 );
+    rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ;
+    rtl::OUString aFileName;
+    createFileURL(aFileNameBase, aFileExtension, aFileName);
+    rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8);
+    std::cout << aFileFormats[XLSX].pName << " Test" << std::endl;
+    ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[XLSX].nFormatType);
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load shared-formula.xlsx", xDocSh.Is());
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test
+
+    rtl::OUString aCSVPath;
+    createCSVPath( aFileNameBase, aCSVPath );
+    testFile( aCSVPath, pDoc, 0 );
+
+    //test some additional properties
+    ScRangeName* pName = pDoc->GetRangeName();
+    for (ScRangeName::iterator itr = pName->begin(); itr != pName->end(); ++itr)
+    {
+        CPPUNIT_ASSERT(itr->second->GetType() & RT_SHARED);
+    }
+}
+
 void ScFiltersTest::testPassword_Impl(const rtl::OUString& aFileNameBase)
 {
     rtl::OUString aFileExtension(aFileFormats[0].pName, strlen(aFileFormats[0].pName), RTL_TEXTENCODING_UTF8 );
commit f892be678a036cd0fea665eda529e9cc906e0cfa
Author: Daniel Bankston <daniel.dev.libreoffice at gmail.com>
Date:   Mon Apr 16 09:34:32 2012 -0500

    Converting UNO calls to direct in WorkbookHelper

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 );
diff --git a/sc/source/filter/inc/defnamesbuffer.hxx b/sc/source/filter/inc/defnamesbuffer.hxx
index 61803b1..d3269a4 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; }
@@ -155,8 +156,7 @@ 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.
+    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..65612bc 100644
--- a/sc/source/filter/inc/sheetdatabuffer.hxx
+++ b/sc/source/filter/inc/sheetdatabuffer.hxx
@@ -35,7 +35,6 @@
 #include "worksheethelper.hxx"
 
 namespace com { namespace sun { namespace star {
-    namespace sheet { class XNamedRange; }
     namespace util { struct DateTime; }
 } } }
 
diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx
index 7a52984..c4a4ee1 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; }
@@ -183,8 +184,7 @@ 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(
+    ScRangeData* createNamedRangeObject(
                             ::rtl::OUString& orName,
                             const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens,
                             sal_Int32 nIndex,
@@ -193,8 +193,7 @@ 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(
+    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 8d04f7a..4eafab7 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 {
@@ -380,9 +382,9 @@ 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 );
+        mpScRangeData = createLocalNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags, maModel.mnSheet );
     else
-        mxNamedRange = createNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags );
+        mpScRangeData = createNamedRangeObject( maCalcName, getTokens(), nIndex, nNameFlags );
     mnTokenIndex = nIndex;
 }
 
@@ -424,9 +426,9 @@ DefinedName::getTokens()
 
 void DefinedName::convertFormula()
 {
-    Reference< XFormulaTokens > xTokens( mxNamedRange, UNO_QUERY );
-    if( !xTokens.is() )
-        return;
+    ScTokenArray* pTokenArray = mpScRangeData->GetCode();
+    Sequence< FormulaToken > aFTokenSeq;
+    (void)ScTokenConversion::ConvertToTokenSequence( this->getScDocument(), aFTokenSeq, *pTokenArray );
     // set built-in names (print ranges, repeated titles, filter ranges)
     if( !isGlobalName() ) switch( mcBuiltinId )
     {
@@ -434,7 +436,7 @@ void DefinedName::convertFormula()
         {
             Reference< XPrintAreas > xPrintAreas( getSheetFromDoc( mnCalcSheet ), UNO_QUERY );
             ApiCellRangeList aPrintRanges;
-            getFormulaParser().extractCellRangeList( aPrintRanges, xTokens->getTokens(), false, mnCalcSheet );
+            getFormulaParser().extractCellRangeList( aPrintRanges, aFTokenSeq, false, mnCalcSheet );
             if( xPrintAreas.is() && !aPrintRanges.empty() )
                 xPrintAreas->setPrintAreas( ContainerHelper::vectorToSequence( aPrintRanges ) );
         }
@@ -443,7 +445,7 @@ void DefinedName::convertFormula()
         {
             Reference< XPrintAreas > xPrintAreas( getSheetFromDoc( mnCalcSheet ), UNO_QUERY );
             ApiCellRangeList aTitleRanges;
-            getFormulaParser().extractCellRangeList( aTitleRanges, xTokens->getTokens(), false, mnCalcSheet );
+            getFormulaParser().extractCellRangeList( aTitleRanges, aFTokenSeq, false, mnCalcSheet );
             if( xPrintAreas.is() && !aTitleRanges.empty() )
             {
                 bool bHasRowTitles = false;
@@ -474,10 +476,10 @@ 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 );
+    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..245b167 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -588,15 +588,13 @@ 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 );
+    ScRangeData* pScRangeData = createNamedRangeObject( aName, rTokens, 0 );
+    pScRangeData->SetType(RT_SHARED);
 
     // 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 = 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 5a872c2..479f504 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -165,9 +165,9 @@ 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;
+    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, 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. */
@@ -358,7 +358,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;
@@ -376,12 +376,14 @@ 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
+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;
+    ScRangeData* pScRangeData;
     if( !orName.isEmpty() ) try
     {
         // find an unused name
@@ -392,20 +394,19 @@ Reference< XNamedRange > WorkbookGlobals::createNamedRangeObject( OUString& orNa
         // create the named range
         ScDocument& rDoc =  getScDocument();
         ScRangeName* pNames = rDoc.GetRangeName();
-        lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
-        xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY );
+        pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
     }
     catch( Exception& )
     {
     }
-    OSL_ENSURE( xNamedRange.is(), "WorkbookGlobals::createNamedRangeObject - cannot create defined name" );
-    return xNamedRange;
+    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
 {
     // create the name and insert it into the Calc document
     Reference< XNamedRange > xNamedRange;
+    ScRangeData* pScRangeData;
     if( !orName.isEmpty() ) try
     {
         // find an unused name
@@ -420,14 +421,12 @@ Reference< XNamedRange > WorkbookGlobals::createLocalNamedRangeObject( OUString&
         // create the named range
         ScDocument& rDoc =  getScDocument();
         ScRangeName* pNames = rDoc.GetRangeName( nTab );
-        lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
-        xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY );
+        pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
     }
     catch( Exception& )
     {
     }
-    OSL_ENSURE( xNamedRange.is(), "WorkbookGlobals::createLocalNamedRangeObject - cannot create defined name" );
-    return xNamedRange;
+    return pScRangeData;
 }
 
 Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ) const
@@ -743,12 +742,12 @@ 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
+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, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
 {
     return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab );
 }


More information about the Libreoffice-commits mailing list