1*24acc546SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*24acc546SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*24acc546SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*24acc546SAndrew Rist  * distributed with this work for additional information
6*24acc546SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*24acc546SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*24acc546SAndrew Rist  * "License"); you may not use this file except in compliance
9*24acc546SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*24acc546SAndrew Rist  *
11*24acc546SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*24acc546SAndrew Rist  *
13*24acc546SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*24acc546SAndrew Rist  * software distributed under the License is distributed on an
15*24acc546SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24acc546SAndrew Rist  * KIND, either express or implied.  See the License for the
17*24acc546SAndrew Rist  * specific language governing permissions and limitations
18*24acc546SAndrew Rist  * under the License.
19*24acc546SAndrew Rist  *
20*24acc546SAndrew Rist  *************************************************************/
21*24acc546SAndrew Rist 
22*24acc546SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_forms.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "navtoolbar.hxx"
28cdf0e10cSrcweir #include "frm_resource.hxx"
29cdf0e10cSrcweir #include "featuredispatcher.hxx"
30cdf0e10cSrcweir #include "frm_resource.hrc"
31cdf0e10cSrcweir #include "commandimageprovider.hxx"
32cdf0e10cSrcweir #include "commanddescriptionprovider.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
35cdf0e10cSrcweir #include <com/sun/star/form/runtime/FormFeature.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <sfx2/imgmgr.hxx>
38cdf0e10cSrcweir #include <vcl/fixed.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <memory>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #define LID_RECORD_LABEL    1000
43cdf0e10cSrcweir #define LID_RECORD_FILLER   1001
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //.........................................................................
46cdf0e10cSrcweir namespace frm
47cdf0e10cSrcweir {
48cdf0e10cSrcweir //.........................................................................
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     using ::com::sun::star::uno::makeAny;
51cdf0e10cSrcweir     namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     //=====================================================================
54cdf0e10cSrcweir     //.....................................................................
55cdf0e10cSrcweir     namespace
56cdf0e10cSrcweir     {
isArtificialItem(sal_Int16 _nFeatureId)57cdf0e10cSrcweir         static bool isArtificialItem( sal_Int16 _nFeatureId )
58cdf0e10cSrcweir         {
59cdf0e10cSrcweir             return ( _nFeatureId == LID_RECORD_LABEL )
60cdf0e10cSrcweir                 || ( _nFeatureId == LID_RECORD_FILLER );
61cdf0e10cSrcweir         }
62cdf0e10cSrcweir 
getLabelString(sal_uInt16 _nResId)63cdf0e10cSrcweir         static String getLabelString( sal_uInt16 _nResId )
64cdf0e10cSrcweir         {
65cdf0e10cSrcweir             String sLabel = String::CreateFromAscii( " " );
66cdf0e10cSrcweir             sLabel += String( FRM_RES_STRING( _nResId ) );
67cdf0e10cSrcweir             sLabel += String::CreateFromAscii( " " );
68cdf0e10cSrcweir             return sLabel;
69cdf0e10cSrcweir         }
70cdf0e10cSrcweir 
lcl_getCommandURL(const sal_Int16 _nFormFeature)71cdf0e10cSrcweir         ::rtl::OUString lcl_getCommandURL( const sal_Int16 _nFormFeature )
72cdf0e10cSrcweir         {
73cdf0e10cSrcweir             const sal_Char* pAsciiCommandName = NULL;
74cdf0e10cSrcweir             switch ( _nFormFeature )
75cdf0e10cSrcweir             {
76cdf0e10cSrcweir                 case FormFeature::MoveAbsolute          : pAsciiCommandName = "AbsoluteRecord";     break;
77cdf0e10cSrcweir                 case FormFeature::TotalRecords          : pAsciiCommandName = "RecTotal";           break;
78cdf0e10cSrcweir                 case FormFeature::MoveToFirst           : pAsciiCommandName = "FirstRecord";        break;
79cdf0e10cSrcweir                 case FormFeature::MoveToPrevious        : pAsciiCommandName = "PrevRecord";         break;
80cdf0e10cSrcweir                 case FormFeature::MoveToNext            : pAsciiCommandName = "NextRecord";         break;
81cdf0e10cSrcweir                 case FormFeature::MoveToLast            : pAsciiCommandName = "LastRecord";         break;
82cdf0e10cSrcweir                 case FormFeature::SaveRecordChanges     : pAsciiCommandName = "RecSave";            break;
83cdf0e10cSrcweir                 case FormFeature::UndoRecordChanges     : pAsciiCommandName = "RecUndo";            break;
84cdf0e10cSrcweir                 case FormFeature::MoveToInsertRow       : pAsciiCommandName = "NewRecord";          break;
85cdf0e10cSrcweir                 case FormFeature::DeleteRecord          : pAsciiCommandName = "DeleteRecord";       break;
86cdf0e10cSrcweir                 case FormFeature::ReloadForm            : pAsciiCommandName = "Refresh";            break;
87cdf0e10cSrcweir                 case FormFeature::RefreshCurrentControl : pAsciiCommandName = "RefreshFormControl"; break;
88cdf0e10cSrcweir                 case FormFeature::SortAscending         : pAsciiCommandName = "Sortup";             break;
89cdf0e10cSrcweir                 case FormFeature::SortDescending        : pAsciiCommandName = "SortDown";           break;
90cdf0e10cSrcweir                 case FormFeature::InteractiveSort       : pAsciiCommandName = "OrderCrit";          break;
91cdf0e10cSrcweir                 case FormFeature::AutoFilter            : pAsciiCommandName = "AutoFilter";         break;
92cdf0e10cSrcweir                 case FormFeature::InteractiveFilter     : pAsciiCommandName = "FilterCrit";         break;
93cdf0e10cSrcweir                 case FormFeature::ToggleApplyFilter     : pAsciiCommandName = "FormFiltered";       break;
94cdf0e10cSrcweir                 case FormFeature::RemoveFilterAndSort   : pAsciiCommandName = "RemoveFilterSort";   break;
95cdf0e10cSrcweir             }
96cdf0e10cSrcweir             if ( pAsciiCommandName != NULL )
97cdf0e10cSrcweir                 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) ) + ::rtl::OUString::createFromAscii( pAsciiCommandName );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir             OSL_ENSURE( false, "lcl_getCommandURL: unknown FormFeature!" );
100cdf0e10cSrcweir             return ::rtl::OUString();
101cdf0e10cSrcweir         }
102cdf0e10cSrcweir     }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     //=====================================================================
105cdf0e10cSrcweir     //= ImplNavToolBar
106cdf0e10cSrcweir     //=====================================================================
107cdf0e10cSrcweir     class ImplNavToolBar : public ToolBox
108cdf0e10cSrcweir     {
109cdf0e10cSrcweir     protected:
110cdf0e10cSrcweir         const IFeatureDispatcher*   m_pDispatcher;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     public:
ImplNavToolBar(Window * _pParent)113cdf0e10cSrcweir         ImplNavToolBar( Window* _pParent )
114cdf0e10cSrcweir             :ToolBox( _pParent, WB_3DLOOK )
115cdf0e10cSrcweir             ,m_pDispatcher( NULL )
116cdf0e10cSrcweir         {
117cdf0e10cSrcweir         }
118cdf0e10cSrcweir 
setDispatcher(const IFeatureDispatcher * _pDispatcher)119cdf0e10cSrcweir         void setDispatcher( const IFeatureDispatcher* _pDispatcher )
120cdf0e10cSrcweir         {
121cdf0e10cSrcweir             m_pDispatcher = _pDispatcher;
122cdf0e10cSrcweir         }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     protected:
125cdf0e10cSrcweir         // ToolBox overridables
126cdf0e10cSrcweir         virtual void        Select();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     };
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     //---------------------------------------------------------------------
Select()131cdf0e10cSrcweir     void ImplNavToolBar::Select()
132cdf0e10cSrcweir     {
133cdf0e10cSrcweir         if ( m_pDispatcher )
134cdf0e10cSrcweir         {
135cdf0e10cSrcweir             if ( !m_pDispatcher->isEnabled( GetCurItemId() ) )
136cdf0e10cSrcweir                 // the toolbox is a little bit buggy: With TIB_REPEAT, it sometimes
137cdf0e10cSrcweir                 // happens that a select is reported, even though the respective
138cdf0e10cSrcweir                 // item has just been disabled.
139cdf0e10cSrcweir                 return;
140cdf0e10cSrcweir             m_pDispatcher->dispatch( GetCurItemId() );
141cdf0e10cSrcweir         }
142cdf0e10cSrcweir     }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     //=====================================================================
145cdf0e10cSrcweir     //= NavigationToolBar
146cdf0e10cSrcweir     //=====================================================================
DBG_NAME(NavigationToolBar)147cdf0e10cSrcweir     DBG_NAME( NavigationToolBar )
148cdf0e10cSrcweir     //---------------------------------------------------------------------
149cdf0e10cSrcweir     NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle, const PCommandImageProvider& _pImageProvider,
150cdf0e10cSrcweir             const PCommandDescriptionProvider& _pDescriptionProvider )
151cdf0e10cSrcweir         :Window( _pParent, _nStyle )
152cdf0e10cSrcweir         ,m_pDispatcher( NULL )
153cdf0e10cSrcweir         ,m_pImageProvider( _pImageProvider )
154cdf0e10cSrcweir         ,m_pDescriptionProvider( _pDescriptionProvider )
155cdf0e10cSrcweir         ,m_eImageSize( eSmall )
156cdf0e10cSrcweir         ,m_pToolbar( NULL )
157cdf0e10cSrcweir     {
158cdf0e10cSrcweir         DBG_CTOR( NavigationToolBar, NULL );
159cdf0e10cSrcweir         implInit( );
160cdf0e10cSrcweir     }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     //---------------------------------------------------------------------
~NavigationToolBar()163cdf0e10cSrcweir     NavigationToolBar::~NavigationToolBar( )
164cdf0e10cSrcweir     {
165cdf0e10cSrcweir         for (   ::std::vector< Window* >::iterator loopChildWins = m_aChildWins.begin();
166cdf0e10cSrcweir                 loopChildWins != m_aChildWins.end();
167cdf0e10cSrcweir                 ++loopChildWins
168cdf0e10cSrcweir             )
169cdf0e10cSrcweir         {
170cdf0e10cSrcweir             delete *loopChildWins;
171cdf0e10cSrcweir         }
172cdf0e10cSrcweir         delete m_pToolbar;
173cdf0e10cSrcweir         DBG_DTOR( NavigationToolBar, NULL );
174cdf0e10cSrcweir     }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     //---------------------------------------------------------------------
setDispatcher(const IFeatureDispatcher * _pDispatcher)177cdf0e10cSrcweir     void NavigationToolBar::setDispatcher( const IFeatureDispatcher* _pDispatcher )
178cdf0e10cSrcweir     {
179cdf0e10cSrcweir         m_pDispatcher = _pDispatcher;
180cdf0e10cSrcweir 
181cdf0e10cSrcweir         m_pToolbar->setDispatcher( _pDispatcher );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir         RecordPositionInput* pPositionWindow = static_cast< RecordPositionInput* >( m_pToolbar->GetItemWindow( FormFeature::MoveAbsolute ) );
184cdf0e10cSrcweir         OSL_ENSURE( pPositionWindow, "NavigationToolBar::setDispatcher: can't forward the dispatcher to the position window!" );
185cdf0e10cSrcweir         if ( pPositionWindow )
186cdf0e10cSrcweir             pPositionWindow->setDispatcher( _pDispatcher );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir         updateFeatureStates( );
189cdf0e10cSrcweir     }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     //---------------------------------------------------------------------
updateFeatureStates()192cdf0e10cSrcweir     void NavigationToolBar::updateFeatureStates( )
193cdf0e10cSrcweir     {
194cdf0e10cSrcweir         for ( sal_uInt16 nPos = 0; nPos < m_pToolbar->GetItemCount(); ++nPos )
195cdf0e10cSrcweir         {
196cdf0e10cSrcweir             sal_uInt16 nItemId = m_pToolbar->GetItemId( nPos );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir             if ( ( nItemId == LID_RECORD_LABEL ) || ( nItemId == LID_RECORD_FILLER ) )
199cdf0e10cSrcweir                 continue;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir             // is this item enabled?
202cdf0e10cSrcweir             bool bEnabled = m_pDispatcher ? m_pDispatcher->isEnabled( nItemId ) : false;
203cdf0e10cSrcweir             implEnableItem( nItemId, bEnabled );
204cdf0e10cSrcweir         }
205cdf0e10cSrcweir     }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     //---------------------------------------------------------------------
implEnableItem(sal_uInt16 _nItemId,bool _bEnabled)208cdf0e10cSrcweir     void NavigationToolBar::implEnableItem( sal_uInt16 _nItemId, bool _bEnabled )
209cdf0e10cSrcweir     {
210cdf0e10cSrcweir         m_pToolbar->EnableItem( _nItemId, _bEnabled );
211cdf0e10cSrcweir 
212cdf0e10cSrcweir         if ( _nItemId == FormFeature::MoveAbsolute )
213cdf0e10cSrcweir             m_pToolbar->EnableItem( LID_RECORD_LABEL, _bEnabled );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir         if ( _nItemId == FormFeature::TotalRecords )
216cdf0e10cSrcweir             m_pToolbar->EnableItem( LID_RECORD_FILLER, _bEnabled );
217cdf0e10cSrcweir     }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     //---------------------------------------------------------------------
enableFeature(sal_Int16 _nFeatureId,bool _bEnabled)220cdf0e10cSrcweir     void NavigationToolBar::enableFeature( sal_Int16 _nFeatureId, bool _bEnabled )
221cdf0e10cSrcweir     {
222cdf0e10cSrcweir         DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
223cdf0e10cSrcweir             "NavigationToolBar::enableFeature: invalid id!" );
224cdf0e10cSrcweir 
225cdf0e10cSrcweir         implEnableItem( (sal_uInt16)_nFeatureId, _bEnabled );
226cdf0e10cSrcweir     }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     //---------------------------------------------------------------------
checkFeature(sal_Int16 _nFeatureId,bool _bEnabled)229cdf0e10cSrcweir     void NavigationToolBar::checkFeature( sal_Int16 _nFeatureId, bool _bEnabled )
230cdf0e10cSrcweir     {
231cdf0e10cSrcweir         DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
232cdf0e10cSrcweir             "NavigationToolBar::checkFeature: invalid id!" );
233cdf0e10cSrcweir 
234cdf0e10cSrcweir         m_pToolbar->CheckItem( (sal_uInt16)_nFeatureId, _bEnabled );
235cdf0e10cSrcweir     }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     //---------------------------------------------------------------------
setFeatureText(sal_Int16 _nFeatureId,const::rtl::OUString & _rText)238cdf0e10cSrcweir     void NavigationToolBar::setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText )
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir         DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
241cdf0e10cSrcweir             "NavigationToolBar::checkFeature: invalid id!" );
242cdf0e10cSrcweir 
243cdf0e10cSrcweir         Window* pItemWindow = m_pToolbar->GetItemWindow( (sal_uInt16)_nFeatureId );
244cdf0e10cSrcweir         if ( pItemWindow )
245cdf0e10cSrcweir             pItemWindow->SetText( _rText );
246cdf0e10cSrcweir         else
247cdf0e10cSrcweir             m_pToolbar->SetItemText( (sal_uInt16)_nFeatureId, _rText );
248cdf0e10cSrcweir     }
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     //---------------------------------------------------------------------
implInit()251cdf0e10cSrcweir     void NavigationToolBar::implInit( )
252cdf0e10cSrcweir     {
253cdf0e10cSrcweir         m_pToolbar = new ImplNavToolBar( this );
254cdf0e10cSrcweir         m_pToolbar->SetOutStyle( TOOLBOX_STYLE_FLAT );
255cdf0e10cSrcweir         m_pToolbar->Show();
256cdf0e10cSrcweir 
257cdf0e10cSrcweir         // need the SfxApplication for retrieving informations about our
258cdf0e10cSrcweir         // items. We could duplicate all the information here in our lib
259cdf0e10cSrcweir         // (such as the item text and the image), but why should we?
260cdf0e10cSrcweir 
261cdf0e10cSrcweir         struct FeatureDescription
262cdf0e10cSrcweir         {
263cdf0e10cSrcweir             sal_uInt16      nId;
264cdf0e10cSrcweir             bool        bRepeat;
265cdf0e10cSrcweir             bool        bItemWindow;
266cdf0e10cSrcweir         } aSupportedFeatures[] =
267cdf0e10cSrcweir         {
268cdf0e10cSrcweir             { LID_RECORD_LABEL,                     false, true },
269cdf0e10cSrcweir             { FormFeature::MoveAbsolute,            false, true },
270cdf0e10cSrcweir             { LID_RECORD_FILLER,                    false, true },
271cdf0e10cSrcweir             { FormFeature::TotalRecords,            false, true },
272cdf0e10cSrcweir             { FormFeature::MoveToFirst,             true,  false },
273cdf0e10cSrcweir             { FormFeature::MoveToPrevious,          true,  false },
274cdf0e10cSrcweir             { FormFeature::MoveToNext,              true,  false },
275cdf0e10cSrcweir             { FormFeature::MoveToLast,              true,  false },
276cdf0e10cSrcweir             { FormFeature::MoveToInsertRow,         false, false },
277cdf0e10cSrcweir             { 0, false, false },
278cdf0e10cSrcweir             { FormFeature::SaveRecordChanges,       false, false },
279cdf0e10cSrcweir             { FormFeature::UndoRecordChanges,       false, false },
280cdf0e10cSrcweir             { FormFeature::DeleteRecord,            false, false },
281cdf0e10cSrcweir             { FormFeature::ReloadForm,              false, false },
282cdf0e10cSrcweir             { FormFeature::RefreshCurrentControl,   false, false },
283cdf0e10cSrcweir             { 0, false, false },
284cdf0e10cSrcweir             { FormFeature::SortAscending,           false, false },
285cdf0e10cSrcweir             { FormFeature::SortDescending,          false, false },
286cdf0e10cSrcweir             { FormFeature::InteractiveSort,         false, false },
287cdf0e10cSrcweir             { FormFeature::AutoFilter,              false, false },
288cdf0e10cSrcweir             { FormFeature::InteractiveFilter,       false, false },
289cdf0e10cSrcweir             { FormFeature::ToggleApplyFilter,       false, false },
290cdf0e10cSrcweir             { FormFeature::RemoveFilterAndSort,     false, false },
291cdf0e10cSrcweir         };
292cdf0e10cSrcweir 
293cdf0e10cSrcweir         size_t nSupportedFeatures = sizeof( aSupportedFeatures ) / sizeof( aSupportedFeatures[0] );
294cdf0e10cSrcweir         FeatureDescription* pSupportedFeatures = aSupportedFeatures;
295cdf0e10cSrcweir         FeatureDescription* pSupportedFeaturesEnd = aSupportedFeatures + nSupportedFeatures;
296cdf0e10cSrcweir         for ( ; pSupportedFeatures < pSupportedFeaturesEnd; ++pSupportedFeatures )
297cdf0e10cSrcweir         {
298cdf0e10cSrcweir             if ( pSupportedFeatures->nId )
299cdf0e10cSrcweir             {   // it's _not_ a separator
300cdf0e10cSrcweir 
301cdf0e10cSrcweir                 // insert the entry
302cdf0e10cSrcweir                 m_pToolbar->InsertItem( pSupportedFeatures->nId, String(), pSupportedFeatures->bRepeat ? TIB_REPEAT : 0 );
303cdf0e10cSrcweir                 m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, String() );  // TODO
304cdf0e10cSrcweir 
305cdf0e10cSrcweir                 if ( !isArtificialItem( pSupportedFeatures->nId ) )
306cdf0e10cSrcweir                 {
307cdf0e10cSrcweir                     ::rtl::OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) );
308cdf0e10cSrcweir                     m_pToolbar->SetItemCommand( pSupportedFeatures->nId, sCommandURL );
309cdf0e10cSrcweir                     if ( m_pDescriptionProvider )
310cdf0e10cSrcweir                         m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, m_pDescriptionProvider->getCommandDescription( sCommandURL ) );
311cdf0e10cSrcweir                 }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir                 if ( pSupportedFeatures->bItemWindow )
314cdf0e10cSrcweir                 {
315cdf0e10cSrcweir                     Window* pItemWindow = NULL;
316cdf0e10cSrcweir                     if ( FormFeature::MoveAbsolute == pSupportedFeatures->nId )
317cdf0e10cSrcweir                     {
318cdf0e10cSrcweir                         pItemWindow = new RecordPositionInput( m_pToolbar );
319cdf0e10cSrcweir                         static_cast< RecordPositionInput* >( pItemWindow )->setDispatcher( m_pDispatcher );
320cdf0e10cSrcweir                     }
321cdf0e10cSrcweir                     else if ( LID_RECORD_FILLER == pSupportedFeatures->nId )
322cdf0e10cSrcweir                     {
323cdf0e10cSrcweir                         pItemWindow = new FixedText( m_pToolbar, WB_CENTER | WB_VCENTER );
324cdf0e10cSrcweir 						pItemWindow->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
325cdf0e10cSrcweir                     }
326cdf0e10cSrcweir                     else
327cdf0e10cSrcweir                     {
328cdf0e10cSrcweir                         pItemWindow = new FixedText( m_pToolbar, WB_VCENTER );
329cdf0e10cSrcweir 						pItemWindow->SetBackground();
330cdf0e10cSrcweir                         pItemWindow->SetPaintTransparent(sal_True);
331cdf0e10cSrcweir                     }
332cdf0e10cSrcweir                     m_aChildWins.push_back( pItemWindow );
333cdf0e10cSrcweir 
334cdf0e10cSrcweir                     switch ( pSupportedFeatures->nId )
335cdf0e10cSrcweir                     {
336cdf0e10cSrcweir                     case LID_RECORD_LABEL:
337cdf0e10cSrcweir                         pItemWindow->SetText( getLabelString( RID_STR_LABEL_RECORD ) );
338cdf0e10cSrcweir                         break;
339cdf0e10cSrcweir 
340cdf0e10cSrcweir                     case LID_RECORD_FILLER:
341cdf0e10cSrcweir                         pItemWindow->SetText( getLabelString( RID_STR_LABEL_OF ) );
342cdf0e10cSrcweir                         break;
343cdf0e10cSrcweir                     }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir                     m_pToolbar->SetItemWindow( pSupportedFeatures->nId, pItemWindow );
346cdf0e10cSrcweir                 }
347cdf0e10cSrcweir             }
348cdf0e10cSrcweir             else
349cdf0e10cSrcweir             {   // a separator
350cdf0e10cSrcweir                 m_pToolbar->InsertSeparator( );
351cdf0e10cSrcweir             }
352cdf0e10cSrcweir         }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
355cdf0e10cSrcweir 
356cdf0e10cSrcweir         implUpdateImages();
357cdf0e10cSrcweir     }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir     //---------------------------------------------------------------------
implUpdateImages()360cdf0e10cSrcweir     void NavigationToolBar::implUpdateImages()
361cdf0e10cSrcweir     {
362cdf0e10cSrcweir         OSL_ENSURE( m_pImageProvider, "NavigationToolBar::implUpdateImages: no image provider => no images!" );
363cdf0e10cSrcweir         if ( !m_pImageProvider )
364cdf0e10cSrcweir             return;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir         const bool bIsHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
367cdf0e10cSrcweir 
368cdf0e10cSrcweir         const sal_uInt16 nItemCount = m_pToolbar->GetItemCount();
369cdf0e10cSrcweir 
370cdf0e10cSrcweir         // collect the FormFeatures in the toolbar
371cdf0e10cSrcweir         typedef ::std::vector< sal_Int16 >  FormFeatures;
372cdf0e10cSrcweir         FormFeatures aFormFeatures;
373cdf0e10cSrcweir         aFormFeatures.reserve( nItemCount );
374cdf0e10cSrcweir 
375cdf0e10cSrcweir         for ( sal_uInt16 i=0; i<nItemCount; ++i )
376cdf0e10cSrcweir         {
377cdf0e10cSrcweir             sal_uInt16 nId = m_pToolbar->GetItemId( i );
378cdf0e10cSrcweir             if ( ( TOOLBOXITEM_BUTTON == m_pToolbar->GetItemType( i ) ) && !isArtificialItem( nId ) )
379cdf0e10cSrcweir                 aFormFeatures.push_back( nId );
380cdf0e10cSrcweir         }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir         // translate them into command URLs
383cdf0e10cSrcweir         CommandURLs aCommandURLs( aFormFeatures.size() );
384cdf0e10cSrcweir         for (   FormFeatures::const_iterator formFeature = aFormFeatures.begin();
385cdf0e10cSrcweir                 formFeature != aFormFeatures.end();
386cdf0e10cSrcweir                 ++formFeature
387cdf0e10cSrcweir             )
388cdf0e10cSrcweir         {
389cdf0e10cSrcweir             aCommandURLs[ formFeature - aFormFeatures.begin() ] = lcl_getCommandURL( *formFeature );
390cdf0e10cSrcweir         }
391cdf0e10cSrcweir 
392cdf0e10cSrcweir         // retrieve the images for the command URLs
393cdf0e10cSrcweir         CommandImages aCommandImages = m_pImageProvider->getCommandImages( aCommandURLs, m_eImageSize == eLarge, bIsHighContrast );
394cdf0e10cSrcweir 
395cdf0e10cSrcweir         // and set them at the toolbar
396cdf0e10cSrcweir         CommandImages::const_iterator commandImage = aCommandImages.begin();
397cdf0e10cSrcweir         for (   FormFeatures::const_iterator formFeature = aFormFeatures.begin();
398cdf0e10cSrcweir                 formFeature != aFormFeatures.end();
399cdf0e10cSrcweir                 ++formFeature, ++commandImage
400cdf0e10cSrcweir             )
401cdf0e10cSrcweir         {
402cdf0e10cSrcweir             m_pToolbar->SetItemImage( *formFeature, *commandImage );
403cdf0e10cSrcweir         }
404cdf0e10cSrcweir 
405cdf0e10cSrcweir         // parts of our layout is dependent on the size of our icons
406cdf0e10cSrcweir         Resize();
407cdf0e10cSrcweir     }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     //---------------------------------------------------------------------
implSetImageSize(ImageSize _eSize)410cdf0e10cSrcweir     void NavigationToolBar::implSetImageSize( ImageSize _eSize )
411cdf0e10cSrcweir     {
412cdf0e10cSrcweir         if ( _eSize != m_eImageSize )
413cdf0e10cSrcweir         {
414cdf0e10cSrcweir             m_eImageSize = _eSize;
415cdf0e10cSrcweir             implUpdateImages();
416cdf0e10cSrcweir         }
417cdf0e10cSrcweir     }
418cdf0e10cSrcweir 
419cdf0e10cSrcweir     //---------------------------------------------------------------------
SetImageSize(ImageSize _eSize)420cdf0e10cSrcweir     void NavigationToolBar::SetImageSize( ImageSize _eSize )
421cdf0e10cSrcweir     {
422cdf0e10cSrcweir         implSetImageSize( _eSize );
423cdf0e10cSrcweir     }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir     //---------------------------------------------------------------------
ShowFunctionGroup(FunctionGroup _eGroup,bool _bShow)426cdf0e10cSrcweir     void NavigationToolBar::ShowFunctionGroup( FunctionGroup _eGroup, bool _bShow )
427cdf0e10cSrcweir     {
428cdf0e10cSrcweir         const sal_uInt16* pGroupIds = NULL;
429cdf0e10cSrcweir 
430cdf0e10cSrcweir         switch ( _eGroup )
431cdf0e10cSrcweir         {
432cdf0e10cSrcweir         case ePosition:
433cdf0e10cSrcweir         {
434cdf0e10cSrcweir             static const sal_uInt16 aPositionIds[] = {
435cdf0e10cSrcweir                 LID_RECORD_LABEL, FormFeature::MoveAbsolute, LID_RECORD_FILLER, FormFeature::TotalRecords, 0
436cdf0e10cSrcweir             };
437cdf0e10cSrcweir             pGroupIds = aPositionIds;
438cdf0e10cSrcweir         }
439cdf0e10cSrcweir         break;
440cdf0e10cSrcweir         case eNavigation:
441cdf0e10cSrcweir         {
442cdf0e10cSrcweir             static const sal_uInt16 aNavigationIds[] = {
443cdf0e10cSrcweir                 FormFeature::MoveToFirst, FormFeature::MoveToPrevious, FormFeature::MoveToNext, FormFeature::MoveToLast, FormFeature::MoveToInsertRow, 0
444cdf0e10cSrcweir             };
445cdf0e10cSrcweir             pGroupIds = aNavigationIds;
446cdf0e10cSrcweir         }
447cdf0e10cSrcweir         break;
448cdf0e10cSrcweir         case eRecordActions:
449cdf0e10cSrcweir         {
450cdf0e10cSrcweir             static const sal_uInt16 aActionIds[] = {
451cdf0e10cSrcweir                 FormFeature::SaveRecordChanges, FormFeature::UndoRecordChanges, FormFeature::DeleteRecord, FormFeature::ReloadForm, FormFeature::RefreshCurrentControl, 0
452cdf0e10cSrcweir             };
453cdf0e10cSrcweir             pGroupIds = aActionIds;
454cdf0e10cSrcweir         }
455cdf0e10cSrcweir         break;
456cdf0e10cSrcweir         case eFilterSort:
457cdf0e10cSrcweir         {
458cdf0e10cSrcweir             static const sal_uInt16 aFilterSortIds[] = {
459cdf0e10cSrcweir                 FormFeature::SortAscending, FormFeature::SortDescending, FormFeature::InteractiveSort, FormFeature::AutoFilter, FormFeature::InteractiveFilter, FormFeature::ToggleApplyFilter, FormFeature::RemoveFilterAndSort, 0
460cdf0e10cSrcweir             };
461cdf0e10cSrcweir             pGroupIds = aFilterSortIds;
462cdf0e10cSrcweir         }
463cdf0e10cSrcweir         break;
464cdf0e10cSrcweir         default:
465cdf0e10cSrcweir             OSL_ENSURE( sal_False, "NavigationToolBar::ShowFunctionGroup: invalid group id!" );
466cdf0e10cSrcweir         }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir         if ( pGroupIds )
469cdf0e10cSrcweir             while ( *pGroupIds )
470cdf0e10cSrcweir                 m_pToolbar->ShowItem( *pGroupIds++, _bShow );
471cdf0e10cSrcweir     }
472cdf0e10cSrcweir 
473cdf0e10cSrcweir     //---------------------------------------------------------------------
IsFunctionGroupVisible(FunctionGroup _eGroup)474cdf0e10cSrcweir     bool NavigationToolBar::IsFunctionGroupVisible( FunctionGroup _eGroup )
475cdf0e10cSrcweir     {
476cdf0e10cSrcweir         sal_uInt16 nIndicatorItem = 0;
477cdf0e10cSrcweir         switch ( _eGroup )
478cdf0e10cSrcweir         {
479cdf0e10cSrcweir         case ePosition      : nIndicatorItem = LID_RECORD_LABEL;    break;
480cdf0e10cSrcweir         case eNavigation    : nIndicatorItem = FormFeature::MoveToFirst; break;
481cdf0e10cSrcweir         case eRecordActions : nIndicatorItem = FormFeature::SaveRecordChanges;  break;
482cdf0e10cSrcweir         case eFilterSort    : nIndicatorItem = FormFeature::SortAscending;       break;
483cdf0e10cSrcweir         default:
484cdf0e10cSrcweir             OSL_ENSURE( sal_False, "NavigationToolBar::IsFunctionGroupVisible: invalid group id!" );
485cdf0e10cSrcweir         }
486cdf0e10cSrcweir 
487cdf0e10cSrcweir         return m_pToolbar->IsItemVisible( nIndicatorItem );
488cdf0e10cSrcweir     }
489cdf0e10cSrcweir 
490cdf0e10cSrcweir     //------------------------------------------------------------------------------
StateChanged(StateChangedType nType)491cdf0e10cSrcweir     void NavigationToolBar::StateChanged( StateChangedType nType )
492cdf0e10cSrcweir     {
493cdf0e10cSrcweir 	    Window::StateChanged( nType );
494cdf0e10cSrcweir 
495cdf0e10cSrcweir         switch ( nType )
496cdf0e10cSrcweir 	    {
497cdf0e10cSrcweir 		    case STATE_CHANGE_ZOOM:
498cdf0e10cSrcweir //                m_pToolbar->SetZoom( GetZoom() );
499cdf0e10cSrcweir //                forEachItemWindow( setItemWindowZoom, NULL );
500cdf0e10cSrcweir                 // the ToolBox class is not zoomable at the moment, so
501cdf0e10cSrcweir                 // we better have no zoom at all instead of only half a zoom ...
502cdf0e10cSrcweir                 break;
503cdf0e10cSrcweir 
504cdf0e10cSrcweir             case STATE_CHANGE_CONTROLFONT:
505cdf0e10cSrcweir                 forEachItemWindow( &NavigationToolBar::setItemControlFont, NULL );
506cdf0e10cSrcweir                 forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
507cdf0e10cSrcweir                 break;
508cdf0e10cSrcweir 
509cdf0e10cSrcweir             case STATE_CHANGE_CONTROLFOREGROUND:
510cdf0e10cSrcweir                 forEachItemWindow( &NavigationToolBar::setItemControlForeground, NULL );
511cdf0e10cSrcweir                 break;
512cdf0e10cSrcweir 
513cdf0e10cSrcweir             case STATE_CHANGE_MIRRORING:
514cdf0e10cSrcweir             {
515cdf0e10cSrcweir                 sal_Bool bIsRTLEnabled( IsRTLEnabled() );
516cdf0e10cSrcweir                 m_pToolbar->EnableRTL( bIsRTLEnabled );
517cdf0e10cSrcweir                 forEachItemWindow( &NavigationToolBar::enableItemRTL, &bIsRTLEnabled );
518cdf0e10cSrcweir                 Resize();
519cdf0e10cSrcweir             }
520cdf0e10cSrcweir             break;
521cdf0e10cSrcweir         }
522cdf0e10cSrcweir     }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     //---------------------------------------------------------------------
Resize()525cdf0e10cSrcweir     void NavigationToolBar::Resize()
526cdf0e10cSrcweir     {
527cdf0e10cSrcweir         // resize/position the toolbox as a whole
528cdf0e10cSrcweir         sal_Int32 nToolbarHeight = m_pToolbar->CalcWindowSizePixel().Height();
529cdf0e10cSrcweir 
530cdf0e10cSrcweir         sal_Int32 nMyHeight = GetOutputSizePixel().Height();
531cdf0e10cSrcweir         m_pToolbar->SetPosSizePixel( Point( 0, ( nMyHeight - nToolbarHeight ) / 2 ),
532cdf0e10cSrcweir                                      Size( GetSizePixel().Width(), nToolbarHeight ) );
533cdf0e10cSrcweir 
534cdf0e10cSrcweir         Window::Resize();
535cdf0e10cSrcweir     }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir     //---------------------------------------------------------------------
SetControlBackground()538cdf0e10cSrcweir     void NavigationToolBar::SetControlBackground()
539cdf0e10cSrcweir     {
540cdf0e10cSrcweir         Window::SetControlBackground();
541cdf0e10cSrcweir         m_pToolbar->SetControlBackground();
542cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::setItemBackground, NULL );
543cdf0e10cSrcweir 
544cdf0e10cSrcweir         // the contrast of the background color may have changed, so force
545cdf0e10cSrcweir         // the images to be rebuild (high contrast requires a possibly different
546cdf0e10cSrcweir         // image set)
547cdf0e10cSrcweir         implUpdateImages();
548cdf0e10cSrcweir     }
549cdf0e10cSrcweir 
550cdf0e10cSrcweir     //---------------------------------------------------------------------
SetControlBackground(const Color & _rColor)551cdf0e10cSrcweir     void NavigationToolBar::SetControlBackground( const Color& _rColor )
552cdf0e10cSrcweir     {
553cdf0e10cSrcweir         Window::SetControlBackground( _rColor );
554cdf0e10cSrcweir         m_pToolbar->SetControlBackground( _rColor );
555cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::setItemBackground, &_rColor );
556cdf0e10cSrcweir 
557cdf0e10cSrcweir         // the contrast of the background color may have changed, so force
558cdf0e10cSrcweir         // the images to be rebuild (high contrast requires a possibly different
559cdf0e10cSrcweir         // image set)
560cdf0e10cSrcweir         implUpdateImages();
561cdf0e10cSrcweir     }
562cdf0e10cSrcweir 
563cdf0e10cSrcweir     //---------------------------------------------------------------------
SetTextLineColor()564cdf0e10cSrcweir     void NavigationToolBar::SetTextLineColor( )
565cdf0e10cSrcweir     {
566cdf0e10cSrcweir         Window::SetTextLineColor( );
567cdf0e10cSrcweir         m_pToolbar->SetTextLineColor( );
568cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::setTextLineColor, NULL );
569cdf0e10cSrcweir     }
570cdf0e10cSrcweir 
571cdf0e10cSrcweir     //---------------------------------------------------------------------
SetTextLineColor(const Color & _rColor)572cdf0e10cSrcweir     void NavigationToolBar::SetTextLineColor( const Color& _rColor )
573cdf0e10cSrcweir     {
574cdf0e10cSrcweir         Window::SetTextLineColor( _rColor );
575cdf0e10cSrcweir         m_pToolbar->SetTextLineColor( _rColor );
576cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::setTextLineColor, &_rColor );
577cdf0e10cSrcweir     }
578cdf0e10cSrcweir 
579cdf0e10cSrcweir     //---------------------------------------------------------------------
forEachItemWindow(ItemWindowHandler _handler,const void * _pParam)580cdf0e10cSrcweir     void NavigationToolBar::forEachItemWindow( ItemWindowHandler _handler, const void* _pParam )
581cdf0e10cSrcweir     {
582cdf0e10cSrcweir         for ( sal_uInt16 item = 0; item < m_pToolbar->GetItemCount(); ++item )
583cdf0e10cSrcweir         {
584cdf0e10cSrcweir             sal_uInt16 nItemId = m_pToolbar->GetItemId( item );
585cdf0e10cSrcweir             Window* pItemWindow = m_pToolbar->GetItemWindow( nItemId );
586cdf0e10cSrcweir             if ( pItemWindow )
587cdf0e10cSrcweir                 (this->*_handler)( nItemId, pItemWindow, _pParam );
588cdf0e10cSrcweir         }
589cdf0e10cSrcweir     }
590cdf0e10cSrcweir 
591cdf0e10cSrcweir     //---------------------------------------------------------------------
setItemBackground(sal_uInt16,Window * _pItemWindow,const void * _pColor) const592cdf0e10cSrcweir     void NavigationToolBar::setItemBackground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const
593cdf0e10cSrcweir     {
594cdf0e10cSrcweir         if ( _pColor )
595cdf0e10cSrcweir             _pItemWindow->SetControlBackground( *static_cast< const Color* >( _pColor ) );
596cdf0e10cSrcweir         else
597cdf0e10cSrcweir             _pItemWindow->SetControlBackground();
598cdf0e10cSrcweir     }
599cdf0e10cSrcweir 
600cdf0e10cSrcweir     //---------------------------------------------------------------------
setTextLineColor(sal_uInt16,Window * _pItemWindow,const void * _pColor) const601cdf0e10cSrcweir     void NavigationToolBar::setTextLineColor( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const
602cdf0e10cSrcweir     {
603cdf0e10cSrcweir         if ( _pColor )
604cdf0e10cSrcweir             _pItemWindow->SetTextLineColor( *static_cast< const Color* >( _pColor ) );
605cdf0e10cSrcweir         else
606cdf0e10cSrcweir             _pItemWindow->SetTextLineColor();
607cdf0e10cSrcweir     }
608cdf0e10cSrcweir #if 0
609cdf0e10cSrcweir     //---------------------------------------------------------------------
610cdf0e10cSrcweir     void NavigationToolBar::setItemWindowZoom( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
611cdf0e10cSrcweir     {
612cdf0e10cSrcweir         _pItemWindow->SetZoom( GetZoom() );
613cdf0e10cSrcweir         _pItemWindow->SetZoomedPointFont( IsControlFont() ? GetControlFont() : GetPointFont() );
614cdf0e10cSrcweir     }
615cdf0e10cSrcweir #endif
616cdf0e10cSrcweir     //---------------------------------------------------------------------
setItemControlFont(sal_uInt16,Window * _pItemWindow,const void *) const617cdf0e10cSrcweir     void NavigationToolBar::setItemControlFont( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
618cdf0e10cSrcweir     {
619cdf0e10cSrcweir         if ( IsControlFont() )
620cdf0e10cSrcweir             _pItemWindow->SetControlFont( GetControlFont() );
621cdf0e10cSrcweir         else
622cdf0e10cSrcweir             _pItemWindow->SetControlFont( );
623cdf0e10cSrcweir     }
624cdf0e10cSrcweir 
625cdf0e10cSrcweir     //---------------------------------------------------------------------
setItemControlForeground(sal_uInt16,Window * _pItemWindow,const void *) const626cdf0e10cSrcweir     void NavigationToolBar::setItemControlForeground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
627cdf0e10cSrcweir     {
628cdf0e10cSrcweir         if ( IsControlForeground() )
629cdf0e10cSrcweir             _pItemWindow->SetControlForeground( GetControlForeground() );
630cdf0e10cSrcweir         else
631cdf0e10cSrcweir             _pItemWindow->SetControlForeground( );
632cdf0e10cSrcweir         _pItemWindow->SetTextColor( GetTextColor() );
633cdf0e10cSrcweir     }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir     //---------------------------------------------------------------------
adjustItemWindowWidth(sal_uInt16 _nItemId,Window * _pItemWindow,const void *) const636cdf0e10cSrcweir     void NavigationToolBar::adjustItemWindowWidth( sal_uInt16 _nItemId, Window* _pItemWindow, const void* /* _pParam */ ) const
637cdf0e10cSrcweir     {
638cdf0e10cSrcweir         String sItemText;
639cdf0e10cSrcweir         switch ( _nItemId )
640cdf0e10cSrcweir         {
641cdf0e10cSrcweir         case LID_RECORD_LABEL:
642cdf0e10cSrcweir             sItemText = getLabelString( RID_STR_LABEL_RECORD );
643cdf0e10cSrcweir             break;
644cdf0e10cSrcweir 
645cdf0e10cSrcweir         case LID_RECORD_FILLER:
646cdf0e10cSrcweir             sItemText = getLabelString( RID_STR_LABEL_OF );
647cdf0e10cSrcweir             break;
648cdf0e10cSrcweir 
649cdf0e10cSrcweir         case FormFeature::MoveAbsolute:
650cdf0e10cSrcweir             sItemText = String::CreateFromAscii( "12345678" );
651cdf0e10cSrcweir             break;
652cdf0e10cSrcweir 
653cdf0e10cSrcweir         case FormFeature::TotalRecords:
654cdf0e10cSrcweir             sItemText = String::CreateFromAscii( "123456" );
655cdf0e10cSrcweir             break;
656cdf0e10cSrcweir         }
657cdf0e10cSrcweir 
658cdf0e10cSrcweir         Size aSize( _pItemWindow->GetTextWidth( sItemText ), /* _pItemWindow->GetSizePixel( ).Height() */ _pItemWindow->GetTextHeight() + 4 );
659cdf0e10cSrcweir         aSize.Width() += 6;
660cdf0e10cSrcweir         _pItemWindow->SetSizePixel( aSize );
661cdf0e10cSrcweir 
662cdf0e10cSrcweir         m_pToolbar->SetItemWindow( _nItemId, _pItemWindow );
663cdf0e10cSrcweir     }
664cdf0e10cSrcweir 
665cdf0e10cSrcweir     //---------------------------------------------------------------------
enableItemRTL(sal_uInt16,Window * _pItemWindow,const void * _pIsRTLEnabled) const666cdf0e10cSrcweir     void NavigationToolBar::enableItemRTL( sal_uInt16 /*_nItemId*/, Window* _pItemWindow, const void* _pIsRTLEnabled ) const
667cdf0e10cSrcweir     {
668cdf0e10cSrcweir         _pItemWindow->EnableRTL( *static_cast< const sal_Bool* >( _pIsRTLEnabled ) );
669cdf0e10cSrcweir     }
670cdf0e10cSrcweir 
671cdf0e10cSrcweir     //=====================================================================
672cdf0e10cSrcweir     //= RecordPositionInput
673cdf0e10cSrcweir     //=====================================================================
674cdf0e10cSrcweir     //---------------------------------------------------------------------
RecordPositionInput(Window * _pParent)675cdf0e10cSrcweir     RecordPositionInput::RecordPositionInput( Window* _pParent )
676cdf0e10cSrcweir 	    :NumericField( _pParent, WB_BORDER | WB_VCENTER )
677cdf0e10cSrcweir         ,m_pDispatcher( NULL )
678cdf0e10cSrcweir     {
679cdf0e10cSrcweir 	    SetMin( 1 );
680cdf0e10cSrcweir 	    SetFirst( 1 );
681cdf0e10cSrcweir 	    SetSpinSize( 1 );
682cdf0e10cSrcweir 	    SetDecimalDigits( 0 );
683cdf0e10cSrcweir 	    SetStrictFormat( sal_True );
684cdf0e10cSrcweir         SetBorderStyle( WINDOW_BORDER_MONO );
685cdf0e10cSrcweir     }
686cdf0e10cSrcweir 
687cdf0e10cSrcweir     //---------------------------------------------------------------------
~RecordPositionInput()688cdf0e10cSrcweir     RecordPositionInput::~RecordPositionInput()
689cdf0e10cSrcweir     {
690cdf0e10cSrcweir     }
691cdf0e10cSrcweir 
692cdf0e10cSrcweir     //---------------------------------------------------------------------
setDispatcher(const IFeatureDispatcher * _pDispatcher)693cdf0e10cSrcweir     void RecordPositionInput::setDispatcher( const IFeatureDispatcher* _pDispatcher )
694cdf0e10cSrcweir     {
695cdf0e10cSrcweir         m_pDispatcher = _pDispatcher;
696cdf0e10cSrcweir     }
697cdf0e10cSrcweir 
698cdf0e10cSrcweir     //---------------------------------------------------------------------
FirePosition(sal_Bool _bForce)699cdf0e10cSrcweir     void RecordPositionInput::FirePosition( sal_Bool _bForce )
700cdf0e10cSrcweir     {
701cdf0e10cSrcweir 	    if ( _bForce || ( GetText() != GetSavedValue() ) )
702cdf0e10cSrcweir 	    {
703cdf0e10cSrcweir 		    sal_Int64 nRecord = GetValue();
704cdf0e10cSrcweir 		    if ( nRecord < GetMin() || nRecord > GetMax() )
705cdf0e10cSrcweir 			    return;
706cdf0e10cSrcweir 
707cdf0e10cSrcweir             if ( m_pDispatcher )
708cdf0e10cSrcweir                 m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( (sal_Int32)nRecord ) );
709cdf0e10cSrcweir 
710cdf0e10cSrcweir             SaveValue();
711cdf0e10cSrcweir 	    }
712cdf0e10cSrcweir     }
713cdf0e10cSrcweir 
714cdf0e10cSrcweir     //---------------------------------------------------------------------
LoseFocus()715cdf0e10cSrcweir     void RecordPositionInput::LoseFocus()
716cdf0e10cSrcweir     {
717cdf0e10cSrcweir 	    FirePosition( sal_False );
718cdf0e10cSrcweir     }
719cdf0e10cSrcweir 
720cdf0e10cSrcweir     //---------------------------------------------------------------------
KeyInput(const KeyEvent & rKeyEvent)721cdf0e10cSrcweir     void RecordPositionInput::KeyInput( const KeyEvent& rKeyEvent )
722cdf0e10cSrcweir     {
723cdf0e10cSrcweir 	    if( rKeyEvent.GetKeyCode() == KEY_RETURN && GetText().Len() )
724cdf0e10cSrcweir 		    FirePosition( sal_True );
725cdf0e10cSrcweir 	    else
726cdf0e10cSrcweir 		    NumericField::KeyInput( rKeyEvent );
727cdf0e10cSrcweir     }
728cdf0e10cSrcweir 
729cdf0e10cSrcweir 
730cdf0e10cSrcweir //.........................................................................
731cdf0e10cSrcweir }   // namespace frm
732cdf0e10cSrcweir //.........................................................................
733