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

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Feb 22 12:41:58 PST 2012


 sc/source/core/data/dpobject.cxx |  105 ++++++++++++++++++---------------------
 sc/source/ui/view/dbfunc3.cxx    |   10 +--
 2 files changed, 55 insertions(+), 60 deletions(-)

New commits:
commit 251c24fed0fd34cec7e699a8af608748e5b9b4bf
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Wed Feb 22 15:41:27 2012 -0500

    Scope reduction.

diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 8f85bcf..4d3ff60 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2377,64 +2377,61 @@ uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPS
     uno::Reference<sheet::XDimensionsSupplier> xRet = NULL;
 
     uno::Reference<lang::XMultiServiceFactory> xManager = comphelper::getProcessServiceFactory();
-    uno::Reference<container::XContentEnumerationAccess> xEnAc( xManager, uno::UNO_QUERY );
-    if ( xEnAc.is() )
+    uno::Reference<container::XContentEnumerationAccess> xEnAc(xManager, uno::UNO_QUERY);
+    if (!xEnAc.is())
+        return xRet;
+
+    uno::Reference<container::XEnumeration> xEnum =
+        xEnAc->createContentEnumeration(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SCDPSOURCE_SERVICE)));
+    if (!xEnum.is())
+        return xRet;
+
+    while (xEnum->hasMoreElements() && !xRet.is())
     {
-        uno::Reference<container::XEnumeration> xEnum = xEnAc->createContentEnumeration(
-                                        rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCDPSOURCE_SERVICE )) );
-        if ( xEnum.is() )
+        uno::Any aAddInAny = xEnum->nextElement();
+        uno::Reference<uno::XInterface> xIntFac;
+        aAddInAny >>= xIntFac;
+        if (!xIntFac.is())
+            continue;
+
+        uno::Reference<lang::XServiceInfo> xInfo(xIntFac, uno::UNO_QUERY);
+        if (!xInfo.is() || xInfo->getImplementationName() != aImplName)
+            continue;
+
+        try
         {
-            while ( xEnum->hasMoreElements() && !xRet.is() )
+            // #i113160# try XSingleComponentFactory in addition to (old) XSingleServiceFactory,
+            // passing the context to the component (see ScUnoAddInCollection::Initialize)
+
+            uno::Reference<uno::XInterface> xInterface;
+            uno::Reference<uno::XComponentContext> xCtx = getContext(xManager);
+            uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY );
+            if (xCtx.is() && xCFac.is())
+                xInterface = xCFac->createInstanceWithContext(xCtx);
+
+            if (!xInterface.is())
             {
-                uno::Any aAddInAny = xEnum->nextElement();
-//              if ( aAddInAny.getReflection()->getTypeClass() == TypeClass_INTERFACE )
-                {
-                    uno::Reference<uno::XInterface> xIntFac;
-                    aAddInAny >>= xIntFac;
-                    if ( xIntFac.is() )
-                    {
-                        uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY );
-                        if ( xInfo.is() && xInfo->getImplementationName() == aImplName )
-                        {
-                            try
-                            {
-                                // #i113160# try XSingleComponentFactory in addition to (old) XSingleServiceFactory,
-                                // passing the context to the component (see ScUnoAddInCollection::Initialize)
-
-                                uno::Reference<uno::XInterface> xInterface;
-                                uno::Reference<uno::XComponentContext> xCtx = getContext(xManager);
-                                uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY );
-                                if (xCtx.is() && xCFac.is())
-                                    xInterface = xCFac->createInstanceWithContext(xCtx);
-
-                                if (!xInterface.is())
-                                {
-                                    uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY );
-                                    if ( xFac.is() )
-                                        xInterface = xFac->createInstance();
-                                }
-
-                                uno::Reference<lang::XInitialization> xInit( xInterface, uno::UNO_QUERY );
-                                if (xInit.is())
-                                {
-                                    //  initialize
-                                    uno::Sequence<uno::Any> aSeq(4);
-                                    uno::Any* pArray = aSeq.getArray();
-                                    pArray[0] <<= rtl::OUString( rDesc.aParSource );
-                                    pArray[1] <<= rtl::OUString( rDesc.aParName );
-                                    pArray[2] <<= rtl::OUString( rDesc.aParUser );
-                                    pArray[3] <<= rtl::OUString( rDesc.aParPass );
-                                    xInit->initialize( aSeq );
-                                }
-                                xRet = uno::Reference<sheet::XDimensionsSupplier>( xInterface, uno::UNO_QUERY );
-                            }
-                            catch(uno::Exception&)
-                            {
-                            }
-                        }
-                    }
-                }
+                uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY );
+                if ( xFac.is() )
+                    xInterface = xFac->createInstance();
             }
+
+            uno::Reference<lang::XInitialization> xInit( xInterface, uno::UNO_QUERY );
+            if (xInit.is())
+            {
+                //  initialize
+                uno::Sequence<uno::Any> aSeq(4);
+                uno::Any* pArray = aSeq.getArray();
+                pArray[0] <<= rtl::OUString( rDesc.aParSource );
+                pArray[1] <<= rtl::OUString( rDesc.aParName );
+                pArray[2] <<= rtl::OUString( rDesc.aParUser );
+                pArray[3] <<= rtl::OUString( rDesc.aParPass );
+                xInit->initialize( aSeq );
+            }
+            xRet = uno::Reference<sheet::XDimensionsSupplier>( xInterface, uno::UNO_QUERY );
+        }
+        catch(uno::Exception&)
+        {
         }
     }
 
commit 32b074bef73e44df397145fbc5e984713f4ef995
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Wed Feb 22 15:32:32 2012 -0500

    Slight cleanup.
    
    No need to make a duplicate of ScDPObject.

diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index abfe1fb..ca1de03 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -1437,7 +1437,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const rtl::OUString& rStri
 
     pDPObj->BuildAllDimensionMembers();
     ScDPSaveData aData( *pDPObj->GetSaveData() );
-    sal_Bool bChange = false;
+    bool bChange = false;
 
     sal_uInt16 nOrient = DataPilotFieldOrientation_HIDDEN;
     long nField = pDPObj->GetHeaderDim( rPos, nOrient );
@@ -1461,7 +1461,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const rtl::OUString& rStri
                     ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aOldText );
                     pSaveDim->SetName( rString );
 
-                    bChange = sal_True;
+                    bChange = true;
                 }
                 else
                     nErrorId = STR_INVALIDNAME;
@@ -1675,10 +1675,8 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const rtl::OUString& rStri
     {
         // apply changes
         ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
-        ScDPObject* pNewObj = new ScDPObject( *pDPObj );
-        pNewObj->SetSaveData( aData );
-        aFunc.DataPilotUpdate( pDPObj, pNewObj, sal_True, false );
-        delete pNewObj;
+        pDPObj->SetSaveData( aData );
+        aFunc.DataPilotUpdate( pDPObj, pDPObj, true, false );
     }
     else
     {


More information about the Libreoffice-commits mailing list