LibreOffice Module sw (master) 1
DateFormFieldButton.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
11#include <edtwin.hxx>
12#include <bookmark.hxx>
13#include <tools/date.hxx>
14#include <svl/numformat.hxx>
15#include <vcl/svapp.hxx>
16
17IMPL_LINK(DateFormFieldButton, ImplSelectHdl, weld::Calendar&, rCalendar, void)
18{
19 if (m_pDateFieldmark)
20 {
21 const Date& rNullDate = m_pNumberFormatter->GetNullDate();
22 double dDate = rCalendar.get_date() - rNullDate;
23 m_pDateFieldmark->SetCurrentDate(dDate);
24 }
25 m_xFieldPopup->popdown();
26}
27
29 SvNumberFormatter* pNumberFormatter)
30 : FormFieldButton(pEditWin, rFieldmark)
31 , m_pNumberFormatter(pNumberFormatter)
32 , m_pDateFieldmark(dynamic_cast<sw::mark::DateFieldmark*>(&m_rFieldmark))
33{
34}
35
37
39{
41 = Application::CreateBuilder(GetFrameWeld(), "modules/swriter/ui/calendar.ui");
42 m_xFieldPopup = m_xFieldPopupBuilder->weld_popover("Calendar");
43 m_xCalendar = m_xFieldPopupBuilder->weld_calendar("date");
45 {
46 std::pair<bool, double> aResult = m_pDateFieldmark->GetCurrentDate();
47 if (aResult.first)
48 {
49 const Date& rNullDate = m_pNumberFormatter->GetNullDate();
50 m_xCalendar->set_date(rNullDate + sal_Int32(aResult.second));
51 }
52 }
53 m_xCalendar->connect_activated(LINK(this, DateFormFieldButton, ImplSelectHdl));
55 m_xCalendar->grab_focus();
56}
57
59{
60 m_xCalendar.reset();
62}
63
64/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
IMPL_LINK(DateFormFieldButton, ImplSelectHdl, weld::Calendar &, rCalendar, void)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
This button is shown when the cursor is on a date form field.
SvNumberFormatter * m_pNumberFormatter
DateFormFieldButton(SwEditWin *pEditWin, sw::mark::DateFieldmark &rFieldMark, SvNumberFormatter *pNumberFormatter)
sw::mark::DateFieldmark * m_pDateFieldmark
std::unique_ptr< weld::Calendar > m_xCalendar
virtual ~DateFormFieldButton() override
virtual void LaunchPopup() override
virtual void DestroyPopup() override
This button is shown when the cursor is on a form field with drop-down capability.
std::unique_ptr< weld::Popover > m_xFieldPopup
virtual void DestroyPopup()
virtual void LaunchPopup()
std::unique_ptr< weld::Builder > m_xFieldPopupBuilder
const Date & GetNullDate() const
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:61
Fieldmark representing a date form field.
std::pair< bool, double > GetCurrentDate() const override
weld::Window * GetFrameWeld() const
Dialog to specify the properties of date form field.