[Libreoffice-commits] core.git: Branch 'private/Sweetshark/mmunocrsrs' - 3 commits - sw/inc sw/source

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Wed May 20 10:50:16 PDT 2015


 sw/inc/unotbl.hxx                 |    6 +--
 sw/source/core/unocore/unotbl.cxx |   64 +++++++++++++++++++-------------------
 2 files changed, 35 insertions(+), 35 deletions(-)

New commits:
commit 9f77db09ad0f2de9878697d30aa26b1adac39dbd
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed May 20 19:39:15 2015 +0200

    use new unocrsrs in SwXTableCursor
    
    Change-Id: I7389794f1ca493a1f7e04c7b24d650223443bf7e

diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index 7ea995a..16d840c 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -213,8 +213,6 @@ class SW_DLLPUBLIC SwXTextTableCursor : public SwXTextTableCursor_Base
     SwDepend                aCrsrDepend;
     const SfxItemPropertySet*   m_pPropSet;
 
-protected:
-    virtual ~SwXTextTableCursor();
 public:
     SwXTextTableCursor(SwFrmFmt* pFmt, SwTableBox* pBox);
     SwXTextTableCursor(SwFrmFmt& rTableFmt,
@@ -265,7 +263,8 @@ public:
     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
 
     //SwClient
-   virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+    virtual void SwClientNotify(const SwModify&, const SfxHint&) SAL_OVERRIDE;
 
     // ITextCursorHelper
     virtual const SwPaM*        GetPaM() const SAL_OVERRIDE;
@@ -275,6 +274,7 @@ public:
 
     const SwUnoCrsr*            GetCrsr() const;
     SwUnoCrsr*                  GetCrsr();
+    std::shared_ptr<SwUnoCrsr> m_pUnoCrsr;
     SwFrmFmt*       GetFrmFmt() const { return const_cast<SwFrmFmt*>(static_cast<const SwFrmFmt*>(GetRegisteredIn())); }
 };
 
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index f085dd9..15a09fa 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1419,10 +1419,10 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt* pFmt, SwTableBox* pBox) :
     SwDoc* pDoc = pFmt->GetDoc();
     const SwStartNode* pSttNd = pBox->GetSttNd();
     SwPosition aPos(*pSttNd);
-    SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
-    pUnoCrsr->Move( fnMoveForward, fnGoNode );
-    pUnoCrsr->Add(&aCrsrDepend);
-    SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
+    m_pUnoCrsr = pDoc->CreateUnoCrsr2(aPos, true);
+    m_pUnoCrsr->Move( fnMoveForward, fnGoNode );
+    m_pUnoCrsr->Add(&aCrsrDepend);
+    SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pUnoCrsr.get());
     rTblCrsr.MakeBoxSels();
 }
 
@@ -1431,28 +1431,21 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor*
     aCrsrDepend(this, 0),
     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
 {
-    SwUnoCrsr* pUnoCrsr = pTableSelection->GetDoc()->CreateUnoCrsr(*pTableSelection->GetPoint(), true);
+    m_pUnoCrsr = pTableSelection->GetDoc()->CreateUnoCrsr2(*pTableSelection->GetPoint(), true);
     if(pTableSelection->HasMark())
     {
-        pUnoCrsr->SetMark();
-        *pUnoCrsr->GetMark() = *pTableSelection->GetMark();
+        m_pUnoCrsr->SetMark();
+        *m_pUnoCrsr->GetMark() = *pTableSelection->GetMark();
     }
     const SwSelBoxes& rBoxes = pTableSelection->GetSelectedBoxes();
-    SwTableCursor& rTableCrsr = dynamic_cast<SwTableCursor&>(*pUnoCrsr);
+    SwTableCursor& rTableCrsr = dynamic_cast<SwTableCursor&>(*m_pUnoCrsr);
     for(auto pBox : rBoxes)
         rTableCrsr.InsertBox(*pBox);
-    pUnoCrsr->Add(&aCrsrDepend);
-    SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
+    m_pUnoCrsr->Add(&aCrsrDepend);
+    SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pUnoCrsr);
     rTblCrsr.MakeBoxSels();
 }
 
-SwXTextTableCursor::~SwXTextTableCursor()
-{
-    SolarMutexGuard aGuard;
-    SwUnoCrsr* pUnoCrsr = GetCrsr();
-    delete pUnoCrsr;
-}
-
 OUString SwXTextTableCursor::getRangeName()
     throw (uno::RuntimeException, std::exception)
 {
@@ -1749,6 +1742,17 @@ void SwXTextTableCursor::removeVetoableChangeListener(const OUString& /*rPropert
 void SwXTextTableCursor::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
     { ClientModify(this, pOld, pNew); }
 
+void SwXTextTableCursor::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+    SwClient::SwClientNotify(rModify, rHint);
+    if(m_pUnoCrsr && typeid(rHint) == typeid(sw::DocDisposingHint))
+    {
+        assert(m_pUnoCrsr->m_bSaneOwnership);
+        m_pUnoCrsr->Remove(&aCrsrDepend);
+        m_pUnoCrsr.reset();
+    }
+}
+
 class SwXTextTable::Impl
 {
 private:
commit 0f8e4e1e79fa2474aa242cfb8c4fccd9fea0409c
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed May 20 18:43:53 2015 +0200

    use new unocrsrs in other writer tables
    
    Change-Id: I0cc178da5ca2493cc50bf6582493790d6b4ba536

diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 879c935..f085dd9 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2579,7 +2579,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
                     const SwStartNode* pSttNd = pTLBox->GetSttNd();
                     SwPosition aPos(*pSttNd);
                     // set cursor to top left cell
-                    SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
+                    auto pUnoCrsr(pDoc->CreateUnoCrsr2(aPos, true));
                     pUnoCrsr->Move( fnMoveForward, fnGoNode );
                     pUnoCrsr->SetRemainInSection( false );
 
@@ -2623,7 +2623,6 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
                     aSet.Put(aBoxInfo);
 
                     pDoc->SetTabBorders(rCrsr, aSet);
-                    delete pUnoCrsr;
                 }
                 break;
 
@@ -2769,7 +2768,7 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
                     const SwStartNode* pSttNd = pTLBox->GetSttNd();
                     SwPosition aPos(*pSttNd);
                     // set cursor to top left cell
-                    SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
+                    auto pUnoCrsr(pDoc->CreateUnoCrsr2(aPos, true));
                     pUnoCrsr->Move( fnMoveForward, fnGoNode );
                     pUnoCrsr->SetRemainInSection( false );
 
@@ -2830,7 +2829,6 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
                         aTableBorder.IsDistanceValid        = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
                         aRet <<= aTableBorder;
                     }
-                    delete pUnoCrsr;
                 }
                 break;
 
commit 6ac7410afa9d6aeb7d9f76b036a6308b59bc9118
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed May 20 18:33:26 2015 +0200

    use new unocrsrs in other writer tables
    
    Change-Id: I61d8956135d65676b449637beb9d588cdc83b7d8

diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index ea07cdc..879c935 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3151,7 +3151,7 @@ SwXCellRange::SwXCellRange(std::shared_ptr<SwUnoCrsr> pCrsr, SwFrmFmt& rFrmFmt,
     , m_bFirstRowAsLabel(false)
     , m_bFirstColumnAsLabel(false)
 {
-    assert(m_pTblCrsr->m_bSaneOwnership);
+    //assert(m_pTblCrsr->m_bSaneOwnership);
     aRgDesc.Normalize();
 }
 
@@ -3996,14 +3996,13 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
     SwPosition aPos(*pSttNd);
     // set cursor to the upper-left cell of the range
     UnoActionContext aAction(pFrmFmt->GetDoc());
-    SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
+    auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
     pUnoCrsr->Move( fnMoveForward, fnGoNode );
     {
         // remove actions
         UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
     }
     pFrmFmt->GetDoc()->InsertRow(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
-    delete pUnoCrsr;
 }
 
 void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
@@ -4027,7 +4026,7 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
     const SwStartNode* pSttNd = pTLBox->GetSttNd();
     SwPosition aPos(*pSttNd);
     // set cursor to the upper-left cell of the range
-    SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
+    auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
     pUnoCrsr->Move(fnMoveForward, fnGoNode);
     pUnoCrsr->SetRemainInSection( false );
     const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
@@ -4037,12 +4036,12 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
     pUnoCrsr->SetMark();
     pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd();
     pUnoCrsr->Move(fnMoveForward, fnGoNode);
-    SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+    SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
     pCrsr->MakeBoxSels();
     {   // these braces are important
         UnoActionContext aAction(pFrmFmt->GetDoc());
         pFrmFmt->GetDoc()->DeleteRow(*pUnoCrsr);
-        delete pUnoCrsr;
+        pUnoCrsr.reset();
     }
     {
         // invalidate all actions
@@ -4135,7 +4134,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
     const SwStartNode* pSttNd = pTLBox->GetSttNd();
     SwPosition aPos(*pSttNd);
     UnoActionContext aAction(pFrmFmt->GetDoc());
-    SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
+    auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
     pUnoCrsr->Move(fnMoveForward, fnGoNode);
 
     {
@@ -4144,7 +4143,6 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
     }
 
     pFrmFmt->GetDoc()->InsertCol(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
-    delete pUnoCrsr;
 }
 
 ///@see SwXTableRows::removeByIndex (TODO: seems to be copy and paste programming here)
@@ -4169,7 +4167,7 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
     const SwStartNode* pSttNd = pTLBox->GetSttNd();
     SwPosition aPos(*pSttNd);
     // set cursor to the upper-left cell of the range
-    SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
+    auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
     pUnoCrsr->Move(fnMoveForward, fnGoNode);
     pUnoCrsr->SetRemainInSection(false);
     const OUString sTRName = sw_GetCellName(nIndex + nCount - 1, 0);
@@ -4179,12 +4177,12 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
     pUnoCrsr->SetMark();
     pUnoCrsr->GetPoint()->nNode = *pTRBox->GetSttNd();
     pUnoCrsr->Move(fnMoveForward, fnGoNode);
-    SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+    SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
     pCrsr->MakeBoxSels();
     {   // these braces are important
         UnoActionContext aAction(pFrmFmt->GetDoc());
         pFrmFmt->GetDoc()->DeleteCol(*pUnoCrsr);
-        delete pUnoCrsr;
+        pUnoCrsr.reset();
     }
     {
         // invalidate all actions


More information about the Libreoffice-commits mailing list