[Libreoffice-commits] .: Branch 'feature/cmclayout' - sfx2/source vcl/inc vcl/source
Caolán McNamara
caolan at kemper.freedesktop.org
Mon Jun 11 13:25:57 PDT 2012
sfx2/source/dialog/basedlgs.cxx | 48 ------------------
vcl/inc/vcl/dialog.hxx | 6 ++
vcl/inc/vcl/tabdlg.hxx | 1
vcl/source/window/dialog.cxx | 105 +++++++++++++++++++++++++++++++++++++---
vcl/source/window/tabdlg.cxx | 9 ++-
5 files changed, 113 insertions(+), 56 deletions(-)
New commits:
commit bfa1bd77fa62e31e25c9a86e4509bf2ae2cdf3d7
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Jun 11 21:25:34 2012 +0100
move dialog-contained widget builder into dialog baseclass
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 8bdb453..db45163 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -163,38 +163,6 @@ void SfxModalDialog::init()
GetDialogData_Impl();
}
-#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"))
-
-rtl::OUString getUIRootDir()
-{
- namespace css = ::com::sun::star;
-
- /*to-do, check if user config has an override before using shared one, etc*/
- css::uno::Reference< css::beans::XPropertySet > xPathSettings(
- ::comphelper::getProcessServiceFactory()->createInstance(SERVICENAME_PATHSETTINGS),
- css::uno::UNO_QUERY_THROW);
-
- ::rtl::OUString sShareLayer;
- xPathSettings->getPropertyValue(BASEPATH_SHARE_LAYER) >>= sShareLayer;
-
- // "UIConfig" is a "multi path" ... use first part only here!
- sal_Int32 nPos = sShareLayer.indexOf(';');
- if (nPos > 0)
- sShareLayer = sShareLayer.copy(0, nPos);
-
- // Note: May be an user uses URLs without a final slash! Check it ...
- nPos = sShareLayer.lastIndexOf('/');
- if (nPos != sShareLayer.getLength()-1)
- sShareLayer += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
-
- 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 )
@@ -210,29 +178,15 @@ SfxModalDialog::SfxModalDialog(Window* pParent, const ResId &rResId )
pInputSet(0),
pOutputSet(0)
{
- sal_Int32 nUIid = static_cast<sal_Int32>(nUniqId);
- rtl::OUString sPath = rtl::OUStringBuffer(getUIRootDir()).
- append(rResId.GetResMgr()->getPrefixName()).
- append("/ui/").
- 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();
}
SfxModalDialog::SfxModalDialog(Window *pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription )
-: ModalDialog(pParent, 0), //todo
+: ModalDialog(pParent, rID, rUIXMLDescription),
nUniqId(0), //todo
pInputSet(0),
pOutputSet(0)
{
- m_pUIBuilder = new VclBuilder(this, getUIRootDir() + rUIXMLDescription, rID);
init();
}
diff --git a/vcl/inc/vcl/dialog.hxx b/vcl/inc/vcl/dialog.hxx
index 7f2670a..e447e13 100644
--- a/vcl/inc/vcl/dialog.hxx
+++ b/vcl/inc/vcl/dialog.hxx
@@ -68,10 +68,12 @@ private:
DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void* );
DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, void* );
+
protected:
using Window::ImplInit;
SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
SAL_DLLPRIVATE void ImplDialogRes( const ResId& rResId );
+ SAL_DLLPRIVATE WinBits init(Window *pParent, const ResId& rResId);
VclBuilder *m_pUIBuilder;
@@ -81,11 +83,13 @@ public:
protected:
Dialog( WindowType nType );
+ Dialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription, WindowType nType );
virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
public:
Dialog( Window* pParent, WinBits nStyle = WB_STDDIALOG );
Dialog( Window* pParent, const ResId& rResId );
+ Dialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription );
virtual ~Dialog();
virtual long Notify( NotifyEvent& rNEvt );
@@ -156,6 +160,7 @@ class VCL_DLLPUBLIC ModelessDialog : public Dialog
public:
ModelessDialog( Window* pParent, const ResId& rResId );
+ ModelessDialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription );
};
// ---------------
@@ -166,6 +171,7 @@ class VCL_DLLPUBLIC ModalDialog : public Dialog
{
public:
ModalDialog( Window* pParent, WinBits nStyle = WB_STDMODAL );
+ ModalDialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription );
ModalDialog( Window* pParent, const ResId& rResId );
private:
diff --git a/vcl/inc/vcl/tabdlg.hxx b/vcl/inc/vcl/tabdlg.hxx
index 4887a46..b13f056 100644
--- a/vcl/inc/vcl/tabdlg.hxx
+++ b/vcl/inc/vcl/tabdlg.hxx
@@ -55,6 +55,7 @@ public:
TabDialog( Window* pParent,
WinBits nStyle = WB_STDTABDIALOG );
TabDialog( Window* pParent, const ResId& rResId );
+ TabDialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription );
~TabDialog();
virtual void StateChanged( StateChangedType nStateChange );
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 4c5c015..3a1caa9 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -26,6 +26,10 @@
*
************************************************************************/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/processfactory.hxx>
+#include <osl/file.hxx>
+
#include <tools/debug.hxx>
#include <tools/rc.h>
@@ -485,6 +489,55 @@ Dialog::Dialog( WindowType nType ) :
ImplInitDialogData();
}
+#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"))
+
+rtl::OUString getUIRootDir()
+{
+ namespace css = ::com::sun::star;
+
+ /*to-do, check if user config has an override before using shared one, etc*/
+ css::uno::Reference< css::beans::XPropertySet > xPathSettings(
+ ::comphelper::getProcessServiceFactory()->createInstance(SERVICENAME_PATHSETTINGS),
+ css::uno::UNO_QUERY_THROW);
+
+ ::rtl::OUString sShareLayer;
+ xPathSettings->getPropertyValue(BASEPATH_SHARE_LAYER) >>= sShareLayer;
+
+ // "UIConfig" is a "multi path" ... use first part only here!
+ sal_Int32 nPos = sShareLayer.indexOf(';');
+ if (nPos > 0)
+ sShareLayer = sShareLayer.copy(0, nPos);
+
+ // Note: May be an user uses URLs without a final slash! Check it ...
+ nPos = sShareLayer.lastIndexOf('/');
+ if (nPos != sShareLayer.getLength()-1)
+ sShareLayer += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+
+ 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;
+}
+
+Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription)
+ : SystemWindow( WINDOW_DIALOG )
+{
+ ImplInitDialogData();
+ ImplInit(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE);
+ m_pUIBuilder = new VclBuilder(this, getUIRootDir() + rUIXMLDescription, rID);
+}
+
+Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription, WindowType nType)
+ : SystemWindow( nType )
+{
+ ImplInitDialogData();
+ ImplInit(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE);
+ m_pUIBuilder = new VclBuilder(this, getUIRootDir() + rUIXMLDescription, rID);
+}
+
+
// -----------------------------------------------------------------------
Dialog::Dialog( Window* pParent, WinBits nStyle ) :
@@ -501,8 +554,38 @@ Dialog::Dialog( Window* pParent, const ResId& rResId ) :
{
ImplInitDialogData();
rResId.SetRT( RSC_DIALOG );
- ImplInit( pParent, ImplInitRes( rResId ) );
- ImplLoadRes( rResId );
+ init(pParent, rResId);
+}
+
+WinBits Dialog::init(Window *pParent, const ResId& rResId)
+{
+ WinBits nStyle = ImplInitRes( rResId );
+
+ ImplInit( pParent, nStyle );
+
+ sal_Int32 nUIid = static_cast<sal_Int32>(rResId.GetId());
+ rtl::OUString sPath = rtl::OUStringBuffer(getUIRootDir()).
+ append(rResId.GetResMgr()->getPrefixName()).
+ append("/ui/").
+ append(nUIid).
+ appendAscii(".ui").
+ makeStringAndClear();
+ fprintf(stderr, "path %s id %d\n", rtl::OUStringToOString(sPath, RTL_TEXTENCODING_UTF8).getStr(), nUIid);
+
+ osl::File aUIFile(sPath);
+ osl::File::RC error = aUIFile.open(osl_File_OpenFlag_Read);
+ if (error == osl::File::E_None)
+ {
+ //good, use the preferred GtkBuilder xml
+ m_pUIBuilder = new VclBuilder(this, sPath, rtl::OString::valueOf(nUIid));
+ }
+ else
+ {
+ //fallback to using the binary resource file
+ ImplLoadRes( rResId );
+ }
+
+ return nStyle;
}
// -----------------------------------------------------------------------
@@ -1216,14 +1299,18 @@ ModelessDialog::ModelessDialog( Window* pParent, const ResId& rResId ) :
Dialog( WINDOW_MODELESSDIALOG )
{
rResId.SetRT( RSC_MODELESSDIALOG );
- WinBits nStyle = ImplInitRes( rResId );
- ImplInit( pParent, nStyle );
- ImplLoadRes( rResId );
+
+ WinBits nStyle = init( pParent, rResId );
if ( !(nStyle & WB_HIDE) )
Show();
}
+ModelessDialog::ModelessDialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription ) :
+ Dialog(pParent, rID, rUIXMLDescription, WINDOW_MODELESSDIALOG)
+{
+}
+
// =======================================================================
ModalDialog::ModalDialog( Window* pParent, WinBits nStyle ) :
@@ -1238,8 +1325,12 @@ ModalDialog::ModalDialog( Window* pParent, const ResId& rResId ) :
Dialog( WINDOW_MODALDIALOG )
{
rResId.SetRT( RSC_MODALDIALOG );
- ImplInit( pParent, ImplInitRes( rResId ) );
- ImplLoadRes( rResId );
+ init( pParent, rResId );
+}
+
+ModalDialog::ModalDialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription ) :
+ Dialog(pParent, rID, rUIXMLDescription, WINDOW_MODALDIALOG)
+{
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/tabdlg.cxx b/vcl/source/window/tabdlg.cxx
index 0701533..2019e52 100644
--- a/vcl/source/window/tabdlg.cxx
+++ b/vcl/source/window/tabdlg.cxx
@@ -231,8 +231,13 @@ TabDialog::TabDialog( Window* pParent, const ResId& rResId ) :
{
ImplInitTabDialogData();
rResId.SetRT( RSC_TABDIALOG );
- ImplInit( pParent, ImplInitRes( rResId ) );
- ImplLoadRes( rResId );
+ init(pParent, rResId);
+}
+
+TabDialog::TabDialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription ) :
+ Dialog(pParent, rID, rUIXMLDescription, WINDOW_TABDIALOG)
+{
+ ImplInitTabDialogData();
}
// -----------------------------------------------------------------------
More information about the Libreoffice-commits
mailing list