1*24acc546SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*24acc546SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*24acc546SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*24acc546SAndrew Rist * distributed with this work for additional information
6*24acc546SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*24acc546SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*24acc546SAndrew Rist * "License"); you may not use this file except in compliance
9*24acc546SAndrew Rist * with the License. You may obtain a copy of the License at
10*24acc546SAndrew Rist *
11*24acc546SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*24acc546SAndrew Rist *
13*24acc546SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*24acc546SAndrew Rist * software distributed under the License is distributed on an
15*24acc546SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24acc546SAndrew Rist * KIND, either express or implied. See the License for the
17*24acc546SAndrew Rist * specific language governing permissions and limitations
18*24acc546SAndrew Rist * under the License.
19*24acc546SAndrew Rist *
20*24acc546SAndrew Rist *************************************************************/
21*24acc546SAndrew Rist
22*24acc546SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_forms.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "navbarcontrol.hxx"
28cdf0e10cSrcweir #include "frm_strings.hxx"
29cdf0e10cSrcweir #include "frm_module.hxx"
30cdf0e10cSrcweir #include "FormComponent.hxx"
31cdf0e10cSrcweir #include "componenttools.hxx"
32cdf0e10cSrcweir #include "navtoolbar.hxx"
33cdf0e10cSrcweir #include "commandimageprovider.hxx"
34cdf0e10cSrcweir #include "commanddescriptionprovider.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir /** === begin UNO includes === **/
37cdf0e10cSrcweir #include <com/sun/star/awt/XView.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
39cdf0e10cSrcweir #include <com/sun/star/form/runtime/FormFeature.hpp>
40cdf0e10cSrcweir #include <com/sun/star/awt/XControlModel.hpp>
41cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
42cdf0e10cSrcweir /** === end UNO includes === **/
43cdf0e10cSrcweir
44cdf0e10cSrcweir #include <tools/debug.hxx>
45cdf0e10cSrcweir #include <tools/diagnose_ex.h>
46cdf0e10cSrcweir #include <vcl/svapp.hxx>
47cdf0e10cSrcweir
48cdf0e10cSrcweir //--------------------------------------------------------------------------
createRegistryInfo_ONavigationBarControl()49cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_ONavigationBarControl()
50cdf0e10cSrcweir {
51cdf0e10cSrcweir static ::frm::OMultiInstanceAutoRegistration< ::frm::ONavigationBarControl > aAutoRegistration;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir
54cdf0e10cSrcweir //.........................................................................
55cdf0e10cSrcweir namespace frm
56cdf0e10cSrcweir {
57cdf0e10cSrcweir //.........................................................................
58cdf0e10cSrcweir
59cdf0e10cSrcweir using namespace ::com::sun::star::uno;
60cdf0e10cSrcweir using namespace ::com::sun::star::beans;
61cdf0e10cSrcweir using namespace ::com::sun::star::awt;
62cdf0e10cSrcweir using namespace ::com::sun::star::lang;
63cdf0e10cSrcweir using namespace ::com::sun::star::frame;
64cdf0e10cSrcweir using namespace ::com::sun::star::graphic;
65cdf0e10cSrcweir namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
66cdf0e10cSrcweir
67cdf0e10cSrcweir #define FORWARD_TO_PEER_1( unoInterface, method, param1 ) \
68cdf0e10cSrcweir Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \
69cdf0e10cSrcweir if ( xTypedPeer.is() ) \
70cdf0e10cSrcweir { \
71cdf0e10cSrcweir xTypedPeer->method( param1 ); \
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
74cdf0e10cSrcweir #define FORWARD_TO_PEER_1_RET( returnType, unoInterface, method, param1 ) \
75cdf0e10cSrcweir returnType aReturn; \
76cdf0e10cSrcweir Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \
77cdf0e10cSrcweir if ( xTypedPeer.is() ) \
78cdf0e10cSrcweir { \
79cdf0e10cSrcweir aReturn = xTypedPeer->method( param1 ); \
80cdf0e10cSrcweir } \
81cdf0e10cSrcweir return aReturn;
82cdf0e10cSrcweir
83cdf0e10cSrcweir #define FORWARD_TO_PEER_3( unoInterface, method, param1, param2, param3 ) \
84cdf0e10cSrcweir Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \
85cdf0e10cSrcweir if ( xTypedPeer.is() ) \
86cdf0e10cSrcweir { \
87cdf0e10cSrcweir xTypedPeer->method( param1, param2, param3 ); \
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
90cdf0e10cSrcweir #define FORWARD_TO_PEER_3_RET( returnType, unoInterface, method, param1, param2, param3 ) \
91cdf0e10cSrcweir returnType aReturn; \
92cdf0e10cSrcweir Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \
93cdf0e10cSrcweir if ( xTypedPeer.is() ) \
94cdf0e10cSrcweir { \
95cdf0e10cSrcweir aReturn = xTypedPeer->method( param1, param2, param3 ); \
96cdf0e10cSrcweir } \
97cdf0e10cSrcweir return aReturn;
98cdf0e10cSrcweir
99cdf0e10cSrcweir //==================================================================
100cdf0e10cSrcweir // ONavigationBarControl
101cdf0e10cSrcweir //==================================================================
DBG_NAME(ONavigationBarControl)102cdf0e10cSrcweir DBG_NAME( ONavigationBarControl )
103cdf0e10cSrcweir //------------------------------------------------------------------
104cdf0e10cSrcweir ONavigationBarControl::ONavigationBarControl( const Reference< XMultiServiceFactory >& _rxORB )
105cdf0e10cSrcweir :UnoControl( _rxORB )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir DBG_CTOR( ONavigationBarControl, NULL );
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
110cdf0e10cSrcweir //------------------------------------------------------------------
~ONavigationBarControl()111cdf0e10cSrcweir ONavigationBarControl::~ONavigationBarControl()
112cdf0e10cSrcweir {
113cdf0e10cSrcweir DBG_DTOR( ONavigationBarControl, NULL );
114cdf0e10cSrcweir }
115cdf0e10cSrcweir
116cdf0e10cSrcweir //------------------------------------------------------------------
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ONavigationBarControl,UnoControl,ONavigationBarControl_Base)117cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( ONavigationBarControl, UnoControl, ONavigationBarControl_Base )
118cdf0e10cSrcweir
119cdf0e10cSrcweir //------------------------------------------------------------------
120cdf0e10cSrcweir Any SAL_CALL ONavigationBarControl::queryAggregation( const Type& _rType ) throw ( RuntimeException )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir Any aReturn = UnoControl::queryAggregation( _rType );
123cdf0e10cSrcweir
124cdf0e10cSrcweir if ( !aReturn.hasValue() )
125cdf0e10cSrcweir aReturn = ONavigationBarControl_Base::queryInterface( _rType );
126cdf0e10cSrcweir
127cdf0e10cSrcweir return aReturn;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir //------------------------------------------------------------------
131cdf0e10cSrcweir namespace
132cdf0e10cSrcweir {
133cdf0e10cSrcweir //..............................................................
lcl_getWinBits_nothrow(const Reference<XControlModel> & _rxModel)134cdf0e10cSrcweir static WinBits lcl_getWinBits_nothrow( const Reference< XControlModel >& _rxModel )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir WinBits nBits = 0;
137cdf0e10cSrcweir try
138cdf0e10cSrcweir {
139cdf0e10cSrcweir Reference< XPropertySet > xProps( _rxModel, UNO_QUERY );
140cdf0e10cSrcweir if ( xProps.is() )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir sal_Int16 nBorder = 0;
143cdf0e10cSrcweir xProps->getPropertyValue( PROPERTY_BORDER ) >>= nBorder;
144cdf0e10cSrcweir if ( nBorder )
145cdf0e10cSrcweir nBits |= WB_BORDER;
146cdf0e10cSrcweir
147cdf0e10cSrcweir sal_Bool bTabStop = sal_False;
148cdf0e10cSrcweir if ( xProps->getPropertyValue( PROPERTY_TABSTOP ) >>= bTabStop )
149cdf0e10cSrcweir nBits |= ( bTabStop ? WB_TABSTOP : WB_NOTABSTOP );
150cdf0e10cSrcweir }
151cdf0e10cSrcweir }
152cdf0e10cSrcweir catch( const Exception& )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
155cdf0e10cSrcweir }
156cdf0e10cSrcweir return nBits;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
160cdf0e10cSrcweir //------------------------------------------------------------------
createPeer(const Reference<XToolkit> &,const Reference<XWindowPeer> & _rParentPeer)161cdf0e10cSrcweir void SAL_CALL ONavigationBarControl::createPeer( const Reference< XToolkit >& /*_rToolkit*/, const Reference< XWindowPeer >& _rParentPeer ) throw( RuntimeException )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
164cdf0e10cSrcweir
165cdf0e10cSrcweir if (!getPeer().is())
166cdf0e10cSrcweir {
167cdf0e10cSrcweir mbCreatingPeer = sal_True;
168cdf0e10cSrcweir
169cdf0e10cSrcweir // determine the VLC window for the parent
170cdf0e10cSrcweir Window* pParentWin = NULL;
171cdf0e10cSrcweir if ( _rParentPeer.is() )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir VCLXWindow* pParentXWin = VCLXWindow::GetImplementation( _rParentPeer );
174cdf0e10cSrcweir if ( pParentXWin )
175cdf0e10cSrcweir pParentWin = pParentXWin->GetWindow();
176cdf0e10cSrcweir DBG_ASSERT( pParentWin, "ONavigationBarControl::createPeer: could not obtain the VCL-level parent window!" );
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
179cdf0e10cSrcweir // create the peer
180cdf0e10cSrcweir ONavigationBarPeer* pPeer = ONavigationBarPeer::Create( maContext.getLegacyServiceFactory(), pParentWin, getModel() );
181cdf0e10cSrcweir DBG_ASSERT( pPeer, "ONavigationBarControl::createPeer: invalid peer returned!" );
182cdf0e10cSrcweir if ( pPeer )
183cdf0e10cSrcweir // by definition, the returned component is aquired once
184cdf0e10cSrcweir pPeer->release();
185cdf0e10cSrcweir
186cdf0e10cSrcweir // announce the peer to the base class
187cdf0e10cSrcweir setPeer( pPeer );
188cdf0e10cSrcweir
189cdf0e10cSrcweir // initialize ourself (and thus the peer) with the model properties
190cdf0e10cSrcweir updateFromModel();
191cdf0e10cSrcweir
192cdf0e10cSrcweir Reference< XView > xPeerView( getPeer(), UNO_QUERY );
193cdf0e10cSrcweir if ( xPeerView.is() )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY );
196cdf0e10cSrcweir xPeerView->setGraphics( mxGraphics );
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
199cdf0e10cSrcweir // a lot of initial settings from our component infos
200cdf0e10cSrcweir setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, PosSize::POSSIZE );
201cdf0e10cSrcweir
202cdf0e10cSrcweir pPeer->setVisible ( maComponentInfos.bVisible && !mbDesignMode );
203cdf0e10cSrcweir pPeer->setEnable ( maComponentInfos.bEnable );
204cdf0e10cSrcweir pPeer->setDesignMode( mbDesignMode );
205cdf0e10cSrcweir
206cdf0e10cSrcweir peerCreated();
207cdf0e10cSrcweir
208cdf0e10cSrcweir mbCreatingPeer = sal_False;
209cdf0e10cSrcweir
210cdf0e10cSrcweir OControl::initFormControlPeer( getPeer() );
211cdf0e10cSrcweir }
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir //------------------------------------------------------------------
getImplementationName()215cdf0e10cSrcweir ::rtl::OUString SAL_CALL ONavigationBarControl::getImplementationName() throw( RuntimeException )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir return getImplementationName_Static();
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir //------------------------------------------------------------------
getSupportedServiceNames()221cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ONavigationBarControl::getSupportedServiceNames() throw( RuntimeException )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir return getSupportedServiceNames_Static();
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
226cdf0e10cSrcweir //------------------------------------------------------------------
getImplementationName_Static()227cdf0e10cSrcweir ::rtl::OUString SAL_CALL ONavigationBarControl::getImplementationName_Static()
228cdf0e10cSrcweir {
229cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.form.ONavigationBarControl" ) );
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir //------------------------------------------------------------------
getSupportedServiceNames_Static()233cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ONavigationBarControl::getSupportedServiceNames_Static()
234cdf0e10cSrcweir {
235cdf0e10cSrcweir Sequence< ::rtl::OUString > aServices( 2 );
236cdf0e10cSrcweir aServices[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControl" ) );
237cdf0e10cSrcweir aServices[ 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.control.NavigationToolBar" ) );
238cdf0e10cSrcweir return aServices;
239cdf0e10cSrcweir }
240cdf0e10cSrcweir
241cdf0e10cSrcweir //------------------------------------------------------------------
Create(const Reference<XMultiServiceFactory> & _rxFactory)242cdf0e10cSrcweir Reference< XInterface > SAL_CALL ONavigationBarControl::Create( const Reference< XMultiServiceFactory >& _rxFactory )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir return *( new ONavigationBarControl( _rxFactory ) );
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
247cdf0e10cSrcweir //------------------------------------------------------------------
registerDispatchProviderInterceptor(const Reference<XDispatchProviderInterceptor> & _rxInterceptor)248cdf0e10cSrcweir void SAL_CALL ONavigationBarControl::registerDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException)
249cdf0e10cSrcweir {
250cdf0e10cSrcweir FORWARD_TO_PEER_1( XDispatchProviderInterception, registerDispatchProviderInterceptor, _rxInterceptor );
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
253cdf0e10cSrcweir //------------------------------------------------------------------
releaseDispatchProviderInterceptor(const Reference<XDispatchProviderInterceptor> & _rxInterceptor)254cdf0e10cSrcweir void SAL_CALL ONavigationBarControl::releaseDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException)
255cdf0e10cSrcweir {
256cdf0e10cSrcweir FORWARD_TO_PEER_1( XDispatchProviderInterception, releaseDispatchProviderInterceptor, _rxInterceptor );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
259cdf0e10cSrcweir //------------------------------------------------------------------
setDesignMode(sal_Bool _bOn)260cdf0e10cSrcweir void SAL_CALL ONavigationBarControl::setDesignMode( sal_Bool _bOn ) throw( RuntimeException )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir UnoControl::setDesignMode( _bOn );
263cdf0e10cSrcweir FORWARD_TO_PEER_1( XVclWindowPeer, setDesignMode, _bOn );
264cdf0e10cSrcweir }
265cdf0e10cSrcweir
266cdf0e10cSrcweir //==================================================================
267cdf0e10cSrcweir // ONavigationBarPeer
268cdf0e10cSrcweir //==================================================================
DBG_NAME(ONavigationBarPeer)269cdf0e10cSrcweir DBG_NAME( ONavigationBarPeer )
270cdf0e10cSrcweir //------------------------------------------------------------------
271cdf0e10cSrcweir ONavigationBarPeer* ONavigationBarPeer::Create( const Reference< XMultiServiceFactory >& _rxORB,
272cdf0e10cSrcweir Window* _pParentWindow, const Reference< XControlModel >& _rxModel )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir DBG_TESTSOLARMUTEX();
275cdf0e10cSrcweir
276cdf0e10cSrcweir // the peer itself
277cdf0e10cSrcweir ONavigationBarPeer* pPeer = new ONavigationBarPeer( _rxORB );
278cdf0e10cSrcweir pPeer->acquire(); // by definition, the returned object is aquired once
279cdf0e10cSrcweir
280cdf0e10cSrcweir // the VCL control for the peer
281cdf0e10cSrcweir Reference< XModel > xContextDocument( getXModel( _rxModel ) );
282cdf0e10cSrcweir NavigationToolBar* pNavBar = new NavigationToolBar(
283cdf0e10cSrcweir _pParentWindow,
284cdf0e10cSrcweir lcl_getWinBits_nothrow( _rxModel ),
285cdf0e10cSrcweir createDocumentCommandImageProvider( _rxORB, xContextDocument ),
286cdf0e10cSrcweir createDocumentCommandDescriptionProvider( _rxORB, xContextDocument )
287cdf0e10cSrcweir );
288cdf0e10cSrcweir
289cdf0e10cSrcweir // some knittings
290cdf0e10cSrcweir pNavBar->setDispatcher( pPeer );
291cdf0e10cSrcweir pNavBar->SetComponentInterface( pPeer );
292cdf0e10cSrcweir
293cdf0e10cSrcweir // we want a faster repeating rate for the slots in this
294cdf0e10cSrcweir // toolbox
295cdf0e10cSrcweir AllSettings aSettings = pNavBar->GetSettings();
296cdf0e10cSrcweir MouseSettings aMouseSettings = aSettings.GetMouseSettings();
297cdf0e10cSrcweir aMouseSettings.SetButtonRepeat( 10 );
298cdf0e10cSrcweir aSettings.SetMouseSettings( aMouseSettings );
299cdf0e10cSrcweir pNavBar->SetSettings( aSettings, sal_True );
300cdf0e10cSrcweir
301cdf0e10cSrcweir // outta here
302cdf0e10cSrcweir return pPeer;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
305cdf0e10cSrcweir //------------------------------------------------------------------
ONavigationBarPeer(const Reference<XMultiServiceFactory> & _rxORB)306cdf0e10cSrcweir ONavigationBarPeer::ONavigationBarPeer( const Reference< XMultiServiceFactory >& _rxORB )
307cdf0e10cSrcweir :OFormNavigationHelper( _rxORB )
308cdf0e10cSrcweir {
309cdf0e10cSrcweir DBG_CTOR( ONavigationBarPeer, NULL );
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
312cdf0e10cSrcweir //------------------------------------------------------------------
~ONavigationBarPeer()313cdf0e10cSrcweir ONavigationBarPeer::~ONavigationBarPeer()
314cdf0e10cSrcweir {
315cdf0e10cSrcweir DBG_DTOR( ONavigationBarPeer, NULL );
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir //------------------------------------------------------------------
IMPLEMENT_FORWARD_XINTERFACE2(ONavigationBarPeer,VCLXWindow,OFormNavigationHelper)319cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( ONavigationBarPeer, VCLXWindow, OFormNavigationHelper )
320cdf0e10cSrcweir
321cdf0e10cSrcweir //------------------------------------------------------------------
322cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( ONavigationBarPeer, VCLXWindow, OFormNavigationHelper )
323cdf0e10cSrcweir
324cdf0e10cSrcweir //------------------------------------------------------------------
325cdf0e10cSrcweir void SAL_CALL ONavigationBarPeer::dispose( ) throw( RuntimeException )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir VCLXWindow::dispose();
328cdf0e10cSrcweir OFormNavigationHelper::dispose();
329cdf0e10cSrcweir }
330cdf0e10cSrcweir
331cdf0e10cSrcweir //------------------------------------------------------------------
setProperty(const::rtl::OUString & _rPropertyName,const Any & _rValue)332cdf0e10cSrcweir void SAL_CALL ONavigationBarPeer::setProperty( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw( RuntimeException )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
335cdf0e10cSrcweir
336cdf0e10cSrcweir NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() );
337cdf0e10cSrcweir if ( !pNavBar )
338cdf0e10cSrcweir {
339cdf0e10cSrcweir VCLXWindow::setProperty( _rPropertyName, _rValue );
340cdf0e10cSrcweir return;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir
343cdf0e10cSrcweir bool bVoid = !_rValue.hasValue();
344cdf0e10cSrcweir
345cdf0e10cSrcweir sal_Bool bBoolValue = sal_False;
346cdf0e10cSrcweir sal_Int32 nColor = COL_TRANSPARENT;
347cdf0e10cSrcweir
348cdf0e10cSrcweir // TODO: more generic mechanisms for this (the grid control implementation,
349cdf0e10cSrcweir // when used herein, will do the same stuff for lot of these)
350cdf0e10cSrcweir
351cdf0e10cSrcweir if ( _rPropertyName.equals( PROPERTY_BACKGROUNDCOLOR ) )
352cdf0e10cSrcweir {
353cdf0e10cSrcweir Wallpaper aTest = pNavBar->GetBackground();
354cdf0e10cSrcweir if ( bVoid )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir pNavBar->SetBackground( pNavBar->GetSettings().GetStyleSettings().GetFaceColor() );
357cdf0e10cSrcweir pNavBar->SetControlBackground();
358cdf0e10cSrcweir }
359cdf0e10cSrcweir else
360cdf0e10cSrcweir {
361cdf0e10cSrcweir OSL_VERIFY( _rValue >>= nColor );
362cdf0e10cSrcweir Color aColor( nColor );
363cdf0e10cSrcweir pNavBar->SetBackground( aColor );
364cdf0e10cSrcweir pNavBar->SetControlBackground( aColor );
365cdf0e10cSrcweir }
366cdf0e10cSrcweir }
367cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_TEXTLINECOLOR ) )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir if ( bVoid )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir pNavBar->SetTextLineColor();
372cdf0e10cSrcweir }
373cdf0e10cSrcweir else
374cdf0e10cSrcweir {
375cdf0e10cSrcweir OSL_VERIFY( _rValue >>= nColor );
376cdf0e10cSrcweir Color aColor( nColor );
377cdf0e10cSrcweir pNavBar->SetTextLineColor( nColor );
378cdf0e10cSrcweir }
379cdf0e10cSrcweir }
380cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_ICONSIZE ) )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir sal_Int16 nInt16Value = 0;
383cdf0e10cSrcweir OSL_VERIFY( _rValue >>= nInt16Value );
384cdf0e10cSrcweir pNavBar->SetImageSize( nInt16Value ? NavigationToolBar::eLarge : NavigationToolBar::eSmall );
385cdf0e10cSrcweir }
386cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_SHOW_POSITION ) )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir OSL_VERIFY( _rValue >>= bBoolValue );
389cdf0e10cSrcweir pNavBar->ShowFunctionGroup( NavigationToolBar::ePosition, bBoolValue );
390cdf0e10cSrcweir }
391cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_SHOW_NAVIGATION ) )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir OSL_VERIFY( _rValue >>= bBoolValue );
394cdf0e10cSrcweir pNavBar->ShowFunctionGroup( NavigationToolBar::eNavigation, bBoolValue );
395cdf0e10cSrcweir }
396cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_SHOW_RECORDACTIONS ) )
397cdf0e10cSrcweir {
398cdf0e10cSrcweir OSL_VERIFY( _rValue >>= bBoolValue );
399cdf0e10cSrcweir pNavBar->ShowFunctionGroup( NavigationToolBar::eRecordActions, bBoolValue );
400cdf0e10cSrcweir }
401cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_SHOW_FILTERSORT ) )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir OSL_VERIFY( _rValue >>= bBoolValue );
404cdf0e10cSrcweir pNavBar->ShowFunctionGroup( NavigationToolBar::eFilterSort, bBoolValue );
405cdf0e10cSrcweir }
406cdf0e10cSrcweir else
407cdf0e10cSrcweir {
408cdf0e10cSrcweir VCLXWindow::setProperty( _rPropertyName, _rValue );
409cdf0e10cSrcweir }
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
412cdf0e10cSrcweir //------------------------------------------------------------------
getProperty(const::rtl::OUString & _rPropertyName)413cdf0e10cSrcweir Any SAL_CALL ONavigationBarPeer::getProperty( const ::rtl::OUString& _rPropertyName ) throw( RuntimeException )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
416cdf0e10cSrcweir
417cdf0e10cSrcweir Any aReturn;
418cdf0e10cSrcweir NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() );
419cdf0e10cSrcweir
420cdf0e10cSrcweir if ( _rPropertyName.equals( PROPERTY_BACKGROUNDCOLOR ) )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir aReturn <<= (sal_Int32)pNavBar->GetControlBackground().GetColor();
423cdf0e10cSrcweir }
424cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_TEXTLINECOLOR ) )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir aReturn <<= (sal_Int32)pNavBar->GetTextLineColor().GetColor();
427cdf0e10cSrcweir }
428cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_ICONSIZE ) )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir sal_Int16 nIconType = ( NavigationToolBar::eLarge == pNavBar->GetImageSize() )
431cdf0e10cSrcweir ? 1 : 0;
432cdf0e10cSrcweir aReturn <<= nIconType;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_SHOW_POSITION ) )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir aReturn <<= (sal_Bool)( pNavBar->IsFunctionGroupVisible( NavigationToolBar::ePosition ) );
437cdf0e10cSrcweir }
438cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_SHOW_NAVIGATION ) )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir aReturn <<= (sal_Bool)( pNavBar->IsFunctionGroupVisible( NavigationToolBar::eNavigation ) );
441cdf0e10cSrcweir }
442cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_SHOW_RECORDACTIONS ) )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir aReturn <<= (sal_Bool)( pNavBar->IsFunctionGroupVisible( NavigationToolBar::eRecordActions ) );
445cdf0e10cSrcweir }
446cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_SHOW_FILTERSORT ) )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir aReturn <<= (sal_Bool)( pNavBar->IsFunctionGroupVisible( NavigationToolBar::eFilterSort ) );
449cdf0e10cSrcweir }
450cdf0e10cSrcweir else
451cdf0e10cSrcweir aReturn = VCLXWindow::getProperty( _rPropertyName );
452cdf0e10cSrcweir
453cdf0e10cSrcweir return aReturn;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir
456cdf0e10cSrcweir //------------------------------------------------------------------
interceptorsChanged()457cdf0e10cSrcweir void ONavigationBarPeer::interceptorsChanged( )
458cdf0e10cSrcweir {
459cdf0e10cSrcweir if ( isDesignMode() )
460cdf0e10cSrcweir // not interested in if we're in design mode
461cdf0e10cSrcweir return;
462cdf0e10cSrcweir
463cdf0e10cSrcweir OFormNavigationHelper::interceptorsChanged();
464cdf0e10cSrcweir }
465cdf0e10cSrcweir
466cdf0e10cSrcweir //------------------------------------------------------------------
featureStateChanged(sal_Int16 _nFeatureId,sal_Bool _bEnabled)467cdf0e10cSrcweir void ONavigationBarPeer::featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled )
468cdf0e10cSrcweir {
469cdf0e10cSrcweir // enable this button on the toolbox
470cdf0e10cSrcweir NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() );
471cdf0e10cSrcweir if ( pNavBar )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir pNavBar->enableFeature( _nFeatureId, _bEnabled );
474cdf0e10cSrcweir
475cdf0e10cSrcweir // is it a feature with additional state information?
476cdf0e10cSrcweir if ( _nFeatureId == FormFeature::ToggleApplyFilter )
477cdf0e10cSrcweir { // additional boolean state
478cdf0e10cSrcweir pNavBar->checkFeature( _nFeatureId, getBooleanState( _nFeatureId ) );
479cdf0e10cSrcweir }
480cdf0e10cSrcweir else if ( _nFeatureId == FormFeature::TotalRecords )
481cdf0e10cSrcweir {
482cdf0e10cSrcweir pNavBar->setFeatureText( _nFeatureId, getStringState( _nFeatureId ) );
483cdf0e10cSrcweir }
484cdf0e10cSrcweir else if ( _nFeatureId == FormFeature::MoveAbsolute )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir pNavBar->setFeatureText( _nFeatureId, String::CreateFromInt32( getIntegerState( _nFeatureId ) ) );
487cdf0e10cSrcweir }
488cdf0e10cSrcweir }
489cdf0e10cSrcweir
490cdf0e10cSrcweir // base class
491cdf0e10cSrcweir OFormNavigationHelper::featureStateChanged( _nFeatureId, _bEnabled );
492cdf0e10cSrcweir }
493cdf0e10cSrcweir
494cdf0e10cSrcweir //------------------------------------------------------------------
allFeatureStatesChanged()495cdf0e10cSrcweir void ONavigationBarPeer::allFeatureStatesChanged( )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir // force the control to update it's states
498cdf0e10cSrcweir NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() );
499cdf0e10cSrcweir if ( pNavBar )
500cdf0e10cSrcweir pNavBar->setDispatcher( this );
501cdf0e10cSrcweir
502cdf0e10cSrcweir // base class
503cdf0e10cSrcweir OFormNavigationHelper::allFeatureStatesChanged( );
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
506cdf0e10cSrcweir //------------------------------------------------------------------
isEnabled(sal_Int16 _nFeatureId) const507cdf0e10cSrcweir bool ONavigationBarPeer::isEnabled( sal_Int16 _nFeatureId ) const
508cdf0e10cSrcweir {
509cdf0e10cSrcweir if ( const_cast< ONavigationBarPeer* >( this )->isDesignMode() )
510cdf0e10cSrcweir return false;
511cdf0e10cSrcweir
512cdf0e10cSrcweir return OFormNavigationHelper::isEnabled( _nFeatureId );
513cdf0e10cSrcweir }
514cdf0e10cSrcweir
515cdf0e10cSrcweir //------------------------------------------------------------------
setDesignMode(sal_Bool _bOn)516cdf0e10cSrcweir void SAL_CALL ONavigationBarPeer::setDesignMode( sal_Bool _bOn ) throw( RuntimeException )
517cdf0e10cSrcweir {
518cdf0e10cSrcweir VCLXWindow::setDesignMode( _bOn );
519cdf0e10cSrcweir
520cdf0e10cSrcweir if ( _bOn )
521cdf0e10cSrcweir disconnectDispatchers();
522cdf0e10cSrcweir else
523cdf0e10cSrcweir connectDispatchers();
524cdf0e10cSrcweir // this will connect if not already connected and just update else
525cdf0e10cSrcweir }
526cdf0e10cSrcweir
527cdf0e10cSrcweir //------------------------------------------------------------------
disposing(const EventObject & _rSource)528cdf0e10cSrcweir void SAL_CALL ONavigationBarPeer::disposing( const EventObject& _rSource ) throw (RuntimeException)
529cdf0e10cSrcweir {
530cdf0e10cSrcweir VCLXWindow::disposing( _rSource );
531cdf0e10cSrcweir OFormNavigationHelper::disposing( _rSource );
532cdf0e10cSrcweir }
533cdf0e10cSrcweir
534cdf0e10cSrcweir //------------------------------------------------------------------
getSupportedFeatures(::std::vector<sal_Int16> & _rFeatureIds)535cdf0e10cSrcweir void ONavigationBarPeer::getSupportedFeatures( ::std::vector< sal_Int16 >& _rFeatureIds )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::MoveAbsolute );
538cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::TotalRecords );
539cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::MoveToFirst );
540cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::MoveToPrevious );
541cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::MoveToNext );
542cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::MoveToLast );
543cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::SaveRecordChanges );
544cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::UndoRecordChanges );
545cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::MoveToInsertRow );
546cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::DeleteRecord );
547cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::ReloadForm );
548cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::RefreshCurrentControl );
549cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::SortAscending );
550cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::SortDescending );
551cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::InteractiveSort );
552cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::AutoFilter );
553cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::InteractiveFilter );
554cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::ToggleApplyFilter );
555cdf0e10cSrcweir _rFeatureIds.push_back( FormFeature::RemoveFilterAndSort );
556cdf0e10cSrcweir }
557cdf0e10cSrcweir
558cdf0e10cSrcweir //.........................................................................
559cdf0e10cSrcweir } // namespace frm
560cdf0e10cSrcweir //.........................................................................
561