diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-05-22 12:33:28 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:20 +0100 |
commit | a983689039321013117a69ac2eba6ecbf85773ac (patch) | |
tree | ada44bcd91458ee987e56c78798a8c0773178312 /sfx2 | |
parent | a3b7b56eaaf6adce8efbbd1d40a06cc703311ee3 (diff) |
Implement conversion scheme for dialogs without changing their code
This supports a scheme where we can change over a dialog to GtkBuilder xml
without touching its code by the presence of a .ui file in the right place e.g.
share/config/soffice.cfg/cui/10000.ui for the zoom dialog
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/basedlgs.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/basedlgs.cxx | 71 |
2 files changed, 43 insertions, 30 deletions
diff --git a/sfx2/inc/sfx2/basedlgs.hxx b/sfx2/inc/sfx2/basedlgs.hxx index 1461177a2b33..c5c8f559059a 100644 --- a/sfx2/inc/sfx2/basedlgs.hxx +++ b/sfx2/inc/sfx2/basedlgs.hxx @@ -70,8 +70,6 @@ private: SAL_DLLPRIVATE void init(); protected: - VclBuilder *m_pUIBuilder; - SfxModalDialog(Window *pParent, const ResId& ); SfxModalDialog(Window *pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription ); SfxModalDialog(Window* pParent, sal_uInt32 nUniqueId, WinBits nWinStyle = WB_STDMODAL ); diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index d6c4fb041c7f..c79819411401 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -19,6 +19,7 @@ #include <stdlib.h> #include <comphelper/processfactory.hxx> +#include <osl/file.hxx> #include <vcl/fixed.hxx> #include <vcl/help.hxx> #include <vcl/msgbox.hxx> @@ -150,34 +151,11 @@ void SfxModalDialog::init() GetDialogData_Impl(); } -// ----------------------------------------------------------------------- - -SfxModalDialog::SfxModalDialog(Window* pParent, const ResId &rResId ) - -/* [Description] - - Constructor of the general base class for modal Dialoge; - ResId is used as ID in ini-file. The saved position from there is set. -*/ - -: ModalDialog(pParent, rResId), - nUniqId(rResId.GetId()), - pInputSet(0), - pOutputSet(0), - m_pUIBuilder(0) -{ - init(); -} - #define BASEPATH_SHARE_LAYER rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIConfig")) #define RELPATH_SHARE_LAYER rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("soffice.cfg")) #define SERVICENAME_PATHSETTINGS rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.PathSettings")) -SfxModalDialog::SfxModalDialog(Window *pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription ) -: ModalDialog(pParent, 0), //todo - nUniqId(0), //todo - pInputSet(0), - pOutputSet(0) +rtl::OUString getUIRootDir() { namespace css = ::com::sun::star; @@ -202,8 +180,47 @@ SfxModalDialog::SfxModalDialog(Window *pParent, const rtl::OString& rID, const r sShareLayer += RELPATH_SHARE_LAYER; // folder sShareLayer += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); /*to-do, can we merge all this foo with existing soffice.cfg finding code, etc*/ + return sShareLayer; +} + +// ----------------------------------------------------------------------- + +SfxModalDialog::SfxModalDialog(Window* pParent, const ResId &rResId ) + +/* [Description] + + Constructor of the general base class for modal Dialoge; + ResId is used as ID in ini-file. The saved position from there is set. +*/ + +: ModalDialog(pParent, rResId), + nUniqId(rResId.GetId()), + pInputSet(0), + pOutputSet(0) +{ + sal_Int32 nUIid = static_cast<sal_Int32>(nUniqId); + rtl::OUString sPath = rtl::OUStringBuffer(getUIRootDir()). + append(rResId.GetResMgr()->getPrefixName()). + append('/'). + append(nUIid). + appendAscii(".ui"). + makeStringAndClear(); + fprintf(stderr, "path %s id %d\n", rtl::OUStringToOString(sPath, RTL_TEXTENCODING_UTF8).getStr(), nUniqId); + + osl::File aUIFile(sPath); + osl::File::RC error = aUIFile.open(osl_File_OpenFlag_Read); + if (error == osl::File::E_None) + m_pUIBuilder = new VclBuilder(this, sPath, rtl::OString::valueOf(nUIid)); + init(); +} - m_pUIBuilder = new VclBuilder(this, sShareLayer + rUIXMLDescription, rID); +SfxModalDialog::SfxModalDialog(Window *pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription ) +: ModalDialog(pParent, 0), //todo + nUniqId(0), //todo + pInputSet(0), + pOutputSet(0) +{ + m_pUIBuilder = new VclBuilder(this, getUIRootDir() + rUIXMLDescription, rID); init(); } @@ -222,8 +239,7 @@ SfxModalDialog::SfxModalDialog(Window* pParent, ModalDialog(pParent, nWinStyle), nUniqId(nUniqueId), pInputSet(0), - pOutputSet(0), - m_pUIBuilder(0) + pOutputSet(0) { init(); } @@ -240,7 +256,6 @@ SfxModalDialog::~SfxModalDialog() { SetDialogData_Impl(); delete pOutputSet; - delete m_pUIBuilder; } void SfxModalDialog::CreateOutputItemSet( SfxItemPool& rPool ) |