summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-06-07 13:25:16 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-07-12 01:04:36 +0200
commit870c66694e7ed392141f0956ef74d1f71cdf8975 (patch)
treecd40e96a262bbbb9e40c230c29b2ed9210a8a371 /sw/source
parent75099d6788672a98389d8592b88777c8d3a25fa6 (diff)
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 <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/ui/dialog/swdlgfact.cxx11
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx14
-rw-r--r--sw/source/ui/dialog/swuiexp.cxx1
-rw-r--r--sw/source/ui/fldui/DateFormFieldDialog.cxx64
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx2
-rw-r--r--sw/source/uibase/inc/DateFormFieldDialog.hxx55
-rw-r--r--sw/source/uibase/shells/textsh1.cxx15
7 files changed, 160 insertions, 2 deletions
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;
}