diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-07-15 11:54:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-15 15:02:27 +0200 |
commit | c8fed68b953e5c1b3101758413fac4809ff3380e (patch) | |
tree | c288041f51e02ed9f2d03255a2dc9e7c3a14c871 /svtools | |
parent | db9d871b2dc89ac1a09e17ec08a1570dae546025 (diff) |
move SVTXDateField to toolkit
and svtools CalendarField to vcl
Change-Id: I6f3e9a71f21ac7ca70f8172d4f8be4804f3b1c7f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98818
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/source/control/calendar.cxx | 235 | ||||
-rw-r--r-- | svtools/source/inc/unoiface.hxx | 14 | ||||
-rw-r--r-- | svtools/source/uno/unoiface.cxx | 53 |
4 files changed, 0 insertions, 303 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 3723fe67bb42..63bb7e13205d 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -92,7 +92,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/contnr/templwin \ svtools/source/control/accessibleruler \ svtools/source/control/asynclink \ - svtools/source/control/calendar \ svtools/source/control/collatorres \ svtools/source/control/ctrlbox \ svtools/source/control/ctrltool \ diff --git a/svtools/source/control/calendar.cxx b/svtools/source/control/calendar.cxx deleted file mode 100644 index f768e803185d..000000000000 --- a/svtools/source/control/calendar.cxx +++ /dev/null @@ -1,235 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <vcl/InterimItemWindow.hxx> -#include <vcl/event.hxx> -#include <vcl/dockwin.hxx> -#include <vcl/svapp.hxx> - -#include <svtools/strings.hrc> -#include <svtools/svtresid.hxx> -#include <svtools/calendar.hxx> - -namespace -{ - class ImplCFieldFloat final - { - private: - std::unique_ptr<weld::Builder> mxBuilder; - std::unique_ptr<weld::Container> mxContainer; - std::unique_ptr<weld::Calendar> mxCalendar; - std::unique_ptr<weld::Button> mxTodayBtn; - std::unique_ptr<weld::Button> mxNoneBtn; - - public: - ImplCFieldFloat(vcl::Window* pContainer) - : mxBuilder(Application::CreateInterimBuilder(pContainer, "svt/ui/calendar.ui")) - , mxContainer(mxBuilder->weld_container("Calendar")) - , mxCalendar(mxBuilder->weld_calendar("date")) - , mxTodayBtn(mxBuilder->weld_button("today")) - , mxNoneBtn(mxBuilder->weld_button("none")) - { - } - - weld::Calendar* GetCalendar() { return mxCalendar.get(); } - weld::Button* EnableTodayBtn(bool bEnable); - weld::Button* EnableNoneBtn(bool bEnable); - - void GrabFocus() - { - mxCalendar->grab_focus(); - } - }; -} - -struct ImplCFieldFloatWin : public DockingWindow -{ - explicit ImplCFieldFloatWin(vcl::Window* pParent); - virtual void dispose() override; - virtual ~ImplCFieldFloatWin() override; - virtual void GetFocus() override; - - VclPtr<vcl::Window> mxBox; - std::unique_ptr<ImplCFieldFloat> mxWidget; -}; - -ImplCFieldFloatWin::ImplCFieldFloatWin(vcl::Window* pParent) - : DockingWindow(pParent, "InterimDockParent", "svx/ui/interimdockparent.ui") - , mxBox(get("box")) -{ - setDeferredProperties(); - mxWidget.reset(new ImplCFieldFloat(mxBox.get())); -} - -ImplCFieldFloatWin::~ImplCFieldFloatWin() -{ - disposeOnce(); -} - -void ImplCFieldFloatWin::dispose() -{ - mxWidget.reset(); - mxBox.disposeAndClear(); - DockingWindow::dispose(); -} - -void ImplCFieldFloatWin::GetFocus() -{ - DockingWindow::GetFocus(); - if (!mxWidget) - return; - mxWidget->GrabFocus(); -} - -weld::Button* ImplCFieldFloat::EnableTodayBtn(bool bEnable) -{ - mxTodayBtn->set_visible(bEnable); - return bEnable ? mxTodayBtn.get() : nullptr; -} - -weld::Button* ImplCFieldFloat::EnableNoneBtn(bool bEnable) -{ - mxNoneBtn->set_visible(bEnable); - return bEnable ? mxNoneBtn.get() : nullptr; -} - -CalendarField::CalendarField(vcl::Window* pParent, WinBits nWinStyle) - : DateField(pParent, nWinStyle) - , mpFloatWin(nullptr) - , mpTodayBtn(nullptr) - , mpNoneBtn(nullptr) - , mbToday(false) - , mbNone(false) -{ -} - -CalendarField::~CalendarField() -{ - disposeOnce(); -} - -void CalendarField::dispose() -{ - mpTodayBtn = nullptr; - mpNoneBtn = nullptr; - mpFloatWin.disposeAndClear(); - DateField::dispose(); -} - -IMPL_LINK(CalendarField, ImplSelectHdl, weld::Calendar&, rCalendar, void) -{ - Date aNewDate = rCalendar.get_date(); - - vcl::Window::GetDockingManager()->EndPopupMode(mpFloatWin); - mpFloatWin->EnableDocking(false); - EndDropDown(); - GrabFocus(); - if ( IsEmptyDate() || ( aNewDate != GetDate() ) ) - { - SetDate( aNewDate ); - SetModifyFlag(); - Modify(); - } -} - -IMPL_LINK(CalendarField, ImplClickHdl, weld::Button&, rBtn, void) -{ - vcl::Window::GetDockingManager()->EndPopupMode(mpFloatWin); - mpFloatWin->EnableDocking(false); - EndDropDown(); - GrabFocus(); - - if (&rBtn == mpTodayBtn) - { - Date aToday( Date::SYSTEM ); - if ( (aToday != GetDate()) || IsEmptyDate() ) - { - SetDate( aToday ); - SetModifyFlag(); - Modify(); - } - } - else if (&rBtn == mpNoneBtn) - { - if ( !IsEmptyDate() ) - { - SetEmptyDate(); - SetModifyFlag(); - Modify(); - } - } -} - -IMPL_LINK_NOARG(CalendarField, ImplPopupModeEndHdl, FloatingWindow*, void) -{ - EndDropDown(); - GrabFocus(); -} - -bool CalendarField::ShowDropDown( bool bShow ) -{ - if ( bShow ) - { - if ( !mpFloatWin ) - mpFloatWin = VclPtr<ImplCFieldFloatWin>::Create( this ); - - Date aDate = GetDate(); - if ( IsEmptyDate() || !aDate.IsValidAndGregorian() ) - { - aDate = Date( Date::SYSTEM ); - } - weld::Calendar* pCalendar = mpFloatWin->mxWidget->GetCalendar(); - pCalendar->set_date( aDate ); - pCalendar->connect_activated(LINK(this, CalendarField, ImplSelectHdl)); - mpTodayBtn = mpFloatWin->mxWidget->EnableTodayBtn(mbToday); - mpNoneBtn = mpFloatWin->mxWidget->EnableNoneBtn(mbNone); - if (mpTodayBtn) - mpTodayBtn->connect_clicked( LINK( this, CalendarField, ImplClickHdl ) ); - if (mpNoneBtn) - mpNoneBtn->connect_clicked( LINK( this, CalendarField, ImplClickHdl ) ); - Point aPos(GetParent()->OutputToScreenPixel(GetPosPixel())); - tools::Rectangle aRect(aPos, GetSizePixel()); - aRect.AdjustBottom( -1 ); - DockingManager* pDockingManager = vcl::Window::GetDockingManager(); - mpFloatWin->EnableDocking(true); - pDockingManager->SetPopupModeEndHdl(mpFloatWin, LINK(this, CalendarField, ImplPopupModeEndHdl)); - pDockingManager->StartPopupMode(mpFloatWin, aRect, FloatWinPopupFlags::Down | FloatWinPopupFlags::GrabFocus); - } - else - { - vcl::Window::GetDockingManager()->EndPopupMode(mpFloatWin); - mpFloatWin->EnableDocking(false); - EndDropDown(); - } - return true; -} - -void CalendarField::StateChanged( StateChangedType nStateChange ) -{ - DateField::StateChanged( nStateChange ); - - if ( ( nStateChange == StateChangedType::Style ) && GetSubEdit() ) - { - WinBits nAllAlignmentBits = ( WB_LEFT | WB_CENTER | WB_RIGHT | WB_TOP | WB_VCENTER | WB_BOTTOM ); - WinBits nMyAlignment = GetStyle() & nAllAlignmentBits; - GetSubEdit()->SetStyle( ( GetSubEdit()->GetStyle() & ~nAllAlignmentBits ) | nMyAlignment ); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/inc/unoiface.hxx b/svtools/source/inc/unoiface.hxx index 7813b9ffe59c..1d3d5cb8ccd6 100644 --- a/svtools/source/inc/unoiface.hxx +++ b/svtools/source/inc/unoiface.hxx @@ -98,18 +98,4 @@ public: virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } }; -class SVTXDateField : public VCLXDateField -{ -public: - SVTXDateField(); - virtual ~SVTXDateField() override; - - // css::awt::VclWindowPeer - void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; - - static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); - virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } -}; - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index 7f10167cf64a..fbd257f8f13c 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -29,7 +29,6 @@ #include <toolkit/helper/convert.hxx> #include <toolkit/helper/property.hxx> #include <svl/numuno.hxx> -#include <svtools/calendar.hxx> #include "svtxgridcontrol.hxx" #include <table/tablecontrol.hxx> @@ -70,16 +69,6 @@ SAL_DLLPUBLIC_EXPORT vcl::Window* CreateWindow( VCLXWindow** ppNewComp, const cs return nullptr; } } - else if (aServiceName.equalsIgnoreAsciiCase("datefield") ) - { - pWindow = VclPtr<CalendarField>::Create( pParent, nWinBits); - static_cast<CalendarField*>(pWindow)->EnableToday(); - static_cast<CalendarField*>(pWindow)->EnableNone(); - static_cast<CalendarField*>(pWindow)->EnableEmptyFieldValue( true ); - SVTXDateField * newComp = new SVTXDateField; - *ppNewComp = newComp; - newComp->SetFormatter( static_cast<FormatterBase*>(static_cast<DateField*>(pWindow)) ); - } else if ( aServiceName.equalsIgnoreAsciiCase( "Grid" ) ) { if ( pParent ) @@ -467,46 +456,4 @@ void VCLXMultiLineEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) VCLXWindow::ImplGetPropertyIds( rIds, true ); } -SVTXDateField::SVTXDateField() - :VCLXDateField() -{ -} - -SVTXDateField::~SVTXDateField() -{ -} - -void SAL_CALL SVTXDateField::setProperty( const OUString& PropertyName, const css::uno::Any& Value ) -{ - VCLXDateField::setProperty( PropertyName, Value ); - - // some properties need to be forwarded to the sub edit, too - SolarMutexGuard g; - VclPtr< Edit > pSubEdit = GetWindow() ? static_cast< Edit* >( GetWindow().get() )->GetSubEdit() : nullptr; - if ( !pSubEdit ) - return; - - switch ( GetPropertyId( PropertyName ) ) - { - case BASEPROPERTY_TEXTLINECOLOR: - if ( !Value.hasValue() ) - pSubEdit->SetTextLineColor(); - else - { - sal_Int32 nColor = 0; - if ( Value >>= nColor ) - pSubEdit->SetTextLineColor( Color( nColor ) ); - } - break; - } -} - -void SVTXDateField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) -{ - PushPropertyIds( rIds, - BASEPROPERTY_TEXTLINECOLOR, - 0); - VCLXDateField::ImplGetPropertyIds( rIds ); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |