LibreOffice Module sw (master) 1
datecontentcontrolbutton.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
12#include <svl/numformat.hxx>
13#include <tools/date.hxx>
14#include <vcl/svapp.hxx>
15
16#include <edtwin.hxx>
18#include <view.hxx>
19#include <wrtsh.hxx>
20
21IMPL_LINK(SwDateContentControlButton, SelectHandler, weld::Calendar&, rCalendar, void)
22{
23 const Date& rNullDate = m_pNumberFormatter->GetNullDate();
24 double fDate = rCalendar.get_date() - rNullDate;
25 m_xPopup->popdown();
26 m_pContentControl->SetSelectedDate(fDate);
27 SwView& rView = static_cast<SwEditWin*>(GetParent())->GetView();
28 SwWrtShell& rWrtShell = rView.GetWrtShell();
29 rWrtShell.GotoContentControl(*m_pContentControl->GetFormatContentControl());
30}
31
33 SwEditWin* pEditWin, const std::shared_ptr<SwContentControl>& pContentControl,
34 SvNumberFormatter* pNumberFormatter)
35 : SwContentControlButton(pEditWin, pContentControl)
36 , m_pNumberFormatter(pNumberFormatter)
37{
38}
39
41
43{
45 "modules/swriter/ui/contentcontrolcalendar.ui");
46 m_xPopup = m_xPopupBuilder->weld_popover("Calendar");
47 m_xCalendar = m_xPopupBuilder->weld_calendar("date");
48
49 // Read the doc model.
51 {
52 const Date& rNullDate = m_pNumberFormatter->GetNullDate();
53 double fCurrentDate = m_pContentControl->GetCurrentDateValue();
54 if (fCurrentDate != 0)
55 {
56 m_xCalendar->set_date(rNullDate + sal_Int32(fCurrentDate));
57 }
58 }
59
60 m_xCalendar->connect_activated(LINK(this, SwDateContentControlButton, SelectHandler));
62 m_xCalendar->grab_focus();
63}
64
66{
67 m_xCalendar.reset();
69}
70
71/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
const Date & GetNullDate() const
This button is shown when the cursor is inside a content control with drop-down capability.
std::shared_ptr< SwContentControl > m_pContentControl
std::unique_ptr< weld::Builder > m_xPopupBuilder
std::unique_ptr< weld::Popover > m_xPopup
This button is shown when the cursor is on a date content control.
std::unique_ptr< weld::Calendar > m_xCalendar
SwDateContentControlButton(SwEditWin *pEditWin, const std::shared_ptr< SwContentControl > &pContentControl, SvNumberFormatter *pNumberFormatter)
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:61
Definition: view.hxx:146
SwWrtShell & GetWrtShell() const
Definition: view.hxx:423
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
bool GotoContentControl(const SwFormatContentControl &rContentControl, bool bOnlyRefresh=false)
Definition: wrtsh3.cxx:96
weld::Window * GetFrameWeld() const
IMPL_LINK(SwDateContentControlButton, SelectHandler, weld::Calendar &, rCalendar, void)