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

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Aug 31 20:50:36 PDT 2011


 sc/source/core/data/documen5.cxx |  136 ++++++++++++++++++---------------------
 1 file changed, 66 insertions(+), 70 deletions(-)

New commits:
commit 886762160996dfa3fee07cf135e53dfe952ed298
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Wed Aug 31 16:34:27 2011 -0400

    Switch to for loop and reduce scoping level.

diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index e7b8fb1..f89e62d 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -711,65 +711,63 @@ void ScDocument::UpdateChartListenerCollection()
             continue;
 
         SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
-        SdrObject* pObject = aIter.Next();
-        while (pObject)
+        for (SdrObject* pObject = aIter.Next(); pObject; pObject = aIter.Next())
         {
-            if ( pObject->GetObjIdentifier() == OBJ_OLE2 )
+            if ( pObject->GetObjIdentifier() != OBJ_OLE2 )
+                continue;
+
+            String aObjName = ((SdrOle2Obj*)pObject)->GetPersistName();
+            aCLSearcher.SetString( aObjName );
+            sal_uInt16 nIndex;
+            if ( pChartListenerCollection->Search( &aCLSearcher, nIndex ) )
             {
-                String aObjName = ((SdrOle2Obj*)pObject)->GetPersistName();
-                aCLSearcher.SetString( aObjName );
-                sal_uInt16 nIndex;
-                if ( pChartListenerCollection->Search( &aCLSearcher, nIndex ) )
-                {
-                    ((ScChartListener*) (pChartListenerCollection->
-                        At( nIndex )))->SetUsed( sal_True );
-                }
-                else if ( lcl_StringInCollection( pOtherObjects, aObjName ) )
-                {
-                    // non-chart OLE object -> don't touch
-                }
-                else
+                ((ScChartListener*) (pChartListenerCollection->
+                    At( nIndex )))->SetUsed( sal_True );
+            }
+            else if ( lcl_StringInCollection( pOtherObjects, aObjName ) )
+            {
+                // non-chart OLE object -> don't touch
+            }
+            else
+            {
+                bool bIsChart = false;
+
+                uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
+                OSL_ENSURE( xIPObj.is(), "No embedded object is given!");
+                uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
+                uno::Reference< embed::XComponentSupplier > xCompSupp( xIPObj, uno::UNO_QUERY );
+                if( xCompSupp.is())
+                    xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+
+                // if the object is a chart2::XDataReceiver, we must attach as XDataProvider
+                if( xReceiver.is() &&
+                    !PastingDrawFromOtherDoc())
                 {
-                    bool bIsChart = false;
-
-                    uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
-                    OSL_ENSURE( xIPObj.is(), "No embedded object is given!");
-                    uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
-                    uno::Reference< embed::XComponentSupplier > xCompSupp( xIPObj, uno::UNO_QUERY );
-                    if( xCompSupp.is())
-                        xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
-
-                    // if the object is a chart2::XDataReceiver, we must attach as XDataProvider
-                    if( xReceiver.is() &&
-                        !PastingDrawFromOtherDoc())
-                    {
-                        // NOTE: this currently does not work as we are
-                        // unable to set the data. So a chart from the
-                        // same document is treated like a chart with
-                        // own data for the time being.
+                    // NOTE: this currently does not work as we are
+                    // unable to set the data. So a chart from the
+                    // same document is treated like a chart with
+                    // own data for the time being.
 
-                        // data provider
-                        // number formats supplier
+                    // data provider
+                    // number formats supplier
 
-                        // data ?
-                        // how to set?? Defined in XML-file, which is already loaded!!!
-                        // => we have to do this stuff here, BEFORE the chart is actually loaded
-                    }
+                    // data ?
+                    // how to set?? Defined in XML-file, which is already loaded!!!
+                    // => we have to do this stuff here, BEFORE the chart is actually loaded
+                }
 
-                    if (!bIsChart)
-                    {
-                        //  put into list of other ole objects, so the object doesn't have to
-                        //  be swapped in the next time UpdateChartListenerCollection is called
-                        //! remove names when objects are no longer there?
-                        //  (object names aren't used again before reloading the document)
-
-                        if (!pOtherObjects)
-                            pOtherObjects = new ScStrCollection;
-                        pOtherObjects->Insert( new StrData( aObjName ) );
-                    }
+                if (!bIsChart)
+                {
+                    //  put into list of other ole objects, so the object doesn't have to
+                    //  be swapped in the next time UpdateChartListenerCollection is called
+                    //! remove names when objects are no longer there?
+                    //  (object names aren't used again before reloading the document)
+
+                    if (!pOtherObjects)
+                        pOtherObjects = new ScStrCollection;
+                    pOtherObjects->Insert( new StrData( aObjName ) );
                 }
             }
-            pObject = aIter.Next();
         }
     }
     // alle nicht auf SetUsed gesetzten loeschen
commit 9a29ac7b485ae681eede9362496b14c62dc2e57e
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Wed Aug 31 16:31:15 2011 -0400

    We can remove this scope too.

diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index f9a0db2..e7b8fb1 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -701,75 +701,75 @@ void ScDocument::UpdateChartListenerCollection()
     ScChartListener aCLSearcher( EMPTY_STRING, this, aRange );
     for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++)
     {
-        if (maTabs[nTab])
-        {
-            SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
-            OSL_ENSURE(pPage,"Page ?");
+        if (!maTabs[nTab])
+            continue;
 
-            if (!pPage)
-                continue;
+        SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+        OSL_ENSURE(pPage,"Page ?");
 
-            SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
-            SdrObject* pObject = aIter.Next();
-            while (pObject)
+        if (!pPage)
+            continue;
+
+        SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+        SdrObject* pObject = aIter.Next();
+        while (pObject)
+        {
+            if ( pObject->GetObjIdentifier() == OBJ_OLE2 )
             {
-                if ( pObject->GetObjIdentifier() == OBJ_OLE2 )
+                String aObjName = ((SdrOle2Obj*)pObject)->GetPersistName();
+                aCLSearcher.SetString( aObjName );
+                sal_uInt16 nIndex;
+                if ( pChartListenerCollection->Search( &aCLSearcher, nIndex ) )
                 {
-                    String aObjName = ((SdrOle2Obj*)pObject)->GetPersistName();
-                    aCLSearcher.SetString( aObjName );
-                    sal_uInt16 nIndex;
-                    if ( pChartListenerCollection->Search( &aCLSearcher, nIndex ) )
-                    {
-                        ((ScChartListener*) (pChartListenerCollection->
-                            At( nIndex )))->SetUsed( sal_True );
-                    }
-                    else if ( lcl_StringInCollection( pOtherObjects, aObjName ) )
-                    {
-                        // non-chart OLE object -> don't touch
-                    }
-                    else
+                    ((ScChartListener*) (pChartListenerCollection->
+                        At( nIndex )))->SetUsed( sal_True );
+                }
+                else if ( lcl_StringInCollection( pOtherObjects, aObjName ) )
+                {
+                    // non-chart OLE object -> don't touch
+                }
+                else
+                {
+                    bool bIsChart = false;
+
+                    uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
+                    OSL_ENSURE( xIPObj.is(), "No embedded object is given!");
+                    uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
+                    uno::Reference< embed::XComponentSupplier > xCompSupp( xIPObj, uno::UNO_QUERY );
+                    if( xCompSupp.is())
+                        xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+
+                    // if the object is a chart2::XDataReceiver, we must attach as XDataProvider
+                    if( xReceiver.is() &&
+                        !PastingDrawFromOtherDoc())
                     {
-                        bool bIsChart = false;
-
-                        uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
-                        OSL_ENSURE( xIPObj.is(), "No embedded object is given!");
-                        uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
-                        uno::Reference< embed::XComponentSupplier > xCompSupp( xIPObj, uno::UNO_QUERY );
-                        if( xCompSupp.is())
-                            xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
-
-                        // if the object is a chart2::XDataReceiver, we must attach as XDataProvider
-                        if( xReceiver.is() &&
-                            !PastingDrawFromOtherDoc())
-                        {
-                            // NOTE: this currently does not work as we are
-                            // unable to set the data. So a chart from the
-                            // same document is treated like a chart with
-                            // own data for the time being.
+                        // NOTE: this currently does not work as we are
+                        // unable to set the data. So a chart from the
+                        // same document is treated like a chart with
+                        // own data for the time being.
 
-                            // data provider
-                            // number formats supplier
+                        // data provider
+                        // number formats supplier
 
-                            // data ?
-                            // how to set?? Defined in XML-file, which is already loaded!!!
-                            // => we have to do this stuff here, BEFORE the chart is actually loaded
-                        }
+                        // data ?
+                        // how to set?? Defined in XML-file, which is already loaded!!!
+                        // => we have to do this stuff here, BEFORE the chart is actually loaded
+                    }
 
-                        if (!bIsChart)
-                        {
-                            //  put into list of other ole objects, so the object doesn't have to
-                            //  be swapped in the next time UpdateChartListenerCollection is called
-                            //! remove names when objects are no longer there?
-                            //  (object names aren't used again before reloading the document)
-
-                            if (!pOtherObjects)
-                                pOtherObjects = new ScStrCollection;
-                            pOtherObjects->Insert( new StrData( aObjName ) );
-                        }
+                    if (!bIsChart)
+                    {
+                        //  put into list of other ole objects, so the object doesn't have to
+                        //  be swapped in the next time UpdateChartListenerCollection is called
+                        //! remove names when objects are no longer there?
+                        //  (object names aren't used again before reloading the document)
+
+                        if (!pOtherObjects)
+                            pOtherObjects = new ScStrCollection;
+                        pOtherObjects->Insert( new StrData( aObjName ) );
                     }
                 }
-                pObject = aIter.Next();
             }
+            pObject = aIter.Next();
         }
     }
     // alle nicht auf SetUsed gesetzten loeschen
commit 7312939f953e00237b524da17351cf4a38a1ba2b
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Wed Aug 31 16:28:51 2011 -0400

    Removed unnecessary scoping.
    
    The if condition is true, the method simply returns.  There is no
    need to have this else scope which would increase the indent level
    for no good reason.

diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index b9519fb..f9a0db2 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -695,87 +695,85 @@ void ScDocument::UpdateChartListenerCollection()
     bChartListenerCollectionNeedsUpdate = false;
     if (!pDrawLayer)
         return;
-    else
+
+    ScRange aRange;
+    // Range for searching is not important
+    ScChartListener aCLSearcher( EMPTY_STRING, this, aRange );
+    for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++)
     {
-        ScRange aRange;
-        // Range for searching is not important
-        ScChartListener aCLSearcher( EMPTY_STRING, this, aRange );
-        for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++)
+        if (maTabs[nTab])
         {
-            if (maTabs[nTab])
-            {
-                SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
-                OSL_ENSURE(pPage,"Page ?");
+            SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+            OSL_ENSURE(pPage,"Page ?");
 
-                if (!pPage)
-                    continue;
+            if (!pPage)
+                continue;
 
-                SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
-                SdrObject* pObject = aIter.Next();
-                while (pObject)
+            SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+            SdrObject* pObject = aIter.Next();
+            while (pObject)
+            {
+                if ( pObject->GetObjIdentifier() == OBJ_OLE2 )
                 {
-                    if ( pObject->GetObjIdentifier() == OBJ_OLE2 )
+                    String aObjName = ((SdrOle2Obj*)pObject)->GetPersistName();
+                    aCLSearcher.SetString( aObjName );
+                    sal_uInt16 nIndex;
+                    if ( pChartListenerCollection->Search( &aCLSearcher, nIndex ) )
                     {
-                        String aObjName = ((SdrOle2Obj*)pObject)->GetPersistName();
-                        aCLSearcher.SetString( aObjName );
-                        sal_uInt16 nIndex;
-                        if ( pChartListenerCollection->Search( &aCLSearcher, nIndex ) )
-                        {
-                            ((ScChartListener*) (pChartListenerCollection->
-                                At( nIndex )))->SetUsed( sal_True );
-                        }
-                        else if ( lcl_StringInCollection( pOtherObjects, aObjName ) )
-                        {
-                            // non-chart OLE object -> don't touch
-                        }
-                        else
+                        ((ScChartListener*) (pChartListenerCollection->
+                            At( nIndex )))->SetUsed( sal_True );
+                    }
+                    else if ( lcl_StringInCollection( pOtherObjects, aObjName ) )
+                    {
+                        // non-chart OLE object -> don't touch
+                    }
+                    else
+                    {
+                        bool bIsChart = false;
+
+                        uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
+                        OSL_ENSURE( xIPObj.is(), "No embedded object is given!");
+                        uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
+                        uno::Reference< embed::XComponentSupplier > xCompSupp( xIPObj, uno::UNO_QUERY );
+                        if( xCompSupp.is())
+                            xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+
+                        // if the object is a chart2::XDataReceiver, we must attach as XDataProvider
+                        if( xReceiver.is() &&
+                            !PastingDrawFromOtherDoc())
                         {
-                            bool bIsChart = false;
-
-                            uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
-                            OSL_ENSURE( xIPObj.is(), "No embedded object is given!");
-                            uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
-                            uno::Reference< embed::XComponentSupplier > xCompSupp( xIPObj, uno::UNO_QUERY );
-                            if( xCompSupp.is())
-                                xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
-
-                            // if the object is a chart2::XDataReceiver, we must attach as XDataProvider
-                            if( xReceiver.is() &&
-                                !PastingDrawFromOtherDoc())
-                            {
-                                // NOTE: this currently does not work as we are
-                                // unable to set the data. So a chart from the
-                                // same document is treated like a chart with
-                                // own data for the time being.
+                            // NOTE: this currently does not work as we are
+                            // unable to set the data. So a chart from the
+                            // same document is treated like a chart with
+                            // own data for the time being.
 
-                                // data provider
-                                // number formats supplier
+                            // data provider
+                            // number formats supplier
 
-                                // data ?
-                                // how to set?? Defined in XML-file, which is already loaded!!!
-                                // => we have to do this stuff here, BEFORE the chart is actually loaded
-                            }
+                            // data ?
+                            // how to set?? Defined in XML-file, which is already loaded!!!
+                            // => we have to do this stuff here, BEFORE the chart is actually loaded
+                        }
 
-                            if (!bIsChart)
-                            {
-                                //  put into list of other ole objects, so the object doesn't have to
-                                //  be swapped in the next time UpdateChartListenerCollection is called
-                                //! remove names when objects are no longer there?
-                                //  (object names aren't used again before reloading the document)
-
-                                if (!pOtherObjects)
-                                    pOtherObjects = new ScStrCollection;
-                                pOtherObjects->Insert( new StrData( aObjName ) );
-                            }
+                        if (!bIsChart)
+                        {
+                            //  put into list of other ole objects, so the object doesn't have to
+                            //  be swapped in the next time UpdateChartListenerCollection is called
+                            //! remove names when objects are no longer there?
+                            //  (object names aren't used again before reloading the document)
+
+                            if (!pOtherObjects)
+                                pOtherObjects = new ScStrCollection;
+                            pOtherObjects->Insert( new StrData( aObjName ) );
                         }
                     }
-                    pObject = aIter.Next();
                 }
+                pObject = aIter.Next();
             }
         }
-        // alle nicht auf SetUsed gesetzten loeschen
-        pChartListenerCollection->FreeUnused();
     }
+    // alle nicht auf SetUsed gesetzten loeschen
+    pChartListenerCollection->FreeUnused();
 }
 
 void ScDocument::AddOLEObjectToCollection(const String& rName)


More information about the Libreoffice-commits mailing list