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. Change-Id: Ie03260f288fad76f994d0ca6a8b1feeade299ffd
This commit is contained in:
@@ -270,6 +270,7 @@
|
|||||||
#define SID_MOVING_AVERAGE_DIALOG (SC_MESSAGE_START + 77)
|
#define SID_MOVING_AVERAGE_DIALOG (SC_MESSAGE_START + 77)
|
||||||
#define SID_TTEST_DIALOG (SC_MESSAGE_START + 78)
|
#define SID_TTEST_DIALOG (SC_MESSAGE_START + 78)
|
||||||
#define SID_FTEST_DIALOG (SC_MESSAGE_START + 79)
|
#define SID_FTEST_DIALOG (SC_MESSAGE_START + 79)
|
||||||
|
#define SID_SEARCH_RESULTS_DIALOG (SC_MESSAGE_START + 80)
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
|
|
||||||
|
@@ -161,6 +161,7 @@ interface CellSelection
|
|||||||
SID_MOVING_AVERAGE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
SID_MOVING_AVERAGE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
||||||
SID_TTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
SID_TTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
||||||
SID_FTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
SID_FTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
||||||
|
SID_SEARCH_RESULTS_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
||||||
SID_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
|
SID_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
|
||||||
SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
|
SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
|
||||||
SID_SETINPUTMODE [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
|
SID_SETINPUTMODE [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
|
||||||
|
@@ -3231,6 +3231,29 @@ SfxVoidItem SolverDialog SID_OPENDLG_OPTSOLVER
|
|||||||
GroupId = GID_OPTIONS;
|
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
|
SfxVoidItem ValidityReference SID_VALIDITY_REFERENCE
|
||||||
()
|
()
|
||||||
|
@@ -72,6 +72,7 @@
|
|||||||
|
|
||||||
#include "docpool.hxx"
|
#include "docpool.hxx"
|
||||||
#include "appoptio.hxx"
|
#include "appoptio.hxx"
|
||||||
|
#include <searchresults.hxx>
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
|
|
||||||
@@ -285,6 +286,7 @@ void ScDLL::Init()
|
|||||||
ScSpellDialogChildWindow ::RegisterChildWindow(false, pMod);
|
ScSpellDialogChildWindow ::RegisterChildWindow(false, pMod);
|
||||||
|
|
||||||
ScValidityRefChildWin::RegisterChildWindow(false, pMod);
|
ScValidityRefChildWin::RegisterChildWindow(false, pMod);
|
||||||
|
sc::SearchResultsDlgWrapper::RegisterChildWindow(false, pMod);
|
||||||
|
|
||||||
// EditEngine Field; insofar not already defined in OfficeApplication::Init
|
// EditEngine Field; insofar not already defined in OfficeApplication::Init
|
||||||
SvClassManager& rClassManager = SvxFieldItem::GetClassManager();
|
SvClassManager& rClassManager = SvxFieldItem::GetClassManager();
|
||||||
|
@@ -11,14 +11,19 @@
|
|||||||
|
|
||||||
#include <svtools/simptabl.hxx>
|
#include <svtools/simptabl.hxx>
|
||||||
#include <svtools/treelistentry.hxx>
|
#include <svtools/treelistentry.hxx>
|
||||||
|
#include <sfx2/bindings.hxx>
|
||||||
|
#include <sfx2/dispatch.hxx>
|
||||||
#include "dociter.hxx"
|
#include "dociter.hxx"
|
||||||
#include "document.hxx"
|
#include "document.hxx"
|
||||||
#include "rangeutl.hxx"
|
#include "rangeutl.hxx"
|
||||||
#include "tabvwsh.hxx"
|
#include "tabvwsh.hxx"
|
||||||
|
#include <sc.hrc>
|
||||||
|
|
||||||
SearchResults::SearchResults(ScDocument *pDoc) :
|
namespace sc {
|
||||||
ModelessDialog(NULL, "SearchResultsDialog", "modules/scalc/ui/searchresults.ui")
|
|
||||||
, mpDoc(pDoc)
|
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");
|
SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("results");
|
||||||
Size aControlSize(150, 120);
|
Size aControlSize(150, 120);
|
||||||
@@ -30,36 +35,56 @@ SearchResults::SearchResults(ScDocument *pDoc) :
|
|||||||
long nTabs[] = {3, 0, 40, 60};
|
long nTabs[] = {3, 0, 40, 60};
|
||||||
mpList->SetTabs(&nTabs[0]);
|
mpList->SetTabs(&nTabs[0]);
|
||||||
mpList->InsertHeaderEntry("Sheet\tCell\tContent");
|
mpList->InsertHeaderEntry("Sheet\tCell\tContent");
|
||||||
mpList->SetSelectHdl( LINK(this, SearchResults, ListSelectHdl) );
|
mpList->SetSelectHdl( LINK(this, SearchResultsDlg, ListSelectHdl) );
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchResults::~SearchResults()
|
SearchResultsDlg::~SearchResultsDlg()
|
||||||
{
|
{
|
||||||
delete mpList;
|
delete mpList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResults::Show(const ScRangeList &rMatchedRanges)
|
void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatchedRanges )
|
||||||
{
|
{
|
||||||
mpList->Clear();
|
mpList->Clear();
|
||||||
mpList->SetUpdateMode(false);
|
mpList->SetUpdateMode(false);
|
||||||
for (size_t i = 0, n = rMatchedRanges.size(); i < n; ++i)
|
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())
|
for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
|
||||||
{
|
{
|
||||||
ScAddress aAddress = aIter.GetPos();
|
ScAddress aAddress = aIter.GetPos();
|
||||||
OUString sAddress;
|
OUString sAddress;
|
||||||
ScRangeStringConverter::GetStringFromAddress(sAddress, aAddress,
|
ScRangeStringConverter::GetStringFromAddress(sAddress, aAddress,
|
||||||
mpDoc, formula::FormulaGrammar::CONV_OOO);
|
pDoc, formula::FormulaGrammar::CONV_OOO);
|
||||||
mpList->InsertEntry(sAddress.replace('.', '\t') + "\t" + mpDoc->GetString(aAddress));
|
mpList->InsertEntry(sAddress.replace('.', '\t') + "\t" + pDoc->GetString(aAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mpList->SetUpdateMode(true);
|
mpList->SetUpdateMode(true);
|
||||||
ModelessDialog::Show();
|
|
||||||
|
mpDoc = pDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPL_LINK_NOARG( SearchResults, ListSelectHdl )
|
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( SearchResultsDlg, ListSelectHdl )
|
||||||
|
{
|
||||||
|
if (!mpDoc)
|
||||||
|
return 0;
|
||||||
|
|
||||||
SvTreeListEntry *pEntry = mpList->FirstSelected();
|
SvTreeListEntry *pEntry = mpList->FirstSelected();
|
||||||
ScAddress aAddress;
|
ScAddress aAddress;
|
||||||
sal_Int32 nOffset = 0;
|
sal_Int32 nOffset = 0;
|
||||||
@@ -70,7 +95,28 @@ IMPL_LINK_NOARG( SearchResults, ListSelectHdl )
|
|||||||
pScViewShell->SetTabNo(aAddress.Tab());
|
pScViewShell->SetTabNo(aAddress.Tab());
|
||||||
pScViewShell->SetCursor(aAddress.Col(), aAddress.Row());
|
pScViewShell->SetCursor(aAddress.Col(), aAddress.Row());
|
||||||
pScViewShell->AlignToCursor(aAddress.Col(), aAddress.Row(), SC_FOLLOW_JUMP);
|
pScViewShell->AlignToCursor(aAddress.Col(), aAddress.Row(), SC_FOLLOW_JUMP);
|
||||||
|
|
||||||
return 0;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -11,21 +11,45 @@
|
|||||||
#define INCLUDED_SC_SOURCE_UI_INC_SEARCHRESULTS_HXX
|
#define INCLUDED_SC_SOURCE_UI_INC_SEARCHRESULTS_HXX
|
||||||
|
|
||||||
#include <vcl/dialog.hxx>
|
#include <vcl/dialog.hxx>
|
||||||
|
#include <sfx2/childwin.hxx>
|
||||||
|
|
||||||
class ScDocument;
|
class ScDocument;
|
||||||
class ScRangeList;
|
class ScRangeList;
|
||||||
class SvSimpleTable;
|
class SvSimpleTable;
|
||||||
|
|
||||||
class SearchResults : public ModelessDialog
|
namespace sc {
|
||||||
|
|
||||||
|
class SearchResultsDlg : public ModelessDialog
|
||||||
{
|
{
|
||||||
ScDocument *mpDoc;
|
|
||||||
SvSimpleTable *mpList;
|
SvSimpleTable *mpList;
|
||||||
|
SfxBindings* mpBindings;
|
||||||
|
sal_uInt16 mnId;
|
||||||
|
|
||||||
|
ScDocument* mpDoc;
|
||||||
|
|
||||||
DECL_LINK( ListSelectHdl, void * );
|
DECL_LINK( ListSelectHdl, void * );
|
||||||
public:
|
public:
|
||||||
SearchResults(ScDocument *);
|
SearchResultsDlg( SfxBindings* _pBindings, Window* pParent, sal_uInt16 nId );
|
||||||
virtual ~SearchResults();
|
virtual ~SearchResultsDlg();
|
||||||
void Show(const ScRangeList &);
|
|
||||||
|
void FillResults( ScDocument* pDoc, const ScRangeList& rMatchedRanges );
|
||||||
|
|
||||||
|
virtual bool Close() SAL_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SearchResultsDlgWrapper : public SfxChildWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SearchResultsDlgWrapper(
|
||||||
|
Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo );
|
||||||
|
|
||||||
|
virtual ~SearchResultsDlgWrapper();
|
||||||
|
|
||||||
|
SFX_DECL_CHILDWINDOW_WITHID(SearchResultsDlgWrapper);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -84,6 +84,7 @@
|
|||||||
#include <tokenarray.hxx>
|
#include <tokenarray.hxx>
|
||||||
#include <formulacell.hxx>
|
#include <formulacell.hxx>
|
||||||
#include <gridwin.hxx>
|
#include <gridwin.hxx>
|
||||||
|
#include <searchresults.hxx>
|
||||||
|
|
||||||
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
|
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
|
||||||
#include <com/sun/star/lang/XInitialization.hpp>
|
#include <com/sun/star/lang/XInitialization.hpp>
|
||||||
@@ -998,6 +999,20 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
|
|||||||
}
|
}
|
||||||
break;
|
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)
|
// disposal (Outlines)
|
||||||
// SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
|
// SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "scitems.hxx"
|
#include "scitems.hxx"
|
||||||
#include <svx/galbrws.hxx>
|
#include <svx/galbrws.hxx>
|
||||||
#include <svx/imapdlg.hxx>
|
#include <svx/imapdlg.hxx>
|
||||||
|
#include <svx/srchdlg.hxx>
|
||||||
#include <svl/srchitem.hxx>
|
#include <svl/srchitem.hxx>
|
||||||
#include <sfx2/templdlg.hxx>
|
#include <sfx2/templdlg.hxx>
|
||||||
#include <sfx2/objface.hxx>
|
#include <sfx2/objface.hxx>
|
||||||
@@ -39,6 +40,7 @@
|
|||||||
#include "dwfunctr.hxx"
|
#include "dwfunctr.hxx"
|
||||||
#include "sc.hrc"
|
#include "sc.hrc"
|
||||||
#include "spelldialog.hxx"
|
#include "spelldialog.hxx"
|
||||||
|
#include <searchresults.hxx>
|
||||||
|
|
||||||
#define ScTabViewShell
|
#define ScTabViewShell
|
||||||
#include "scslots.hxx"
|
#include "scslots.hxx"
|
||||||
@@ -79,11 +81,12 @@ void ScTabViewShell::InitInterface_Impl()
|
|||||||
GetStaticInterface()->RegisterChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
|
GetStaticInterface()->RegisterChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
|
||||||
GetStaticInterface()->RegisterChildWindow(ScHighlightChgDlgWrapper::GetChildWindowId());
|
GetStaticInterface()->RegisterChildWindow(ScHighlightChgDlgWrapper::GetChildWindowId());
|
||||||
GetStaticInterface()->RegisterChildWindow(ScSimpleRefDlgWrapper::GetChildWindowId());
|
GetStaticInterface()->RegisterChildWindow(ScSimpleRefDlgWrapper::GetChildWindowId());
|
||||||
GetStaticInterface()->RegisterChildWindow(SID_SEARCH_DLG);
|
GetStaticInterface()->RegisterChildWindow(SvxSearchDialogWrapper::GetChildWindowId());
|
||||||
GetStaticInterface()->RegisterChildWindow(SID_HYPERLINK_DIALOG);
|
GetStaticInterface()->RegisterChildWindow(SID_HYPERLINK_DIALOG);
|
||||||
GetStaticInterface()->RegisterChildWindow(GalleryChildWindow::GetChildWindowId());
|
GetStaticInterface()->RegisterChildWindow(GalleryChildWindow::GetChildWindowId());
|
||||||
GetStaticInterface()->RegisterChildWindow(ScSpellDialogChildWindow::GetChildWindowId());
|
GetStaticInterface()->RegisterChildWindow(ScSpellDialogChildWindow::GetChildWindowId());
|
||||||
GetStaticInterface()->RegisterChildWindow(ScValidityRefChildWin::GetChildWindowId());
|
GetStaticInterface()->RegisterChildWindow(ScValidityRefChildWin::GetChildWindowId());
|
||||||
|
GetStaticInterface()->RegisterChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId());
|
||||||
|
|
||||||
GetStaticInterface()->RegisterChildWindow(ScRandomNumberGeneratorDialogWrapper::GetChildWindowId());
|
GetStaticInterface()->RegisterChildWindow(ScRandomNumberGeneratorDialogWrapper::GetChildWindowId());
|
||||||
GetStaticInterface()->RegisterChildWindow(ScSamplingDialogWrapper::GetChildWindowId());
|
GetStaticInterface()->RegisterChildWindow(ScSamplingDialogWrapper::GetChildWindowId());
|
||||||
|
@@ -1580,8 +1580,18 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
|
|||||||
|
|
||||||
if (nCommand == SVX_SEARCHCMD_FIND_ALL || nCommand == SVX_SEARCHCMD_REPLACE_ALL)
|
if (nCommand == SVX_SEARCHCMD_FIND_ALL || nCommand == SVX_SEARCHCMD_REPLACE_ALL)
|
||||||
{
|
{
|
||||||
SearchResults aSearchResults(pDoc);
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
||||||
aSearchResults.Show(aMatchedRanges);
|
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();
|
rMark.ResetMark();
|
||||||
for (size_t i = 0, n = aMatchedRanges.size(); i < n; ++i)
|
for (size_t i = 0, n = aMatchedRanges.size(); i < n; ++i)
|
||||||
|
Reference in New Issue
Block a user