Kaydet (Commit) 1c47c45b authored tarafından Jan Holesovsky's avatar Jan Holesovsky

lokdialog: Convert the Format -> Bullets and Numbering... dialog to async exec

Change-Id: I01886ca1f0d7942450838e5f2de4700bdf81150f
Reviewed-on: https://gerrit.libreoffice.org/48029Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst d5e2569f
...@@ -187,53 +187,59 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) ...@@ -187,53 +187,59 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
vcl::Window *pParent = rReq.GetDialogParent(); vcl::Window *pParent = rReq.GetDialogParent();
if (!pParent) if (!pParent)
pParent = GetView().GetWindow(); pParent = GetView().GetWindow();
ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, &aSet, GetShell()));
VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, &aSet, GetShell()));
assert(pDlg && "Dialog creation failed!"); assert(pDlg && "Dialog creation failed!");
const SfxStringItem* pPageItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1); const SfxStringItem* pPageItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
if ( pPageItem ) if ( pPageItem )
pDlg->SetCurPageId( OUStringToOString( pPageItem->GetValue(), RTL_TEXTENCODING_UTF8 ) ); pDlg->SetCurPageId( OUStringToOString( pPageItem->GetValue(), RTL_TEXTENCODING_UTF8 ) );
const short nRet = pDlg->Execute();
const SfxPoolItem* pItem; std::shared_ptr<SfxRequest> pRequest(new SfxRequest(rReq));
if ( RET_OK == nRet ) rReq.Ignore(); // the 'old' request is not relevant any more
{
if( SfxItemState::SET == pDlg->GetOutputItemSet()->GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem )) pDlg->StartExecuteAsync([=](sal_Int32 nResult){
{ if (RET_OK == nResult)
rReq.AppendItem( *pItem );
rReq.Done();
SvxNumRule* pSetRule = static_cast<const SvxNumBulletItem*>( pItem )->GetNumRule();
pSetRule->UnLinkGraphics();
SwNumRule aSetRule( pNumRuleAtCurrentSelection != nullptr
? pNumRuleAtCurrentSelection->GetName()
: GetShell().GetUniqueNumRuleName(),
numfunc::GetDefaultPositionAndSpaceMode() );
aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc() );
aSetRule.SetAutoRule( true );
// No start of new list, if an existing list style is edited.
// Otherwise start a new list.
const bool bCreateList = ( pNumRuleAtCurrentSelection == nullptr );
GetShell().SetCurNumRule( aSetRule, bCreateList );
}
// If the Dialog was leaved with OK but nothing was chosen then the
// numbering must be at least activated, if it is not already.
else if ( pNumRuleAtCurrentSelection == nullptr
&& SfxItemState::SET == aSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ) )
{ {
rReq.AppendItem( *pItem ); const SfxPoolItem* pItem;
rReq.Done(); if (SfxItemState::SET == pDlg->GetOutputItemSet()->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem))
SvxNumRule* pSetRule = static_cast<const SvxNumBulletItem*>( pItem )->GetNumRule(); {
SwNumRule aSetRule( pRequest->AppendItem(*pItem);
GetShell().GetUniqueNumRuleName(), pRequest->Done();
numfunc::GetDefaultPositionAndSpaceMode() ); SvxNumRule* pSetRule = static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule();
aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc() ); pSetRule->UnLinkGraphics();
aSetRule.SetAutoRule( true ); SwNumRule aSetRule(pNumRuleAtCurrentSelection != nullptr
// start new list ? pNumRuleAtCurrentSelection->GetName()
GetShell().SetCurNumRule( aSetRule, true ); : GetShell().GetUniqueNumRuleName(),
numfunc::GetDefaultPositionAndSpaceMode());
aSetRule.SetSvxRule(*pSetRule, GetShell().GetDoc());
aSetRule.SetAutoRule(true);
// No start of new list, if an existing list style is edited.
// Otherwise start a new list.
const bool bCreateList = (pNumRuleAtCurrentSelection == nullptr);
GetShell().SetCurNumRule(aSetRule, bCreateList);
}
// If the Dialog was leaved with OK but nothing was chosen then the
// numbering must be at least activated, if it is not already.
else if (pNumRuleAtCurrentSelection == nullptr
&& SfxItemState::SET == aSet.GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem))
{
pRequest->AppendItem(*pItem);
pRequest->Done();
SvxNumRule* pSetRule = static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule();
SwNumRule aSetRule(
GetShell().GetUniqueNumRuleName(),
numfunc::GetDefaultPositionAndSpaceMode());
aSetRule.SetSvxRule(*pSetRule, GetShell().GetDoc());
aSetRule.SetAutoRule(true);
// start new list
GetShell().SetCurNumRule(aSetRule, true);
}
} }
} else if (RET_USER == nResult)
else if ( RET_USER == nRet ) GetShell().DelNumRules();
GetShell().DelNumRules(); }, pDlg);
} }
break; break;
default: default:
OSL_FAIL("wrong dispatcher"); OSL_FAIL("wrong dispatcher");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment