Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / extensions / source / propctrlr / commoncontrol.cxx
blobc84593501edc94cc8b3c9b20efe0da1771c84cee
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "pcrcommon.hxx"
22 #include <tools/debug.hxx>
23 #include <tools/diagnose_ex.h>
24 #include <vcl/combobox.hxx>
25 #include <toolkit/helper/vclunohelper.hxx>
28 namespace pcr
32 using ::com::sun::star::uno::RuntimeException;
33 using ::com::sun::star::uno::Reference;
34 using ::com::sun::star::inspection::XPropertyControlContext;
35 using ::com::sun::star::uno::Exception;
36 using ::com::sun::star::inspection::XPropertyControl;
38 CommonBehaviourControlHelper::CommonBehaviourControlHelper( sal_Int16 _nControlType, XPropertyControl& _rAntiImpl )
39 :m_nControlType( _nControlType )
40 ,m_rAntiImpl( _rAntiImpl )
41 ,m_bModified( false )
46 CommonBehaviourControlHelper::~CommonBehaviourControlHelper()
50 void SAL_CALL CommonBehaviourControlHelper::setControlContext( const Reference< XPropertyControlContext >& _controlcontext )
52 m_xContext = _controlcontext;
55 void SAL_CALL CommonBehaviourControlHelper::notifyModifiedValue( )
57 if ( isModified() && m_xContext.is() )
59 try
61 m_xContext->valueChanged( &m_rAntiImpl );
62 m_bModified = false;
64 catch( const Exception& )
66 DBG_UNHANDLED_EXCEPTION();
72 void CommonBehaviourControlHelper::autoSizeWindow()
74 ScopedVclPtrInstance< ComboBox > aComboBox(getVclWindow(), WB_DROPDOWN);
75 aComboBox->SetPosSizePixel(Point(0,0), Size(100,100));
76 getVclWindow()->SetSizePixel(aComboBox->GetSizePixel());
78 // TODO/UNOize: why do the controls this themselves? Shouldn't this be the task
79 // of the browser listbox/line?
83 void CommonBehaviourControlHelper::activateNextControl() const
85 try
87 if ( m_xContext.is() )
88 m_xContext->activateNextControl( &m_rAntiImpl );
90 catch( const Exception& )
92 DBG_UNHANDLED_EXCEPTION();
97 IMPL_LINK_NOARG( CommonBehaviourControlHelper, EditModifiedHdl, Edit&, void )
99 setModified();
102 IMPL_LINK_NOARG( CommonBehaviourControlHelper, ModifiedHdl, ListBox&, void )
104 setModified();
107 IMPL_LINK_NOARG( CommonBehaviourControlHelper, ColorModifiedHdl, SvxColorListBox&, void )
109 setModified();
112 IMPL_LINK_NOARG( CommonBehaviourControlHelper, GetFocusHdl, Control&, void )
116 if ( m_xContext.is() )
117 m_xContext->focusGained( &m_rAntiImpl );
119 catch( const Exception& )
121 DBG_UNHANDLED_EXCEPTION();
126 IMPL_LINK_NOARG( CommonBehaviourControlHelper, LoseFocusHdl, Control&, void )
128 // TODO/UNOize: should this be outside the default control's implementations? If somebody
129 // has an own control implementation, which does *not* do this - would this be allowed?
130 // If not, then we must move this logic out of here.
131 notifyModifiedValue();
135 } // namespace pcr
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */