[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - 2 commits - sw/inc sw/source

Oliver-Rainer Wittmann orw at apache.org
Tue Jun 17 03:51:11 PDT 2014


 sw/inc/txtfld.hxx                        |   10 +++++++++
 sw/source/core/txtnode/atrfld.cxx        |   34 +++++++++++++++++++++++++++++++
 sw/source/core/unocore/unofield.cxx      |   24 ++++++++-------------
 sw/source/ui/dbui/mmaddressblockpage.cxx |    1 
 4 files changed, 54 insertions(+), 15 deletions(-)

New commits:
commit 47bf6ae2d0618313f75dcd7ac73c72dbd218c242
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Mon Jun 16 12:01:46 2014 +0000

    Resolves: #i125086# correct implementation of css::text::XTextField...
    
    in Writer to reflect changes made for the in-place editing of Input Fields
    
    (cherry picked from commit 90b633455a6e54300330e68e71e22e729b445f31)
    
    Conflicts:
    	sw/source/core/txtnode/atrfld.cxx
    	sw/source/core/unocore/unofield.cxx
    
    Change-Id: I39de2b5074c2e7d8671ad2c0a3c01a29ccfc7882
    (cherry picked from commit 41d43bc95b64e1907709141fcd8b6ce08b0841c8)

diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx
index 7ce306e..b4d32cd 100644
--- a/sw/inc/txtfld.hxx
+++ b/sw/inc/txtfld.hxx
@@ -22,6 +22,9 @@
 #include <txatbase.hxx>
 #include <rtl/ustring.hxx>
 
+#include <boost/shared_ptr.hpp>
+
+class SwPaM;
 class SwTxtNode;
 
 // ATT_FLD ***********************************
@@ -68,6 +71,13 @@ public:
     // enable notification that field content has changed and needs reformatting
     virtual void NotifyContentChange( SwFmtFld& rFmtFld );
 
+    // deletes the given field via removing the corresponding text selection from the document's content
+    static void DeleteTxtFld( const SwTxtFld& rTxtFld );
+
+    // return text selection for the given field
+    static void GetPamForTxtFld( const SwTxtFld& rTxtFld,
+                                 boost::shared_ptr< SwPaM >& rPamForTxtFld );
+
 };
 
 class SwTxtInputFld : public SwTxtFld
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index faf2b81..ae65c36 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -431,6 +431,40 @@ void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld)
     }
 }
 
+/*static*/
+void SwTxtFld::GetPamForTxtFld(
+    const SwTxtFld& rTxtFld,
+    boost::shared_ptr< SwPaM >& rPamForTxtFld )
+{
+    if (rTxtFld.GetpTxtNode() == NULL)
+    {
+        SAL_WARN("sw.core", "<SwTxtFld::GetPamForField> - missing <SwTxtNode>");
+        return;
+    }
+
+    const SwTxtNode& rTxtNode = rTxtFld.GetTxtNode();
+
+    rPamForTxtFld.reset( new SwPaM( rTxtNode,
+                                    ( (rTxtFld.End() != NULL) ? *(rTxtFld.End()) : ( *(rTxtFld.GetStart()) + 1 ) ),
+                                    rTxtNode,
+                                    *(rTxtFld.GetStart()) ) );
+
+}
+
+/*static*/
+void SwTxtFld::DeleteTxtFld( const SwTxtFld& rTxtFld )
+{
+    if (rTxtFld.GetpTxtNode() != NULL)
+    {
+        boost::shared_ptr< SwPaM > pPamForTxtFld;
+        GetPamForTxtFld(rTxtFld, pPamForTxtFld);
+        if (pPamForTxtFld.get() != NULL)
+        {
+            rTxtFld.GetTxtNode().GetDoc()->DeleteAndJoin(*pPamForTxtFld);
+        }
+    }
+}
+
 // input field in-place editing
 SwTxtInputFld::SwTxtInputFld(
     SwFmtFld & rAttr,
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 2ef5ecb..3043353 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -976,15 +976,10 @@ throw (uno::RuntimeException, std::exception)
     SwFmtFld* pFld = aIter.First();
     while(pFld)
     {
-        // Feld im Undo?
         SwTxtFld *pTxtFld = pFld->GetTxtFld();
         if(pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
         {
-            SwTxtNode& rTxtNode = (SwTxtNode&)*pTxtFld->GetpTxtNode();
-            SwPaM aPam(rTxtNode, *pTxtFld->GetStart());
-            aPam.SetMark();
-            aPam.Move();
-            m_pImpl->m_pDoc->DeleteAndJoin(aPam);
+            SwTxtFld::DeleteTxtFld(*pTxtFld);
         }
         pFld = aIter.Next();
     }
@@ -2035,12 +2030,14 @@ SwXTextField::getAnchor() throw (uno::RuntimeException, std::exception)
     const SwTxtFld* pTxtFld = m_pImpl->m_pFmtFld->GetTxtFld();
     if (!pTxtFld)
         throw uno::RuntimeException();
-    const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
 
-    SwPaM aPam(rTxtNode, *pTxtFld->GetStart() + 1, rTxtNode, *pTxtFld->GetStart());
+    boost::shared_ptr< SwPaM > pPamForTxtFld;
+    SwTxtFld::GetPamForTxtFld(*pTxtFld, pPamForTxtFld);
+    if (pPamForTxtFld.get() == NULL)
+        return 0;
 
     uno::Reference<text::XTextRange> xRange = SwXTextRange::CreateXTextRange(
-            *m_pImpl->m_pDoc, *aPam.GetPoint(), aPam.GetMark());
+            *m_pImpl->m_pDoc, *(pPamForTxtFld->GetPoint()), pPamForTxtFld->GetMark());
     return xRange;
 }
 
@@ -2051,12 +2048,9 @@ void SAL_CALL SwXTextField::dispose() throw (uno::RuntimeException, std::excepti
     if(pField)
     {
         UnoActionContext aContext(m_pImpl->m_pDoc);
-        const SwTxtFld* pTxtFld = m_pImpl->m_pFmtFld->GetTxtFld();
-        SwTxtNode& rTxtNode = (SwTxtNode&)*pTxtFld->GetpTxtNode();
-        SwPaM aPam(rTxtNode, *pTxtFld->GetStart());
-        aPam.SetMark();
-        aPam.Move();
-        m_pImpl->m_pDoc->DeleteAndJoin(aPam);
+
+        assert(m_pImpl->m_pFmtFld->GetTxtFld() && "<SwXTextField::dispose()> - missing <SwTxtFld> --> crash");
+        SwTxtFld::DeleteTxtFld(*(m_pImpl->m_pFmtFld->GetTxtFld()));
     }
 
     if (m_pImpl->m_pTextObject)
commit 0c89f37b75804f9e3cc3fbd3d85dc8c4cb899773
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Jun 16 16:42:01 2014 +0100

    missing SetForbiddenChars call
    
    Change-Id: I03a26d49210c3dfe89abd31e5c754fafe2b7acee
    (cherry picked from commit f219ec6b5e09b55466ce313d73929670cf11a989)

diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index a548b28..1d8814b 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -509,6 +509,7 @@ SwCustomizeAddressBlockDialog::SwCustomizeAddressBlockDialog(
     get(m_pOK, "ok");
     get(m_pPreviewWIN, "addrpreview");
     get(m_pFieldCB, "custom");
+    m_pFieldCB->SetForbiddenChars("<>");
     get(m_pFieldFT, "customft");
     get(m_pDownIB, "down");
     get(m_pRightIB, "right");


More information about the Libreoffice-commits mailing list