summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-23 11:24:24 -0400
committerEike Rathke <erack@redhat.com>2014-05-23 15:47:59 -0500
commitdbbbf51bcc54e99611e809d4615be1d9f110d01a (patch)
tree628630337ef4beb350d9c409f4f285ce1d63a449
parent9d8f8074edbb63db467cc451c0596585e2f0422c (diff)
fdo#79011: Properly implement the search results dialog as modeless.
It's unfortunate that adding a modeless dialog is such a pain. But we still need to implemenet this properly else we'll leak at best, or end up with tons of weird bugs at worst. (cherry picked from commit 81c492ef18b04cc283561018d69818cbca7f83ef) Conflicts: sc/inc/sc.hrc sc/sdi/cellsh.sdi sc/sdi/scalc.sdi sc/source/ui/view/cellsh1.cxx sc/source/ui/view/tabvwsh.cxx Change-Id: Ie03260f288fad76f994d0ca6a8b1feeade299ffd Reviewed-on: https://gerrit.libreoffice.org/9451 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/inc/sc.hrc1
-rw-r--r--sc/sdi/cellsh.sdi1
-rw-r--r--sc/sdi/scalc.sdi25
-rw-r--r--sc/source/ui/app/scdll.cxx2
-rw-r--r--sc/source/ui/dialogs/searchresults.cxx68
-rw-r--r--sc/source/ui/inc/searchresults.hxx34
-rw-r--r--sc/source/ui/view/cellsh1.cxx15
-rw-r--r--sc/source/ui/view/tabvwsh.cxx3
-rw-r--r--sc/source/ui/view/viewfun2.cxx14
9 files changed, 144 insertions, 19 deletions
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 4c72f1cb9ce4..8e517ae952c6 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -267,6 +267,7 @@
#define SID_COVARIANCE_DIALOG (SC_MESSAGE_START + 75)
#define SID_EXPONENTIAL_SMOOTHING_DIALOG (SC_MESSAGE_START + 76)
#define SID_MOVING_AVERAGE_DIALOG (SC_MESSAGE_START + 77)
+#define SID_SEARCH_RESULTS_DIALOG (SC_MESSAGE_START + 78)
// functions
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index 2fe1237c570b..41d57bc7979e 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -158,6 +158,7 @@ interface CellSelection
SID_COVARIANCE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_EXPONENTIAL_SMOOTHING_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_MOVING_AVERAGE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
+ SID_SEARCH_RESULTS_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_SETINPUTMODE [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index f4bba08a2c1e..18e548361c04 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -3159,7 +3159,30 @@ SfxVoidItem SolverDialog SID_OPENDLG_OPTSOLVER
GroupId = GID_OPTIONS;
]
-//--------------------------------------------------------------------------
+SfxVoidItem SearchResultsDialog SID_SEARCH_RESULTS_DIALOG
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = TRUE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_OPTIONS;
+]
+
SfxVoidItem ValidityReference SID_VALIDITY_REFERENCE
()
[
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index 84f5823ca461..0cd68ffae2ca 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -73,6 +73,7 @@
#include "docpool.hxx"
#include "appoptio.hxx"
+#include <searchresults.hxx>
// Controls
@@ -291,6 +292,7 @@ void ScDLL::Init()
ScSpellDialogChildWindow ::RegisterChildWindow(false, pMod);
ScValidityRefChildWin::RegisterChildWindow(false, pMod);
+ sc::SearchResultsDlgWrapper::RegisterChildWindow(false, pMod);
// Edit-Engine-Felder, soweit nicht schon in OfficeApplication::Init
diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx
index 3b27a2a91ea5..1f8ee016d292 100644
--- a/sc/source/ui/dialogs/searchresults.cxx
+++ b/sc/source/ui/dialogs/searchresults.cxx
@@ -11,14 +11,19 @@
#include <svtools/simptabl.hxx>
#include <svtools/treelistentry.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
#include "dociter.hxx"
#include "document.hxx"
#include "rangeutl.hxx"
#include "tabvwsh.hxx"
+#include <sc.hrc>
-SearchResults::SearchResults(ScDocument *pDoc) :
- ModelessDialog(NULL, "SearchResultsDialog", "modules/scalc/ui/searchresults.ui")
- , mpDoc(pDoc)
+namespace sc {
+
+SearchResultsDlg::SearchResultsDlg( SfxBindings* _pBindings, Window* pParent, sal_uInt16 nId ) :
+ ModelessDialog(pParent, "SearchResultsDialog", "modules/scalc/ui/searchresults.ui"),
+ mpBindings(_pBindings), mnId(nId), mpDoc(NULL)
{
SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("results");
Size aControlSize(150, 120);
@@ -30,36 +35,56 @@ SearchResults::SearchResults(ScDocument *pDoc) :
long nTabs[] = {3, 0, 40, 60};
mpList->SetTabs(&nTabs[0]);
mpList->InsertHeaderEntry("Sheet\tCell\tContent");
- mpList->SetSelectHdl( LINK(this, SearchResults, ListSelectHdl) );
+ mpList->SetSelectHdl( LINK(this, SearchResultsDlg, ListSelectHdl) );
}
-SearchResults::~SearchResults()
+SearchResultsDlg::~SearchResultsDlg()
{
delete mpList;
}
-void SearchResults::Show(const ScRangeList &rMatchedRanges)
+void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatchedRanges )
{
mpList->Clear();
mpList->SetUpdateMode(false);
for (size_t i = 0, n = rMatchedRanges.size(); i < n; ++i)
{
- ScCellIterator aIter(mpDoc, *rMatchedRanges[i]);
+ ScCellIterator aIter(pDoc, *rMatchedRanges[i]);
for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
ScAddress aAddress = aIter.GetPos();
OUString sAddress;
ScRangeStringConverter::GetStringFromAddress(sAddress, aAddress,
- mpDoc, formula::FormulaGrammar::CONV_OOO);
- mpList->InsertEntry(sAddress.replace('.', '\t') + "\t" + mpDoc->GetString(aAddress));
+ pDoc, formula::FormulaGrammar::CONV_OOO);
+ mpList->InsertEntry(sAddress.replace('.', '\t') + "\t" + pDoc->GetString(aAddress));
}
}
mpList->SetUpdateMode(true);
- ModelessDialog::Show();
+
+ mpDoc = pDoc;
+}
+
+sal_Bool SearchResultsDlg::Close()
+{
+ if (mpBindings)
+ {
+ // Remove this dialog from the view frame after the dialog gets
+ // dismissed, else it would keep popping up endlessly!
+ SfxDispatcher* pDispacher = mpBindings ->GetDispatcher();
+ SfxBoolItem aItem(SID_SEARCH_RESULTS_DIALOG, false);
+ if (pDispacher)
+ pDispacher->Execute(
+ SID_SEARCH_RESULTS_DIALOG, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L);
+ }
+
+ return ModelessDialog::Close();
}
-IMPL_LINK_NOARG( SearchResults, ListSelectHdl )
+IMPL_LINK_NOARG( SearchResultsDlg, ListSelectHdl )
{
+ if (!mpDoc)
+ return 0;
+
SvTreeListEntry *pEntry = mpList->FirstSelected();
ScAddress aAddress;
sal_Int32 nOffset = 0;
@@ -70,7 +95,28 @@ IMPL_LINK_NOARG( SearchResults, ListSelectHdl )
pScViewShell->SetTabNo(aAddress.Tab());
pScViewShell->SetCursor(aAddress.Col(), aAddress.Row());
pScViewShell->AlignToCursor(aAddress.Col(), aAddress.Row(), SC_FOLLOW_JUMP);
+
return 0;
}
+SearchResultsDlgWrapper::SearchResultsDlgWrapper(
+ Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* /*pInfo*/ ) :
+ SfxChildWindow(_pParent, nId)
+{
+ pWindow = new SearchResultsDlg(pBindings, _pParent, nId);
+}
+
+SearchResultsDlgWrapper::~SearchResultsDlgWrapper() {}
+
+SfxChildWinInfo SearchResultsDlgWrapper::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+ aInfo.bVisible = false;
+ return aInfo;
+}
+
+SFX_IMPL_CHILDWINDOW_WITHID(SearchResultsDlgWrapper, SID_SEARCH_RESULTS_DIALOG);
+
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/searchresults.hxx b/sc/source/ui/inc/searchresults.hxx
index a5f01a0c5bab..ad799f655f46 100644
--- a/sc/source/ui/inc/searchresults.hxx
+++ b/sc/source/ui/inc/searchresults.hxx
@@ -11,21 +11,45 @@
#define SC_UI_SEARCHRESULTS_HXX
#include <vcl/dialog.hxx>
+#include <sfx2/childwin.hxx>
+
class ScDocument;
class ScRangeList;
class SvSimpleTable;
-class SearchResults : public ModelessDialog
+namespace sc {
+
+class SearchResultsDlg : public ModelessDialog
{
- ScDocument *mpDoc;
SvSimpleTable *mpList;
+ SfxBindings* mpBindings;
+ sal_uInt16 mnId;
+
+ ScDocument* mpDoc;
+
DECL_LINK( ListSelectHdl, void * );
public:
- SearchResults(ScDocument *);
- virtual ~SearchResults();
- void Show(const ScRangeList &);
+ SearchResultsDlg( SfxBindings* _pBindings, Window* pParent, sal_uInt16 nId );
+ virtual ~SearchResultsDlg();
+
+ void FillResults( ScDocument* pDoc, const ScRangeList& rMatchedRanges );
+
+ virtual sal_Bool Close();
};
+class SearchResultsDlgWrapper : public SfxChildWindow
+{
+public:
+ SearchResultsDlgWrapper(
+ Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo );
+
+ virtual ~SearchResultsDlgWrapper();
+
+ SFX_DECL_CHILDWINDOW_WITHID(SearchResultsDlgWrapper);
+};
+
+}
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 5b3c6b9f5dd8..288a0a0c2ae1 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -79,6 +79,7 @@
#include "scui_def.hxx"
#include <svx/dialogs.hrc>
#include "scabstdlg.hxx"
+#include <searchresults.hxx>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
@@ -974,6 +975,20 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
}
break;
+ case SID_SEARCH_RESULTS_DIALOG:
+ {
+ const SfxPoolItem* pItem = NULL;
+ if (pReqArgs->HasItem(SID_SEARCH_RESULTS_DIALOG, &pItem))
+ {
+ bool bVisible = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ // The window ID should equal the slot ID, but not a biggie if it wasn't.
+ sal_uInt16 nId = sc::SearchResultsDlgWrapper::GetChildWindowId();
+ pViewFrm->SetChildWindow(nId, bVisible, false);
+ }
+ rReq.Done();
+ }
+ break;
//
// disposal (Outlines)
diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx
index 0298764b8088..16f2b65f51e9 100644
--- a/sc/source/ui/view/tabvwsh.cxx
+++ b/sc/source/ui/view/tabvwsh.cxx
@@ -20,6 +20,7 @@
#include "scitems.hxx"
#include <svx/galbrws.hxx>
#include <svx/imapdlg.hxx>
+#include <svx/srchdlg.hxx>
#include <svl/srchitem.hxx>
#include <sfx2/templdlg.hxx>
#include <sfx2/objface.hxx>
@@ -37,6 +38,7 @@
#include "sc.hrc"
#include "drawattr.hxx"
#include "spelldialog.hxx"
+#include <searchresults.hxx>
#define ScTabViewShell
@@ -90,6 +92,7 @@ SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL))
SFX_CHILDWINDOW_REGISTRATION(ScExponentialSmoothingDialogWrapper::GetChildWindowId());
SFX_CHILDWINDOW_REGISTRATION(ScMovingAverageDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(sc::SearchResultsDlgWrapper::GetChildWindowId());
}
SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" )
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 241d5ddb8e3e..f8cb117a516b 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1638,8 +1638,18 @@ void ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
if (nCommand == SVX_SEARCHCMD_FIND_ALL || nCommand == SVX_SEARCHCMD_REPLACE_ALL)
{
- SearchResults aSearchResults(pDoc);
- aSearchResults.Show(aMatchedRanges);
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (pViewFrm)
+ {
+ pViewFrm->ShowChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId(), true);
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId());
+ if (pWnd)
+ {
+ sc::SearchResultsDlg* pDlg = static_cast<sc::SearchResultsDlg*>(pWnd->GetWindow());
+ if (pDlg)
+ pDlg->FillResults(pDoc, aMatchedRanges);
+ }
+ }
rMark.ResetMark();
for (size_t i = 0, n = aMatchedRanges.size(); i < n; ++i)