summaryrefslogtreecommitdiff
path: root/reportdesign/source/ui/dlg/DateTime.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'reportdesign/source/ui/dlg/DateTime.cxx')
-rw-r--r--reportdesign/source/ui/dlg/DateTime.cxx143
1 files changed, 60 insertions, 83 deletions
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;
}