[Libreoffice] How do tab dialogs update model/view in Writer?
Miklos Vajna
vmiklos at frugalware.org
Wed Mar 23 05:29:12 PDT 2011
Hi,
I'm trying to partly implement this bug:
https://bugs.freedesktop.org/show_bug.cgi?id=32413
To reproduce: start writer, type in some text, press F11, right click on
Default->Modify, set for example font size from 12 to 14, and the target
is to get the view updated without closing the dialog.
So far here is what I have:
To have tha Apply button, that's easy:
diff --git a/sfx2/inc/sfx2/styledlg.hxx b/sfx2/inc/sfx2/styledlg.hxx
index 05d05ba..7721bcc 100644
--- a/sfx2/inc/sfx2/styledlg.hxx
+++ b/sfx2/inc/sfx2/styledlg.hxx
@@ -40,6 +40,7 @@ class SFX2_DLLPUBLIC SfxStyleDialog: public SfxTabDialog
private:
SfxStyleSheetBase* pStyle;
DECL_DLLPRIVATE_LINK( CancelHdl, Button * );
+ DECL_DLLPRIVATE_LINK( ApplyHdl, void* );
protected:
virtual const SfxItemSet* GetRefreshedSet();
diff --git a/sfx2/source/dialog/styledlg.cxx b/sfx2/source/dialog/styledlg.cxx
index bddc0b9..5d54658 100644
--- a/sfx2/source/dialog/styledlg.cxx
+++ b/sfx2/source/dialog/styledlg.cxx
@@ -89,6 +89,8 @@ SfxStyleDialog::SfxStyleDialog
if ( bFreeRes )
FreeResource();
GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog, CancelHdl) );
+ EnableApplyButton( TRUE );
+ SetApplyHandler( LINK(this, SfxStyleDialog, ApplyHdl ) );
}
// -----------------------------------------------------------------------
@@ -170,5 +172,13 @@ IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
return 0;
}
+IMPL_LINK( SfxStyleDialog, ApplyHdl, void*, pVoid )
+{
+ (void)pVoid; //unused
+ printf("debug, SfxStyleDialog::ApplyHdl start\n");
+ return 0;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The part I'm having problem is to get SfxStyleDialog::ApplyHdl()
actually apply style settings.
So far what I see is that if I partly disable SwTemplateDlg::Ok():
diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx
index 3deeda0..49b43f1 100644
--- a/sw/source/ui/fmtui/tmpdlg.cxx
+++ b/sw/source/ui/fmtui/tmpdlg.cxx
@@ -323,7 +323,9 @@ SwTemplateDlg::~SwTemplateDlg()
short SwTemplateDlg::Ok()
{
+ printf("debug, SwTemplateDlg::Ok() start\n");
short nRet = SfxTabDialog::Ok();
+#if 0
if( RET_OK == nRet )
{
const SfxPoolItem *pOutItem, *pExItem;
@@ -344,6 +346,7 @@ short SwTemplateDlg::Ok()
//JP 09.01.98 Bug #46446#:
// das ist der Ok - Handler also muss auf OK defaultet werden!
nRet = RET_OK;
+#endif
return nRet;
}
Then the OK button has no effect. So I would guess that the Ok() method
does the update work - however, in case I just add Ok(); to
SfxStyleDialog::ApplyHdl(), then it does not update the model/view based
on the new settings.
So I guess it's not enough to call Ok(), probably there is some other
call after the destructor of the dialog to update model/view.
And that seems to be true:
In case I update SfxTabDialog::OkHdl() and change "EndDialog( Ok() );"
to "Ok();", then the OK button doesn't have any effect, either.
Now what I can't find so far is: where is the code that updates the
model/view once the dialog is closed? I guess I want to call that from
the Apply handler, but I don't yet have an idea where it is.
Thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110323/f12ca8bb/attachment.pgp>
More information about the LibreOffice
mailing list