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