diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-08-16 14:04:00 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:35 +0100 |
commit | 6981ae169ff82ccaaff7040fef03b3bb322790e0 (patch) | |
tree | 804fdc4e74c4b6fb0914286fd97b76fa63fb5d33 /vcl | |
parent | a8875d1373f57370026e270fb51e1205e9d1edbf (diff) |
Cut Gordian Knot of helpids with .ui format
There isn't really an equivalent feature in gtk as help ids (apparently anyway)
Rather than munge one in, use the widget id + path as an unique help identifier
For the retro-fit where code remains unchanged, don't override the
.res loaded id with the .ui generated id
Change-Id: I1befe77408cb317e0462dacb26b7d12f9399d372
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/builder.hxx | 4 | ||||
-rw-r--r-- | vcl/source/uipreviewer/previewer.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 13 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 17 | ||||
-rw-r--r-- | vcl/source/window/window2.cxx | 4 |
5 files changed, 27 insertions, 13 deletions
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx index 7b9823feff1d..ff346dd8e2f4 100644 --- a/vcl/inc/vcl/builder.hxx +++ b/vcl/inc/vcl/builder.hxx @@ -43,7 +43,6 @@ class VCL_DLLPUBLIC VclBuilder public: typedef std::map<rtl::OString, rtl::OString> stringmap; private: - //todo merge into Windows UniqueID/HelpID ? struct WinAndId { rtl::OString m_sID; @@ -122,9 +121,10 @@ private: rtl::OString getTranslation(const rtl::OString &rId, const rtl::OString &rProperty) const; rtl::OString m_sID; + rtl::OString m_sHelpRoot; Window *m_pParent; public: - VclBuilder(Window *pParent, rtl::OUString sUIFile, rtl::OString sID = rtl::OString()); + VclBuilder(Window *pParent, rtl::OUString sUIRootDir, rtl::OUString sUIFile, rtl::OString sID = rtl::OString()); ~VclBuilder(); Window *get_widget_root(); Window *get_by_name(rtl::OString sID); diff --git a/vcl/source/uipreviewer/previewer.cxx b/vcl/source/uipreviewer/previewer.cxx index e18730bc3156..42c035333575 100644 --- a/vcl/source/uipreviewer/previewer.cxx +++ b/vcl/source/uipreviewer/previewer.cxx @@ -85,7 +85,7 @@ int UIPreviewApp::Main() Dialog *pDialog = new Dialog(NULL, WB_STDDIALOG); { - VclBuilder aBuilder(pDialog, uifiles[0]); + VclBuilder aBuilder(pDialog, rtl::OUString(), uifiles[0]); Dialog *pRealDialog = dynamic_cast<Dialog*>(aBuilder.get_widget_root()); if (!pRealDialog) diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 0176bfadfe23..a9e56010832f 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -39,10 +39,18 @@ #include <vcl/tabpage.hxx> #include <window.h> -VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUri, rtl::OString sID) +VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIFile, rtl::OString sID) : m_sID(sID) + , m_sHelpRoot(rtl::OUStringToOString(sUIFile, RTL_TEXTENCODING_UTF8)) , m_pParent(pParent) { + sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); + if (nIdx != -1) + m_sHelpRoot = m_sHelpRoot.copy(0, nIdx); + m_sHelpRoot = m_sHelpRoot + rtl::OString('/'); + + rtl::OUString sUri = sUIDir + sUIFile; + ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); for (int i = aLocale.Country.isEmpty() ? 1 : 0; i < 2; ++i) { @@ -375,7 +383,8 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const fprintf(stderr, "TO-DO, implement %s\n", name.getStr()); if (pWindow) { - fprintf(stderr, "for %s, created %p child of %p (%p/%p/%p)\n", name.getStr(), pWindow, pParent, pWindow->mpWindowImpl->mpParent, pWindow->mpWindowImpl->mpRealParent, pWindow->mpWindowImpl->mpBorderWindow); + pWindow->SetHelpId(m_sHelpRoot + id); + fprintf(stderr, "for %s, created %p child of %p (%p/%p/%p) with helpid %s\n", name.getStr(), pWindow, pParent, pWindow->mpWindowImpl->mpParent, pWindow->mpWindowImpl->mpRealParent, pWindow->mpWindowImpl->mpBorderWindow, pWindow->GetHelpId().getStr()); m_aChildren.push_back(WinAndId(id, pWindow)); } return pWindow; diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 12d7feab0517..7b7be589f81f 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -510,7 +510,7 @@ Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rU { ImplInitDialogData(); ImplInit(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE); - m_pUIBuilder = new VclBuilder(this, getUIRootDir() + rUIXMLDescription, rID); + m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); } Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription, WindowType nType) @@ -518,7 +518,7 @@ Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rU { ImplInitDialogData(); ImplInit(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE); - m_pUIBuilder = new VclBuilder(this, getUIRootDir() + rUIXMLDescription, rID); + m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); } @@ -544,19 +544,22 @@ Dialog::Dialog( Window* pParent, const ResId& rResId ) : VclBuilder* VclBuilderContainer::overrideResourceWithUIXML(Window *pWindow, const ResId& rResId) { sal_Int32 nUIid = static_cast<sal_Int32>(rResId.GetId()); - rtl::OUString sPath = rtl::OUStringBuffer(getUIRootDir()). - append(rResId.GetResMgr()->getPrefixName()). + + rtl::OUString sRoot = getUIRootDir(); + rtl::OUString sPath = rtl::OUStringBuffer( + 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); + fprintf(stderr, "path %s id %d\n", rtl::OUStringToOString(sRoot+sPath, RTL_TEXTENCODING_UTF8).getStr(), nUIid); + + osl::File aUIFile(sRoot + sPath); osl::File::RC error = aUIFile.open(osl_File_OpenFlag_Read); //good, use the preferred GtkBuilder xml if (error == osl::File::E_None) - return new VclBuilder(pWindow, sPath, rtl::OString::valueOf(nUIid)); + return new VclBuilder(pWindow, sRoot, sPath, rtl::OString::valueOf(nUIid)); return NULL; } diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index f760f130f423..9b51446260dd 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1761,6 +1761,9 @@ void Window::queue_resize() pParent->Resize(); } +//We deliberately do not overwrite our maHelpId here +//so that the .res loaded id is not overwritten +//by the .ui loaded one void Window::take_properties(Window &rOther) { if (!mpWindowImpl) @@ -1791,7 +1794,6 @@ void Window::take_properties(Window &rOther) mpWindowImpl->mnY = pWindowImpl->mnY; mpWindowImpl->mnAbsScreenX = pWindowImpl->mnAbsScreenX; mpWindowImpl->maPos = pWindowImpl->maPos; - mpWindowImpl->maHelpId = pWindowImpl->maHelpId; mpWindowImpl->maUniqId = pWindowImpl->maUniqId; mpWindowImpl->maHelpText = pWindowImpl->maHelpText; mpWindowImpl->maQuickHelpText = pWindowImpl->maQuickHelpText; |