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 #include "navigationbar.hxx"
31*cdf0e10cSrcweir #include "frm_module.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <com/sun/star/text/WritingMode2.hpp>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <comphelper/streamsection.hxx>
36*cdf0e10cSrcweir #include <comphelper/basicio.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir //--------------------------------------------------------------------------
39*cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_ONavigationBarModel()
40*cdf0e10cSrcweir {
41*cdf0e10cSrcweir     static ::frm::OMultiInstanceAutoRegistration< ::frm::ONavigationBarModel > aAutoRegistration;
42*cdf0e10cSrcweir }
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir //.........................................................................
45*cdf0e10cSrcweir namespace frm
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir //.........................................................................
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir     using namespace ::com::sun::star::uno;
50*cdf0e10cSrcweir     using namespace ::com::sun::star::beans;
51*cdf0e10cSrcweir     using namespace ::com::sun::star::form;
52*cdf0e10cSrcweir     using namespace ::com::sun::star::awt;
53*cdf0e10cSrcweir     using namespace ::com::sun::star::io;
54*cdf0e10cSrcweir     using namespace ::com::sun::star::lang;
55*cdf0e10cSrcweir     using namespace ::com::sun::star::util;
56*cdf0e10cSrcweir     using namespace ::com::sun::star::container;
57*cdf0e10cSrcweir     using namespace ::comphelper;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #define REGISTER_VOID_PROP( prop, memberAny, type ) \
62*cdf0e10cSrcweir     registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::MAYBEVOID, \
63*cdf0e10cSrcweir         &memberAny, ::getCppuType( static_cast< type* >( NULL ) ) );
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     //==================================================================
66*cdf0e10cSrcweir     // ONavigationBarModel
67*cdf0e10cSrcweir     //==================================================================
68*cdf0e10cSrcweir     DBG_NAME( ONavigationBarModel )
69*cdf0e10cSrcweir     //------------------------------------------------------------------
70*cdf0e10cSrcweir     ONavigationBarModel::ONavigationBarModel( const Reference< XMultiServiceFactory >& _rxFactory )
71*cdf0e10cSrcweir         :OControlModel( _rxFactory, ::rtl::OUString() )
72*cdf0e10cSrcweir         ,FontControlModel( true )
73*cdf0e10cSrcweir     {
74*cdf0e10cSrcweir     	DBG_CTOR( ONavigationBarModel, NULL );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         m_nClassId = FormComponentType::NAVIGATIONBAR;
77*cdf0e10cSrcweir         implInitPropertyContainer();
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_DEFAULTCONTROL          ) >>= m_sDefaultControl;
80*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_ICONSIZE                ) >>= m_nIconSize;
81*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_BORDER                  ) >>= m_nBorder;
82*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_DELAY                   ) >>= m_nDelay;
83*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_ENABLED                 ) >>= m_bEnabled;
84*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_ENABLEVISIBLE           ) >>= m_bEnableVisible;
85*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_SHOW_POSITION           ) >>= m_bShowPosition;
86*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_SHOW_NAVIGATION         ) >>= m_bShowNavigation;
87*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_SHOW_RECORDACTIONS      ) >>= m_bShowActions;
88*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_SHOW_FILTERSORT         ) >>= m_bShowFilterSort;
89*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_WRITING_MODE            ) >>= m_nWritingMode;
90*cdf0e10cSrcweir         getPropertyDefaultByHandle( PROPERTY_ID_CONTEXT_WRITING_MODE    ) >>= m_nContextWritingMode;
91*cdf0e10cSrcweir     }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     //------------------------------------------------------------------
94*cdf0e10cSrcweir     ONavigationBarModel::ONavigationBarModel( const ONavigationBarModel* _pOriginal, const Reference< XMultiServiceFactory >& _rxFactory )
95*cdf0e10cSrcweir 	    :OControlModel( _pOriginal, _rxFactory )
96*cdf0e10cSrcweir         ,FontControlModel( _pOriginal )
97*cdf0e10cSrcweir     {
98*cdf0e10cSrcweir     	DBG_CTOR( ONavigationBarModel, NULL );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir         implInitPropertyContainer();
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir         m_aTabStop              = _pOriginal->m_aTabStop;
103*cdf0e10cSrcweir         m_aBackgroundColor      = _pOriginal->m_aBackgroundColor;
104*cdf0e10cSrcweir         m_sDefaultControl       = _pOriginal->m_sDefaultControl;
105*cdf0e10cSrcweir         m_sHelpText             = _pOriginal->m_sHelpText;
106*cdf0e10cSrcweir         m_sHelpURL              = _pOriginal->m_sHelpURL;
107*cdf0e10cSrcweir         m_bEnabled              = _pOriginal->m_bEnabled;
108*cdf0e10cSrcweir         m_bEnableVisible        = _pOriginal->m_bEnableVisible;
109*cdf0e10cSrcweir         m_nIconSize             = _pOriginal->m_nIconSize;
110*cdf0e10cSrcweir         m_nBorder               = _pOriginal->m_nBorder;
111*cdf0e10cSrcweir         m_nDelay                = _pOriginal->m_nDelay;
112*cdf0e10cSrcweir         m_bShowPosition         = _pOriginal->m_bShowPosition;
113*cdf0e10cSrcweir         m_bShowNavigation       = _pOriginal->m_bShowNavigation;
114*cdf0e10cSrcweir         m_bShowActions          = _pOriginal->m_bShowActions;
115*cdf0e10cSrcweir         m_bShowFilterSort       = _pOriginal->m_bShowFilterSort;
116*cdf0e10cSrcweir         m_nWritingMode          = _pOriginal->m_nWritingMode;
117*cdf0e10cSrcweir         m_nContextWritingMode   = _pOriginal->m_nContextWritingMode;
118*cdf0e10cSrcweir     }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     //------------------------------------------------------------------
121*cdf0e10cSrcweir     void ONavigationBarModel::implInitPropertyContainer()
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir         REGISTER_PROP_2( DEFAULTCONTROL,      m_sDefaultControl,        BOUND, MAYBEDEFAULT );
124*cdf0e10cSrcweir         REGISTER_PROP_2( HELPTEXT,            m_sHelpText,              BOUND, MAYBEDEFAULT );
125*cdf0e10cSrcweir         REGISTER_PROP_2( HELPURL,             m_sHelpURL,               BOUND, MAYBEDEFAULT );
126*cdf0e10cSrcweir         REGISTER_PROP_2( ENABLED,             m_bEnabled,               BOUND, MAYBEDEFAULT );
127*cdf0e10cSrcweir         REGISTER_PROP_2( ENABLEVISIBLE,       m_bEnableVisible,         BOUND, MAYBEDEFAULT );
128*cdf0e10cSrcweir         REGISTER_PROP_2( ICONSIZE,            m_nIconSize,              BOUND, MAYBEDEFAULT );
129*cdf0e10cSrcweir         REGISTER_PROP_2( BORDER,              m_nBorder,                BOUND, MAYBEDEFAULT );
130*cdf0e10cSrcweir         REGISTER_PROP_2( DELAY,               m_nDelay,                 BOUND, MAYBEDEFAULT );
131*cdf0e10cSrcweir         REGISTER_PROP_2( SHOW_POSITION,       m_bShowPosition,          BOUND, MAYBEDEFAULT );
132*cdf0e10cSrcweir         REGISTER_PROP_2( SHOW_NAVIGATION,     m_bShowNavigation,        BOUND, MAYBEDEFAULT );
133*cdf0e10cSrcweir         REGISTER_PROP_2( SHOW_RECORDACTIONS,  m_bShowActions,           BOUND, MAYBEDEFAULT );
134*cdf0e10cSrcweir         REGISTER_PROP_2( SHOW_FILTERSORT,     m_bShowFilterSort,        BOUND, MAYBEDEFAULT );
135*cdf0e10cSrcweir         REGISTER_PROP_2( WRITING_MODE,        m_nWritingMode,           BOUND, MAYBEDEFAULT );
136*cdf0e10cSrcweir         REGISTER_PROP_3( CONTEXT_WRITING_MODE,m_nContextWritingMode,    BOUND, MAYBEDEFAULT, TRANSIENT );
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         REGISTER_VOID_PROP( TABSTOP,         m_aTabStop,         sal_Bool );
139*cdf0e10cSrcweir         REGISTER_VOID_PROP( BACKGROUNDCOLOR, m_aBackgroundColor, sal_Int32 );
140*cdf0e10cSrcweir     }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir     //------------------------------------------------------------------
143*cdf0e10cSrcweir     ONavigationBarModel::~ONavigationBarModel()
144*cdf0e10cSrcweir     {
145*cdf0e10cSrcweir 	    if ( !OComponentHelper::rBHelper.bDisposed )
146*cdf0e10cSrcweir 	    {
147*cdf0e10cSrcweir 		    acquire();
148*cdf0e10cSrcweir 		    dispose();
149*cdf0e10cSrcweir 	    }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	    DBG_DTOR( ONavigationBarModel, NULL );
152*cdf0e10cSrcweir     }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     //------------------------------------------------------------------
155*cdf0e10cSrcweir     Any SAL_CALL ONavigationBarModel::queryAggregation( const Type& _rType ) throw ( RuntimeException )
156*cdf0e10cSrcweir     {
157*cdf0e10cSrcweir 	    Any aReturn = ONavigationBarModel_BASE::queryInterface( _rType );
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	    if ( !aReturn.hasValue() )
160*cdf0e10cSrcweir 		    aReturn = OControlModel::queryAggregation( _rType );
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir         return aReturn;
163*cdf0e10cSrcweir     }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     //------------------------------------------------------------------
166*cdf0e10cSrcweir     IMPLEMENT_FORWARD_XTYPEPROVIDER2( ONavigationBarModel, OControlModel, ONavigationBarModel_BASE )
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     //------------------------------------------------------------------------------
169*cdf0e10cSrcweir     IMPLEMENT_DEFAULT_CLONING( ONavigationBarModel )
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     //------------------------------------------------------------------
172*cdf0e10cSrcweir     ::rtl::OUString	SAL_CALL ONavigationBarModel::getImplementationName()  throw(RuntimeException)
173*cdf0e10cSrcweir     {
174*cdf0e10cSrcweir         return getImplementationName_Static();
175*cdf0e10cSrcweir     }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     //------------------------------------------------------------------
178*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL ONavigationBarModel::getSupportedServiceNames()  throw(RuntimeException)
179*cdf0e10cSrcweir     {
180*cdf0e10cSrcweir         return getSupportedServiceNames_Static();
181*cdf0e10cSrcweir     }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     //------------------------------------------------------------------
184*cdf0e10cSrcweir     ::rtl::OUString	SAL_CALL ONavigationBarModel::getImplementationName_Static()
185*cdf0e10cSrcweir     {
186*cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.form.ONavigationBarModel" ) );
187*cdf0e10cSrcweir     }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir     //------------------------------------------------------------------
190*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL ONavigationBarModel::getSupportedServiceNames_Static()
191*cdf0e10cSrcweir     {
192*cdf0e10cSrcweir 	    Sequence< ::rtl::OUString > aSupported = OControlModel::getSupportedServiceNames_Static();
193*cdf0e10cSrcweir 	    aSupported.realloc( aSupported.getLength() + 2 );
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	    ::rtl::OUString* pArray = aSupported.getArray();
196*cdf0e10cSrcweir 	    pArray[ aSupported.getLength() - 2 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlModel" ) );
197*cdf0e10cSrcweir 	    pArray[ aSupported.getLength() - 1 ] = FRM_SUN_COMPONENT_NAVTOOLBAR;
198*cdf0e10cSrcweir 	    return aSupported;
199*cdf0e10cSrcweir     }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir     //------------------------------------------------------------------
202*cdf0e10cSrcweir     Reference< XInterface > SAL_CALL ONavigationBarModel::Create( const Reference< XMultiServiceFactory >& _rxFactory )
203*cdf0e10cSrcweir     {
204*cdf0e10cSrcweir         return *( new ONavigationBarModel( _rxFactory ) );
205*cdf0e10cSrcweir     }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     //------------------------------------------------------------------
208*cdf0e10cSrcweir     void SAL_CALL ONavigationBarModel::disposing()
209*cdf0e10cSrcweir     {
210*cdf0e10cSrcweir         OControlModel::disposing( );
211*cdf0e10cSrcweir     }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir     //------------------------------------------------------------------
214*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL ONavigationBarModel::getServiceName() throw ( RuntimeException )
215*cdf0e10cSrcweir     {
216*cdf0e10cSrcweir         return FRM_SUN_COMPONENT_NAVTOOLBAR;
217*cdf0e10cSrcweir     }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir     //------------------------------------------------------------------
220*cdf0e10cSrcweir     #define PERSIST_TABSTOP         0x0001
221*cdf0e10cSrcweir     #define PERSIST_BACKGROUND      0x0002
222*cdf0e10cSrcweir     #define PERSIST_TEXTCOLOR       0x0004
223*cdf0e10cSrcweir     #define PERSIST_TEXTLINECOLOR   0x0008
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir     #define PERSIST_ENABLED         0x0001
226*cdf0e10cSrcweir     #define PERSIST_LARGEICONS      0x0002
227*cdf0e10cSrcweir         // leaf a leap here - this will allow for two more icon size values to be stored compatibly
228*cdf0e10cSrcweir     #define PERSIST_SHOW_POSITION   0x0008
229*cdf0e10cSrcweir     #define PERSIST_SHOW_NAVIGATION 0x0010
230*cdf0e10cSrcweir     #define PERSIST_SHOW_ACTIONS    0x0020
231*cdf0e10cSrcweir     #define PERSIST_SHOW_FILTERSORT 0x0040
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     //------------------------------------------------------------------
234*cdf0e10cSrcweir     void SAL_CALL ONavigationBarModel::write( const Reference< XObjectOutputStream >& _rxOutStream ) throw ( IOException, RuntimeException )
235*cdf0e10cSrcweir     {
236*cdf0e10cSrcweir         // open a section for compatibility - if we later on write additional members,
237*cdf0e10cSrcweir         // then older versions can skip them
238*cdf0e10cSrcweir         Reference< XDataOutputStream > xDataOut( _rxOutStream, UNO_QUERY );
239*cdf0e10cSrcweir         OStreamSection aEnsureBlockCompat( xDataOut );
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir         // base class
242*cdf0e10cSrcweir         OControlModel::write( _rxOutStream );
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir         {
245*cdf0e10cSrcweir             OStreamSection aEnsureCompat( xDataOut );
246*cdf0e10cSrcweir             // determine which properties are not void and need to be written
247*cdf0e10cSrcweir             sal_Int32 nNonVoids = 0;
248*cdf0e10cSrcweir             if ( m_aTabStop.hasValue() )
249*cdf0e10cSrcweir                 nNonVoids |= PERSIST_TABSTOP;
250*cdf0e10cSrcweir             if ( m_aBackgroundColor.hasValue() )
251*cdf0e10cSrcweir                 nNonVoids |= PERSIST_BACKGROUND;
252*cdf0e10cSrcweir             if ( hasTextColor() )
253*cdf0e10cSrcweir                 nNonVoids |= PERSIST_TEXTCOLOR;
254*cdf0e10cSrcweir             if ( hasTextLineColor() )
255*cdf0e10cSrcweir                 nNonVoids |= PERSIST_TEXTLINECOLOR;
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir             _rxOutStream->writeLong( nNonVoids );
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir             // the maybeboid anys
260*cdf0e10cSrcweir             if ( nNonVoids & PERSIST_TABSTOP )
261*cdf0e10cSrcweir             {
262*cdf0e10cSrcweir                 sal_Bool bTabStop( sal_False );
263*cdf0e10cSrcweir                 m_aTabStop >>= bTabStop;
264*cdf0e10cSrcweir                 _rxOutStream->writeBoolean( bTabStop );
265*cdf0e10cSrcweir             }
266*cdf0e10cSrcweir             if ( nNonVoids & PERSIST_BACKGROUND )
267*cdf0e10cSrcweir             {
268*cdf0e10cSrcweir                 sal_Int32 nBackgroundColor = 0;
269*cdf0e10cSrcweir                 m_aBackgroundColor >>= nBackgroundColor;
270*cdf0e10cSrcweir                 _rxOutStream->writeLong( nBackgroundColor );
271*cdf0e10cSrcweir             }
272*cdf0e10cSrcweir             if ( nNonVoids & PERSIST_TEXTCOLOR )
273*cdf0e10cSrcweir             {
274*cdf0e10cSrcweir                _rxOutStream->writeLong( getTextColor() );
275*cdf0e10cSrcweir             }
276*cdf0e10cSrcweir             if ( nNonVoids & PERSIST_TEXTLINECOLOR )
277*cdf0e10cSrcweir             {
278*cdf0e10cSrcweir                 _rxOutStream->writeLong( getTextLineColor() );
279*cdf0e10cSrcweir             }
280*cdf0e10cSrcweir         }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir         {
283*cdf0e10cSrcweir             OStreamSection aEnsureCompat( xDataOut );
284*cdf0e10cSrcweir             ::comphelper::operator<<( _rxOutStream, getFont() );
285*cdf0e10cSrcweir         }
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir         // our boolean flags
288*cdf0e10cSrcweir         sal_Int32 nFlags = 0;
289*cdf0e10cSrcweir         if ( m_bEnabled        ) nFlags |= PERSIST_ENABLED;
290*cdf0e10cSrcweir         if ( m_nIconSize       ) nFlags |= PERSIST_LARGEICONS;   // at the moment, this is quasi boolean
291*cdf0e10cSrcweir         if ( m_bShowPosition   ) nFlags |= PERSIST_SHOW_POSITION;
292*cdf0e10cSrcweir         if ( m_bShowNavigation ) nFlags |= PERSIST_SHOW_NAVIGATION;
293*cdf0e10cSrcweir         if ( m_bShowActions    ) nFlags |= PERSIST_SHOW_ACTIONS;
294*cdf0e10cSrcweir         if ( m_bShowFilterSort ) nFlags |= PERSIST_SHOW_FILTERSORT;
295*cdf0e10cSrcweir         _rxOutStream->writeLong( nFlags );
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir         // our strings
298*cdf0e10cSrcweir         _rxOutStream->writeUTF( m_sHelpText       );
299*cdf0e10cSrcweir         _rxOutStream->writeUTF( m_sHelpURL        );
300*cdf0e10cSrcweir         _rxOutStream->writeUTF( m_sDefaultControl );
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir         // misc
303*cdf0e10cSrcweir         _rxOutStream->writeShort( m_nBorder );
304*cdf0e10cSrcweir         _rxOutStream->writeLong ( m_nDelay  );
305*cdf0e10cSrcweir     }
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir     //------------------------------------------------------------------
308*cdf0e10cSrcweir     void SAL_CALL ONavigationBarModel::read( const Reference< XObjectInputStream >& _rxInStream ) throw ( IOException, RuntimeException )
309*cdf0e10cSrcweir     {
310*cdf0e10cSrcweir         Reference< XDataInputStream > xDataIn( _rxInStream, UNO_QUERY );
311*cdf0e10cSrcweir         OStreamSection aEnsureBlockCompat( xDataIn );
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir         // base class
314*cdf0e10cSrcweir         OControlModel::read( _rxInStream );
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir         {
317*cdf0e10cSrcweir             OStreamSection aEnsureCompat( xDataIn );
318*cdf0e10cSrcweir             // determine which properties were non-void
319*cdf0e10cSrcweir             sal_Int32 nNonVoids = _rxInStream->readLong( );
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir             // the maybeboid anys
322*cdf0e10cSrcweir             if ( nNonVoids & PERSIST_TABSTOP )
323*cdf0e10cSrcweir                 m_aTabStop = makeAny( _rxInStream->readBoolean() );
324*cdf0e10cSrcweir             else
325*cdf0e10cSrcweir                 m_aTabStop.clear();
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir             if ( nNonVoids & PERSIST_BACKGROUND )
328*cdf0e10cSrcweir                 m_aBackgroundColor = makeAny( _rxInStream->readLong() );
329*cdf0e10cSrcweir             else
330*cdf0e10cSrcweir                 m_aBackgroundColor.clear();
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir             if ( nNonVoids & PERSIST_TEXTCOLOR )
333*cdf0e10cSrcweir                 setTextColor( _rxInStream->readLong() );
334*cdf0e10cSrcweir             else
335*cdf0e10cSrcweir                 clearTextColor();
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir             if ( nNonVoids & PERSIST_TEXTLINECOLOR )
338*cdf0e10cSrcweir                 setTextLineColor( _rxInStream->readLong() );
339*cdf0e10cSrcweir             else
340*cdf0e10cSrcweir                 clearTextLineColor();
341*cdf0e10cSrcweir         }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir         {
344*cdf0e10cSrcweir             OStreamSection aEnsureCompat( xDataIn );
345*cdf0e10cSrcweir             FontDescriptor aFont;
346*cdf0e10cSrcweir             ::comphelper::operator>>( _rxInStream, aFont );
347*cdf0e10cSrcweir             setFont( aFont );
348*cdf0e10cSrcweir         }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir         // our boolean flags
351*cdf0e10cSrcweir         sal_Int32 nFlags = _rxInStream->readLong( );
352*cdf0e10cSrcweir         m_bEnabled        = ( nFlags & PERSIST_ENABLED         ) ? sal_True : sal_False;
353*cdf0e10cSrcweir         m_nIconSize       = ( nFlags & PERSIST_LARGEICONS      ) ?        1 :         0;
354*cdf0e10cSrcweir         m_bShowPosition   = ( nFlags & PERSIST_SHOW_POSITION   ) ? sal_True : sal_False;
355*cdf0e10cSrcweir         m_bShowNavigation = ( nFlags & PERSIST_SHOW_NAVIGATION ) ? sal_True : sal_False;
356*cdf0e10cSrcweir         m_bShowActions    = ( nFlags & PERSIST_SHOW_ACTIONS    ) ? sal_True : sal_False;
357*cdf0e10cSrcweir         m_bShowFilterSort = ( nFlags & PERSIST_SHOW_FILTERSORT ) ? sal_True : sal_False;
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir         // our strings
360*cdf0e10cSrcweir         m_sHelpText       = _rxInStream->readUTF( );
361*cdf0e10cSrcweir         m_sHelpURL        = _rxInStream->readUTF( );
362*cdf0e10cSrcweir         m_sDefaultControl = _rxInStream->readUTF( );
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir         // misc
365*cdf0e10cSrcweir         m_nBorder = _rxInStream->readShort();
366*cdf0e10cSrcweir         m_nDelay  = _rxInStream->readLong();
367*cdf0e10cSrcweir     }
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir     //------------------------------------------------------------------
370*cdf0e10cSrcweir     void SAL_CALL ONavigationBarModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
371*cdf0e10cSrcweir     {
372*cdf0e10cSrcweir         if ( isRegisteredProperty( _nHandle ) )
373*cdf0e10cSrcweir         {
374*cdf0e10cSrcweir             OPropertyContainerHelper::getFastPropertyValue( _rValue, _nHandle );
375*cdf0e10cSrcweir         }
376*cdf0e10cSrcweir         else if ( isFontRelatedProperty( _nHandle ) )
377*cdf0e10cSrcweir         {
378*cdf0e10cSrcweir             FontControlModel::getFastPropertyValue( _rValue, _nHandle );
379*cdf0e10cSrcweir         }
380*cdf0e10cSrcweir         else
381*cdf0e10cSrcweir         {
382*cdf0e10cSrcweir     		OControlModel::getFastPropertyValue( _rValue, _nHandle );
383*cdf0e10cSrcweir         }
384*cdf0e10cSrcweir     }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir     //------------------------------------------------------------------
387*cdf0e10cSrcweir     sal_Bool SAL_CALL ONavigationBarModel::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue,
388*cdf0e10cSrcweir         sal_Int32 _nHandle, const Any& _rValue ) throw( IllegalArgumentException )
389*cdf0e10cSrcweir     {
390*cdf0e10cSrcweir         sal_Bool bModified = sal_False;
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir         if ( isRegisteredProperty( _nHandle ) )
393*cdf0e10cSrcweir         {
394*cdf0e10cSrcweir             bModified = OPropertyContainerHelper::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
395*cdf0e10cSrcweir         }
396*cdf0e10cSrcweir         else if ( isFontRelatedProperty( _nHandle ) )
397*cdf0e10cSrcweir         {
398*cdf0e10cSrcweir             bModified = FontControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
399*cdf0e10cSrcweir         }
400*cdf0e10cSrcweir         else
401*cdf0e10cSrcweir         {
402*cdf0e10cSrcweir     		bModified = OControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
403*cdf0e10cSrcweir         }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir         return bModified;
406*cdf0e10cSrcweir     }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir     //------------------------------------------------------------------
409*cdf0e10cSrcweir     void SAL_CALL ONavigationBarModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception )
410*cdf0e10cSrcweir     {
411*cdf0e10cSrcweir         if ( isRegisteredProperty( _nHandle ) )
412*cdf0e10cSrcweir         {
413*cdf0e10cSrcweir             OPropertyContainerHelper::setFastPropertyValue( _nHandle, _rValue );
414*cdf0e10cSrcweir         }
415*cdf0e10cSrcweir         else if ( isFontRelatedProperty( _nHandle ) )
416*cdf0e10cSrcweir         {
417*cdf0e10cSrcweir             FontDescriptor aOldFont( getFont() );
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir             FontControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir             if ( isFontAggregateProperty( _nHandle ) )
422*cdf0e10cSrcweir 	            firePropertyChange( PROPERTY_ID_FONT, makeAny( getFont() ), makeAny( aOldFont ) );
423*cdf0e10cSrcweir         }
424*cdf0e10cSrcweir         else
425*cdf0e10cSrcweir         {
426*cdf0e10cSrcweir     		OControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
427*cdf0e10cSrcweir         }
428*cdf0e10cSrcweir     }
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir     //------------------------------------------------------------------
431*cdf0e10cSrcweir     Any ONavigationBarModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const
432*cdf0e10cSrcweir     {
433*cdf0e10cSrcweir         Any aDefault;
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir 	    switch ( _nHandle )
436*cdf0e10cSrcweir 	    {
437*cdf0e10cSrcweir         case PROPERTY_ID_TABSTOP:
438*cdf0e10cSrcweir         case PROPERTY_ID_BACKGROUNDCOLOR:
439*cdf0e10cSrcweir             /* void */
440*cdf0e10cSrcweir             break;
441*cdf0e10cSrcweir         case PROPERTY_ID_WRITING_MODE:
442*cdf0e10cSrcweir         case PROPERTY_ID_CONTEXT_WRITING_MODE:
443*cdf0e10cSrcweir             aDefault <<= WritingMode2::CONTEXT;
444*cdf0e10cSrcweir             break;
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir         case PROPERTY_ID_ENABLED:
447*cdf0e10cSrcweir         case PROPERTY_ID_ENABLEVISIBLE:
448*cdf0e10cSrcweir         case PROPERTY_ID_SHOW_POSITION:
449*cdf0e10cSrcweir         case PROPERTY_ID_SHOW_NAVIGATION:
450*cdf0e10cSrcweir         case PROPERTY_ID_SHOW_RECORDACTIONS:
451*cdf0e10cSrcweir         case PROPERTY_ID_SHOW_FILTERSORT:
452*cdf0e10cSrcweir             aDefault <<= (sal_Bool)sal_True;
453*cdf0e10cSrcweir             break;
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir         case PROPERTY_ID_ICONSIZE:
456*cdf0e10cSrcweir             aDefault <<= (sal_Int16)0;
457*cdf0e10cSrcweir             break;
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir         case PROPERTY_ID_DEFAULTCONTROL:
460*cdf0e10cSrcweir             aDefault <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.control.NavigationToolBar" ) );
461*cdf0e10cSrcweir             break;
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir         case PROPERTY_ID_HELPTEXT:
464*cdf0e10cSrcweir         case PROPERTY_ID_HELPURL:
465*cdf0e10cSrcweir             aDefault <<= ::rtl::OUString();
466*cdf0e10cSrcweir             break;
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir         case PROPERTY_ID_BORDER:
469*cdf0e10cSrcweir             aDefault <<= (sal_Int16)0;
470*cdf0e10cSrcweir             break;
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir         case PROPERTY_ID_DELAY:
473*cdf0e10cSrcweir             aDefault <<= (sal_Int32)20;
474*cdf0e10cSrcweir             break;
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir 		default:
477*cdf0e10cSrcweir             if ( isFontRelatedProperty( _nHandle ) )
478*cdf0e10cSrcweir                 aDefault = FontControlModel::getPropertyDefaultByHandle( _nHandle );
479*cdf0e10cSrcweir             else
480*cdf0e10cSrcweir     			aDefault = OControlModel::getPropertyDefaultByHandle( _nHandle );
481*cdf0e10cSrcweir         }
482*cdf0e10cSrcweir         return aDefault;
483*cdf0e10cSrcweir     }
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir     //------------------------------------------------------------------
486*cdf0e10cSrcweir     void ONavigationBarModel::describeFixedProperties( Sequence< Property >& _rProps ) const
487*cdf0e10cSrcweir     {
488*cdf0e10cSrcweir         BEGIN_DESCRIBE_PROPERTIES( 1, OControlModel )
489*cdf0e10cSrcweir             DECL_PROP2( TABINDEX,           sal_Int16,          BOUND, MAYBEDEFAULT );
490*cdf0e10cSrcweir 	    END_DESCRIBE_PROPERTIES();
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir         // properties which the OPropertyContainerHelper is responsible for
493*cdf0e10cSrcweir         Sequence< Property > aContainedProperties;
494*cdf0e10cSrcweir         describeProperties( aContainedProperties );
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir         // properties which the FontControlModel is responsible for
497*cdf0e10cSrcweir         Sequence< Property > aFontProperties;
498*cdf0e10cSrcweir         describeFontRelatedProperties( aFontProperties );
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir         _rProps = concatSequences(
501*cdf0e10cSrcweir             aContainedProperties,
502*cdf0e10cSrcweir             aFontProperties,
503*cdf0e10cSrcweir             _rProps
504*cdf0e10cSrcweir         );
505*cdf0e10cSrcweir     }
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir //.........................................................................
508*cdf0e10cSrcweir }   // namespace frm
509*cdf0e10cSrcweir //.........................................................................
510