diff options
Diffstat (limited to 'sd/source/ui/view/drtxtob1.cxx')
-rw-r--r-- | sd/source/ui/view/drtxtob1.cxx | 128 |
1 files changed, 56 insertions, 72 deletions
diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index 09f37d6a2872..44a63a3634d1 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -66,53 +66,19 @@ #include <memory> -namespace -{ - void lcl_convertStringArguments(sal_uInt16 nSlot, const std::unique_ptr<SfxItemSet>& pArgs) - { - Color aColor; - OUString sColor; - const SfxPoolItem* pColorStringItem = nullptr; - - if (SfxItemState::SET != pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem)) - return; - - sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); - - if (sColor == "transparent") - aColor = COL_TRANSPARENT; - else - aColor = Color(ColorTransparency, sColor.toInt32(16)); - - switch (nSlot) - { - case SID_ATTR_CHAR_COLOR: - { - SvxColorItem aColorItem(aColor, EE_CHAR_COLOR); - pArgs->Put(aColorItem); - break; - } - - case SID_ATTR_CHAR_BACK_COLOR: - { - SvxColorItem pBackgroundItem(aColor, EE_CHAR_BKGCOLOR); - pArgs->Put(pBackgroundItem); - break; - } - } - } -} - namespace sd { /** * Process SfxRequests */ +void TextObjectBar::Execute(SfxRequest& rReq) +{ + ExecuteImpl(mpViewShell, mpView, rReq, this); +} -void TextObjectBar::Execute( SfxRequest &rReq ) +void TextObjectBar::ExecuteImpl(ViewShell* mpViewShell, ::sd::View* mpView, SfxRequest& rReq, SfxShell* pTextObjectBar) { const SfxItemSet* pArgs = rReq.GetArgs(); - const SfxPoolItem* pPoolItem = nullptr; sal_uInt16 nSlot = rReq.GetSlot(); OutlinerView* pOLV = mpView->GetTextEditOutlinerView(); @@ -198,8 +164,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) pNewItem->SetLeftValue( static_cast<sal_uInt16>(nLeft) ); SfxItemSet aNewAttrs( aAttr ); - aNewAttrs.Put( *pNewItem ); - pNewItem.reset(); + aNewAttrs.Put( std::move(pNewItem) ); pOLV->GetOutliner()->SetParaAttribs( nPara, aNewAttrs ); } } @@ -208,7 +173,8 @@ void TextObjectBar::Execute( SfxRequest &rReq ) } rReq.Done(); - Invalidate(); + if(pTextObjectBar) + pTextObjectBar->Invalidate(); // to refresh preview (in outline mode), slot has to be invalidated: mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true ); @@ -265,8 +231,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) pNewItem->SetLower( static_cast<sal_uInt16>(nLower) ); SfxItemSet aNewAttrs( aAttr ); - aNewAttrs.Put( *pNewItem ); - pNewItem.reset(); + aNewAttrs.Put( std::move(pNewItem) ); pOLV->GetOutliner()->SetParaAttribs( nPara, aNewAttrs ); } } @@ -307,15 +272,15 @@ void TextObjectBar::Execute( SfxRequest &rReq ) } pNewItem->SetLower( static_cast<sal_uInt16>(nLower) ); - aNewAttrs.Put( *pNewItem ); - pNewItem.reset(); + aNewAttrs.Put( std::move(pNewItem) ); mpView->SetAttributes( aNewAttrs ); } } rReq.Done(); - Invalidate(); + if (pTextObjectBar) + pTextObjectBar->Invalidate(); // to refresh preview (in outline mode), slot has to be invalidated: mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true ); mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_PARA_ULSPACE, true ); @@ -329,7 +294,8 @@ void TextObjectBar::Execute( SfxRequest &rReq ) pOLV->AdjustDepth( -1 ); // Ensure bold/italic etc. icon state updates - Invalidate(); + if (pTextObjectBar) + pTextObjectBar->Invalidate(); // trigger preview refresh mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true ); } @@ -344,7 +310,8 @@ void TextObjectBar::Execute( SfxRequest &rReq ) pOLV->AdjustDepth( 1 ); // Ensure bold/italic etc. icon state updates - Invalidate(); + if (pTextObjectBar) + pTextObjectBar->Invalidate(); // trigger preview refresh mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true ); } @@ -355,21 +322,22 @@ void TextObjectBar::Execute( SfxRequest &rReq ) case SID_ATTR_PARA_LRSPACE: { SvxLRSpaceItem aLRSpace = static_cast<const SvxLRSpaceItem&>(pArgs->Get( - GetPool().GetWhich(SID_ATTR_PARA_LRSPACE))); + SID_ATTR_PARA_LRSPACE)); - SfxItemSet aEditAttr( GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} ); + SfxItemSetFixed<EE_PARA_LRSPACE, EE_PARA_LRSPACE> aEditAttr(mpView->GetDoc().GetPool()); aLRSpace.SetWhich( EE_PARA_LRSPACE ); aEditAttr.Put( aLRSpace ); mpView->SetAttributes( aEditAttr ); - Invalidate(SID_ATTR_PARA_LRSPACE); + if (pTextObjectBar) + pTextObjectBar->Invalidate(SID_ATTR_PARA_LRSPACE); } break; case SID_HANGING_INDENT: { - SfxItemSet aLRSpaceSet( GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} ); + SfxItemSetFixed<EE_PARA_LRSPACE, EE_PARA_LRSPACE> aLRSpaceSet(mpView->GetDoc().GetPool()); mpView->GetAttributes( aLRSpaceSet ); SvxLRSpaceItem aParaMargin( aLRSpaceSet.Get( EE_PARA_LRSPACE ) ); @@ -380,7 +348,8 @@ void TextObjectBar::Execute( SfxRequest &rReq ) aLRSpaceSet.Put( aNewMargin ); mpView->SetAttributes( aLRSpaceSet ); - Invalidate(SID_ATTR_PARA_LRSPACE); + if (pTextObjectBar) + pTextObjectBar->Invalidate(SID_ATTR_PARA_LRSPACE); } break; @@ -417,14 +386,15 @@ void TextObjectBar::Execute( SfxRequest &rReq ) // tdf#131571: SdrEndTextEdit invalidates pTextEditOutlinerView, the pointer retrieved for pOLV // so reinitialize pOLV pOLV=mpView->GetTextEditOutlinerView(); - SfxItemSet aAttr( mpView->GetDoc().GetPool(), svl::Items<SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION>{} ); + SfxItemSetFixed<SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION> aAttr( mpView->GetDoc().GetPool() ); aAttr.Put( SvxWritingModeItem( nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ? css::text::WritingMode_LR_TB : css::text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION ) ); rReq.Done( aAttr ); mpView->SetAttributes( aAttr ); - Invalidate(); + if (pTextObjectBar) + pTextObjectBar->Invalidate(); mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true ); } break; @@ -459,7 +429,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) OUString sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " 1"); SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find(sStyleName, SfxStyleFamily::Pseudo); if( pFirstStyleSheet ) - pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, false, reinterpret_cast<const SfxPoolItem**>(&pItem)); + pItem = pFirstStyleSheet->GetItemSet().GetItemIfSet(EE_PARA_NUMBULLET, false); if (pItem ) { @@ -488,7 +458,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) aNewRule.SetLevel(nLevel, aFmt); } - pFirstStyleSheet->GetItemSet().Put(SvxNumBulletItem(aNewRule, EE_PARA_NUMBULLET)); + pFirstStyleSheet->GetItemSet().Put(SvxNumBulletItem(std::move(aNewRule), EE_PARA_NUMBULLET)); SdStyleSheet::BroadcastSdStyleSheetChange(pFirstStyleSheet, PresentationObjects::Outline_1, pSSPool); } @@ -516,7 +486,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) case SID_THES: { OUString aReplaceText; - const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(SID_THES); + const SfxStringItem* pItem2 = rReq.GetArg(FN_PARAM_THES_WORD_REPLACE); if (pItem2) aReplaceText = pItem2->GetValue(); if (!aReplaceText.isEmpty()) @@ -532,8 +502,6 @@ void TextObjectBar::Execute( SfxRequest &rReq ) if( !pArgs ) { - //aNewAttr.InvalidateAllItems(); <- produces problems (#35465#) - switch ( nSlot ) { case SID_ATTR_CHAR_WEIGHT: @@ -689,6 +657,18 @@ void TextObjectBar::Execute( SfxRequest &rReq ) } break; + case SID_SET_SMALL_CAPS: + { + SvxCaseMap eCaseMap = aEditAttr.Get(EE_CHAR_CASEMAP).GetCaseMap(); + if (eCaseMap == SvxCaseMap::SmallCaps) + eCaseMap = SvxCaseMap::NotMapped; + else + eCaseMap = SvxCaseMap::SmallCaps; + SvxCaseMapItem aItem(eCaseMap, EE_CHAR_CASEMAP); + aNewAttr.Put(aItem); + } + break; + // attributes for TextObjectBar case SID_ATTR_CHAR_FONT: mpViewShell->GetViewFrame()->GetDispatcher()-> @@ -712,8 +692,8 @@ void TextObjectBar::Execute( SfxRequest &rReq ) bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT; SvxAdjust nAdjust = SvxAdjust::Left; - if( SfxItemState::SET == aEditAttr.GetItemState(EE_PARA_JUST, true, &pPoolItem ) ) - nAdjust = static_cast<const SvxAdjustItem*>(pPoolItem)->GetAdjust(); + if( const SvxAdjustItem* pAdjustItem = aEditAttr.GetItemIfSet(EE_PARA_JUST) ) + nAdjust = pAdjustItem->GetAdjust(); if( bLeftToRight ) { @@ -731,7 +711,8 @@ void TextObjectBar::Execute( SfxRequest &rReq ) rReq.Done( aNewAttr ); pArgs = rReq.GetArgs(); - Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT ); + if (pTextObjectBar) + pTextObjectBar->Invalidate(SID_RULER_TEXT_RIGHT_TO_LEFT); } else if ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT || @@ -745,7 +726,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) SfxItemPool& rPool = mpView->GetDoc().GetPool(); SvxScriptSetItem aSvxScriptSetItem( nSlot, rPool ); - aSvxScriptSetItem.PutItemForScriptType( nScriptType, pArgs->Get( rPool.GetWhich( nSlot ) ) ); + aSvxScriptSetItem.PutItemForScriptType( nScriptType, pArgs->Get( rPool.GetWhichIDFromSlotID( nSlot ) ) ); aNewAttr.Put( aSvxScriptSetItem.GetItemSet() ); rReq.Done( aNewAttr ); pArgs = rReq.GetArgs(); @@ -783,7 +764,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) } else if(nSlot == SID_ATTR_CHAR_KERNING) { - aNewAttr.Put(pArgs->Get(pArgs->GetPool()->GetWhich(nSlot))); + aNewAttr.Put(pArgs->Get(pArgs->GetPool()->GetWhichIDFromSlotID(nSlot))); rReq.Done( aNewAttr ); pArgs = rReq.GetArgs(); } @@ -815,12 +796,12 @@ void TextObjectBar::Execute( SfxRequest &rReq ) } std::unique_ptr<SfxItemSet> pNewArgs = pArgs->Clone(); - lcl_convertStringArguments(nSlot, pNewArgs); mpView->SetAttributes(*pNewArgs); // invalidate entire shell because of performance and // extension reasons - Invalidate(); + if (pTextObjectBar) + pTextObjectBar->Invalidate(); // to refresh preview (in outline mode), slot has to be invalidated: mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true ); @@ -834,10 +815,13 @@ void TextObjectBar::Execute( SfxRequest &rReq ) pOLV->GetWindow()->GrabFocus(); } - Invalidate( SID_OUTLINE_LEFT ); - Invalidate( SID_OUTLINE_RIGHT ); - Invalidate( SID_OUTLINE_UP ); - Invalidate( SID_OUTLINE_DOWN ); + if (pTextObjectBar) + { + pTextObjectBar->Invalidate(SID_OUTLINE_LEFT); + pTextObjectBar->Invalidate(SID_OUTLINE_RIGHT); + pTextObjectBar->Invalidate(SID_OUTLINE_UP); + pTextObjectBar->Invalidate(SID_OUTLINE_DOWN); + } } } // end of namespace sd |