1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "commoncontrol.hxx"
21 #include <comphelper/diagnose_ex.hxx>
28 using ::com::sun::star::uno::Reference
;
29 using ::com::sun::star::inspection::XPropertyControlContext
;
30 using ::com::sun::star::uno::Exception
;
31 using ::com::sun::star::inspection::XPropertyControl
;
33 CommonBehaviourControlHelper::CommonBehaviourControlHelper( sal_Int16 _nControlType
, XPropertyControl
& _rAntiImpl
)
34 :m_nControlType( _nControlType
)
35 ,m_rAntiImpl( _rAntiImpl
)
41 CommonBehaviourControlHelper::~CommonBehaviourControlHelper()
45 void CommonBehaviourControlHelper::setControlContext( const Reference
< XPropertyControlContext
>& _controlcontext
)
47 m_xContext
= _controlcontext
;
50 void CommonBehaviourControlHelper::notifyModifiedValue( )
52 if ( isModified() && m_xContext
.is() )
56 m_xContext
->valueChanged( &m_rAntiImpl
);
59 catch( const Exception
& )
61 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
66 void CommonBehaviourControlHelper::editChanged()
71 IMPL_LINK_NOARG( CommonBehaviourControlHelper
, EditModifiedHdl
, weld::Entry
&, void )
76 IMPL_LINK_NOARG( CommonBehaviourControlHelper
, ModifiedHdl
, weld::ComboBox
&, void )
79 // notify as soon as the Data source is changed, don't wait until we lose focus
80 // because the Content dropdown cannot be populated after it is popped up
81 // and going from Data source direct to Content may give focus-lost to
82 // Content after the popup attempt is made
83 notifyModifiedValue();
86 IMPL_LINK_NOARG( CommonBehaviourControlHelper
, MetricModifiedHdl
, weld::MetricSpinButton
&, void )
91 IMPL_LINK_NOARG( CommonBehaviourControlHelper
, FormattedModifiedHdl
, weld::FormattedSpinButton
&, void )
96 IMPL_LINK_NOARG( CommonBehaviourControlHelper
, TimeModifiedHdl
, weld::FormattedSpinButton
&, void )
101 IMPL_LINK_NOARG( CommonBehaviourControlHelper
, DateModifiedHdl
, SvtCalendarBox
&, void )
106 IMPL_LINK_NOARG( CommonBehaviourControlHelper
, ColorModifiedHdl
, ColorListBox
&, void )
111 IMPL_LINK_NOARG( CommonBehaviourControlHelper
, GetFocusHdl
, weld::Widget
&, void )
115 if ( m_xContext
.is() )
116 m_xContext
->focusGained( &m_rAntiImpl
);
118 catch( const Exception
& )
120 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
124 IMPL_LINK_NOARG( CommonBehaviourControlHelper
, LoseFocusHdl
, weld::Widget
&, void )
126 // TODO/UNOize: should this be outside the default control's implementations? If somebody
127 // has an own control implementation, which does *not* do this - would this be allowed?
128 // If not, then we must move this logic out of here.
129 notifyModifiedValue();
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */