[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 42 commits - basic/source canvas/source chart2/source comphelper/source cui/source desktop/qa desktop/source include/comphelper include/LibreOfficeKit include/rtl include/sfx2 include/svx include/vcl instsetoo_native/inc_ooohelppack instsetoo_native/inc_openoffice instsetoo_native/inc_sdkoo libreofficekit/qa libreofficekit/source sal/qa sal/rtl sal/util sc/inc scp2/source sc/qa sc/source sfx2/source shell/Library_syssh.mk shell/source svx/source sw/CppunitTest_sw_uibase_unit.mk sw/inc sw/Module_sw.mk sw/qa sw/source vcl/source writerfilter/source

Pranav Kant pranavk at collabora.co.uk
Mon Mar 19 20:20:33 UTC 2018


 basic/source/classes/sbunoobj.cxx                                   |    5 
 canvas/source/cairo/cairo_canvashelper.cxx                          |    2 
 canvas/source/tools/canvastools.cxx                                 |    2 
 chart2/source/view/charttypes/BarChart.cxx                          |   19 
 chart2/source/view/main/ShapeFactory.cxx                            |  275 +++++-----
 comphelper/source/misc/lok.cxx                                      |   27 
 cui/source/tabpages/numpages.cxx                                    |   17 
 desktop/qa/desktop_lib/test_desktop_lib.cxx                         |   68 ++
 desktop/source/lib/init.cxx                                         |   32 -
 include/LibreOfficeKit/LibreOfficeKit.h                             |    9 
 include/LibreOfficeKit/LibreOfficeKit.hxx                           |   11 
 include/LibreOfficeKit/LibreOfficeKitEnums.h                        |   39 +
 include/comphelper/lok.hxx                                          |   11 
 include/rtl/alloc.h                                                 |   37 +
 include/sfx2/lokhelper.hxx                                          |    2 
 include/sfx2/viewsh.hxx                                             |    5 
 include/svx/scene3d.hxx                                             |    5 
 include/svx/svdobj.hxx                                              |    3 
 include/vcl/menu.hxx                                                |    3 
 include/vcl/window.hxx                                              |    7 
 instsetoo_native/inc_ooohelppack/windows/msi_templates/InstallE.idt |    3 
 instsetoo_native/inc_openoffice/windows/msi_templates/AdminExe.idt  |    1 
 instsetoo_native/inc_openoffice/windows/msi_templates/AdvtExec.idt  |    1 
 instsetoo_native/inc_openoffice/windows/msi_templates/CustomAc.idt  |    1 
 instsetoo_native/inc_openoffice/windows/msi_templates/InstallE.idt  |   16 
 instsetoo_native/inc_openoffice/windows/msi_templates/InstallU.idt  |    2 
 instsetoo_native/inc_sdkoo/windows/msi_templates/InstallE.idt       |    3 
 libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx |    9 
 libreofficekit/source/gtk/lokdocview.cxx                            |   46 +
 sal/qa/rtl/alloc/rtl_alloc.cxx                                      |   70 ++
 sal/rtl/alloc_arena.cxx                                             |   28 +
 sal/rtl/alloc_arena.hxx                                             |    5 
 sal/rtl/alloc_cache.cxx                                             |   18 
 sal/rtl/strimp.cxx                                                  |   65 ++
 sal/rtl/strimp.hxx                                                  |   10 
 sal/rtl/string.cxx                                                  |    6 
 sal/rtl/strtmpl.cxx                                                 |    4 
 sal/rtl/ustring.cxx                                                 |    8 
 sal/util/sal.map                                                    |    5 
 sc/inc/conditio.hxx                                                 |   11 
 sc/inc/strings.hrc                                                  |    1 
 sc/qa/unit/ucalc.hxx                                                |    2 
 sc/qa/unit/ucalc_condformat.cxx                                     |   76 ++
 sc/source/core/data/conditio.cxx                                    |   78 +-
 sc/source/core/data/table2.cxx                                      |   24 
 sc/source/filter/xml/xmlcondformat.cxx                              |    2 
 sc/source/ui/docshell/dbdocfun.cxx                                  |   16 
 sc/source/ui/docshell/olinefun.cxx                                  |   85 ++-
 sc/source/ui/inc/dbfunc.hxx                                         |    2 
 sc/source/ui/inc/printfun.hxx                                       |   35 +
 sc/source/ui/inc/tabview.hxx                                        |    9 
 sc/source/ui/inc/tabvwsh.hxx                                        |    8 
 sc/source/ui/undo/undoblk2.cxx                                      |    4 
 sc/source/ui/undo/undodat.cxx                                       |   14 
 sc/source/ui/unoobj/docuno.cxx                                      |    4 
 sc/source/ui/view/dbfunc.cxx                                        |    2 
 sc/source/ui/view/dbfunc3.cxx                                       |   13 
 sc/source/ui/view/gridwin.cxx                                       |   20 
 sc/source/ui/view/printfun.cxx                                      |   61 +-
 sc/source/ui/view/tabview.cxx                                       |   18 
 sc/source/ui/view/tabview4.cxx                                      |    5 
 sc/source/ui/view/tabvwshc.cxx                                      |   25 
 sc/source/ui/view/viewfunc.cxx                                      |    4 
 scp2/source/ooo/windowscustomaction_ooo.scp                         |    4 
 sfx2/source/appl/openuriexternally.cxx                              |   15 
 sfx2/source/appl/sfxhelp.cxx                                        |   26 
 sfx2/source/dialog/basedlgs.cxx                                     |   40 -
 sfx2/source/dialog/tabdlg.cxx                                       |    6 
 sfx2/source/view/lokhelper.cxx                                      |   17 
 sfx2/source/view/viewsh.cxx                                         |    1 
 shell/Library_syssh.mk                                              |    1 
 shell/source/unix/exec/shellexec.cxx                                |    7 
 svx/source/dialog/fntctrl.cxx                                       |   34 -
 svx/source/engine3d/scene3d.cxx                                     |   17 
 svx/source/svdraw/svdobj.cxx                                        |    5 
 svx/source/svdraw/svdpage.cxx                                       |    1 
 sw/CppunitTest_sw_uibase_unit.mk                                    |   31 +
 sw/Module_sw.mk                                                     |    4 
 sw/inc/dbmgr.hxx                                                    |   17 
 sw/inc/textboxhelper.hxx                                            |    2 
 sw/qa/extras/ooxmlexport/data/parasplit-on-section-border.odt       |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx                          |   13 
 sw/qa/extras/rtfexport/data/tdf114333.rtf                           |    5 
 sw/qa/extras/rtfexport/data/tdf97035.rtf                            |    2 
 sw/qa/extras/rtfexport/rtfexport2.cxx                               |    4 
 sw/qa/extras/rtfexport/rtfexport3.cxx                               |   12 
 sw/qa/extras/rtfimport/rtfimport.cxx                                |    7 
 sw/qa/unit/uibase.cxx                                               |   44 +
 sw/source/core/doc/doclay.cxx                                       |    5 
 sw/source/core/doc/textboxhelper.cxx                                |   21 
 sw/source/core/docnode/nodes.cxx                                    |   82 +-
 sw/source/core/draw/dflyobj.cxx                                     |    6 
 sw/source/core/frmedt/feshview.cxx                                  |    2 
 sw/source/core/inc/dflyobj.hxx                                      |    2 
 sw/source/core/objectpositioning/anchoredobjectposition.cxx         |    2 
 sw/source/filter/ww8/rtfattributeoutput.cxx                         |   21 
 sw/source/filter/ww8/wrtw8nds.cxx                                   |   26 
 sw/source/uibase/dbui/dbmgr.cxx                                     |   18 
 vcl/source/window/dialog.cxx                                        |    4 
 vcl/source/window/floatwin.cxx                                      |   12 
 vcl/source/window/menu.cxx                                          |   97 +++
 vcl/source/window/menubarwindow.cxx                                 |   64 ++
 vcl/source/window/menubarwindow.hxx                                 |    1 
 vcl/source/window/menufloatingwindow.cxx                            |    4 
 vcl/source/window/menuitemlist.hxx                                  |    3 
 vcl/source/window/window.cxx                                        |   47 -
 writerfilter/source/rtftok/rtfdispatchsymbol.cxx                    |    5 
 writerfilter/source/rtftok/rtfdispatchvalue.cxx                     |    8 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx                      |    8 
 writerfilter/source/rtftok/rtfdocumentimpl.hxx                      |    4 
 110 files changed, 1592 insertions(+), 564 deletions(-)

New commits:
commit fb51e433f8991c9a50fcd53e2845538a5710c776
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Dec 21 13:20:26 2017 +0530

    lokdocview: Handle INVALIDATE_HEADER cb
    
    With this calc gtktiledviewer or any other lok client shouldn't crash
    anymore when a new view is opened.
    
    And while at it, update documentation of callbacks.
    
    (cherry picked from commit 71cd37fad9792038279969c82e0cb209df06f024)
    
    Change-Id: I436c3b424dd4e2e6b8c312b0d3ba43d7006e944b

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index dc5f82d2f1e2..46be3f25fea8 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -540,7 +540,32 @@ typedef enum
      */
     LOK_CALLBACK_RULER_UPDATE = 35,
     /**
-     * Dialog invalidation
+     * Window related callbacks are emitted under this category. It includes
+     * external windows like dialogs, autopopups for now.
+     *
+     * The payload format is:
+     *
+     * {
+     *    "id": "unique integer id of the dialog",
+     *    "action": "<see below>",
+     *    "type": "<see below>"
+     *    "rectangle": "x, y, width, height"
+     * }
+     *
+     * "type" tells the type of the window the action is associated with
+     *  - "dialog" - window is a dialog
+     *  - "child" - window is a floating window (combo boxes, etc.)
+     *
+     * "action" can take following values:
+     * - "created" - window is created in the backend, client can render it now
+     * - "title_changed" - window's title is changed
+     * - "size_changed" - window's size is changed
+     * - "invalidate" - the area as described by "rectangle" is invalidated
+     *    Clients must request the new area
+     * - "cursor_invalidate" - cursor is invalidated. New position is in "rectangle"
+     * - "cursor_visible" - cursor visible status is changed. Status is availabe
+     *    in "visible" field
+     * - "close" - window is closed
      */
     LOK_CALLBACK_WINDOW = 36,
 }
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 01873f516bb0..5243e3887514 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -3247,9 +3247,32 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
                      G_TYPE_STRING);
 
     /**
-     * LOKDocView::window
-     * @pDocView: the #LOKDocView on which the signal is emitted
-     * @pPayload: JSON containing the information, including id, about the window
+     * Window related callbacks are emitted under this category. It includes
+     * external windows like dialogs, autopopups for now.
+     *
+     * The payload format is:
+     *
+     * {
+     *    "id": "unique integer id of the dialog",
+     *    "action": "<see below>",
+     *    "type": "<see below>"
+     *    "rectangle": "x, y, width, height"
+     * }
+     *
+     * "type" tells the type of the window the action is associated with
+     *  - "dialog" - window is a dialog
+     *  - "child" - window is a floating window (combo boxes, etc.)
+     *
+     * "action" can take following values:
+     * - "created" - window is created in the backend, client can render it now
+     * - "title_changed" - window's title is changed
+     * - "size_changed" - window's size is changed
+     * - "invalidate" - the area as described by "rectangle" is invalidated
+     *    Clients must request the new area
+     * - "cursor_invalidate" - cursor is invalidated. New position is in "rectangle"
+     * - "cursor_visible" - cursor visible status is changed. Status is availabe
+     *    in "visible" field
+     * - "close" - window is closed
      */
     doc_view_signals[WINDOW] =
         g_signal_new("window",
@@ -3260,6 +3283,23 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
                      g_cclosure_marshal_generic,
                      G_TYPE_NONE, 1,
                      G_TYPE_STRING);
+
+    /**
+     * The column/row header is no more valid because of a column/row insertion
+     * or a similar event. Clients must query a new column/row header set.
+     *
+     * The payload says if we are invalidating a row or column header. So,
+     * payload values can be: "row", "column", "all".
+     */
+    doc_view_signals[INVALIDATE_HEADER] =
+        g_signal_new("invalidate-header",
+                     G_TYPE_FROM_CLASS(pGObjectClass),
+                     G_SIGNAL_RUN_FIRST,
+                     0,
+                     nullptr, nullptr,
+                     g_cclosure_marshal_generic,
+                     G_TYPE_NONE, 1,
+                     G_TYPE_STRING);
 }
 
 SAL_DLLPUBLIC_EXPORT GtkWidget*
commit d2e79cfbb188d6402dbcfc7bd71886f6d2252727
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Dec 19 10:42:40 2017 +0100

    Don't use -I$(SRCDIR), people have various strange stuff in the SRCDIR.
    
    For me, the build failed because of a file named 'new' ;-)
    
    Change-Id: I1816ff16b1b76a833ded2b6f332553b768916cad
    Reviewed-on: https://gerrit.libreoffice.org/46776
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    (cherry picked from commit fadbccc3176044b3642716f5b388a793165da05a)

diff --git a/sal/CppunitTest_sal_rtl.mk b/sal/CppunitTest_sal_rtl.mk
index c4629a2c33db..43533fc5ab1c 100644
--- a/sal/CppunitTest_sal_rtl.mk
+++ b/sal/CppunitTest_sal_rtl.mk
@@ -54,7 +54,6 @@ $(eval $(call gb_CppunitTest_use_libraries,sal_rtl,\
 
 $(eval $(call gb_CppunitTest_set_include,sal_rtl,\
 	-I$(SRCDIR)/sal/qa/inc \
-	-I$(SRCDIR) \
 	$$(INCLUDE) \
 ))
 
diff --git a/sal/qa/rtl/alloc/rtl_alloc.cxx b/sal/qa/rtl/alloc/rtl_alloc.cxx
index 6a4c1648ff53..0e9b7c0f47a8 100644
--- a/sal/qa/rtl/alloc/rtl_alloc.cxx
+++ b/sal/qa/rtl/alloc/rtl_alloc.cxx
@@ -24,7 +24,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 #include <cppunit/plugin/TestPlugIn.h>
 
-#include <sal/rtl/strimp.hxx>
+#include "../../../rtl/strimp.hxx"
 
 #include <memory.h>
 
commit 1372021878beec8145efa2e41d61a3c83ac3841f
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Dec 20 17:58:05 2017 +0530

    lokdialog: Use Application::Post{Mouse,Key}Event() to post to main thread
    
    ... instead of custom machinery there to post to main thread. This also
    now posts window key events to the main thread instead of processing
    them on the lok thread.
    
    Change-Id: Ided1efb3f237a1838fa50bb8d74752be714c3032
    (cherry picked from commit ace646b20ee88fdca2780365039e90cb1542262b)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 670032a18211..f87caa5b0787 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -73,6 +73,7 @@
 #include <svx/ruler.hxx>
 #include <svx/svxids.hrc>
 #include <svx/ucsubset.hxx>
+#include <vcl/vclevent.hxx>
 #include <vcl/svapp.hxx>
 #include <unotools/resmgr.hxx>
 #include <tools/fract.hxx>
@@ -2269,10 +2270,10 @@ static void doc_postWindowKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned n
     switch (nType)
     {
         case LOK_KEYEVENT_KEYINPUT:
-            pWindow->LOKKeyInput(aEvent);
+            Application::PostKeyEvent(VclEventId::WindowKeyInput, pWindow, &aEvent);
             break;
         case LOK_KEYEVENT_KEYUP:
-            pWindow->LOKKeyUp(aEvent);
+            Application::PostKeyEvent(VclEventId::WindowKeyUp, pWindow, &aEvent);
             break;
         default:
             assert(false);
@@ -2449,13 +2450,13 @@ static void doc_postWindowMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned
     switch (nType)
     {
         case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
-            pWindow->LogicMouseButtonDown(aEvent);
+            Application::PostMouseEvent(VclEventId::WindowMouseButtonDown, pWindow, &aEvent);
             break;
         case LOK_MOUSEEVENT_MOUSEBUTTONUP:
-            pWindow->LogicMouseButtonUp(aEvent);
+            Application::PostMouseEvent(VclEventId::WindowMouseButtonUp, pWindow, &aEvent);
             break;
         case LOK_MOUSEEVENT_MOUSEMOVE:
-            pWindow->LogicMouseMove(aEvent);
+            Application::PostMouseEvent(VclEventId::WindowMouseMove, pWindow, &aEvent);
             break;
         default:
             assert(false);
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index e0c72393201a..477401d7d7b6 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1223,13 +1223,6 @@ public:
     /// Dialog / window tunneling related methods.
     Size PaintActiveFloatingWindow(VirtualDevice& rDevice) const;
 
-    void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
-    void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
-    void LogicMouseMove(const MouseEvent& rMouseEvent);
-
-    void LOKKeyInput(const KeyEvent& rKeyEvent);
-    void LOKKeyUp(const KeyEvent& rKeyEvent);
-
     /** @name Accessibility
      */
     ///@{
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 4ef9e5772d37..20e7fde45c66 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3247,74 +3247,6 @@ VclPtr<vcl::Window> Window::GetParentWithLOKNotifier()
     return pWindow;
 }
 
-struct LOKAsyncEvent
-{
-    VclPtr<vcl::Window> mpWindow;
-    SalEvent mnEvent;
-    MouseEvent maMouseEvent;
-};
-
-static void LOKAsyncEventLink( void* pEvent, void* )
-{
-    LOKAsyncEvent* pLOKEv = static_cast<LOKAsyncEvent*>(pEvent);
-    if (!pLOKEv->mpWindow->IsDisposed())
-    {
-        ImplWindowFrameProc(pLOKEv->mpWindow, pLOKEv->mnEvent, &pLOKEv->maMouseEvent);
-    }
-    delete pLOKEv;
-}
-
-void Window::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
-{
-    // When we're not doing tiled rendering, then positions must be passed as pixels.
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    LOKAsyncEvent* pEv = new LOKAsyncEvent;
-    pEv->mpWindow = ImplIsFloatingWindow() ? ImplGetBorderWindow() : this;
-    pEv->mnEvent = SalEvent::ExternalMouseButtonDown;
-    pEv->maMouseEvent = rMouseEvent;
-    Application::PostUserEvent( Link<void*, void>(pEv, LOKAsyncEventLink) );
-
-}
-
-void Window::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
-{
-    // When we're not doing tiled rendering, then positions must be passed as pixels.
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    LOKAsyncEvent* pEv = new LOKAsyncEvent;
-    pEv->mpWindow = ImplIsFloatingWindow() ? ImplGetBorderWindow() : this;
-    pEv->mnEvent = SalEvent::ExternalMouseButtonUp;
-    pEv->maMouseEvent = rMouseEvent;
-    Application::PostUserEvent( Link<void*, void>(pEv, LOKAsyncEventLink) );
-}
-
-void Window::LogicMouseMove(const MouseEvent& rMouseEvent)
-{
-    // When we're not doing tiled rendering, then positions must be passed as pixels.
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    LOKAsyncEvent* pEv = new LOKAsyncEvent;
-    pEv->mpWindow = ImplIsFloatingWindow() ? ImplGetBorderWindow() : this;
-    pEv->mnEvent = SalEvent::ExternalMouseMove;
-    pEv->maMouseEvent = rMouseEvent;
-    Application::PostUserEvent( Link<void*, void>(pEv, LOKAsyncEventLink) );
-}
-
-void Window::LOKKeyInput(const KeyEvent& rKeyEvent)
-{
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplWindowFrameProc(this, SalEvent::ExternalKeyInput, &rKeyEvent);
-}
-
-void Window::LOKKeyUp(const KeyEvent& rKeyEvent)
-{
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplWindowFrameProc(this, SalEvent::ExternalKeyUp, &rKeyEvent);
-}
-
 void Window::ImplCallDeactivateListeners( vcl::Window *pNew )
 {
     // no deactivation if the newly activated window is my child
commit 8841c7b96e49d55e86cae12a3f72d07ccf3c0f08
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Dec 20 15:00:36 2017 +0200

    Bin mysterious pointless '// HACK' comment
    
    Change-Id: I40509707bd98be6891f4158428163fa722c6e4d3
    (cherry picked from commit 8ab6440cf04c6d8412bf0f6850e6f12aee38966a)

diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index a03b6f53963c..a17e0b83ab32 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -22,7 +22,6 @@
 
 #include <svx/svdpage.hxx>
 
-// HACK
 #include <sot/storage.hxx>
 #include <comphelper/classids.hxx>
 #include <svx/svdview.hxx>
commit 0d13d04dab7a115bd680d6b45ba3d1221c016159
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Dec 19 21:22:02 2017 +0100

    svx: CleanAndCheckEmpty() can be in the anonymous namespace
    
    Change-Id: I51c636559aee10791102e70b5507fdab3c9a4e11
    Reviewed-on: https://gerrit.libreoffice.org/46819
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 226804c8f7d2306562380283edfd919a88863807)

diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx
index f41889f3b766..39e044447301 100644
--- a/svx/source/dialog/fntctrl.cxx
+++ b/svx/source/dialog/fntctrl.cxx
@@ -122,6 +122,22 @@ void setFont(const SvxFont& rNewFont, SvxFont& rImplFont)
     rImplFont.SetAlignment(ALIGN_BASELINE);
 }
 
+/*
+ * removes line feeds and carriage returns from string
+ * returns if param is empty
+ */
+bool CleanAndCheckEmpty(OUString& rText)
+{
+    bool bEmpty = true;
+    for (sal_Int32 i = 0; i < rText.getLength(); ++i)
+    {
+        if (0xa == rText[i] || 0xd == rText[i])
+            rText = rText.replaceAt(i, 1, " ");
+        else
+            bEmpty = false;
+    }
+    return bEmpty;
+}
 } // end anonymous namespace
 
 class FontPrevWin_Impl
@@ -612,24 +628,6 @@ void SvxFontPrevWindow::UseResourceText()
     pImpl->mbUseResText = true;
 }
 
-/*
- * removes line feeds and carriage returns from string
- * returns if param is empty
- */
-bool CleanAndCheckEmpty(OUString& rText)
-{
-    bool bEmpty = true;
-    for (sal_Int32 i = 0; i < rText.getLength(); ++i)
-    {
-        if (0xa == rText[i] || 0xd == rText[i])
-            rText = rText.replaceAt(i, 1, " ");
-        else
-            bEmpty = false;
-    }
-    return bEmpty;
-}
-
-
 void SvxFontPrevWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
 {
     ApplySettings(rRenderContext);
commit 301e38b6ef055d1186d858fcb9e70f2a7398defd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Dec 19 21:21:32 2017 +0100

    tdf#98168 sw: add mail merge from xlsx testcase
    
    Commit 83b43ef2223b66484e0e90e7b614886e06f955b5 (sw mail merge: add
    support for the new 'writer' connectivity driver, 2017-07-18) fixed
    this, with:
    
    > If we are at it, also accept xlsx next to xls.
    
    But there was no test for that part.
    
    Change-Id: Iffbd4d21e52700d38dc0a83cb5540fa10c062944
    Reviewed-on: https://gerrit.libreoffice.org/46818
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 28ddaf520da56701508acc258cf1d90f26134d28)

diff --git a/sw/CppunitTest_sw_uibase_unit.mk b/sw/CppunitTest_sw_uibase_unit.mk
new file mode 100644
index 000000000000..03a780a156ce
--- /dev/null
+++ b/sw/CppunitTest_sw_uibase_unit.mk
@@ -0,0 +1,31 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_uibase_unit))
+
+$(eval $(call gb_CppunitTest_use_external,sw_uibase_unit,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sw_uibase_unit))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_uibase_unit, \
+    sw/qa/unit/uibase \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_uibase_unit, \
+	sal \
+	sw \
+	tl \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_uibase_unit,\
+    -I$(SRCDIR)/sw/inc \
+    $$(INCLUDE) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 966c71d097fd..91e04e86f3a1 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -48,6 +48,10 @@ $(eval $(call gb_Module_add_targets,sw,\
 
 endif
 
+$(eval $(call gb_Module_add_check_targets,sw,\
+    CppunitTest_sw_uibase_unit \
+))
+
 $(eval $(call gb_Module_add_slowcheck_targets,sw,\
 	$(if $(and $(filter $(COM),MSC),$(MERGELIBS)),, \
 		CppunitTest_sw_uwriter) \
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 098e1a26f7f7..932d3c165eed 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -473,6 +473,23 @@ public:
     void RevokeNotUsedConnections();
 };
 
+namespace sw
+{
+enum class DBConnURIType
+{
+    UNKNOWN = 0,
+    ODB,
+    CALC,
+    DBASE,
+    FLAT,
+    MSJET,
+    MSACE,
+    WRITER
+};
+
+DBConnURIType SW_DLLPUBLIC GetDBunoType(const INetURLObject &rURL);
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/unit/uibase.cxx b/sw/qa/unit/uibase.cxx
new file mode 100644
index 000000000000..188916da35a2
--- /dev/null
+++ b/sw/qa/unit/uibase.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <tools/urlobj.hxx>
+
+#include <dbmgr.hxx>
+
+namespace
+{
+/// Test suite for unit tests covering uibase code.
+class Test : public CppUnit::TestFixture
+{
+public:
+    void testTdf98168();
+
+    CPPUNIT_TEST_SUITE(Test);
+    CPPUNIT_TEST(testTdf98168);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void Test::testTdf98168()
+{
+    INetURLObject aURL("file:///tmp/test.xlsx");
+    // This was sw::DBConnURIType::UNKNOWN, xlsx was not recognized.
+    CPPUNIT_ASSERT_EQUAL(sw::DBConnURIType::CALC, sw::GetDBunoType(aURL));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 244a03e00bc2..a5269e241dd4 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -144,6 +144,7 @@
 #include <officecfg/Office/Common.hxx>
 
 using namespace ::com::sun::star;
+using namespace sw;
 
 #define DB_SEP_SPACE    0
 #define DB_SEP_TAB      1
@@ -2562,18 +2563,8 @@ uno::Sequence<OUString> SwDBManager::GetExistingDatabaseNames()
     return xDBContext->getElementNames();
 }
 
-namespace {
-enum class DBConnURIType {
-    UNKNOWN = 0,
-    ODB,
-    CALC,
-    DBASE,
-    FLAT,
-    MSJET,
-    MSACE,
-    WRITER
-};
-
+namespace  sw
+{
 DBConnURIType GetDBunoType(const INetURLObject &rURL)
 {
     OUString sExt(rURL.GetExtension());
@@ -2614,7 +2605,10 @@ DBConnURIType GetDBunoType(const INetURLObject &rURL)
 #endif
     return type;
 }
+}
 
+namespace
+{
 uno::Any GetDBunoURI(const INetURLObject &rURL, DBConnURIType& rType)
 {
     uno::Any aURLAny;
commit 6963c81fea907ec0f71ff6e25f37cec94451e5a5
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Dec 19 16:38:05 2017 +0200

    Remove unnecessary nested block level
    
    Change-Id: I06fb2d13bf39d636151396a2cbac35b3403ffe39
    Reviewed-on: https://gerrit.libreoffice.org/46798
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    (cherry picked from commit ae71020598362784b39eb4f67178166754db6fe0)

diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 4fb732b02da1..ed793a1dc5d8 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -2212,57 +2212,55 @@ void SwNodes::ForEach( const SwNodeIndex& rStart, const SwNodeIndex& rEnd,
 
 void SwNodes::RemoveNode( sal_uLong nDelPos, sal_uLong nSz, bool bDel )
 {
-    {
 #ifndef NDEBUG
-        SwNode *const pFirst((*this)[nDelPos]);
+    SwNode *const pFirst((*this)[nDelPos]);
 #endif
-        for (sal_uLong nCnt = 0; nCnt < nSz; nCnt++)
-        {
-            SwNode* pNode = ((*this)[ nDelPos + nCnt ]);
-            SwTextNode * pTextNd = pNode->GetTextNode();
+    for (sal_uLong nCnt = 0; nCnt < nSz; nCnt++)
+    {
+        SwNode* pNode = ((*this)[ nDelPos + nCnt ]);
+        SwTextNode * pTextNd = pNode->GetTextNode();
 
-            if (pTextNd)
+        if (pTextNd)
+        {
+            pTextNd->RemoveFromList();
+            // remove RndStdIds::FLY_AS_CHAR *before* adjusting SwNodeIndex
+            // so their anchor still points to correct node when deleted!
+            // NOTE: this will call RemoveNode() recursively!
+            // so adjust our indexes to account for removed nodes
+            sal_uLong const nPos = pTextNd->GetIndex();
+            SwpHints *const pHints(pTextNd->GetpSwpHints());
+            if (pHints)
             {
-                pTextNd->RemoveFromList();
-                // remove RndStdIds::FLY_AS_CHAR *before* adjusting SwNodeIndex
-                // so their anchor still points to correct node when deleted!
-                // NOTE: this will call RemoveNode() recursively!
-                // so adjust our indexes to account for removed nodes
-                sal_uLong const nPos = pTextNd->GetIndex();
-                SwpHints *const pHints(pTextNd->GetpSwpHints());
-                if (pHints)
+                std::vector<SwTextAttr*> flys;
+                for (size_t i = 0; i < pHints->Count(); ++i)
                 {
-                    std::vector<SwTextAttr*> flys;
-                    for (size_t i = 0; i < pHints->Count(); ++i)
+                    SwTextAttr *const pHint(pHints->Get(i));
+                    if (RES_TXTATR_FLYCNT == pHint->Which())
                     {
-                        SwTextAttr *const pHint(pHints->Get(i));
-                        if (RES_TXTATR_FLYCNT == pHint->Which())
-                        {
-                            flys.push_back(pHint);
-                        }
+                        flys.push_back(pHint);
                     }
-                    for (SwTextAttr * pHint : flys)
-                    {
-                        pTextNd->DeleteAttribute(pHint);
-                    }   // pHints may be dead now
-                    sal_uLong const nDiff = nPos - pTextNd->GetIndex();
-                    if (nDiff)
-                    {
-                        nDelPos -= nDiff;
-                    }
-                    assert(pTextNd == (*this)[nDelPos + nCnt]);
-                    assert(pFirst == (*this)[nDelPos]);
                 }
+                for (SwTextAttr * pHint : flys)
+                {
+                    pTextNd->DeleteAttribute(pHint);
+                }   // pHints may be dead now
+                sal_uLong const nDiff = nPos - pTextNd->GetIndex();
+                if (nDiff)
+                {
+                    nDelPos -= nDiff;
+                }
+                assert(pTextNd == (*this)[nDelPos + nCnt]);
+                assert(pFirst == (*this)[nDelPos]);
             }
-            SwTableNode* pTableNode = pNode->GetTableNode();
-            if (pTableNode)
-            {
-                // The node that is deleted is a table node.
-                // Need to make sure that all the redlines that are
-                // related to this table are removed from the
-                // 'Extra Redlines' array
-                pTableNode->RemoveRedlines();
-            }
+        }
+        SwTableNode* pTableNode = pNode->GetTableNode();
+        if (pTableNode)
+        {
+            // The node that is deleted is a table node.
+            // Need to make sure that all the redlines that are
+            // related to this table are removed from the
+            // 'Extra Redlines' array
+            pTableNode->RemoveRedlines();
         }
     }
 
commit c459bf8bf39eba39f9ead7e8195341b55dfdc556
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Fri Dec 15 14:42:06 2017 +0200

    Properly skip ignored value
    
    Change-Id: I1ac75cde58a52f87ef6825baa2e689dbc449c8f0
    Reviewed-on: https://gerrit.libreoffice.org/46547
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 0545c1ad981a3dcb8264da3215bc069b03f4d988)

diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index 06c07665a831..74b612928ffd 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -2097,7 +2097,7 @@ namespace cairocanvas
                         *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                         *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                         *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
-                        *pOut++ = 1.0; // the value does not matter
+                        *pOut++ = 1.0; pIn++; // the value does not matter
                     }
                     return aRes;
                 }
diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx
index a80f23b3f2f4..d1155243275c 100644
--- a/canvas/source/tools/canvastools.cxx
+++ b/canvas/source/tools/canvastools.cxx
@@ -678,7 +678,7 @@ namespace canvas
                             *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                             *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                             *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
-                            *pOut++ = 1.0;
+                            *pOut++ = 1.0; pIn++;
                         }
                         return aRes;
                     }
commit 7e43d4fdfdd5cc97a3f8a9f2fc8ea1bac7f6eb3f
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Dec 18 17:49:59 2017 +0200

    Get rid of a dynamic_cast
    
    Add a virtual member function instead. This improves performance a
    bit. The time to load a specific pathological customer document
    dropped from 1min 53s to 1min 47s on my machine. Not hugely, but
    clearly.
    
    Change-Id: I1e59d601e9d0e14b6a756c6e0ad29ce2a1fce66d
    Reviewed-on: https://gerrit.libreoffice.org/46791
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    (cherry picked from commit fdbd3ac1880b3943e2cff48ecfb95dd088210d09)

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index f1768787c92a..265ec9b96c72 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -801,6 +801,9 @@ public:
 
     virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 
+    /// Is this a textbox of a drawinglayer shape?
+    virtual bool IsTextBox() const;
+
     void SetEmptyPresObj(bool bEpt);
     bool IsEmptyPresObj() const { return bEmptyPresObj;}
     void SetNotVisibleAsMaster(bool bFlg);
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 5c97d855633c..5ff4b27a8fc7 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -3065,6 +3065,11 @@ bool SdrObject::HasText() const
     return false;
 }
 
+bool SdrObject::IsTextBox() const
+{
+    return false;
+}
+
 SdrDelayBroadcastObjectChange::SdrDelayBroadcastObjectChange( SdrObject& rObj ) :
     mrObj(rObj), mbOldDelayBroadcastObjectChange( rObj.mbDelayBroadcastObjectChange)
 {
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 189b7c006c96..0c3bf5ff742b 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -89,8 +89,6 @@ public:
      *              Valid types are RES_DRAWFRMFMT and RES_FLYFRMFMT.
      */
     static bool isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType);
-    /// Is pObject a textbox of a drawinglayer shape?
-    static bool isTextBox(const SdrObject* pObject);
 
     /// Count number of shapes in the document, excluding TextBoxes.
     static sal_Int32 getCount(const SwDoc* pDoc);
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 050d5339961c..7ec48abc9eaa 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -147,20 +147,13 @@ bool SwTextBoxHelper::isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType)
     return pOtherFormat->GetAttrSet().HasItem(RES_CNTNT) && pOtherFormat->GetContent() == rContent;
 }
 
-bool SwTextBoxHelper::isTextBox(const SdrObject* pObject)
-{
-    auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>(pObject);
-    if (!pVirtFlyDrawObj)
-        return false;
-    return isTextBox(pVirtFlyDrawObj->GetFormat(), RES_FLYFRMFMT);
-}
-
 sal_Int32 SwTextBoxHelper::getCount(SdrPage const* pPage)
 {
     sal_Int32 nRet = 0;
     for (std::size_t i = 0; i < pPage->GetObjCount(); ++i)
     {
-        if (isTextBox(pPage->GetObj(i)))
+        SdrObject* p = pPage->GetObj(i);
+        if (p && p->IsTextBox())
             continue;
         ++nRet;
     }
@@ -188,11 +181,12 @@ uno::Any SwTextBoxHelper::getByIndex(SdrPage const* pPage, sal_Int32 nIndex)
     sal_Int32 nCount = 0; // Current logical index.
     for (std::size_t i = 0; i < pPage->GetObjCount(); ++i)
     {
-        if (isTextBox(pPage->GetObj(i)))
+        SdrObject* p = pPage->GetObj(i);
+        if (p && p->IsTextBox())
             continue;
         if (nCount == nIndex)
         {
-            pRet = pPage->GetObj(i);
+            pRet = p;
             break;
         }
         ++nCount;
@@ -211,9 +205,10 @@ sal_Int32 SwTextBoxHelper::getOrdNum(const SdrObject* pObject)
         sal_Int32 nOrder = 0; // Current logical order.
         for (std::size_t i = 0; i < pPage->GetObjCount(); ++i)
         {
-            if (isTextBox(pPage->GetObj(i)))
+            SdrObject* p = pPage->GetObj(i);
+            if (p && p->IsTextBox())
                 continue;
-            if (pPage->GetObj(i) == pObject)
+            if (p == pObject)
                 return nOrder;
             ++nOrder;
         }
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 56558e29b7fe..e9f93c295fd8 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -47,6 +47,7 @@
 #include <grfatr.hxx>
 #include <pagefrm.hxx>
 #include <rootfrm.hxx>
+#include <textboxhelper.hxx>
 #include <wrtsh.hxx>
 #include <ndgrf.hxx>
 #include <frmmgr.hxx>
@@ -1275,4 +1276,9 @@ SdrObject* SwVirtFlyDrawObj::CheckMacroHit( const SdrObjMacroHitRec& rRec ) cons
     return SdrObject::CheckMacroHit( rRec );
 }
 
+bool SwVirtFlyDrawObj::IsTextBox() const
+{
+    return SwTextBoxHelper::isTextBox(GetFormat(), RES_FLYFRMFMT);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 8f6e3ef357b9..f6a5d1ee05d3 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -1533,7 +1533,7 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
                 // Ignore TextBoxes of draw shapes here, so that
                 // SwFEShell::SelectObj() won't jump back on this list, meaning
                 // we never jump to the next draw shape.
-                SwTextBoxHelper::isTextBox(pObj) ||
+                (pObj && pObj->IsTextBox()) ||
                 ( eType == GotoObjFlags::DrawSimple && lcl_IsControlGroup( pObj ) ) ||
                 ( eType == GotoObjFlags::DrawControl && !lcl_IsControlGroup( pObj ) ) ||
                 ( pFilter && !pFilter->includeObject( *pObj ) ) )
diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx
index 77df7060420d..a0cf7fd28d3a 100644
--- a/sw/source/core/inc/dflyobj.hxx
+++ b/sw/source/core/inc/dflyobj.hxx
@@ -128,6 +128,8 @@ public:
 
     // RotGrfFlyFrame: If true, this SdrObject supports only limited rotation.
     virtual bool HasLimitedRotation() const override;
+
+    virtual bool IsTextBox() const override;
 };
 
 #endif
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index 94afc9ddc38d..600b923ac177 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -511,7 +511,7 @@ SwTwips SwAnchoredObjectPosition::ImplAdjustVertRelPos( const SwTwips nTopOfAnch
              && nAdjustedRelPosY < nProposedRelPosY )
         {
             const SwFrameFormat* pFormat = &(GetFrameFormat());
-            if ( SwTextBoxHelper::isTextBox(&GetObject()) )
+            if ( GetObject().IsTextBox() )
             {
                 // shrink textboxes to extend beyond the page bottom
                 SwFrameFormat* pFrameFormat = ::FindFrameFormat(&GetObject());
commit f4c9b387b697aca3c1e600fcd1fddf188d691a29
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Dec 13 15:09:36 2017 +0000

    LOK: fix URL launching, so that Help buttons work.
    
    Change-Id: I9efe0173c35341043c3402042d9aa364a03e4fc5
    Reviewed-on: https://gerrit.libreoffice.org/46419
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>
    (cherry picked from commit 2ccf578372cd77060abb6db520985165e779de3f)
    (cherry picked from commit 7978eb8f6efa64fb0d5fba993f029793672a78ba)

diff --git a/sfx2/source/appl/openuriexternally.cxx b/sfx2/source/appl/openuriexternally.cxx
index 9518b913441b..5b3e4821b200 100644
--- a/sfx2/source/appl/openuriexternally.cxx
+++ b/sfx2/source/appl/openuriexternally.cxx
@@ -23,14 +23,27 @@
 #include <sfx2/sfxresid.hxx>
 #include <vcl/layout.hxx>
 #include <vcl/svapp.hxx>
-
 #include <openuriexternally.hxx>
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
+#include <sfx2/viewsh.hxx>
 #include <sfx2/strings.hrc>
 
 bool sfx2::openUriExternally(
     OUString const & uri, bool handleSystemShellExecuteException)
 {
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        if(SfxViewShell* pViewShell = SfxViewShell::Current())
+        {
+            pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED,
+                                                   uri.toUtf8().getStr());
+            return true;
+        }
+        return false;
+    }
+
     css::uno::Reference< css::system::XSystemShellExecute > exec(
         css::system::SystemShellExecute::create(comphelper::getProcessComponentContext()));
     try {
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 2df8b5ac7012..a281a6dd479a 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -56,6 +56,10 @@
 #include <svtools/sfxecode.hxx>
 #include <openuriexternally.hxx>
 
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <sfx2/viewsh.hxx>
+
 #include "newhelp.hxx"
 #include <sfx2/objsh.hxx>
 #include <sfx2/docfac.hxx>
@@ -505,6 +509,9 @@ OUString SfxHelp::GetHelpText( const OUString& aCommandURL, const vcl::Window* p
 /// Check for built-in help
 static bool impl_hasHelpInstalled( const OUString &rLang = OUString() )
 {
+    if (comphelper::LibreOfficeKit::isActive())
+        return false;
+
     OUStringBuffer aHelpRootURL("vnd.sun.star.help://");
     AppendConfigToken(aHelpRootURL, true, rLang);
     std::vector< OUString > aFactories = SfxContentHelper::GetResultSet(aHelpRootURL.makeStringAndClear());
@@ -533,6 +540,19 @@ static bool impl_showOnlineHelp( const OUString& rURL )
 
     aHelpLink += rURL.copy( aInternal.getLength() );
     aHelpLink = aHelpLink.replaceAll("%2F","/");
+
+
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        if(SfxViewShell* pViewShell = SfxViewShell::Current())
+        {
+            pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED,
+                                                   aHelpLink.toUtf8().getStr());
+            return true;
+        }
+        return false;
+    }
+
     try
     {
         sfx2::openUriExternally(aHelpLink, false);
@@ -624,6 +644,12 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const
         }
     }
 
+    if ( comphelper::LibreOfficeKit::isActive() )
+    {
+        impl_showOnlineHelp( aHelpURL );
+        return true;
+    }
+
     if ( !impl_hasHelpInstalled() )
     {
         ScopedVclPtrInstance< MessageDialog > aQueryBox(const_cast< vcl::Window* >( pWindow ),"onlinehelpmanual","sfx/ui/helpmanual.ui");
diff --git a/shell/Library_syssh.mk b/shell/Library_syssh.mk
index c36056a9536b..cd64791f1cd5 100644
--- a/shell/Library_syssh.mk
+++ b/shell/Library_syssh.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_Library_use_sdk_api,syssh))
 $(eval $(call gb_Library_use_libraries,syssh,\
 	cppu \
 	cppuhelper \
+	comphelper \
 	sal \
 ))
 
diff --git a/shell/source/unix/exec/shellexec.cxx b/shell/source/unix/exec/shellexec.cxx
index 3411f2c446fe..fd9932353e0c 100644
--- a/shell/source/unix/exec/shellexec.cxx
+++ b/shell/source/unix/exec/shellexec.cxx
@@ -34,6 +34,7 @@
 #include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
 #include <com/sun/star/uri/UriReferenceFactory.hpp>
 #include <cppuhelper/supportsservice.hxx>
+#include <comphelper/lok.hxx>
 
 #include <uno/current_context.hxx>
 
@@ -97,6 +98,12 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar
 {
     OStringBuffer aBuffer, aLaunchBuffer;
 
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        SAL_WARN("shell", "Unusual - shell attemp to launch " << aCommand << " with params " << aParameter << " under lok");
+        return;
+    }
+
     // DESKTOP_LAUNCH, see http://freedesktop.org/pipermail/xdg/2004-August/004489.html
     static const char *pDesktopLaunch = getenv( "DESKTOP_LAUNCH" );
 
commit a3b1500439ebc9986a57457254cdeaddbf458832
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Dec 19 22:51:00 2017 +0530

    lokdialog: Handle closing of modeless dialogs too
    
    Change-Id: I87ed60e940fad199b14a2e2179cc1f10008bfe93
    (cherry picked from commit fbd537ae68ec587c323fb0f1674bdd7747b93d04)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 13b072ec630f..670032a18211 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3308,7 +3308,7 @@ static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindo
     if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow.get()))
     {
         if (nAction == LOK_WINDOW_CLOSE)
-            pDialog->EndDialog( RET_CANCEL );
+            pDialog->Close();
     }
 }
 
commit f03e71758c9a2f616dfbaaf81b77bd73b7024c8b
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Dec 12 18:13:03 2017 +0100

    lokdialog: Allow windows / dialogs in different languages.
    
    Change-Id: I9f32161981aed73e6d97696e5f976af276d1625a
    Reviewed-on: https://gerrit.libreoffice.org/46327
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/46775
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit e16852cd1bc5d9e0646ae4183bc13a7bce19df7f)

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index b8324a4defcd..2e8624d1e8d0 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -27,6 +27,10 @@ static bool g_bTiledAnnotations(true);
 
 static bool g_bRangeHeaders(false);
 
+static bool g_bLocalRendering(false);
+
+static LanguageTag g_aLanguageTag("en-US", true);
+
 void setActive(bool bActive)
 {
     g_bActive = bActive;
@@ -87,8 +91,6 @@ bool isRangeHeaders()
     return g_bRangeHeaders;
 }
 
-static bool g_bLocalRendering(false);
-
 void setLocalRendering(bool bLocalRendering)
 {
     g_bLocalRendering = bLocalRendering;
@@ -99,6 +101,17 @@ bool isLocalRendering()
     return g_bLocalRendering;
 }
 
+void setLanguageTag(const LanguageTag& languageTag)
+{
+    if (g_aLanguageTag != languageTag)
+        g_aLanguageTag = languageTag;
+}
+
+const LanguageTag& getLanguageTag()
+{
+    return g_aLanguageTag;
+}
+
 static void (*pStatusIndicatorCallback)(void *data, statusIndicatorCallbackType type, int percent)(nullptr);
 static void *pStatusIndicatorCallbackData(nullptr);
 
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index ba76a8ca532d..37c7755a0d08 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2289,10 +2289,11 @@ void DesktopLOKTest::testABI()
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(36), offsetof(struct _LibreOfficeKitDocumentClass, postWindow));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(37), offsetof(struct _LibreOfficeKitDocumentClass, postWindowKeyEvent));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(38), offsetof(struct _LibreOfficeKitDocumentClass, postWindowMouseEvent));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(39), offsetof(struct _LibreOfficeKitDocumentClass, setViewLanguage));
 
     // Extending is fine, update this, and add new assert for the offsetof the
     // new method
-    CPPUNIT_ASSERT_EQUAL(documentClassOffset(39), sizeof(struct _LibreOfficeKitDocumentClass));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(40), sizeof(struct _LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5f18a457f241..13b072ec630f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -598,6 +598,7 @@ static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
 static int doc_getView(LibreOfficeKitDocument* pThis);
 static int doc_getViewsCount(LibreOfficeKitDocument* pThis);
 static bool doc_getViewIds(LibreOfficeKitDocument* pThis, int* pArray, size_t nSize);
+static void doc_setViewLanguage(LibreOfficeKitDocument* pThis, int nId, const char* language);
 static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
                           const char *pFontName,
                           const char *pChar,
@@ -663,6 +664,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->paintWindow = doc_paintWindow;
         m_pDocumentClass->postWindow = doc_postWindow;
 
+        m_pDocumentClass->setViewLanguage = doc_setViewLanguage;
+
         gDocumentClass = m_pDocumentClass;
     }
     pClass = m_pDocumentClass.get();
@@ -3153,6 +3156,13 @@ static bool doc_getViewIds(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*
     return SfxLokHelper::getViewIds(pArray, nSize);
 }
 
+static void doc_setViewLanguage(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, int nId, const char* language)
+{
+    SolarMutexGuard aGuard;
+
+    SfxLokHelper::setViewLanguage(nId, OStringToOUString(language, RTL_TEXTENCODING_UTF8));
+}
+
 unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/,
                     const char* pFontName,
                     const char* pChar,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index ed8b295b3f09..d42bd3434689 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -297,6 +297,9 @@ struct _LibreOfficeKitDocumentClass
                                   int nButtons,
                                   int nModifier);
 
+    /// @see lok::Document::setViewLanguage().
+    void (*setViewLanguage) (LibreOfficeKitDocument* pThis, int nId, const char* language);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 835710e07e91..310b9cfcee88 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -526,6 +526,17 @@ public:
         return mpDoc->pClass->getViewIds(mpDoc, pArray, nSize);
     }
 
+    /**
+     * Set the language tag of the window with the specified nId.
+     *
+     * @param nId a view ID, returned by createView().
+     * @param language Bcp47 languageTag, like en-US or so.
+     */
+    void setViewLanguage(int nId, const char* language)
+    {
+        mpDoc->pClass->setViewLanguage(mpDoc, nId, language);
+    }
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index c42a740822e0..e9634e77d6f9 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -12,6 +12,8 @@
 
 #include <comphelper/comphelperdllapi.h>
 
+#include <i18nlangtag/languagetag.hxx>
+
 // Interface between the LibreOfficeKit implementation called by LibreOfficeKit clients and other
 // LibreOffice code.
 
@@ -65,6 +67,11 @@ COMPHELPER_DLLPUBLIC void setRangeHeaders(bool bTiledAnnotations);
 /// Check if range based header data is enabled
 COMPHELPER_DLLPUBLIC bool isRangeHeaders();
 
+/// Update the current LOK's language.
+COMPHELPER_DLLPUBLIC void setLanguageTag(const LanguageTag& languageTag);
+/// Get the current LOK's language.
+COMPHELPER_DLLPUBLIC const LanguageTag& getLanguageTag();
+
 // Status indicator handling. Even if in theory there could be several status indicators active at
 // the same time, in practice there is only one at a time, so we don't handle any identification of
 // status indicator in this API.
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 52c9b9763eae..b2b6f9f09977 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -34,6 +34,8 @@ public:
     static std::size_t getViewsCount();
     /// Get viewIds of all existing views.
     static bool getViewIds(int* pArray, size_t nSize);
+    /// Set language of the given view.
+    static void setViewLanguage(int nId, const OUString& rBcp47LanguageTag);
     /// Iterate over any view shell, except pThisViewShell, passing it to the f function.
     template<typename ViewShellType, typename FunctionType>
     static void forEachOtherView(ViewShellType* pThisViewShell, FunctionType f);
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 988e1d3490ec..0c83f5faee15 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -153,6 +153,7 @@ friend class SfxPrinterController;
     VclPtr<vcl::Window>         pWindow;
     bool                        bNoNewWindow;
     bool                        mbPrinterSettingsModified;
+    LanguageTag                 maLOKLanguageTag;
 
 protected:
     virtual void                Activate(bool IsMDIActivate) override;
@@ -342,6 +343,10 @@ public:
     /// See OutlinerViewShell::GetEditWindowForActiveOLEObj().
     virtual vcl::Window* GetEditWindowForActiveOLEObj() const override;
 
+    /// Set the LibreOfficeKit language of this view.
+    void SetLOKLanguageTag(const OUString& rBcp47LanguageTag) { maLOKLanguageTag = LanguageTag(rBcp47LanguageTag, true); }
+    /// Get the LibreOfficeKit language of this view.
+    const LanguageTag& GetLOKLanguageTag() const { return maLOKLanguageTag; }
 };
 
 
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 135c36003192..cd672aaf91e1 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -69,6 +69,9 @@ void SfxLokHelper::setView(int nId)
     {
         if ((sal_Int32)pViewShell->GetViewShellId() == nViewShellId)
         {
+            // update the current LOK language for the dialog tunneling
+            comphelper::LibreOfficeKit::setLanguageTag(pViewShell->GetLOKLanguageTag());
+
             if (pViewShell == SfxViewShell::Current())
                 return;
 
@@ -120,6 +123,20 @@ bool SfxLokHelper::getViewIds(int* pArray, size_t nSize)
     return true;
 }
 
+void SfxLokHelper::setViewLanguage(int nId, const OUString& rBcp47LanguageTag)
+{
+    SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+
+    for (SfxViewShell* pViewShell : rViewArr)
+    {
+        if (pViewShell->GetViewShellId() == ViewShellId(nId))
+        {
+            pViewShell->SetLOKLanguageTag(rBcp47LanguageTag);
+            return;
+        }
+    }
+}
+
 void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload)
 {
     OString aPayload = OString("{ \"viewId\": \"") + OString::number(SfxLokHelper::getView(pThisView)) +
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 2c38ac071a31..ad0fce0a6466 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1059,6 +1059,7 @@ SfxViewShell::SfxViewShell
 ,   pWindow(nullptr)
 ,   bNoNewWindow( nFlags & SfxViewShellFlags::NO_NEWWINDOW )
 ,   mbPrinterSettingsModified(false)
+,   maLOKLanguageTag("en-US", true)
 {
 
     SetMargin( pViewFrame->GetMargin_Impl() );
commit adffe88eaa4608ce52676568598cbc4199599ee7
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Sun Dec 17 14:08:50 2017 +0100

    lok: sc: missing header invalidation on undo an autofilter action
    
    Change-Id: Ibfa7602221ed0c115ad469bd8a61e62baaff0bdf
    Reviewed-on: https://gerrit.libreoffice.org/46715
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>
    (cherry picked from commit b0cecbfb03dba67f01d1411a1e8b7402c2ca90ce)

diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 4ce55220b73a..72f91d74677f 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -817,6 +817,7 @@ void ScUndoQuery::Undo()
 
     // invalidate cache positions and update cursor and selection
     pViewShell->OnLOKShowHideColRow(/*bColumns*/ false, aQueryParam.nRow1 - 1);
+    ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, nTab);
 
     //  Paint
 
commit b0c25b9f81780b15c94eaa1041c7b6240a03e572
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Mon Dec 18 21:08:05 2017 +0200

    Correct the assertion
    
    The anchor node passed to SwDoc::MakeFlySection may be non-content node,
    e.g. a table node when a whole table is selected when inserting a frame.
    Thus assertion must take into account if the bCalledFromShell flag is true.
    
    Change-Id: I947ed9dfc4846a8c4fe430d80fb8286212e0b248
    Reviewed-on: https://gerrit.libreoffice.org/46736
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 79827580ce7f6be4ff9017b516dc45c9eba5e01e)

diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 641bfb282c0e..c95b43b0d451 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -328,7 +328,10 @@ SwFlyFrameFormat* SwDoc::MakeFlySection( RndStdIds eAnchorType,
             (SwNodeIndex( GetNodes().GetEndOfAutotext()),
              getIDocumentStylePoolAccess().GetTextCollFromPool( nCollId ));
         SwContentNode * pAnchorNode = pAnchorPos->nNode.GetNode().GetContentNode();
-        assert(pAnchorNode); // pAnchorNode from cursor, must be valid
+        // pAnchorNode from cursor must be valid, unless a whole table is selected (in which
+        // case the node is not a content node, and pAnchorNode is nullptr). In the latter case,
+        // bCalledFromShell is false.
+        assert(!bCalledFromShell || pAnchorNode);
 
         const SfxPoolItem * pItem = nullptr;
 
commit ff87ba0139c1f98ca4b94a4a8f8be822f366cfea
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Dec 18 19:30:06 2017 +0900

    show rest of the menu bar in a pop-up if the are is too small
    
    In case when the window is to small to show the whole menu then
    the use couldn't access the rest of the items in the menu. This
    change adds a button in the end (using the ">>" marker as in
    toolbar) which on click adds a pop-up that shows the rest of the
    menu items.
    
    Change-Id: I9218dba504464bdd44d61ebb383f7674f3df760f
    Reviewed-on: https://gerrit.libreoffice.org/46711
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 9f3b61e51f7f9de11436b0e4eaec164f2656fbdd)

diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 123fd0e8fb39..2728b1ac8f21 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -164,6 +164,7 @@ protected:
     SAL_DLLPRIVATE Menu* ImplFindMenu( sal_uInt16 nId );
     SAL_DLLPRIVATE Size  ImplCalcSize( vcl::Window* pWin );
     SAL_DLLPRIVATE bool  ImplIsVisible( sal_uInt16 nPos ) const;
+    SAL_DLLPRIVATE bool  ImplCurrentlyHiddenOnGUI(sal_uInt16 nPos) const;
     SAL_DLLPRIVATE bool  ImplIsSelectable( sal_uInt16 nPos ) const;
     SAL_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const;
     SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const;
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 3c821e7b5b5b..61957f56cd6f 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -121,8 +121,50 @@ void ImplClosePopupToolBox( const VclPtr<vcl::Window>& pWin )
     }
 }
 
+// TODO: Move to common code with the same function in toolbox
+// Draw the ">>" - more indictor at the coordinates
+void lclDrawMoreIndicator(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
+{
+    rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
+    rRenderContext.SetLineColor();
+
+    if (rRenderContext.GetSettings().GetStyleSettings().GetFaceColor().IsDark())
+        rRenderContext.SetFillColor(Color(COL_WHITE));
+    else
+        rRenderContext.SetFillColor(Color(COL_BLACK));
+    float fScaleFactor = rRenderContext.GetDPIScaleFactor();
+
+    int linewidth = 1 * fScaleFactor;
+    int space = 4 * fScaleFactor;
+
+    long width = 8 * fScaleFactor;
+    long height = 5 * fScaleFactor;
+
+    //Keep odd b/c drawing code works better
+    if ( height % 2 == 0 )
+        height--;
+
+    long heightOrig = height;
+
+    long x = rRect.Left() + (rRect.getWidth() - width)/2 + 1;
+    long y = rRect.Top() + (rRect.getHeight() - height)/2 + 1;
+    while( height >= 1)
+    {
+        rRenderContext.DrawRect( tools::Rectangle( x, y, x + linewidth, y ) );
+        x += space;
+        rRenderContext.DrawRect( tools::Rectangle( x, y, x + linewidth, y ) );
+        x -= space;
+        y++;
+        if( height <= heightOrig / 2 + 1) x--;
+        else            x++;
+        height--;
+    }
+    rRenderContext.Pop();
 }
 
+} // end anonymouse namespace
+
+
 Menu::Menu()
     : mpFirstDel(nullptr),
       pItemList(new MenuItemList),
@@ -1138,6 +1180,22 @@ Menu& Menu::operator=( const Menu& rMenu )
     return *this;
 }
 
+// Returns true if the item is completely hidden on the GUI and shouldn't
+// be possible to interact with
+bool Menu::ImplCurrentlyHiddenOnGUI(sal_uInt16 nPos) const
+{
+    MenuItemData* pData = pItemList->GetDataFromPos(nPos);
+    if (pData)
+    {
+        MenuItemData* pPreviousData = pItemList->GetDataFromPos( nPos - 1 );
+        if (pPreviousData && pPreviousData->bHiddenOnGUI)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
 bool Menu::ImplIsVisible( sal_uInt16 nPos ) const
 {
     bool bVisible = true;
@@ -1696,6 +1754,8 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
     if (!pThisItemOnly && !IsMenuBar() && nTitleHeight > 0)
         ImplPaintMenuTitle(rRenderContext, tools::Rectangle(aTopLeft, aOutSz));
 
+    bool bHiddenItems = false; // are any items on the GUI hidden
+
     for (size_t n = 0; n < nCount; n++)
     {
         MenuItemData* pData = pItemList->GetDataFromPos( n );
@@ -1921,7 +1981,25 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
                     {
                         nMaxItemTextWidth -= nFontHeight - nExtra;
                     }
-                    OUString aItemText(getShortenedString(pData->aText, rRenderContext, nMaxItemTextWidth));
+
+                    OUString aItemText(pData->aText);
+                    pData->bHiddenOnGUI = false;
+
+                    if (IsMenuBar()) // In case of menubar if we are out of bounds we shouldn't paint the item
+                    {
+                        if (nMaxItemTextWidth < rRenderContext.GetTextWidth(aItemText))
+                        {
+                            aItemText = "";
+                            pData->bHiddenOnGUI = true;
+                            bHiddenItems = true;
+                        }
+                    }
+                    else
+                    {
+                        aItemText = getShortenedString(aItemText, rRenderContext, nMaxItemTextWidth);
+                        pData->bHiddenOnGUI = false;
+                    }
+
                     rRenderContext.DrawCtrlText(aTmpPos, aItemText, 0, aItemText.getLength(), nStyle, pVector, pDisplayText);
                     if (bSetTmpBackground)
                         rRenderContext.SetBackground();
@@ -2014,6 +2092,14 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
         else
             aTopLeft.X() += pData->aSz.Width();
     }
+
+    // draw "more" (">>") indicator if some items have been hidden as they go out of visible area
+    if (bHiddenItems)
+    {
+        sal_Int32 nSize = nFontHeight;
+        tools::Rectangle aRectangle(Point(aOutSz.Width() - nSize, (aOutSz.Height() / 2) - (nSize / 2)), Size(nSize, nSize));
+        lclDrawMoreIndicator(rRenderContext, aRectangle);
+    }
 }
 
 Menu* Menu::ImplGetStartMenu()
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 0b4e6b7df5bc..6a8877263b43 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -160,6 +160,7 @@ void MenuBarWindow::dispose()
     aCloseBtn->RemoveEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl));
     RemoveEventListener(LINK(this, MenuBarWindow, ShowHideListener));
 
+    mpParentPopup.disposeAndClear();
     aHideBtn.disposeAndClear();
     aFloatBtn.disposeAndClear();
     aCloseBtn.disposeAndClear();
@@ -301,6 +302,29 @@ void MenuBarWindow::ImplCreatePopup( bool bPreSelectFirst )
             Point aItemBottomRight( aItemTopLeft );
             aItemBottomRight.X() += pData->aSz.Width();
 
+            if (pData->bHiddenOnGUI)
+            {
+                mpParentPopup.disposeAndClear();
+                mpParentPopup = VclPtr<PopupMenu>::Create();
+                pActivePopup = mpParentPopup.get();
+
+                for (sal_uInt16 i = nHighlightedItem; i < pMenu->GetItemCount(); ++i)
+                {
+                    sal_uInt16 nId = pMenu->GetItemId(i);
+
+                    MenuItemData* pParentItemData = pMenu->GetItemList()->GetData(nId);
+
+                    mpParentPopup->InsertItem(nId, pParentItemData->aText, pParentItemData->nBits, pParentItemData->sIdent);
+                    mpParentPopup->SetHelpId(nId, pParentItemData->aHelpId);
+                    mpParentPopup->SetHelpText(nId, pParentItemData->aHelpText);
+                    mpParentPopup->SetAccelKey(nId, pParentItemData->aAccelKey);
+                    mpParentPopup->SetItemCommand(nId, pParentItemData->aCommandStr);
+                    mpParentPopup->SetHelpCommand(nId, pParentItemData->aHelpCommandStr);
+
+                    PopupMenu* pPopup = pMenu->GetPopupMenu(nId);
+                    mpParentPopup->SetPopupMenu(nId, pPopup);
+                }
+            }
             // the menu bar could have height 0 in fullscreen mode:
             // so do not use always WindowHeight, as ItemHeight < WindowHeight.
             if ( GetSizePixel().Height() )
@@ -340,6 +364,15 @@ void MenuBarWindow::KillActivePopup()
         // check for pActivePopup, if stopped by deactivate...
         if ( pActivePopup->ImplGetWindow() )
         {
+            if (mpParentPopup)
+            {
+                for (sal_uInt16 i = 0; i < mpParentPopup->GetItemCount(); ++i)
+                {
+                    sal_uInt16 nId = mpParentPopup->GetItemId(i);
+                    MenuItemData* pParentItemData = mpParentPopup->GetItemList()->GetData(nId);
+                    pParentItemData->pSubMenu = nullptr;
+                }
+            }
             pActivePopup->ImplGetFloatingWindow()->StopExecute();
             pActivePopup->ImplGetFloatingWindow()->doShutdown();
             pActivePopup->pWindow->doLazyDelete();
@@ -769,7 +802,9 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
                 }
 
                 MenuItemData* pData = pMenu->GetItemList()->GetDataFromPos( n );
-                if ( ( pData->eType != MenuItemType::SEPARATOR ) && pMenu->ImplIsVisible( n ) )
+                if (pData->eType != MenuItemType::SEPARATOR &&
+                    pMenu->ImplIsVisible(n) &&
+                    !pMenu->ImplCurrentlyHiddenOnGUI(n))
                 {
                     bool bDoSelect = true;
                     if( ImplGetSVData()->maNWFData.mbOpenMenuOnF10 )
@@ -891,9 +926,9 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
     aOutputSize.Width() -= aCloseBtn->GetSizePixel().Width();
 
     rRenderContext.SetFillColor(rStyleSettings.GetMenuColor());
-
     pMenu->ImplPaint(rRenderContext, aOutputSize, 0);
-    if (nHighlightedItem != ITEMPOS_INVALID)
+
+    if (nHighlightedItem != ITEMPOS_INVALID && pMenu && !pMenu->GetItemList()->GetDataFromPos(nHighlightedItem)->bHiddenOnGUI)
         HighlightItem(rRenderContext, nHighlightedItem);
     else if (ImplGetSVData()->maNWFData.mbRolloverMenubar && nRolloveredItem != ITEMPOS_INVALID)
         HighlightItem(rRenderContext, nRolloveredItem);
diff --git a/vcl/source/window/menubarwindow.hxx b/vcl/source/window/menubarwindow.hxx
index c1aa5ce49d0d..bdf785f36d13 100644
--- a/vcl/source/window/menubarwindow.hxx
+++ b/vcl/source/window/menubarwindow.hxx
@@ -69,6 +69,7 @@ private:
 
     VclPtr<Menu>           pMenu;
     VclPtr<PopupMenu>      pActivePopup;
+    VclPtr<PopupMenu>      mpParentPopup;
     sal_uInt16      nHighlightedItem;
     sal_uInt16      nRolloveredItem;
     VclPtr<vcl::Window> xSaveFocusId;
diff --git a/vcl/source/window/menuitemlist.hxx b/vcl/source/window/menuitemlist.hxx
index bd264e41fdfa..2c7820af7a83 100644
--- a/vcl/source/window/menuitemlist.hxx
+++ b/vcl/source/window/menuitemlist.hxx
@@ -50,6 +50,7 @@ struct MenuItemData
     bool            bEnabled;               // Enabled
     bool            bVisible;               // Visible (note: this flag will not override MenuFlags::HideDisabledEntries when true)
     bool            bIsTemporary;           // Temporary inserted ('No selection possible')
+    bool            bHiddenOnGUI;
     Size            aSz;                    // only temporarily valid
     OUString        aAccessibleName;        // accessible name
 
@@ -66,6 +67,7 @@ struct MenuItemData
         , bEnabled(false)
         , bVisible(false)
         , bIsTemporary(false)
+        , bHiddenOnGUI(false)
         , pSalMenuItem(nullptr)
     {
     }
@@ -82,6 +84,7 @@ struct MenuItemData
         , bEnabled(false)
         , bVisible(false)
         , bIsTemporary(false)
+        , bHiddenOnGUI(false)
         , pSalMenuItem(nullptr)
     {
     }
commit b869326fb0df94d36e0a61c5e2ac6f1096b6b564
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Dec 18 17:42:00 2017 +0900

    menu: pass paint size to ImplPaint and account for buttons
    
    When a menu bar is painted it needs to take into account that
    the buttons (close) is positioned at the right side of the paint
    area. To do this we need to pass what the output size is when
    painting (ImplPaint) on the common menu code, instead of assuming
    the whole area can be used.
    
    Change-Id: I2e9d6c686929fe1cd7e28368a8055c1e2df13c49
    Reviewed-on: https://gerrit.libreoffice.org/46710
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit e11234d8d8d8ff2744b77a128f845dbe8e6faa1e)

diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index d8d61f72bdbd..123fd0e8fb39 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -169,7 +169,7 @@ protected:
     SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const;
     SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const;
     SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( sal_uInt16 nPos ) const;
-    SAL_DLLPRIVATE void ImplPaint(vcl::RenderContext& rRenderContext,
+    SAL_DLLPRIVATE void ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
                                   sal_uInt16 nBorder, long nOffY = 0, MenuItemData const * pThisDataOnly = nullptr,
                                   bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const;
     SAL_DLLPRIVATE void ImplPaintMenuTitle(vcl::RenderContext&, const tools::Rectangle& rRect) const;
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 0bb415251eab..3c821e7b5b5b 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1661,7 +1661,7 @@ void Menu::ImplPaintMenuTitle(vcl::RenderContext& rRenderContext, const tools::R
     rRenderContext.SetBackground(aOldBackground);
 }
 
-void Menu::ImplPaint(vcl::RenderContext& rRenderContext,
+void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
                      sal_uInt16 nBorder, long nStartY, MenuItemData const * pThisItemOnly,
                      bool bHighlighted, bool bLayout, bool bRollover) const
 {
@@ -1686,7 +1686,7 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext,
     }
 
     // for the computations, use size of the underlying window, not of RenderContext
-    Size aOutSz = pWindow->GetOutputSizePixel();
+    Size aOutSz(rSize);
 
     size_t nCount = pItemList->size();
     if (bLayout)
@@ -2153,12 +2153,13 @@ void Menu::ImplFillLayoutData() const
         mpLayoutData = new MenuLayoutData;
         if (IsMenuBar())
         {
-            ImplPaint(*pWindow, 0, 0, nullptr, false, true); // FIXME
+            ImplPaint(*pWindow, pWindow->GetOutputSizePixel(), 0, 0, nullptr, false, true); // FIXME
         }
         else
         {
             MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get());
-            ImplPaint(*pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), nullptr, false, true); //FIXME
+            ImplPaint(*pWindow, pWindow->GetOutputSizePixel(), pFloat->nScrollerHeight, pFloat->ImplGetStartY(),
+                      nullptr, false, true); //FIXME
         }
     }
 }
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 6486ffb86a9c..0b4e6b7df5bc 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -574,6 +574,10 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
 
     long nX = 0;
     size_t nCount = pMenu->pItemList->size();
+
+    Size aOutputSize = GetOutputSizePixel();
+    aOutputSize.Width() -= aCloseBtn->GetSizePixel().Width();
+
     for (size_t n = 0; n < nCount; n++)
     {
         MenuItemData* pData = pMenu->pItemList->GetDataFromPos( n );
@@ -582,7 +586,7 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
             if (pData->eType != MenuItemType::SEPARATOR)
             {
                 // #107747# give menuitems the height of the menubar
-                tools::Rectangle aRect = tools::Rectangle(Point(nX, 1), Size(pData->aSz.Width(), GetOutputSizePixel().Height() - 2));
+                tools::Rectangle aRect = tools::Rectangle(Point(nX, 1), Size(pData->aSz.Width(), aOutputSize.Height() - 2));
                 rRenderContext.Push(PushFlags::CLIPREGION);
                 rRenderContext.IntersectClipRegion(aRect);
                 bool bRollover, bHighlight;
@@ -607,12 +611,12 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
                          Erase(rRenderContext);
                     else
                     {
-                        tools::Rectangle aBgRegion(Point(), GetOutputSizePixel());
+                        tools::Rectangle aBgRegion(Point(), aOutputSize);
                         rRenderContext.DrawNativeControl(ControlType::Menubar, ControlPart::Entire, aBgRegion,
                                                          ControlState::ENABLED, aControlValue, OUString());
                     }
 
-                    ImplAddNWFSeparator(rRenderContext, GetOutputSizePixel(), aControlValue);
+                    ImplAddNWFSeparator(rRenderContext, aOutputSize, aControlValue);
 
                     // draw selected item
                     ControlState nState = ControlState::ENABLED;
@@ -633,7 +637,8 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
                     rRenderContext.DrawRect(aRect);
                 }
                 rRenderContext.Pop();
-                pMenu->ImplPaint(rRenderContext, 0, 0, pData, bHighlight, false, bRollover);
+
+                pMenu->ImplPaint(rRenderContext, aOutputSize, 0, 0, pData, bHighlight, false, bRollover);
             }
             return;
         }
@@ -854,6 +859,8 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
 
     const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
 
+    Size aOutputSize = GetOutputSizePixel();
+
     // no VCL paint if native menus
     if (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar())
     {
@@ -871,17 +878,21 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
         else
         {
             Point aPt;
-            tools::Rectangle aCtrlRegion( aPt, GetOutputSizePixel() );
+            tools::Rectangle aCtrlRegion( aPt, aOutputSize );
 
             rRenderContext.DrawNativeControl(ControlType::Menubar, ControlPart::Entire, aCtrlRegion,
                                              ControlState::ENABLED, aMenubarValue, OUString());
         }
 
-        ImplAddNWFSeparator(rRenderContext, GetOutputSizePixel(), aMenubarValue);
+        ImplAddNWFSeparator(rRenderContext, aOutputSize, aMenubarValue);
     }
+
+    // shrink the area of the buttons
+    aOutputSize.Width() -= aCloseBtn->GetSizePixel().Width();
+
     rRenderContext.SetFillColor(rStyleSettings.GetMenuColor());
 
-    pMenu->ImplPaint(rRenderContext, 0);
+    pMenu->ImplPaint(rRenderContext, aOutputSize, 0);
     if (nHighlightedItem != ITEMPOS_INVALID)
         HighlightItem(rRenderContext, nHighlightedItem);
     else if (ImplGetSVData()->maNWFData.mbRolloverMenubar && nRolloveredItem != ITEMPOS_INVALID)
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 601434cbb8c7..c66510cf8f1a 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -869,7 +869,7 @@ void MenuFloatingWindow::RenderHighlightItem(vcl::RenderContext& rRenderContext,
 
                     rRenderContext.DrawRect(aItemRect);
                 }
-                pMenu->ImplPaint(rRenderContext, nScrollerHeight, nStartY, pData, true/*bHighlight*/);
+                pMenu->ImplPaint(rRenderContext, GetOutputSizePixel(), nScrollerHeight, nStartY, pData, true/*bHighlight*/);
                 if (bRestoreLineColor)
                     rRenderContext.SetLineColor(oldLineColor);
             }
@@ -1195,7 +1195,7 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools::
         ImplDrawScroller(rRenderContext, false);
     }
     rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
-    pMenu->ImplPaint(rRenderContext, nScrollerHeight, ImplGetStartY());
+    pMenu->ImplPaint(rRenderContext, GetOutputSizePixel(), nScrollerHeight, ImplGetStartY());
     if (nHighlightedItem != ITEMPOS_INVALID)
         RenderHighlightItem(rRenderContext, nHighlightedItem);
 
commit b2b3e9bf87cf901c22958424920bb263c6d77ae1
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Dec 13 22:08:20 2017 +0900

    chart2: When creating objects prevent setting object rects dirty
    
    3D objects using a E3dScene are traversing all object in the tree
    when setting rects dirty. When we are creating objects, setting
    properties and adding them to the tree we trigger setting rects
    dirty which slows down considerably - more are added objects,
    bigger the slowdown gets. So the solution here is to temporary
    disable setting object rects dirty during creation of objects.
    
    Change-Id: Id068cda9cb798d49b75bf4228cf6460f7e98c033
    Reviewed-on: https://gerrit.libreoffice.org/46446
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 55a7e836a2db662a53adc4f8b98d08b06790c758)

diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx
index 476dc39d36fb..5700e7b29b25 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -26,6 +26,8 @@
 #include <AxisIndexDefines.hxx>
 #include <Clipping.hxx>
 #include <DateHelper.hxx>
+#include <svx/scene3d.hxx>
+#include <svx/unoshape.hxx>
 
 #include <com/sun/star/chart/DataLabelPlacement.hpp>
 
@@ -404,6 +406,20 @@ void BarChart::adaptOverlapAndGapwidthForGroupBarsPerAxis()
     }
 }
 
+E3dScene* lcl_getE3dScene(uno::Reference<drawing::XShapes> const & xShapes)
+{
+    E3dScene* pScene = nullptr;
+
+    SvxShape* pSvxShape = SvxShape::getImplementation(xShapes);
+    if (pSvxShape)
+    {
+        SdrObject* pObject = pSvxShape->GetSdrObject();
+        if (pObject && dynamic_cast<const E3dScene*>(pObject) != nullptr)
+            pScene = static_cast<E3dScene*>(pObject);
+    }
+    return pScene;
+}
+
 void BarChart::createShapes()
 {
     if( m_aZSlots.empty() ) //no series
@@ -776,9 +792,12 @@ void BarChart::createShapes()
                                 if( fTopHeight < 0 )
                                     fTopHeight *= -1.0;
 
+                                E3dScene* pScene = lcl_getE3dScene(xSeriesGroupShape_Shapes);
+                                pScene->EnterObjectSetupMode();
                                 xShape = createDataPoint3D_Bar(
                                     xSeriesGroupShape_Shapes, aTransformedBottom, aSize, fTopHeight, nRotateZAngleHundredthDegree
                                     , xDataPointProperties, nGeometry3D );
+                                pScene->ExitObjectSetupMode();
                             }
                             else //m_nDimension!=3
                             {
diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx
index 81703f1d001f..2f76cec02a13 100644
--- a/include/svx/scene3d.hxx
+++ b/include/svx/scene3d.hxx
@@ -75,6 +75,8 @@ protected:
     // Flag to determine if only selected objects should be drawn
     bool                        bDrawOnlySelected       : 1;
 
+    bool mbSkipSettingDirty : 1;
+
     virtual void NewObjectInserted(const E3dObject* p3DObj) override;
     virtual void StructureChanged() override;
 
@@ -161,6 +163,9 @@ public:
     virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
     virtual bool BckCreate(SdrDragStat& rStat) override;
     virtual void BrkCreate(SdrDragStat& rStat) override;
+
+    void EnterObjectSetupMode();
+    void ExitObjectSetupMode();
 };
 
 #endif // INCLUDED_SVX_SCENE3D_HXX
diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx
index bec310a686a9..1da5c1411150 100644
--- a/svx/source/engine3d/scene3d.cxx
+++ b/svx/source/engine3d/scene3d.cxx
@@ -174,7 +174,8 @@ E3dScene::E3dScene()
 :   E3dObject(),
     aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
     mp3DDepthRemapper(nullptr),
-    bDrawOnlySelected(false)
+    bDrawOnlySelected(false),
+    mbSkipSettingDirty(false)
 {
     // Set defaults
     SetDefaultAttributes();
@@ -345,7 +346,9 @@ void E3dScene::NewObjectInserted(const E3dObject* p3DObj)
 void E3dScene::StructureChanged()
 {
     E3dObject::StructureChanged();
-    SetRectsDirty();
+
+    if (!GetScene()->mbSkipSettingDirty)
+        SetRectsDirty();
 
     ImpCleanup3DDepthMapper();
 }
@@ -413,6 +416,16 @@ E3dScene* E3dScene::Clone() const
     return CloneHelper< E3dScene >();
 }
 
+void E3dScene::EnterObjectSetupMode()
+{
+    GetScene()->mbSkipSettingDirty = true;
+}
+
+void E3dScene::ExitObjectSetupMode()
+{
+    GetScene()->mbSkipSettingDirty = false;
+}
+
 E3dScene& E3dScene::operator=(const E3dScene& rObj)
 {
     if( this == &rObj )
commit 394e63997e9ff9eff272946e412804864ff86b86
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Dec 13 22:03:12 2017 +0900

    chart2: Batch changes to properties when creating 3D objects
    
    MultiPropertySet doesn't broadcast ItemSets as often as setting
    each property separately. This can help when we create a lot of
    3D objects.
    
    Change-Id: I4eb842a5d8c43963bdceee84468593f5f6b47336
    Reviewed-on: https://gerrit.libreoffice.org/46445
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit e1697600253361a26d77a1ef61f8bde16af0ed2c)

diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 3ed37f316225..53a10b922276 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -24,6 +24,7 @@
 #include <RelativeSizeHelper.hxx>
 #include <PropertyMapper.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
 #include <com/sun/star/drawing/CircleKind.hpp>
 #include <com/sun/star/drawing/DoubleSequence.hpp>
 #include <com/sun/star/drawing/FlagSequence.hpp>
@@ -60,6 +61,21 @@ using ::com::sun::star::uno::Reference;
 namespace chart
 {
 
+namespace
+{
+
+void lcl_addProperty(uno::Sequence<OUString> & rPropertyNames, uno::Sequence<uno::Any> & rPropertyValues,
+                 OUString const & rName, uno::Any const & rAny)
+{
+    rPropertyNames.realloc(rPropertyNames.getLength() + 1);
+    rPropertyNames[rPropertyNames.getLength() - 1] = rName;
+
+    rPropertyValues.realloc(rPropertyValues.getLength() + 1);
+    rPropertyValues[rPropertyValues.getLength() - 1] = rAny;
+}
+
+} // end anonymous namespace
+
 uno::Reference< drawing::XShapes > ShapeFactory::getOrCreateChartRootShape(
     const uno::Reference< drawing::XDrawPage>& xDrawPage )
 {
@@ -389,40 +405,42 @@ uno::Reference<drawing::XShape>
     xTarget->add(xShape);
 
     //set properties
-    uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY );
-    OSL_ENSURE(xProp.is(), "created shape offers no XPropertySet");
-    if( xProp.is())
+    uno::Reference<beans::XMultiPropertySet> xMultiPropertySet(xShape, uno::UNO_QUERY);
+    OSL_ENSURE(xMultiPropertySet.is(), "created shape offers no XMultiPropertySet");
+    if (xMultiPropertySet.is())
     {
         try
         {
             //depth
             double fDepth = rSize.DirectionZ;
-            if(fDepth<0)
+            if (fDepth<0)
                 fDepth*=-1.0;
-            xProp->setPropertyValue( UNO_NAME_3D_EXTRUDE_DEPTH
-                , uno::Any((sal_Int32)fDepth) );
 
             //PercentDiagonal
             sal_Int16 nPercentDiagonal = bRounded ? 3 : 0;
-            xProp->setPropertyValue( UNO_NAME_3D_PERCENT_DIAGONAL
-                , uno::Any( nPercentDiagonal ) );
-
-            //Polygon
-            xProp->setPropertyValue( UNO_NAME_3D_POLYPOLYGON3D
-                , createPolyPolygon_Cube( rSize, double(nPercentDiagonal)/200.0,bRounded) );
 
             //Matrix for position
-            {
-                ::basegfx::B3DHomMatrix aM;
-                if(nRotateZAngleHundredthDegree!=0)
-                    aM.rotate(0.0,0.0,-nRotateZAngleHundredthDegree/18000.00*F_PI);
-                aM.translate(rPosition.PositionX
-                            , rPosition.PositionY
-                            , rPosition.PositionZ - (fDepth/2.0));
-                drawing::HomogenMatrix aHM = B3DHomMatrixToHomogenMatrix(aM);
-                xProp->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX
-                    , uno::Any(aHM) );
-            }
+            basegfx::B3DHomMatrix aHomMatrix;
+            if (nRotateZAngleHundredthDegree != 0)
+                aHomMatrix.rotate(0.0, 0.0, -nRotateZAngleHundredthDegree / 18000.00 * F_PI);
+            aHomMatrix.translate(rPosition.PositionX, rPosition.PositionY,
+                                 rPosition.PositionZ - (fDepth / 2.0));
+
+            uno::Sequence<OUString> aPropertyNames {
+                UNO_NAME_3D_EXTRUDE_DEPTH,
+                UNO_NAME_3D_PERCENT_DIAGONAL,
+                UNO_NAME_3D_POLYPOLYGON3D,
+                UNO_NAME_3D_TRANSFORM_MATRIX,
+            };
+
+            uno::Sequence<uno::Any> aPropertyValues {
+                uno::Any(sal_Int32(fDepth)), // Depth
+                uno::Any(nPercentDiagonal),  // PercentDiagonal
+                createPolyPolygon_Cube(rSize, double(nPercentDiagonal) / 200.0, bRounded),
+                uno::Any(B3DHomMatrixToHomogenMatrix(aHomMatrix))
+            };
+
+            xMultiPropertySet->setPropertyValues(aPropertyNames, aPropertyValues);
         }
         catch( const uno::Exception& e )
         {
@@ -632,46 +650,45 @@ uno::Reference<drawing::XShape>
     double fHeight     = rSize.DirectionY;
 
     //set properties
-    uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY );
-    OSL_ENSURE(xProp.is(), "created shape offers no XPropertySet");
-    if( xProp.is())
+    uno::Reference<beans::XMultiPropertySet> xMultiPropertySet(xShape, uno::UNO_QUERY);
+    OSL_ENSURE(xMultiPropertySet.is(), "created shape offers no XMultiPropertySet");
+    if (xMultiPropertySet.is())
     {
         try
         {
-            //PercentDiagonal
-            xProp->setPropertyValue( UNO_NAME_3D_PERCENT_DIAGONAL
-                , uno::Any( sal_Int16(5) ) );
-
             //Polygon
             sal_Int32 nVerticalSegmentCount = 0;
-            uno::Any aPPolygon = bCylinder ? createPolyPolygon_Cylinder(
-                                                fHeight, fRadius, nVerticalSegmentCount)
-                                           : createPolyPolygon_Cone(
-                                                fHeight, fRadius, fTopHeight, nVerticalSegmentCount);
-            xProp->setPropertyValue( UNO_NAME_3D_POLYPOLYGON3D, aPPolygon );
+            uno::Any aPPolygon = bCylinder
+                ? createPolyPolygon_Cylinder(fHeight, fRadius, nVerticalSegmentCount)
+                : createPolyPolygon_Cone(fHeight, fRadius, fTopHeight, nVerticalSegmentCount);
 
             //Matrix for position
-            {
-                ::basegfx::B3DHomMatrix aM;
-                if(nRotateZAngleHundredthDegree!=0)
-                    aM.rotate(0.0,0.0,-nRotateZAngleHundredthDegree/18000.00*F_PI);
-                //stretch the symmetric objects to given depth
-                aM.scale(1.0,1.0,rSize.DirectionZ/rSize.DirectionX);
-                aM.translate(rPosition.PositionX, rPosition.PositionY, rPosition.PositionZ);
-                drawing::HomogenMatrix aHM = B3DHomMatrixToHomogenMatrix(aM);
-                xProp->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX
-                    , uno::Any(aHM) );
-            }
-
-            //Segments
-            xProp->setPropertyValue( UNO_NAME_3D_HORZ_SEGS
-                , uno::Any(CHART_3DOBJECT_SEGMENTCOUNT) );
-            xProp->setPropertyValue( UNO_NAME_3D_VERT_SEGS
-                , uno::Any(nVerticalSegmentCount) );//depends on point count of the used polygon
-
-            //Reduced lines
-            xProp->setPropertyValue( UNO_NAME_3D_REDUCED_LINE_GEOMETRY
-                , uno::Any(true) );
+            basegfx::B3DHomMatrix aHomMatrix;
+            if (nRotateZAngleHundredthDegree != 0)
+                aHomMatrix.rotate(0.0,0.0,-nRotateZAngleHundredthDegree/18000.00*F_PI);
+            //stretch the symmetric objects to given depth
+            aHomMatrix.scale(1.0,1.0,rSize.DirectionZ/rSize.DirectionX);
+            aHomMatrix.translate(rPosition.PositionX, rPosition.PositionY, rPosition.PositionZ);
+
+            uno::Sequence<OUString> aPropertyNames{
+                UNO_NAME_3D_PERCENT_DIAGONAL,
+                UNO_NAME_3D_POLYPOLYGON3D,
+                UNO_NAME_3D_TRANSFORM_MATRIX,
+                UNO_NAME_3D_HORZ_SEGS,
+                UNO_NAME_3D_VERT_SEGS,
+                UNO_NAME_3D_REDUCED_LINE_GEOMETRY
+            };
+
+            uno::Sequence<uno::Any> aPropertyValues {
+                uno::Any(sal_Int16(5)),  // PercentDiagonal
+                aPPolygon,               // Polygon
+                uno::Any(B3DHomMatrixToHomogenMatrix(aHomMatrix)), // Matrix
+                uno::Any(CHART_3DOBJECT_SEGMENTCOUNT), // Horizontal Segments
+                uno::Any(nVerticalSegmentCount),       // Vertical Segments
+                uno::Any(true)                         // Reduced lines
+            };
+
+            xMultiPropertySet->setPropertyValues(aPropertyNames, aPropertyValues);
         }
         catch( const uno::Exception& e )
         {
@@ -990,38 +1007,40 @@ uno::Reference< drawing::XShape >
     xTarget->add(xShape);
 
     //set properties
-    uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY );
-    OSL_ENSURE(xProp.is(), "created shape offers no XPropertySet");
-    if( xProp.is())
+    uno::Reference<beans::XMultiPropertySet> xMultiPropertySet(xShape, uno::UNO_QUERY);
+    OSL_ENSURE(xMultiPropertySet.is(), "created shape offers no XMultiPropertySet");
+    if (xMultiPropertySet.is())
     {
         try
         {
-            //Polygon
-            xProp->setPropertyValue( UNO_NAME_3D_POLYPOLYGON3D
-                , rStripe.getPolyPolygonShape3D() );
+            uno::Sequence<OUString> aPropertyNames{
+                UNO_NAME_3D_POLYPOLYGON3D,
+                UNO_NAME_3D_TEXTUREPOLYGON3D,
+                UNO_NAME_3D_NORMALSPOLYGON3D,
+                UNO_NAME_3D_LINEONLY,
+                UNO_NAME_3D_DOUBLE_SIDED
+            };
+
+            uno::Sequence<uno::Any> aPropertyValues {
+                rStripe.getPolyPolygonShape3D(),            // Polygon
+                Stripe::getTexturePolygon(nRotatedTexture), // TexturePolygon
+                rStripe.getNormalsPolygon(),                // Normals Polygon
+                uno::Any(false),        // LineOnly
+                uno::Any(bDoubleSided)  // DoubleSided
+            };
 
-            //TexturePolygon
-            xProp->setPropertyValue( UNO_NAME_3D_TEXTUREPOLYGON3D
-                , Stripe::getTexturePolygon( nRotatedTexture ) );
-
-            //Normals Polygon
-            xProp->setPropertyValue( UNO_NAME_3D_NORMALSPOLYGON3D
-                , rStripe.getNormalsPolygon() );
             //NormalsKind
-            if(bFlatNormals)
-                xProp->setPropertyValue( UNO_NAME_3D_NORMALS_KIND
-                    , uno::Any( drawing::NormalsKind_FLAT ) );
+            if (bFlatNormals)
+                lcl_addProperty(aPropertyNames, aPropertyValues,
+                                UNO_NAME_3D_NORMALS_KIND, uno::Any(drawing::NormalsKind_FLAT));
 
-            //LineOnly
-            xProp->setPropertyValue( UNO_NAME_3D_LINEONLY
-                , uno::Any( false) );
+            xMultiPropertySet->setPropertyValues(aPropertyNames, aPropertyValues);
 
-            //DoubleSided
-            xProp->setPropertyValue( UNO_NAME_3D_DOUBLE_SIDED
-                , uno::Any(bDoubleSided) );
-
-            if( xSourceProp.is())
-                PropertyMapper::setMappedProperties( xProp, xSourceProp, rPropertyNameMap );
+            uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+            if (xSourceProp.is() && xPropertySet.is())
+            {
+                PropertyMapper::setMappedProperties(xPropertySet, xSourceProp, rPropertyNameMap);
+            }
         }
         catch( const uno::Exception& e )
         {
@@ -1049,42 +1068,38 @@ uno::Reference< drawing::XShape >
     xTarget->add(xShape);
 
     //set properties
-    uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY );
-    OSL_ENSURE(xProp.is(), "created shape offers no XPropertySet");
-    if( xProp.is())
+    uno::Reference<beans::XMultiPropertySet> xMultiPropertySet(xShape, uno::UNO_QUERY);
+    OSL_ENSURE(xMultiPropertySet.is(), "created shape offers no XMultiPropertySet");
+    if (xMultiPropertySet.is())
     {
         try
         {
-            //depth
-            xProp->setPropertyValue( UNO_NAME_3D_EXTRUDE_DEPTH
-                , uno::Any((sal_Int32)fDepth) );
-
-            //PercentDiagonal
-            xProp->setPropertyValue( UNO_NAME_3D_PERCENT_DIAGONAL
-                , uno::Any( sal_Int16(0) ) );
-
-            //Polygon
-            xProp->setPropertyValue( UNO_NAME_3D_POLYPOLYGON3D
-                , uno::Any( rPolyPolygon ) );
+            uno::Sequence<OUString> aPropertyNames{
+                UNO_NAME_3D_EXTRUDE_DEPTH,
+                UNO_NAME_3D_PERCENT_DIAGONAL,
+                UNO_NAME_3D_POLYPOLYGON3D,
+                UNO_NAME_3D_DOUBLE_SIDED,
+            };
 
-            //DoubleSided
-            xProp->setPropertyValue( UNO_NAME_3D_DOUBLE_SIDED
-                , uno::Any( true) );
+            uno::Sequence<uno::Any> aPropertyValues {
+                uno::Any(sal_Int32(fDepth)), // depth
+                uno::Any(sal_Int16(0)),      // PercentDiagonal
+                uno::Any(rPolyPolygon),      // Polygon
+                uno::Any(true)               // DoubleSided
+            };
 
             //the z component of the polygon is now ignored by the drawing layer,
             //so we need to translate the object via transformation matrix
 
             //Matrix for position
-            if( rPolyPolygon.SequenceZ.getLength()&& rPolyPolygon.SequenceZ[0].getLength() )
+            if (rPolyPolygon.SequenceZ.getLength()&& rPolyPolygon.SequenceZ[0].getLength())
             {
-                ::basegfx::B3DHomMatrix aM;
-                aM.translate( 0
-                            , 0
-                            , rPolyPolygon.SequenceZ[0][0] );
+                basegfx::B3DHomMatrix aM;
+                aM.translate(0, 0, rPolyPolygon.SequenceZ[0][0]);
                 drawing::HomogenMatrix aHM = B3DHomMatrixToHomogenMatrix(aM);
-                xProp->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX
-                    , uno::Any(aHM) );
+                lcl_addProperty(aPropertyNames, aPropertyValues, UNO_NAME_3D_TRANSFORM_MATRIX, uno::Any(aHM));
             }
+            xMultiPropertySet->setPropertyValues(aPropertyNames, aPropertyValues);
         }
         catch( const uno::Exception& e )
         {
@@ -1898,40 +1913,54 @@ uno::Reference< drawing::XShape >
     xTarget->add(xShape);
 
     //set properties
-    uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY );
-    OSL_ENSURE(xProp.is(), "created shape offers no XPropertySet");
-    if( xProp.is())
+    uno::Reference<beans::XMultiPropertySet> xMultiPropertySet(xShape, uno::UNO_QUERY);
+    OSL_ENSURE(xMultiPropertySet.is(), "created shape offers no XMultiPropertySet");
+    if (xMultiPropertySet.is())
     {
         try
         {
-            //Polygon
-            xProp->setPropertyValue( UNO_NAME_3D_POLYPOLYGON3D
-                , uno::Any( rPoints ) );
+             uno::Sequence<OUString> aPropertyNames {
+                UNO_NAME_3D_POLYPOLYGON3D,
+                UNO_NAME_3D_LINEONLY
+            };
 
-            //LineOnly
-            xProp->setPropertyValue( UNO_NAME_3D_LINEONLY
-                , uno::Any( true ) );
+            uno::Sequence<uno::Any> aPropertyValues {
+                uno::Any(rPoints),  // Polygon
+                uno::Any(true)      // LineOnly
+            };
 
             //Transparency
             if(rLineProperties.Transparence.hasValue())
-                xProp->setPropertyValue( UNO_NAME_LINETRANSPARENCE
-                    , rLineProperties.Transparence );
+            {
+                lcl_addProperty(aPropertyNames, aPropertyValues,
+                                UNO_NAME_LINETRANSPARENCE,
+                                rLineProperties.Transparence);
+            }
 
             //LineStyle
             if(rLineProperties.LineStyle.hasValue())
-                xProp->setPropertyValue( UNO_NAME_LINESTYLE
-                    , rLineProperties.LineStyle );
+            {
+                lcl_addProperty(aPropertyNames, aPropertyValues,
+                                UNO_NAME_LINESTYLE,
+                                rLineProperties.LineStyle);
+            }
 
             //LineWidth
             if(rLineProperties.Width.hasValue())
-                xProp->setPropertyValue( UNO_NAME_LINEWIDTH
-                    , rLineProperties.Width );
+            {
+                lcl_addProperty(aPropertyNames, aPropertyValues,
+                                UNO_NAME_LINEWIDTH,
+                                rLineProperties.Width);
+            }
 
             //LineColor
             if(rLineProperties.Color.hasValue())
-                xProp->setPropertyValue( UNO_NAME_LINECOLOR
-                    , rLineProperties.Color );
-                    //, uno::Any( sal_Int32( Color(COL_RED).GetColor()) ) );
+            {
+                lcl_addProperty(aPropertyNames, aPropertyValues,
+                                UNO_NAME_LINECOLOR,
+                                rLineProperties.Color);
+            }
+            xMultiPropertySet->setPropertyValues(aPropertyNames, aPropertyValues);
         }
         catch( const uno::Exception& e )
         {
commit d0f8d9e82925231f4921425a6d55ad18bd0e73ac
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Sat Dec 16 21:21:37 2017 +0200

    loplugin:unusedindex Remove useless outer loop
    
    Change-Id: I6e5e7162b1e0ea2b9f33866ea76e2614acdffb06
    Reviewed-on: https://gerrit.libreoffice.org/46606
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit ccb6a1c6d59859467f9d9a6d954501e9329ee202)

diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index a6e69c4d023b..c8cded8ce25d 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -1718,19 +1718,16 @@ IMPL_LINK_NOARG(SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl, Timer *, void)
 
 IMPL_LINK( SvxNumOptionsTabPage, AllLevelHdl_Impl, Edit&, rBox, void )
 {
-    for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
+    sal_uInt16 nMask = 1;
+    for(sal_uInt16 e = 0; e < pActNum->GetLevelCount(); e++)
     {
-        sal_uInt16 nMask = 1;
-        for(sal_uInt16 e = 0; e < pActNum->GetLevelCount(); e++)
+        if(nActNumLvl & nMask)
         {
-            if(nActNumLvl & nMask)
-            {
-                SvxNumberFormat aNumFmt(pActNum->GetLevel(e));
-                aNumFmt.SetIncludeUpperLevels((sal_uInt8) std::min(static_cast<NumericField&>(rBox).GetValue(), sal_Int64(e + 1)) );
-                pActNum->SetLevel(e, aNumFmt);
-            }
-            nMask <<= 1;
+            SvxNumberFormat aNumFmt(pActNum->GetLevel(e));
+            aNumFmt.SetIncludeUpperLevels((sal_uInt8) std::min(static_cast<NumericField&>(rBox).GetValue(), sal_Int64(e + 1)) );
+            pActNum->SetLevel(e, aNumFmt);
         }
+        nMask <<= 1;
     }
     SetModified();
 }
commit b2ebb68ddebf584a08933db5d2351e47b0055c99
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Fri Dec 15 11:43:55 2017 +0100

    lok: sc: header, cursor and selection overlays issues wrt autofilter
    
    Change-Id: I5d797b48083c24e63f7149cf3a469ebf93213311
    Reviewed-on: https://gerrit.libreoffice.org/46530
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>
    (cherry picked from commit a2cd438a34e911650acf8bbd85840eb8aa36543a)

diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 02090556c614..a46413200225 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -616,6 +616,12 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
     ScDocShellModificator aModificator( rDocShell );
 
     ScDocument& rDoc = rDocShell.GetDocument();
+
+    if (ScTabViewShell::isAnyEditViewInRange(/*bColumns*/ false, rQueryParam.nRow1, rQueryParam.nRow2))
+    {
+        return false;
+    }
+
     if (bRecord && !rDoc.IsUndoEnabled())
         bRecord = false;
     ScDBData* pDBData = rDoc.GetDBAtArea( nTab, rQueryParam.nCol1, rQueryParam.nRow1,
@@ -926,6 +932,16 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
                                         pOld, bDoSize, pAdvSource ) );
     }
 
+    ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
+    if ( pViewSh )
+    {
+        // could there be horizontal autofilter ?
+        // maybe it would be better to set bColumns to !rQueryParam.bByRow ?
+        // anyway at the beginning the value of bByRow is 'false'
+        // then after the first sort action it becomes 'true'
+        pViewSh->OnLOKShowHideColRow(/*bColumns*/ false, rQueryParam.nRow1 - 1);
+    }
+
     if (bCopy)
     {
         SCCOL nEndX = aLocalParam.nCol2;
diff --git a/sc/source/ui/docshell/olinefun.cxx b/sc/source/ui/docshell/olinefun.cxx
index 410c6e1bc58a..90df8eb475ba 100644
--- a/sc/source/ui/docshell/olinefun.cxx
+++ b/sc/source/ui/docshell/olinefun.cxx
@@ -79,32 +79,6 @@ static void lcl_PaintWidthHeight( ScDocShell& rDocShell, SCTAB nTab,
     rDocShell.PostPaint( nStartCol,nStartRow,nTab, MAXCOL,MAXROW,nTab, nParts );
 }
 
-static bool lcl_IsAnyViewEditingInEntryRange(bool bColumns, SCCOLROW nStart, SCCOLROW nEnd)
-{
-    if (comphelper::LibreOfficeKit::isActive())
-    {
-        SfxViewShell* pViewShell = SfxViewShell::GetFirst();
-        while (pViewShell)
-        {
-            ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
-            if (pTabViewShell)
-            {
-                ScInputHandler* pInputHandler = pTabViewShell->GetInputHandler();
-                if (pInputHandler && pInputHandler->GetActiveView())
-                {
-                    const ScViewData& rViewData = pTabViewShell->GetViewData();
-                    SCCOLROW nPos = bColumns ? rViewData.GetCurX() : rViewData.GetCurY();
-                    if (nStart <= nPos && nPos <= nEnd)
-                        return true;
-                }
-            }
-            pViewShell = SfxViewShell::GetNext(*pViewShell);
-        }
-    }
-    return false;
-}
-
-
 void ScOutlineDocFunc::MakeOutline( const ScRange& rRange, bool bColumns, bool bRecord, bool bApi )
 {
     SCCOL nStartCol = rRange.aStart.Col();
@@ -393,7 +367,7 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
         sal_uInt16 nThisLevel = aIter.LastLevel();
         bool bShow = (nThisLevel < nLevel);
 
-        if (!bShow && lcl_IsAnyViewEditingInEntryRange(bColumns, nThisStart, nThisEnd))

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list