diff options
Diffstat (limited to 'cui/source/dialogs/srchxtra.cxx')
-rw-r--r-- | cui/source/dialogs/srchxtra.cxx | 96 |
1 files changed, 45 insertions, 51 deletions
diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx index 513501700970..f8080f537775 100644 --- a/cui/source/dialogs/srchxtra.cxx +++ b/cui/source/dialogs/srchxtra.cxx @@ -49,10 +49,9 @@ SvxSearchFormatDialog::SvxSearchFormatDialog(weld::Window* pParent, const SfxIte AddTabPage("background", SvxBkgTabPage::Create, nullptr); // remove asian tabpages if necessary - SvtCJKOptions aCJKOptions; - if ( !aCJKOptions.IsDoubleLinesEnabled() ) + if ( !SvtCJKOptions::IsDoubleLinesEnabled() ) RemoveTabPage("asianlayout"); - if ( !aCJKOptions.IsAsianTypographyEnabled() ) + if ( !SvtCJKOptions::IsAsianTypographyEnabled() ) RemoveTabPage("labelTP_PARA_ASIAN"); } @@ -60,14 +59,12 @@ SvxSearchFormatDialog::~SvxSearchFormatDialog() { } -void SvxSearchFormatDialog::PageCreated(const OString& rId, SfxTabPage& rPage) +void SvxSearchFormatDialog::PageCreated(const OUString& rId, SfxTabPage& rPage) { if (rId == "font") { const FontList* pApm_pFontList = nullptr; - SfxObjectShell* pSh = SfxObjectShell::Current(); - - if ( pSh ) + if (SfxObjectShell* pSh = SfxObjectShell::Current()) { const SvxFontListItem* pFLItem = static_cast<const SvxFontListItem*>( pSh->GetItem( SID_ATTR_CHAR_FONTLIST )); @@ -105,7 +102,7 @@ void SvxSearchFormatDialog::PageCreated(const OString& rId, SfxTabPage& rPage) } SvxSearchAttributeDialog::SvxSearchAttributeDialog(weld::Window* pParent, - SearchAttrItemList& rLst, const sal_uInt16* pWhRanges) + SearchAttrItemList& rLst, const WhichRangesContainer& pWhRanges) : GenericDialogController(pParent, "cui/ui/searchattrdialog.ui", "SearchAttrDialog") , rList(rLst) , m_xAttrLB(m_xBuilder->weld_tree_view("treeview")) @@ -120,42 +117,44 @@ SvxSearchAttributeDialog::SvxSearchAttributeDialog(weld::Window* pParent, SfxObjectShell* pSh = SfxObjectShell::Current(); DBG_ASSERT( pSh, "No DocShell" ); - - SfxItemPool& rPool = pSh->GetPool(); - SfxItemSet aSet( rPool, pWhRanges ); - SfxWhichIter aIter( aSet ); - sal_uInt16 nWhich = aIter.FirstWhich(); - - while ( nWhich ) + if (pSh) { - sal_uInt16 nSlot = rPool.GetSlotId( nWhich ); - if ( nSlot >= SID_SVX_START ) + SfxItemPool& rPool = pSh->GetPool(); + SfxItemSet aSet( rPool, pWhRanges ); + SfxWhichIter aIter( aSet ); + sal_uInt16 nWhich = aIter.FirstWhich(); + + while ( nWhich ) { - bool bChecked = false, bFound = false; - for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i ) + sal_uInt16 nSlot = rPool.GetSlotId( nWhich ); + if ( nSlot >= SID_SVX_START ) { - if ( nSlot == rList[i].nSlot ) + bool bChecked = false, bFound = false; + for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i ) { - bFound = true; - if ( IsInvalidItem( rList[i].pItem ) ) - bChecked = true; + if ( nSlot == rList[i].nSlot ) + { + bFound = true; + if ( IsInvalidItem( rList[i].aItemPtr.getItem() ) ) + bChecked = true; + } } - } - // item resources are in svx - sal_uInt32 nId = SvxAttrNameTable::FindIndex(nSlot); - if (RESARRAY_INDEX_NOTFOUND != nId) - { - m_xAttrLB->append(); - const int nRow = m_xAttrLB->n_children() - 1; - m_xAttrLB->set_toggle(nRow, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE); - m_xAttrLB->set_text(nRow, SvxAttrNameTable::GetString(nId), 0); - m_xAttrLB->set_id(nRow, OUString::number(nSlot)); + // item resources are in svx + sal_uInt32 nId = SvxAttrNameTable::FindIndex(nSlot); + if (RESARRAY_INDEX_NOTFOUND != nId) + { + m_xAttrLB->append(); + const int nRow = m_xAttrLB->n_children() - 1; + m_xAttrLB->set_toggle(nRow, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xAttrLB->set_text(nRow, SvxAttrNameTable::GetString(nId), 0); + m_xAttrLB->set_id(nRow, OUString::number(nSlot)); + } + else + SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) ); } - else - SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) ); + nWhich = aIter.NextWhich(); } - nWhich = aIter.NextWhich(); } m_xAttrLB->make_sorted(); @@ -168,28 +167,24 @@ SvxSearchAttributeDialog::~SvxSearchAttributeDialog() IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, weld::Button&, void) { - SearchAttrItem aInvalidItem; - aInvalidItem.pItem = INVALID_POOL_ITEM; + DBG_ASSERT( SfxObjectShell::Current(), "No DocShell" ); + SfxItemPool& rPool(SfxObjectShell::Current()->GetPool()); for (int i = 0, nCount = m_xAttrLB->n_children(); i < nCount; ++i) { - sal_uInt16 nSlot = m_xAttrLB->get_id(i).toUInt32(); - bool bChecked = m_xAttrLB->get_toggle(i) == TRISTATE_TRUE; + const sal_uInt16 nSlot(m_xAttrLB->get_id(i).toUInt32()); + const bool bChecked(TRISTATE_TRUE == m_xAttrLB->get_toggle(i)); sal_uInt16 j; for ( j = rList.Count(); j; ) { - SearchAttrItem& rItem = rList[ --j ]; + SearchAttrInfo& rItem = rList[ --j ]; if( rItem.nSlot == nSlot ) { if( bChecked ) - { - if( !IsInvalidItem( rItem.pItem ) ) - delete rItem.pItem; - rItem.pItem = INVALID_POOL_ITEM; - } - else if( IsInvalidItem( rItem.pItem ) ) - rItem.pItem = nullptr; + rItem.aItemPtr = SfxPoolItemHolder(rPool, INVALID_POOL_ITEM); + else if( IsInvalidItem( rItem.aItemPtr.getItem() ) ) + rItem.aItemPtr = SfxPoolItemHolder(); j = 1; break; } @@ -197,14 +192,13 @@ IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, weld::Button&, void) if ( !j && bChecked ) { - aInvalidItem.nSlot = nSlot; - rList.Insert( aInvalidItem ); + rList.Insert( { nSlot, SfxPoolItemHolder(rPool, INVALID_POOL_ITEM) }); } } // remove invalid items (pItem == NULL) for ( sal_uInt16 n = rList.Count(); n; ) - if ( !rList[ --n ].pItem ) + if ( !rList[ --n ].aItemPtr.getItem() ) rList.Remove( n ); m_xDialog->response(RET_OK); |