diff options
Diffstat (limited to 'sw/source/uibase/utlui/uitool.cxx')
-rw-r--r-- | sw/source/uibase/utlui/uitool.cxx | 201 |
1 files changed, 117 insertions, 84 deletions
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index b971dc95bb2c..72c67ce7ab1b 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -36,6 +36,7 @@ #include <editeng/lrspitem.hxx> #include <svl/style.hxx> #include <unotools/localedatawrapper.hxx> +#include <com/sun/star/awt/XPopupMenu.hpp> #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XFrame.hpp> @@ -43,6 +44,8 @@ #include <com/sun/star/util/XURLTransformer.hpp> #include <comphelper/processfactory.hxx> #include <sfx2/viewfrm.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/docfilt.hxx> #include <fmtornt.hxx> #include <tabcol.hxx> #include <fmtfsize.hxx> @@ -61,12 +64,12 @@ #include <cmdid.h> #include <doc.hxx> -#include <docary.hxx> #include <charfmt.hxx> #include <SwStyleNameMapper.hxx> #include <strings.hrc> -// 50 cm 28350 +#include <docmodel/color/ComplexColor.hxx> +// 50 cm 28350 #define MAXHEIGHT 28350 #define MAXWIDTH 28350 @@ -79,11 +82,10 @@ using namespace ::com::sun::star; void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh) { std::shared_ptr<SvxBoxInfoItem> aBoxInfo(std::make_shared<SvxBoxInfoItem>(SID_ATTR_BORDER_INNER)); - const SfxPoolItem *pBoxInfo; - if ( SfxItemState::SET == rSet.GetItemState( SID_ATTR_BORDER_INNER, true, &pBoxInfo)) + if ( const SvxBoxInfoItem *pBoxInfo = rSet.GetItemIfSet( SID_ATTR_BORDER_INNER )) { - aBoxInfo.reset(static_cast<SvxBoxInfoItem*>(pBoxInfo->Clone())); + aBoxInfo.reset(pBoxInfo->Clone()); } // Table variant: If more than one table cells are selected @@ -106,10 +108,9 @@ void ConvertAttrCharToGen(SfxItemSet& rSet, bool bIsPara) // Background / highlight { // Always use the visible background - const SfxPoolItem *pTmpBrush; - if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_HIGHLIGHT, true, &pTmpBrush ) ) + if( const SvxBrushItem *pTmpBrush = rSet.GetItemIfSet( RES_CHRATR_HIGHLIGHT ) ) { - SvxBrushItem aTmpBrush( pTmpBrush->StaticWhichCast(RES_CHRATR_HIGHLIGHT) ); + SvxBrushItem aTmpBrush( *pTmpBrush ); if( aTmpBrush.GetColor() != COL_TRANSPARENT ) { aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); @@ -128,11 +129,14 @@ void ConvertAttrCharToGen(SfxItemSet& rSet, bool bIsPara) SfxGrabBagItem aGrabBag(RES_PARATR_GRABBAG); aGrabBag.GetGrabBag()["DialogUseCharAttr"] <<= true; // Store initial ranges to allow restoring later - const sal_uInt16* pRanges = rSet.GetRanges(); - const sal_uInt16* pEnd = pRanges; - while (*pEnd) - ++pEnd; - const uno::Sequence<sal_uInt16> aOrigRanges(pRanges, pEnd - pRanges + 1); + uno::Sequence<sal_uInt16> aOrigRanges(rSet.GetRanges().size() * 2 + 1); + int i = 0; + for (const auto& rPair : rSet.GetRanges()) + { + aOrigRanges.getArray()[i++] = rPair.first; + aOrigRanges.getArray()[i++] = rPair.second; + } + aOrigRanges.getArray()[i++] = 0; aGrabBag.GetGrabBag()["OrigItemSetRanges"] <<= aOrigRanges; rSet.MergeRange(RES_PARATR_GRABBAG, RES_PARATR_GRABBAG); rSet.Put(aGrabBag); @@ -141,17 +145,16 @@ void ConvertAttrCharToGen(SfxItemSet& rSet, bool bIsPara) void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet, bool bIsPara) { // Background / highlighting - const SfxPoolItem *pTmpItem; - if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, false, &pTmpItem ) ) + if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, false ) ) { // Highlight is an MS specific thing, so remove it at the first time when LO modifies // this part of the imported document. rSet.Put( SvxBrushItem(RES_CHRATR_HIGHLIGHT) ); // Remove shading marker - if (SfxItemState::SET == rOrigSet.GetItemState(RES_CHRATR_GRABBAG, false, &pTmpItem)) + if (const SfxGrabBagItem* pGrabBagItem = rOrigSet.GetItemIfSet(RES_CHRATR_GRABBAG, false)) { - SfxGrabBagItem aGrabBag(pTmpItem->StaticWhichCast(RES_CHRATR_GRABBAG)); + SfxGrabBagItem aGrabBag(*pGrabBagItem); std::map<OUString, css::uno::Any>& rMap = aGrabBag.GetGrabBag(); auto aIterator = rMap.find("CharShadingMarker"); if( aIterator != rMap.end() ) @@ -167,43 +170,49 @@ void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet, bool bIs rSet.ClearItem( RES_BACKGROUND ); - if (SfxItemState::SET == rOrigSet.GetItemState(RES_PARATR_GRABBAG, false, &pTmpItem)) + if (const SfxGrabBagItem* pGrabBagItem = rOrigSet.GetItemIfSet(RES_PARATR_GRABBAG, false)) { - SfxGrabBagItem aGrabBag(pTmpItem->StaticWhichCast(RES_PARATR_GRABBAG)); + SfxGrabBagItem aGrabBag(*pGrabBagItem); std::map<OUString, css::uno::Any>& rMap = aGrabBag.GetGrabBag(); auto aIterator = rMap.find("OrigItemSetRanges"); if (aIterator != rMap.end()) { - if (uno::Sequence<sal_uInt16> aOrigRanges; (aIterator->second >>= aOrigRanges) - && aOrigRanges.getLength() % 2 == 1 - && *(std::cend(aOrigRanges) - 1) == 0) - rSet.SetRanges(aOrigRanges.getConstArray()); + uno::Sequence<sal_uInt16> aOrigRanges; + if ( aIterator->second >>= aOrigRanges ) + { + assert(aOrigRanges.getLength() % 2 == 1); + int numPairs = (aOrigRanges.getLength()-1)/2; + std::unique_ptr<WhichPair[]> xPairs(new WhichPair[numPairs]); + for(int i=0; i<aOrigRanges.getLength()-1; i += 2) + { + xPairs[i/2] = { aOrigRanges[i], aOrigRanges[i+1] }; + } + rSet.SetRanges(WhichRangesContainer(std::move(xPairs), numPairs)); + } } } assert(SfxItemState::SET != rSet.GetItemState(RES_PARATR_GRABBAG, false)); } -void ApplyCharBackground(const Color& rBackgroundColor, SwWrtShell& rShell) +void ApplyCharBackground(Color const& rBackgroundColor, model::ComplexColor const& rComplexColor, SwWrtShell& rShell) { rShell.StartUndo(SwUndoId::INSATTR); - SfxItemSet aCoreSet(rShell.GetView().GetPool(), svl::Items< - RES_CHRATR_GRABBAG, RES_CHRATR_GRABBAG>{}); + SfxItemSetFixed<RES_CHRATR_GRABBAG, RES_CHRATR_GRABBAG> aCoreSet(rShell.GetView().GetPool()); rShell.GetCurAttr(aCoreSet); // Set char background - rShell.SetAttrItem(SvxBrushItem(rBackgroundColor, RES_CHRATR_BACKGROUND)); + rShell.SetAttrItem(SvxBrushItem(rBackgroundColor, rComplexColor, RES_CHRATR_BACKGROUND)); // Highlight is an MS specific thing, so remove it at the first time when LO modifies // this part of the imported document. rShell.SetAttrItem(SvxBrushItem(RES_CHRATR_HIGHLIGHT)); // Remove shading marker - const SfxPoolItem *pTmpItem; - if (SfxItemState::SET == aCoreSet.GetItemState(RES_CHRATR_GRABBAG, false, &pTmpItem)) + if (const SfxGrabBagItem* pGrabBagItem = aCoreSet.GetItemIfSet(RES_CHRATR_GRABBAG, false)) { - SfxGrabBagItem aGrabBag(pTmpItem->StaticWhichCast(RES_CHRATR_GRABBAG)); + SfxGrabBagItem aGrabBag(*pGrabBagItem); std::map<OUString, css::uno::Any>& rMap = aGrabBag.GetGrabBag(); auto aIterator = rMap.find("CharShadingMarker"); if (aIterator != rMap.end()) @@ -273,16 +282,18 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) // before SetFormatAttr() in case it contains RES_BACKGROUND_FULL_SIZE // itself, as it does when called from SwXPageStyle - SfxPoolItem const* pItem(nullptr); - if (SfxItemState::SET == rSet.GetItemState(SID_ATTR_CHAR_GRABBAG, true, &pItem)) + if (const SfxGrabBagItem* pGrabBag = rSet.GetItemIfSet(SID_ATTR_CHAR_GRABBAG)) { - SfxGrabBagItem const*const pGrabBag(static_cast<SfxGrabBagItem const*>(pItem)); bool bValue; - if (pGrabBag->GetGrabBag().find("BackgroundFullSize")->second >>= bValue) + const auto pGrabBagInner = pGrabBag->GetGrabBag(); + const auto iter = pGrabBagInner.find("BackgroundFullSize"); + assert(iter != pGrabBagInner.end()); + if (iter->second >>= bValue) { rMaster.SetFormatAttr(SfxBoolItem(RES_BACKGROUND_FULL_SIZE, bValue)); } - if (pGrabBag->GetGrabBag().find("RtlGutter")->second >>= bValue) + auto it = pGrabBagInner.find("RtlGutter"); + if (it != pGrabBagInner.end() && (it->second >>= bValue)) { rMaster.SetFormatAttr(SfxBoolItem(RES_RTL_GUTTER, bValue)); } @@ -313,10 +324,10 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) rMaster.SetFormatAttr(aSize); } // Evaluate header attributes - if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_PAGE_HEADERSET, - false, &pItem ) ) + if( const SvxSetItem* pHeaderSetItem = rSet.GetItemIfSet( SID_ATTR_PAGE_HEADERSET, + false ) ) { - const SfxItemSet& rHeaderSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet(); + const SfxItemSet& rHeaderSet = pHeaderSetItem->GetItemSet(); const SfxBoolItem& rHeaderOn = rHeaderSet.Get(SID_ATTR_PAGE_ON); if(rHeaderOn.GetValue()) @@ -349,10 +360,10 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) } // Evaluate footer attributes - if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_PAGE_FOOTERSET, - false, &pItem ) ) + if( const SvxSetItem* pFooterSetItem = rSet.GetItemIfSet( SID_ATTR_PAGE_FOOTERSET, + false ) ) { - const SfxItemSet& rFooterSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet(); + const SfxItemSet& rFooterSet = pFooterSetItem->GetItemSet(); const SfxBoolItem& rFooterOn = rFooterSet.Get(SID_ATTR_PAGE_ON); if(rFooterOn.GetValue()) @@ -381,6 +392,7 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) if(rMaster.GetFooter().IsActive()) { rMaster.SetFormatAttr(SwFormatFooter(false)); + // why reset this? but not doing it causes testTdf112694 to fail rPageDesc.ChgFooterShare(false); } } @@ -388,25 +400,26 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) // Footnotes - if( SfxItemState::SET == rSet.GetItemState( FN_PARAM_FTN_INFO, - false, &pItem ) ) - rPageDesc.SetFootnoteInfo( static_cast<const SwPageFootnoteInfoItem*>(pItem)->GetPageFootnoteInfo() ); + if( const SwPageFootnoteInfoItem* pFootnoteItem = rSet.GetItemIfSet( FN_PARAM_FTN_INFO, + false ) ) + rPageDesc.SetFootnoteInfo( pFootnoteItem->GetPageFootnoteInfo() ); // Columns // Register compliant - if(SfxItemState::SET != rSet.GetItemState( - SID_SWREGISTER_MODE, false, &pItem)) + const SfxBoolItem* pRegisterModeItem = rSet.GetItemIfSet( + SID_SWREGISTER_MODE, false); + if(!pRegisterModeItem) return; - bool bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue(); + bool bSet = pRegisterModeItem->GetValue(); if(!bSet) rPageDesc.SetRegisterFormatColl(nullptr); - else if(SfxItemState::SET == rSet.GetItemState( - SID_SWREGISTER_COLLECTION, false, &pItem)) + else if(const SfxStringItem* pCollectionItem = rSet.GetItemIfSet( + SID_SWREGISTER_COLLECTION, false)) { - const OUString& rColl = static_cast<const SfxStringItem*>(pItem)->GetValue(); + const OUString& rColl = pCollectionItem->GetValue(); SwDoc& rDoc = *rMaster.GetDoc(); SwTextFormatColl* pColl = rDoc.FindTextFormatCollByName( rColl ); if( !pColl ) @@ -425,6 +438,27 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) } } +namespace +{ +bool IsOwnFormat(const SwDoc& rDoc) +{ + const SwDocShell* pDocShell = rDoc.GetDocShell(); + SfxMedium* pMedium = pDocShell->GetMedium(); + if (!pMedium) + { + return false; + } + + std::shared_ptr<const SfxFilter> pFilter = pMedium->GetFilter(); + if (!pFilter) + { + return false; + } + + return pFilter->IsOwnFormat(); +} +} + void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) { const SwFrameFormat& rMaster = rPageDesc.GetMaster(); @@ -449,11 +483,10 @@ void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) rSet.Put(rMaster.GetAttrSet()); std::shared_ptr<SvxBoxInfoItem> aBoxInfo(std::make_shared<SvxBoxInfoItem>(SID_ATTR_BORDER_INNER)); - const SfxPoolItem *pBoxInfo; - if ( SfxItemState::SET == rSet.GetItemState( SID_ATTR_BORDER_INNER, true, &pBoxInfo) ) + if ( const SvxBoxInfoItem *pBoxInfo = rSet.GetItemIfSet( SID_ATTR_BORDER_INNER ) ) { - aBoxInfo.reset(static_cast<SvxBoxInfoItem*>(pBoxInfo->Clone())); + aBoxInfo.reset(pBoxInfo->Clone()); } aBoxInfo->SetTable( false ); @@ -480,8 +513,7 @@ void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) OSL_ENSURE(pHeaderFormat != nullptr, "no header format"); // HeaderInfo, margins, background, border - SfxItemSet aHeaderSet(*rSet.GetPool(), - svl::Items<RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 + SfxItemSetFixed<RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 // FillAttribute support XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 @@ -489,7 +521,7 @@ void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023 SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051 SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060 - SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST>{}); + SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST> aHeaderSet(*rSet.GetPool()); // set correct parent to get the XFILL_NONE FillStyle as needed aHeaderSet.SetParent(&rMaster.GetDoc()->GetDfltFrameFormat()->GetAttrSet()); @@ -530,8 +562,7 @@ void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) OSL_ENSURE(pFooterFormat != nullptr, "no footer format"); // FooterInfo, margins, background, border - SfxItemSet aFooterSet(*rSet.GetPool(), - svl::Items<RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 + SfxItemSetFixed<RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 // FillAttribute support XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 @@ -539,7 +570,7 @@ void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023 SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051 SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060 - SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST>{}); + SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST> aFooterSet(*rSet.GetPool()); // set correct parent to get the XFILL_NONE FillStyle as needed aFooterSet.SetParent(&rMaster.GetDoc()->GetDfltFrameFormat()->GetAttrSet()); @@ -586,10 +617,9 @@ void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, pCol->GetName())); std::optional<SfxGrabBagItem> oGrabBag; - SfxPoolItem const* pItem(nullptr); - if (SfxItemState::SET == rSet.GetItemState(SID_ATTR_CHAR_GRABBAG, true, &pItem)) + if (SfxGrabBagItem const* pItem = rSet.GetItemIfSet(SID_ATTR_CHAR_GRABBAG)) { - oGrabBag.emplace(*static_cast<SfxGrabBagItem const*>(pItem)); + oGrabBag.emplace(*pItem); } else { @@ -597,8 +627,13 @@ void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) } oGrabBag->GetGrabBag()["BackgroundFullSize"] <<= rMaster.GetAttrSet().GetItem<SfxBoolItem>(RES_BACKGROUND_FULL_SIZE)->GetValue(); - oGrabBag->GetGrabBag()["RtlGutter"] <<= - rMaster.GetAttrSet().GetItem<SfxBoolItem>(RES_RTL_GUTTER)->GetValue(); + + if (IsOwnFormat(*rMaster.GetDoc())) + { + oGrabBag->GetGrabBag()["RtlGutter"] + <<= rMaster.GetAttrSet().GetItem<SfxBoolItem>(RES_RTL_GUTTER)->GetValue(); + } + rSet.Put(*oGrabBag); } @@ -649,9 +684,9 @@ void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet ) assert(false); // unexpected break; } - if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, false, &pItem )) + if( const SvxPageModelItem* pModelItem = rSet.GetItemIfSet( SID_ATTR_PARA_MODEL, false )) { - const OUString& rDescName = static_cast<const SvxPageModelItem*>(pItem)->GetValue(); + const OUString& rDescName = pModelItem->GetValue(); if( !rDescName.isEmpty() ) // No name -> disable PageDesc! { // Delete only, if PageDesc will be enabled! @@ -666,11 +701,11 @@ void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet ) } else { - SfxItemSet aCoreSet(rShell.GetView().GetPool(), svl::Items<RES_PAGEDESC, RES_PAGEDESC>{} ); + SfxItemSetFixed<RES_PAGEDESC, RES_PAGEDESC> aCoreSet(rShell.GetView().GetPool()); rShell.GetCurAttr( aCoreSet ); - if(SfxItemState::SET == aCoreSet.GetItemState( RES_PAGEDESC, true, &pItem ) ) + if(const SwFormatPageDesc* pPageDescItem = aCoreSet.GetItemIfSet( RES_PAGEDESC ) ) { - auto pPageDesc = pItem->StaticWhichCast(RES_PAGEDESC).GetPageDesc(); + const SwPageDesc* pPageDesc = pPageDescItem->GetPageDesc(); if( pPageDesc ) { aPgDesc.RegisterToPageDesc( *const_cast<SwPageDesc*>(pPageDesc) ); @@ -685,19 +720,18 @@ void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet ) // Inquire if in the set is a Sfx-PageDesc combination present and return it. void SwToSfxPageDescAttr( SfxItemSet& rCoreSet ) { - const SfxPoolItem* pItem = nullptr; + const SwFormatPageDesc* pPageDescItem = nullptr; OUString aName; ::std::optional<sal_uInt16> oNumOffset; bool bPut = true; - switch( rCoreSet.GetItemState( RES_PAGEDESC, true, &pItem ) ) + switch( rCoreSet.GetItemState( RES_PAGEDESC, true, &pPageDescItem ) ) { case SfxItemState::SET: { - auto rPageDescItem = pItem->StaticWhichCast(RES_PAGEDESC); - if( rPageDescItem.GetPageDesc() ) + if( pPageDescItem->GetPageDesc() ) { - aName = rPageDescItem.GetPageDesc()->GetName(); - oNumOffset = rPageDescItem.GetNumOffset(); + aName = pPageDescItem->GetPageDesc()->GetName(); + oNumOffset = pPageDescItem->GetNumOffset(); } rCoreSet.ClearItem( RES_PAGEDESC ); // Page number @@ -770,10 +804,8 @@ void FillCharStyleListBox(weld::ComboBox& rToFill, SwDocShell* pDocSh, bool bSor pBase = pPool->Next(); } // non-pool styles - const SwCharFormats* pFormats = pDoc->GetCharFormats(); - for(size_t i = 0; i < pFormats->size(); ++i) + for(const auto pFormat : *pDoc->GetCharFormats()) { - const SwCharFormat* pFormat = (*pFormats)[i]; if(pFormat->IsDefault()) continue; const OUString& rName = pFormat->GetName(); @@ -850,17 +882,18 @@ void SetApplyCharUnit(bool bApplyChar, bool bWeb) SW_MOD()->ApplyUserCharUnit(bApplyChar, bWeb); } -bool ExecuteMenuCommand( PopupMenu const & rMenu, SfxViewFrame const & rViewFrame, sal_uInt16 nId ) +bool ExecuteMenuCommand(const css::uno::Reference<css::awt::XPopupMenu>& rMenu, const SfxViewFrame& rViewFrame, sal_uInt16 nId) { bool bRet = false; - const sal_uInt16 nItemCount = rMenu.GetItemCount(); + const sal_uInt16 nItemCount = rMenu->getItemCount(); OUString sCommand; - for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem) + for (sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem) { - PopupMenu* pPopup = rMenu.GetPopupMenu( rMenu.GetItemId( nItem ) ); - if(pPopup) + sal_Int16 nItemId = rMenu->getItemId(nItem); + css::uno::Reference<css::awt::XPopupMenu> xPopup = rMenu->getPopupMenu(nItemId); + if (xPopup.is()) { - sCommand = pPopup->GetItemCommand(nId); + sCommand = xPopup->getCommand(nId); if(!sCommand.isEmpty()) break; } |