getting a pointer to the open modal dialog

Markus Mohrhard markus.mohrhard at googlemail.com
Thu Oct 25 03:56:52 PDT 2012


2012/10/25 Caolán McNamara <caolanm at redhat.com>:
> On Thu, 2012-10-25 at 11:15 +0200, Markus Mohrhard wrote:
>> Hey,
>>
>> is there a way to get the open dialog in the code? I know that there
>> is a "way" for modeless dialogs if you know the id of the dialog but
>> have still no idea about modal dialogs.
>
> Can you give the use case ? I mean if you already have a window that you
> want to get a dialog parent for or dialog child you could just go up and
> down the hierarchy. Otherwise stuff like Application::GetActiveTopWindow
> or some of the other thingies in Application might be useful.

In Calc we have a dialog class that allows to select a range in the
workbook. At the moment this class derives indirectly from
SfxModelessDialog which creates a bunch of problems inside calc code.
These dialogs behave like modal dialogs and are designed like modal
dialogs but since they are technically modeless can't be used in
several situations. We already have some hacks to get them working in
these situation but I came now to the point that I need to call one of
them from a modal dialog which is impossible.

So I spend the last weeks turinging these dialogs also in the code
into modal dialogs. Now the only problem is that the mouse signals in
ScGridWindow are rtansformed into a range and this range needs to be
send to the calling dialog. Until now this happened through the saved
id of the modeless dialog. You can get a pointer to them through:

SfxViewFrame* pFrame = SfxViewFrame::Current();
SfxChildWindow* pChildWindow = pFrame->GetChildWindow( nId ); // where
nId is the registered id of the SfxModelessDialog

there are some more hacks around it if the dialog is not from the
current SfxViewFrame.

As long as I'm limited to ModalDialogs I had hoped that I can get an
easier solution but after thinking now about all use cases I realised
that this will only work for selecting from the current
sheet/document. I might need to implement a stack for these dialogs
where they just put a pointer during Execute and remove it with
EndDialog.

Regards,
Markus


More information about the LibreOffice mailing list