[Libreoffice-commits] core.git: 4 commits - sw/inc sw/source

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Thu Mar 26 08:09:52 PDT 2015


 sw/inc/unotbl.hxx                   |    2 +
 sw/source/core/doc/docdraw.cxx      |    2 -
 sw/source/core/unocore/unoframe.cxx |   37 +------------------
 sw/source/core/unocore/unotbl.cxx   |   68 ++++++++++++++----------------------
 4 files changed, 33 insertions(+), 76 deletions(-)

New commits:
commit 63fccb1101cacd7887a5f7a094fd376d164e3d73
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Mar 26 15:55:37 2015 +0100

    remove copypasta
    
    Change-Id: Ieed83781b89ff18f870ad8c64ca00d306b097aea

diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 6a3ffd1..6a5b6d8 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -3592,41 +3592,8 @@ void SwXTextEmbeddedObject::removeEventListener(const uno::Reference< lang::XEve
 
 uno::Reference< lang::XComponent >  SwXTextEmbeddedObject::getEmbeddedObject(void) throw( uno::RuntimeException, std::exception )
 {
-    uno::Reference< lang::XComponent >  xRet;
-    SwFrmFmt*   pFmt = GetFrmFmt();
-    if(pFmt)
-    {
-        SwDoc* pDoc = pFmt->GetDoc();
-        const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
-        OSL_ENSURE( pCnt->GetCntntIdx() &&
-                       pDoc->GetNodes()[ pCnt->GetCntntIdx()->
-                                        GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
-
-        SwOLENode* pOleNode =  pDoc->GetNodes()[ pCnt->GetCntntIdx()
-                                        ->GetIndex() + 1 ]->GetOLENode();
-        uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef();
-        if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
-        {
-            // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here
-            if ( pDoc->GetDocShell() )
-                pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) );
-
-            xRet = uno::Reference < lang::XComponent >( xIP->getComponent(), uno::UNO_QUERY );
-            uno::Reference< util::XModifyBroadcaster >  xBrdcst( xRet, uno::UNO_QUERY);
-            uno::Reference< frame::XModel > xModel( xRet, uno::UNO_QUERY);
-            if( xBrdcst.is() && xModel.is() )
-            {
-                SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>( *pFmt ).First();
-                //create a new one if the OLE object doesn't have one already
-                if( !pListener )
-                {
-                    uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel);
-                    xBrdcst->addModifyListener( xOLEListener );
-                }
-            }
-        }
-    }
-    return xRet;
+    uno::Reference<embed::XEmbeddedObject> xObj(getExtendedControlOverEmbeddedObject());
+    return xObj.is() ? uno::Reference<lang::XComponent>(xObj->getComponent(), uno::UNO_QUERY) : nullptr;
 }
 
 uno::Reference< embed::XEmbeddedObject > SAL_CALL SwXTextEmbeddedObject::getExtendedControlOverEmbeddedObject()
commit 2bfc2c4a2cbc86ec193fdb30ab0f4f4fab01790d
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Mar 25 12:50:44 2015 +0100

    fix horrible genglish
    
    Change-Id: I2b7ed81511c6f89240f192cd6efaf8698e73f8ff

diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx
index 54eeeb1..ff8190f 100644
--- a/sw/source/core/doc/docdraw.cxx
+++ b/sw/source/core/doc/docdraw.cxx
@@ -511,7 +511,7 @@ _ZSortFly::_ZSortFly( const SwFrmFmt* pFrmFmt, const SwFmtAnchor* pFlyAn,
             nOrdNum = pContact->GetMaster()->GetOrdNum();
     }
     else {
-        OSL_ENSURE( false, "what is that for a format?" );
+        OSL_ENSURE( false, "what kind of format is this?" );
     }
 }
 
commit 9e3064c172082eb43640381452d907bdb2ca6ebf
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Mar 25 11:26:06 2015 +0100

    refactor FormatTable away from SwClients a bit
    
    Change-Id: I43cf4ca6f8cf66b045eedd99108941ea44d56086

diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 7a1fff4..7b667a1 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -604,20 +604,23 @@ static void lcl_InspectLines(SwTableLines& rLines, std::vector<OUString*>& rAllN
     }
 }
 
-static void lcl_FormatTable(SwFrmFmt* pTblFmt)
+static bool lcl_FormatTable(SwFrmFmt* pTblFmt)
 {
+    bool bHasFrames = false;
     SwIterator<SwFrm,SwFmt> aIter( *pTblFmt );
-    for( SwFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
+    for(SwFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next())
     {
         // mba: no TYPEINFO for SwTabFrm
-        if( pFrm->IsTabFrm() )
-        {
-            if(pFrm->IsValid())
-                pFrm->InvalidatePos();
-            static_cast<SwTabFrm*>(pFrm)->SetONECalcLowers();
-            static_cast<SwTabFrm*>(pFrm)->Calc();
-        }
+        if(!pFrm->IsTabFrm())
+            continue;
+        SwTabFrm* pTabFrm = static_cast<SwTabFrm*>(pFrm);
+        if(pTabFrm->IsValid())
+            pTabFrm->InvalidatePos();
+        pTabFrm->SetONECalcLowers();
+        pTabFrm->Calc();
+        bHasFrames = true;
     }
+    return bHasFrames;
 }
 
 static void lcl_CrsrSelect(SwPaM& rCrsr, bool bExpand)
@@ -3180,13 +3183,8 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
                         break; // something else
                     }
                     SwDoc* pDoc = pFmt->GetDoc();
-                    SwFrm* pFrm = SwIterator<SwFrm,SwFmt>( *pFmt ).First();
-                    // tables without layout (invisible header/footer?)
-                    if (!pFrm)
-                    {
+                    if(!lcl_FormatTable(pFmt))
                         break;
-                    }
-                    lcl_FormatTable(pFmt);
                     SwTable* pTable = SwTable::FindTable( pFmt );
                     SwTableLines &rLines = pTable->GetTabLines();
 
@@ -3374,13 +3372,9 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
                 case FN_UNO_TABLE_BORDER2:
                 {
                     SwDoc* pDoc = pFmt->GetDoc();
-                    SwFrm* pFrm = SwIterator<SwFrm,SwFmt>( *pFmt ).First();
                     // tables without layout (invisible header/footer?)
-                    if (!pFrm)
-                    {
+                    if(!lcl_FormatTable(pFmt))
                         break;
-                    }
-                    lcl_FormatTable(pFmt);
                     SwTable* pTable = SwTable::FindTable( pFmt );
                     SwTableLines &rLines = pTable->GetTabLines();
 
commit dc8697e554417d31501a0d90d731403ede223370
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Mar 25 11:07:17 2015 +0100

    use a WeakReference instead of meddling in SwClients
    
    Change-Id: I9dcf00607bac820c3dbb26c6de9f6e326df7fb99

diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index 3b7b303..a352677 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -307,6 +307,8 @@ class SwXTextTable : public cppu::WeakImplHelper10
 private:
     class Impl;
     ::sw::UnoImplPtr<Impl> m_pImpl;
+    ::com::sun::star::uno::WeakReference< ::com::sun::star::table::XTableRows > m_xRows;
+    ::com::sun::star::uno::WeakReference< ::com::sun::star::table::XTableColumns > m_xColumns;
 
     const SfxItemPropertySet*       m_pPropSet;
 
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index ddc7f70..7a1fff4 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2258,33 +2258,27 @@ void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeExc
 uno::Reference< table::XTableRows >  SwXTextTable::getRows(void) throw( uno::RuntimeException, std::exception )
 {
     SolarMutexGuard aGuard;
-    uno::Reference< table::XTableRows >  xRet;
-    if (SwFrmFmt* pFmt = GetFrmFmt())
-    {
-        SwXTableRows* pRows = SwIterator<SwXTableRows,SwFmt>(*pFmt).First();
-        if (!pRows)
-            pRows = new SwXTableRows(*pFmt);
-        xRet = pRows;
-    }
-    if (!xRet.is())
+    uno::Reference<table::XTableRows> xResult(m_xRows);
+    if(xResult.is())
+        return xResult;
+    if(SwFrmFmt* pFmt = GetFrmFmt())
+        m_xRows = xResult = new SwXTableRows(*pFmt);
+    if(!xResult.is())
         throw uno::RuntimeException();
-    return xRet;
+    return xResult;
 }
 
 uno::Reference< table::XTableColumns >  SwXTextTable::getColumns(void) throw( uno::RuntimeException, std::exception )
 {
     SolarMutexGuard aGuard;
-    uno::Reference< table::XTableColumns >  xRet;
-    if (SwFrmFmt* pFmt = GetFrmFmt())
-    {
-        SwXTableColumns* pCols = SwIterator<SwXTableColumns,SwFmt>(*pFmt).First();
-        if (!pCols)
-            pCols = new SwXTableColumns(*pFmt);
-        xRet = pCols;
-    }
-    if (!xRet.is())
+    uno::Reference<table::XTableColumns> xResult(m_xColumns);
+    if(xResult.is())
+        return xResult;
+    if(SwFrmFmt* pFmt = GetFrmFmt())
+        m_xColumns = xResult = new SwXTableColumns(*pFmt);
+    if(!xResult.is())
         throw uno::RuntimeException();
-    return xRet;
+    return xResult;
 }
 
 uno::Reference< table::XCell > SwXTextTable::getCellByName(const OUString& sCellName) throw( uno::RuntimeException, std::exception )


More information about the Libreoffice-commits mailing list