[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 26 commits - bin/gbuild-to-ide cppuhelper/source cui/source desktop/source framework/inc framework/source include/LibreOfficeKit include/sfx2 include/vcl sc/inc sc/source sfx2/source sw/source unotools/source vcl/headless vcl/inc vcl/source

Jan Holesovsky kendy at collabora.com
Wed Mar 21 12:06:33 UTC 2018


 bin/gbuild-to-ide                            |    2 
 cppuhelper/source/servicemanager.cxx         |   31 ++
 cui/source/dialogs/cuicharmap.cxx            |    2 
 desktop/source/lib/init.cxx                  |    5 
 framework/inc/classes/taskcreator.hxx        |    3 
 framework/source/classes/taskcreator.cxx     |   10 
 framework/source/loadenv/loadenv.cxx         |    4 
 framework/source/services/desktop.cxx        |    4 
 framework/source/services/frame.cxx          |   23 +-
 framework/source/services/taskcreatorsrv.cxx |    9 
 include/LibreOfficeKit/LibreOfficeKit.hxx    |    5 
 include/sfx2/lokhelper.hxx                   |    2 
 include/sfx2/tabdlg.hxx                      |    1 
 include/vcl/abstdlg.hxx                      |   18 +
 include/vcl/dialog.hxx                       |   19 +
 include/vcl/window.hxx                       |    7 
 sc/inc/clipparam.hxx                         |    6 
 sc/source/core/data/clipparam.cxx            |    6 
 sc/source/ui/attrdlg/scdlgfact.hxx           |    5 
 sc/source/ui/inc/inputhdl.hxx                |    1 
 sc/source/ui/inc/viewdata.hxx                |   52 ++++
 sc/source/ui/view/gridwin4.cxx               |   92 ++++----
 sc/source/ui/view/tabview.cxx                |  247 -----------------------
 sc/source/ui/view/tabvwsha.cxx               |   54 +++--
 sc/source/ui/view/viewdata.cxx               |  198 +++++++++++++++++++
 sc/source/ui/view/viewfun2.cxx               |   17 +
 sc/source/ui/view/viewfun3.cxx               |   22 --
 sfx2/source/appl/macroloader.cxx             |   12 -
 sfx2/source/appl/sfxhelp.cxx                 |    3 
 sfx2/source/control/request.cxx              |   17 +
 sfx2/source/dialog/tabdlg.cxx                |   37 ++-
 sfx2/source/notify/eventsupplier.cxx         |    8 
 sfx2/source/view/lokhelper.cxx               |   11 +
 sw/source/ui/dialog/swdlgfact.hxx            |    9 
 sw/source/uibase/app/docst.cxx               |   31 +-
 sw/source/uibase/shells/textsh1.cxx          |  281 ++++++++++++++-------------
 sw/source/uibase/shells/txtnum.cxx           |   86 ++++----
 unotools/source/misc/syslocale.cxx           |    8 
 vcl/headless/svpgdi.cxx                      |   21 +-
 vcl/inc/implimagetree.hxx                    |    2 
 vcl/inc/svdata.hxx                           |    2 
 vcl/source/app/svdata.cxx                    |    3 
 vcl/source/app/svmain.cxx                    |    2 
 vcl/source/image/ImplImageTree.cxx           |   49 ++--
 vcl/source/uitest/uitest.cxx                 |    4 
 vcl/source/window/abstdlg.cxx                |    6 
 vcl/source/window/dialog.cxx                 |  155 ++++++++------
 vcl/source/window/window.cxx                 |    5 
 vcl/source/window/winproc.cxx                |    6 
 49 files changed, 934 insertions(+), 669 deletions(-)

New commits:
commit c6750cc682634ed141c75f8e2c78fe5bc4e78d1a
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jan 17 11:11:34 2018 +0100

    sw: Actually only .uno:StyleApply and .uno:StyleWatercanMode can return...
    
    ...a value, at least according to sfx2/sdi/sfx.sdi.
    
    Reviewed-on: https://gerrit.libreoffice.org/48041
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 67ea8e1432f4ea86f2bc16d8479ef8cf10c74b80)
    
    Change-Id: I1a12c025386cfc6eae529782cdb69207ffa388c5

diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index c414b3c05368..b17e936dd02e 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -295,7 +295,6 @@ void  SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
 void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
 {
     sal_uInt16  nSlot   = rReq.GetSlot();
-    sal_uInt16  nRet    = SFXSTYLEBIT_ALL;
 
     const SfxItemSet* pArgs = rReq.GetArgs();
     const SfxPoolItem* pItem;
@@ -323,7 +322,7 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
             if (sName.isEmpty() && m_xBasePool.get())
                 sName = SfxStyleDialog::GenerateUnusedName(*m_xBasePool);
 
-            nRet = Edit( sName, sParent, nFamily, nMask, true, OString(), nullptr, rReq.IsAPI() );
+            Edit(sName, sParent, nFamily, nMask, true, OString(), nullptr, rReq.IsAPI());
 
             // Update Watermark if new page style was created
             if( nFamily == SfxStyleFamily::Page )
@@ -498,47 +497,55 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
             }
             if (!aParam.isEmpty() || nSlot == SID_STYLE_WATERCAN )
             {
+                sal_uInt16 nRet = SFXSTYLEBIT_ALL;
+                bool bReturns = false;
+
                 switch(nSlot)
                 {
                     case SID_STYLE_EDIT:
-                        nRet = Edit(aParam, aEmptyOUStr, nFamily, nMask, false, OString(), pActShell );
+                        Edit(aParam, aEmptyOUStr, nFamily, nMask, false, OString(), pActShell);
                         break;
                     case SID_STYLE_DELETE:
-                        nRet = sal_uInt16(Delete(aParam, nFamily));
+                        Delete(aParam, nFamily);
                         break;
                     case SID_STYLE_HIDE:
                     case SID_STYLE_SHOW:
-                        nRet = sal_uInt16(Hide(aParam, nFamily, nSlot == SID_STYLE_HIDE));
+                        Hide(aParam, nFamily, nSlot == SID_STYLE_HIDE);
                         break;
                     case SID_STYLE_APPLY:
                         // Shell-switch in ApplyStyles
                         nRet = (sal_uInt16) ApplyStyles(aParam, nFamily, pActShell, rReq.GetModifier() );
+                        bReturns = true;
                         break;
                     case SID_STYLE_WATERCAN:
                         nRet = (sal_uInt16) DoWaterCan(aParam, nFamily);
+                        bReturns = true;
                         break;
                     case SID_STYLE_UPDATE_BY_EXAMPLE:
-                        nRet = (sal_uInt16) UpdateStyle(aParam, nFamily, pActShell);
+                        nRet = static_cast<sal_uInt16>(UpdateStyle(aParam, nFamily, pActShell));
                         break;
                     case SID_STYLE_NEW_BY_EXAMPLE:
-                        nRet = (sal_uInt16) MakeByExample(aParam, nFamily, nMask, pActShell );
+                        nRet = static_cast<sal_uInt16>(MakeByExample(aParam, nFamily, nMask, pActShell ));
                         break;
 
                     default:
                         OSL_FAIL("Invalid SlotId");
                 }
 
+                if (bReturns)
+                {
+                    if(rReq.IsAPI()) // Basic only gets TRUE or FALSE
+                        rReq.SetReturnValue(SfxUInt16Item(nSlot, sal_uInt16(nRet !=0)));
+                    else
+                        rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet));
+                }
+
                 rReq.Done();
             }
 
             break;
         }
     }
-
-        if(rReq.IsAPI()) // Basic only gets TRUE or FALSE
-            rReq.SetReturnValue(SfxUInt16Item(nSlot, sal_uInt16(nRet !=0)));
-        else
-            rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet));
 }
 
 class ApplyStyle
commit 6fe37f133f089ebcdb943818341c3f80fa6a58e6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Jan 17 17:24:35 2018 +0100

    framework: disable layout manager in hidden frames
    
    The point of hidden frames is that they are not visible on the UI, only their
    doc model / layout is accessible via the API or file format conversion. That
    means that laying out the UI elements like menus and toolbars is pointless.
    
    So change Frame::initialize() and Frame::setLayoutManager() to not enable the
    layout manager for hidden frames. To do this, we need a new window style flag,
    as both hidden and visible frames have an underlying hidden window at the time
    the framework layout manager would be enabled.
    
    Times for 200 hello world inputs: 5780 -> 5054 ms is spent in XHTML-load + ODT
    export + close (87% of original).
    
    Change-Id: I841507bbb62f8fc2979d20e2d579d0bb47b98f37
    Reviewed-on: https://gerrit.libreoffice.org/48068
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 4a0f506f0d8c2a017f0cf880481d3c0c32a48909)

diff --git a/framework/inc/classes/taskcreator.hxx b/framework/inc/classes/taskcreator.hxx
index 3c34bb00e1ad..ee8056f13812 100644
--- a/framework/inc/classes/taskcreator.hxx
+++ b/framework/inc/classes/taskcreator.hxx
@@ -27,6 +27,7 @@
 
 #include <com/sun/star/uno/Reference.hxx>
 #include <rtl/ustring.hxx>
+#include <unotools/mediadescriptor.hxx>
 
 namespace framework{
 
@@ -53,7 +54,7 @@ class TaskCreator final
                  TaskCreator( const css::uno::Reference< css::uno::XComponentContext >& xContext );
                  ~TaskCreator(                                                                     );
 
-        css::uno::Reference< css::frame::XFrame > createTask( const OUString& sName );
+        css::uno::Reference< css::frame::XFrame > createTask( const OUString& sName, const utl::MediaDescriptor& rDesciprtor );
 
 }; // class TaskCreator
 
diff --git a/framework/source/classes/taskcreator.cxx b/framework/source/classes/taskcreator.cxx
index 612ab433e7e3..0bf720b510ac 100644
--- a/framework/source/classes/taskcreator.cxx
+++ b/framework/source/classes/taskcreator.cxx
@@ -57,7 +57,7 @@ TaskCreator::~TaskCreator()
 /*-****************************************************************************************************
     TODO document me
 *//*-*****************************************************************************************************/
-css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName )
+css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName, const utl::MediaDescriptor& rDescriptor )
 {
     css::uno::Reference< css::lang::XSingleServiceFactory > xCreator;
     OUString sCreator = IMPLEMENTATIONNAME_FWK_TASKCREATOR;
@@ -86,7 +86,7 @@ css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUStrin
     if ( ! xCreator.is())
         xCreator = css::frame::TaskCreator::create(m_xContext);
 
-    css::uno::Sequence< css::uno::Any > lArgs(5);
+    css::uno::Sequence< css::uno::Any > lArgs(6);
     css::beans::NamedValue              aArg;
 
     aArg.Name    = ARGUMENT_PARENTFRAME;
@@ -109,6 +109,12 @@ css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUStrin
     aArg.Value <<= sName;
     lArgs[4]   <<= aArg;
 
+    bool bHidden
+        = rDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(), false);
+    aArg.Name = "Hidden";
+    aArg.Value <<= bHidden;
+    lArgs[5] <<= aArg;
+
     css::uno::Reference< css::frame::XFrame > xTask(xCreator->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
     return xTask;
 }
diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx
index a2cfb5e2b9f7..15861f8df97d 100644
--- a/framework/source/loadenv/loadenv.cxx
+++ b/framework/source/loadenv/loadenv.cxx
@@ -87,6 +87,7 @@
 #include <vcl/svapp.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <comphelper/profilezone.hxx>
+#include <classes/taskcreator.hxx>
 
 const char PROP_TYPES[] = "Types";
 const char PROP_NAME[] = "Name";
@@ -989,7 +990,8 @@ bool LoadEnv::impl_loadContent()
         {
             if (! impl_furtherDocsAllowed())
                 return false;
-            m_xTargetFrame       = m_xBaseFrame->findFrame(SPECIALTARGET_BLANK, 0);
+            TaskCreator aCreator(m_xContext);
+            m_xTargetFrame = aCreator.createTask(SPECIALTARGET_BLANK, m_lMediaDescriptor);
             m_bCloseFrameOnError = m_xTargetFrame.is();
         }
         else
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 119dd5d69697..b479687fdeae 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -967,7 +967,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
     if ( sTargetFrameName==SPECIALTARGET_BLANK )
     {
         TaskCreator aCreator( m_xContext );
-        xTarget = aCreator.createTask(sTargetFrameName);
+        xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor());
     }
 
     // I.II) "_top"
@@ -1051,7 +1051,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
            )
         {
             TaskCreator aCreator( m_xContext );
-            xTarget = aCreator.createTask(sTargetFrameName);
+            xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor());
         }
     }
 
diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx
index 5998d7902ccb..f404b6fbf9f0 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -412,6 +412,8 @@ private:
     bool                                                                    m_bSelfClose;
     /// indicates, if this frame is used in hidden mode or not
     bool                                                                    m_bIsHidden;
+    /// The container window has WindowExtendedStyle::DocHidden set.
+    bool                                                                    m_bDocHidden = false;
     /// is used to layout the child windows of the frame.
     css::uno::Reference< css::frame::XLayoutManager2 >                      m_xLayoutManager;
     css::uno::Reference< css::frame::XDispatchInformationProvider >         m_xDispatchInfoHelper;
@@ -772,8 +774,13 @@ void SAL_CALL Frame::initialize( const css::uno::Reference< css::awt::XWindow >&
 
     // if window is initially visible, we will never get a windowShowing event
     VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow);
-    if (pWindow && pWindow->IsVisible())
-        m_bIsHidden = false;
+    if (pWindow)
+    {
+        if (pWindow->IsVisible())
+            m_bIsHidden = false;
+        m_bDocHidden
+            = static_cast<bool>(pWindow->GetExtendedStyle() & WindowExtendedStyle::DocHidden);
+    }
 
     css::uno::Reference< css::frame::XLayoutManager2 >  xLayoutManager = m_xLayoutManager;
 
@@ -782,7 +789,9 @@ void SAL_CALL Frame::initialize( const css::uno::Reference< css::awt::XWindow >&
     aWriteLock.clear();
     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
 
-    if (xLayoutManager.is())
+    // Avoid enabling the layout manager for hidden frames: it's expensive and
+    // provides little value.
+    if (xLayoutManager.is() && !m_bDocHidden)
         lcl_enableLayoutManager(xLayoutManager, this);
 
     // create progress helper
@@ -971,7 +980,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const OUStr
     if ( sTargetFrameName==SPECIALTARGET_BLANK )
     {
         TaskCreator aCreator(m_xContext);
-        xTarget = aCreator.createTask(sTargetFrameName);
+        xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor());
     }
 
     // I.II) "_parent"
@@ -1171,7 +1180,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const OUStr
            )
         {
             TaskCreator aCreator(m_xContext);
-            xTarget = aCreator.createTask(sTargetFrameName);
+            xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor());
         }
     }
 
@@ -1825,7 +1834,7 @@ void SAL_CALL Frame::setLayoutManager(const css::uno::Reference<css::uno::XInter
         m_xLayoutManager = xNewLayoutManager;
         if (xOldLayoutManager.is())
             disableLayoutManager(xOldLayoutManager);
-        if (xNewLayoutManager.is())
+        if (xNewLayoutManager.is() && !m_bDocHidden)
             lcl_enableLayoutManager(xNewLayoutManager, this);
     }
 }
@@ -2738,7 +2747,7 @@ void SAL_CALL Frame::impl_setPropertyValue(sal_Int32 nHandle,
                         m_xLayoutManager = xNewLayoutManager;
                         if (xOldLayoutManager.is())
                             disableLayoutManager(xOldLayoutManager);
-                        if (xNewLayoutManager.is())
+                        if (xNewLayoutManager.is() && !m_bDocHidden)
                             lcl_enableLayoutManager(xNewLayoutManager, this);
                     }
                 }
diff --git a/framework/source/services/taskcreatorsrv.cxx b/framework/source/services/taskcreatorsrv.cxx
index b6f6a7ff1920..e526481c709f 100644
--- a/framework/source/services/taskcreatorsrv.cxx
+++ b/framework/source/services/taskcreatorsrv.cxx
@@ -129,6 +129,8 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI
     css::uno::Reference< css::awt::XWindow >  xContainerWindow              = lArgs.getUnpackedValueOrDefault(ARGUMENT_CONTAINERWINDOW              , css::uno::Reference< css::awt::XWindow >() );
     bool                                  bSupportPersistentWindowState = lArgs.getUnpackedValueOrDefault(ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE , false );
     bool                                  bEnableTitleBarUpdate         = lArgs.getUnpackedValueOrDefault(ARGUMENT_ENABLE_TITLEBARUPDATE        , true );
+    // If the frame is explicitly requested to be hidden.
+    bool bHidden = lArgs.getUnpackedValueOrDefault("Hidden", false);
 
     // We use FrameName property to set it as API name of the new created frame later.
     // But those frame names must be different from the set of special target names as e.g. _blank, _self etcpp !
@@ -167,6 +169,13 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI
     //------------------->
 
     // create the new frame
+    VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow(xContainerWindow);
+    if (pContainerWindow && bHidden)
+    {
+        WindowExtendedStyle eStyle = pContainerWindow->GetExtendedStyle();
+        eStyle |= WindowExtendedStyle::DocHidden;
+        pContainerWindow->SetExtendedStyle(eStyle);
+    }
     css::uno::Reference< css::frame::XFrame2 > xFrame = implts_createFrame(xParentFrame, xContainerWindow, sRightName);
 
     // special freature:
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 477401d7d7b6..4285d0277da1 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -470,9 +470,14 @@ enum class WindowExtendedStyle {
     NONE        = 0x0000,
     Document    = 0x0001,
     DocModified = 0x0002,
+    /**
+     * This is a frame window that is requested to be hidden (not just "not yet
+     * shown").
+     */
+    DocHidden   = 0x0004,
 };
 namespace o3tl {
-    template<> struct typed_flags<WindowExtendedStyle> : is_typed_flags<WindowExtendedStyle, 0x0003> {};
+    template<> struct typed_flags<WindowExtendedStyle> : is_typed_flags<WindowExtendedStyle, 0x0007> {};
 };
 
 namespace vcl {
commit 96c8ac6faa238e77b17f9cf48cc0f565c5ac640e
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jan 17 09:58:10 2018 +0100

    lokdialog: Convert the Format -> Bullets and Numbering... dialog to async exec
    
    Change-Id: I01886ca1f0d7942450838e5f2de4700bdf81150f
    Reviewed-on: https://gerrit.libreoffice.org/48029
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 1c47c45b9308b0710950e8078a57e0b3acbab364)

diff --git a/sw/source/uibase/shells/txtnum.cxx b/sw/source/uibase/shells/txtnum.cxx
index c89fae5043e9..866c439b8c6a 100644
--- a/sw/source/uibase/shells/txtnum.cxx
+++ b/sw/source/uibase/shells/txtnum.cxx
@@ -187,53 +187,59 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
         vcl::Window *pParent = rReq.GetDialogParent();
         if (!pParent)
             pParent = GetView().GetWindow();
-        ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, &aSet, GetShell()));
+
+        VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, &aSet, GetShell()));
         assert(pDlg && "Dialog creation failed!");
         const SfxStringItem* pPageItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
         if ( pPageItem )
             pDlg->SetCurPageId( OUStringToOString( pPageItem->GetValue(), RTL_TEXTENCODING_UTF8 ) );
-        const short nRet = pDlg->Execute();
-        const SfxPoolItem* pItem;
-        if ( RET_OK == nRet )
-        {
-            if( SfxItemState::SET == pDlg->GetOutputItemSet()->GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
-            {
-                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 ) )
+
+        std::shared_ptr<SfxRequest> pRequest(new SfxRequest(rReq));
+        rReq.Ignore(); // the 'old' request is not relevant any more
+
+        pDlg->StartExecuteAsync([=](sal_Int32 nResult){
+            if (RET_OK == nResult)
             {
-                rReq.AppendItem( *pItem );
-                rReq.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 );
+                const SfxPoolItem* pItem;
+                if (SfxItemState::SET == pDlg->GetOutputItemSet()->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem))
+                {
+                    pRequest->AppendItem(*pItem);
+                    pRequest->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))
+                {
+                    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 == nRet )
-            GetShell().DelNumRules();
+            else if (RET_USER == nResult)
+                GetShell().DelNumRules();
+        }, pDlg);
     }
-        break;
+    break;
 
     default:
         OSL_FAIL("wrong dispatcher");
commit 2612983f2cd2b0a5ae688cc2879d9859739e2fd8
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Jan 16 18:54:19 2018 +0100

    lokdialog: Convert the Format -> Paragraph... dialog to async exec.
    
    Change-Id: I47ec0ca95a713a7485b936aea7d7351970c9d967
    Reviewed-on: https://gerrit.libreoffice.org/48011
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 34527cec54ca634b831cfa5ac1098c4046818ac3)

diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index add083e1080d..7133f722f844 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -125,7 +125,7 @@ using namespace ::com::sun::star::container;
 using namespace com::sun::star::style;
 using namespace svx::sidebar;
 
-void sw_CharDialogResult(const SfxItemSet* pSet, SwWrtShell &rWrtSh, std::shared_ptr<SfxItemSet> pCoreSet, bool bSel, bool bSelectionPut, SfxRequest *pReq);
+static void sw_CharDialogResult(const SfxItemSet* pSet, SwWrtShell &rWrtSh, std::shared_ptr<SfxItemSet> pCoreSet, bool bSel, bool bSelectionPut, SfxRequest *pReq);
 
 void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const SfxItemSet *pArgs, SfxRequest *pReq )
 {
@@ -215,7 +215,7 @@ void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const
     }
 }
 
-void sw_CharDialogResult(const SfxItemSet* pSet, SwWrtShell &rWrtSh, std::shared_ptr<SfxItemSet> pCoreSet, bool bSel, bool bSelectionPut, SfxRequest *pReq)
+static void sw_CharDialogResult(const SfxItemSet* pSet, SwWrtShell &rWrtSh, std::shared_ptr<SfxItemSet> pCoreSet, bool bSel, bool bSelectionPut, SfxRequest *pReq)
 {
     SfxItemSet aTmpSet( *pSet );
     ::ConvertAttrGenToChar(aTmpSet, *pCoreSet, CONV_ATTR_STD);
@@ -291,6 +291,73 @@ static short lcl_AskRedlineFlags(vcl::Window *pWin)
     return aQBox->Execute();
 }
 
+static void sw_ParagraphDialogResult(SfxItemSet* pSet, SwWrtShell &rWrtSh, SfxRequest& rReq, SwPaM* pPaM)
+{
+    if (!pSet)
+        return;
+
+    rReq.Done( *pSet );
+    ::SfxToSwPageDescAttr( rWrtSh, *pSet );
+    // #i56253#
+    // enclose all undos.
+    // Thus, check conditions, if actions will be performed.
+    const bool bUndoNeeded( pSet->Count() ||
+            SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART) ||
+            SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) );
+    if ( bUndoNeeded )
+    {
+        rWrtSh.StartUndo( SwUndoId::INSATTR );
+    }
+    if( pSet->Count() )
+    {
+        rWrtSh.StartAction();
+        const SfxPoolItem* pItem = nullptr;
+        if ( SfxItemState::SET == pSet->GetItemState(FN_DROP_TEXT, false, &pItem) )
+        {
+            if ( !static_cast<const SfxStringItem*>(pItem)->GetValue().isEmpty() )
+                rWrtSh.ReplaceDropText(static_cast<const SfxStringItem*>(pItem)->GetValue(), pPaM);
+        }
+        rWrtSh.SetAttrSet(*pSet, SetAttrMode::DEFAULT, pPaM);
+        rWrtSh.EndAction();
+        SwTextFormatColl* pColl = rWrtSh.GetPaMTextFormatColl(pPaM);
+        if(pColl && pColl->IsAutoUpdateFormat())
+        {
+            rWrtSh.AutoUpdatePara(pColl, *pSet, pPaM);
+        }
+    }
+
+    if( SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART) )
+    {
+        //SetNumRuleStart(true) restarts the numbering at the value
+        //that is defined at the starting point of the numbering level
+        //otherwise the SetNodeNumStart() value determines the start
+        //if it's set to something different than USHRT_MAX
+
+        bool bStart = static_cast<const SfxBoolItem&>(pSet->Get(FN_NUMBER_NEWSTART)).GetValue();
+
+        // Default value for restart value has to be USHRT_MAX
+        // in order to indicate that the restart value of the list
+        // style has to be used on restart.
+        sal_uInt16 nNumStart = USHRT_MAX;
+        if( SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
+        {
+            nNumStart = static_cast<const SfxUInt16Item&>(pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
+        }
+        rWrtSh.SetNumRuleStart(bStart, pPaM);
+        rWrtSh.SetNodeNumStart(nNumStart);
+    }
+    else if( SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
+    {
+        rWrtSh.SetNodeNumStart(static_cast<const SfxUInt16Item&>(pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue());
+        rWrtSh.SetNumRuleStart(false, pPaM);
+    }
+    // #i56253#
+    if ( bUndoNeeded )
+    {
+        rWrtSh.EndUndo( SwUndoId::INSATTR );
+    }
+}
+
 void SwTextShell::Execute(SfxRequest &rReq)
 {
     bool bUseDialog = true;
@@ -990,7 +1057,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
                                         rWrtSh.GetNodeNumStart( pPaM ) );
                 aCoreSet.Put(aStartAt);
             }
-            ScopedVclPtr<SfxAbstractTabDialog> pDlg;
+            VclPtr<SfxAbstractTabDialog> pDlg;
 
             if ( bUseDialog && GetActiveView() )
             {
@@ -1001,10 +1068,10 @@ void SwTextShell::Execute(SfxRequest &rReq)
                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
-                pDlg.disposeAndReset(pFact->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet, false, sDefPage ));
+                pDlg.reset(pFact->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet, false, sDefPage ));
                 OSL_ENSURE(pDlg, "Dialog creation failed!");
             }
-            SfxItemSet* pSet = nullptr;
+
             if ( !bUseDialog )
             {
                 if ( nSlot == SID_ATTR_PARA_LRSPACE)
@@ -1012,102 +1079,50 @@ void SwTextShell::Execute(SfxRequest &rReq)
                     SvxLRSpaceItem aParaMargin(static_cast<const SvxLRSpaceItem&>(pArgs->Get(nSlot)));
                     aParaMargin.SetWhich( RES_LR_SPACE);
                     aCoreSet.Put(aParaMargin);
-                    pSet = &aCoreSet;
-
-                } else
-                    pSet = const_cast<SfxItemSet*>(pArgs);
 
+                    sw_ParagraphDialogResult(&aCoreSet, rWrtSh, rReq, pPaM);
+                }
+                else
+                    sw_ParagraphDialogResult(const_cast<SfxItemSet*>(pArgs), rWrtSh, rReq, pPaM);
             }
-            else if ( pDlg && pDlg->Execute() == RET_OK )
+            else if (pDlg)
             {
-                // Apply defaults if necessary.
-                pSet = const_cast<SfxItemSet*>(pDlg->GetOutputItemSet());
-                sal_uInt16 nNewDist;
-                if( SfxItemState::SET == pSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS, false, &pItem ) &&
-                    nDefDist != (nNewDist = static_cast<const SfxUInt16Item*>(pItem)->GetValue()) )
-                {
-                    SvxTabStopItem aDefTabs( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP );
-                    MakeDefTabs( nNewDist, aDefTabs );
-                    rWrtSh.SetDefault( aDefTabs );
-                    pSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS );
-                }
+                std::shared_ptr<SfxRequest> pRequest(new SfxRequest(rReq));
+                rReq.Ignore(); // the 'old' request is not relevant any more
 
-                if ( SfxItemState::SET == pSet->GetItemState(FN_PARAM_1,false,&pItem) )
-                {
-                    pSet->Put(SfxStringItem(FN_DROP_TEXT, static_cast<const SfxStringItem*>(pItem)->GetValue()));
-                    pSet->ClearItem(FN_PARAM_1);
-                }
+                pDlg->StartExecuteAsync([pDlg, &rWrtSh, pRequest, nDefDist, pPaM](sal_Int32 nResult){
+                    if (nResult == RET_OK)
+                    {
+                        // Apply defaults if necessary.
+                        SfxItemSet* pSet = const_cast<SfxItemSet*>(pDlg->GetOutputItemSet());
+                        sal_uInt16 nNewDist;
+                        const SfxPoolItem* pItem2 = nullptr;
+                        if (SfxItemState::SET == pSet->GetItemState(SID_ATTR_TABSTOP_DEFAULTS, false, &pItem2) &&
+                            nDefDist != (nNewDist = static_cast<const SfxUInt16Item*>(pItem2)->GetValue()) )
+                        {
+                            SvxTabStopItem aDefTabs( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP );
+                            MakeDefTabs( nNewDist, aDefTabs );
+                            rWrtSh.SetDefault( aDefTabs );
+                            pSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS );
+                        }
 
-                if( SfxItemState::SET == pSet->GetItemState( RES_PARATR_DROP, false, &pItem ))
-                {
-                    OUString sCharStyleName;
-                    if(static_cast<const SwFormatDrop*>(pItem)->GetCharFormat())
-                        sCharStyleName = static_cast<const SwFormatDrop*>(pItem)->GetCharFormat()->GetName();
-                    pSet->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME, sCharStyleName));
-                }
-            }
+                        if (SfxItemState::SET == pSet->GetItemState(FN_PARAM_1, false, &pItem2))
+                        {
+                            pSet->Put(SfxStringItem(FN_DROP_TEXT, static_cast<const SfxStringItem*>(pItem2)->GetValue()));
+                            pSet->ClearItem(FN_PARAM_1);
+                        }
 
-            if ( pSet )
-            {
-                rReq.Done( *pSet );
-                ::SfxToSwPageDescAttr( rWrtSh, *pSet );
-                // #i56253#
-                // enclose all undos.
-                // Thus, check conditions, if actions will be performed.
-                const bool bUndoNeeded( pSet->Count() ||
-                        SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART) ||
-                        SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) );
-                if ( bUndoNeeded )
-                {
-                    rWrtSh.StartUndo( SwUndoId::INSATTR );
-                }
-                if( pSet->Count() )
-                {
-                    rWrtSh.StartAction();
-                    if ( SfxItemState::SET == pSet->GetItemState(FN_DROP_TEXT, false, &pItem) )
-                    {
-                        if ( !static_cast<const SfxStringItem*>(pItem)->GetValue().isEmpty() )
-                            rWrtSh.ReplaceDropText(static_cast<const SfxStringItem*>(pItem)->GetValue(), pPaM);
-                    }
-                    rWrtSh.SetAttrSet( *pSet, SetAttrMode::DEFAULT, pPaM );
-                    rWrtSh.EndAction();
-                    SwTextFormatColl* pColl = rWrtSh.GetPaMTextFormatColl( pPaM );
-                    if(pColl && pColl->IsAutoUpdateFormat())
-                    {
-                        rWrtSh.AutoUpdatePara(pColl, *pSet, pPaM);
-                    }
-                }
+                        if (SfxItemState::SET == pSet->GetItemState(RES_PARATR_DROP, false, &pItem2))
+                        {
+                            OUString sCharStyleName;
+                            if (static_cast<const SwFormatDrop*>(pItem2)->GetCharFormat())
+                                sCharStyleName = static_cast<const SwFormatDrop*>(pItem2)->GetCharFormat()->GetName();
+                            pSet->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME, sCharStyleName));
+                        }
 
-                if( SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART) )
-                {
-                    //SetNumRuleStart(true) restarts the numbering at the value
-                    //that is defined at the starting point of the numbering level
-                    //otherwise the SetNodeNumStart() value determines the start
-                    //if it's set to something different than USHRT_MAX
-
-                    bool bStart = static_cast<const SfxBoolItem&>(pSet->Get(FN_NUMBER_NEWSTART)).GetValue();
-
-                    // Default value for restart value has to be USHRT_MAX
-                    // in order to indicate that the restart value of the list
-                    // style has to be used on restart.
-                    sal_uInt16 nNumStart = USHRT_MAX;
-                    if( SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
-                    {
-                        nNumStart = static_cast<const SfxUInt16Item&>(pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
+                        sw_ParagraphDialogResult(pSet, rWrtSh, *pRequest, pPaM);
                     }
-                    rWrtSh.SetNumRuleStart(bStart, pPaM);
-                    rWrtSh.SetNodeNumStart(nNumStart);
-                }
-                else if( SfxItemState::SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
-                {
-                    rWrtSh.SetNodeNumStart(static_cast<const SfxUInt16Item&>(pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue());
-                    rWrtSh.SetNumRuleStart(false, pPaM);
-                }
-                // #i56253#
-                if ( bUndoNeeded )
-                {
-                    rWrtSh.EndUndo( SwUndoId::INSATTR );
-                }
+                }, pDlg);
             }
         }
         break;
commit 80f5746d64313907419777bb0b8e4795fda0f838
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Jan 16 13:41:34 2018 +0100

    lokdialog: Convert the Format -> Character... dialog to async exec.
    
    Change-Id: Idd1407f54729f7be18d458db7bda7de0b0cc6ad6
    Reviewed-on: https://gerrit.libreoffice.org/47986
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    (cherry picked from commit ce9594d40a8d72370624b045761df4e0078d601e)

diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 489faaaf7354..337bdf6bc4aa 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -53,12 +53,17 @@ public:                                             \
     explicit        Class( DialogClass* p)          \
                      : pDlg(p)                      \
                      {}                             \
-    virtual short   Execute() override ;
+    virtual short   Execute() override;             \
+    virtual bool    StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override;
 
 #define IMPL_ABSTDLG_BASE(Class)                    \
-short Class::Execute()                             \
+short Class::Execute()                              \
 {                                                   \
     return pDlg->Execute();                         \
+}                                                   \
+bool Class::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) \
+{ \
+    return pDlg->StartExecuteAsync(rCtx); \
 }
 
 class SwWordCountFloatDlg;
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index e69bc47b629a..add083e1080d 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -125,11 +125,13 @@ using namespace ::com::sun::star::container;
 using namespace com::sun::star::style;
 using namespace svx::sidebar;
 
-void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq )
+void sw_CharDialogResult(const SfxItemSet* pSet, SwWrtShell &rWrtSh, std::shared_ptr<SfxItemSet> pCoreSet, bool bSel, bool bSelectionPut, SfxRequest *pReq);
+
+void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const SfxItemSet *pArgs, SfxRequest *pReq )
 {
     FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( &rWrtSh.GetView()) != nullptr );
     SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
-    SfxItemSet aCoreSet(
+    std::shared_ptr<SfxItemSet> pCoreSet(new SfxItemSet(
         rWrtSh.GetView().GetPool(),
         svl::Items<
             RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
@@ -138,8 +140,9 @@ void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const
             SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
             SID_HTML_MODE, SID_HTML_MODE,
             SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
-            FN_PARAM_SELECTION, FN_PARAM_SELECTION>{} );
-    rWrtSh.GetCurAttr( aCoreSet );
+            FN_PARAM_SELECTION, FN_PARAM_SELECTION>{}));
+    rWrtSh.GetCurAttr(*pCoreSet);
+
     bool bSel = rWrtSh.HasSelection();
     bool bSelectionPut = false;
     if(bSel || rWrtSh.IsInWord())
@@ -151,7 +154,7 @@ void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const
             if(!rWrtSh.SelectTextAttr( RES_TXTATR_INETFMT ))
                 rWrtSh.SelWrd();
         }
-        aCoreSet.Put(SfxStringItem(FN_PARAM_SELECTION, rWrtSh.GetSelText()));
+        pCoreSet->Put(SfxStringItem(FN_PARAM_SELECTION, rWrtSh.GetSelText()));
         bSelectionPut = true;
         if(!bSel)
         {
@@ -159,54 +162,63 @@ void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const
             rWrtSh.EndAction();
         }
     }
-        aCoreSet.Put( SfxUInt16Item( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
-                    rWrtSh.GetScalingOfSelectedText() ) );
+    pCoreSet->Put(SfxUInt16Item(SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, rWrtSh.GetScalingOfSelectedText()));
 
-    ::ConvertAttrCharToGen(aCoreSet, CONV_ATTR_STD);
+    ::ConvertAttrCharToGen(*pCoreSet, CONV_ATTR_STD);
 
     // Setting the BoxInfo
-    ::PrepareBoxInfo( aCoreSet, rWrtSh );
+    ::PrepareBoxInfo(*pCoreSet, rWrtSh);
 
-    aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(rWrtSh.GetView().GetDocShell())));
-    ScopedVclPtr<SfxAbstractTabDialog> pDlg;
+    pCoreSet->Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(rWrtSh.GetView().GetDocShell())));
+    VclPtr<SfxAbstractTabDialog> pDlg;
     if ( bUseDialog && GetActiveView() )
     {
         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
         OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
-        pDlg.disposeAndReset(pFact->CreateSwCharDlg(rWrtSh.GetView().GetWindow(), rWrtSh.GetView(), aCoreSet, SwCharDlgMode::Std));
-        OSL_ENSURE(pDlg, "Dialog creation failed!");
-        if( FN_INSERT_HYPERLINK == nSlot )
+        pDlg.reset(pFact->CreateSwCharDlg(rWrtSh.GetView().GetWindow(), rWrtSh.GetView(), *pCoreSet, SwCharDlgMode::Std));
+        if (!pDlg)
+        {
+            SAL_WARN("sw.ui", "Dialog creation failed!");
+            return;
+        }
+
+        if (nSlot == FN_INSERT_HYPERLINK)
             pDlg->SetCurPageId("hyperlink");
+        else if (nSlot == SID_CHAR_DLG_EFFECT)
+            pDlg->SetCurPageId("fonteffects");
+        else if (nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
+            pDlg->SetCurPageId("font");
+        else if (pReq)
+        {
+            const SfxStringItem* pItem = (*pReq).GetArg<SfxStringItem>(FN_PARAM_1);
+            if (pItem)
+                pDlg->SetCurPageId(OUStringToOString(pItem->GetValue(), RTL_TEXTENCODING_UTF8));
+        }
     }
-    if (pDlg && nSlot == SID_CHAR_DLG_EFFECT)
-    {
-        pDlg->SetCurPageId("fonteffects");
-    }
-    else if (pDlg && (nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_CHAR_DLG_FOR_PARAGRAPH))
-    {
-        pDlg->SetCurPageId("font");
-    }
-    else if (pDlg && pReq)
+
+    if (bUseDialog)
     {
-        const SfxStringItem* pItem = (*pReq).GetArg<SfxStringItem>(FN_PARAM_1);
-        if (pItem)
-            pDlg->SetCurPageId(OUStringToOString(pItem->GetValue(), RTL_TEXTENCODING_UTF8));
-    }
+        std::shared_ptr<SfxRequest> pRequest(new SfxRequest(*pReq));
+        pReq->Ignore(); // the 'old' request is not relevant any more
 
-    const SfxItemSet* pSet = nullptr;
-    if ( !bUseDialog )
-        pSet = pArgs;
-    else if ( pDlg && pDlg->Execute() == RET_OK ) /* #110771# pDlg can be NULL */
+        pDlg->StartExecuteAsync([pDlg, &rWrtSh, pCoreSet, bSel, bSelectionPut, pRequest](sal_Int32 nResult){
+            if (nResult == RET_OK)
+            {
+                sw_CharDialogResult(pDlg->GetOutputItemSet(), rWrtSh, pCoreSet, bSel, bSelectionPut, pRequest.get());
+            }
+        }, pDlg);
+    }
+    else if (pArgs)
     {
-        pSet = pDlg->GetOutputItemSet();
+        sw_CharDialogResult(pArgs, rWrtSh, pCoreSet, bSel, bSelectionPut, pReq);
     }
+}
 
-    if ( !pSet)
-        return;
-
+void sw_CharDialogResult(const SfxItemSet* pSet, SwWrtShell &rWrtSh, std::shared_ptr<SfxItemSet> pCoreSet, bool bSel, bool bSelectionPut, SfxRequest *pReq)
+{
     SfxItemSet aTmpSet( *pSet );
-    ::ConvertAttrGenToChar(aTmpSet, aCoreSet, CONV_ATTR_STD);
+    ::ConvertAttrGenToChar(aTmpSet, *pCoreSet, CONV_ATTR_STD);
 
     const SfxPoolItem* pSelectionItem;
     bool bInsert = false;
commit 56204491741ede1634e0a9c465a5c9d26dea1874
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Wed Jan 17 05:40:54 2018 +0100

    VS generator: set output to soffice.bin to allow starting from debugger
    
    It is more likely that soffice.bit should be debugged, not soffice.exe
    stub. This allows to start debug session from VisualStudio, and debug
    startup code.
    
    Change-Id: Iab4615c67aeb25b811ecc71f6ae48aa9b40c45dc
    Reviewed-on: https://gerrit.libreoffice.org/48025
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 688b16df55afa1920f007b5bbe52c24f431c4ac2)

diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide
index 35fefd110e0b..48d1a760c781 100755
--- a/bin/gbuild-to-ide
+++ b/bin/gbuild-to-ide
@@ -904,7 +904,7 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator):
             nmake_rebuild_node = ET.SubElement(conf_node, '{%s}NMakeReBuildCommandLine' % ns)
             nmake_rebuild_node.text = cfg_targets['rebuild'] % nmake_params
             nmake_output_node = ET.SubElement(conf_node, '{%s}NMakeOutput' % ns)
-            nmake_output_node.text = os.path.join(self.gbuildparser.instdir, 'program', 'soffice.exe')
+            nmake_output_node.text = os.path.join(self.gbuildparser.instdir, 'program', 'soffice.bin')
             nmake_defs_node = ET.SubElement(conf_node, '{%s}NMakePreprocessorDefinitions' % ns)
             nmake_defs_node.text = ';'.join(self.defs_list(target.defs) + ['$(NMakePreprocessorDefinitions)'])
             include_path_node = ET.SubElement(conf_node, '{%s}IncludePath' % ns)
commit 370c664f6a1b5b58d67478234f4ad276e3e7df76
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Jan 16 13:40:18 2018 +0100

    lokdialog: Don't output anything for the incoming SfxRequest.
    
    Change-Id: I1b216b7348a46835df3c2d307ce17bca64199997
    Reviewed-on: https://gerrit.libreoffice.org/47985
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    (cherry picked from commit 5134220858afef8593b45a0e4fd25b401b1d7892)

diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 507471162ac0..da1c35a3b33b 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -543,6 +543,8 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName
         pDlg->SetCurPageId(rName);
 
     std::shared_ptr<SfxRequest> pRequest(new SfxRequest(rReq));
+    rReq.Ignore(); // the 'old' request is not relevant any more
+
     pDlg->StartExecuteAsync([=](sal_Int32 nResult){
             bInFormatDialog = false;
 
commit 75fea9c4141102baf82197346f8a71ee34a6d75d
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Jan 16 12:27:56 2018 +0530

    svx: chain up correctly for SvxCharacterMap::Execute()
    
    Change-Id: I2ff70f7b2ade8e2aad96cff31bd313822779094c
    (cherry picked from commit f1ec1b1f6e24fce5e496fd7c97c93884068dfba2)

diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx
index 0bc4db911c28..fb0410148105 100644
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -173,7 +173,7 @@ short SvxCharacterMap::Execute()
         m_pOKBtn->Enable();
     }
 
-    return ModalDialog::Execute();
+    return SfxModalDialog::Execute();
 }
 
 void SvxCharacterMap::dispose()
commit 874951ccb5210dc8428faafda017c3da17aee806
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Jan 15 19:56:52 2018 +0100

    vcl: No need for a double-linked list of dialogs in Execute().
    
    Instead use a simple vector.
    
    Change-Id: I50652468cf06ba681d5caccb74a52b32c6c507a0
    Reviewed-on: https://gerrit.libreoffice.org/47910
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    (cherry picked from commit 1a156644e27a380daed217707a9cff9319f70a49)

diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 6dea53f47058..7fe00ba1c8c3 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -45,9 +45,7 @@ public:
     };
 
 private:
-    VclPtr<Dialog>  mpPrevExecuteDlg;
-    VclPtr<Dialog>  mpNextExecuteDlg;
-    std::unique_ptr<DialogImpl>     mpDialogImpl;
+    std::unique_ptr<DialogImpl> mpDialogImpl;
     long            mnMousePositioned;
     bool            mbInExecute;
     bool            mbInClose;
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index f8bed79fb105..f35ea6da1730 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -203,7 +203,7 @@ struct ImplSVWinData
     VclPtr<vcl::Window>     mpCaptureWin;                   // window, that has the mouse capture
     VclPtr<vcl::Window>     mpLastDeacWin;                  // Window, that need a deactivate (FloatingWindow-Handling)
     VclPtr<FloatingWindow>  mpFirstFloat;                   // First FloatingWindow in PopupMode
-    VclPtr<Dialog>          mpLastExecuteDlg;               // First Dialog that is in Execute
+    std::vector<VclPtr<Dialog>> mpExecuteDialogs;           ///< Stack of dialogs that are Execute()'d - the last one is the top most one.
     VclPtr<vcl::Window>     mpExtTextInputWin;              // Window, which is in ExtTextInput
     VclPtr<vcl::Window>     mpTrackWin;                     // window, that is in tracking mode
     AutoTimer*              mpTrackTimer = nullptr;         // tracking timer
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 8f546feb5f78..1dfede46fc94 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -606,7 +606,7 @@ void DeInitVCL()
     pSVData->maWinData.mpCaptureWin = nullptr;
     pSVData->maWinData.mpLastDeacWin = nullptr;
     pSVData->maWinData.mpFirstFloat = nullptr;
-    pSVData->maWinData.mpLastExecuteDlg = nullptr;
+    pSVData->maWinData.mpExecuteDialogs.clear();
     pSVData->maWinData.mpExtTextInputWin = nullptr;
     pSVData->maWinData.mpTrackWin = nullptr;
     pSVData->maWinData.mpAutoScrollWin = nullptr;
diff --git a/vcl/source/uitest/uitest.cxx b/vcl/source/uitest/uitest.cxx
index 3234108ca7ed..658b8cf75a82 100644
--- a/vcl/source/uitest/uitest.cxx
+++ b/vcl/source/uitest/uitest.cxx
@@ -38,9 +38,9 @@ std::unique_ptr<UIObject> UITest::getFocusTopWindow()
     ImplSVData* pSVData = ImplGetSVData();
     ImplSVWinData& rWinData = pSVData->maWinData;
 
-    if (rWinData.mpLastExecuteDlg)
+    if (!rWinData.mpExecuteDialogs.empty())
     {
-        return rWinData.mpLastExecuteDlg->GetUITestFactory()(rWinData.mpLastExecuteDlg);
+        return rWinData.mpExecuteDialogs.back()->GetUITestFactory()(rWinData.mpExecuteDialogs.back());
     }
 
     return rWinData.mpFirstFrame->GetUITestFactory()(rWinData.mpFirstFrame);
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 3d43c7750fd2..afaab2a21f9a 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -351,8 +351,6 @@ struct DialogImpl
 void Dialog::ImplInitDialogData()
 {
     mpWindowImpl->mbDialog  = true;
-    mpPrevExecuteDlg        = nullptr;
-    mpNextExecuteDlg        = nullptr;
     mbInExecute             = false;
     mbInClose               = false;
     mbModalMode             = false;
@@ -374,19 +372,17 @@ vcl::Window* Dialog::GetDefaultParent(WinBits nStyle)
     if (pParent && (!pParent->IsInputEnabled() || pParent->IsInModalMode()))
     {
         ImplSVData* pSVData = ImplGetSVData();
-        Dialog*     pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
-        while (pExeDlg)
+        auto& rExecuteDialogs = pSVData->maWinData.mpExecuteDialogs;
+        for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
         {
             // only if visible and enabled
-            if (pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild(pExeDlg, true) &&
-                pExeDlg->IsReallyVisible() &&
-                pExeDlg->IsEnabled() && pExeDlg->IsInputEnabled() && !pExeDlg->IsInModalMode())
+            if (pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild(*it, true) &&
+                (*it)->IsReallyVisible() &&
+                (*it)->IsEnabled() && (*it)->IsInputEnabled() && !(*it)->IsInModalMode())
             {
-                pParent = pExeDlg;
+                pParent = it->get();
                 break;
             }
-
-            pExeDlg = pExeDlg->mpPrevExecuteDlg;
         }
     }
 
@@ -587,8 +583,6 @@ void Dialog::dispose()
 {
     mpDialogImpl.reset();
     RemoveFromDlgList();
-    mpPrevExecuteDlg.clear();
-    mpNextExecuteDlg.clear();
     mpActionArea.clear();
     mpContentArea.clear();
 
@@ -832,10 +826,7 @@ bool Dialog::ImplStartExecuteModal()
     ImplSVData* pSVData = ImplGetSVData();
 
      // link all dialogs which are being executed
-    mpPrevExecuteDlg = pSVData->maWinData.mpLastExecuteDlg;
-    if (mpPrevExecuteDlg)
-        mpPrevExecuteDlg->mpNextExecuteDlg = this;
-    pSVData->maWinData.mpLastExecuteDlg = this;
+    pSVData->maWinData.mpExecuteDialogs.push_back(this);
 
     // stop capturing, in order to have control over the dialog
     if ( pSVData->maWinData.mpTrackWin )
@@ -996,21 +987,11 @@ bool Dialog::StartExecuteAsync( VclAbstractDialog::AsyncContext &rCtx )
 
 void Dialog::RemoveFromDlgList()
 {
-    // remove dialog from the list of dialogs which are being executed
     ImplSVData* pSVData = ImplGetSVData();
-    if (pSVData->maWinData.mpLastExecuteDlg == this)
-    {
-        if (mpPrevExecuteDlg)
-            pSVData->maWinData.mpLastExecuteDlg = mpPrevExecuteDlg;
-        else
-            pSVData->maWinData.mpLastExecuteDlg = mpNextExecuteDlg;
-    }
-    if (mpPrevExecuteDlg)
-        mpPrevExecuteDlg->mpNextExecuteDlg = mpNextExecuteDlg;
-    if (mpNextExecuteDlg)
-        mpNextExecuteDlg->mpPrevExecuteDlg = mpPrevExecuteDlg;
-    mpPrevExecuteDlg.clear();
-    mpNextExecuteDlg.clear();
+    auto& rExecuteDialogs = pSVData->maWinData.mpExecuteDialogs;
+
+    // remove dialog from the list of dialogs which are being executed
+    rExecuteDialogs.erase(std::remove_if(rExecuteDialogs.begin(), rExecuteDialogs.end(), [=](VclPtr<Dialog>& dialog){ return dialog.get() == this; }), rExecuteDialogs.end());
 }
 
 void Dialog::EndDialog( long nResult )
@@ -1024,19 +1005,20 @@ void Dialog::EndDialog( long nResult )
 
     // set focus to previous modal dialogue if it is modal for
     // the same frame parent (or NULL)
-    if( mpPrevExecuteDlg )
+    ImplSVData* pSVData = ImplGetSVData();
+    if (!pSVData->maWinData.mpExecuteDialogs.empty())
     {
+        VclPtr<Dialog> pPrevious = pSVData->maWinData.mpExecuteDialogs.back();
+
         vcl::Window* pFrameParent = ImplGetFrameWindow()->ImplGetParent();
-        vcl::Window* pPrevFrameParent = mpPrevExecuteDlg->ImplGetFrameWindow()? mpPrevExecuteDlg->ImplGetFrameWindow()->ImplGetParent(): nullptr;
+        vcl::Window* pPrevFrameParent = pPrevious->ImplGetFrameWindow()? pPrevious->ImplGetFrameWindow()->ImplGetParent(): nullptr;
         if( ( !pFrameParent && !pPrevFrameParent ) ||
             ( pFrameParent && pPrevFrameParent && pFrameParent->ImplGetFrame() == pPrevFrameParent->ImplGetFrame() )
             )
         {
-            mpPrevExecuteDlg->GrabFocus();
+            pPrevious->GrabFocus();
         }
     }
-    mpPrevExecuteDlg = nullptr;
-    mpNextExecuteDlg = nullptr;
 
     Hide();
     if ( GetParent() )
@@ -1072,17 +1054,15 @@ long Dialog::GetResult() const
 void Dialog::EndAllDialogs( vcl::Window const * pParent )
 {
     ImplSVData* pSVData = ImplGetSVData();
-    Dialog* pTempModDialog;
-    Dialog* pModDialog = pSVData->maWinData.mpLastExecuteDlg;
-    while (pModDialog)
+    auto& rExecuteDialogs = pSVData->maWinData.mpExecuteDialogs;
+
+    for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
     {
-        pTempModDialog = pModDialog->mpPrevExecuteDlg;
-        if(!pParent || pParent->IsWindowOrChild(pModDialog,true))
+        if (!pParent || pParent->IsWindowOrChild(*it, true))
         {
-            pModDialog->EndDialog();
-            pModDialog->PostUserEvent( Link<void*,void>() );
+            (*it)->EndDialog();
+            (*it)->PostUserEvent(Link<void*, void>());
         }
-        pModDialog = pTempModDialog;
     }
 }
 
@@ -1100,14 +1080,21 @@ void Dialog::ImplSetModalInputMode( bool bModal )
     if ( bModal == mbModalMode )
         return;
 
+    // previously Execute()'d dialog - the one below the top-most one
+    VclPtr<Dialog> pPrevious;
+    ImplSVData* pSVData = ImplGetSVData();
+    auto& rExecuteDialogs = pSVData->maWinData.mpExecuteDialogs;
+    if (rExecuteDialogs.size() > 1)
+        pPrevious = rExecuteDialogs[rExecuteDialogs.size() - 2];
+
     mbModalMode = bModal;
     if ( bModal )
     {
         // Disable the prev Modal Dialog, because our dialog must close at first,
         // before the other dialog can be closed (because the other dialog
         // is on stack since our dialog returns)
-        if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->IsWindowOrChild( this, true ) )
-            mpPrevExecuteDlg->EnableInput( false, this );
+        if (pPrevious && !pPrevious->IsWindowOrChild(this, true))
+            pPrevious->EnableInput(false, this);
 
         // determine next overlap dialog parent
         vcl::Window* pParent = GetParent();
@@ -1131,24 +1118,18 @@ void Dialog::ImplSetModalInputMode( bool bModal )
         }
 
         // Enable the prev Modal Dialog
-        if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->IsWindowOrChild( this, true ) )
+        if (pPrevious && !pPrevious->IsWindowOrChild(this, true))
         {
-            mpPrevExecuteDlg->EnableInput( true, this );
+            pPrevious->EnableInput(true, this);
+
             // ensure continued modality of prev dialog
             // do not change modality counter
 
             // #i119994# need find the last modal dialog before reactive it
-            Dialog * pPrevModalDlg = mpPrevExecuteDlg;
-
-            while( pPrevModalDlg && !pPrevModalDlg->IsModalInputMode() )
-                pPrevModalDlg = pPrevModalDlg->mpPrevExecuteDlg;
-
-            if( pPrevModalDlg &&
-            ( pPrevModalDlg == mpPrevExecuteDlg.get()
-                || !pPrevModalDlg->IsWindowOrChild( this, true ) ) )
+            if (pPrevious->IsModalInputMode() || !pPrevious->IsWindowOrChild(this, true))
             {
-                mpPrevExecuteDlg->ImplSetModalInputMode( false );
-                mpPrevExecuteDlg->ImplSetModalInputMode( true );
+                pPrevious->ImplSetModalInputMode(false);
+                pPrevious->ImplSetModalInputMode(true);
             }
         }
     }
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index ad4c6920a738..39b16257f2f1 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -1733,9 +1733,9 @@ IMPL_LINK_NOARG(vcl::Window, ImplAsyncFocusHdl, void*, void)
             {
                 ImplSVData* pSVData = ImplGetSVData();
                 vcl::Window*     pTopLevelWindow = ImplGetWindowImpl()->mpFrameData->mpFocusWin->ImplGetFirstOverlapWindow();
-                if ( ( ! pTopLevelWindow->IsInputEnabled() || pTopLevelWindow->IsInModalMode() )
-                     && pSVData->maWinData.mpLastExecuteDlg )
-                    pSVData->maWinData.mpLastExecuteDlg->ToTop( ToTopFlags::RestoreWhenMin | ToTopFlags::GrabFocusOnly);
+
+                if ((!pTopLevelWindow->IsInputEnabled() || pTopLevelWindow->IsInModalMode()) && !pSVData->maWinData.mpExecuteDialogs.empty())
+                    pSVData->maWinData.mpExecuteDialogs.back()->ToTop(ToTopFlags::RestoreWhenMin | ToTopFlags::GrabFocusOnly);
                 else
                     pTopLevelWindow->GrabFocus();
             }
commit de70c261103da079a8cf54c818aa1e6d6085202c
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Jan 12 11:57:22 2018 +0000

    lokdialog: Allow closing the Format Cell dialogs in any order.
    
    Includes also lots of infrastructural changes, making the
    conversion of the rest of the dialogs much easier.
    
    StartExecuteAsync should be used in-place of StartExecuteModal
    and the latter removed from the code-base incrementally. More
    common code from Dialog::Execute should be moved to
    ImplStartExecuteModal in a next step, as this is used more widely.
    
    Reviewed-on: https://gerrit.libreoffice.org/47722
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>
    (cherry picked from commit c40dfabd56ade10fe35690dc9810955c2e99e2c0)
    
    Change-Id: Idb2c1ec790e38f582438471a0419a56cdcf1439d

diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 533496966d12..c6bc49157b28 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -190,6 +190,7 @@ public:
 
     short               Execute() override;
     void                StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) override;
+    bool                StartExecuteAsync( VclAbstractDialog::AsyncContext &rCtx ) override;
     void                Start();
 
     const SfxItemSet*   GetExampleSet() const { return m_pExampleSet; }
diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx
index 40f75ed293b6..87336e0d5a5f 100644
--- a/include/vcl/abstdlg.hxx
+++ b/include/vcl/abstdlg.hxx
@@ -25,6 +25,7 @@
 #include <vcl/vclptr.hxx>
 #include <vcl/vclreferencebase.hxx>
 #include <vector>
+#include <functional>
 
 namespace vcl { class Window; }
 class Dialog;
@@ -42,6 +43,23 @@ protected:
 public:
     virtual short       Execute() = 0;
 
+    struct AsyncContext {
+        VclPtr<VclReferenceBase> mxOwner;
+        std::function<void(sal_Int32)> maEndDialogFn;
+        bool isSet() { return !!maEndDialogFn; }
+    };
+
+    bool StartExecuteAsync(const std::function<void(sal_Int32)> &rEndDialogFn, VclPtr<VclReferenceBase> xOwner)
+    {
+        AsyncContext aCtx;
+        aCtx.mxOwner = xOwner;
+        aCtx.maEndDialogFn = rEndDialogFn;
+        return StartExecuteAsync(aCtx);
+    }
+
+    /// Commence execution of a modal dialog.
+    virtual bool StartExecuteAsync(AsyncContext &);
+
     // Screenshot interface
     virtual std::vector<OString> getAllPageUIXMLDescriptions() const;
     virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription);
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 3da4ec0cb59a..6dea53f47058 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -26,6 +26,7 @@
 #include <vcl/syswin.hxx>
 #include <vcl/vclptr.hxx>
 #include <vcl/IDialogRenderable.hxx>
+#include <vcl/abstdlg.hxx>
 
 struct DialogImpl;
 class VclBox;
@@ -45,6 +46,7 @@ public:
 
 private:
     VclPtr<Dialog>  mpPrevExecuteDlg;
+    VclPtr<Dialog>  mpNextExecuteDlg;
     std::unique_ptr<DialogImpl>     mpDialogImpl;
     long            mnMousePositioned;
     bool            mbInExecute;
@@ -57,6 +59,7 @@ private:
     VclPtr<VclButtonBox> mpActionArea;
     VclPtr<VclBox>       mpContentArea;
 
+    SAL_DLLPRIVATE void    RemoveFromDlgList();
     SAL_DLLPRIVATE void    ImplInitDialogData();
     SAL_DLLPRIVATE void    ImplInitSettings();
     SAL_DLLPRIVATE VclPtr<vcl::Window> AddBorderWindow(vcl::Window* pParent, WinBits nBits);
@@ -138,6 +141,20 @@ private:
     void            ImplSetModalInputMode(bool bModal);
 public:
 
+    // FIXME: Need to remove old StartExecuteModal in favour of this one.
+    /// Returns true of the dialog successfully starts
+    bool StartExecuteAsync(const std::function<void(sal_Int32)> &rEndDialogFn,
+                           VclPtr<VclReferenceBase> xOwner = VclPtr<VclReferenceBase>())
+    {
+        VclAbstractDialog::AsyncContext aCtx;
+        aCtx.mxOwner = xOwner;
+        aCtx.maEndDialogFn = rEndDialogFn;
+        return StartExecuteAsync(aCtx);
+    }
+
+    /// Commence execution of a modal dialog, disposes owner on failure
+    virtual bool    StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx);
+
     // Dialog::Execute replacement API
 
 
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index f167952383c8..842505f2b4b7 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -65,6 +65,7 @@ public:                                             \
                      {}                             \
     virtual         ~Class() override;                       \
     virtual short   Execute() override ;            \
+    virtual bool    StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; \
     std::vector<OString> getAllPageUIXMLDescriptions() const override; \
     bool selectPageByUIXMLDescription(const OString& rUIXMLDescription) override; \
     virtual Bitmap  createScreenshot() const override; \
@@ -78,6 +79,10 @@ short Class::Execute()                              \
 {                                                   \
     return pDlg->Execute();                         \
 }                                                   \
+bool Class::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx)\
+{ \
+    return pDlg->StartExecuteAsync( rCtx ); \
+} \
 std::vector<OString> Class::getAllPageUIXMLDescriptions() const \
 {                                                   \
     return pDlg->getAllPageUIXMLDescriptions();     \
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 74d82d65bc18..507471162ac0 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -478,8 +478,8 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName
 
     const ScPatternAttr*    pOldAttrs       = GetSelectionPattern();
 
-    std::unique_ptr<SfxItemSet> pOldSet(new SfxItemSet(pOldAttrs->GetItemSet()));
-    std::unique_ptr<SvxNumberInfoItem> pNumberInfoItem;
+    std::shared_ptr<SfxItemSet> pOldSet(new SfxItemSet(pOldAttrs->GetItemSet()));
+    std::shared_ptr<SvxNumberInfoItem> pNumberInfoItem;
 
     pOldSet->MergeRange(SID_ATTR_BORDER_STYLES, SID_ATTR_BORDER_DEFAULT_WIDTH);
 
@@ -537,28 +537,30 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName
     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
 
-    ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateScAttrDlg(GetDialogParent(), pOldSet.get()));
+    VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateScAttrDlg(GetDialogParent(), pOldSet.get()));
 
     if (!rName.isEmpty())
         pDlg->SetCurPageId(rName);
-    short nResult = pDlg->Execute();
-    bInFormatDialog = false;
 
-    if ( nResult == RET_OK )
-    {
-        const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+    std::shared_ptr<SfxRequest> pRequest(new SfxRequest(rReq));
+    pDlg->StartExecuteAsync([=](sal_Int32 nResult){
+            bInFormatDialog = false;
 
-        const SfxPoolItem* pItem=nullptr;
-        if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,true,&pItem)==SfxItemState::SET)
-        {
+            if ( nResult == RET_OK )
+            {
+                const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
 
-            UpdateNumberFormatter(static_cast<const SvxNumberInfoItem&>(*pItem));
-        }
+                const SfxPoolItem* pItem=nullptr;
+                if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,true,&pItem)==SfxItemState::SET)
+                {
+                    UpdateNumberFormatter(static_cast<const SvxNumberInfoItem&>(*pItem));
+                }
 
-        ApplyAttributes(pOutSet, pOldSet.get());
+                ApplyAttributes(pOutSet, pOldSet.get());
 
-        rReq.Done( *pOutSet );
-    }
+                pRequest->Done(pOutSet);
+            }
+        }, pDlg);
 }
 
 bool ScTabViewShell::IsRefInputMode() const
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index 2bd37d439613..d7e6e6af1346 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -155,6 +155,23 @@ SfxRequest::SfxRequest
         pImpl->SetPool( pArgs->GetPool() );
     else
         pImpl->SetPool( rOrig.pImpl->pPool );
+
+    // setup macro recording if it was in the original SfxRequest
+    if (rOrig.pImpl->pViewFrame && rOrig.pImpl->xRecorder.is())
+    {
+        nSlot = rOrig.nSlot;
+        pImpl->pViewFrame = rOrig.pImpl->pViewFrame;
+        if (pImpl->pViewFrame->GetDispatcher()->GetShellAndSlot_Impl(nSlot, &pImpl->pShell, &pImpl->pSlot, true, true))
+        {
+            pImpl->SetPool( &pImpl->pShell->GetPool() );
+            pImpl->xRecorder = SfxRequest::GetMacroRecorder(pImpl->pViewFrame);
+            pImpl->aTarget = pImpl->pShell->GetName();
+        }
+        else
+        {
+            SAL_WARN("sfx", "Recording unsupported slot: " << pImpl->pPool->GetSlotId(nSlot));
+        }
+    }
 }
 
 
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 784a0c274b45..d1c366490e88 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -518,22 +518,19 @@ short SfxTabDialog::Execute()
         return RET_CANCEL;
     Start_Impl();
 
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    if (comphelper::LibreOfficeKit::isActive() && pViewShell && !GetLOKNotifier())
-    {
-        SetLOKNotifier(pViewShell);
-        const Size aSize = GetOptimalSize();
-        std::vector<vcl::LOKPayloadItem> aItems;
-        aItems.emplace_back("type", "dialog");
-        aItems.emplace_back("size", aSize.toString());
-        if (!GetText().isEmpty())
-            aItems.emplace_back("title", GetText().toUtf8());
-        pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
-    }
-
     return TabDialog::Execute();
 }
 
+bool SfxTabDialog::StartExecuteAsync( VclAbstractDialog::AsyncContext &rCtx )
+{
+    if ( !m_pTabCtrl->GetPageCount() )
+    {
+        rCtx.mxOwner.disposeAndClear();
+        return false;
+    }
+    Start_Impl();
+    return TabDialog::StartExecuteAsync( rCtx );
+}
 
 void SfxTabDialog::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl )
 {
@@ -590,6 +587,20 @@ void SfxTabDialog::Start_Impl()
 
     m_pTabCtrl->SetCurPageId( nActPage );
     ActivatePageHdl( m_pTabCtrl );
+
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+
+    if (comphelper::LibreOfficeKit::isActive() && pViewShell && !GetLOKNotifier())
+    {
+        SetLOKNotifier(pViewShell);
+        const Size aSize = GetOptimalSize();
+        std::vector<vcl::LOKPayloadItem> aItems;
+        aItems.emplace_back("type", "dialog");
+        aItems.emplace_back("size", aSize.toString());
+        if (!GetText().isEmpty())
+            aItems.emplace_back("title", GetText().toUtf8());
+        pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
+    }
 }
 
 void SfxTabDialog::AddTabPage( sal_uInt16 nId, const OUString &rRiderText )
diff --git a/vcl/source/window/abstdlg.cxx b/vcl/source/window/abstdlg.cxx
index 807e75ead2d0..8ce6fd4221d6 100644
--- a/vcl/source/window/abstdlg.cxx
+++ b/vcl/source/window/abstdlg.cxx
@@ -58,6 +58,12 @@ VclAbstractDialog::~VclAbstractDialog()
 {
 }
 
+bool VclAbstractDialog::StartExecuteAsync(AsyncContext &)
+{
+    assert(false);
+    return false;
+}
+
 std::vector<OString> VclAbstractDialog::getAllPageUIXMLDescriptions() const
 {
     // default has no pages
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 5be7d2a01ed5..3d43c7750fd2 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -37,6 +37,7 @@
 #include <rtl/strbuf.hxx>
 #include <sal/log.hxx>
 
+#include <vcl/abstdlg.hxx>
 #include <vcl/builder.hxx>
 #include <vcl/layout.hxx>
 #include <vcl/svapp.hxx>
@@ -342,7 +343,7 @@ struct DialogImpl
 {
     long    mnResult;
     bool    mbStartedModal;
-    Link<Dialog&,void>  maEndDialogHdl;
+    VclAbstractDialog::AsyncContext maEndCtx;
 
     DialogImpl() : mnResult( -1 ), mbStartedModal( false ) {}
 };
@@ -351,6 +352,7 @@ void Dialog::ImplInitDialogData()
 {
     mpWindowImpl->mbDialog  = true;
     mpPrevExecuteDlg        = nullptr;
+    mpNextExecuteDlg        = nullptr;
     mbInExecute             = false;
     mbInClose               = false;
     mbModalMode             = false;
@@ -584,7 +586,9 @@ Dialog::~Dialog()
 void Dialog::dispose()
 {
     mpDialogImpl.reset();
+    RemoveFromDlgList();
     mpPrevExecuteDlg.clear();
+    mpNextExecuteDlg.clear();
     mpActionArea.clear();
     mpContentArea.clear();
 
@@ -781,7 +785,9 @@ bool Dialog::Close()
 
 bool Dialog::ImplStartExecuteModal()
 {
-    if ( mbInExecute )
+    setDeferredProperties();
+
+    if ( mbInExecute || mpDialogImpl->maEndCtx.isSet() )
     {
 #ifdef DBG_UTIL
         SAL_WARN( "vcl", "Dialog::StartExecuteModal() is called in Dialog::StartExecuteModal(): "
@@ -827,6 +833,8 @@ bool Dialog::ImplStartExecuteModal()
 
      // link all dialogs which are being executed
     mpPrevExecuteDlg = pSVData->maWinData.mpLastExecuteDlg;
+    if (mpPrevExecuteDlg)
+        mpPrevExecuteDlg->mpNextExecuteDlg = this;
     pSVData->maWinData.mpLastExecuteDlg = this;
 
     // stop capturing, in order to have control over the dialog
@@ -842,7 +850,9 @@ bool Dialog::ImplStartExecuteModal()
         GetParent()->CompatNotify( aNEvt );
     }
     mbInExecute = true;
-    SetModalInputMode(true);
+    // no real modality in LibreOfficeKit
+    if (!comphelper::LibreOfficeKit::isActive())
+        SetModalInputMode(true);
 
     // FIXME: no layouting, workaround some clipping issues
     ImplAdjustNWFSizes();
@@ -854,6 +864,13 @@ bool Dialog::ImplStartExecuteModal()
     Show(true, showFlags);
 
     pSVData->maAppData.mnModalMode++;
+
+    css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_QUERY_THROW);
+    css::document::DocumentEvent aObject;
+    aObject.EventName = "DialogExecute";
+    xEventBroadcaster->documentEventOccured(aObject);
+    UITestLogger::getInstance().log("DialogExecute");
+
     return true;
 }
 
@@ -914,21 +931,11 @@ Bitmap Dialog::createScreenshot()
 short Dialog::Execute()
 {
 #if HAVE_FEATURE_DESKTOP
-
-    setDeferredProperties();
+    VclPtr<vcl::Window> xWindow = this;
 
     if ( !ImplStartExecuteModal() )
         return 0;
 
-    VclPtr<vcl::Window> xWindow = this;
-
-    css::uno::Reference< css::uno::XComponentContext > xContext(
-            comphelper::getProcessComponentContext() );
-    css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_QUERY_THROW);
-    css::document::DocumentEvent aObject;
-    aObject.EventName = "DialogExecute";
-    xEventBroadcaster->documentEventOccured(aObject);
-    UITestLogger::getInstance().log("DialogExecute");
     // Yield util EndDialog is called or dialog gets destroyed
     // (the latter should not happen, but better safe than sorry
     while ( !xWindow->IsDisposed() && mbInExecute )
@@ -950,7 +957,8 @@ short Dialog::Execute()
 
     long nRet = mpDialogImpl->mnResult;
     mpDialogImpl->mnResult = -1;
-    return (short)nRet;
+
+    return static_cast<short>(nRet);
 
 #else
 
@@ -965,11 +973,44 @@ short Dialog::Execute()
 // virtual
 void Dialog::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl )
 {
+    VclAbstractDialog::AsyncContext aCtx;
+    VclPtr<Dialog> ref(this);
+    aCtx.maEndDialogFn = [ref,rEndDialogHdl](sal_Int32){ rEndDialogHdl.Call(*ref.get()); };
+    StartExecuteAsync(aCtx);
+}
+
+// virtual
+bool Dialog::StartExecuteAsync( VclAbstractDialog::AsyncContext &rCtx )
+{
     if ( !ImplStartExecuteModal() )
-        return;
+    {
+        rCtx.mxOwner.disposeAndClear();
+        return false;
+    }
 
-    mpDialogImpl->maEndDialogHdl = rEndDialogHdl;
+    mpDialogImpl->maEndCtx = rCtx;
     mpDialogImpl->mbStartedModal = true;
+
+    return true;
+}
+
+void Dialog::RemoveFromDlgList()
+{
+    // remove dialog from the list of dialogs which are being executed
+    ImplSVData* pSVData = ImplGetSVData();
+    if (pSVData->maWinData.mpLastExecuteDlg == this)
+    {
+        if (mpPrevExecuteDlg)
+            pSVData->maWinData.mpLastExecuteDlg = mpPrevExecuteDlg;
+        else
+            pSVData->maWinData.mpLastExecuteDlg = mpNextExecuteDlg;
+    }
+    if (mpPrevExecuteDlg)
+        mpPrevExecuteDlg->mpNextExecuteDlg = mpNextExecuteDlg;
+    if (mpNextExecuteDlg)
+        mpNextExecuteDlg->mpPrevExecuteDlg = mpPrevExecuteDlg;
+    mpPrevExecuteDlg.clear();
+    mpNextExecuteDlg.clear();
 }
 
 void Dialog::EndDialog( long nResult )
@@ -979,24 +1020,14 @@ void Dialog::EndDialog( long nResult )
 
     SetModalInputMode(false);
 
-    // remove dialog from the list of dialogs which are being executed
-    ImplSVData* pSVData = ImplGetSVData();
-    Dialog* pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
-    while ( pExeDlg )
-    {
-        if ( pExeDlg == this )
-        {
-            pSVData->maWinData.mpLastExecuteDlg = mpPrevExecuteDlg;
-            break;
-        }
-        pExeDlg = pExeDlg->mpPrevExecuteDlg;
-    }
+    RemoveFromDlgList();
+
     // set focus to previous modal dialogue if it is modal for
     // the same frame parent (or NULL)
     if( mpPrevExecuteDlg )
     {
         vcl::Window* pFrameParent = ImplGetFrameWindow()->ImplGetParent();
-        vcl::Window* pPrevFrameParent = mpPrevExecuteDlg->ImplGetFrameWindow()->ImplGetParent();
+        vcl::Window* pPrevFrameParent = mpPrevExecuteDlg->ImplGetFrameWindow()? mpPrevExecuteDlg->ImplGetFrameWindow()->ImplGetParent(): nullptr;
         if( ( !pFrameParent && !pPrevFrameParent ) ||
             ( pFrameParent && pPrevFrameParent && pFrameParent->ImplGetFrame() == pPrevFrameParent->ImplGetFrame() )
             )
@@ -1005,6 +1036,7 @@ void Dialog::EndDialog( long nResult )
         }
     }
     mpPrevExecuteDlg = nullptr;
+    mpNextExecuteDlg = nullptr;
 
     Hide();
     if ( GetParent() )
@@ -1018,16 +1050,18 @@ void Dialog::EndDialog( long nResult )
     if ( mpDialogImpl->mbStartedModal )
     {
         ImplEndExecuteModal();
-        if (mpDialogImpl->maEndDialogHdl.IsSet())
+        if (mpDialogImpl->maEndCtx.isSet())
         {
-            mpDialogImpl->maEndDialogHdl.Call( *this );
-            mpDialogImpl->maEndDialogHdl = Link<Dialog&,void>();
+            mpDialogImpl->maEndCtx.maEndDialogFn(nResult);
+            mpDialogImpl->maEndCtx.maEndDialogFn = nullptr;
         }
         mpDialogImpl->mbStartedModal = false;
         mpDialogImpl->mnResult = -1;
     }
     mbInExecute = false;
 
+    // Destroy ourselves (if we have a context with VclPtr owner)
+    mpDialogImpl->maEndCtx.mxOwner.disposeAndClear();
 }
 
 long Dialog::GetResult() const
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 20e7fde45c66..3aff52f67573 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -2494,6 +2494,8 @@ bool Window::IsCallHandlersOnInputDisabled() const
 
 void Window::EnableInput( bool bEnable, bool bChild )
 {
+    if (!mpWindowImpl)
+        return;
 
     bool bNotify = (bEnable != mpWindowImpl->mbInputDisabled);
     if ( mpWindowImpl->mpBorderWindow )
@@ -2557,6 +2559,9 @@ void Window::EnableInput( bool bEnable, bool bChild )
 
 void Window::EnableInput( bool bEnable, const vcl::Window* pExcludeWindow )
 {
+    if (!mpWindowImpl)
+        return;
+
     EnableInput( bEnable );
 
     // pExecuteWindow is the first Overlap-Frame --> if this
commit a1d6bb723907c0c5e0b1753f2e95724d16c67133
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Thu Jan 11 16:03:30 2018 +0100

    lok: sc: invalidate cached positions and row header on font resizing
    
    Change-Id: I9678d6bd730d09d1cc47a8633368c99abe1f9bd9
    Reviewed-on: https://gerrit.libreoffice.org/47762
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    (cherry picked from commit d5b38f415ba4e65012db4b9d01ea29a4ca3ffa08)

diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 5d5457b4e088..aaac0138287f 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -114,6 +114,12 @@ bool ScViewFunc::AdjustBlockHeight( bool bPaint, ScMarkData* pMarkData )
         aMarkedRows.emplace_back(nCurRow, nCurRow);
     }
 
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        SCCOLROW nStart = aMarkedRows[0].mnStart;
+        OnLOKSetWidthOrHeight(nStart, /*width: */ false);
+    }
+
     double nPPTX = GetViewData().GetPPTX();
     double nPPTY = GetViewData().GetPPTY();
     Fraction aZoomX = GetViewData().GetZoomX();
@@ -160,11 +166,19 @@ bool ScViewFunc::AdjustBlockHeight( bool bPaint, ScMarkData* pMarkData )
     if ( bPaint && bAnyChanged )
         pDocSh->UpdateOle(&GetViewData());
 
+    if (comphelper::LibreOfficeKit::isActive())
+        ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, GetViewData().GetTabNo());
+
     return bAnyChanged;
 }
 
 bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow )
 {
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        OnLOKSetWidthOrHeight(nStartRow, /*width: */ false);
+    }
+
     ScDocShell* pDocSh = GetViewData().GetDocShell();
     ScDocument& rDoc = pDocSh->GetDocument();
     SCTAB nTab = GetViewData().GetTabNo();
@@ -201,6 +215,9 @@ bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow )
         pDocSh->PostPaint( 0, nStartRow, nTab, MAXCOL, MAXROW, nTab,
                                             PaintPartFlags::Grid | PaintPartFlags::Left );
 
+    if (comphelper::LibreOfficeKit::isActive())
+        ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, GetViewData().GetTabNo());
+
     return bChanged;
 }
 
commit 0d60dfd81b81921aa38f75d33162e0ba6c0e510e
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Wed Jan 10 17:31:35 2018 +0100

    Revert "lok: sc: copy / paste confusion -- workaround"
    
    This reverts commit f0684222540b96d8366ce175c522b64472361b80.
    
    This workaround is no more needed because of commit 1b7a827
    
    Change-Id: Icd13b245d5965c2b2ece326f7f5705cf06cf1b64
    Reviewed-on: https://gerrit.libreoffice.org/47761
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>
    (cherry picked from commit 183fd9a58ae3eeb749b78e6f4ca5783c79b43acb)

diff --git a/sc/inc/clipparam.hxx b/sc/inc/clipparam.hxx
index 16555225d074..2e5dece711e8 100644
--- a/sc/inc/clipparam.hxx
+++ b/sc/inc/clipparam.hxx
@@ -26,8 +26,6 @@
 
 #include <vector>
 
-class SfxViewShell;
-
 /**
  * This struct stores general clipboard parameters associated with a
  * ScDocument instance created in clipboard mode.
@@ -40,7 +38,6 @@ struct ScClipParam
     Direction           meDirection;
     bool                mbCutMode;
     sal_uInt32          mnSourceDocID;
-    SfxViewShell*       mpSourceView;
     ScRangeListVector   maProtectedChartRangesVector;
 
     ScClipParam();
@@ -70,9 +67,6 @@ struct ScClipParam
 
     sal_uInt32 getSourceDocID() const { return mnSourceDocID; }
     void setSourceDocID( sal_uInt32 nVal ) { mnSourceDocID = nVal; }
-
-    SfxViewShell* getSourceView() const { return mpSourceView; }
-    void setSourceView( SfxViewShell* pSourceView ) { mpSourceView = pSourceView; }
 };
 
 #endif
diff --git a/sc/source/core/data/clipparam.cxx b/sc/source/core/data/clipparam.cxx
index c80521045691..51738c9532e3 100644
--- a/sc/source/core/data/clipparam.cxx
+++ b/sc/source/core/data/clipparam.cxx
@@ -23,16 +23,14 @@
 ScClipParam::ScClipParam() :
     meDirection(Unspecified),
     mbCutMode(false),
-    mnSourceDocID(0),
-    mpSourceView(nullptr)
+    mnSourceDocID(0)
 {
 }
 
 ScClipParam::ScClipParam(const ScRange& rRange, bool bCutMode) :
     meDirection(Unspecified),
     mbCutMode(bCutMode),
-    mnSourceDocID(0),
-    mpSourceView(nullptr)
+    mnSourceDocID(0)
 {
     maRanges.Append(rRange);
 }
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index dd038f35e242..2c50bdfff97b 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -227,14 +227,6 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b
             // and lose the 'if' above
             aClipParam.setSourceDocID( pDoc->GetDocumentID() );
 
-            // This is only a workaround, which doesn't allow to paste content
-            // in one view which has been copied in a different view.
-            // TODO: implement a solution providing one clipboard per view
-            if (comphelper::LibreOfficeKit::isActive())
-            {
-                aClipParam.setSourceView(GetViewData().GetViewShell());
-            }
-
             if (SfxObjectShell* pObjectShell = pDoc->GetDocumentShell())
             {
                 // Copy document properties from pObjectShell to pClipDoc (to its clip options, as it has no object shell).
@@ -875,20 +867,6 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc,
     if (GetViewData().SelectionForbidsCellFill())
         return false;
 
-    // This is only a workaround, which doesn't allow to paste content
-    // in one view which has been copied in a different view.
-    // TODO: implement a solution providing one clipboard per view
-    if (comphelper::LibreOfficeKit::isActive())
-    {
-        ScTabViewShell* pThisView = GetViewData().GetViewShell();
-        ScTabViewShell* pSourceView = dynamic_cast<ScTabViewShell*>(pClipDoc->GetClipParam().getSourceView());
-
-        if (pThisView && pSourceView && pThisView != pSourceView)
-        {
-            return false;
-        }
-    }
-
     //  undo: save all or no content
     InsertDeleteFlags nContFlags = InsertDeleteFlags::NONE;
     if (nFlags & InsertDeleteFlags::CONTENTS)
commit 97a170e0fd06a7968fd23db931cd01f99a5c36cd
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Sun Jan 7 16:54:47 2018 +0100

    lok: sc: exploiting cached position helper for tile rendering
    
    Change-Id: I02b21c5979d1dfb6bb60a05d891c632602fb44ee
    Reviewed-on: https://gerrit.libreoffice.org/47540
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    (cherry picked from commit dee9ccaef8a01e7eb68f8d20210060c49fa6feaa)

diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 889df879a665..04e0dd81388e 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -148,6 +148,58 @@ public:
     long getPosition(index_type nIndex) const;
 };
 
+class ScBoundsProvider
+{
+    typedef ScPositionHelper::value_type value_type;
+    typedef SCCOLROW index_type;
+
+    ScDocument* pDoc;
+    const SCTAB nTab;
+    const bool bColumnHeader;
+    const index_type MAX_INDEX;
+
+    index_type nFirstIndex;
+    index_type nSecondIndex;
+    long nFirstPositionPx;
+    long nSecondPositionPx;
+
+public:
+    ScBoundsProvider(ScDocument* pD, SCTAB nT, bool bColumnHeader);
+
+    void GetStartIndexAndPosition(SCCOL& nIndex, long& nPosition) const;
+    void GetEndIndexAndPosition(SCCOL& nIndex, long& nPosition) const;
+    void GetStartIndexAndPosition(SCROW& nIndex, long& nPosition) const;
+    void GetEndIndexAndPosition(SCROW& nIndex, long& nPosition) const;
+
+    void Compute(value_type aFirstNearest, value_type aSecondNearest,
+                 long nFirstBound, long nSecondBound);
+
+    void EnlargeStartBy(long nOffset);
+
+    void EnlargeEndBy(long nOffset);
+
+    void EnlargeBy(long nOffset)
+    {
+        EnlargeStartBy(nOffset);
+        EnlargeEndBy(nOffset);
+    }
+
+private:
+    long GetSize(index_type nIndex) const;
+
+    void GetIndexAndPos(index_type nNearestIndex, long nNearestPosition,
+                        long nBound, index_type& nFoundIndex, long& nPosition,
+                        bool bTowards, long nDiff);
+
+    void GeIndexBackwards(index_type nNearestIndex, long nNearestPosition,
+                          long nBound, index_type& nFoundIndex, long& nPosition,
+                          bool bTowards);
+
+    void GetIndexTowards(index_type nNearestIndex, long nNearestPosition,
+                         long nBound, index_type& nFoundIndex, long& nPosition,
+                         bool bTowards);
+};
+
 class ScViewDataTable                           // per-sheet data
 {
 friend class ScViewData;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 92b0eee6cc96..955c7d13783c 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1048,41 +1048,41 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
         mpNoteMarker->Draw(); // Above the cursor, in drawing map mode
 }
 
-namespace {
-    // Find the row/col just -before- the nPosition in pixels and its offset
-    inline void mapConservativeToRowCol(const ScDocument *pDoc,
-                                        sal_Int32  *nIndex,
-                                        sal_Int32  *nOffset,
-                                        sal_Int32  *nOrigin,
-                                        sal_Int32   nTabNo,
-                                        sal_Int32   nPosition,
-                                        bool        bRowNotCol,
-                                        double      nPPTX,
-                                        double      nPPTY)
+namespace
+{
+    template<typename IndexType>
+    inline
+    void lcl_getBoundingRowColumnforTile(ScViewData* pViewData,
+            long nTileStartPosPx, long nTileEndPosPx,
+            sal_Int32& nTopLeftTileOffset, sal_Int32& nTopLeftTileOrigin,
+            sal_Int32& nTopLeftTileIndex, sal_Int32& nBottomRightTileIndex)
     {
-        long nTmp = 0; // row/col to render for nPosition
-        long nLastScrPos = 0, nScrPos = 0;
-        const long nMaxIndex = bRowNotCol ? MAXROW : MAXCOL;
-        while (nScrPos <= nPosition && nTmp < nMaxIndex)
-        {
-            long nSize = bRowNotCol ? pDoc->GetRowHeight( nTmp, nTabNo )
-                                    : pDoc->GetColWidth( nTmp, nTabNo );
-            if (nSize)
-            {
-                nLastScrPos = nScrPos;
-                nScrPos += ScViewData::ToPixel( nSize, bRowNotCol ? nPPTY : nPPTX );
-            } // else - FIXME 'skip multiple hidden rows'
+        const bool bColumnHeader = std::is_same<IndexType, SCCOL>::value;
 
-            *nIndex = nTmp;
-            nTmp++;
-        }
+        SCTAB nTab = pViewData->GetTabNo();
+        ScDocument* pDoc = pViewData->GetDocument();
 
-        // offset into that row/col for nPosition
-        assert (nPosition >= nLastScrPos);
-        *nOffset = (nScrPos == nPosition ? 0 : nPosition - nLastScrPos);
-        *nOrigin = nLastScrPos;
+        IndexType nStartIndex = -1;
+        IndexType nEndIndex = -1;
+        long nStartPosPx = 0;
+        long nEndPosPx = 0;
+
+        ScPositionHelper& rPositionHelper =
+                bColumnHeader ? pViewData->GetLOKWidthHelper() : pViewData->GetLOKHeightHelper();
+        const auto& rStartNearest = rPositionHelper.getNearestByPosition(nTileStartPosPx);
+        const auto& rEndNearest = rPositionHelper.getNearestByPosition(nTileEndPosPx);
+
+        ScBoundsProvider aBoundsProvider(pDoc, nTab, bColumnHeader);
+        aBoundsProvider.Compute(rStartNearest, rEndNearest, nTileStartPosPx, nTileEndPosPx);
+        aBoundsProvider.GetStartIndexAndPosition(nStartIndex, nStartPosPx); ++nStartIndex;
+        aBoundsProvider.GetEndIndexAndPosition(nEndIndex, nEndPosPx);
+
+        nTopLeftTileOffset = nTileStartPosPx - nStartPosPx;
+        nTopLeftTileOrigin = nStartPosPx;
+        nTopLeftTileIndex = nStartIndex;
+        nBottomRightTileIndex = nEndIndex;
     }
-}
+} // anonymous namespace
 
 void ScGridWindow::PaintTile( VirtualDevice& rDevice,
                               int nOutputWidth, int nOutputHeight,
@@ -1121,31 +1121,37 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     const double fPPTX = pViewData->GetPPTX();
     const double fPPTY = pViewData->GetPPTY();
 
+    // find approximate col/row offsets of nearby.
     sal_Int32 nTopLeftTileRowOffset = 0;
     sal_Int32 nTopLeftTileColOffset = 0;
     sal_Int32 nTopLeftTileRowOrigin = 0;
     sal_Int32 nTopLeftTileColOrigin = 0;
 
-    // find approximate col/row offsets of nearby.
     sal_Int32 nTopLeftTileRow = 0;
     sal_Int32 nTopLeftTileCol = 0;
     sal_Int32 nBottomRightTileRow = 0;
     sal_Int32 nBottomRightTileCol = 0;
-    sal_Int32 nDummy;
-    mapConservativeToRowCol(pDoc, &nTopLeftTileCol, &nTopLeftTileColOffset,
-                            &nTopLeftTileColOrigin,
-                            nTab, fTilePosXPixel, false, fPPTX, fPPTY);
-    mapConservativeToRowCol(pDoc, &nBottomRightTileCol, &nDummy, &nDummy, nTab,
-                            fTileRightPixel, false, fPPTX, fPPTY);
-    mapConservativeToRowCol(pDoc, &nTopLeftTileRow, &nTopLeftTileRowOffset,
-                            &nTopLeftTileRowOrigin,
-                            nTab, fTilePosYPixel, true, fPPTX, fPPTY);
-    mapConservativeToRowCol(pDoc, &nBottomRightTileRow, &nDummy, &nDummy, nTab,
-                            fTileBottomPixel, true, fPPTX, fPPTY);
+
+    lcl_getBoundingRowColumnforTile<SCROW>(pViewData,
+            fTilePosYPixel, fTileBottomPixel,
+            nTopLeftTileRowOffset, nTopLeftTileRowOrigin,
+            nTopLeftTileRow, nBottomRightTileRow);
+
+    lcl_getBoundingRowColumnforTile<SCCOL>(pViewData,
+            fTilePosXPixel, fTileRightPixel,
+            nTopLeftTileColOffset, nTopLeftTileColOrigin,
+            nTopLeftTileCol, nBottomRightTileCol);
+
     // Enlarge
     nBottomRightTileCol++;
     nBottomRightTileRow++;
 
+    if (nBottomRightTileCol > MAXCOL)
+        nBottomRightTileCol = MAXCOL;
+
+    if (nBottomRightTileRow > MAXTILEDROW)
+        nBottomRightTileRow = MAXTILEDROW;
+
     // size of the document including drawings, charts, etc.
     SCCOL nEndCol = 0;
     SCROW nEndRow = 0;
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 826679b34d6f..e2200fcf5323 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2327,249 +2327,6 @@ long lcl_GetColWidthPx(const ScDocument* pDoc, SCCOL nCol, SCTAB nTab)
     return ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
 }
 
-} // anonymous namespace
-
-template<typename IndexType>
-class BoundsProvider
-{
-    typedef ScPositionHelper::value_type value_type;
-    typedef IndexType index_type;
-
-    static const index_type MAX_INDEX;
-
-    ScDocument* pDoc;
-    const SCTAB nTab;
-
-    index_type nFirstIndex;
-    index_type nSecondIndex;
-    long nFirstPositionPx;
-    long nSecondPositionPx;
-
-public:
-    BoundsProvider(ScDocument* pD, SCTAB nT)
-        : pDoc(pD)
-        , nTab(nT)
-        , nFirstIndex(-1)
-        , nSecondIndex(-1)
-        , nFirstPositionPx(-1)
-        , nSecondPositionPx(-1)
-    {}
-
-    void GetStartIndexAndPosition(index_type& nIndex, long& nPosition) const
-    {
-        nIndex = nFirstIndex;
-        nPosition = nFirstPositionPx;
-    }
-
-    void GetEndIndexAndPosition(index_type& nIndex, long& nPosition) const
-    {
-        nIndex = nSecondIndex;
-        nPosition = nSecondPositionPx;
-    }
-
-    void Compute(value_type aFirstNearest, value_type aSecondNearest,
-                 long nFirstBound, long nSecondBound);
-
-    void EnlargeStartBy(long nOffset);
-
-    void EnlargeEndBy(long nOffset);
-
-    void EnlargeBy(long nOffset)
-    {
-        EnlargeStartBy(nOffset);
-        EnlargeEndBy(nOffset);
-    }
-
-private:
-    long GetSize(SCROW nIndex) const
-    {
-        return lcl_GetRowHeightPx(pDoc, nIndex, nTab);
-    }
-
-    long GetSize(SCCOL nIndex) const
-    {
-        return lcl_GetColWidthPx(pDoc, nIndex, nTab);
-    }
-
-    void GetIndexAndPos(index_type nNearestIndex, long nNearestPosition,
-                        long nBound, index_type& nFoundIndex, long& nPosition,
-                        bool bTowards, long nDiff)
-    {
-        if (nDiff > 0) // nBound < nNearestPosition
-            GeIndexBackwards(nNearestIndex, nNearestPosition, nBound,
-                             nFoundIndex, nPosition, bTowards);
-        else
-            GetIndexTowards(nNearestIndex, nNearestPosition, nBound,
-                            nFoundIndex, nPosition, bTowards);
-    }
-
-    void GeIndexBackwards(index_type nNearestIndex, long nNearestPosition,
-                          long nBound, index_type& nFoundIndex, long& nPosition,
-                          bool bTowards);
-
-    void GetIndexTowards(index_type nNearestIndex, long nNearestPosition,
-                         long nBound, index_type& nFoundIndex, long& nPosition,
-                         bool bTowards);
-};
-
-template<typename IndexType>
-const IndexType BoundsProvider<IndexType>::MAX_INDEX;
-
-template<>
-const SCROW BoundsProvider<SCROW>::MAX_INDEX = MAXTILEDROW;
-
-template<>
-const SCCOL BoundsProvider<SCCOL>::MAX_INDEX = MAXCOL;
-
-template<typename IndexType>
-void BoundsProvider<IndexType>::Compute(
-            value_type aFirstNearest, value_type aSecondNearest,
-            long nFirstBound, long nSecondBound)
-{
-    SAL_INFO("sc.lok.header", "BoundsProvider: nFirstBound: " << nFirstBound
-            << ", nSecondBound: " << nSecondBound);
-
-    long nFirstDiff = aFirstNearest.second - nFirstBound;
-    long nSecondDiff = aSecondNearest.second - nSecondBound;
-    SAL_INFO("sc.lok.header", "BoundsProvider: rTopNearest: index: " << aFirstNearest.first
-            << ", pos: " << aFirstNearest.second << ", diff: " << nFirstDiff);
-    SAL_INFO("sc.lok.header", "BoundsProvider: rBottomNearest: index: " << aSecondNearest.first
-            << ", pos: " << aSecondNearest.second << ", diff: " << nSecondDiff);
-
-    bool bReverse = (std::abs(nFirstDiff) >= std::abs(nSecondDiff));
-
-    if(bReverse)
-    {
-        std::swap(aFirstNearest, aSecondNearest);
-        std::swap(nFirstBound, nSecondBound);
-        std::swap(nFirstDiff, nSecondDiff);
-    }
-
-    index_type nNearestIndex = aFirstNearest.first;
-    long nNearestPosition = aFirstNearest.second;
-    SAL_INFO("sc.lok.header", "BoundsProvider: nearest to first bound:  nNearestIndex: "
-            << nNearestIndex << ", nNearestPosition: " << nNearestPosition);
-
-    GetIndexAndPos(nNearestIndex, nNearestPosition, nFirstBound,
-                   nFirstIndex, nFirstPositionPx, !bReverse, nFirstDiff);
-    SAL_INFO("sc.lok.header", "BoundsProvider: nFirstIndex: " << nFirstIndex
-            << ", nFirstPositionPx: " << nFirstPositionPx);
-
-    if (std::abs(nSecondDiff) < std::abs(nSecondBound - nFirstPositionPx))
-    {
-        nNearestIndex = aSecondNearest.first;
-        nNearestPosition = aSecondNearest.second;
-    }
-    else
-    {
-        nNearestPosition = nFirstPositionPx;
-        nNearestIndex = nFirstIndex;
-        nSecondDiff = !bReverse ? -1 : 1;
-    }
-    SAL_INFO("sc.lok.header", "BoundsProvider: nearest to second bound: nNearestIndex: "
-            << nNearestIndex << ", nNearestPosition: " << nNearestPosition
-            << ", diff: " << nSecondDiff);
-
-    GetIndexAndPos(nNearestIndex, nNearestPosition, nSecondBound,
-                   nSecondIndex, nSecondPositionPx, bReverse, nSecondDiff);
-    SAL_INFO("sc.lok.header", "BoundsProvider: nSecondIndex: " << nSecondIndex
-            << ", nSecondPositionPx: " << nSecondPositionPx);
-
-    if (bReverse)
-    {
-        std::swap(nFirstIndex, nSecondIndex);
-        std::swap(nFirstPositionPx, nSecondPositionPx);
-    }
-}
-
-template<typename IndexType>
-void BoundsProvider<IndexType>::EnlargeStartBy(long nOffset)
-{
-    const index_type nNewFirstIndex =
-            std::max(static_cast<index_type>(-1),
-                     static_cast<index_type>(nFirstIndex - nOffset));
-    for (index_type nIndex = nFirstIndex; nIndex > nNewFirstIndex; --nIndex)
-    {
-        const long nSizePx = GetSize(nIndex);
-        nFirstPositionPx -= nSizePx;
-    }
-    nFirstIndex = nNewFirstIndex;
-    SAL_INFO("sc.lok.header", "BoundsProvider: added offset: nFirstIndex: " << nFirstIndex
-            << ", nFirstPositionPx: " << nFirstPositionPx);
-}
-
-template<typename IndexType>
-void BoundsProvider<IndexType>::EnlargeEndBy(long nOffset)
-{

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list