diff options
author | Muhammet Kara <muhammet.kara@collabora.com> | 2019-06-28 22:44:10 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@collabora.com> | 2019-06-29 00:51:21 +0200 |
commit | f86578129a14e2e70a50a9e13afaed7ad522463a (patch) | |
tree | 1f5b2a5a14819fbc27f5e09f7c3e61818ff1da87 /sw | |
parent | 9105b85c708f42024ce063b9a944466c0afdfe9a (diff) |
lokdialog: Convert the Format -> Position and Size... to async exec for sw
Change-Id: Ie3383ebe7a712d711e28c626be9e0aaeed5379bb
Reviewed-on: https://gerrit.libreoffice.org/74860
Tested-by: Jenkins
Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/shells/drwbassh.cxx | 176 |
1 files changed, 94 insertions, 82 deletions
diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx index 94799bc4a80a..ef90e5b7abe0 100644 --- a/sw/source/uibase/shells/drwbassh.cxx +++ b/sw/source/uibase/shells/drwbassh.cxx @@ -172,7 +172,7 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq) if( rMarkList.GetMark(0) != nullptr ) { SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - ScopedVclPtr<SfxAbstractTabDialog> pDlg; + VclPtr<SfxAbstractTabDialog> pDlg; bool bCaption = false; // Allowed anchorages: @@ -191,7 +191,7 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); VclPtr<AbstractSvxCaptionDialog> pCaptionDlg = pFact->CreateCaptionDialog( rReq.GetFrameWeld(), pSdrView, nAllowedAnchors ); - pDlg.disposeAndReset(pCaptionDlg); + pDlg.reset(pCaptionDlg); pCaptionDlg->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) ); } else @@ -199,7 +199,7 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); VclPtr<AbstractSvxTransformTabDialog> pTransform = pFact->CreateSvxTransformTabDialog(rReq.GetFrameWeld(), nullptr, pSdrView, nAllowedAnchors); - pDlg.disposeAndReset(pTransform); + pDlg.reset(pTransform); pTransform->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) ); } SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked()); @@ -239,99 +239,111 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq) pDlg->SetInputSet( &aSet ); - if (pDlg->Execute() == RET_OK) - { - const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); - pSh->StartAllAction(); + pDlg->StartExecuteAsync([=](sal_Int32 nResult){ + if (nResult == RET_OK) + { + SwFormatVertOrient aVOrientFinal(pFrameFormat->GetFormatAttr(RES_VERT_ORIENT)); + SwFormatHoriOrient aHOrientFinal(pFrameFormat->GetFormatAttr(RES_HORI_ORIENT)); - // #i30451# - pSh->StartUndo(SwUndoId::INSFMTATTR); + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + pSh->StartAllAction(); - pSdrView->SetGeoAttrToMarked(*pOutSet); + // #i30451# + pSh->StartUndo(SwUndoId::INSFMTATTR); - if (bCaption) - pSdrView->SetAttributes(*pOutSet); + pSdrView->SetGeoAttrToMarked(*pOutSet); - bool bPosCorr = - SfxItemState::SET != pOutSet->GetItemState( - SID_ATTR_TRANSFORM_POS_X, false ) && - SfxItemState::SET != pOutSet->GetItemState( - SID_ATTR_TRANSFORM_POS_Y, false ); + if (bCaption) + pSdrView->SetAttributes(*pOutSet); - SfxItemSet aFrameAttrSet(GetPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>{}); + bool bPosCorr = + SfxItemState::SET != pOutSet->GetItemState( + SID_ATTR_TRANSFORM_POS_X, false ) && + SfxItemState::SET != pOutSet->GetItemState( + SID_ATTR_TRANSFORM_POS_Y, false ); - bool bSingleSelection = rMarkList.GetMarkCount() == 1; + SfxItemSet aFrameAttrSet(GetPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>{}); - const SfxPoolItem* pAnchorItem; - if(SfxItemState::SET == pOutSet->GetItemState( - SID_ATTR_TRANSFORM_ANCHOR, false, &pAnchorItem)) - { - if(!bSingleSelection) - pSh->ChgAnchor(static_cast<RndStdIds>(static_cast<const SfxInt16Item*>(pAnchorItem) - ->GetValue()), false, bPosCorr ); - else + bool bSingleSelection = rMarkList.GetMarkCount() == 1; + + const SfxPoolItem* pAnchorItem; + if(SfxItemState::SET == pOutSet->GetItemState( + SID_ATTR_TRANSFORM_ANCHOR, false, &pAnchorItem)) { - SwFormatAnchor aAnchor(pFrameFormat->GetAnchor()); - aAnchor.SetType(static_cast<RndStdIds>(static_cast<const SfxInt16Item*>(pAnchorItem)->GetValue())); - aFrameAttrSet.Put( aAnchor ); + if(!bSingleSelection) + pSh->ChgAnchor(static_cast<RndStdIds>(static_cast<const SfxInt16Item*>(pAnchorItem) + ->GetValue()), false, bPosCorr ); + else + { + SwFormatAnchor aAnchor(pFrameFormat->GetAnchor()); + aAnchor.SetType(static_cast<RndStdIds>(static_cast<const SfxInt16Item*>(pAnchorItem)->GetValue())); + aFrameAttrSet.Put( aAnchor ); + } + } + const SfxPoolItem* pHoriOrient = nullptr; + const SfxPoolItem* pHoriRelation = nullptr; + const SfxPoolItem* pHoriPosition = nullptr; + const SfxPoolItem* pHoriMirror = nullptr; + pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_ORIENT, false, &pHoriOrient); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_RELATION, false, &pHoriRelation); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_POSITION, false, &pHoriPosition); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_MIRROR, false, &pHoriMirror); + if(pHoriOrient || pHoriRelation || pHoriPosition || pHoriMirror) + { + if(pHoriOrient) + aHOrientFinal.SetHoriOrient( + static_cast<const SfxInt16Item*>(pHoriOrient)->GetValue()); + if(pHoriRelation) + aHOrientFinal.SetRelationOrient( + static_cast<const SfxInt16Item*>(pHoriRelation)->GetValue()); + if(pHoriPosition) + aHOrientFinal.SetPos( static_cast<const SfxInt32Item*>(pHoriPosition)->GetValue()); + if(pHoriMirror) + aHOrientFinal.SetPosToggle( static_cast<const SfxBoolItem*>(pHoriMirror)->GetValue()); + aFrameAttrSet.Put(aHOrientFinal); } - } - const SfxPoolItem* pHoriOrient = nullptr; - const SfxPoolItem* pHoriRelation = nullptr; - const SfxPoolItem* pHoriPosition = nullptr; - const SfxPoolItem* pHoriMirror = nullptr; - pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_ORIENT, false, &pHoriOrient); - pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_RELATION, false, &pHoriRelation); - pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_POSITION, false, &pHoriPosition); - pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_MIRROR, false, &pHoriMirror); - if(pHoriOrient || pHoriRelation || pHoriPosition || pHoriMirror) - { - if(pHoriOrient) - aHOrient.SetHoriOrient( - static_cast<const SfxInt16Item*>(pHoriOrient)->GetValue()); - if(pHoriRelation) - aHOrient.SetRelationOrient( - static_cast<const SfxInt16Item*>(pHoriRelation)->GetValue()); - if(pHoriPosition) - aHOrient.SetPos( static_cast<const SfxInt32Item*>(pHoriPosition)->GetValue()); - if(pHoriMirror) - aHOrient.SetPosToggle( static_cast<const SfxBoolItem*>(pHoriMirror)->GetValue()); - aFrameAttrSet.Put(aHOrient); - } - const SfxPoolItem* pVertOrient = nullptr; - const SfxPoolItem* pVertRelation = nullptr; - const SfxPoolItem* pVertPosition = nullptr; - pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_ORIENT, false, &pVertOrient); - pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_RELATION, false, &pVertRelation); - pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_POSITION, false, &pVertPosition); - if(pVertOrient || pVertRelation || pVertPosition ) - { - if(pVertOrient) - aVOrient.SetVertOrient( - static_cast<const SfxInt16Item*>(pVertOrient)->GetValue()); - if(pVertRelation) - aVOrient.SetRelationOrient( - static_cast<const SfxInt16Item*>(pVertRelation)->GetValue()); - if(pVertPosition) - aVOrient.SetPos( static_cast<const SfxInt32Item*>(pVertPosition)->GetValue()); - aFrameAttrSet.Put( aVOrient ); - } - const SfxPoolItem* pFollowItem = nullptr; - pOutSet->GetItemState(RES_FOLLOW_TEXT_FLOW, false, &pFollowItem); - if(pFollowItem) - aFrameAttrSet.Put(*pFollowItem); + const SfxPoolItem* pVertOrient = nullptr; + const SfxPoolItem* pVertRelation = nullptr; + const SfxPoolItem* pVertPosition = nullptr; + pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_ORIENT, false, &pVertOrient); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_RELATION, false, &pVertRelation); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_POSITION, false, &pVertPosition); + if(pVertOrient || pVertRelation || pVertPosition ) + { + if(pVertOrient) + aVOrientFinal.SetVertOrient( + static_cast<const SfxInt16Item*>(pVertOrient)->GetValue()); + if(pVertRelation) + aVOrientFinal.SetRelationOrient( + static_cast<const SfxInt16Item*>(pVertRelation)->GetValue()); + if(pVertPosition) + aVOrientFinal.SetPos( static_cast<const SfxInt32Item*>(pVertPosition)->GetValue()); + aFrameAttrSet.Put( aVOrientFinal ); + } + const SfxPoolItem* pFollowItem = nullptr; + pOutSet->GetItemState(RES_FOLLOW_TEXT_FLOW, false, &pFollowItem); + if(pFollowItem) + aFrameAttrSet.Put(*pFollowItem); - if(aFrameAttrSet.Count()) - pSh->SetDrawingAttr(aFrameAttrSet); + if(aFrameAttrSet.Count()) + pSh->SetDrawingAttr(aFrameAttrSet); - rBind.InvalidateAll(false); + GetView().GetViewFrame()->GetBindings().InvalidateAll(false); - // #i30451# - pSh->EndUndo( SwUndoId::INSFMTATTR ); + // #i30451# + pSh->EndUndo( SwUndoId::INSFMTATTR ); - pSh->EndAllAction(); - } + pSh->EndAllAction(); + } + + if (pSdrView->GetModel()->IsChanged()) + pSh->SetModified(); + else if (bChanged) + pSdrView->GetModel()->SetChanged(); + + pDlg->disposeOnce(); + }); } } else |