20#include <com/sun/star/beans/XPropertySet.hpp>
21#include <rptui_slotid.hrc>
29#include <com/sun/star/util/NumberFormat.hpp>
30#include <com/sun/star/util/XNumberFormatPreviewer.hpp>
41 OReportController* _pController)
42 : GenericDialogController(_pParent,
"modules/dbreport/ui/datetimedialog.ui",
"DateTimeDialog")
44 , m_pController(_pController)
45 , m_xHoldAlive(
std::move(_xHoldAlive))
46 , m_xDate(m_xBuilder->weld_check_button(
"date"))
47 , m_xFTDateFormat(m_xBuilder->weld_label(
"datelistbox_label"))
48 , m_xDateListBox(m_xBuilder->weld_combo_box(
"datelistbox"))
49 , m_xTime(m_xBuilder->weld_check_button(
"time"))
50 , m_xFTTimeFormat(m_xBuilder->weld_label(
"timelistbox_label"))
51 , m_xTimeListBox(m_xBuilder->weld_combo_box(
"timelistbox"))
52 , m_xPB_OK(m_xBuilder->weld_button(
"ok"))
59 InsertEntry(util::NumberFormat::DATE);
60 InsertEntry(util::NumberFormat::TIME);
62 catch (
const uno::Exception&)
66 m_xDateListBox->set_active(0);
67 m_xTimeListBox->set_active(0);
75void ODateTimeDialog::InsertEntry(sal_Int16 _nNumberFormatId)
77 const bool bTime = util::NumberFormat::TIME == _nNumberFormatId;
80 pListBox = m_xTimeListBox.get();
82 const uno::Reference< util::XNumberFormatter> xNumberFormatter = m_pController->getReportNumberFormatter();
83 const uno::Reference< util::XNumberFormats> xFormats = xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats();
84 const uno::Sequence<sal_Int32> aFormatKeys = xFormats->queryKeys(_nNumberFormatId,m_nLocale,
true);
85 for (
const sal_Int32 nFormatKey : aFormatKeys)
87 pListBox->
append(OUString::number(nFormatKey), getFormatStringByKey(nFormatKey,xFormats,bTime));
91short ODateTimeDialog::run()
93 short nRet = GenericDialogController::run();
94 if (nRet ==
RET_OK && (m_xDate->get_active() || m_xTime->get_active()))
99 uno::Sequence<beans::PropertyValue> aValues( 6 );
100 auto pValues = aValues.getArray();
117 sal_Int32 nWidth = 0;
118 if ( m_xDate->get_active() )
120 OUString sDateFormat = m_xDateListBox->get_active_text();
124 if ( m_xTime->get_active() )
126 OUString sDateFormat = m_xTimeListBox->get_active_text();
137 m_pController->executeChecked(SID_DATETIME,aValues);
139 catch (
const uno::Exception&)
147OUString ODateTimeDialog::getFormatStringByKey(::sal_Int32 _nNumberFormatKey,
const uno::Reference< util::XNumberFormats>& _xFormats,
bool _bTime)
149 uno::Reference< beans::XPropertySet> xFormSet = _xFormats->getByKey(_nNumberFormatKey);
150 OSL_ENSURE(xFormSet.is(),
"XPropertySet is null!");
152 xFormSet->getPropertyValue(
"FormatString") >>= sFormat;
158 nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.
GetTime()));
163 static css::util::Date STANDARD_DB_DATE(30,12,1899);
164 nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(aCurrentDate.
GetDate()),STANDARD_DB_DATE);
167 uno::Reference< util::XNumberFormatPreviewer> xPreviewer(m_pController->getReportNumberFormatter(),uno::UNO_QUERY);
168 OSL_ENSURE(xPreviewer.is(),
"XNumberFormatPreviewer is null!");
169 return xPreviewer->convertNumberToPreviewString(sFormat,
nValue,m_nLocale,
true);
174 const bool bDate = m_xDate->get_active();
175 m_xFTDateFormat->set_sensitive(bDate);
176 m_xDateListBox->set_sensitive(bDate);
178 const bool bTime = m_xTime->get_active();
179 m_xFTTimeFormat->set_sensitive(bTime);
180 m_xTimeListBox->set_sensitive(bTime);
182 if (!bDate && !bTime)
184 m_xPB_OK->set_sensitive(
false);
188 m_xPB_OK->set_sensitive(
true);
192sal_Int32 ODateTimeDialog::getFormatKey(
bool _bDate)
const
194 sal_Int32 nFormatKey;
197 nFormatKey = m_xDateListBox->get_active_id().toInt32();
201 nFormatKey = m_xTimeListBox->get_active_id().toInt32();
const PropertyValue * pValues
static OutputDevice * GetDefaultDevice()
sal_Int32 GetDate() const
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
MapUnit GetMapUnit() const
tools::Long GetCtrlTextWidth(const OUString &rStr, const SalLayoutGlyphs *pLayoutCache=nullptr) const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const MapMode & GetMapMode() const
const LanguageTag & GetLanguageTag() const
void append(const weld::ComboBoxEntry &rItem)
virtual void connect_toggled(const Link< Toggleable &, void > &rLink)
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(ODateTimeDialog, CBClickHdl, weld::Toggleable &, void)
constexpr OUStringLiteral PROPERTY_DATE_STATE
constexpr OUStringLiteral PROPERTY_FORMATKEYDATE
constexpr OUStringLiteral PROPERTY_FORMATKEYTIME
constexpr OUStringLiteral PROPERTY_SECTION
constexpr OUStringLiteral PROPERTY_WIDTH
constexpr OUStringLiteral PROPERTY_TIME_STATE