summaryrefslogtreecommitdiff
path: root/forms/source/solar/control/navtoolbar.cxx
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-05 16:31:23 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-05 16:31:23 +0100
commit595e1c2ebb346b3f7c69837fcf73d943bcade582 (patch)
tree9fdbcd8f279314a9519ff43c62f4be911fd18ddb /forms/source/solar/control/navtoolbar.cxx
parenta7b054e6309a841df1c67696258af8ad19cebdea (diff)
#i68332# use css.form.runtime.FormFeature, instead of SFX slot IDs (where possible so far)
Diffstat (limited to 'forms/source/solar/control/navtoolbar.cxx')
-rw-r--r--forms/source/solar/control/navtoolbar.cxx197
1 files changed, 120 insertions, 77 deletions
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx
index 37b9faf8a5f4..c5d52261d8a8 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -30,39 +30,40 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_forms.hxx"
+
#include "navtoolbar.hxx"
#include "frm_resource.hxx"
-#ifndef _FRM_RESOURCE_HRC_
-#include "frm_resource.hrc"
-#endif
-#include <vcl/fixed.hxx>
-#ifndef _SVX_SVXIDS_HRC
-#include <svx/svxids.hrc>
-#endif
-#include <sfx2/msgpool.hxx>
-#include <sfx2/imgmgr.hxx>
#include "featuredispatcher.hxx"
+#include "frm_resource.hrc"
+
#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/form/runtime/FormFeature.hpp>
+
+#include <sfx2/imgmgr.hxx>
+#include <svx/svxids.hrc>
+#include <vcl/fixed.hxx>
#include <memory>
-#define LID_RECORD_LABEL 1
-#define LID_RECORD_FILLER 2
+#define LID_RECORD_LABEL 1000
+#define LID_RECORD_FILLER 1001
//.........................................................................
namespace frm
{
//.........................................................................
+ using ::com::sun::star::uno::makeAny;
+ namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
+
//=====================================================================
//.....................................................................
namespace
{
- static bool isSfxSlot( sal_Int32 _nFeatureId )
+ static bool isArtificialItem( sal_Int16 _nFeatureId )
{
- // everything we use in this class is an SFX-slot - except the LID_* ids
- return ( _nFeatureId != LID_RECORD_LABEL )
- && ( _nFeatureId != LID_RECORD_FILLER );
+ return ( _nFeatureId == LID_RECORD_LABEL )
+ || ( _nFeatureId == LID_RECORD_FILLER );
}
static String getLabelString( USHORT _nResId )
@@ -72,10 +73,39 @@ namespace frm
sLabel += String::CreateFromAscii( " " );
return sLabel;
}
+
static bool lcl_isHighContrast( const Color& _rColor )
{
return _rColor.IsDark();
}
+
+ sal_Int32 lcl_getSlotId( const sal_Int16 _nFormFeature )
+ {
+ switch ( _nFormFeature )
+ {
+ case FormFeature::MoveAbsolute : return SID_FM_RECORD_ABSOLUTE;
+ case FormFeature::TotalRecords : return SID_FM_RECORD_TOTAL;
+ case FormFeature::MoveToFirst : return SID_FM_RECORD_FIRST;
+ case FormFeature::MoveToPrevious : return SID_FM_RECORD_PREV;
+ case FormFeature::MoveToNext : return SID_FM_RECORD_NEXT;
+ case FormFeature::MoveToLast : return SID_FM_RECORD_LAST;
+ case FormFeature::SaveRecordChanges : return SID_FM_RECORD_SAVE;
+ case FormFeature::UndoRecordChanges : return SID_FM_RECORD_UNDO;
+ case FormFeature::MoveToInsertRow : return SID_FM_RECORD_NEW;
+ case FormFeature::DeleteRecord : return SID_FM_RECORD_DELETE;
+ case FormFeature::ReloadForm : return SID_FM_REFRESH;
+ case FormFeature::RefreshCurrentControl : return SID_FM_REFRESH_FORM_CONTROL;
+ case FormFeature::SortAscending : return SID_FM_SORTUP;
+ case FormFeature::SortDescending : return SID_FM_SORTDOWN;
+ case FormFeature::InteractiveSort : return SID_FM_ORDERCRIT;
+ case FormFeature::AutoFilter : return SID_FM_AUTOFILTER;
+ case FormFeature::InteractiveFilter : return SID_FM_FILTERCRIT;
+ case FormFeature::ToggleApplyFilter : return SID_FM_FORM_FILTERED;
+ case FormFeature::RemoveFilterAndSort : return SID_FM_REMOVE_FILTER_SORT;
+ }
+ OSL_ENSURE( isArtificialItem( _nFormFeature ), "lcl_getSlotId: unknown FormFeature!" );
+ return 0;
+ }
}
//=====================================================================
@@ -154,7 +184,7 @@ namespace frm
m_pToolbar->setDispatcher( _pDispatcher );
- RecordPositionInput* pPositionWindow = static_cast< RecordPositionInput* >( m_pToolbar->GetItemWindow( SID_FM_RECORD_ABSOLUTE ) );
+ RecordPositionInput* pPositionWindow = static_cast< RecordPositionInput* >( m_pToolbar->GetItemWindow( FormFeature::MoveAbsolute ) );
OSL_ENSURE( pPositionWindow, "NavigationToolBar::setDispatcher: can't forward the dispatcher to the position window!" );
if ( pPositionWindow )
pPositionWindow->setDispatcher( _pDispatcher );
@@ -183,15 +213,15 @@ namespace frm
{
m_pToolbar->EnableItem( _nItemId, _bEnabled );
- if ( _nItemId == SID_FM_RECORD_ABSOLUTE )
+ if ( _nItemId == FormFeature::MoveAbsolute )
m_pToolbar->EnableItem( LID_RECORD_LABEL, _bEnabled );
- if ( _nItemId == SID_FM_RECORD_TOTAL )
+ if ( _nItemId == FormFeature::TotalRecords )
m_pToolbar->EnableItem( LID_RECORD_FILLER, _bEnabled );
}
//---------------------------------------------------------------------
- void NavigationToolBar::enableFeature( sal_Int32 _nFeatureId, bool _bEnabled )
+ void NavigationToolBar::enableFeature( sal_Int16 _nFeatureId, bool _bEnabled )
{
DBG_ASSERT( m_pToolbar->GetItemPos( (USHORT)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
"NavigationToolBar::enableFeature: invalid id!" );
@@ -200,7 +230,7 @@ namespace frm
}
//---------------------------------------------------------------------
- void NavigationToolBar::checkFeature( sal_Int32 _nFeatureId, bool _bEnabled )
+ void NavigationToolBar::checkFeature( sal_Int16 _nFeatureId, bool _bEnabled )
{
DBG_ASSERT( m_pToolbar->GetItemPos( (USHORT)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
"NavigationToolBar::checkFeature: invalid id!" );
@@ -209,7 +239,7 @@ namespace frm
}
//---------------------------------------------------------------------
- void NavigationToolBar::setFeatureText( sal_Int32 _nFeatureId, const ::rtl::OUString& _rText )
+ void NavigationToolBar::setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText )
{
DBG_ASSERT( m_pToolbar->GetItemPos( (USHORT)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
"NavigationToolBar::checkFeature: invalid id!" );
@@ -232,45 +262,44 @@ namespace frm
// items. We could duplicate all the information here in our lib
// (such as the item text and the image), but why should we?
- struct SlotDescription
+ struct FeatureDescription
{
USHORT nId;
bool bRepeat;
bool bItemWindow;
- } aSupportedSlots[] =
+ } aSupportedFeatures[] =
{
- { LID_RECORD_LABEL, false, true },
- { SID_FM_RECORD_ABSOLUTE, false, true },
- { LID_RECORD_FILLER, false, true },
- { SID_FM_RECORD_TOTAL, false, true },
-
- { SID_FM_RECORD_FIRST, true, false },
- { SID_FM_RECORD_PREV, true, false },
- { SID_FM_RECORD_NEXT, true, false },
- { SID_FM_RECORD_LAST, true, false },
+ { LID_RECORD_LABEL, false, true },
+ { FormFeature::MoveAbsolute, false, true },
+ { LID_RECORD_FILLER, false, true },
+ { FormFeature::TotalRecords, false, true },
+ { FormFeature::MoveToFirst, true, false },
+ { FormFeature::MoveToPrevious, true, false },
+ { FormFeature::MoveToNext, true, false },
+ { FormFeature::MoveToLast, true, false },
+ { FormFeature::MoveToInsertRow, false, false },
{ 0, false, false },
- { SID_FM_RECORD_SAVE, false, false },
- { SID_FM_RECORD_UNDO, false, false },
- { SID_FM_RECORD_NEW, false, false },
- { SID_FM_RECORD_DELETE, false, false },
- { SID_FM_REFRESH, false, false },
- { SID_FM_REFRESH_FORM_CONTROL, false, false },
+ { FormFeature::SaveRecordChanges, false, false },
+ { FormFeature::UndoRecordChanges, false, false },
+ { FormFeature::DeleteRecord, false, false },
+ { FormFeature::ReloadForm, false, false },
+ { FormFeature::RefreshCurrentControl, false, false },
{ 0, false, false },
- { SID_FM_SORTUP, false, false },
- { SID_FM_SORTDOWN, false, false },
- { SID_FM_ORDERCRIT, false, false },
- { SID_FM_AUTOFILTER, false, false },
- { SID_FM_FILTERCRIT, false, false },
- { SID_FM_FORM_FILTERED, false, false },
- { SID_FM_REMOVE_FILTER_SORT, false, false },
+ { FormFeature::SortAscending, false, false },
+ { FormFeature::SortDescending, false, false },
+ { FormFeature::InteractiveSort, false, false },
+ { FormFeature::AutoFilter, false, false },
+ { FormFeature::InteractiveFilter, false, false },
+ { FormFeature::ToggleApplyFilter, false, false },
+ { FormFeature::RemoveFilterAndSort, false, false },
};
- size_t nSupportedSlots = sizeof( aSupportedSlots ) / sizeof( aSupportedSlots[0] );
- SlotDescription* pSupportedSlots = aSupportedSlots;
- SlotDescription* pSupportedSlotsEnd = aSupportedSlots + nSupportedSlots;
- for ( ; pSupportedSlots < pSupportedSlotsEnd; ++pSupportedSlots )
+ size_t nSupportedFeatures = sizeof( aSupportedFeatures ) / sizeof( aSupportedFeatures[0] );
+ FeatureDescription* pSupportedFeatures = aSupportedFeatures;
+ FeatureDescription* pSupportedFeaturesEnd = aSupportedFeatures + nSupportedFeatures;
+ for ( ; pSupportedFeatures < pSupportedFeaturesEnd; ++pSupportedFeatures )
{
- if ( pSupportedSlots->nId )
+ if ( pSupportedFeatures->nId )
{ // it's _not_ a separator
// the text(s) of the item
@@ -279,24 +308,24 @@ namespace frm
// TODO/CLEANUP: this code does nothing(!) nowadays
//SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( NULL );
- //sItemText = rSlotPool.GetSlotName( pSupportedSlots->nId, &sItemHelpText );
+ //sItemText = rSlotPool.GetSlotName( pSupportedFeatures->nId, &sItemHelpText );
// insert the entry
- m_pToolbar->InsertItem( pSupportedSlots->nId, sItemText, pSupportedSlots->bRepeat ? TIB_REPEAT : 0 );
- m_pToolbar->SetQuickHelpText( pSupportedSlots->nId, sItemHelpText );
- if ( isSfxSlot( pSupportedSlots->nId ) )
- m_pToolbar->SetHelpId( pSupportedSlots->nId, pSupportedSlots->nId );
+ m_pToolbar->InsertItem( pSupportedFeatures->nId, sItemText, pSupportedFeatures->bRepeat ? TIB_REPEAT : 0 );
+ m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, sItemHelpText );
+ if ( !isArtificialItem( pSupportedFeatures->nId ) )
+ m_pToolbar->SetHelpId( pSupportedFeatures->nId, lcl_getSlotId( pSupportedFeatures->nId ) );
- if ( pSupportedSlots->bItemWindow )
+ if ( pSupportedFeatures->bItemWindow )
{
Window* pItemWindow = NULL;
- if ( SID_FM_RECORD_ABSOLUTE == pSupportedSlots->nId )
+ if ( FormFeature::MoveAbsolute == pSupportedFeatures->nId )
{
pItemWindow = new RecordPositionInput( m_pToolbar );
static_cast< RecordPositionInput* >( pItemWindow )->setDispatcher( m_pDispatcher );
}
- else if ( LID_RECORD_FILLER == pSupportedSlots->nId )
+ else if ( LID_RECORD_FILLER == pSupportedFeatures->nId )
{
pItemWindow = new FixedText( m_pToolbar, WB_CENTER | WB_VCENTER );
pItemWindow->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
@@ -309,7 +338,7 @@ namespace frm
}
m_aChildWins.push_back( pItemWindow );
- switch ( pSupportedSlots->nId )
+ switch ( pSupportedFeatures->nId )
{
case LID_RECORD_LABEL:
pItemWindow->SetText( getLabelString( RID_STR_LABEL_RECORD ) );
@@ -320,7 +349,7 @@ namespace frm
break;
}
- m_pToolbar->SetItemWindow( pSupportedSlots->nId, pItemWindow );
+ m_pToolbar->SetItemWindow( pSupportedFeatures->nId, pItemWindow );
}
}
else
@@ -331,12 +360,7 @@ namespace frm
forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
- // the image of the item
- ::std::auto_ptr< SfxImageManager > pImageManager( new SfxImageManager( NULL ) );
- pImageManager->SetImagesForceSize( *m_pToolbar, FALSE, m_eImageSize == eLarge );
-
- // parts of our layout is dependent on the size of our icons
- Resize();
+ implSetImageSize( m_eImageSize, true );
}
//---------------------------------------------------------------------
@@ -345,8 +369,27 @@ namespace frm
if ( ( _eSize != m_eImageSize ) || _bForce )
{
m_eImageSize = _eSize;
+
::std::auto_ptr< SfxImageManager > pImageManager( new SfxImageManager( NULL ) );
- pImageManager->SetImagesForceSize( *m_pToolbar, lcl_isHighContrast( GetBackground().GetColor() ), m_eImageSize == eLarge );
+ const bool bIsHighContrast = lcl_isHighContrast( GetBackground().GetColor() );
+
+ const USHORT nCount = m_pToolbar->GetItemCount();
+ for ( USHORT i=0; i<nCount; ++i )
+ {
+ USHORT nId = m_pToolbar->GetItemId( i );
+ if ( TOOLBOXITEM_BUTTON == m_pToolbar->GetItemType( i ) )
+ {
+ Image aItemImage;
+ if ( !isArtificialItem( nId ) )
+ aItemImage = pImageManager->GetImage( lcl_getSlotId( nId ), m_eImageSize == eLarge, bIsHighContrast );
+ m_pToolbar->SetItemImage( nId, aItemImage );
+ }
+ }
+
+ // TODO: using the "official" command URLs belonging to a FormFeature, it should be possible to obtain
+ // the images from some global UNO service, instead of using the SfxImageManager, and SFX slot IDs.
+ // Also, those URLs allow (/me thinks) to obtain the command texts, which we could set at the toolbox,
+ // so they would appear as tooltip.
// parts of our layout is dependent on the size of our icons
Resize();
@@ -369,7 +412,7 @@ namespace frm
case ePosition:
{
static const USHORT aPositionIds[] = {
- LID_RECORD_LABEL, SID_FM_RECORD_ABSOLUTE, LID_RECORD_FILLER, SID_FM_RECORD_TOTAL, 0
+ LID_RECORD_LABEL, FormFeature::MoveAbsolute, LID_RECORD_FILLER, FormFeature::TotalRecords, 0
};
pGroupIds = aPositionIds;
}
@@ -377,7 +420,7 @@ namespace frm
case eNavigation:
{
static const USHORT aNavigationIds[] = {
- SID_FM_RECORD_FIRST, SID_FM_RECORD_PREV, SID_FM_RECORD_NEXT, SID_FM_RECORD_LAST, 0
+ FormFeature::MoveToFirst, FormFeature::MoveToPrevious, FormFeature::MoveToNext, FormFeature::MoveToLast, FormFeature::MoveToInsertRow, 0
};
pGroupIds = aNavigationIds;
}
@@ -385,7 +428,7 @@ namespace frm
case eRecordActions:
{
static const USHORT aActionIds[] = {
- SID_FM_RECORD_SAVE, SID_FM_RECORD_UNDO, SID_FM_RECORD_NEW, SID_FM_RECORD_DELETE, SID_FM_REFRESH, SID_FM_REFRESH_FORM_CONTROL, 0
+ FormFeature::SaveRecordChanges, FormFeature::UndoRecordChanges, FormFeature::DeleteRecord, FormFeature::ReloadForm, FormFeature::RefreshCurrentControl, 0
};
pGroupIds = aActionIds;
}
@@ -393,7 +436,7 @@ namespace frm
case eFilterSort:
{
static const USHORT aFilterSortIds[] = {
- SID_FM_SORTUP, SID_FM_SORTDOWN, SID_FM_ORDERCRIT, SID_FM_AUTOFILTER, SID_FM_FILTERCRIT, SID_FM_FORM_FILTERED, SID_FM_REMOVE_FILTER_SORT, 0
+ FormFeature::SortAscending, FormFeature::SortDescending, FormFeature::InteractiveSort, FormFeature::AutoFilter, FormFeature::InteractiveFilter, FormFeature::ToggleApplyFilter, FormFeature::RemoveFilterAndSort, 0
};
pGroupIds = aFilterSortIds;
}
@@ -414,9 +457,9 @@ namespace frm
switch ( _eGroup )
{
case ePosition : nIndicatorItem = LID_RECORD_LABEL; break;
- case eNavigation : nIndicatorItem = SID_FM_RECORD_FIRST; break;
- case eRecordActions : nIndicatorItem = SID_FM_RECORD_SAVE; break;
- case eFilterSort : nIndicatorItem = SID_FM_SORTUP; break;
+ case eNavigation : nIndicatorItem = FormFeature::MoveToFirst; break;
+ case eRecordActions : nIndicatorItem = FormFeature::SaveRecordChanges; break;
+ case eFilterSort : nIndicatorItem = FormFeature::SortAscending; break;
default:
OSL_ENSURE( sal_False, "NavigationToolBar::IsFunctionGroupVisible: invalid group id!" );
}
@@ -583,11 +626,11 @@ namespace frm
sItemText = getLabelString( RID_STR_LABEL_OF );
break;
- case SID_FM_RECORD_ABSOLUTE:
+ case FormFeature::MoveAbsolute:
sItemText = String::CreateFromAscii( "12345678" );
break;
- case SID_FM_RECORD_TOTAL:
+ case FormFeature::TotalRecords:
sItemText = String::CreateFromAscii( "123456" );
break;
}
@@ -642,7 +685,7 @@ namespace frm
return;
if ( m_pDispatcher )
- m_pDispatcher->dispatchWithArgument( SID_FM_RECORD_ABSOLUTE, "Position", ::com::sun::star::uno::makeAny( (sal_Int32)nRecord ) );
+ m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( (sal_Int32)nRecord ) );
SaveValue();
}