23#include <featuredispatcher.hxx>
27#include <com/sun/star/uno/Any.hxx>
28#include <com/sun/star/form/runtime/FormFeature.hpp>
37#include <osl/diagnose.h>
40#define LID_RECORD_LABEL 1000
41#define LID_RECORD_FILLER 1001
48 using ::com::sun::star::uno::Any;
49 namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
54 bool isArtificialItem( sal_Int16 _nFeatureId )
66 OUString lcl_getCommandURL(
const sal_Int16 _nFormFeature )
68 const char* pAsciiCommandName =
nullptr;
69 switch ( _nFormFeature )
71 case FormFeature::MoveAbsolute : pAsciiCommandName =
"AbsoluteRecord";
break;
72 case FormFeature::TotalRecords : pAsciiCommandName =
"RecTotal";
break;
73 case FormFeature::MoveToFirst : pAsciiCommandName =
"FirstRecord";
break;
74 case FormFeature::MoveToPrevious : pAsciiCommandName =
"PrevRecord";
break;
75 case FormFeature::MoveToNext : pAsciiCommandName =
"NextRecord";
break;
76 case FormFeature::MoveToLast : pAsciiCommandName =
"LastRecord";
break;
77 case FormFeature::SaveRecordChanges : pAsciiCommandName =
"RecSave";
break;
78 case FormFeature::UndoRecordChanges : pAsciiCommandName =
"RecUndo";
break;
79 case FormFeature::MoveToInsertRow : pAsciiCommandName =
"NewRecord";
break;
80 case FormFeature::DeleteRecord : pAsciiCommandName =
"DeleteRecord";
break;
81 case FormFeature::ReloadForm : pAsciiCommandName =
"Refresh";
break;
82 case FormFeature::RefreshCurrentControl : pAsciiCommandName =
"RefreshFormControl";
break;
83 case FormFeature::SortAscending : pAsciiCommandName =
"Sortup";
break;
84 case FormFeature::SortDescending : pAsciiCommandName =
"SortDown";
break;
85 case FormFeature::InteractiveSort : pAsciiCommandName =
"OrderCrit";
break;
86 case FormFeature::AutoFilter : pAsciiCommandName =
"AutoFilter";
break;
87 case FormFeature::InteractiveFilter : pAsciiCommandName =
"FilterCrit";
break;
88 case FormFeature::ToggleApplyFilter : pAsciiCommandName =
"FormFiltered";
break;
89 case FormFeature::RemoveFilterAndSort : pAsciiCommandName =
"RemoveFilterSort";
break;
91 if ( pAsciiCommandName !=
nullptr )
92 return ".uno:" + OUString::createFromAscii( pAsciiCommandName );
117 virtual void Select()
override;
139 :
Window( _pParent, _nStyle )
140 ,m_pDispatcher( nullptr )
141 ,m_pImageProvider(
std::move( _pImageProvider ))
142 ,m_eImageSize( eSmall )
143 ,m_pToolbar( nullptr )
144 ,m_sModuleId(
std::move( sModuleId ))
157 childWin.disposeAndClear();
170 OSL_ENSURE( pPositionWindow,
"NavigationToolBar::setDispatcher: can't forward the dispatcher to the position window!" );
171 if ( pPositionWindow )
192 if ( _nItemId == FormFeature::MoveAbsolute )
195 if ( _nItemId == FormFeature::TotalRecords )
202 "NavigationToolBar::enableFeature: invalid id!" );
204 implEnableItem(
static_cast<sal_uInt16
>(_nFeatureId), _bEnabled );
210 "NavigationToolBar::checkFeature: invalid id!" );
218 "NavigationToolBar::checkFeature: invalid id!" );
223 if (_nFeatureId == FormFeature::TotalRecords)
225 else if (_nFeatureId == FormFeature::MoveAbsolute)
241 static struct FeatureDescription
246 }
const aSupportedFeatures[] =
249 { FormFeature::MoveAbsolute,
false,
true },
251 { FormFeature::TotalRecords,
false,
true },
252 { FormFeature::MoveToFirst,
true,
false },
253 { FormFeature::MoveToPrevious,
true,
false },
254 { FormFeature::MoveToNext,
true,
false },
255 { FormFeature::MoveToLast,
true,
false },
256 { FormFeature::MoveToInsertRow,
false,
false },
258 { FormFeature::SaveRecordChanges,
false,
false },
259 { FormFeature::UndoRecordChanges,
false,
false },
260 { FormFeature::DeleteRecord,
false,
false },
261 { FormFeature::ReloadForm,
false,
false },
262 { FormFeature::RefreshCurrentControl,
false,
false },
264 { FormFeature::SortAscending,
false,
false },
265 { FormFeature::SortDescending,
false,
false },
266 { FormFeature::InteractiveSort,
false,
false },
267 { FormFeature::AutoFilter,
false,
false },
268 { FormFeature::InteractiveFilter,
false,
false },
269 { FormFeature::ToggleApplyFilter,
false,
false },
270 { FormFeature::RemoveFilterAndSort,
false,
false },
273 FeatureDescription
const * pSupportedFeatures = aSupportedFeatures;
274 FeatureDescription
const * pSupportedFeaturesEnd = aSupportedFeatures +
SAL_N_ELEMENTS( aSupportedFeatures );
275 for ( ; pSupportedFeatures < pSupportedFeaturesEnd; ++pSupportedFeatures )
277 if ( pSupportedFeatures->nId )
281 OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) );
282 m_pToolbar->InsertItem(
ToolBoxItemId(pSupportedFeatures->nId), OUString(), sCommandURL, pSupportedFeatures->bRepeat ? ToolBoxItemBits::REPEAT : ToolBoxItemBits::NONE );
285 if ( !isArtificialItem( pSupportedFeatures->nId ) )
292 if ( pSupportedFeatures->bItemWindow )
295 if ( FormFeature::MoveAbsolute == pSupportedFeatures->nId )
304 else if (pSupportedFeatures->nId == FormFeature::TotalRecords)
325 OSL_ENSURE(
m_pImageProvider,
"NavigationToolBar::implUpdateImages: no image provider => no images!" );
329 const ToolBox::ImplToolItems::size_type nItemCount =
m_pToolbar->GetItemCount();
332 std::vector<sal_Int16> aFormFeatures;
333 aFormFeatures.reserve( nItemCount );
335 for ( ToolBox::ImplToolItems::size_type
i=0;
i<nItemCount; ++
i )
338 if ( ( ToolBoxItemType::BUTTON ==
m_pToolbar->GetItemType(
i ) ) && !isArtificialItem( sal_uInt16(
nId) ) )
339 aFormFeatures.push_back( sal_uInt16(
nId) );
343 css::uno::Sequence< OUString > aCommandURLs( aFormFeatures.size() );
344 auto aCommandURLsRange = asNonConstRange(aCommandURLs);
346 for (
auto const& formFeature : aFormFeatures)
348 aCommandURLsRange[
i++] = lcl_getCommandURL(formFeature);
355 auto commandImage = aCommandImages.begin();
356 for (sal_Int16 formFeature : aFormFeatures)
385 const sal_uInt16* pGroupIds =
nullptr;
391 static const sal_uInt16 aPositionIds[] = {
394 pGroupIds = aPositionIds;
399 static const sal_uInt16 aNavigationIds[] = {
400 FormFeature::MoveToFirst, FormFeature::MoveToPrevious, FormFeature::MoveToNext, FormFeature::MoveToLast, FormFeature::MoveToInsertRow, 0
402 pGroupIds = aNavigationIds;
407 static const sal_uInt16 aActionIds[] = {
408 FormFeature::SaveRecordChanges, FormFeature::UndoRecordChanges, FormFeature::DeleteRecord, FormFeature::ReloadForm, FormFeature::RefreshCurrentControl, 0
410 pGroupIds = aActionIds;
415 static const sal_uInt16 aFilterSortIds[] = {
416 FormFeature::SortAscending, FormFeature::SortDescending, FormFeature::InteractiveSort, FormFeature::AutoFilter, FormFeature::InteractiveFilter, FormFeature::ToggleApplyFilter, FormFeature::RemoveFilterAndSort, 0
418 pGroupIds = aFilterSortIds;
422 OSL_FAIL(
"NavigationToolBar::ShowFunctionGroup: invalid group id!" );
433 sal_uInt16 nIndicatorItem = 0;
437 case eNavigation : nIndicatorItem = FormFeature::MoveToFirst;
break;
438 case eRecordActions : nIndicatorItem = FormFeature::SaveRecordChanges;
break;
439 case eFilterSort : nIndicatorItem = FormFeature::SortAscending;
break;
441 OSL_FAIL(
"NavigationToolBar::IsFunctionGroupVisible: invalid group id!" );
450 Window::StateChanged(
nType );
454 case StateChangedType::Zoom:
461 case StateChangedType::ControlFont:
466 case StateChangedType::ControlForeground:
470 case StateChangedType::Mirroring:
485 sal_Int32 nToolbarHeight =
m_pToolbar->CalcWindowSizePixel().Height();
488 m_pToolbar->SetPosSizePixel(
Point( 0, ( nMyHeight - nToolbarHeight ) / 2 ),
496 Window::SetControlBackground();
505 Window::SetControlBackground( _rColor );
514 Window::SetTextLineColor( );
521 Window::SetTextLineColor( _rColor );
528 for ( ToolBox::ImplToolItems::size_type item = 0; item <
m_pToolbar->GetItemCount(); ++item )
533 (this->*_handler)( sal_uInt16(nItemId), pItemWindow );
539 for ( ToolBox::ImplToolItems::size_type item = 0; item <
m_pToolbar->GetItemCount(); ++item )
544 (*_handler)( sal_uInt16(nItemId), pItemWindow, _pParam );
589 sItemText = getLabelString( RID_STR_LABEL_RECORD );
593 sItemText = getLabelString( RID_STR_LABEL_OF );
596 case FormFeature::MoveAbsolute:
597 sItemText =
"12345678";
601 case FormFeature::TotalRecords:
602 sItemText =
"123456";
623 , m_pDispatcher( nullptr )
PropertiesInfo aProperties
constexpr tools::Long Height() const
tools::Long AdjustWidth(tools::Long n)
static VclPtr< reference_type > Create(Arg &&... arg)
virtual bool isEnabled(sal_Int16 _nFeatureId) const =0
checks whether a given feature is enabled
virtual void dispatch(sal_Int16 _nFeatureId) const =0
dispatches a feature
virtual void dispatchWithArgument(sal_Int16 _nFeatureId, const char *_pParamName, const css::uno::Any &_rParamValue) const =0
dispatches a feature, with an additional named parameter
virtual void dispose() override
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetControlForeground()
bool IsControlFont() const
virtual void SetSizePixel(const Size &rNewSize)
Size get_preferred_size() const
const Color & GetControlForeground() const
void SetControlBackground()
virtual void EnableRTL(bool bEnable=true)
tools::Long GetTextHeight() const
bool IsControlForeground() const
vcl::Font GetControlFont() const
const Color & GetTextColor() const
bool IsRTLEnabled() const
virtual Size GetSizePixel() const
Size GetOutputSizePixel() const
void SetTextColor(const Color &rColor)
#define DBG_ASSERT(sCon, aError)
#define SAL_N_ELEMENTS(arr)
OUString loadString(TranslateId aResId)
loads the string with the specified resource id from the FormLayer mo file
ListBox is a bit confusing / different from other form components, so here are a few notes:
std::shared_ptr< const DocumentCommandImageProvider > PCommandImageProvider
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
OUString GetLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)