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

Caolán McNamara caolanm at redhat.com
Tue Jul 12 14:54:47 UTC 2016


 sw/source/core/crsr/findtxt.cxx |   48 +++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

New commits:
commit 46b52c22bfb6b145af3c8407fd96321381e78d99
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jul 12 15:45:22 2016 +0100

    Resolves: tdf#100538 make searching in shape text a libreoffice-kit only thing
    
    This effectively reverts for the normal-app
    
    commit bdc1824ea7acfa2fe9d71cdbe57882acce155577
    Author: Miklos Vajna <vmiklos at collabora.co.uk>
    Date:   Tue May 19 17:20:10 2015 +0200
    
        SwPaM::Find: search in shapes anchored to the range
    
    The catches are that...
    
    writer will use SvxSearchCmd::Find and not SvxSearchCmd::Replace when Replacing
    text, and replacing it afterwards. So replace doesn't work. It might be possible
    to mitigate that by passing down the m_bReplace to SwPam::Find and do a
    SvxSearchCmd::Replace on the editeng SearchAndReplace in that case and then change
    the return code to not-found/found-in-writer/found-in-drawing to figure out what
    to do there.
    
    regexps are disabled in the ui for draw/impress, maybe because they seem not be fully
    implemented right wrt matching empty paragraphs, so using regexps in writer and
    letting them into editeng via this loophole is new territory for the editengine
    
    I think if I was trying this I'd fix regexp in editengine, then try add
    searching/replacing in drawing boxes sort of at the end of searching in the
    main document, something like how searching in frames works.
    
    Change-Id: I2875b374a7ede8edd7f479254cbc2da36488abc8

diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 0011605..d37756f 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -21,6 +21,7 @@
 
 #include <com/sun/star/util/SearchOptions2.hpp>
 #include <com/sun/star/util/SearchFlags.hpp>
+#include <comphelper/lok.hxx>
 #include <comphelper/string.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/window.hxx>
@@ -343,33 +344,36 @@ bool SwPaM::Find( const SearchOptions2& rSearchOpt, bool bSearchInNotes , utl::T
                 }
             }
 
-            // Writer and editeng selections are not supported in parallel.
-            SvxSearchItem* pSearchItem = SwView::GetSearchItem();
-            // If we just finished search in shape text, don't attempt to do that again.
-            if (!bEndedTextEdit && !(pSearchItem && pSearchItem->GetCommand() == SvxSearchCmd::FIND_ALL))
+            if (comphelper::LibreOfficeKit::isActive())
             {
-                // If there are any shapes anchored to this node, search there.
-                SwPaM aPaM(pNode->GetDoc()->GetNodes().GetEndOfContent());
-                aPaM.GetPoint()->nNode = rTextNode;
-                aPaM.GetPoint()->nContent.Assign(aPaM.GetPoint()->nNode.GetNode().GetTextNode(), nStart);
-                aPaM.SetMark();
-                aPaM.GetMark()->nNode = rTextNode.GetIndex() + 1;
-                aPaM.GetMark()->nContent.Assign(aPaM.GetMark()->nNode.GetNode().GetTextNode(), 0);
-                if (pNode->GetDoc()->getIDocumentDrawModelAccess().Search(aPaM, aSearchItem) && pSdrView)
+                // Writer and editeng selections are not supported in parallel.
+                SvxSearchItem* pSearchItem = SwView::GetSearchItem();
+                // If we just finished search in shape text, don't attempt to do that again.
+                if (!bEndedTextEdit && !(pSearchItem && pSearchItem->GetCommand() == SvxSearchCmd::FIND_ALL))
                 {
-                    if (SdrObject* pObject = pSdrView->GetTextEditObject())
+                    // If there are any shapes anchored to this node, search there.
+                    SwPaM aPaM(pNode->GetDoc()->GetNodes().GetEndOfContent());
+                    aPaM.GetPoint()->nNode = rTextNode;
+                    aPaM.GetPoint()->nContent.Assign(aPaM.GetPoint()->nNode.GetNode().GetTextNode(), nStart);
+                    aPaM.SetMark();
+                    aPaM.GetMark()->nNode = rTextNode.GetIndex() + 1;
+                    aPaM.GetMark()->nContent.Assign(aPaM.GetMark()->nNode.GetNode().GetTextNode(), 0);
+                    if (pNode->GetDoc()->getIDocumentDrawModelAccess().Search(aPaM, aSearchItem) && pSdrView)
                     {
-                        if (SwFrameFormat* pFrameFormat = FindFrameFormat(pObject))
+                        if (SdrObject* pObject = pSdrView->GetTextEditObject())
                         {
-                            const SwPosition* pPosition = pFrameFormat->GetAnchor().GetContentAnchor();
-                            if (pPosition)
+                            if (SwFrameFormat* pFrameFormat = FindFrameFormat(pObject))
                             {
-                                // Set search position to the shape's anchor point.
-                                *GetPoint() = *pPosition;
-                                GetPoint()->nContent.Assign(pPosition->nNode.GetNode().GetContentNode(), 0);
-                                SetMark();
-                                bFound = true;
-                                break;
+                                const SwPosition* pPosition = pFrameFormat->GetAnchor().GetContentAnchor();
+                                if (pPosition)
+                                {
+                                    // Set search position to the shape's anchor point.
+                                    *GetPoint() = *pPosition;
+                                    GetPoint()->nContent.Assign(pPosition->nNode.GetNode().GetContentNode(), 0);
+                                    SetMark();
+                                    bFound = true;
+                                    break;
+                                }
                             }
                         }
                     }


More information about the Libreoffice-commits mailing list