[Libreoffice-commits] .: 2 commits - chart2/source sc/source

Caolán McNamara caolan at kemper.freedesktop.org
Wed Jun 1 07:41:34 PDT 2011


 chart2/source/controller/main/ChartController.cxx |   10 ++--------
 chart2/source/model/template/BubbleChartType.cxx  |   17 ++++++-----------
 chart2/source/model/template/ChartType.cxx        |   16 ++++------------
 chart2/source/model/template/ScatterChartType.cxx |   18 +++++-------------
 chart2/source/tools/UncachedDataSequence.cxx      |    3 +--
 sc/source/ui/app/transobj.cxx                     |   16 +++++++---------
 6 files changed, 25 insertions(+), 55 deletions(-)

New commits:
commit 38272e237c014fa15c7ecadca65df2a517097763
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Jun 1 12:15:11 2011 +0100

    overly static

diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 0130fbb..2bbdb8d 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -1375,14 +1375,8 @@ uno::Sequence< ::rtl::OUString > SAL_CALL
     ChartController::getAvailableServiceNames()
     throw (uno::RuntimeException)
 {
-    static uno::Sequence< ::rtl::OUString > aServiceNames;
-
-    if( aServiceNames.getLength() == 0 )
-    {
-        aServiceNames.realloc(1);
-        aServiceNames[0] = CHART_ACCESSIBLE_TEXT_SERVICE_NAME;
-    }
-
+    uno::Sequence< ::rtl::OUString > aServiceNames(1);
+    aServiceNames[0] = CHART_ACCESSIBLE_TEXT_SERVICE_NAME;
     return aServiceNames;
 }
 
diff --git a/chart2/source/model/template/BubbleChartType.cxx b/chart2/source/model/template/BubbleChartType.cxx
index 8058118..2ea1d22 100644
--- a/chart2/source/model/template/BubbleChartType.cxx
+++ b/chart2/source/model/template/BubbleChartType.cxx
@@ -178,17 +178,12 @@ Reference< chart2::XCoordinateSystem > SAL_CALL
 uno::Sequence< ::rtl::OUString > SAL_CALL BubbleChartType::getSupportedMandatoryRoles()
     throw (uno::RuntimeException)
 {
-    static uno::Sequence< ::rtl::OUString > aMandRolesSeq;
-
-    if( aMandRolesSeq.getLength() == 0 )
-    {
-        aMandRolesSeq.realloc( 4 );
-        aMandRolesSeq[0] = C2U( "label" );
-        aMandRolesSeq[1] = C2U( "values-x" );
-        aMandRolesSeq[2] = C2U( "values-y" );
-        aMandRolesSeq[3] = C2U( "values-size" );
-    }
-
+    uno::Sequence< ::rtl::OUString > aMandRolesSeq(4);
+    aMandRolesSeq.realloc( 4 );
+    aMandRolesSeq[0] = C2U( "label" );
+    aMandRolesSeq[1] = C2U( "values-x" );
+    aMandRolesSeq[2] = C2U( "values-y" );
+    aMandRolesSeq[3] = C2U( "values-size" );
     return aMandRolesSeq;
 }
 
diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx
index 0c2528d..90c8c77 100644
--- a/chart2/source/model/template/ChartType.cxx
+++ b/chart2/source/model/template/ChartType.cxx
@@ -122,24 +122,16 @@ Reference< chart2::XCoordinateSystem > SAL_CALL
 Sequence< OUString > SAL_CALL ChartType::getSupportedMandatoryRoles()
     throw (uno::RuntimeException)
 {
-    static Sequence< OUString > aDefaultSeq;
-
-    if( aDefaultSeq.getLength() == 0 )
-    {
-        aDefaultSeq.realloc( 2 );
-        aDefaultSeq[0] = C2U( "label" );
-        aDefaultSeq[1] = C2U( "values-y" );
-    }
-
+    Sequence< OUString > aDefaultSeq(2);
+    aDefaultSeq[0] = C2U( "label" );
+    aDefaultSeq[1] = C2U( "values-y" );
     return aDefaultSeq;
 }
 
 Sequence< OUString > SAL_CALL ChartType::getSupportedOptionalRoles()
     throw (uno::RuntimeException)
 {
-    static Sequence< OUString > aDefaultOptRolesSeq;
-
-    return aDefaultOptRolesSeq;
+    return Sequence< OUString >();
 }
 
 OUString SAL_CALL ChartType::getRoleOfSequenceForSeriesLabel()
diff --git a/chart2/source/model/template/ScatterChartType.cxx b/chart2/source/model/template/ScatterChartType.cxx
index bfcd49b..8e02dac 100644
--- a/chart2/source/model/template/ScatterChartType.cxx
+++ b/chart2/source/model/template/ScatterChartType.cxx
@@ -228,25 +228,17 @@ Reference< chart2::XCoordinateSystem > SAL_CALL
 uno::Sequence< ::rtl::OUString > SAL_CALL ScatterChartType::getSupportedMandatoryRoles()
     throw (uno::RuntimeException)
 {
-    static uno::Sequence< ::rtl::OUString > aMandRolesSeq;
-
-    if( aMandRolesSeq.getLength() == 0 )
-    {
-        aMandRolesSeq.realloc( 3 );
-        aMandRolesSeq[0] = C2U( "label" );
-        aMandRolesSeq[1] = C2U( "values-x" );
-        aMandRolesSeq[2] = C2U( "values-y" );
-    }
-
+    uno::Sequence< ::rtl::OUString > aMandRolesSeq(3);
+    aMandRolesSeq[0] = C2U( "label" );
+    aMandRolesSeq[1] = C2U( "values-x" );
+    aMandRolesSeq[2] = C2U( "values-y" );
     return aMandRolesSeq;
 }
 
 uno::Sequence< ::rtl::OUString > SAL_CALL ScatterChartType::getSupportedOptionalRoles()
     throw (uno::RuntimeException)
 {
-    static uno::Sequence< ::rtl::OUString > aOptRolesSeq;
-
-    return aOptRolesSeq;
+    return uno::Sequence< ::rtl::OUString >();
 }
 
 
diff --git a/chart2/source/tools/UncachedDataSequence.cxx b/chart2/source/tools/UncachedDataSequence.cxx
index fad583f..1397356 100644
--- a/chart2/source/tools/UncachedDataSequence.cxx
+++ b/chart2/source/tools/UncachedDataSequence.cxx
@@ -233,8 +233,7 @@ Sequence< OUString > SAL_CALL UncachedDataSequence::generateLabel( chart2::data:
     throw (uno::RuntimeException)
 {
     // auto-generated label is an empty string
-    static const Sequence< OUString > aOneEmptyString( 1 );
-    return aOneEmptyString;
+    return Sequence< OUString >(1);
 }
 
 ::sal_Int32 SAL_CALL UncachedDataSequence::getNumberFormatKeyByIndex( ::sal_Int32 )
commit dd3301054f23b64371fee798a9ef8839362554be
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Jun 1 12:15:00 2011 +0100

    use tunnel id pattern here

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 56ddd7d..b6ce879 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -44,6 +44,7 @@
 #include <unotools/tempfile.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 #include <comphelper/storagehelper.hxx>
+#include <comphelper/servicehelper.hxx>
 #include <sot/storage.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/virdev.hxx>
@@ -846,17 +847,14 @@ void ScTransferObj::StripRefs( ScDocument* pDoc,
     }
 }
 
+namespace
+{
+    class theScTransferUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTransferUnoTunnelId> {};
+}
+
 const com::sun::star::uno::Sequence< sal_Int8 >& ScTransferObj::getUnoTunnelId()
 {
-    static com::sun::star::uno::Sequence< sal_Int8 > aSeq;
-    if( !aSeq.getLength() )
-    {
-        static osl::Mutex           aCreateMutex;
-        osl::Guard< osl::Mutex >    aGuard( aCreateMutex );
-        aSeq.realloc( 16 );
-        rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
-    }
-    return aSeq;
+    return theScTransferUnoTunnelId::get().getSeq();
 }
 
 sal_Int64 SAL_CALL ScTransferObj::getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( com::sun::star::uno::RuntimeException )


More information about the Libreoffice-commits mailing list