[Libreoffice-commits] core.git: 3 commits - sw/inc sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue May 19 08:35:42 PDT 2015
sw/inc/IDocumentDrawModelAccess.hxx | 5 ++
sw/source/core/crsr/findtxt.cxx | 26 ++++++++--
sw/source/core/doc/DocumentDrawModelManager.cxx | 59 ++++++++++++++++++++++++
sw/source/core/inc/DocumentDrawModelManager.hxx | 2
sw/source/uibase/inc/view.hxx | 2
sw/source/uibase/uiview/viewdraw.cxx | 7 ++
6 files changed, 96 insertions(+), 5 deletions(-)
New commits:
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
Change-Id: I028f95029deaebddcacf2730d429ad53abbc79fa
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 200d02b..ba7dcbd 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -37,6 +37,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentState.hxx>
+#include <IDocumentDrawModelAccess.hxx>
#include <pamtyp.hxx>
#include <ndtxt.hxx>
#include <swundo.hxx>
@@ -244,7 +245,8 @@ bool SwPaM::Find( const SearchOptions& rSearchOpt, bool bSearchInNotes , utl::Te
{
if( pNode->IsTxtNode() )
{
- sal_Int32 nTxtLen = pNode->GetTxtNode()->GetTxt().getLength();
+ SwTxtNode& rTxtNode = *pNode->GetTxtNode();
+ sal_Int32 nTxtLen = rTxtNode.GetTxt().getLength();
sal_Int32 nEnd;
if( rNdIdx == pPam->GetMark()->nNode )
nEnd = pPam->GetMark()->nContent.GetIndex();
@@ -256,7 +258,7 @@ bool SwPaM::Find( const SearchOptions& rSearchOpt, bool bSearchInNotes , utl::Te
// if there are SwPostItFields inside our current node text, we
// split the text into separate pieces and search for text inside
// the pieces as well as inside the fields
- const SwpHints *pHts = pNode->GetTxtNode()->GetpSwpHints();
+ const SwpHints *pHts = rTxtNode.GetpSwpHints();
// count PostItFields by looping over all fields
sal_Int32 aNumberPostits = 0;
@@ -295,14 +297,15 @@ bool SwPaM::Find( const SearchOptions& rSearchOpt, bool bSearchInNotes , utl::Te
SwViewShell *const pWrtShell = (pDocShell) ? pDocShell->GetEditShell() : 0;
SwPostItMgr *const pPostItMgr = (pWrtShell) ? pWrtShell->GetPostItMgr() : 0;
+ SvxSearchItem aSearchItem(SID_SEARCH_ITEM);
+ aSearchItem.SetSearchOptions(rSearchOpt);
+ aSearchItem.SetBackward(!bSrchForward);
+
// If there is an active text edit, then search there.
if (SdrView* pSdrView = pWrtShell->GetDrawView())
{
if (pSdrView->GetTextEditObject())
{
- SvxSearchItem aSearchItem(SID_SEARCH_ITEM);
- aSearchItem.SetSearchOptions(rSearchOpt);
- aSearchItem.SetBackward(!bSrchForward);
sal_uInt16 nResult = pSdrView->GetTextEditOutlinerView()->StartSearchAndReplace(aSearchItem);
if (!nResult)
{
@@ -318,6 +321,19 @@ bool SwPaM::Find( const SearchOptions& rSearchOpt, bool bSearchInNotes , utl::Te
}
}
+ // If there are any shapes anchored to this node, search there.
+ SwPaM aPaM(pNode->GetDoc()->GetNodes().GetEndOfContent());
+ aPaM.GetPoint()->nNode = rTxtNode;
+ aPaM.GetPoint()->nContent.Assign(aPaM.GetPoint()->nNode.GetNode().GetTxtNode(), nStart);
+ aPaM.SetMark();
+ aPaM.GetMark()->nNode = rTxtNode.GetIndex() + 1;
+ aPaM.GetMark()->nContent.Assign(aPaM.GetMark()->nNode.GetNode().GetTxtNode(), 0);
+ if (pNode->GetDoc()->getIDocumentDrawModelAccess().Search(aPaM, aSearchItem))
+ {
+ bFound = true;
+ break;
+ }
+
sal_Int32 aStart = 0;
// do we need to finish a note?
if (pPostItMgr && pPostItMgr->HasActiveSidebarWin())
commit b97fb340b23e1b6a48c5c95c8d42e9f10ece1748
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue May 19 17:19:14 2015 +0200
Add sw::DocumentDrawModelManager::Search()
Change-Id: Idcbbb9e049f0fbc5d6503b86fd506df9fb2ad3c5
diff --git a/sw/inc/IDocumentDrawModelAccess.hxx b/sw/inc/IDocumentDrawModelAccess.hxx
index 7cf0b86..a8b5ba2 100644
--- a/sw/inc/IDocumentDrawModelAccess.hxx
+++ b/sw/inc/IDocumentDrawModelAccess.hxx
@@ -23,7 +23,9 @@
#include <svx/svdtypes.hxx>
class SwDrawModel;
+class SwPaM;
class SdrPageView;
+class SvxSearchItem;
class IDocumentDrawModelAccess
{
@@ -89,6 +91,9 @@ public:
*/
virtual SdrLayerID GetInvisibleLayerIdByVisibleOne( const SdrLayerID& _nVisibleLayerId ) = 0;
+ /// Searches text in shapes anchored inside rPaM.
+ virtual bool Search(const SwPaM& rPaM, const SvxSearchItem& rSearchItem) = 0;
+
protected:
virtual ~IDocumentDrawModelAccess() {};
diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx b/sw/source/core/doc/DocumentDrawModelManager.cxx
index 5cb1e0d..bed970f 100644
--- a/sw/source/core/doc/DocumentDrawModelManager.cxx
+++ b/sw/source/core/doc/DocumentDrawModelManager.cxx
@@ -26,11 +26,15 @@
#include <IDocumentLinksAdministration.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <docsh.hxx>
+#include <wrtsh.hxx>
#include <swtypes.hxx>
+#include <ndtxt.hxx>
#include <swhints.hxx>
#include <viewsh.hxx>
+#include <view.hxx>
#include <drawdoc.hxx>
#include <rootfrm.hxx>
+#include <fmtanchr.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <svx/svdmodel.hxx>
@@ -38,7 +42,9 @@
#include <svx/svdoutl.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdpagv.hxx>
+#include <svx/svdotext.hxx>
#include <svl/smplhint.hxx>
+#include <svl/srchitem.hxx>
#include <tools/link.hxx>
class SdrOutliner;
@@ -364,6 +370,59 @@ SdrLayerID DocumentDrawModelManager::GetInvisibleLayerIdByVisibleOne( const SdrL
return nInvisibleLayerId;
}
+bool DocumentDrawModelManager::Search(const SwPaM& rPaM, const SvxSearchItem& rSearchItem)
+{
+ SwPosFlyFrms aFrames = m_rDoc.GetAllFlyFmts(&rPaM, /*bDrawAlso=*/true);
+
+ for (const SwPosFlyFrmPtr& pPosFlyFrm : aFrames)
+ {
+ // Filter for at-paragraph anchored draw frames.
+ const SwFrmFmt& rFrmFmt = pPosFlyFrm->GetFmt();
+ const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor();
+ if (rAnchor.GetAnchorId() != FLY_AT_PARA || rFrmFmt.Which() != RES_DRAWFRMFMT)
+ continue;
+
+ // Does the shape have matching text?
+ SdrOutliner& rOutliner = GetDrawModel()->GetDrawOutliner();
+ SdrObject* pObject = const_cast<SdrObject*>(rFrmFmt.FindSdrObject());
+ SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObject);
+ if (!pTextObj)
+ continue;
+ const OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
+ if (!pParaObj)
+ continue;
+ rOutliner.SetText(*pParaObj);
+ SwDocShell* pDocShell = m_rDoc.GetDocShell();
+ if (!pDocShell)
+ return false;
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ if (!pWrtShell)
+ return false;
+ if (!rOutliner.HasText(rSearchItem))
+ continue;
+
+ // If so, then select highlight the search result.
+ pWrtShell->SelectObj(Point(), 0, pObject);
+ SwView* pView = pDocShell->GetView();
+ if (!pView)
+ return false;
+ if (!pView->EnterShapeDrawTextMode(pObject))
+ continue;
+ SdrView* pSdrView = pWrtShell->GetDrawView();
+ if (!pSdrView)
+ return false;
+ OutlinerView* pOutlinerView = pSdrView->GetTextEditOutlinerView();
+ if (!rSearchItem.GetBackward())
+ pOutlinerView->SetSelection(ESelection(0, 0, 0, 0));
+ else
+ pOutlinerView->SetSelection(ESelection(EE_PARA_MAX_COUNT, EE_TEXTPOS_MAX_COUNT, EE_PARA_MAX_COUNT, EE_TEXTPOS_MAX_COUNT));
+ pOutlinerView->StartSearchAndReplace(rSearchItem);
+ return true;
+ }
+
+ return false;
+}
+
void DocumentDrawModelManager::DrawNotifyUndoHdl()
{
mpDrawModel->SetNotifyUndoActionHdl( Link<>() );
diff --git a/sw/source/core/inc/DocumentDrawModelManager.hxx b/sw/source/core/inc/DocumentDrawModelManager.hxx
index b87b06f..32656a8 100644
--- a/sw/source/core/inc/DocumentDrawModelManager.hxx
+++ b/sw/source/core/inc/DocumentDrawModelManager.hxx
@@ -63,6 +63,8 @@ public:
virtual SdrLayerID GetInvisibleLayerIdByVisibleOne( const SdrLayerID& _nVisibleLayerId ) SAL_OVERRIDE;
+ virtual bool Search(const SwPaM& rPaM, const SvxSearchItem& rSearchItem) SAL_OVERRIDE;
+
virtual ~DocumentDrawModelManager() {}
private:
commit 0549f250aac361075287d8acae9b7ee73c66256d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue May 19 17:18:19 2015 +0200
Add SwView::EnterShapeDrawTextMode()
Change-Id: Ic19519ee727bd4b6c18d14dc3eb21b2eeb4395c9
diff --git a/sw/source/uibase/inc/view.hxx b/sw/source/uibase/inc/view.hxx
index c89d330..9d6a9b2 100644
--- a/sw/source/uibase/inc/view.hxx
+++ b/sw/source/uibase/inc/view.hxx
@@ -556,6 +556,8 @@ public:
inline void FlipDrawSelMode() { m_bDrawSelMode = !m_bDrawSelMode; }
void NoRotate(); // turn off rotate mode
bool EnterDrawTextMode(const Point& aDocPos);
+ /// Same as EnterDrawTextMode(), but takes an SdrObject instead of guessing it by document position.
+ bool EnterShapeDrawTextMode(SdrObject* pObject);
void LeaveDrawCreate() { m_nDrawSfxId = m_nFormSfxId = USHRT_MAX; m_sDrawCustom.clear();}
bool IsDrawMode() { return (m_nDrawSfxId != USHRT_MAX || m_nFormSfxId != USHRT_MAX); }
bool IsFormMode() const;
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx
index 51e0376..38c405f 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -504,6 +504,13 @@ bool SwView::EnterDrawTextMode(const Point& aDocPos)
return bReturn;
}
+bool SwView::EnterShapeDrawTextMode(SdrObject* pObject)
+{
+ SdrView* pSdrView = GetWrtShell().GetDrawView();
+ SdrPageView* pPageView = pSdrView->GetSdrPageView();
+ return BeginTextEdit(pObject, pPageView, m_pEditWin);
+}
+
// Enable DrawTextEditMode
bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin,
More information about the Libreoffice-commits
mailing list