[Libreoffice-commits] core.git: reportdesign/source reportdesign/uiconfig
Caolán McNamara
caolanm at redhat.com
Mon May 21 16:33:53 UTC 2018
reportdesign/source/ui/dlg/DateTime.cxx | 143 ++++++++------------
reportdesign/source/ui/inc/DateTime.hxx | 39 ++---
reportdesign/source/ui/report/ReportController.cxx | 4
reportdesign/uiconfig/dbreport/ui/datetimedialog.ui | 16 +-
4 files changed, 88 insertions(+), 114 deletions(-)
New commits:
commit 4da8aef20416d0e1320a1ee455e2edc2ae61f9ac
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon May 21 12:05:55 2018 +0100
weld ODateTimeDialog
Change-Id: Id93147f1d442e1e5f1cfba8ef2f9e476f4f6d728
Reviewed-on: https://gerrit.libreoffice.org/54623
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/reportdesign/source/ui/dlg/DateTime.cxx b/reportdesign/source/ui/dlg/DateTime.cxx
index c1b4e23e01b9..69f5cd531e05 100644
--- a/reportdesign/source/ui/dlg/DateTime.cxx
+++ b/reportdesign/source/ui/dlg/DateTime.cxx
@@ -40,25 +40,20 @@ using namespace ::comphelper;
// class ODateTimeDialog
-ODateTimeDialog::ODateTimeDialog( vcl::Window* _pParent
- ,const uno::Reference< report::XSection >& _xHoldAlive
- ,OReportController* _pController)
- : ModalDialog( _pParent, "DateTimeDialog" , "modules/dbreport/ui/datetimedialog.ui" )
+ODateTimeDialog::ODateTimeDialog(weld::Window* _pParent, const uno::Reference< report::XSection >& _xHoldAlive,
+ OReportController* _pController)
+ : GenericDialogController(_pParent, "modules/dbreport/ui/datetimedialog.ui", "DateTimeDialog")
- , m_aDateControlling()
- , m_aTimeControlling()
, m_pController(_pController)
, m_xHoldAlive(_xHoldAlive)
+ , m_xDate(m_xBuilder->weld_check_button("date"))
+ , m_xFTDateFormat(m_xBuilder->weld_label("datelistbox_label"))
+ , m_xDateListBox(m_xBuilder->weld_combo_box_text("datelistbox"))
+ , m_xTime(m_xBuilder->weld_check_button("time"))
+ , m_xFTTimeFormat(m_xBuilder->weld_label("timelistbox_label"))
+ , m_xTimeListBox(m_xBuilder->weld_combo_box_text("timelistbox"))
+ , m_xPB_OK(m_xBuilder->weld_button("ok"))
{
- get(m_pDate,"date");
- get(m_pFTDateFormat,"datelistbox_label");
- get(m_pDateListBox,"datelistbox");
- get(m_pTime,"time");
- get(m_pFTTimeFormat,"timelistbox_label");
- get(m_pTimeListBox,"timelistbox");
- get(m_pPB_OK,"ok");
-
-
try
{
SvtSysLocale aSysLocale;
@@ -71,60 +66,36 @@ ODateTimeDialog::ODateTimeDialog( vcl::Window* _pParent
{
}
- m_pDateListBox->SelectEntryPos(0);
-
- m_pTimeListBox->SelectEntryPos(0);
-
- // use nice enhancement, to toggle enable/disable if a checkbox is checked or not
- m_aDateControlling.enableOnCheckMark( *m_pDate, *m_pFTDateFormat, *m_pDateListBox);
- m_aTimeControlling.enableOnCheckMark( *m_pTime, *m_pFTTimeFormat, *m_pTimeListBox);
-
- CheckBox* aCheckBoxes[] = { m_pDate,m_pTime};
- for (CheckBox* pCheckBox : aCheckBoxes)
- pCheckBox->SetClickHdl(LINK(this,ODateTimeDialog,CBClickHdl));
+ m_xDateListBox->set_active(0);
+ m_xTimeListBox->set_active(0);
+ weld::CheckButton* aCheckBoxes[] = { m_xDate.get(), m_xTime.get() };
+ for (weld::CheckButton* pCheckBox : aCheckBoxes)
+ pCheckBox->connect_toggled(LINK(this,ODateTimeDialog,CBClickHdl));
}
- void ODateTimeDialog::InsertEntry(sal_Int16 _nNumberFormatId)
+void ODateTimeDialog::InsertEntry(sal_Int16 _nNumberFormatId)
+{
+ const bool bTime = util::NumberFormat::TIME == _nNumberFormatId;
+ weld::ComboBoxText* pListBox = m_xDateListBox.get();
+ if (bTime)
+ pListBox = m_xTimeListBox.get();
+
+ const uno::Reference< util::XNumberFormatter> xNumberFormatter = m_pController->getReportNumberFormatter();
+ const uno::Reference< util::XNumberFormats> xFormats = xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats();
+ const uno::Sequence<sal_Int32> aFormatKeys = xFormats->queryKeys(_nNumberFormatId,m_nLocale,true);
+ const sal_Int32* pIter = aFormatKeys.getConstArray();
+ const sal_Int32* pEnd = pIter + aFormatKeys.getLength();
+ for (;pIter != pEnd; ++pIter)
{
- const bool bTime = util::NumberFormat::TIME == _nNumberFormatId;
- ListBox* pListBox = m_pDateListBox;
- if ( bTime )
- pListBox = m_pTimeListBox;
-
- const uno::Reference< util::XNumberFormatter> xNumberFormatter = m_pController->getReportNumberFormatter();
- const uno::Reference< util::XNumberFormats> xFormats = xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats();
- const uno::Sequence<sal_Int32> aFormatKeys = xFormats->queryKeys(_nNumberFormatId,m_nLocale,true);
- const sal_Int32* pIter = aFormatKeys.getConstArray();
- const sal_Int32* pEnd = pIter + aFormatKeys.getLength();
- for(;pIter != pEnd;++pIter)
- {
- const sal_Int16 nPos = pListBox->InsertEntry(getFormatStringByKey(*pIter,xFormats,bTime));
- pListBox->SetEntryData(nPos, reinterpret_cast<void*>(*pIter));
- }
+ pListBox->append(OUString::number(*pIter), getFormatStringByKey(*pIter,xFormats,bTime));
}
-
-ODateTimeDialog::~ODateTimeDialog()
-{
- disposeOnce();
-}
-
-void ODateTimeDialog::dispose()
-{
- m_pDate.clear();
- m_pFTDateFormat.clear();
- m_pDateListBox.clear();
- m_pTime.clear();
- m_pFTTimeFormat.clear();
- m_pTimeListBox.clear();
- m_pPB_OK.clear();
- ModalDialog::dispose();
}
-short ODateTimeDialog::Execute()
+short ODateTimeDialog::execute()
{
- short nRet = ModalDialog::Execute();
- if ( nRet == RET_OK && (m_pDate->IsChecked() || m_pTime->IsChecked()) )
+ short nRet = m_xDialog->run();
+ if (nRet == RET_OK && (m_xDate->get_active() || m_xTime->get_active()))
{
try
{
@@ -134,10 +105,10 @@ short ODateTimeDialog::Execute()
aValues[nLength++].Value <<= m_xHoldAlive;
aValues[nLength].Name = PROPERTY_TIME_STATE;
- aValues[nLength++].Value <<= m_pTime->IsChecked();
+ aValues[nLength++].Value <<= m_xTime->get_active();
aValues[nLength].Name = PROPERTY_DATE_STATE;
- aValues[nLength++].Value <<= m_pDate->IsChecked();
+ aValues[nLength++].Value <<= m_xDate->get_active();
aValues[nLength].Name = PROPERTY_FORMATKEYDATE;
aValues[nLength++].Value <<= getFormatKey(true);
@@ -145,16 +116,19 @@ short ODateTimeDialog::Execute()
aValues[nLength].Name = PROPERTY_FORMATKEYTIME;
aValues[nLength++].Value <<= getFormatKey(false);
+ OutputDevice* pDefDev = Application::GetDefaultDevice();
sal_Int32 nWidth = 0;
- if ( m_pDate->IsChecked() )
+ if ( m_xDate->get_active() )
{
- OUString sDateFormat = m_pDateListBox->GetSelectedEntry();
- nWidth = LogicToLogic(PixelToLogic(Size(GetCtrlTextWidth(sDateFormat),0)).Width(),GetMapMode().GetMapUnit(),MapUnit::Map100thMM);
+ OUString sDateFormat = m_xDateListBox->get_active_text();
+ nWidth = OutputDevice::LogicToLogic(pDefDev->PixelToLogic(Size(pDefDev->GetCtrlTextWidth(sDateFormat),0)).Width(),
+ pDefDev->GetMapMode().GetMapUnit(),MapUnit::Map100thMM);
}
- if ( m_pTime->IsChecked() )
+ if ( m_xTime->get_active() )
{
- OUString sDateFormat = m_pTimeListBox->GetSelectedEntry();
- nWidth = ::std::max<sal_Int32>(LogicToLogic(PixelToLogic(Size(GetCtrlTextWidth(sDateFormat),0)).Width(),GetMapMode().GetMapUnit(),MapUnit::Map100thMM),nWidth);
+ OUString sDateFormat = m_xTimeListBox->get_active_text();
+ nWidth = ::std::max<sal_Int32>(OutputDevice::LogicToLogic(pDefDev->PixelToLogic(Size(pDefDev->GetCtrlTextWidth(sDateFormat),0)).Width(),
+ pDefDev->GetMapMode().GetMapUnit(),MapUnit::Map100thMM),nWidth);
}
if ( nWidth > 4000 )
@@ -198,20 +172,23 @@ OUString ODateTimeDialog::getFormatStringByKey(::sal_Int32 _nNumberFormatKey,con
return xPreviewer->convertNumberToPreviewString(sFormat,nValue,m_nLocale,true);
}
-IMPL_LINK( ODateTimeDialog, CBClickHdl, Button*, _pBox, void )
+IMPL_LINK_NOARG(ODateTimeDialog, CBClickHdl, weld::ToggleButton&, void)
{
- if ( _pBox == m_pDate || _pBox == m_pTime)
+ const bool bDate = m_xDate->get_active();
+ m_xFTDateFormat->set_sensitive(bDate);
+ m_xDateListBox->set_sensitive(bDate);
+
+ const bool bTime = m_xTime->get_active();
+ m_xFTTimeFormat->set_sensitive(bTime);
+ m_xTimeListBox->set_sensitive(bTime);
+
+ if (!bDate && !bTime)
{
- bool bDate = m_pDate->IsChecked();
- bool bTime = m_pTime->IsChecked();
- if (!bDate && !bTime)
- {
- m_pPB_OK->Disable();
- }
- else
- {
- m_pPB_OK->Enable();
- }
+ m_xPB_OK->set_sensitive(false);
+ }
+ else
+ {
+ m_xPB_OK->set_sensitive(true);
}
}
@@ -220,11 +197,11 @@ sal_Int32 ODateTimeDialog::getFormatKey(bool _bDate) const
sal_Int32 nFormatKey;
if ( _bDate )
{
- nFormatKey = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(m_pDateListBox->GetSelectedEntryData()));
+ nFormatKey = m_xDateListBox->get_active_id().toInt32();
}
else
{
- nFormatKey = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(m_pTimeListBox->GetSelectedEntryData()));
+ nFormatKey = m_xTimeListBox->get_active_id().toInt32();
}
return nFormatKey;
}
diff --git a/reportdesign/source/ui/inc/DateTime.hxx b/reportdesign/source/ui/inc/DateTime.hxx
index 2409cceb6cf8..0d5953498627 100644
--- a/reportdesign/source/ui/inc/DateTime.hxx
+++ b/reportdesign/source/ui/inc/DateTime.hxx
@@ -19,11 +19,7 @@
#ifndef INCLUDED_REPORTDESIGN_SOURCE_UI_INC_DATETIME_HXX
#define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_DATETIME_HXX
-#include <vcl/dialog.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/lstbox.hxx>
-#include <vcl/field.hxx>
-#include <vcl/button.hxx>
+#include <vcl/weld.hxx>
#include <com/sun/star/report/XSection.hpp>
#include <com/sun/star/util/XNumberFormats.hpp>
#include <com/sun/star/lang/Locale.hpp>
@@ -38,24 +34,21 @@ class OReportController;
|* Groups and Sorting dialog
|*
\************************************************************************/
-class ODateTimeDialog : public ModalDialog
+class ODateTimeDialog : public weld::GenericDialogController
{
- VclPtr<CheckBox> m_pDate;
- VclPtr<FixedText> m_pFTDateFormat;
- VclPtr<ListBox> m_pDateListBox;
- VclPtr<CheckBox> m_pTime;
- VclPtr<FixedText> m_pFTTimeFormat;
- VclPtr<ListBox> m_pTimeListBox;
- VclPtr<OKButton> m_pPB_OK;
-
- svt::ControlDependencyManager m_aDateControlling;
- svt::ControlDependencyManager m_aTimeControlling;
-
::rptui::OReportController* m_pController;
css::uno::Reference< css::report::XSection>
m_xHoldAlive;
css::lang::Locale m_nLocale;
+ std::unique_ptr<weld::CheckButton> m_xDate;
+ std::unique_ptr<weld::Label> m_xFTDateFormat;
+ std::unique_ptr<weld::ComboBoxText> m_xDateListBox;
+ std::unique_ptr<weld::CheckButton> m_xTime;
+ std::unique_ptr<weld::Label> m_xFTTimeFormat;
+ std::unique_ptr<weld::ComboBoxText> m_xTimeListBox;
+ std::unique_ptr<weld::Button> m_xPB_OK;
+
/** returns the format string
*
* \param _nNumberFormatKey the number format key
@@ -70,19 +63,17 @@ class ODateTimeDialog : public ModalDialog
*/
sal_Int32 getFormatKey(bool _bDate) const;
- DECL_LINK( CBClickHdl, Button*, void );
+ DECL_LINK(CBClickHdl, weld::ToggleButton&, void);
ODateTimeDialog(const ODateTimeDialog&) = delete;
void operator =(const ODateTimeDialog&) = delete;
// fill methods
void InsertEntry(sal_Int16 _nNumberFormatId);
public:
- ODateTimeDialog( vcl::Window* pParent
- ,const css::uno::Reference< css::report::XSection>& _xHoldAlive
- ,::rptui::OReportController* _pController);
- virtual ~ODateTimeDialog() override;
- virtual void dispose() override;
- virtual short Execute() override;
+ ODateTimeDialog(weld::Window* pParent,
+ const css::uno::Reference< css::report::XSection>& _xHoldAlive,
+ ::rptui::OReportController* _pController);
+ short execute();
};
} // namespace rptui
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index b981e1bba458..32898fcc74a6 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -1554,8 +1554,8 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >
{
if ( !aArgs.getLength() )
{
- ScopedVclPtrInstance< ODateTimeDialog > aDlg(getView(),getDesignView()->getCurrentSection(),this);
- aDlg->Execute();
+ ODateTimeDialog aDlg(getFrameWeld(), getDesignView()->getCurrentSection(), this);
+ aDlg.execute();
}
else
createDateTime(aArgs);
diff --git a/reportdesign/uiconfig/dbreport/ui/datetimedialog.ui b/reportdesign/uiconfig/dbreport/ui/datetimedialog.ui
index 2b8434164886..5286cca6dff6 100644
--- a/reportdesign/uiconfig/dbreport/ui/datetimedialog.ui
+++ b/reportdesign/uiconfig/dbreport/ui/datetimedialog.ui
@@ -1,12 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="rpt">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="DateTimeDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="datetimedialog|DateTimeDialog">Date and Time</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>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -104,10 +110,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="datetimedialog|datelistbox_label">_Format:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">datelistbox</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -136,10 +142,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="datetimedialog|timelistbox_label">Fo_rmat:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">timelistbox</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -147,7 +153,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="timelistbox">
+ <object class="GtkComboBoxText" id="timelistbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -158,7 +164,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="datelistbox">
+ <object class="GtkComboBoxText" id="datelistbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
More information about the Libreoffice-commits
mailing list