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