22using com::sun::star::beans::PropertyValue;
34void lcl_ConvertSequenceToValues(
36 AddonStatusbarItem &rItem )
39 bool bAutoSize =
false;
40 bool bOwnerDraw =
false;
41 bool bMandatory =
true;
43 for ( PropertyValue
const & aPropVal : rSequence )
45 if ( aPropVal.Name ==
"URL" )
46 aPropVal.Value >>= rItem.aCommandURL;
47 else if ( aPropVal.Name ==
"Title" )
48 aPropVal.Value >>= rItem.aLabel;
49 else if ( aPropVal.Name ==
"Context" )
50 aPropVal.Value >>= rItem.aContext;
51 else if ( aPropVal.Name ==
"Alignment" )
52 aPropVal.Value >>= sAlignment;
53 else if ( aPropVal.Name ==
"AutoSize" )
54 aPropVal.Value >>= bAutoSize;
55 else if ( aPropVal.Name ==
"OwnerDraw" )
56 aPropVal.Value >>= bOwnerDraw;
57 else if ( aPropVal.Name ==
"Mandatory" )
58 aPropVal.Value >>= bMandatory;
59 else if ( aPropVal.Name ==
"Width" )
62 aPropVal.Value >>= aWidth;
63 rItem.nWidth = sal_uInt16( aWidth );
69 nItemBits |= StatusBarItemBits::AutoSize;
71 nItemBits |= StatusBarItemBits::UserDraw;
73 nItemBits |= StatusBarItemBits::Mandatory;
74 if ( sAlignment ==
"center" )
75 nItemBits |= StatusBarItemBits::Center;
76 else if ( sAlignment ==
"right" )
77 nItemBits |= StatusBarItemBits::Right;
80 nItemBits |= StatusBarItemBits::Left;
81 rItem.nItemBits = nItemBits;
84void lcl_CreateStatusbarItem(
StatusBar* pStatusbar,
87 const AddonStatusbarItem& rAddonItem )
99 AddonStatusbarItemData *pUserData =
new AddonStatusbarItemData;
100 pUserData->aLabel = rAddonItem.aLabel;
104bool lcl_MergeItems(
StatusBar* pStatusbar,
106 sal_uInt16 nModIndex,
110 const sal_uInt16 nSize( rAddonItems.size() );
111 for ( sal_Int32 i = 0;
i < nSize;
i++ )
113 const AddonStatusbarItem& rItem = rAddonItems[
i];
117 sal_uInt16 nInsPos =
nPos + nModIndex +
i;
121 lcl_CreateStatusbarItem( pStatusbar, nInsPos, rItemId, rItem );
128bool lcl_ReplaceItem(
StatusBar* pStatusbar,
134 return lcl_MergeItems( pStatusbar, nPos, 0, rItemId, rAddonToolbarItems );
137bool lcl_RemoveItems(
StatusBar* pStatusbar,
139 std::u16string_view rMergeCommandParameter )
144 for ( sal_Int32 i = 0;
i <
nCount;
i++ )
146 if ( nPos < pStatusbar->GetItemCount() )
156 std::u16string_view rContext )
158 return rContext.empty();
165 for (
auto const & i : rSequence )
168 lcl_ConvertSequenceToValues( i, aStatusBarItem );
169 rContainer.push_back( aStatusBarItem );
177 std::u16string_view rReferencePoint )
182 if ( rReferencePoint == rCmd )
193 std::u16string_view rMergeCommand,
194 std::u16string_view rMergeCommandParameter,
198 return lcl_MergeItems( pStatusbar,
nPos, 1, rItemId, rItems );
200 return lcl_MergeItems( pStatusbar,
nPos, 0, rItemId, rItems );
202 return lcl_ReplaceItem( pStatusbar,
nPos, rItemId, rItems );
204 return lcl_RemoveItems( pStatusbar,
nPos, rMergeCommandParameter );
212 std::u16string_view rMergeCommand,
213 std::u16string_view rMergeFallback,
217 if (( rMergeFallback ==
u"Ignore" ) ||
226 if ( rMergeFallback ==
u"AddFirst" )
227 return lcl_MergeItems( pStatusbar, 0, 0, rItemId, rItems );
228 else if ( rMergeFallback ==
u"AddLast" )
void SetAccessibleName(sal_uInt16 nItemId, const OUString &rName)
void SetItemCommand(sal_uInt16 nItemId, const OUString &rCommand)
void InsertItem(sal_uInt16 nItemId, sal_uLong nWidth, StatusBarItemBits nBits=StatusBarItemBits::Center|StatusBarItemBits::In, tools::Long nOffset=STATUSBAR_OFFSET, sal_uInt16 nPos=STATUSBAR_APPEND)
void SetQuickHelpText(sal_uInt16 nItemId, const OUString &rText)
sal_uInt16 GetItemId(sal_uInt16 nPos) const
sal_uInt16 GetItemCount() const
void RemoveItem(sal_uInt16 nItemId)
OUString GetItemCommand(sal_uInt16 nItemId)
void SetItemData(sal_uInt16 nItemId, void *pNewData)
bool ConvertSeqSeqToVector(const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > &rSequence, AddonStatusbarItemContainer &rContainer)
bool ProcessMergeOperation(StatusBar *pStatusbar, sal_uInt16 nPos, sal_uInt16 &rItemId, std::u16string_view rMergeCommand, std::u16string_view rMergeCommandParameter, const AddonStatusbarItemContainer &rItems)
bool IsCorrectContext(std::u16string_view aContext)
bool ProcessMergeFallback(StatusBar *pStatusbar, sal_uInt16 &rItemId, std::u16string_view rMergeCommand, std::u16string_view rMergeFallback, const AddonStatusbarItemContainer &rItems)
sal_uInt16 FindReferencePos(StatusBar *pStatusbar, std::u16string_view rReferencePoint)
const char16_t MERGECOMMAND_REPLACE[]
const char16_t MERGECOMMAND_ADDAFTER[]
::std::vector< AddonStatusbarItem > AddonStatusbarItemContainer
const char16_t MERGECOMMAND_REMOVE[]
const char16_t MERGECOMMAND_ADDBEFORE[]
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
#define STATUSBAR_ITEM_NOTFOUND