[Libreoffice-commits] core.git: include/vcl sfx2/source sfx2/uiconfig vcl/source vcl/unx
Caolán McNamara
caolanm at redhat.com
Sat Mar 3 17:50:26 UTC 2018
include/vcl/weld.hxx | 1
sfx2/source/appl/appserv.cxx | 101 ++++++++++++++++++++++----------------
sfx2/uiconfig/ui/licensedialog.ui | 16 ++++--
vcl/source/app/salvtables.cxx | 5 +
vcl/unx/gtk3/gtk3gtkinst.cxx | 6 ++
5 files changed, 85 insertions(+), 44 deletions(-)
New commits:
commit 301514183d471cfeb085673eb4563f8c310162b7
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Mar 2 21:11:10 2018 +0000
weld license dialog
Change-Id: Icfd921923cf6396db4cc5ecabd7b65d0b4c9aef7
Reviewed-on: https://gerrit.libreoffice.org/50648
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index e77936765787..0aad7d0d943f 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -442,6 +442,7 @@ class VCL_DLLPUBLIC Label : virtual public Widget
{
public:
virtual void set_label(const OUString& rText) = 0;
+ virtual OUString get_label() const = 0;
};
class VCL_DLLPUBLIC TextView : virtual public Container
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index dc89048452e8..4b5c0080dc28 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -271,26 +271,69 @@ static void showDocument( const char* pBaseName )
namespace
{
- class LicenseDialog : public ModalDialog
+ Reference<XFrame> GetRequestFrame(SfxRequest& rReq)
{
- private:
- DECL_LINK(ShowHdl, Button*, void);
- public:
- explicit LicenseDialog();
- };
+ const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl();
+ const SfxPoolItem* pItem = nullptr;
+ Reference <XFrame> xFrame;
+ if (pArgs && pArgs->GetItemState(SID_FILLFRAME, false, &pItem) == SfxItemState::SET)
+ {
+ OSL_ENSURE( dynamic_cast< const SfxUnoFrameItem *>( pItem ) != nullptr, "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
+ xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
+ }
+ return xFrame;
+ }
- LicenseDialog::LicenseDialog()
- : ModalDialog(nullptr, "LicenseDialog", "sfx/ui/licensedialog.ui")
+ weld::Window* getFrameWeld(const Reference<XFrame>& rFrame)
{
- get<PushButton>("show")->SetClickHdl(LINK(this, LicenseDialog, ShowHdl));
+ if (rFrame.is())
+ {
+ try
+ {
+ Reference< awt::XWindow > xContainerWindow(rFrame->getContainerWindow(), UNO_SET_THROW);
+ VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xContainerWindow);
+ if (pWindow)
+ return pWindow->GetFrameWeld();
+ }
+ catch (const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ SAL_WARN( "sfx.appl", "no parent for dialogs" );
+ return nullptr;
}
- IMPL_LINK_NOARG(LicenseDialog, ShowHdl, Button*, void)
+ weld::Window* GetRequestFrameWeld(SfxRequest& rReq)
{
- EndDialog(RET_OK);
- showDocument("LICENSE");
+ return getFrameWeld(GetRequestFrame(rReq));
}
+ class LicenseDialog
+ {
+ private:
+ std::unique_ptr<weld::Builder> m_xBuilder;
+ std::unique_ptr<weld::Dialog> m_xDialog;
+ std::unique_ptr<weld::Label> m_xLabel;
+ public:
+ LicenseDialog(weld::Window* pParent)
+ : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/licensedialog.ui"))
+ , m_xDialog(m_xBuilder->weld_dialog("LicenseDialog"))
+ , m_xLabel(m_xBuilder->weld_label("label"))
+ {
+ m_xLabel->set_label(Translate::GetReadStringHook()(m_xLabel->get_label()));
+ }
+
+ short run()
+ {
+ short nRet = m_xDialog->run();
+ if (nRet == RET_OK)
+ showDocument("LICENSE");
+ return nRet;
+ }
+ };
+
class SafeModeQueryDialog : public ModalDialog
{
private:
@@ -412,12 +455,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
SID_CONFIG, pStringItem->GetValue() ) );
}
- Reference< XFrame > xFrame;
- const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
- const SfxUnoFrameItem* pFrameItem = SfxItemSet::GetItem<SfxUnoFrameItem>(pIntSet, SID_FILLFRAME, false);
- if ( pFrameItem )
- xFrame = pFrameItem->GetFrame();
-
+ Reference <XFrame> xFrame(GetRequestFrame(rReq));
ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateCustomizeTabDialog(
&aSet, xFrame ));
@@ -524,8 +562,8 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
}
case SID_SHOW_LICENSE:
{
- ScopedVclPtrInstance< LicenseDialog > aDialog;
- aDialog->Execute();
+ LicenseDialog aDialog(GetRequestFrameWeld(rReq));
+ aDialog.run();
break;
}
@@ -1307,14 +1345,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
const SfxStringItem* pURLItem = rReq.GetArg<SfxStringItem>(SID_OPTIONS_PAGEURL);
if ( pURLItem )
sPageURL = pURLItem->GetValue();
- const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl();
- const SfxPoolItem* pItem = nullptr;
- Reference < XFrame > xFrame;
- if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, false, &pItem ) == SfxItemState::SET )
- {
- OSL_ENSURE( dynamic_cast< const SfxUnoFrameItem *>( pItem ) != nullptr, "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
- xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
- }
+ Reference <XFrame> xFrame(GetRequestFrame(rReq));
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
if ( pFact )
{
@@ -1455,12 +1486,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
}
}
- Reference< XFrame > xFrame;
- const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
- const SfxUnoFrameItem* pFrameItem = SfxItemSet::GetItem<SfxUnoFrameItem>(pIntSet, SID_FILLFRAME, false);
- if (pFrameItem)
- xFrame = pFrameItem->GetFrame();
-
+ Reference <XFrame> xFrame(GetRequestFrame(rReq));
rReq.SetReturnValue(SfxStringItem(rReq.GetSlot(), ChooseMacro(xLimitToModel, xFrame, bChooseOnly)));
rReq.Done();
}
@@ -1487,12 +1513,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
SAL_INFO("sfx.appl", "SfxApplication::OfaExec_Impl: case ScriptOrg");
- Reference< XFrame > xFrame;
- const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
- const SfxUnoFrameItem* pFrameItem = SfxItemSet::GetItem<SfxUnoFrameItem>(pIntSet, SID_FILLFRAME, false);
- if ( pFrameItem )
- xFrame = pFrameItem->GetFrame();
-
+ Reference <XFrame> xFrame(GetRequestFrame(rReq));
if ( !xFrame.is() )
{
const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
diff --git a/sfx2/uiconfig/ui/licensedialog.ui b/sfx2/uiconfig/ui/licensedialog.ui
index 73ae86471ddc..7d34353c1008 100644
--- a/sfx2/uiconfig/ui/licensedialog.ui
+++ b/sfx2/uiconfig/ui/licensedialog.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.2 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.0"/>
<object class="GtkDialog" id="LicenseDialog">
@@ -7,6 +7,9 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="licensedialog|LicenseDialog">Licensing and Legal information</property>
<property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -18,12 +21,11 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="show">
+ <object class="GtkButton" id="ok">
<property name="label" translatable="yes" context="licensedialog|show">_Show License</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
- <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
</object>
@@ -39,6 +41,9 @@
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
@@ -83,8 +88,11 @@ This product was created by %OOOVENDOR, based on OpenOffice.org, which is Copyri
</object>
</child>
<action-widgets>
- <action-widget response="0">show</action-widget>
+ <action-widget response="-5">ok</action-widget>
<action-widget response="-7">close</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index c1a968db3cc8..6e459298a683 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1015,6 +1015,11 @@ public:
{
m_xLabel->SetText(rText);
}
+
+ virtual OUString get_label() const override
+ {
+ return m_xLabel->GetText();
+ }
};
class SalInstanceTextView : public SalInstanceContainer, public virtual weld::TextView
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index dfe9c89cabea..87e981a7c6fe 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2215,6 +2215,12 @@ public:
{
gtk_label_set_label(m_pLabel, MapToGtkAccelerator(rText).getStr());
}
+
+ virtual OUString get_label() const override
+ {
+ const char* pLabel = gtk_label_get_label(m_pLabel);
+ return OUString(pLabel, strlen(pLabel), RTL_TEXTENCODING_UTF8);
+ }
};
class GtkInstanceTextView : public GtkInstanceContainer, public virtual weld::TextView
More information about the Libreoffice-commits
mailing list