[Libreoffice-commits] core.git: Branch 'distro/suse/suse-4.0' - 5 commits - oovbaapi/ooo sc/inc sc/qa sc/source

Noel Power noel.power at suse.com
Wed May 15 03:01:12 PDT 2013


 oovbaapi/ooo/vba/excel/XName.idl    |   10 +--
 sc/inc/nameuno.hxx                  |    3 
 sc/qa/extras/macros-test.cxx        |   28 ++++++--
 sc/qa/unit/data/xls/Names.xls       |binary
 sc/qa/unit/data/xls/Workbooks.xls   |binary
 sc/source/ui/vba/vbaapplication.cxx |    2 
 sc/source/ui/vba/vbaname.cxx        |  114 +++++++++++++++---------------------
 sc/source/ui/vba/vbaname.hxx        |    5 -
 sc/source/ui/vba/vbanames.cxx       |  107 ++++++++++++++++++++++++++++-----
 9 files changed, 173 insertions(+), 96 deletions(-)

New commits:
commit e9281c438b8cd8b34e8cbc1dd05c22e374f21fc0
Author: Noel Power <noel.power at suse.com>
Date:   Tue May 14 12:07:43 2013 +0100

    make some vba Name object attributes read/write and add test document
    
    cherry-picked from fbd74ed44cd011ebab95bb4bc4eb6b15c1272c43
    
    Change-Id: Ibd12835cc5368080a302b3b8d7c6f52ccc434e3c

diff --git a/oovbaapi/ooo/vba/excel/XName.idl b/oovbaapi/ooo/vba/excel/XName.idl
index dc6ba1c..d46dc14 100644
--- a/oovbaapi/ooo/vba/excel/XName.idl
+++ b/oovbaapi/ooo/vba/excel/XName.idl
@@ -37,10 +37,10 @@ interface XName
     [attribute] string NameLocal;
     [attribute] boolean Visible;
     [attribute] string Value;
-    [attribute, readonly] string RefersTo;
-    [attribute, readonly] string RefersToLocal;
-    [attribute, readonly] string RefersToR1C1;
-    [attribute, readonly] string RefersToR1C1Local;
+    [attribute] string RefersTo;
+    [attribute] string RefersToLocal;
+    [attribute] string RefersToR1C1;
+    [attribute] string RefersToR1C1Local;
     [attribute, readonly] XRange RefersToRange;
 
     void Delete( );
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index ad1df32..0ee6b9e 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -217,7 +217,10 @@ void ScMacrosTest::testVba()
             OUString("Workbooks."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
-
+        {
+            OUString("Names."),
+            OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
+        },
     };
 
     rtl::OUString aFileExtension("xls");
diff --git a/sc/qa/unit/data/xls/Names.xls b/sc/qa/unit/data/xls/Names.xls
new file mode 100755
index 0000000..fcacf9b
Binary files /dev/null and b/sc/qa/unit/data/xls/Names.xls differ
commit b4f069e21378c03a1306220b953eb1172df1a8bd
Author: Noel Power <noel.power at suse.com>
Date:   Wed May 15 09:50:05 2013 +0100

    fix Workbooks.xls unit test ( was failing on windows )
    
    was cherry-picked from f34c31560bb29f90d579a795cd9f7707163c025f
    
    Change-Id: I3f7bac8d071875a462f9f1a7180b8c6da93c8c70

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 0d792b1..ad1df32 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -225,12 +225,9 @@ void ScMacrosTest::testVba()
     OUString sTempDirURL;
     osl::FileBase:: getTempDirURL( sTempDirURL );
     osl::FileBase::getSystemPathFromFileURL( sTempDirURL, sTempDir );
+    sTempDir += OUString( SAL_PATHDELIMITER );
+    OUString sTestFileName("My Test WorkBook.xls");
     Sequence< uno::Any > aParams;
-    if ( !sTempDir.isEmpty() )
-    {
-        aParams.realloc(1);
-        aParams[ 0 ] <<= sTempDir;
-    }
     for ( sal_uInt32  i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
     {
         rtl::OUString aFileName;
@@ -245,6 +242,14 @@ void ScMacrosTest::testVba()
         Sequence< sal_Int16 > aOutParamIndex;
         Sequence< Any > aOutParam;
 
+        bool bWorkbooksHandling = OUString( testInfo[i].sFileBaseName ).equalsAscii("Workbooks.") && !sTempDir.isEmpty() ;
+        if ( bWorkbooksHandling )
+        {
+            aParams.realloc(2);
+            aParams[ 0 ] <<= sTempDir;
+            aParams[ 1 ] <<= sTestFileName;
+        }
+
         SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
 
         CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
@@ -256,6 +261,14 @@ void ScMacrosTest::testVba()
         std::cout << "value of Ret " << rtl::OUStringToOString( aStringRes, RTL_TEXTENCODING_UTF8 ).getStr() << std::endl;
         CPPUNIT_ASSERT_MESSAGE( "script reported failure",aStringRes == "OK" );
         pFoundShell->DoClose();
+        if ( bWorkbooksHandling )
+        {
+            OUString sFileUrl;
+            OUString sFilePath = sTempDir + sTestFileName;
+            osl::FileBase::getFileURLFromSystemPath( sFilePath, sFileUrl );
+            if ( !sFileUrl.isEmpty() )
+                osl::File::remove( sFileUrl );
+        }
     }
 }
 
diff --git a/sc/qa/unit/data/xls/Workbooks.xls b/sc/qa/unit/data/xls/Workbooks.xls
index a732167..2e8a7e7 100755
Binary files a/sc/qa/unit/data/xls/Workbooks.xls and b/sc/qa/unit/data/xls/Workbooks.xls differ
commit 999908d66f9960709ab4912177b9adb6b23ab337
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 10 20:09:04 2013 +0100

    try fix build failure ( on some platforms ) uno::makeAny( 1 )
    
    Change-Id: I0107fc919a785195a1247c08ae019ed3f48f7e7d
    (cherry picked from commit 5c20d05f925c9142f023ed910a1205acfc734c65)

diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
index e4f5503..f86b1d8 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -196,7 +196,8 @@ ScVbaNames::Add( const css::uno::Any& Name ,
         if ( !xRange.is() )
             xRange = new ScVbaRange( mxParent, mxContext, xUnoRange );
 
-        uno::Reference< excel::XRange > xArea( xRange->Areas( uno::makeAny( 1 ) ), uno::UNO_QUERY );
+        uno::Reference< excel::XRange > xArea( xRange->Areas( uno::makeAny( sal_Int32(1) ) ), uno::UNO_QUERY );
+
         uno::Any xAny = xArea->getCellRange() ;
 
         uno::Reference< sheet::XCellRangeAddressable > thisRangeAdd( xAny, ::uno::UNO_QUERY_THROW);
commit 07334f694e413eb2f4839dddfa6feb9fa6a908b0
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 10 17:21:54 2013 +0100

    fix various problems with vba Names & Names objects
    
    a) Name.Value attribute was read only
    b) Name.[Get|Set]Value  not working property
    c) Name.ReferToR1C1xxx attributes not returning r1c1 related addresses
    d) Names.Add just not working( should return a reference to the new Name )
    e) Names.Add not handling multi-area addresses, not constructing the Content for the names correctly
    
    cherry-picked from 566f52506e8e160540a3bcd0dc46f93e87e3155a
    
    Change-Id: I6f3c1cf029d5e4003c5900a4e9525f5a0d9a8ed6

diff --git a/oovbaapi/ooo/vba/excel/XName.idl b/oovbaapi/ooo/vba/excel/XName.idl
index 379095b..dc6ba1c 100644
--- a/oovbaapi/ooo/vba/excel/XName.idl
+++ b/oovbaapi/ooo/vba/excel/XName.idl
@@ -36,7 +36,7 @@ interface XName
     [attribute] string Name;
     [attribute] string NameLocal;
     [attribute] boolean Visible;
-    [attribute, readonly] string Value;
+    [attribute] string Value;
     [attribute, readonly] string RefersTo;
     [attribute, readonly] string RefersToLocal;
     [attribute, readonly] string RefersToR1C1;
diff --git a/sc/inc/nameuno.hxx b/sc/inc/nameuno.hxx
index 02cf724..8e8a753 100644
--- a/sc/inc/nameuno.hxx
+++ b/sc/inc/nameuno.hxx
@@ -48,7 +48,7 @@ class ScRangeData;
 class ScTokenArray;
 class ScNamedRangesObj;
 
-class ScNamedRangeObj : public ::cppu::WeakImplHelper6<
+class SC_DLLPUBLIC ScNamedRangeObj : public ::cppu::WeakImplHelper6<
                             ::com::sun::star::sheet::XNamedRange,
                             ::com::sun::star::sheet::XFormulaTokens,
                             ::com::sun::star::sheet::XCellRangeReferrer,
@@ -64,6 +64,7 @@ private:
     com::sun::star::uno::Reference< com::sun::star::container::XNamed > mxSheet;
 
 private:
+friend class ScVbaName;
     ScRangeData*            GetRangeData_Impl();
     void                    Modify_Impl( const String* pNewName,
                                         const ScTokenArray* pNewTokens, const String* pNewContent,
diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx
index f6fc76e..b46b647 100644
--- a/sc/source/ui/vba/vbaname.cxx
+++ b/sc/source/ui/vba/vbaname.cxx
@@ -30,6 +30,9 @@
 #include <vcl/msgbox.hxx>
 #include "tabvwsh.hxx"
 #include "viewdata.hxx"
+#include "nameuno.hxx"
+#include "compiler.hxx"
+#include "tokenarray.hxx"
 
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
@@ -94,81 +97,63 @@ ScVbaName::setVisible( sal_Bool /*bVisible*/ ) throw (css::uno::RuntimeException
 {
 }
 
-::rtl::OUString
-ScVbaName::getValue() throw (css::uno::RuntimeException)
+OUString ScVbaName::getContent( const formula::FormulaGrammar::Grammar eGrammar, bool bPrependEquals )
 {
-    ::rtl::OUString sValue = mxNamedRange->getContent();
-    ::rtl::OUString sSheetName = getWorkSheet()->getName();
-    ::rtl::OUString sSegmentation = ::rtl::OUString::createFromAscii( ";" );
-    ::rtl::OUString sNewSegmentation = ::rtl::OUString::createFromAscii( "," );
-    ::rtl::OUString sResult;
-    sal_Int32 nFrom = 0;
-    sal_Int32 nTo = 0;
-    nTo = sValue.indexOf( sSegmentation, nFrom );
-    while ( nTo != -1 )
-    {
-        ::rtl::OUString sTmpValue = sValue.copy( nFrom, nTo - nFrom );
-        if ( sTmpValue.toChar() == '$' )
-        {
-            ::rtl::OUString sTmp = sTmpValue.copy( 1 );
-            sTmp = sTmp.replaceAt(0, OUString(sSheetName + ::rtl::OUString::createFromAscii(".")).getLength(), sSheetName + ::rtl::OUString::createFromAscii("!"));
-            sResult += sTmp;
-            sResult += sNewSegmentation;
-        }
-        nFrom = nTo + 1;
-        nTo = sValue.indexOf( sSegmentation, nFrom );
-    }
-    ::rtl::OUString sTmpValue = sValue.copy( nFrom );
-    if ( sTmpValue.toChar() == '$' )
+    ScNamedRangeObj* pNamedRange = dynamic_cast< ScNamedRangeObj* >( mxNamedRange.get() );
+    OUString aContent;
+    if ( pNamedRange )
     {
-        ::rtl::OUString sTmp = sTmpValue.copy(1);
-        sTmp = sTmp.replaceAt(0, OUString(sSheetName + ::rtl::OUString::createFromAscii(".")).getLength(), sSheetName + ::rtl::OUString::createFromAscii("!"));
-        sResult += sTmp;
+        ScRangeData* pData = pNamedRange->GetRangeData_Impl();
+        if (pData)
+            pData->GetSymbol( aContent, eGrammar );
     }
-    if (sResult.indexOf('=') != 0)
+    if ( bPrependEquals )
     {
-        sResult = ::rtl::OUString::createFromAscii("=") + sResult;
+        if (aContent.indexOf('=') != 0)
+            aContent = OUString::createFromAscii("=") + aContent;
     }
-    return sResult;
+    return aContent;
 }
 
-void
-ScVbaName::setValue( const ::rtl::OUString & rValue ) throw (css::uno::RuntimeException)
+void  ScVbaName::setContent( const OUString& rContent, const formula::FormulaGrammar::Grammar eGrammar, bool bRemoveEquals )
 {
-    ::rtl::OUString sSheetName = getWorkSheet()->getName();
-    ::rtl::OUString sValue = rValue;
-    ::rtl::OUString sSegmentation = ::rtl::OUString::createFromAscii( "," );
-    ::rtl::OUString sNewSegmentation = ::rtl::OUString::createFromAscii( ";" );
-    ::rtl::OUString sResult;
-    sal_Int32 nFrom = 0;
-    sal_Int32 nTo = 0;
-    if (sValue.indexOf('=') == 0)
+    OUString sContent( rContent );
+    if ( bRemoveEquals )
     {
-        ::rtl::OUString sTmp = sValue.copy(1);
-        sValue = sTmp;
+        if (sContent.indexOf('=') == 0)
+            sContent = sContent.copy(1);
     }
-    nTo = sValue.indexOf( sSegmentation, nFrom );
-    while ( nTo != -1 )
+    ScNamedRangeObj* pNamedRange = dynamic_cast< ScNamedRangeObj* >( mxNamedRange.get() );
+
+    // We should be able to do the below by just setting calling SetCode on pNamedRange
+    // right?
+    if ( pNamedRange && pNamedRange->pDocShell )
     {
-        ::rtl::OUString sTmpValue = sValue.copy( nFrom, nTo - nFrom );
-        sTmpValue = sTmpValue.replaceAt(0, OUString(sSheetName + ::rtl::OUString::createFromAscii("!")).getLength(), sSheetName + ::rtl::OUString::createFromAscii("."));
-        if (sTmpValue.copy(0, sSheetName.getLength()).equals(sSheetName))
+        ScDocument* pDoc = pNamedRange->pDocShell->GetDocument();
+        ScRangeData* pOldData = pNamedRange->GetRangeData_Impl();
+        if (pOldData)
         {
-            sTmpValue = ::rtl::OUString::createFromAscii("$") + sTmpValue;
+            // Shorter way of doing this ?
+            ScCompiler aComp( pDoc, pOldData->GetPos() );
+            aComp.SetGrammar( eGrammar );
+            ScTokenArray aArray(*aComp.CompileString( sContent ) );
+            pOldData->SetCode( aArray );
         }
-        sTmpValue += sNewSegmentation;
-        sResult += sTmpValue;
-        nFrom = nTo + 1;
-        nTo = sValue.indexOf( sSegmentation, nFrom );
     }
-    ::rtl::OUString sTmpValue = sValue.copy( nFrom );
-    sTmpValue = sTmpValue.replaceAt(0, OUString(sSheetName + ::rtl::OUString::createFromAscii("!")).getLength(), sSheetName + ::rtl::OUString::createFromAscii("."));
-    if (sTmpValue.copy(0, sSheetName.getLength()).equals(sSheetName))
-    {
-        sTmpValue = ::rtl::OUString::createFromAscii("$") + sTmpValue;
-    }
-    sResult += sTmpValue;
-    mxNamedRange->setContent(sResult);
+}
+
+OUString
+ScVbaName::getValue() throw (css::uno::RuntimeException)
+{
+    rtl::OUString sResult = getContent( formula::FormulaGrammar::GRAM_NATIVE_XL_A1, true );
+
+    return sResult;
+}
+
+void
+ScVbaName::setValue( const OUString & rValue ) throw (css::uno::RuntimeException)
+{
+    setContent( rValue, formula::FormulaGrammar::GRAM_NATIVE_XL_A1, true );
 }
 
 ::rtl::OUString
@@ -198,19 +183,20 @@ ScVbaName::setRefersToLocal( const ::rtl::OUString & rRefersTo ) throw (css::uno
 ::rtl::OUString
 ScVbaName::getRefersToR1C1() throw (css::uno::RuntimeException)
 {
-    return getRefersTo();
+    rtl::OUString sResult = getContent( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1, true );
+    return  sResult;
 }
 
 void
 ScVbaName::setRefersToR1C1( const ::rtl::OUString & rRefersTo ) throw (css::uno::RuntimeException)
 {
-    setRefersTo( rRefersTo );
+    setContent( rRefersTo, formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1, true );
 }
 
 ::rtl::OUString
 ScVbaName::getRefersToR1C1Local() throw (css::uno::RuntimeException)
 {
-    return getRefersTo();
+    return getRefersToR1C1();
 }
 
 void
diff --git a/sc/source/ui/vba/vbaname.hxx b/sc/source/ui/vba/vbaname.hxx
index 801d14f..85e4ce6 100644
--- a/sc/source/ui/vba/vbaname.hxx
+++ b/sc/source/ui/vba/vbaname.hxx
@@ -24,7 +24,7 @@
 #include <com/sun/star/sheet/XNamedRanges.hpp>
 
 #include <vbahelper/vbahelperinterface.hxx>
-
+#include <formula/grammar.hxx>
 class ScDocument;
 
 typedef InheritedHelperInterfaceImpl1< ov::excel::XName > NameImpl_BASE;
@@ -34,7 +34,8 @@ class ScVbaName : public NameImpl_BASE
     css::uno::Reference< css::frame::XModel > mxModel;
     css::uno::Reference< css::sheet::XNamedRange > mxNamedRange;
     css::uno::Reference< css::sheet::XNamedRanges > mxNames;
-
+    OUString getContent( const formula::FormulaGrammar::Grammar eGrammar, bool prependEquals = true );
+    void setContent( const OUString& sContent, const formula::FormulaGrammar::Grammar eGrammar, bool removeEquals = true );
 protected:
     virtual css::uno::Reference< css::frame::XModel >  getModel() { return mxModel; }
     virtual css::uno::Reference< ov::excel::XWorksheet > getWorkSheet() throw (css::uno::RuntimeException);
diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
index 5f1ea72..e4f5503 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -30,6 +30,9 @@
 #include <vcl/msgbox.hxx>
 #include "tabvwsh.hxx"
 #include "viewdata.hxx"
+#include "compiler.hxx"
+#include "tokenarray.hxx"
+#include "cellsuno.hxx"
 
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
@@ -117,40 +120,109 @@ ScVbaNames::Add( const css::uno::Any& Name ,
                                              uno::Reference< uno::XInterface >() );
         }
     }
+    uno::Reference< table::XCellRange > xUnoRange;
     if ( RefersTo.hasValue() || RefersToR1C1.hasValue() || RefersToR1C1Local.hasValue() )
     {
+        OUString sFormula;
+
+        formula::FormulaGrammar::Grammar eGram = formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
         if ( RefersTo.hasValue() )
-            RefersTo >>= xRange;
+        {
+            if ( RefersTo.getValueTypeClass() == uno::TypeClass_STRING )
+                RefersTo >>= sFormula;
+            else
+                RefersTo >>= xRange;
+        }
         if ( RefersToR1C1.hasValue() )
-            RefersToR1C1 >>= xRange;
+        {
+            if ( RefersToR1C1.getValueTypeClass() == uno::TypeClass_STRING )
+            {
+                RefersToR1C1 >>= sFormula;
+                eGram = formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
+            }
+            else
+                RefersToR1C1 >>= xRange;
+        }
         if ( RefersToR1C1Local.hasValue() )
-            RefersToR1C1Local >>= xRange;
+        {
+            if ( RefersToR1C1Local.getValueTypeClass() == uno::TypeClass_STRING )
+            {
+                RefersToR1C1Local >>= sFormula;
+                eGram = formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
+            }
+            else
+                RefersToR1C1Local >>= xRange;
+        }
+        if ( !xRange.is() && !sFormula.isEmpty() )
+        {
+            ScAddress aBlank;
+            ScCompiler aComp( getScDocument(), aBlank );
+            aComp.SetGrammar( eGram );
+            ScTokenArray* pTokens = aComp.CompileString( sFormula );
+            if ( pTokens )
+            {
+                ScRange aRange;
+                ScDocShell* pDocSh = excel::getDocShell(getModel());
+                if ( pTokens->IsValidReference( aRange ) )
+                    xUnoRange =  new ScCellRangeObj( pDocSh, aRange );
+                else
+                {
+                    // assume it's an address try strip the '=' if it's there
+                    // and try and create a range ( must be a better way )
+                    if ( sFormula.startsWith("=") )
+                        sFormula = sFormula.copy(1);
+                    ScRangeList aCellRanges;
+                    sal_uInt16 nFlags = 0;
+
+                    formula::FormulaGrammar::AddressConvention eConv = ( eGram == formula::FormulaGrammar::GRAM_NATIVE_XL_A1 ) ? formula::FormulaGrammar::CONV_XL_A1 : formula::FormulaGrammar::CONV_XL_R1C1;
+                    if ( ScVbaRange::getCellRangesForAddress( nFlags, sFormula, pDocSh, aCellRanges, eConv , ',' ) )
+                    {
+                        if ( aCellRanges.size() == 1 )
+                            xUnoRange =  new ScCellRangeObj( pDocSh, *aCellRanges.front() );
+                        else
+                        {
+                            uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocSh, aCellRanges ) );
+                            xRange = new ScVbaRange( mxParent, mxContext, xRanges );
+                        }
+                    }
+
+                }
+            }
+        }
     }
 
-    if ( xRange.is() )
+    if ( xRange.is() || xUnoRange.is() )
     {
-        ScVbaRange* pRange = dynamic_cast< ScVbaRange* >( xRange.get() );
-        uno::Reference< table::XCellRange > thisRange ;
-        uno::Any xAny = pRange->getCellRange() ;
-        if ( xAny.hasValue() )
-            xAny >>= thisRange;
-        uno::Reference< sheet::XCellRangeAddressable > thisRangeAdd( thisRange, ::uno::UNO_QUERY_THROW);
+        if ( !xRange.is() )
+            xRange = new ScVbaRange( mxParent, mxContext, xUnoRange );
+
+        uno::Reference< excel::XRange > xArea( xRange->Areas( uno::makeAny( 1 ) ), uno::UNO_QUERY );
+        uno::Any xAny = xArea->getCellRange() ;
+
+        uno::Reference< sheet::XCellRangeAddressable > thisRangeAdd( xAny, ::uno::UNO_QUERY_THROW);
+
         table::CellRangeAddress aAddr = thisRangeAdd->getRangeAddress();
         ScAddress aPos( static_cast< SCCOL >( aAddr.StartColumn ) , static_cast< SCROW >( aAddr.StartRow ) , static_cast< SCTAB >(aAddr.Sheet ) );
         uno::Any xAny2 ;
-        String sRangeAdd = xRange->Address( xAny2, xAny2 , xAny2 , xAny2, xAny2 );
-        String sTmp;
-        sTmp += "$";
-        sTmp += UniString(xRange->getWorksheet()->getName());
-        sTmp += ".";
-        sTmp += sRangeAdd;
         if ( mxNames.is() )
         {
             RangeType nType = RT_NAME;
             table::CellAddress aCellAddr( aAddr.Sheet , aAddr.StartColumn , aAddr.StartRow );
             if ( mxNames->hasByName( sName ) )
                 mxNames->removeByName(sName);
-            mxNames->addNewByName( sName , rtl::OUString(sTmp) , aCellAddr , (sal_Int32)nType);
+            OUString sTmp = "$";
+            uno::Reference< ov::XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY );
+            for ( sal_Int32 nArea = 1; nArea <= xCol->getCount(); ++nArea )
+            {
+                xArea.set( xRange->Areas( uno::makeAny( nArea ) ), uno::UNO_QUERY_THROW );
+
+                String sRangeAdd = xArea->Address( xAny2, xAny2 , xAny2 , xAny2, xAny2 );
+                if ( nArea > 1 )
+                    sTmp += ",";
+                sTmp = sTmp + "'" + xRange->getWorksheet()->getName() + "'." + sRangeAdd;
+            }
+            mxNames->addNewByName( sName , sTmp , aCellAddr , (sal_Int32)nType);
+            return Item( uno::makeAny( sName ), uno::Any() );
         }
     }
     return css::uno::Any();
commit 29f0c3dbe5a1266d0ef5df7fd144af3f3706cdc5
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 9 16:21:09 2013 +0100

    fix wae
    
    Change-Id: I30481f8377d471a1bce50026adff53c15fbc6889
    (cherry picked from commit d6fd3fa6e840c6374f53beeae54f4aa71d73ffcd)

diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 67b02ab..e1d0308 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -329,7 +329,7 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException )
 }
 
 uno::Any SAL_CALL
-ScVbaApplication::International( sal_Int32 Index ) throw (uno::RuntimeException)
+ScVbaApplication::International( sal_Int32 /*Index*/ ) throw (uno::RuntimeException)
 {
     // complete stub for now
     // #TODO flesh out some of the Indices we could handle


More information about the Libreoffice-commits mailing list