Kaydet (Commit) b97fb340 authored tarafından Miklos Vajna's avatar Miklos Vajna

Add sw::DocumentDrawModelManager::Search()

Change-Id: Idcbbb9e049f0fbc5d6503b86fd506df9fb2ad3c5
üst 0549f250
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
#include <svx/svdtypes.hxx> #include <svx/svdtypes.hxx>
class SwDrawModel; class SwDrawModel;
class SwPaM;
class SdrPageView; class SdrPageView;
class SvxSearchItem;
class IDocumentDrawModelAccess class IDocumentDrawModelAccess
{ {
...@@ -89,6 +91,9 @@ public: ...@@ -89,6 +91,9 @@ public:
*/ */
virtual SdrLayerID GetInvisibleLayerIdByVisibleOne( const SdrLayerID& _nVisibleLayerId ) = 0; 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: protected:
virtual ~IDocumentDrawModelAccess() {}; virtual ~IDocumentDrawModelAccess() {};
......
...@@ -26,11 +26,15 @@ ...@@ -26,11 +26,15 @@
#include <IDocumentLinksAdministration.hxx> #include <IDocumentLinksAdministration.hxx>
#include <IDocumentLayoutAccess.hxx> #include <IDocumentLayoutAccess.hxx>
#include <docsh.hxx> #include <docsh.hxx>
#include <wrtsh.hxx>
#include <swtypes.hxx> #include <swtypes.hxx>
#include <ndtxt.hxx>
#include <swhints.hxx> #include <swhints.hxx>
#include <viewsh.hxx> #include <viewsh.hxx>
#include <view.hxx>
#include <drawdoc.hxx> #include <drawdoc.hxx>
#include <rootfrm.hxx> #include <rootfrm.hxx>
#include <fmtanchr.hxx>
#include <editeng/eeitem.hxx> #include <editeng/eeitem.hxx>
#include <editeng/fhgtitem.hxx> #include <editeng/fhgtitem.hxx>
#include <svx/svdmodel.hxx> #include <svx/svdmodel.hxx>
...@@ -38,7 +42,9 @@ ...@@ -38,7 +42,9 @@
#include <svx/svdoutl.hxx> #include <svx/svdoutl.hxx>
#include <svx/svdpage.hxx> #include <svx/svdpage.hxx>
#include <svx/svdpagv.hxx> #include <svx/svdpagv.hxx>
#include <svx/svdotext.hxx>
#include <svl/smplhint.hxx> #include <svl/smplhint.hxx>
#include <svl/srchitem.hxx>
#include <tools/link.hxx> #include <tools/link.hxx>
class SdrOutliner; class SdrOutliner;
...@@ -364,6 +370,59 @@ SdrLayerID DocumentDrawModelManager::GetInvisibleLayerIdByVisibleOne( const SdrL ...@@ -364,6 +370,59 @@ SdrLayerID DocumentDrawModelManager::GetInvisibleLayerIdByVisibleOne( const SdrL
return nInvisibleLayerId; 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() void DocumentDrawModelManager::DrawNotifyUndoHdl()
{ {
mpDrawModel->SetNotifyUndoActionHdl( Link<>() ); mpDrawModel->SetNotifyUndoActionHdl( Link<>() );
......
...@@ -63,6 +63,8 @@ public: ...@@ -63,6 +63,8 @@ public:
virtual SdrLayerID GetInvisibleLayerIdByVisibleOne( const SdrLayerID& _nVisibleLayerId ) SAL_OVERRIDE; virtual SdrLayerID GetInvisibleLayerIdByVisibleOne( const SdrLayerID& _nVisibleLayerId ) SAL_OVERRIDE;
virtual bool Search(const SwPaM& rPaM, const SvxSearchItem& rSearchItem) SAL_OVERRIDE;
virtual ~DocumentDrawModelManager() {} virtual ~DocumentDrawModelManager() {}
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment