include/xmloff/odffields.hxx | 1 sw/Library_swui.mk | 1 sw/UIConfig_swriter.mk | 1 sw/inc/swabstdlg.hxx | 3 sw/source/ui/dialog/swdlgfact.cxx | 11 + sw/source/ui/dialog/swdlgfact.hxx | 14 ++ sw/source/ui/dialog/swuiexp.cxx | 1 sw/source/ui/fldui/DateFormFieldDialog.cxx | 64 ++++++++++ sw/source/uibase/docvw/edtwin.cxx | 2 sw/source/uibase/inc/DateFormFieldDialog.hxx | 55 +++++++++ sw/source/uibase/shells/textsh1.cxx | 15 ++ sw/uiconfig/swriter/ui/dateformfielddialog.ui | 157 ++++++++++++++++++++++++++ 12 files changed, 323 insertions(+), 2 deletions(-)
New commits: commit 870c66694e7ed392141f0956ef74d1f71cdf8975 Author: Tamás Zolnai <[email protected]> AuthorDate: Fri Jun 7 13:25:16 2019 +0200 Commit: Tamás Zolnai <[email protected]> CommitDate: Fri Jul 12 01:04:36 2019 +0200 MSForms: Introduce a properties dialog for date form field * The dialog can be opened by the menu item and also by double click. * The dialog contains a list to specify the date format. Change-Id: I109a688752c5155f5bfabff272da3d6ab90dcded Reviewed-on: https://gerrit.libreoffice.org/75439 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <[email protected]> diff --git a/include/xmloff/odffields.hxx b/include/xmloff/odffields.hxx index 82127a57628e..0b0ec4676f39 100644 --- a/include/xmloff/odffields.hxx +++ b/include/xmloff/odffields.hxx @@ -34,6 +34,7 @@ #define ODF_FORMDROPDOWN_RESULT "Dropdown_Selected" #define ODF_FORMDATE "vnd.oasis.opendocument.field.FORMDATE" +#define ODF_FORMDATE_DATEFORMAT "DateField_DateFormat" #define ODF_TOC "vnd.oasis.opendocument.field.TOC" diff --git a/sw/Library_swui.mk b/sw/Library_swui.mk index 51d80f89cff9..915d5ac09464 100644 --- a/sw/Library_swui.mk +++ b/sw/Library_swui.mk @@ -109,6 +109,7 @@ $(eval $(call gb_Library_add_exception_objects,swui,\ sw/source/ui/envelp/labfmt \ sw/source/ui/envelp/labprt \ sw/source/ui/envelp/mailmrge \ + sw/source/ui/fldui/DateFormFieldDialog \ sw/source/ui/fldui/DropDownFieldDialog \ sw/source/ui/fldui/DropDownFormFieldDialog \ sw/source/ui/fldui/changedb \ diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 78536b90dd7a..0ddb67a241a0 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -122,6 +122,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/createautomarkdialog \ sw/uiconfig/swriter/ui/customizeaddrlistdialog \ sw/uiconfig/swriter/ui/datasourcesunavailabledialog \ + sw/uiconfig/swriter/ui/dateformfielddialog \ sw/uiconfig/swriter/ui/dropcapspage \ sw/uiconfig/swriter/ui/dropdownfielddialog \ sw/uiconfig/swriter/ui/dropdownformfielddialog \ diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 144c0bdb0e8b..c5607dceb0b8 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -390,6 +390,9 @@ public: virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Widget* pParent, SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) = 0; virtual VclPtr<VclAbstractDialog> CreateDropDownFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* pDropDownField) = 0; + + virtual VclPtr<VclAbstractDialog> CreateDateFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* pDateField) = 0; + virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) = 0; virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index c08ec419eb9c..c94c75b1f428 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -39,6 +39,7 @@ #include <dbinsdlg.hxx> #include <docfnote.hxx> #include <docstdlg.hxx> +#include <DateFormFieldDialog.hxx> #include <DropDownFieldDialog.hxx> #include <DropDownFormFieldDialog.hxx> #include <envlop.hxx> @@ -181,6 +182,11 @@ short AbstractDropDownFormFieldDialog_Impl::Execute() return m_xDlg->run(); } +short AbstractDateFormFieldDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + short AbstractSwLabDlg_Impl::Execute() { return m_xDlg->run(); @@ -872,6 +878,11 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateDropDownFormFieldD return VclPtr<AbstractDropDownFormFieldDialog_Impl>::Create(std::make_unique<sw::DropDownFormFieldDialog>(pParent, pDropDownField)); } +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateDateFormFieldDialog(weld::Widget *pParent, sw::mark::IFieldmark* pDateField) +{ + return VclPtr<AbstractDateFormFieldDialog_Impl>::Create(std::make_unique<sw::DateFormFieldDialog>(pParent, pDateField)); +} + VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 130343cf3330..8c70da33a556 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -50,6 +50,7 @@ namespace sw { class DropDownFieldDialog; class DropDownFormFieldDialog; +class DateFormFieldDialog; } #define DECL_ABSTDLG_BASE(Class,DialogClass) \ @@ -302,6 +303,17 @@ public: virtual short Execute() override; }; +class AbstractDateFormFieldDialog_Impl : public VclAbstractDialog +{ + std::unique_ptr<sw::DateFormFieldDialog> m_xDlg; +public: + explicit AbstractDateFormFieldDialog_Impl(std::unique_ptr<sw::DateFormFieldDialog> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; +}; + class AbstractSwLabDlg_Impl : public AbstractSwLabDlg { std::unique_ptr<SwLabDlg> m_xDlg; @@ -640,6 +652,8 @@ public: virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Widget* pParent, SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) override; virtual VclPtr<VclAbstractDialog> CreateDropDownFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* pDropDownField) override; + virtual VclPtr<VclAbstractDialog> CreateDateFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* pDateField) override; + virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) override; virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, SwDBManager* pDBManager, bool bLabel) override; diff --git a/sw/source/ui/dialog/swuiexp.cxx b/sw/source/ui/dialog/swuiexp.cxx index 048904334f8b..6dd7f675f793 100644 --- a/sw/source/ui/dialog/swuiexp.cxx +++ b/sw/source/ui/dialog/swuiexp.cxx @@ -28,6 +28,7 @@ #include <dbinsdlg.hxx> #include <DropDownFieldDialog.hxx> #include <DropDownFormFieldDialog.hxx> +#include <DateFormFieldDialog.hxx> #include <fldtdlg.hxx> #include <glossary.hxx> #include <inpdlg.hxx> diff --git a/sw/source/ui/fldui/DateFormFieldDialog.cxx b/sw/source/ui/fldui/DateFormFieldDialog.cxx new file mode 100644 index 000000000000..c5774e4b54af --- /dev/null +++ b/sw/source/ui/fldui/DateFormFieldDialog.cxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <DateFormFieldDialog.hxx> +#include <vcl/event.hxx> +#include <IMark.hxx> +#include <xmloff/odffields.hxx> + +namespace sw +{ +DateFormFieldDialog::DateFormFieldDialog(weld::Widget* pParent, mark::IFieldmark* pDateField) + : GenericDialogController(pParent, "modules/swriter/ui/dateformfielddialog.ui", + "DateFormFieldDialog") + , m_pDateField(pDateField) + , m_xFormatLB(new SwNumFormatTreeView(m_xBuilder->weld_tree_view("date_formats_treeview"))) +{ + m_xFormatLB->SetFormatType(SvNumFormatType::DATETIME); + m_xFormatLB->SetShowLanguageControl(true); + m_xFormatLB->SetAutomaticLanguage(true); + m_xFormatLB->SetOneArea(true); + + // Set a default height + weld::TreeView& rTreeView = dynamic_cast<weld::TreeView&>(m_xFormatLB->get_widget()); + rTreeView.set_size_request(rTreeView.get_preferred_size().Width(), + rTreeView.get_height_rows(10)); + InitControls(); +} + +DateFormFieldDialog::~DateFormFieldDialog() {} + +void DateFormFieldDialog::Apply() +{ + if (m_pDateField != nullptr) + { + mark::IFieldmark::parameter_map_t* pParameters = m_pDateField->GetParameters(); + (*pParameters)[ODF_FORMDATE_DATEFORMAT] <<= m_xFormatLB->GetFormat(); + } +} + +void DateFormFieldDialog::InitControls() +{ + if (m_pDateField != nullptr) + { + mark::IFieldmark::parameter_map_t* pParameters = m_pDateField->GetParameters(); + + auto pResult = pParameters->find(ODF_FORMDATE_DATEFORMAT); + if (pResult != pParameters->end()) + { + sal_uInt32 nDateFormat = 0; + pResult->second >>= nDateFormat; + m_xFormatLB->SetDefFormat(nDateFormat); + } + } +} + +} // namespace sw + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 692b1acddca0..8087d1dca59f 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -3378,7 +3378,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) aContentAtPos.aFnd.pFieldmark != nullptr) { IFieldmark *pFieldBM = const_cast< IFieldmark* > ( aContentAtPos.aFnd.pFieldmark ); - if ( pFieldBM->GetFieldname( ) == ODF_FORMDROPDOWN ) + if ( pFieldBM->GetFieldname( ) == ODF_FORMDROPDOWN || pFieldBM->GetFieldname( ) == ODF_FORMDATE ) { RstMBDownFlags(); rSh.getIDocumentMarkAccess()->ClearFieldActivation(); diff --git a/sw/source/uibase/inc/DateFormFieldDialog.hxx b/sw/source/uibase/inc/DateFormFieldDialog.hxx new file mode 100644 index 000000000000..cc3af63166e7 --- /dev/null +++ b/sw/source/uibase/inc/DateFormFieldDialog.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_DATEFORMFIELDDIALOG_HXX +#define INCLUDED_SW_SOURCE_UIBASE_INC_DATEFORMFIELDDIALOG_HXX + +#include <vcl/weld.hxx> +#include "actctrl.hxx" +#include "numfmtlb.hxx" + +namespace sw +{ +namespace mark +{ +class IFieldmark; +} +} // namespace sw + +/// Dialog to specify the properties of date form field +namespace sw +{ +class DateFormFieldDialog : public weld::GenericDialogController +{ +private: + mark::IFieldmark* m_pDateField; + + std::unique_ptr<SwNumFormatTreeView> m_xFormatLB; + + void Apply(); + void InitControls(); + +public: + DateFormFieldDialog(weld::Widget* pParent, mark::IFieldmark* pDateField); + virtual ~DateFormFieldDialog() override; + + virtual short run() override + { + short nRet = GenericDialogController::run(); + if (nRet == RET_OK) + Apply(); + return nRet; + } +}; + +} // namespace sw + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 704c54bb1e55..11f990d06d08 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1374,6 +1374,19 @@ void SwTextShell::Execute(SfxRequest &rReq) dynamic_cast<::sw::mark::DropDownFieldmark*>(pFieldBM)->HideButton(); } } + else if ( pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDATE ) + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateDateFormFieldDialog(rWrtSh.GetView().GetFrameWeld(), pFieldBM)); + if (pDlg->Execute() == RET_OK) + { + pFieldBM->Invalidate(); + rWrtSh.InvalidateWindows( rWrtSh.GetView().GetVisArea() ); + rWrtSh.UpdateCursor(); // cursor position might be invalid + // Hide the button here and make it visible later, to make transparent background work with SAL_USE_VCLPLUGIN=gen + dynamic_cast<::sw::mark::DateFieldmark*>(pFieldBM)->HideButton(); + } + } else { SfxRequest aReq( GetView().GetViewFrame(), SID_FM_CTL_PROPERTIES ); @@ -1942,7 +1955,7 @@ void SwTextShell::GetState( SfxItemSet &rSet ) --aPos.nContent; pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos); } - if ( pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDROPDOWN ) + if ( pFieldBM && (pFieldBM->GetFieldname() == ODF_FORMDROPDOWN || pFieldBM->GetFieldname() == ODF_FORMDATE) ) { bDisable = false; } diff --git a/sw/uiconfig/swriter/ui/dateformfielddialog.ui b/sw/uiconfig/swriter/ui/dateformfielddialog.ui new file mode 100644 index 000000000000..aa22008372ae --- /dev/null +++ b/sw/uiconfig/swriter/ui/dateformfielddialog.ui @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.4 --> +<interface domain="sw"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkDialog" id="DateFormFieldDialog"> + <property name="can_focus">False</property> + <property name="border_width">6</property> + <property name="title" translatable="yes" context="dateformfielddialog|DateFormFieldDialog">Date Picker Content Control</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="ok"> + <property name="label">gtk-ok</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_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="cancel"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="help"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + <property name="secondary">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="list_grid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">12</property> + <child> + <object class="GtkLabel" id="date_format_list_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="dateformfielddialog|date_format_list_label">Date Format</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">date_formats_treeview</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="date_formats_treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection1"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <child> + <object class="GtkCellRendererText" id="cellrenderertext1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-5">ok</action-widget> + <action-widget response="-6">cancel</action-widget> + <action-widget response="-11">help</action-widget> + </action-widgets> + <child> + <placeholder/> + </child> + </object> +</interface> _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
