[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 42 commits - comphelper/source desktop/qa desktop/README.vars desktop/source framework/source include/comphelper include/LibreOfficeKit include/sfx2 include/vcl sfx2/Library_sfx.mk sfx2/source sw/inc sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Oct 6 07:59:14 PDT 2015


 comphelper/source/misc/lok.cxx                 |   12 +++
 desktop/README.vars                            |   16 ++++
 desktop/qa/desktop_lib/test_desktop_lib.cxx    |   32 +++++++--
 desktop/source/lib/init.cxx                    |   72 +++++++++++++++++++--
 framework/source/helper/statusindicator.cxx    |    2 
 include/LibreOfficeKit/LibreOfficeKit.h        |   19 ++++-
 include/LibreOfficeKit/LibreOfficeKit.hxx      |   50 +++++++++++++++
 include/comphelper/lok.hxx                     |    5 +
 include/sfx2/lokhelper.hxx                     |   34 ++++++++++
 include/sfx2/viewsh.hxx                        |    7 ++
 include/vcl/ITiledRenderable.hxx               |    2 
 sfx2/Library_sfx.mk                            |    1 
 sfx2/source/view/lokhelper.cxx                 |   83 +++++++++++++++++++++++++
 sfx2/source/view/viewimp.hxx                   |    3 
 sfx2/source/view/viewsh.cxx                    |   14 ++++
 sw/inc/crsrsh.hxx                              |    2 
 sw/inc/viewsh.hxx                              |    3 
 sw/qa/extras/tiledrendering/tiledrendering.cxx |    4 +
 sw/source/core/crsr/crsrsh.cxx                 |   34 +++++++++-
 sw/source/core/crsr/viscrs.cxx                 |   34 +++++++---
 sw/source/core/text/xmldump.cxx                |   10 +--
 sw/source/core/view/viewsh.cxx                 |    6 +
 sw/source/uibase/docvw/edtwin.cxx              |   10 ++-
 23 files changed, 413 insertions(+), 42 deletions(-)

New commits:
commit fa579fa78e35b8507f228f47702c156d7c160253
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 18 14:32:53 2015 +0200

    sw: implement per-view LOK_CALLBACK_CURSOR_VISIBLE
    
    Change-Id: I4e00679547997cfb3dafe603b908f055011a3b30
    (cherry picked from commit 32f419fee5f9df4facb7a9b3ec910471d2a20247)

diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 442eb7b..4339937 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -23,6 +23,7 @@
 #include <hintids.hxx>
 #include <svx/svdmodel.hxx>
 #include <editeng/frmdiritem.hxx>
+#include <sfx2/viewsh.hxx>
 #include <SwSmartTagMgr.hxx>
 #include <doc.hxx>
 #include <rootfrm.hxx>
@@ -63,6 +64,7 @@
 #include <comcore.hrc>
 #include <IDocumentLayoutAccess.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
 
 using namespace com::sun::star;
 using namespace util;
@@ -2118,8 +2120,13 @@ void SwCrsrShell::ShowCrsr()
         m_bSVCrsrVis = true;
         m_pCurCrsr->SetShowTextInputFieldOverlay( true );
 
-        if (isTiledRendering())
-            libreOfficeKitCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr());
+        if (comphelper::LibreOfficeKit::isActive())
+        {
+            if (comphelper::LibreOfficeKit::isViewCallback())
+                GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr());
+            else
+                libreOfficeKitCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr());
+        }
 
         UpdateCrsr();
     }
@@ -2135,8 +2142,13 @@ void SwCrsrShell::HideCrsr()
         m_pCurCrsr->SetShowTextInputFieldOverlay( false );
         m_pVisCrsr->Hide();
 
-        if (isTiledRendering())
-            libreOfficeKitCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr());
+        if (comphelper::LibreOfficeKit::isActive())
+        {
+            if (comphelper::LibreOfficeKit::isViewCallback())
+                GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr());
+            else
+                libreOfficeKitCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr());
+        }
     }
 }
 
commit 8f95f34195e638e6689f090b85def209194fac5d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 18 14:29:18 2015 +0200

    sw: implement per-view LOK_CALLBACK_TEXT_SELECTION
    
    Also:
    
    - let the unit test set the global LOK flag, as sw code now depends on
      that
    - in framework, don't return early after emitting the LOK status
      indicator callback, otherwise CppunitTest_sw_tiledrendering shows how
      sw LOK callbacks are missing
    
    Change-Id: I0c4ac12f2ef5118d29afd131676bcb27d5db7746
    (cherry picked from commit 1a83f30ebe2c56b00804ce774537b34f1049be84)

diff --git a/framework/source/helper/statusindicator.cxx b/framework/source/helper/statusindicator.cxx
index 5c9dafc..ce8310a 100644
--- a/framework/source/helper/statusindicator.cxx
+++ b/framework/source/helper/statusindicator.cxx
@@ -43,7 +43,6 @@ void SAL_CALL StatusIndicator::start(const OUString& sText ,
         m_nLastCallbackPercent = -1;
 
         comphelper::LibreOfficeKit::statusIndicatorStart();
-        return;
     }
 
     css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory(m_xFactory);
@@ -60,7 +59,6 @@ void SAL_CALL StatusIndicator::end()
     if (comphelper::LibreOfficeKit::isActive())
     {
         comphelper::LibreOfficeKit::statusIndicatorFinish();
-        return;
     }
 
     css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory(m_xFactory);
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 07dd7e3..e7ab149 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -383,6 +383,8 @@ void SwTiledRenderingTest::testSearchViewArea()
 void SwTiledRenderingTest::testSearchTextFrame()
 {
 #if !defined(WNT) && !defined(MACOSX)
+    comphelper::LibreOfficeKit::setActive();
+
     SwXTextDocument* pXTextDocument = createDoc("search.odt");
     pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
     uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
@@ -393,6 +395,8 @@ void SwTiledRenderingTest::testSearchTextFrame()
     comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
     // This was empty: nothing was highlighted after searching for 'TextFrame'.
     CPPUNIT_ASSERT(!m_aTextSelection.isEmpty());
+
+    comphelper::LibreOfficeKit::setActive(false);
 #endif
 }
 
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 13cfcd8..8087561 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -361,7 +361,7 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
         // talks about "the" cursor at the moment. As long as that's true,
         // don't say anything about the Writer cursor till a draw object is
         // being edited.
-        if (GetShell()->isTiledRendering() && !pView->GetTextEditObject())
+        if (comphelper::LibreOfficeKit::isActive() && !pView->GetTextEditObject())
         {
             if (!empty())
             {
@@ -377,12 +377,18 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
                 if (aStartRect.HasArea())
                 {
                     OString sRect = aStartRect.SVRect().toString();
-                    GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr());
+                    if (comphelper::LibreOfficeKit::isViewCallback())
+                        GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr());
+                    else
+                        GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr());
                 }
                 if (aEndRect.HasArea())
                 {
                     OString sRect = aEndRect.SVRect().toString();
-                    GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr());
+                    if (comphelper::LibreOfficeKit::isViewCallback())
+                        GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr());
+                    else
+                        GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr());
                 }
             }
 
@@ -396,7 +402,12 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
             }
             OString sRect = ss.str().c_str();
             if (!pSelectionRectangles)
-                GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+            {
+                if (comphelper::LibreOfficeKit::isViewCallback())
+                    GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+                else
+                    GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+            }
             else
                 pSelectionRectangles->push_back(sRect);
         }
@@ -593,7 +604,7 @@ void SwShellCrsr::Show()
             pShCrsr->SwSelPaintRects::Show(&aSelectionRectangles);
     }
 
-    if (GetShell()->isTiledRendering())
+    if (comphelper::LibreOfficeKit::isActive())
     {
         std::stringstream ss;
         bool bFirst = true;
@@ -609,7 +620,10 @@ void SwShellCrsr::Show()
             ss << rSelectionRectangle.getStr();
         }
         OString sRect = ss.str().c_str();
-        GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+        if (comphelper::LibreOfficeKit::isViewCallback())
+            GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+        else
+            GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
     }
 }
 
commit 8dc6418d4ee6d536a80d43843dc63d826f225be7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 18 11:14:58 2015 +0200

    gtktiledviewer: fix leftover import progressbar in createView()
    
    (cherry picked from commit af29b2b57cc07490cc36ff02d5ff3f3844e7c102)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: Ia71e80c521cdc6a8e4df52e51e063a44a0dd53df
commit 6f056c71aace81c72b619a52c1ad0e9a49292e7a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 18 10:58:24 2015 +0200

    gtktiledviewer: don't crash on opening non-existing files
    
    (cherry picked from commit 43b2103f932c92374e2ba2ab0ec1006582a0f646)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    	libreofficekit/source/gtk/lokdocview.cxx
    
    Change-Id: Ic48adaf038e8fbcc86a94b5e351d2f963fcfcd16
commit 09832857e0eef85f9fbc1a753ca5ef937ebb57f6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 18 08:31:36 2015 +0200

    desktop: document a number of environment variables
    
    Change-Id: Ie33f8b2f8d2a65fbdb7f4f3caaeee8f0f046cba5
    (cherry picked from commit de244205f2287263ee9013cf37108186aed531cf)

diff --git a/desktop/README.vars b/desktop/README.vars
new file mode 100644
index 0000000..b84a270
--- /dev/null
+++ b/desktop/README.vars
@@ -0,0 +1,16 @@
+Environment variables in desktop:
+
+General
+-------
+
+DISPLAY - X11 display to use.
+OOO_DISABLE_RECOVERY - Disables the recovery dialog.
+OOO_EXIT_POST_STARTUP - Exit right after startup, for profiling purposes.
+SAL_DISABLE_USERMIGRATION - Disable automatic conversion of old user configurations.
+SAL_USE_VCLPLUGIN - Which VCL plugin to use instead of the auto-detected one.
+
+LibreOfficeKit
+--------------
+
+LOK_DEBUG - Draw a small red rectangle in the top left corner so that it's easy to see where a new tile begins.
+LOK_VIEW_CALLBACK - Use incomplete per-view callbacks instead of a single one.
commit f3a9b3b9999b6acb92bc7e695ddf24d2b80ffc92
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 17:19:49 2015 +0200

    sw: implement per-view LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR
    
    Change-Id: Ib4c1caede94d3eac372a3605c430bbbd353755f3
    (cherry picked from commit 5c2811d682c6e623f3b2613df3119987c0c79c12)

diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index abb9f0b..eaa0bf9 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -449,7 +449,7 @@ public:
                           { return mpCareWindow ? mpCareWindow.get() : CareChildWin(rVSh); }
     static vcl::Window*   CareChildWin(SwViewShell& rVSh);
 
-    inline SfxViewShell   *GetSfxViewShell() { return mpSfxViewShell; }
+    inline SfxViewShell   *GetSfxViewShell() const { return mpSfxViewShell; }
     inline void           SetSfxViewShell(SfxViewShell *pNew) { mpSfxViewShell = pNew; }
 
     // Selection of  Draw Engine has been changed.
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index e0d32cc..13cfcd8 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -54,6 +54,7 @@
 #include <boost/scoped_ptr.hpp>
 
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
 #include <paintfrm.hxx>
 
 // Here static members are defined. They will get changed on alteration of the
@@ -178,7 +179,7 @@ void SwVisCrsr::_SetPosAndShow()
 
     m_aTextCrsr.SetPos( aRect.Pos() );
 
-    if (m_pCrsrShell->isTiledRendering())
+    if (comphelper::LibreOfficeKit::isActive())
     {
         // notify about page number change (if that happened)
         sal_uInt16 nPage, nVirtPage;
@@ -193,7 +194,10 @@ void SwVisCrsr::_SetPosAndShow()
         // notify about the cursor position & size
         Rectangle aSVRect(aRect.Pos().getX(), aRect.Pos().getY(), aRect.Pos().getX() + aRect.SSize().Width(), aRect.Pos().getY() + aRect.SSize().Height());
         OString sRect = aSVRect.toString();
-        m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
+        if (comphelper::LibreOfficeKit::isViewCallback())
+            m_pCrsrShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
+        else
+            m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
     }
 
     if ( !m_pCrsrShell->IsCrsrReadonly()  || m_pCrsrShell->GetViewOptions()->IsSelectionInReadonly() )
commit 9c445b8cd52a8599797862ef39d6d5d625737355
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 15:42:16 2015 +0200

    sfx2: adapt comment to reality
    
    Change-Id: I9dd2934eaa7b479460c3a2dc7d2d51ce5c767a9f
    (cherry picked from commit b20de6c5cfad2a48c4b35b7111b3d6ea285de061)

diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 69bd32c..945b38a 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -320,7 +320,7 @@ public:
     SAL_DLLPRIVATE void TakeFrameOwnership_Impl();
     SAL_DLLPRIVATE bool ExecKey_Impl(const KeyEvent& aKey);
 
-    /// The actual implementation of the lok::Document::registerViewCallback() API.
+    /// The actual per-view implementation of lok::Document::registerCallback().
     void registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
     /// Invokes the registered callback, if there are any.
     void libreOfficeKitViewCallback(int nType, const char* pPayload) const;
commit 50667d768d6dae43465eb839afad2e20d8eda8b9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 15:39:19 2015 +0200

    lok::Document: register callback in the view, if requested
    
    With this, a postKeyEvent() in one view properly results in one
    LOK_CALLBACK_INVALIDATE_TILES per view, at least in Writer.
    
    Change-Id: Ia0a9a00ea5a98c38f3d399208b9ef028f3036f79
    (cherry picked from commit b8a54763f4f66538f13b6c0e13045e5cb3167ca4)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2d5c270..fea4ec6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -54,6 +54,8 @@
 #include <sfx2/msgpool.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/lokhelper.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/viewsh.hxx>
 #include <svx/svxids.hrc>
 #include <vcl/svapp.hxx>
 #include <vcl/svpforlokit.hxx>
@@ -816,14 +818,22 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
                                 LibreOfficeKitCallback pCallback,
                                 void* pData)
 {
-    ITiledRenderable* pDoc = getTiledRenderable(pThis);
-    if (!pDoc)
+    if (comphelper::LibreOfficeKit::isViewCallback())
     {
-        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
-        return;
+        if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell())
+            pViewShell->registerLibreOfficeKitViewCallback(pCallback, pData);
     }
+    else
+    {
+        ITiledRenderable* pDoc = getTiledRenderable(pThis);
+        if (!pDoc)
+        {
+            gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+            return;
+        }
 
-    pDoc->registerCallback(pCallback, pData);
+        pDoc->registerCallback(pCallback, pData);
+    }
 }
 
 static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nCharCode, int nKeyCode)
commit efc318650e22ccd99d2df2f8f67aed0999036095
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 11:44:53 2015 +0200

    sw: implement per-view LOK_CALLBACK_INVALIDATE_TILES
    
    Change-Id: Id839dc076824e69fe07386c83bf21fc4c7ce2b8e
    (cherry picked from commit b0f04d1ba273cc94989a5079f957117433076a9b)

diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 388ca50..f60723b 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -69,6 +69,7 @@
 #include <basegfx/polygon/b2dpolygon.hxx>
 
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
 
 #include <editeng/acorrcfg.hxx>
 #include <SwSmartTagMgr.hxx>
@@ -6217,8 +6218,13 @@ void SwEditWin::LogicInvalidate(const Rectangle* pRectangle)
     else
         sRectangle = pRectangle->toString();
 
-    if ( m_rView.GetWrtShellPtr() )
-        m_rView.GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
+    if (comphelper::LibreOfficeKit::isViewCallback())
+        m_rView.libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
+    else
+    {
+        if (m_rView.GetWrtShellPtr())
+            m_rView.GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
+    }
 }
 
 void SwEditWin::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
commit 17d82b77a567a2fb3d69e8541d60284702bc632e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 10:59:13 2015 +0200

    comphelper: add LibreOfficeKit::set/isViewCallback()
    
    Change-Id: Iad0b2ee419327daf478f3ddda2378effe0184067
    (cherry picked from commit 1704221067e2bc6ba26eaa83573d29964b413a34)

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index a6abd2a..279ec65 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -17,6 +17,8 @@ namespace LibreOfficeKit
 
 static bool g_bActive(false);
 
+static bool g_bViewCallback(false);
+
 void setActive(bool bActive)
 {
     g_bActive = bActive;
@@ -27,6 +29,16 @@ bool isActive()
     return g_bActive;
 }
 
+void setViewCallback(bool bViewCallback)
+{
+    g_bViewCallback = bViewCallback;
+}
+
+bool isViewCallback()
+{
+    return g_bViewCallback;
+}
+
 static void (*pStatusIndicatorCallback)(void *data, statusIndicatorCallbackType type, int percent)(nullptr);
 static void *pStatusIndicatorCallbackData(nullptr);
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 274eb72..2d5c270 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1190,6 +1190,10 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
         return 1;
 
     comphelper::LibreOfficeKit::setActive();
+
+    static bool bViewCallback = getenv("LOK_VIEW_CALLBACK");
+    comphelper::LibreOfficeKit::setViewCallback(bViewCallback);
+
     comphelper::LibreOfficeKit::setStatusIndicatorCallback(lo_status_indicator_callback, pLib);
 
     if (pUserProfilePath)
diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index 79fa115..2cc38c6 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -36,6 +36,11 @@ COMPHELPER_DLLPUBLIC void setStatusIndicatorCallback(void (*callback)(void *data
 // Check whether the code is running as invoked through LibreOfficeKit.
 COMPHELPER_DLLPUBLIC bool isActive();
 
+/// Check whether clients register a callback for each view.
+COMPHELPER_DLLPUBLIC bool isViewCallback();
+/// Set whether clients register a callback for each view.
+COMPHELPER_DLLPUBLIC void setViewCallback(bool bViewCallback);
+
 // 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.
commit 7755b08d465d63503f2883de52e01b55c3189079
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 10:58:56 2015 +0200

    sfx2: add SfxViewShell::libreOfficeKitViewCallback()
    
    This is similar to the existing LOK callback, the difference is that the
    existing one assumes there is only one SfxViewShell instance at the same
    time.
    
    This newer callback is precisely per-view, so model notifications can
    invoke all view callbacks, while view notifications can invoke only the
    callback of the relevant view.
    
    This is just the framework, all actual client code has to be still
    ported over (and then the existing callback can be removed).
    
    (cherry picked from commit c74ccac7cd94eba052d21cf74e03e214d58942e4)
    
    Conflicts:
    	sfx2/source/view/viewimp.hxx
    
    Change-Id: I3d8f27740c69fcf6ffbbdce12db2ea088321493d

diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index c6e7f4a..69bd32c 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -39,6 +39,8 @@
 #include <o3tl/typed_flags_set.hxx>
 #include <vcl/vclptr.hxx>
 #include <sfx2/tabdlg.hxx>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKitTypes.h>
 
 class SfxBaseController;
 class Size;
@@ -317,6 +319,11 @@ public:
     SAL_DLLPRIVATE void TakeOwnership_Impl();
     SAL_DLLPRIVATE void TakeFrameOwnership_Impl();
     SAL_DLLPRIVATE bool ExecKey_Impl(const KeyEvent& aKey);
+
+    /// The actual implementation of the lok::Document::registerViewCallback() API.
+    void registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
+    /// Invokes the registered callback, if there are any.
+    void libreOfficeKitViewCallback(int nType, const char* pPayload) const;
 };
 
 
diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx
index 43b25d0..2d2ddf3 100644
--- a/sfx2/source/view/viewimp.hxx
+++ b/sfx2/source/view/viewimp.hxx
@@ -65,6 +65,9 @@ struct SfxViewShell_Impl
 
     mutable SfxInPlaceClientList* mpIPClientList;
 
+    LibreOfficeKitCallback m_pLibreOfficeKitViewCallback;
+    void* m_pLibreOfficeKitViewData;
+
     SfxViewShell_Impl(SfxViewShellFlags const nFlags);
     ~SfxViewShell_Impl();
 
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 939c590..8e7e685 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -310,6 +310,8 @@ SfxViewShell_Impl::SfxViewShell_Impl(SfxViewShellFlags const nFlags)
 ,   m_nFamily(0xFFFF)   // undefined, default set by TemplateDialog
 ,   m_pController(0)
 ,   mpIPClientList(NULL)
+,   m_pLibreOfficeKitViewCallback(0)
+,   m_pLibreOfficeKitViewData(0)
 {}
 
 SfxViewShell_Impl::~SfxViewShell_Impl()
@@ -1633,6 +1635,18 @@ bool SfxViewShell::ExecKey_Impl(const KeyEvent& aKey)
     return pImp->m_xAccExec->execute(aKey.GetKeyCode());
 }
 
+void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pData)
+{
+    pImp->m_pLibreOfficeKitViewCallback = pCallback;
+    pImp->m_pLibreOfficeKitViewData = pData;
+}
+
+void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) const
+{
+    if (pImp->m_pLibreOfficeKitViewCallback)
+        pImp->m_pLibreOfficeKitViewCallback(nType, pPayload, pImp->m_pLibreOfficeKitViewData);
+}
+
 bool SfxViewShell::KeyInput( const KeyEvent &rKeyEvent )
 
 /*  [Description]
commit dbf5c74789c580ec60ef7545da4c8d9589d0a4db
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 09:30:09 2015 +0200

    SfxLokHelper::setView: check if view is already current
    
    Change-Id: I9cf3a4887774657e0e205114688b088fc11c6822
    (cherry picked from commit 714257af17f74f8bcb5acceaebb0d0f4b3be3231)

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 646715e..f3731e7 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -45,6 +45,9 @@ void SfxLokHelper::setView(size_t nId)
         return;
 
     SfxViewShell* pViewShell = rViewArr[nId];
+    if (pViewShell->GetViewFrame() == SfxViewFrame::Current())
+        return;
+
     if (SfxViewFrame* pViewFrame = pViewShell->GetViewFrame())
         pViewFrame->MakeActive_Impl(false);
 }
commit e0e0c179c8125a5fd1ad54d73dfb773153ce05ec
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 16 14:46:39 2015 +0200

    lokdocview: set view before calling lok::Document member functions
    
    getTextSelection() is still to be done, but has to be moved to the
    widget first.
    
    (cherry picked from commit d3446bc860e2e41adbee5ad6c49f12991dd9087b)
    
    Conflicts:
    	libreofficekit/source/gtk/lokdocview.cxx
    
    Change-Id: I780a31f1dbce38b2b7398bfdacbbc1c40881229d

diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 97ae136..4c3e1fa 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -158,7 +158,7 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::resetSelection
     void (*resetSelection) (LibreOfficeKitDocument* pThis);
 
-    /// @see lok::Document:getStyles
+    /// @see lok::Document::getCommandValues().
     char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
 
     /// @see lok::Document::createView().
commit 7cbf629b2b33ab8dfeaaf8154c40e848bbc75f58
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 16 14:31:49 2015 +0200

    Add missing lok::Document::setPartMode() wrapper
    
    Change-Id: I5dd5f0cfb8b34621b18a35be682249e042d9b173
    (cherry picked from commit 42844c2a8b614efa3bb7cd4f2525ce05a8647d20)

diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index fc025ae..97ae136 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -93,10 +93,7 @@ struct _LibreOfficeKitDocumentClass
     char* (*getPartName) (LibreOfficeKitDocument* pThis,
                           int nPart);
 
-    /** Sets mode of the current part.
-     *
-     * @param nMode - element from the LibreOfficeKitPartMode enum.
-     */
+    /// @see lok::Document::setPartMode().
     void (*setPartMode) (LibreOfficeKitDocument* pThis,
                          int nMode);
 
@@ -118,6 +115,7 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::initializeForRendering().
     void (*initializeForRendering) (LibreOfficeKitDocument* pThis);
 
+    /// @see lok::Document::registerCallback().
     void (*registerCallback) (LibreOfficeKitDocument* pThis,
                               LibreOfficeKitCallback pCallback,
                               void* pData);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 45ace9d..7f96e19 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -94,6 +94,11 @@ public:
         return mpDoc->pClass->getPartName(mpDoc, nPart);
     }
 
+    inline void setPartMode(int nMode)
+    {
+        mpDoc->pClass->setPartMode(mpDoc, nMode);
+    }
+
     /**
      * Renders a subset of the document to a pre-allocated buffer.
      *
commit 787da24c78adda4c9c19469787d9f4ee82721afc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 16 14:28:00 2015 +0200

    LOK: allow postMouseEvent() in multiple views
    
    (cherry picked from commit c9ebc92a1ebd48ad96ee5ca527c250489cb4ec27)
    
    Conflicts:
    	libreofficekit/source/gtk/lokdocview.cxx
    
    Change-Id: Iafb08cb44a96dbc03d12367d21b4120063bd0222
commit dcdff4c897e9a0f10f2422a907b33bea8f4edf6c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 16 14:14:04 2015 +0200

    LOK: make getViews() be a member function of Document
    
    Just to be consistent, as all other view-related member functions are
    there, too.
    
    No real impact, as only the unit test uses this so far, and it always
    works with a single document.
    
    Change-Id: I46f1ed8265ab95017986ab45c1b510e961192241
    (cherry picked from commit a04b31c9facb08a8e38b79480b9a73bd2693cb9e)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 7ad8127..0cd88ce 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -134,10 +134,10 @@ void DesktopLOKTest::testGetFonts()
 void DesktopLOKTest::testCreateView()
 {
     LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
-    CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews());
+    CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument));
 
     int nId = pDocument->m_pDocumentClass->createView(pDocument);
-    CPPUNIT_ASSERT_EQUAL(2, SfxLokHelper::getViews());
+    CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViews(pDocument));
 
     // Make sure the created view is the active one, then switch to the old
     // one.
@@ -146,7 +146,7 @@ void DesktopLOKTest::testCreateView()
     CPPUNIT_ASSERT_EQUAL(0, pDocument->m_pDocumentClass->getView(pDocument));
 
     pDocument->m_pDocumentClass->destroyView(pDocument, nId);
-    CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews());
+    CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument));
     closeDoc();
 }
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e898a04..274eb72 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -254,6 +254,7 @@ static int doc_createView(LibreOfficeKitDocument* pThis);
 static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
 static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
 static int doc_getView(LibreOfficeKitDocument* pThis);
+static int doc_getViews(LibreOfficeKitDocument* pThis);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
     mxComponent( xComponent )
@@ -289,6 +290,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->destroyView = doc_destroyView;
         m_pDocumentClass->setView = doc_setView;
         m_pDocumentClass->getView = doc_getView;
+        m_pDocumentClass->getViews = doc_getViews;
 
         gDocumentClass = m_pDocumentClass;
     }
@@ -316,8 +318,6 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions  (LibreOfficeKit* pThi
 static void                    lo_registerCallback (LibreOfficeKit* pThis,
                                                     LibreOfficeKitCallback pCallback,
                                                     void* pData);
-static int lo_getViews(LibreOfficeKit* pThis);
-
 struct LibLibreOffice_Impl : public _LibreOfficeKit
 {
     OUString maLastExceptionMsg;
@@ -340,7 +340,6 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
             m_pOfficeClass->getError = lo_getError;
             m_pOfficeClass->documentLoadWithOptions = lo_documentLoadWithOptions;
             m_pOfficeClass->registerCallback = lo_registerCallback;
-            m_pOfficeClass->getViews = lo_getViews;
 
             gOfficeClass = m_pOfficeClass;
         }
@@ -458,11 +457,6 @@ static void lo_registerCallback (LibreOfficeKit* pThis,
     pLib->mpCallbackData = pData;
 }
 
-static int lo_getViews(LibreOfficeKit* /*pThis*/)
-{
-    return SfxLokHelper::getViews();
-}
-
 static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const char* pFormat, const char* pFilterOptions)
 {
     LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
@@ -1077,6 +1071,13 @@ static int doc_getView(LibreOfficeKitDocument* /*pThis*/)
     return SfxLokHelper::getView();
 }
 
+static int doc_getViews(LibreOfficeKitDocument* /*pThis*/)
+{
+    SolarMutexGuard aGuard;
+
+    return SfxLokHelper::getViews();
+}
+
 static char* lo_getError (LibreOfficeKit *pThis)
 {
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 18f4b3e..fc025ae 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -54,9 +54,6 @@ struct _LibreOfficeKitClass
     void (*registerCallback) (LibreOfficeKit* pThis,
                               LibreOfficeKitCallback pCallback,
                               void* pData);
-
-    /// @see lok::Office::getViews().
-    int (*getViews) (LibreOfficeKit* pThis);
 #endif
 };
 
@@ -174,6 +171,8 @@ struct _LibreOfficeKitDocumentClass
     void (*setView) (LibreOfficeKitDocument* pThis, int nId);
     /// @see lok::Document::getView().
     int (*getView) (LibreOfficeKitDocument* pThis);
+    /// @see lok::Document::getViews().
+    int (*getViews) (LibreOfficeKitDocument* pThis);
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index f5821b7..45ace9d 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -294,6 +294,14 @@ public:
     {
         return mpDoc->pClass->getView(mpDoc);
     }
+
+    /**
+     * Get number of views of this document.
+     */
+    inline int getViews()
+    {
+        return mpDoc->pClass->getViews(mpDoc);
+    }
 #endif // LOK_USE_UNSTABLE_API
 };
 
@@ -340,16 +348,6 @@ public:
     {
         return mpThis->pClass->getError(mpThis);
     }
-
-#ifdef LOK_USE_UNSTABLE_API
-    /**
-     * Get number of total views.
-     */
-    inline int getViews()
-    {
-        return mpThis->pClass->getViews(mpThis);
-    }
-#endif
 };
 
 /// Factory method to create a lok::Office instance.
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 5051622..99f2076 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -25,9 +25,8 @@ public:
     static void setView(size_t nId);
     /// Get the currently active view.
     static size_t getView();
-
-    /// Total number of view shells.
-    static int getViews();
+    /// Get the number of views of the current object shell.
+    static size_t getViews();
 };
 
 #endif
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 0beb06d..646715e 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -62,10 +62,19 @@ size_t SfxLokHelper::getView()
     return 0;
 }
 
-int SfxLokHelper::getViews()
+size_t SfxLokHelper::getViews()
 {
+    size_t nRet = 0;
+
+    SfxObjectShell* pObjectShell = SfxViewFrame::Current()->GetObjectShell();
     SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
-    return rViewArr.size();
+    for (size_t i = 0; i < rViewArr.size(); ++i)
+    {
+        if (rViewArr[i]->GetObjectShell() == pObjectShell)
+            ++nRet;
+    }
+
+    return nRet;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit b40bc4e75a7fc3d4dc4eca6c556e4f93f2143249
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 16 12:30:25 2015 +0200

    gtktiledviewer: use setView() before postKeyEvent()
    
    Also in SfxLokHelper::setView() set the current view shell directly,
    GetFocus() in VCL may be a NOP for hidden windows.
    
    With this, the Writer layout dump shows that two Gtk windows can have
    different cursor positions correctly.
    
    (cherry picked from commit f2e55ea10676d14c6564696a0648c0edbe4bd36d)
    
    Conflicts:
    	libreofficekit/source/gtk/lokdocview.cxx
    
    Change-Id: I81890c1d8ad7972f1194db3d5f2e9d8a39fc2f87

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index f53d2b3..0beb06d 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -46,7 +46,7 @@ void SfxLokHelper::setView(size_t nId)
 
     SfxViewShell* pViewShell = rViewArr[nId];
     if (SfxViewFrame* pViewFrame = pViewShell->GetViewFrame())
-        pViewFrame->GetWindow().GrabFocus();
+        pViewFrame->MakeActive_Impl(false);
 }
 
 size_t SfxLokHelper::getView()
commit 425b2076a2bdfa24691e7df50be6f110422283a7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 16 10:32:34 2015 +0200

    Use SfxViewFrame::Current()
    
    Allows getting rid of vcl::ITiledRenderable::getCurrentViewShell(),
    which would do the same, just not implemented outside Writer.
    
    Change-Id: Id26ceca560fb9002dc2d5c740c411b9c4a149523
    (cherry picked from commit 8cb6094447041b7fbe29bd5584b5daf9babb5cad)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c56e8d0..e898a04 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1049,19 +1049,11 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
     }
 }
 
-static int doc_createView(LibreOfficeKitDocument* pThis)
+static int doc_createView(LibreOfficeKitDocument* /*pThis*/)
 {
     SolarMutexGuard aGuard;
 
-    ITiledRenderable* pDoc = getTiledRenderable(pThis);
-    if (!pDoc)
-    {
-        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
-        return -1;
-    }
-
-    SfxViewShell* pViewShell = pDoc->getCurrentViewShell();
-    return SfxLokHelper::createView(pViewShell);
+    return SfxLokHelper::createView();
 }
 
 static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId)
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index a05cd5d..5051622 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -17,8 +17,8 @@ class SfxViewShell;
 class SFX2_DLLPUBLIC SfxLokHelper
 {
 public:
-    /// Create a new view shell for pViewShell's object shell.
-    static int createView(SfxViewShell* pViewShell);
+    /// Create a new view shell from the current view frame.
+    static int createView();
     /// Destroy a view shell from the global shell list.
     static void destroyView(size_t nId);
     /// Set a view shell as current one.
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 6a573bc..18bd3a4 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -16,8 +16,6 @@
 #include <tools/gen.hxx>
 #include <vcl/virdev.hxx>
 
-class SfxViewShell;
-
 namespace vcl
 {
 
@@ -141,12 +139,6 @@ public:
      * @see lok::Document::resetSelection().
      */
     virtual void resetSelection() = 0;
-
-    /// Get the currently active view shell of the document.
-    virtual SfxViewShell* getCurrentViewShell()
-    {
-        return 0;
-    }
 };
 
 } // namespace vcl
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 0aea6db..f53d2b3 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -15,9 +15,9 @@
 
 #include <shellimpl.hxx>
 
-int SfxLokHelper::createView(SfxViewShell* pViewShell)
+int SfxLokHelper::createView()
 {
-    SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
+    SfxViewFrame* pViewFrame = SfxViewFrame::Current();
     SfxRequest aRequest(pViewFrame, SID_NEWWINDOW);
     pViewFrame->ExecView_Impl(aRequest);
 
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 71dbb4f..9f0b03b 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -431,8 +431,6 @@ public:
     virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::resetSelection().
     virtual void resetSelection() SAL_OVERRIDE;
-    /// @see vcl::ITiledRenderable::getCurrentViewShell().
-    virtual SfxViewShell* getCurrentViewShell() SAL_OVERRIDE;
 
     // ::com::sun::star::tiledrendering::XTiledRenderable
     virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index fbacf5d..b0f37a8 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3401,11 +3401,6 @@ void SwXTextDocument::resetSelection()
     pWrtShell->ResetSelect(0, false);
 }
 
-SfxViewShell* SwXTextDocument::getCurrentViewShell()
-{
-    return pDocShell->GetView();
-}
-
 void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception)
 {
     SystemGraphicsData aData;
commit 470db78ef09351db67fc22c70c5dd4b98bc43a14
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 16 09:30:41 2015 +0200

    lok::Document: add get/setView()
    
    Change-Id: Ic3bce8f01d7e048e853c063c4bce1255845c60d0
    (cherry picked from commit 46588c42a546d4517b773853856b9c8f8c2e5ece)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 6baaa32..7ad8127 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -139,6 +139,12 @@ void DesktopLOKTest::testCreateView()
     int nId = pDocument->m_pDocumentClass->createView(pDocument);
     CPPUNIT_ASSERT_EQUAL(2, SfxLokHelper::getViews());
 
+    // Make sure the created view is the active one, then switch to the old
+    // one.
+    CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getView(pDocument));
+    pDocument->m_pDocumentClass->setView(pDocument, 0);
+    CPPUNIT_ASSERT_EQUAL(0, pDocument->m_pDocumentClass->getView(pDocument));
+
     pDocument->m_pDocumentClass->destroyView(pDocument, nId);
     CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews());
     closeDoc();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 75fbafa..c56e8d0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -252,6 +252,8 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
 
 static int doc_createView(LibreOfficeKitDocument* pThis);
 static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
+static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
+static int doc_getView(LibreOfficeKitDocument* pThis);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
     mxComponent( xComponent )
@@ -285,6 +287,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
 
         m_pDocumentClass->createView = doc_createView;
         m_pDocumentClass->destroyView = doc_destroyView;
+        m_pDocumentClass->setView = doc_setView;
+        m_pDocumentClass->getView = doc_getView;
 
         gDocumentClass = m_pDocumentClass;
     }
@@ -1067,6 +1071,20 @@ static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId)
     SfxLokHelper::destroyView(nId);
 }
 
+static void doc_setView(LibreOfficeKitDocument* /*pThis*/, int nId)
+{
+    SolarMutexGuard aGuard;
+
+    SfxLokHelper::setView(nId);
+}
+
+static int doc_getView(LibreOfficeKitDocument* /*pThis*/)
+{
+    SolarMutexGuard aGuard;
+
+    return SfxLokHelper::getView();
+}
+
 static char* lo_getError (LibreOfficeKit *pThis)
 {
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 7f41d13..18f4b3e 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -170,6 +170,10 @@ struct _LibreOfficeKitDocumentClass
     int (*createView) (LibreOfficeKitDocument* pThis);
     /// @see lok::Document::destroyView().
     void (*destroyView) (LibreOfficeKitDocument* pThis, int nId);
+    /// @see lok::Document::setView().
+    void (*setView) (LibreOfficeKitDocument* pThis, int nId);
+    /// @see lok::Document::getView().
+    int (*getView) (LibreOfficeKitDocument* pThis);
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 3e1a0ac..f5821b7 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -269,13 +269,31 @@ public:
     }
 
     /**
-     * Destroy a view of an existring document.
+     * Destroy a view of an existing document.
      * @param nId a view ID, returned by createView().
      */
     void destroyView(int nId)
     {
         mpDoc->pClass->destroyView(mpDoc, nId);
     }
+
+    /**
+     * Set an existing view of an existing document as current.
+     * @param nId a view ID, returned by createView().
+     */
+    void setView(int nId)
+    {
+        mpDoc->pClass->setView(mpDoc, nId);
+    }
+
+    /**
+     * Get the current view.
+     * @return a view ID, previously returned by createView().
+     */
+    int getView()
+    {
+        return mpDoc->pClass->getView(mpDoc);
+    }
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index b57cb7d..a05cd5d 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -21,6 +21,10 @@ public:
     static int createView(SfxViewShell* pViewShell);
     /// Destroy a view shell from the global shell list.
     static void destroyView(size_t nId);
+    /// Set a view shell as current one.
+    static void setView(size_t nId);
+    /// Get the currently active view.
+    static size_t getView();
 
     /// Total number of view shells.
     static int getViews();
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 557478a..0aea6db 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -38,6 +38,30 @@ void SfxLokHelper::destroyView(size_t nId)
     pViewFrame->Exec_Impl(aRequest);
 }
 
+void SfxLokHelper::setView(size_t nId)
+{
+    SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+    if (nId > rViewArr.size() - 1)
+        return;
+
+    SfxViewShell* pViewShell = rViewArr[nId];
+    if (SfxViewFrame* pViewFrame = pViewShell->GetViewFrame())
+        pViewFrame->GetWindow().GrabFocus();
+}
+
+size_t SfxLokHelper::getView()
+{
+    SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+    SfxViewFrame* pViewFrame = SfxViewFrame::Current();
+    for (size_t i = 0; i < rViewArr.size(); ++i)
+    {
+        if (rViewArr[i]->GetViewFrame() == pViewFrame)
+            return i;
+    }
+    assert(false);
+    return 0;
+}
+
 int SfxLokHelper::getViews()
 {
     SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
commit a0b7695a88ee54595880582dd0a17a0a38bb9a78
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 16 09:22:17 2015 +0200

    gtktiledviewer: add setupWidgetAndCreateWindow() to avoid copy&paste
    
    (cherry picked from commit 855e1bac1d5155352706c7d849942f5dc453c67d)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: Ibbbaaa1c148cfd4578ad37e0f99b62ab885a1a83
commit 08cc0754dfb3a0ee009c71b2994e3058cd33199c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 15:41:46 2015 +0200

    lokdocview: set up the widget in all windows
    
    With this finally the number of GTK+ windows always match the number
    returned by SfxLokHelper::getViews().
    
    (cherry picked from commit b3498e9fcdc895853564d13173075bebc7407ef2)
    
    Conflicts:
    	libreofficekit/source/gtk/lokdocview.cxx
    
    Change-Id: Ia45bef7dea86b80cfac00e2ad7c1a16d7f5b507b
commit 690bef942d0c79472af951670d76de7914414ea8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 15:36:51 2015 +0200

    lokdocview: avoid GTK+ calls in openDocumentInThread()
    
    GTK+ calls should be made from the main thread.
    
    (cherry picked from commit e6e5c248e52524ddaddc6d1a2627f10f169d0167)
    
    Conflicts:
    	libreofficekit/source/gtk/lokdocview.cxx
    
    Change-Id: Idcfa46d427d6e35fc544246a691bafc72f75a74c
commit de8b781ed1817f9a2df68ec46505d376d3df6de1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 15:22:53 2015 +0200

    gtktiledviewer: set up a new GtkWindow for a new view
    
    (cherry picked from commit c1d72145314be0e53d5f93e3b639715c9fbba8b0)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: I9dcb5871c231a49bcd65a1187df6c3c81f92bd55
commit 78f2a9ddac50418af6e3e1ea58dd4bf323d495f0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 15:05:51 2015 +0200

    gtktiledviewer: factor out setupDocView() from main()
    
    (cherry picked from commit 8d8a8e1a2ea26df6d676495af7f017baa071153d)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: Iac803f03267859c11f0f9090346b09b90c115b76
commit bef54b288b829430c8eb683accee29027ff839ab
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 14:51:06 2015 +0200

    gtktiledviewer: factor out createWindow() from main()
    
    (cherry picked from commit 2b69ce33edaed9eaa018821180a00d563ad1ba18)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: Ib7ccd2192247805205b65e5e8da67bcc826f4d31
commit 40ef9f019394594b04b10767618682a929407baf
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 14:23:53 2015 +0200

    lokdocview: allow not calling documentLoad()
    
    (cherry picked from commit 4fd59356cb09e89324e8cd8ec84eef22a4c2031b)
    
    Conflicts:
    	include/LibreOfficeKit/LibreOfficeKitGtk.h
    	libreofficekit/source/gtk/lokdocview.cxx
    
    Change-Id: I2ff57c4be11cd3908bc951ebf572a2c02e2c4585
commit 821d5570dd836029729e7d3c8d3cae580a5a4227
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 12:53:24 2015 +0200

    gtktiledviewer: allow findbar in multiple windows
    
    With this, all previously global data is now stored per-window in the
    g_aWindows map.
    
    (cherry picked from commit d51e3f7877afe62b68071a694438d2d6722bb406)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: I45b4449ee7d516106ea0b039d1af97db49edf759
commit a8e1c18cbf0f6b3db85e7bc2f8804f2052678884
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 12:45:58 2015 +0200

    gtktiledviewer: allow part selector in multiple windows
    
    (cherry picked from commit d8bf31e129c4e791bfb02c8d0ccbaedb53d9b300)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: Ib31fca3d8b4119704fb1a5c3cee885e7c239c247
commit 395056dc3f9201f9d73dacc65e98774054bbeae8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 12:36:49 2015 +0200

    gtktiledviwer: tool item registration is per-window
    
    (cherry picked from commit bec8a1b74f91ffc579567f44a65b903bc854ec4f)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: I11a6cda7b9b8949c48c201c4bd467b49f2f43ca5
commit db3b73a90381e44b7d04420797b39742e1b613ca
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 12:21:10 2015 +0200

    gtktiledviwer: allow GtkToolItems in multiple windows
    
    (cherry picked from commit 91d67ec9a5cc2064b90a888ed962d215bee5dc2d)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: I6c19a9bdd34163d12047929170e5cfa7bb9a5820
commit c2b2a56276e551192c3f548bd21d6443dbf3d193
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 12:10:03 2015 +0200

    gtktiledviewer: allow multiple status bars
    
    (cherry picked from commit 36fa8d443a9ad87ee7077be7263870fab9dd6261)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: I84c4102937deee662814c41607ee8de380a067f2
commit d7eb1b3b7ef02358cc9d40022ad969831bba1b22
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 11:55:09 2015 +0200

    gtktiledviewer: allow multiple DocView instances
    
    (cherry picked from commit f6ef6af23db8b718ef75f66680f696396fa74eaf)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: I4e8a08d71a94445e8fd30563867a2741cad862e5
commit e3201479ef12d2f4d441adb1872a7563dee72d82
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 10:59:58 2015 +0200

    gtktiledviewer: these globals can be static
    
    (cherry picked from commit 20df29e660139fc27d50fe006202f7ea78a3903a)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: Ife0a4bb1102f6135e297dc69ba5b52b89a5dd9dd
commit 0e99a07b2d15c7ed1a47746a43e2af99ef72df3c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 10:31:20 2015 +0200

    sfx2: add missing header guard
    
    Change-Id: Ide261670be475f5d54d9d12c701ad82470396aeb
    (cherry picked from commit d990a8762e5e67747e169103bc8b9a40605afa81)

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 9430cd5..b57cb7d 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -7,6 +7,9 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef INCLUDED_SFX2_LOKHELPER_HXX
+#define INCLUDED_SFX2_LOKHELPER_HXX
+
 #include <sfx2/dllapi.h>
 
 class SfxViewShell;
@@ -23,4 +26,6 @@ public:
     static int getViews();
 };
 
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 65070716e06fd05765b8da53073d1325dfd9f886
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 09:31:49 2015 +0200

    lok::Document: add destroyView()
    
    Change-Id: Id9e92593217541b4123e95279019cec3c958056c
    (cherry picked from commit 10a0cad9d6990abac507899a34fbcdeb466187f7)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 8642f44..6baaa32 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -136,8 +136,11 @@ void DesktopLOKTest::testCreateView()
     LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
     CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews());
 
-    pDocument->m_pDocumentClass->createView(pDocument);
+    int nId = pDocument->m_pDocumentClass->createView(pDocument);
     CPPUNIT_ASSERT_EQUAL(2, SfxLokHelper::getViews());
+
+    pDocument->m_pDocumentClass->destroyView(pDocument, nId);
+    CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews());
     closeDoc();
 }
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index f7132e9..75fbafa 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -251,6 +251,7 @@ static void doc_resetSelection (LibreOfficeKitDocument* pThis);
 static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
 
 static int doc_createView(LibreOfficeKitDocument* pThis);
+static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
     mxComponent( xComponent )
@@ -283,6 +284,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->getCommandValues = doc_getCommandValues;
 
         m_pDocumentClass->createView = doc_createView;
+        m_pDocumentClass->destroyView = doc_destroyView;
 
         gDocumentClass = m_pDocumentClass;
     }
@@ -1058,6 +1060,13 @@ static int doc_createView(LibreOfficeKitDocument* pThis)
     return SfxLokHelper::createView(pViewShell);
 }
 
+static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId)
+{
+    SolarMutexGuard aGuard;
+
+    SfxLokHelper::destroyView(nId);
+}
+
 static char* lo_getError (LibreOfficeKit *pThis)
 {
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index b59d3f8..7f41d13 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -168,6 +168,8 @@ struct _LibreOfficeKitDocumentClass
 
     /// @see lok::Document::createView().
     int (*createView) (LibreOfficeKitDocument* pThis);
+    /// @see lok::Document::destroyView().
+    void (*destroyView) (LibreOfficeKitDocument* pThis, int nId);
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 32f1902..3e1a0ac 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -267,6 +267,15 @@ public:
     {
         return mpDoc->pClass->createView(mpDoc);
     }
+
+    /**
+     * Destroy a view of an existring document.
+     * @param nId a view ID, returned by createView().
+     */
+    void destroyView(int nId)
+    {
+        mpDoc->pClass->destroyView(mpDoc, nId);
+    }
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index bc3f430..9430cd5 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -16,6 +16,8 @@ class SFX2_DLLPUBLIC SfxLokHelper
 public:
     /// Create a new view shell for pViewShell's object shell.
     static int createView(SfxViewShell* pViewShell);
+    /// Destroy a view shell from the global shell list.
+    static void destroyView(size_t nId);
 
     /// Total number of view shells.
     static int getViews();
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 1bb43d0..557478a 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -26,6 +26,18 @@ int SfxLokHelper::createView(SfxViewShell* pViewShell)
     return rViewArr.size() - 1;
 }
 
+void SfxLokHelper::destroyView(size_t nId)
+{
+    SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+    if (nId > rViewArr.size() - 1)
+        return;
+
+    SfxViewShell* pViewShell = rViewArr[nId];
+    SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
+    SfxRequest aRequest(pViewFrame, SID_CLOSEWIN);
+    pViewFrame->Exec_Impl(aRequest);
+}
+
 int SfxLokHelper::getViews()
 {
     SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
commit 77c645fb3ac929a76ed0388b544c0d3edb00f2b4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 15:56:34 2015 +0200

    CppunitTest_desktop_lib: fix reported name of failed test
    
    Change-Id: Iaa9effdcf6d6c6b2292e3fc7b666afdb3678694d
    (cherry picked from commit 4f62c14748c0e62ad0212e831d606ac32e694eca)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d5616d5..8642f44 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -48,13 +48,14 @@ public:
     LibLODocument_Impl* loadDoc(const char* pName);
     void closeDoc();
 
-    void runAllTests();
     void testGetStyles();
     void testGetFonts();
     void testCreateView();
 
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
-    CPPUNIT_TEST(runAllTests);
+    CPPUNIT_TEST(testGetStyles);
+    CPPUNIT_TEST(testGetFonts);
+    CPPUNIT_TEST(testCreateView);
     CPPUNIT_TEST_SUITE_END();
 
     uno::Reference<lang::XComponent> mxComponent;
@@ -81,13 +82,6 @@ void DesktopLOKTest::closeDoc()
     }
 }
 
-void DesktopLOKTest::runAllTests()
-{
-    testGetStyles();
-    testGetFonts();
-    testCreateView();
-}
-
 void DesktopLOKTest::testGetStyles()
 {
     LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
commit 18b9b1b768cbddcf3955bbd280e4629777afcf6c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 15:43:17 2015 +0200

    lok::Office: add getViews()
    
    Change-Id: Iabfb0f2a19106dc4a6bdae45f9e85d76c68a973e
    (cherry picked from commit 2e523afe61f76d9b065a771e558683afb701b93b)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a089614..d5616d5 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -14,6 +14,7 @@
 #include <boost/property_tree/json_parser.hpp>
 #include <comphelper/processfactory.hxx>
 #include <sfx2/objsh.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <test/unoapi_test.hxx>
 
 #include "../../inc/lib/init.hxx"
@@ -50,6 +51,7 @@ public:
     void runAllTests();
     void testGetStyles();
     void testGetFonts();
+    void testCreateView();
 
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
     CPPUNIT_TEST(runAllTests);
@@ -83,6 +85,7 @@ void DesktopLOKTest::runAllTests()
 {
     testGetStyles();
     testGetFonts();
+    testCreateView();
 }
 
 void DesktopLOKTest::testGetStyles()
@@ -134,6 +137,16 @@ void DesktopLOKTest::testGetFonts()
     closeDoc();
 }
 
+void DesktopLOKTest::testCreateView()
+{
+    LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+    CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews());
+
+    pDocument->m_pDocumentClass->createView(pDocument);
+    CPPUNIT_ASSERT_EQUAL(2, SfxLokHelper::getViews());
+    closeDoc();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7881ccc..f7132e9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -310,6 +310,7 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions  (LibreOfficeKit* pThi
 static void                    lo_registerCallback (LibreOfficeKit* pThis,
                                                     LibreOfficeKitCallback pCallback,
                                                     void* pData);
+static int lo_getViews(LibreOfficeKit* pThis);
 
 struct LibLibreOffice_Impl : public _LibreOfficeKit
 {
@@ -333,6 +334,7 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
             m_pOfficeClass->getError = lo_getError;
             m_pOfficeClass->documentLoadWithOptions = lo_documentLoadWithOptions;
             m_pOfficeClass->registerCallback = lo_registerCallback;
+            m_pOfficeClass->getViews = lo_getViews;
 
             gOfficeClass = m_pOfficeClass;
         }
@@ -450,6 +452,11 @@ static void lo_registerCallback (LibreOfficeKit* pThis,
     pLib->mpCallbackData = pData;
 }
 
+static int lo_getViews(LibreOfficeKit* /*pThis*/)
+{
+    return SfxLokHelper::getViews();
+}
+
 static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const char* pFormat, const char* pFilterOptions)
 {
     LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index eae3537..b59d3f8 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -54,6 +54,9 @@ struct _LibreOfficeKitClass
     void (*registerCallback) (LibreOfficeKit* pThis,
                               LibreOfficeKitCallback pCallback,
                               void* pData);
+
+    /// @see lok::Office::getViews().
+    int (*getViews) (LibreOfficeKit* pThis);
 #endif
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 1a8b002..32f1902 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -313,6 +313,16 @@ public:
     {
         return mpThis->pClass->getError(mpThis);
     }
+
+#ifdef LOK_USE_UNSTABLE_API
+    /**
+     * Get number of total views.
+     */
+    inline int getViews()
+    {
+        return mpThis->pClass->getViews(mpThis);
+    }
+#endif
 };
 
 /// Factory method to create a lok::Office instance.
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index d439bce..bc3f430 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -16,6 +16,9 @@ class SFX2_DLLPUBLIC SfxLokHelper
 public:
     /// Create a new view shell for pViewShell's object shell.
     static int createView(SfxViewShell* pViewShell);
+
+    /// Total number of view shells.
+    static int getViews();
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 4f500e0..1bb43d0 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -26,4 +26,10 @@ int SfxLokHelper::createView(SfxViewShell* pViewShell)
     return rViewArr.size() - 1;
 }
 
+int SfxLokHelper::getViews()
+{
+    SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+    return rViewArr.size();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit dc331776fbdce5a147a0c0105523c609b5272bdd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 15:10:22 2015 +0200

    gtktiledviewer: add button tooltips
    
    (cherry picked from commit 179a0d0ea0ec4251152fe4c5e0fb3fd53f6f7967)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: Ifad67adf80761118bbbfb110cbadd493214fee93
commit 06d202aea377eaf012e426ec66c5052ccfb3eaec
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 14:36:56 2015 +0200

    lok::Document: add createView()
    
    (cherry picked from commit 655c7877a0650b7bfd04a3294cdf92bc7ab94055)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: Ic871ec41992b611b10958799b2dc12375a91efe4

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1439e28..7881ccc 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -53,6 +53,7 @@
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/msgpool.hxx>
 #include <sfx2/dispatch.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <svx/svxids.hrc>
 #include <vcl/svapp.hxx>
 #include <vcl/svpforlokit.hxx>
@@ -249,6 +250,7 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
 static void doc_resetSelection (LibreOfficeKitDocument* pThis);
 static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
 
+static int doc_createView(LibreOfficeKitDocument* pThis);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
     mxComponent( xComponent )
@@ -280,6 +282,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->resetSelection = doc_resetSelection;
         m_pDocumentClass->getCommandValues = doc_getCommandValues;
 
+        m_pDocumentClass->createView = doc_createView;
+
         gDocumentClass = m_pDocumentClass;
     }
     pClass = m_pDocumentClass.get();
@@ -1032,6 +1036,21 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
     }
 }
 
+static int doc_createView(LibreOfficeKitDocument* pThis)
+{
+    SolarMutexGuard aGuard;
+
+    ITiledRenderable* pDoc = getTiledRenderable(pThis);
+    if (!pDoc)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+        return -1;
+    }
+
+    SfxViewShell* pViewShell = pDoc->getCurrentViewShell();
+    return SfxLokHelper::createView(pViewShell);
+}
+
 static char* lo_getError (LibreOfficeKit *pThis)
 {
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 8060f0e..eae3537 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -162,6 +162,9 @@ struct _LibreOfficeKitDocumentClass
 
     /// @see lok::Document:getStyles
     char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
+
+    /// @see lok::Document::createView().
+    int (*createView) (LibreOfficeKitDocument* pThis);
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 4459994..1a8b002 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -257,6 +257,16 @@ public:
     {
         return mpDoc->pClass->getCommandValues(mpDoc, pCommand);
     }
+
+    /**
+     * Create a new view for an existing document.
+     * By default a loaded document has 1 view.
+     * @return the ID of the new view.
+     */
+    int createView()
+    {
+        return mpDoc->pClass->createView(mpDoc);
+    }
 #endif // LOK_USE_UNSTABLE_API
 };
 
commit 477bd979170e754322d7656c5bf195bdc4777bd9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 14:36:38 2015 +0200

    sfx2: add SfxLokHelper
    
    This is meant to be a class that is visible outside sfx2 (so e.g.
    desktop can use it later), but has access to various sfx2 internals.
    
    Change-Id: I83204963492b11c1c4a621e86528a64fba27acf3
    (cherry picked from commit 58b5c13b00cd4d881e1d6313316cc621198a4b04)

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
new file mode 100644
index 0000000..d439bce
--- /dev/null
+++ b/include/sfx2/lokhelper.hxx
@@ -0,0 +1,21 @@
+/* -*- 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 <sfx2/dllapi.h>
+
+class SfxViewShell;
+
+class SFX2_DLLPUBLIC SfxLokHelper
+{
+public:
+    /// Create a new view shell for pViewShell's object shell.
+    static int createView(SfxViewShell* pViewShell);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 0a1100e..40dedd5 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -290,6 +290,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/view/frame2 \
     sfx2/source/view/frmload \
     sfx2/source/view/ipclient \
+    sfx2/source/view/lokhelper \
     sfx2/source/view/printer \
     sfx2/source/view/sfxbasecontroller \
     sfx2/source/view/userinputinterception \
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
new file mode 100644
index 0000000..4f500e0
--- /dev/null
+++ b/sfx2/source/view/lokhelper.cxx
@@ -0,0 +1,29 @@
+/* -*- 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 <sfx2/lokhelper.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/viewfrm.hxx>
+
+#include <shellimpl.hxx>
+
+int SfxLokHelper::createView(SfxViewShell* pViewShell)
+{
+    SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
+    SfxRequest aRequest(pViewFrame, SID_NEWWINDOW);
+    pViewFrame->ExecView_Impl(aRequest);
+
+    // The SfxViewShell ctor always puts the view shell to the end of the vector.
+    SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+    return rViewArr.size() - 1;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit df91ed8bb8c61fc7c8cfc0f09604329b4723f538
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 12:50:48 2015 +0200

    vcl::ITiledRenderable: add getCurrentViewShell() and implement it for Writer
    
    Change-Id: Ic936746f3d473e15f5a1589cba35173778b442c6
    (cherry picked from commit 7b0de91faaaf9a051e082ec7ea5024474f4a1299)

diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index d212519..6a573bc 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -16,6 +16,8 @@
 #include <tools/gen.hxx>
 #include <vcl/virdev.hxx>
 
+class SfxViewShell;
+
 namespace vcl
 {
 
@@ -139,8 +141,16 @@ public:
      * @see lok::Document::resetSelection().
      */
     virtual void resetSelection() = 0;
+
+    /// Get the currently active view shell of the document.
+    virtual SfxViewShell* getCurrentViewShell()
+    {
+        return 0;
+    }
 };
 
 } // namespace vcl
 
 #endif // INCLUDED_VCL_ITILEDRENDERABLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 9f0b03b..71dbb4f 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -431,6 +431,8 @@ public:
     virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::resetSelection().
     virtual void resetSelection() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::getCurrentViewShell().
+    virtual SfxViewShell* getCurrentViewShell() SAL_OVERRIDE;
 
     // ::com::sun::star::tiledrendering::XTiledRenderable
     virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index b0f37a8..fbacf5d 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3401,6 +3401,11 @@ void SwXTextDocument::resetSelection()
     pWrtShell->ResetSelect(0, false);
 }
 
+SfxViewShell* SwXTextDocument::getCurrentViewShell()
+{
+    return pDocShell->GetView();
+}
+
 void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception)
 {
     SystemGraphicsData aData;
commit 15c8a8c452cd993345e0cd8159d739711db3efb5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 11:20:47 2015 +0200

    sw layout dump: show selection ranges from all shells
    
    Change-Id: I89d0f3c66f3939fc6795892d727d782c3f8bbda3
    (cherry picked from commit e13510cf2c54f85379fa959296a8ccf7a8cd5cb7)

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 073a8df..0345c42 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -852,6 +852,8 @@ public:
        @return the textual description of the current selection
      */
     OUString GetCrsrDescr() const;
+
+    virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const SAL_OVERRIDE;
 };
 
 // Cursor Inlines:
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 1ba064f..abb9f0b 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -595,6 +595,7 @@ public:
     void setOutputToWindow(bool bOutputToWindow);
     bool isOutputToWindow() const;
 
+    virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 // manages global ShellPointer
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 3a0c666..442eb7b 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3319,6 +3319,20 @@ OUString SwCrsrShell::GetCrsrDescr() const
     return aResult;
 }
 
+void SwCrsrShell::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("swCrsrShell"));
+
+    SwViewShell::dumpAsXml(pWriter);
+
+    xmlTextWriterStartElement(pWriter, BAD_CAST("m_pCurCrsr"));
+    for (SwPaM& rPaM : m_pCurCrsr->GetRingContainer())
+        rPaM.dumpAsXml(pWriter);
+    xmlTextWriterEndElement(pWriter);
+
+    xmlTextWriterEndElement(pWriter);
+}
+
 static void lcl_FillRecognizerData( uno::Sequence< OUString >& rSmartTagTypes,
                              uno::Sequence< uno::Reference< container::XStringKeyMap > >& rStringKeyMaps,
                              const SwWrongList& rSmartTagList, sal_Int32 nCurrent )
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 951b415..2a0ddf8 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -295,12 +295,10 @@ void SwFrm::dumpAsXml( xmlTextWriterPtr writer ) const
 
         if (IsRootFrm())
         {
-            // Root frame has access to the edit shell, so dump the current selection ranges here.
-            const SwRootFrm* const pRootFrm = static_cast<const SwRootFrm* const>(this);
-            SwEditShell* pEditShell = pRootFrm->GetCurrShell()->GetDoc()->GetEditShell();
-            xmlTextWriterStartElement(writer, BAD_CAST("shellCrsr"));
-            for (SwPaM& rPaM : pEditShell->getShellCrsr(false)->GetRingContainer())
-                rPaM.dumpAsXml(writer);
+            const SwRootFrm* pRootFrm = static_cast<const SwRootFrm*>(this);
+            xmlTextWriterStartElement(writer, BAD_CAST("shells"));
+            for (SwViewShell& rViewShell : pRootFrm->GetCurrShell()->GetRingContainer())
+                rViewShell.dumpAsXml(writer);
             xmlTextWriterEndElement(writer);
         }
 
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 2906426..0605438 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -150,6 +150,12 @@ bool SwViewShell::isOutputToWindow() const
     return mbOutputToWindow;
 }
 
+void SwViewShell::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("swViewShell"));
+    xmlTextWriterEndElement(pWriter);
+}
+
 static void
 lcl_PaintTransparentFormControls(SwViewShell & rShell, SwRect const& rRect)
 {


More information about the Libreoffice-commits mailing list