[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - 19 commits - desktop/qa desktop/source include/LibreOfficeKit include/vcl libreofficekit/source sc/source sd/qa sd/source sfx2/source sw/inc sw/qa sw/source

Marco Cecchetti marco.cecchetti at collabora.com
Sun Jun 12 18:51:23 UTC 2016


 desktop/qa/desktop_lib/test_desktop_lib.cxx                |    5 
 desktop/source/lib/init.cxx                                |   64 ++
 desktop/source/lib/lokinteractionhandler.cxx               |  285 ++++++++++---
 desktop/source/lib/lokinteractionhandler.hxx               |   33 +
 include/LibreOfficeKit/LibreOfficeKit.h                    |    5 
 include/LibreOfficeKit/LibreOfficeKit.hxx                  |   21 
 include/LibreOfficeKit/LibreOfficeKitEnums.h               |   15 
 include/LibreOfficeKit/LibreOfficeKitInit.h                |   18 
 include/vcl/ITiledRenderable.hxx                           |    5 
 libreofficekit/source/gtk/lokdocview.cxx                   |   17 
 sc/source/ui/unoobj/docuno.cxx                             |   13 
 sc/source/ui/view/viewfun2.cxx                             |    1 
 sd/qa/unit/tiledrendering/tiledrendering.cxx               |   17 
 sd/source/ui/unoidl/unomodel.cxx                           |    7 
 sd/source/ui/view/Outliner.cxx                             |   16 
 sfx2/source/control/unoctitm.cxx                           |    2 
 sw/inc/unotxdoc.hxx                                        |    2 
 sw/inc/view.hxx                                            |    3 
 sw/qa/extras/tiledrendering/data/pagedown-invalidation.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx             |   28 +
 sw/source/uibase/uiview/view.cxx                           |    1 
 sw/source/uibase/uiview/viewport.cxx                       |    6 
 sw/source/uibase/uiview/viewsrch.cxx                       |   19 
 sw/source/uibase/uno/unotxdoc.cxx                          |   16 
 sw/source/uibase/wrtsh/wrtsh1.cxx                          |    5 
 25 files changed, 496 insertions(+), 108 deletions(-)

New commits:
commit ae848bd48e5ce25be0886aaf263ac709f54f629d
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon Feb 8 11:26:29 2016 +0100

    sw - m_eLastSearchCommand initialization
    
    Change-Id: Iafd72a05a745207dfff7663eeeb7bc697b5b8fd1
    (cherry picked from commit d9959d3763e155b45d7bd2181bb81803566517be)

diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 49ce99d..0e70bfe 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -707,6 +707,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
     m_nLastPasteDestination( static_cast<SotExchangeDest>(0xFFFF) ),
     m_nLeftBorderDistance( 0 ),
     m_nRightBorderDistance( 0 ),
+    m_eLastSearchCommand( static_cast<SvxSearchCmd>(0xFFFF) ),
     m_bWheelScrollInProgress(false),
     m_bInMailMerge(false),
     m_bInDtor(false),
commit fc6de78323da616af21e84de9984ea8a754de6f3
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Sun Feb 7 12:09:36 2016 +0100

    sw - single search after find all selects the 2nd occurrence - fixed
    
    Now, after a search all action we place the cursor at the beginning of
    the document so that the single search selects the first matching
    occurrence in the document instead of the second.
    
    Change-Id: I8c295bcd316c6197154c68ae97eb424ee6cc9904
    Reviewed-on: https://gerrit.libreoffice.org/22175
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>
    (cherry picked from commit 7f1ccaf62e42a26d48d324bcc6758100c6ec682b)

diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index a757d79..1df6d7d 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -79,6 +79,7 @@ class GraphicFilter;
 class SwPostItMgr;
 enum class SotExchangeDest;
 class SwCursorShell;
+enum class SvxSearchCmd;
 
 namespace com{ namespace sun { namespace star {
     namespace view{ class XSelectionSupplier; }
@@ -230,6 +231,8 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
     sal_uInt16          m_nLeftBorderDistance;
     sal_uInt16          m_nRightBorderDistance;
 
+    SvxSearchCmd        m_eLastSearchCommand;
+
     bool m_bWheelScrollInProgress;
 
     bool            m_bCenterCursor : 1,
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index f3f216f..bc92249 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -441,6 +441,7 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage)
                 rReq.AppendItem(SfxBoolItem(SID_SEARCH_QUIET, true));
 
             rReq.Done();
+            m_eLastSearchCommand = m_pSrchItem->GetCommand();
         }
         break;
         case FID_SEARCH_SEARCHSET:
@@ -532,6 +533,17 @@ bool SwView::SearchAndWrap(bool bApi)
     m_pWrtShell->StartAllAction();
     m_pWrtShell->Push();
 
+    // After a search all action we place the cursor at the beginning of
+    // the document so that the single search selects the first matching
+    // occurrence in the document instead of the second.
+    if( m_eLastSearchCommand == SvxSearchCmd::FIND_ALL )
+    {
+        if( DOCPOS_START == aOpts.eEnd )
+            m_pWrtShell->EndDoc();
+        else
+            m_pWrtShell->SttDoc();
+    }
+
     // fdo#65014 : Ensure that the point of the cursor is at the extremity of the
     // selection closest to the end being searched to as to exclude the selected
     // region from the search. (This doesn't work in the case of multiple
commit c5ab252a9c36736d9f0c8b1bac7b6f881b3b0f4c
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Feb 5 16:54:31 2016 +0100

    lok: Search result should contain info if it is a 'search all' result.
    
    Change-Id: Ia3ee81ced4f74c0d029a478bd59eff44d72ef327
    (cherry picked from commit e54f49d65888e180118992c33f7348d6e08b3e20)

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 3f2a6ea..343d169 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -197,6 +197,7 @@ typedef enum
      *
      * {
      *     "searchString": "...",
+     *     "highlightAll": true|false, // this is a result of 'search all'
      *     "searchResultSelection": [
      *         {
      *             "part": "...",
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 63ac05a..4c64e57 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1862,6 +1862,7 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
 
                 boost::property_tree::ptree aTree;
                 aTree.put("searchString", pSearchItem->GetSearchString().toUtf8().getStr());
+                aTree.put("highlightAll", nCommand == SvxSearchCmd::FIND_ALL);
 
                 boost::property_tree::ptree aSelections;
                 for (const Rectangle& rLogicRect : aLogicRects)
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index dfb6beb..ec984b7 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -654,6 +654,7 @@ bool Outliner::SearchAndReplaceAll()
         {
             boost::property_tree::ptree aTree;
             aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
+            aTree.put("highlightAll", true);
 
             boost::property_tree::ptree aChildren;
             for (const SearchSelection& rSelection : aSelections)
@@ -802,6 +803,7 @@ bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
             // also about search result selections
             boost::property_tree::ptree aTree;
             aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
+            aTree.put("highlightAll", false);
 
             boost::property_tree::ptree aChildren;
             boost::property_tree::ptree aChild;
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index 8918ff1..f3f216f 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -107,7 +107,7 @@ static void lcl_addContainerToJson(boost::property_tree::ptree& rTree, const OSt
 }
 
 /// Emits LOK callbacks (count, selection) for search results.
-static void lcl_emitSearchResultCallbacks(SvxSearchItem* pSearchItem, SwWrtShell* pWrtShell)
+static void lcl_emitSearchResultCallbacks(SvxSearchItem* pSearchItem, SwWrtShell* pWrtShell, bool bHighlightAll)
 {
     // Emit a callback also about the selection rectangles, grouped by matches.
     if (SwPaM* pPaM = pWrtShell->GetCursor())
@@ -133,6 +133,7 @@ static void lcl_emitSearchResultCallbacks(SvxSearchItem* pSearchItem, SwWrtShell
         }
         boost::property_tree::ptree aTree;
         aTree.put("searchString", pSearchItem->GetSearchString().toUtf8().getStr());
+        aTree.put("highlightAll", bHighlightAll);
         lcl_addContainerToJson(aTree, "searchResultSelection", aMatches);
 
         std::stringstream aStream;
@@ -252,7 +253,7 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage)
                 {
                     Scroll(m_pWrtShell->GetCharRect().SVRect());
                     if (comphelper::LibreOfficeKit::isActive())
-                        lcl_emitSearchResultCallbacks(m_pSrchItem, m_pWrtShell);
+                        lcl_emitSearchResultCallbacks(m_pSrchItem, m_pWrtShell, /* bHighlightAll = */ false);
                 }
                 rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
 #if HAVE_FEATURE_DESKTOP
@@ -290,7 +291,7 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage)
                     m_bFound = false;
                 }
                 else if (comphelper::LibreOfficeKit::isActive())
-                    lcl_emitSearchResultCallbacks(m_pSrchItem, m_pWrtShell);
+                    lcl_emitSearchResultCallbacks(m_pSrchItem, m_pWrtShell, /* bHighlightAll = */ true);
                 rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
 #if HAVE_FEATURE_DESKTOP
                 {
commit 669a4d61ba8335678185f18c135b0ecd889fb6fc
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Feb 5 12:20:11 2016 +0100

    lok: Notify also about the states of .uno:CharBackgroundExt.
    
    .uno:CharBackgroundExt is supplementary to .uno:BackColor.
    
    When .uno:BackColor is set, Writer turns into a 'watercan' mode, where the
    user directly marks parts of the text with the wanted background color.
    
    .uno:CharBackgroundExt then controls this watercan mode - dispatching it
    toggles the watercan mode on/off, and also the StateChanged events reflect the
    on/off mode accordingly.
    
    Change-Id: I6472eb39129d1b1517fba14bad584cbd125e826a
    (cherry picked from commit e6a2b10b7a01cbb1d7b2148c37e73cee2d78c10e)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7dacae0..5169b06 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -697,6 +697,7 @@ static void doc_iniUnoCommands ()
         OUString(".uno:Bold"),
         OUString(".uno:CenterPara"),
         OUString(".uno:CharBackColor"),
+        OUString(".uno:CharBackgroundExt"),
         OUString(".uno:CharFontName"),
         OUString(".uno:Color"),
         OUString(".uno:DecrementIndent"),
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 130f0d1..bbd5074 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1065,6 +1065,7 @@ void SfxDispatchController_Impl::InterceptLOKStateChangeEvent(const SfxObjectShe
 
     if (aEvent.FeatureURL.Path == "Bold" ||
         aEvent.FeatureURL.Path == "CenterPara" ||
+        aEvent.FeatureURL.Path == "CharBackgroundExt" ||
         aEvent.FeatureURL.Path == "DefaultBullet" ||
         aEvent.FeatureURL.Path == "DefaultNumbering" ||
         aEvent.FeatureURL.Path == "Italic" ||
@@ -1082,7 +1083,6 @@ void SfxDispatchController_Impl::InterceptLOKStateChangeEvent(const SfxObjectShe
         bool bTemp = false;
         aEvent.State >>= bTemp;
         aBuffer.append(bTemp);
-
     }
     else if (aEvent.FeatureURL.Path == "CharFontName")
     {
commit 1ecc789c6ebd2f4909f8cb538c46be1ddb060aee
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Thu Feb 4 15:36:43 2016 +0100

    impress - unable to search inside table - fixed
    
    Change-Id: I07df8d0330390ac599aac364581aee1c9fd0f809
    (cherry picked from commit 5c91631dbfc9394687fb84cc76384601a566d6ff)

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index d963d43..dfb6beb 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -1225,11 +1225,6 @@ bool Outliner::ShowWrapArroundDialog()
 
 bool Outliner::IsValidTextObject (const ::sd::outliner::IteratorPosition& rPosition)
 {
-    // TODO implement iteration through table cells and remove this workaround
-    ::sdr::table::SdrTableObj* pTableObject = dynamic_cast< ::sdr::table::SdrTableObj* >( rPosition.mxObject.get() );
-    if( pTableObject != nullptr )
-        return false;
-
     SdrTextObj* pObject = dynamic_cast< SdrTextObj* >( rPosition.mxObject.get() );
     return (pObject != nullptr) && pObject->HasText() && ! pObject->IsEmptyPresObj();
 }
@@ -1239,7 +1234,7 @@ void Outliner::PutTextIntoOutliner()
     mpTextObj = dynamic_cast<SdrTextObj*>( mpObj );
     if ( mpTextObj && mpTextObj->HasText() && !mpTextObj->IsEmptyPresObj() )
     {
-        SdrText* pText = mpTextObj->getText( mnText );
+        SdrText* pText = mpTextObj->getText( maCurrentPosition.mnText );
         mpParaObj = pText ? pText->GetOutlinerParaObject() : nullptr;
 
         if (mpParaObj != nullptr)
commit 310a19c6fe7117fa424d7c886e7c430660f59551
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Feb 3 11:38:10 2016 +0100

    libreofficekit: CppunitTest_libreofficekit_tiledrendering crashes
    
    Need to check that a callback was actually set before calling it.
    
    Change-Id: Icb2ca19aec0c74f6695d7286f046dadfe609d68c
    (cherry picked from commit d04cf314d44c0ae0cbb135d21436d119f936208c)

diff --git a/desktop/source/lib/lokinteractionhandler.cxx b/desktop/source/lib/lokinteractionhandler.cxx
index a4a60c2..e4c3ee5 100644
--- a/desktop/source/lib/lokinteractionhandler.cxx
+++ b/desktop/source/lib/lokinteractionhandler.cxx
@@ -115,9 +115,9 @@ void LOKInteractionHandler::postError(css::task::InteractionClassification class
     std::stringstream aStream;
     boost::property_tree::write_json(aStream, aTree);
 
-    if (m_pLOKDocument)
+    if (m_pLOKDocument && m_pLOKDocument->mpCallback)
         m_pLOKDocument->mpCallback(LOK_CALLBACK_ERROR, aStream.str().c_str(), m_pLOKDocument->mpCallbackData);
-    else
+    else if (m_pLOKit->mpCallback)
         m_pLOKit->mpCallback(LOK_CALLBACK_ERROR, aStream.str().c_str(), m_pLOKit->mpCallbackData);
 }
 
@@ -243,7 +243,8 @@ bool LOKInteractionHandler::handlePasswordRequest(const uno::Sequence<uno::Refer
     if (!(rRequest >>= passwordRequest))
         return false;
 
-    if (m_pLOKit->hasOptionalFeature((passwordRequest.IsRequestPasswordToModify)
+    if (m_pLOKit->mpCallback &&
+        m_pLOKit->hasOptionalFeature((passwordRequest.IsRequestPasswordToModify)
                 ? LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY
                 : LOK_FEATURE_DOCUMENT_PASSWORD))
     {
commit 2013010c67016ec6c17db0a4fb29eb3b40deb2db
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Feb 3 11:59:04 2016 +0100

    lok: Avoid the 'alien format' warning in LibreOfficeKit.
    
    We immediately cancel all the dialogs that potentially come up when using
    LibreOfficeKit; which means that when you tried to save a .docx to a remote
    server (which triggered the 'alien format' warning), the save operation
    couldn't be completed.
    
    Change-Id: I6bb5eadac994c1f515d7a49299c21960b3491bbe
    (cherry picked from commit 70a1dbb4c7fdcb6ba309aa53dac8299a3f2bc626)

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index d92f129..5227750 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -44,6 +44,7 @@
 #include <tools/multisel.hxx>
 #include <tools/resary.hxx>
 #include <toolkit/awt/vclxdevice.hxx>
+#include <unotools/saveopt.hxx>
 
 #include <ctype.h>
 #include <float.h>
@@ -931,6 +932,12 @@ void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans
     SC_MOD()->SetInputOptions(aInputOptions);
     pDocShell->CalcOutputFactor();
 
+    // when the "This document may contain formatting or content that cannot
+    // be saved..." dialog appears, it is auto-cancelled with tiled rendering,
+    // causing 'Save' being disabled; so let's always save to the original
+    // format
+    SvtSaveOptions().SetWarnAlienFormat(false);
+
     // default tile size in pixels
     nTilePixelWidth = 256;
     nTilePixelHeight = 256;
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 4b31e96..8025a4b 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -63,6 +63,7 @@
 #include <svx/unoshape.hxx>
 #include <editeng/unonrule.hxx>
 #include <editeng/eeitem.hxx>
+#include <unotools/saveopt.hxx>
 
 // Support creation of GraphicObjectResolver and EmbeddedObjectResolver
 #include <svx/xmleohlp.hxx>
@@ -2392,6 +2393,12 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs
         //  by the tile being rerendered - which is wasteful and ugly).
         pDrawView->SetSwapAsynchron(false);
     }
+
+    // when the "This document may contain formatting or content that cannot
+    // be saved..." dialog appears, it is auto-cancelled with tiled rendering,
+    // causing 'Save' being disabled; so let's always save to the original
+    // format
+    SvtSaveOptions().SetWarnAlienFormat(false);
 }
 
 void SdXImpressDocument::registerCallback(LibreOfficeKitCallback pCallback, void* pData)
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 218b1ea..210de58 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -115,6 +115,7 @@
 #include <osl/file.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <unotools/saveopt.hxx>
 
 #include <EnhancedPDFExportHelper.hxx>
 #include <numrule.hxx>
@@ -3258,6 +3259,12 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
     // directly in twips.
     SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
     rEditWin.EnableMapMode(false);
+
+    // when the "This document may contain formatting or content that cannot
+    // be saved..." dialog appears, it is auto-cancelled with tiled rendering,
+    // causing 'Save' being disabled; so let's always save to the original
+    // format
+    SvtSaveOptions().SetWarnAlienFormat(false);
 }
 
 void SwXTextDocument::registerCallback(LibreOfficeKitCallback pCallback, void* pData)
commit aea412dcfffd36b0a377961f741caf396a20a9dd
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Feb 2 22:59:34 2016 +0100

    lok interaction handler: Add handling of io and network errors.
    
    Change-Id: If7c84a7b24f2072439718fb0c473b73243f2ecc1
    (cherry picked from commit c406c90289baa12663a382c7ed664f2cf93b75ab)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cd6c045..7dacae0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -270,7 +270,7 @@ static OUString getAbsoluteURL(const char* pURL)
     return OUString();
 }
 
-static void jsonToPropertyValues(const char* pJSON, uno::Sequence<beans::PropertyValue>& rPropertyValues)
+static std::vector<beans::PropertyValue> jsonToPropertyValuesVector(const char* pJSON)
 {
     std::vector<beans::PropertyValue> aArguments;
     if (pJSON && pJSON[0] != '\0')
@@ -297,11 +297,11 @@ static void jsonToPropertyValues(const char* pJSON, uno::Sequence<beans::Propert
             else if (rType == "unsigned short")
                 aValue.Value <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32());
             else
-                SAL_WARN("desktop.lib", "jsonToPropertyValues: unhandled type '"<<rType<<"'");
+                SAL_WARN("desktop.lib", "jsonToPropertyValuesVector: unhandled type '"<<rType<<"'");
             aArguments.push_back(aValue);
         }
     }
-    rPropertyValues = comphelper::containerToSequence(aArguments);
+    return aArguments;
 }
 
 extern "C"
@@ -544,7 +544,7 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
                                                        beans::PropertyState_DIRECT_VALUE);
 
         rtl::Reference<LOKInteractionHandler> const pInteraction(
-            new LOKInteractionHandler(::comphelper::getProcessComponentContext(), pLib));
+            new LOKInteractionHandler(::comphelper::getProcessComponentContext(), "load", pLib));
         auto const pair(pLib->mInteractionMap.insert(std::make_pair(aURL.toUtf8(), pInteraction)));
         comphelper::ScopeGuard const g([&] () {
                 if (pair.second)
@@ -1001,9 +1001,9 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
     if (pDoc)
     {
         doc_iniUnoCommands();
-        uno::Sequence<beans::PropertyValue> aPropertyValues;
-        jsonToPropertyValues(pArguments, aPropertyValues);
-        pDoc->initializeForTiledRendering(aPropertyValues);
+
+        pDoc->initializeForTiledRendering(
+                comphelper::containerToSequence(jsonToPropertyValuesVector(pArguments)));
     }
 }
 
@@ -1093,20 +1093,33 @@ public:
 static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, bool bNotifyWhenFinished)
 {
     OUString aCommand(pCommand, strlen(pCommand), RTL_TEXTENCODING_UTF8);
+    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
 
-    uno::Sequence<beans::PropertyValue> aPropertyValues;
-    jsonToPropertyValues(pArguments, aPropertyValues);
-    bool bResult = false;
+    std::vector<beans::PropertyValue> aPropertyValuesVector(jsonToPropertyValuesVector(pArguments));
 
-    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+    // handle potential interaction
+    if (aCommand == ".uno:Save")
+    {
+        rtl::Reference<LOKInteractionHandler> const pInteraction(
+            new LOKInteractionHandler(::comphelper::getProcessComponentContext(), "save", gImpl, pDocument));
+        uno::Reference<task::XInteractionHandler2> const xInteraction(pInteraction.get());
+
+        beans::PropertyValue aValue;
+        aValue.Name = "InteractionHandler";
+        aValue.Value <<= xInteraction;
+
+        aPropertyValuesVector.push_back(aValue);
+    }
+
+    bool bResult = false;
 
     if (bNotifyWhenFinished && pDocument->mpCallback)
     {
-        bResult = comphelper::dispatchCommand(aCommand, aPropertyValues,
+        bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector),
                 new DispatchResultListener(pCommand, pDocument->mpCallback, pDocument->mpCallbackData));
     }
     else
-        bResult = comphelper::dispatchCommand(aCommand, aPropertyValues);
+        bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector));
 
     if (!bResult)
     {
diff --git a/desktop/source/lib/lokinteractionhandler.cxx b/desktop/source/lib/lokinteractionhandler.cxx
index 86f521e..a4a60c2 100644
--- a/desktop/source/lib/lokinteractionhandler.cxx
+++ b/desktop/source/lib/lokinteractionhandler.cxx
@@ -19,12 +19,21 @@
 
 #include "lokinteractionhandler.hxx"
 
+#include <boost/property_tree/json_parser.hpp>
+
 #include <rtl/ref.hxx>
 #include <cppuhelper/supportsservice.hxx>
 
 #include <com/sun/star/task/XInteractionAbort.hpp>
 #include <com/sun/star/task/XInteractionApprove.hpp>
 #include <com/sun/star/task/XInteractionPassword2.hpp>
+#include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp>
+#include <com/sun/star/ucb/InteractiveNetworkOffLineException.hpp>
+
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
+#include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp>
+#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
 
 #define LOK_USE_UNSTABLE_API
 #include <../../inc/lib/init.hxx>
@@ -35,8 +44,12 @@ using namespace com::sun::star;
 
 LOKInteractionHandler::LOKInteractionHandler(
         uno::Reference<uno::XComponentContext> const & /*rxContext*/,
-        desktop::LibLibreOffice_Impl *const pLOKit)
+        const OString& rCommand,
+        desktop::LibLibreOffice_Impl *const pLOKit,
+        desktop::LibLODocument_Impl *const pLOKDocument)
     : m_pLOKit(pLOKit)
+    , m_pLOKDocument(pLOKDocument)
+    , m_command(rCommand)
     , m_usePassword(false)
 {
     assert(m_pLOKit);
@@ -79,8 +92,157 @@ throw (uno::RuntimeException, std::exception)
     handleInteractionRequest(xRequest);
 }
 
-sal_Bool LOKInteractionHandler::handlePasswordRequest(const uno::Sequence<uno::Reference<task::XInteractionContinuation>> &rContinuations, const task::DocumentPasswordRequest2& passwordRequest)
+void LOKInteractionHandler::postError(css::task::InteractionClassification classif, const char* kind, ErrCode code, const OUString &message)
 {
+    const char *classification = "error";
+    switch (classif)
+    {
+        case task::InteractionClassification_ERROR: break;
+        case task::InteractionClassification_WARNING: classification = "warning"; break;
+        case task::InteractionClassification_INFO: classification = "info"; break;
+        case task::InteractionClassification_QUERY: classification = "query"; break;
+        default: assert(false); break;
+    }
+
+    // create the JSON representation
+    boost::property_tree::ptree aTree;
+    aTree.put("classification", classification);
+    aTree.put("cmd", m_command.getStr());
+    aTree.put("kind", kind);
+    aTree.put("code", code);
+    aTree.put("message", message.toUtf8());
+
+    std::stringstream aStream;
+    boost::property_tree::write_json(aStream, aTree);
+
+    if (m_pLOKDocument)
+        m_pLOKDocument->mpCallback(LOK_CALLBACK_ERROR, aStream.str().c_str(), m_pLOKDocument->mpCallbackData);
+    else
+        m_pLOKit->mpCallback(LOK_CALLBACK_ERROR, aStream.str().c_str(), m_pLOKit->mpCallbackData);
+}
+
+namespace {
+
+/// Just approve the interaction.
+void selectApproved(uno::Sequence<uno::Reference<task::XInteractionContinuation>> const &rContinuations)
+{
+    for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
+    {
+        uno::Reference<task::XInteractionApprove> xApprove(rContinuations[i], uno::UNO_QUERY);
+        if (xApprove.is())
+            xApprove->select();
+    }
+}
+
+}
+
+bool LOKInteractionHandler::handleIOException(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest)
+{
+    ucb::InteractiveIOException aIoException;
+    if (!(rRequest >>= aIoException))
+        return false;
+
+    static ErrCode const aErrorCode[ucb::IOErrorCode_WRONG_VERSION + 1] =
+    {
+        ERRCODE_IO_ABORT,
+        ERRCODE_IO_ACCESSDENIED,
+        ERRCODE_IO_ALREADYEXISTS,
+        ERRCODE_IO_BADCRC,
+        ERRCODE_IO_CANTCREATE,
+        ERRCODE_IO_CANTREAD,
+        ERRCODE_IO_CANTSEEK,
+        ERRCODE_IO_CANTTELL,
+        ERRCODE_IO_CANTWRITE,
+        ERRCODE_IO_CURRENTDIR,
+        ERRCODE_IO_DEVICENOTREADY,
+        ERRCODE_IO_NOTSAMEDEVICE,
+        ERRCODE_IO_GENERAL,
+        ERRCODE_IO_INVALIDACCESS,
+        ERRCODE_IO_INVALIDCHAR,
+        ERRCODE_IO_INVALIDDEVICE,
+        ERRCODE_IO_INVALIDLENGTH,
+        ERRCODE_IO_INVALIDPARAMETER,
+        ERRCODE_IO_ISWILDCARD,
+        ERRCODE_IO_LOCKVIOLATION,
+        ERRCODE_IO_MISPLACEDCHAR,
+        ERRCODE_IO_NAMETOOLONG,
+        ERRCODE_IO_NOTEXISTS,
+        ERRCODE_IO_NOTEXISTSPATH,
+        ERRCODE_IO_NOTSUPPORTED,
+        ERRCODE_IO_NOTADIRECTORY,
+        ERRCODE_IO_NOTAFILE,
+        ERRCODE_IO_OUTOFSPACE,
+        ERRCODE_IO_TOOMANYOPENFILES,
+        ERRCODE_IO_OUTOFMEMORY,
+        ERRCODE_IO_PENDING,
+        ERRCODE_IO_RECURSIVE,
+        ERRCODE_IO_UNKNOWN,
+        ERRCODE_IO_WRITEPROTECTED,
+        ERRCODE_IO_WRONGFORMAT,
+        ERRCODE_IO_WRONGVERSION,
+    };
+
+    postError(aIoException.Classification, "io", aErrorCode[aIoException.Code], "");
+    selectApproved(rContinuations);
+
+    return true;
+}
+
+bool LOKInteractionHandler::handleNetworkException(const uno::Sequence<uno::Reference<task::XInteractionContinuation>> &rContinuations, const uno::Any &rRequest)
+{
+    ucb::InteractiveNetworkException aNetworkException;
+    if (!(rRequest >>= aNetworkException))
+        return false;
+
+    ErrCode nErrorCode;
+    OUString aMessage;
+
+    ucb::InteractiveNetworkOffLineException aOffLineException;
+    ucb::InteractiveNetworkResolveNameException aResolveNameException;
+    ucb::InteractiveNetworkConnectException aConnectException;
+    ucb::InteractiveNetworkReadException aReadException;
+    ucb::InteractiveNetworkWriteException aWriteException;
+    if (rRequest >>= aOffLineException)
+    {
+        nErrorCode = ERRCODE_INET_OFFLINE;
+    }
+    else if (rRequest >>= aResolveNameException)
+    {
+        nErrorCode = ERRCODE_INET_NAME_RESOLVE;
+        aMessage = aResolveNameException.Server;
+    }
+    else if (rRequest >>= aConnectException)
+    {
+        nErrorCode = ERRCODE_INET_CONNECT;
+        aMessage = aConnectException.Server;
+    }
+    else if (rRequest >>= aReadException)
+    {
+        nErrorCode = ERRCODE_INET_READ;
+        aMessage = aReadException.Diagnostic;
+    }
+    else if (rRequest >>= aWriteException)
+    {
+        nErrorCode = ERRCODE_INET_WRITE;
+        aMessage = aWriteException.Diagnostic;
+    }
+    else
+    {
+        nErrorCode = ERRCODE_INET_GENERAL;
+    }
+
+    postError(aNetworkException.Classification, "network", nErrorCode, aMessage);
+    selectApproved(rContinuations);
+
+    return true;
+}
+
+bool LOKInteractionHandler::handlePasswordRequest(const uno::Sequence<uno::Reference<task::XInteractionContinuation>> &rContinuations, const uno::Any &rRequest)
+{
+    task::DocumentPasswordRequest2 passwordRequest;
+    if (!(rRequest >>= passwordRequest))
+        return false;
+
     if (m_pLOKit->hasOptionalFeature((passwordRequest.IsRequestPasswordToModify)
                 ? LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY
                 : LOK_FEATURE_DOCUMENT_PASSWORD))
@@ -135,28 +297,26 @@ sal_Bool LOKInteractionHandler::handlePasswordRequest(const uno::Sequence<uno::R
             }
         }
     }
-    return sal_True;
+    return true;
 }
 
 sal_Bool SAL_CALL LOKInteractionHandler::handleInteractionRequest(
-        const uno::Reference<task::XInteractionRequest>& xRequest)
-throw (uno::RuntimeException, std::exception)
+        const uno::Reference<task::XInteractionRequest>& xRequest) throw (uno::RuntimeException, std::exception)
 {
     uno::Sequence<uno::Reference<task::XInteractionContinuation>> const &rContinuations = xRequest->getContinuations();
-
     uno::Any const request(xRequest->getRequest());
-    task::DocumentPasswordRequest2 passwordRequest;
-    if (request >>= passwordRequest)
-        return handlePasswordRequest(rContinuations, passwordRequest);
 
-    // TODO: add LOK api that allows handling this for real, for the moment we
-    // just set the interaction as 'Approved'
-    for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
-    {
-        uno::Reference<task::XInteractionApprove> xApprove(rContinuations[i], uno::UNO_QUERY);
-        if (xApprove.is())
-            xApprove->select();
-    }
+    if (handleIOException(rContinuations, request))
+        return true;
+
+    if (handleNetworkException(rContinuations, request))
+        return true;
+
+    if (handlePasswordRequest(rContinuations, request))
+        return true;
+
+    // TODO: perform more interactions 'for real' like the above
+    selectApproved(rContinuations);
 
     return sal_True;
 }
diff --git a/desktop/source/lib/lokinteractionhandler.hxx b/desktop/source/lib/lokinteractionhandler.hxx
index e21d757..337e215 100644
--- a/desktop/source/lib/lokinteractionhandler.hxx
+++ b/desktop/source/lib/lokinteractionhandler.hxx
@@ -22,13 +22,18 @@
 
 #include <osl/conditn.hxx>
 #include <cppuhelper/implbase.hxx>
+#include <tools/errcode.hxx>
 
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/task/DocumentPasswordRequest2.hpp>
 #include <com/sun/star/task/InteractionHandler.hpp>
+#include <com/sun/star/ucb/InteractiveNetworkException.hpp>
 
-namespace desktop { struct LibLibreOffice_Impl; }
+namespace desktop {
+    struct LibLibreOffice_Impl;
+    struct LibLODocument_Impl;
+}
 
 /** InteractionHandler is an interface that provides the user with various dialogs / error messages.
 
@@ -44,6 +49,11 @@ class LOKInteractionHandler: public cppu::WeakImplHelper<com::sun::star::lang::X
 {
 private:
     desktop::LibLibreOffice_Impl * m_pLOKit;
+    desktop::LibLODocument_Impl * m_pLOKDocument;
+
+    /// Command for which we use this interaction handler (like "load", "save", "saveas", ...)
+    OString m_command;
+
     OUString m_Password;
     bool m_usePassword;
     osl::Condition m_havePassword;
@@ -51,14 +61,30 @@ private:
     LOKInteractionHandler(const LOKInteractionHandler&) = delete;
     LOKInteractionHandler& operator=(const LOKInteractionHandler&) = delete;
 
-    sal_Bool handlePasswordRequest(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::task::DocumentPasswordRequest2& passwordRequest);
+    /** Call the LOK_CALLBACK_ERROR on the LOK document (if available) or LOK lib.
+
+        The error itself is a JSON message, like:
+        {
+            "classification": "error" | "warning" | "info"
+            "kind": "network" etc.
+            "code": 403 | 404 | ...
+            "message": freeform description
+        }
+    */
+    void postError(css::task::InteractionClassification classif, const char* kind, ErrCode code, const OUString &message);
+
+    bool handleIOException(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest);
+    bool handleNetworkException(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest);
+    bool handlePasswordRequest(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest);
 
 public:
     void SetPassword(char const* pPassword);
 
     explicit LOKInteractionHandler(
             com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const & rxContext,
-            desktop::LibLibreOffice_Impl *);
+            const OString& rCommand,
+            desktop::LibLibreOffice_Impl *,
+            desktop::LibLODocument_Impl *pLOKDocumt = nullptr);
 
     virtual ~LOKInteractionHandler();
 
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 5931f78..3f2a6ea 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -265,6 +265,20 @@ typedef enum
      * lok::Office::setDocumentPassword().
      */
     LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY,
+
+    /**
+     * An error happened.
+     *
+     * The payload returns information further identifying the error, like:
+     *
+     * {
+     *     "classification": "error" | "warning" | "info"
+     *     "kind": "network" etc.
+     *     "code": 403 | 404 | ...
+     *     "message": freeform description
+     * }
+     */
+    LOK_CALLBACK_ERROR,
 }
 LibreOfficeKitCallbackType;
 
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 175ba50..d2655e4 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -736,6 +736,18 @@ static void formulaChanged(LOKDocView* pDocView, const std::string& rString)
     g_signal_emit(pDocView, doc_view_signals[FORMULA_CHANGED], 0, rString.c_str());
 }
 
+static void reportError(LOKDocView* /*pDocView*/, const std::string& rString)
+{
+    GtkWidget *dialog = gtk_message_dialog_new(nullptr,
+            GTK_DIALOG_DESTROY_WITH_PARENT,
+            GTK_MESSAGE_ERROR,
+            GTK_BUTTONS_CLOSE,
+            "%s",
+            rString.c_str());
+    gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_widget_destroy(dialog);
+}
+
 static void
 setPart(LOKDocView* pDocView, const std::string& rString)
 {
@@ -1074,6 +1086,11 @@ callback (gpointer pData)
         formulaChanged(pDocView, pCallback->m_aPayload);
     }
     break;
+    case LOK_CALLBACK_ERROR:
+    {
+        reportError(pDocView, pCallback->m_aPayload);
+    }
+    break;
     default:
         g_assert(false);
         break;
commit 67f7e80d9ec2227770dc0e052c658bbc499083bf
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Feb 2 11:54:35 2016 +0100

    lok interaction handler: Move password handling to an own method.
    
    Change-Id: I1b3cfdef5f4f81c9138ad5600e43755841df5d75
    (cherry picked from commit 0fa0bc66e2010d01947671022926c3ae920fbf11)

diff --git a/desktop/source/lib/lokinteractionhandler.cxx b/desktop/source/lib/lokinteractionhandler.cxx
index 50a7972..86f521e 100644
--- a/desktop/source/lib/lokinteractionhandler.cxx
+++ b/desktop/source/lib/lokinteractionhandler.cxx
@@ -25,7 +25,6 @@
 #include <com/sun/star/task/XInteractionAbort.hpp>
 #include <com/sun/star/task/XInteractionApprove.hpp>
 #include <com/sun/star/task/XInteractionPassword2.hpp>
-#include <com/sun/star/task/DocumentPasswordRequest2.hpp>
 
 #define LOK_USE_UNSTABLE_API
 #include <../../inc/lib/init.hxx>
@@ -80,76 +79,75 @@ throw (uno::RuntimeException, std::exception)
     handleInteractionRequest(xRequest);
 }
 
-sal_Bool SAL_CALL LOKInteractionHandler::handleInteractionRequest(
-        const uno::Reference<task::XInteractionRequest>& xRequest)
-throw (uno::RuntimeException, std::exception)
+sal_Bool LOKInteractionHandler::handlePasswordRequest(const uno::Sequence<uno::Reference<task::XInteractionContinuation>> &rContinuations, const task::DocumentPasswordRequest2& passwordRequest)
 {
-    uno::Sequence<uno::Reference<task::XInteractionContinuation>> const &rContinuations = xRequest->getContinuations();
-
-    uno::Any const request(xRequest->getRequest());
-    task::DocumentPasswordRequest2 passwordRequest;
-    if (request >>= passwordRequest)
+    if (m_pLOKit->hasOptionalFeature((passwordRequest.IsRequestPasswordToModify)
+                ? LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY
+                : LOK_FEATURE_DOCUMENT_PASSWORD))
     {
-        if (m_pLOKit->hasOptionalFeature((passwordRequest.IsRequestPasswordToModify)
-                    ? LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY
-                    : LOK_FEATURE_DOCUMENT_PASSWORD))
-        {
-            OString const url(passwordRequest.Name.toUtf8());
-            m_pLOKit->mpCallback(passwordRequest.IsRequestPasswordToModify
-                        ? LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY
-                        : LOK_CALLBACK_DOCUMENT_PASSWORD,
-                    url.getStr(),
-                    m_pLOKit->mpCallbackData);
-
-            // block until SetPassword is called
-            m_havePassword.wait();
-            m_havePassword.reset();
-        }
+        OString const url(passwordRequest.Name.toUtf8());
+        m_pLOKit->mpCallback(passwordRequest.IsRequestPasswordToModify
+                ? LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY
+                : LOK_CALLBACK_DOCUMENT_PASSWORD,
+                url.getStr(),
+                m_pLOKit->mpCallbackData);
+
+        // block until SetPassword is called
+        m_havePassword.wait();
+        m_havePassword.reset();
+    }
 
-        for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
+    for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
+    {
+        if (m_usePassword)
         {
-            if (m_usePassword)
+            if (passwordRequest.IsRequestPasswordToModify)
             {
-                if (passwordRequest.IsRequestPasswordToModify)
-                {
-                    uno::Reference<task::XInteractionPassword2> const xIPW2(
-                            rContinuations[i], uno::UNO_QUERY);
-                    xIPW2->setPasswordToModify(m_Password);
-                    xIPW2->select();
-                }
-                else
-                {
-                    uno::Reference<task::XInteractionPassword> const xIPW(
-                            rContinuations[i], uno::UNO_QUERY);
-                    if (xIPW.is())
-                    {
-                        xIPW->setPassword(m_Password);
-                        xIPW->select();
-                    }
-                }
+                uno::Reference<task::XInteractionPassword2> const xIPW2(rContinuations[i], uno::UNO_QUERY);
+                xIPW2->setPasswordToModify(m_Password);
+                xIPW2->select();
             }
             else
             {
-                if (passwordRequest.IsRequestPasswordToModify)
+                uno::Reference<task::XInteractionPassword> const xIPW(rContinuations[i], uno::UNO_QUERY);
+                if (xIPW.is())
                 {
-                    uno::Reference<task::XInteractionPassword2> const xIPW2(
-                            rContinuations[i], uno::UNO_QUERY);
-                    xIPW2->setRecommendReadOnly(true);
-                    xIPW2->select();
+                    xIPW->setPassword(m_Password);
+                    xIPW->select();
                 }
-                else
+            }
+        }
+        else
+        {
+            if (passwordRequest.IsRequestPasswordToModify)
+            {
+                uno::Reference<task::XInteractionPassword2> const xIPW2(rContinuations[i], uno::UNO_QUERY);
+                xIPW2->setRecommendReadOnly(true);
+                xIPW2->select();
+            }
+            else
+            {
+                uno::Reference<task::XInteractionAbort> const xAbort(rContinuations[i], uno::UNO_QUERY);
+                if (xAbort.is())
                 {
-                    uno::Reference<task::XInteractionAbort> const xAbort(
-                            rContinuations[i], uno::UNO_QUERY);
-                    if (xAbort.is())
-                    {
-                        xAbort->select();
-                    }
+                    xAbort->select();
                 }
             }
         }
-        return sal_True;
     }
+    return sal_True;
+}
+
+sal_Bool SAL_CALL LOKInteractionHandler::handleInteractionRequest(
+        const uno::Reference<task::XInteractionRequest>& xRequest)
+throw (uno::RuntimeException, std::exception)
+{
+    uno::Sequence<uno::Reference<task::XInteractionContinuation>> const &rContinuations = xRequest->getContinuations();
+
+    uno::Any const request(xRequest->getRequest());
+    task::DocumentPasswordRequest2 passwordRequest;
+    if (request >>= passwordRequest)
+        return handlePasswordRequest(rContinuations, passwordRequest);
 
     // TODO: add LOK api that allows handling this for real, for the moment we
     // just set the interaction as 'Approved'
diff --git a/desktop/source/lib/lokinteractionhandler.hxx b/desktop/source/lib/lokinteractionhandler.hxx
index 85a71da..e21d757 100644
--- a/desktop/source/lib/lokinteractionhandler.hxx
+++ b/desktop/source/lib/lokinteractionhandler.hxx
@@ -25,6 +25,7 @@
 
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/task/DocumentPasswordRequest2.hpp>
 #include <com/sun/star/task/InteractionHandler.hpp>
 
 namespace desktop { struct LibLibreOffice_Impl; }
@@ -50,6 +51,8 @@ private:
     LOKInteractionHandler(const LOKInteractionHandler&) = delete;
     LOKInteractionHandler& operator=(const LOKInteractionHandler&) = delete;
 
+    sal_Bool handlePasswordRequest(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::task::DocumentPasswordRequest2& passwordRequest);
+
 public:
     void SetPassword(char const* pPassword);
 
commit cd3d4135bb71ff2013fd7635bb51c0911337d367
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Feb 2 10:32:36 2016 +0100

    LOK: add Document::setClientVisibleArea()
    
    ... and implement it in Writer.
    
    Otherwise there is no way we can perform e.g. page down in an expected
    way. Without this, the core visible area depends on the zoom in the
    document, and the client visible area can be something entirely
    different.
    
    (cherry picked from commit bd8610ebafa9caf9f09a5aba9cca04c23691513d)
    
    Conflicts:
    	libreofficekit/source/gtk/lokdocview.cxx
    	sw/inc/unotxdoc.hxx
    
    (cherry picked from commit 1ae319aa81b7d42441886dd232256b0336308cf3)
    
    Change-Id: Iadfb5a225da09a2551ffa41ddf503bb3d22b3eae

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6cdf89e..cd6c045 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -368,6 +368,7 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis,
                                     int nTilePixelHeight,
                                     int nTileTwipWidth,
                                     int nTileTwipHeight);
+static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
 static int doc_createView(LibreOfficeKitDocument* pThis);
 static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
 static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
@@ -409,6 +410,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->resetSelection = doc_resetSelection;
         m_pDocumentClass->getCommandValues = doc_getCommandValues;
         m_pDocumentClass->setClientZoom = doc_setClientZoom;
+        m_pDocumentClass->setClientVisibleArea = doc_setClientVisibleArea;
 
         m_pDocumentClass->createView = doc_createView;
         m_pDocumentClass->destroyView = doc_destroyView;
@@ -1509,6 +1511,19 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTilePixelWidth
     pDoc->setClientZoom(nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
 }
 
+static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight)
+{
+    ITiledRenderable* pDoc = getTiledRenderable(pThis);
+    if (!pDoc)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+        return;
+    }
+
+    Rectangle aRectangle(Point(nX, nY), Size(nWidth, nHeight));
+    pDoc->setClientVisibleArea(aRectangle);
+}
+
 static int doc_createView(LibreOfficeKitDocument* /*pThis*/)
 {
     SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 502c607..0ad5dc6 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -203,6 +203,8 @@ struct _LibreOfficeKitDocumentClass
             int nTilePixelHeight,
             int nTileTwipWidth,
             int nTileTwipHeight);
+    /// @see lok::Document::setVisibleArea).
+    void (*setClientVisibleArea) (LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
 
     /// @see lok::Document::createView().
     int (*createView) (LibreOfficeKitDocument* pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 8a7361c..896b5d5 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -333,6 +333,21 @@ public:
     }
 
     /**
+     * Inform core about the currently visible area of the document on the
+     * client, so that it can perform e.g. page down (which depends on the
+     * visible height) in a sane way.
+     *
+     * @param nX - top left corner horizontal position
+     * @param nY - top left corner vertical position
+     * @param nWidth - area width
+     * @param nHeight - area height
+     */
+    inline void setClientVisibleArea(int nX, int nY, int nWidth, int nHeight)
+    {
+        mpDoc->pClass->setClientVisibleArea(mpDoc, nX, nY, nWidth, nHeight);
+    }
+
+    /**
      * Create a new view for an existing document.
      * By default a loaded document has 1 view.
      * @return the ID of the new view.
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index a86bb4d..87b2dff 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -198,6 +198,11 @@ public:
                                int /*nTileTwipHeight*/)
     {
     }
+
+    /// @see lok::Document::setClientVisibleArea().
+    virtual void setClientVisibleArea(const Rectangle& /*rRectangle*/)
+    {
+    }
 };
 
 } // namespace vcl
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 9435920..81dd85e 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -435,6 +435,8 @@ public:
     virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override;
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() override;
+    /// @see vcl::ITiledRenderable::setClientVisibleArea().
+    virtual void setClientVisibleArea(const Rectangle& rRectangle) override;
     /// @see vcl::ITiledRenderable::getPointer().
     virtual Pointer getPointer() override;
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 3d3f224..218b1ea 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3180,6 +3180,15 @@ bool SwXTextDocument::isMimeTypeSupported()
     return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper);
 }
 
+void SwXTextDocument::setClientVisibleArea(const Rectangle& rRectangle)
+{
+    SwView* pView = pDocShell->GetView();
+    if (!pView)
+        return;
+
+    pView->SetVisArea(rRectangle);
+}
+
 Pointer SwXTextDocument::getPointer()
 {
     SolarMutexGuard aGuard;
commit 31da9fc61614b60785a7c04f6d4e7ef7a3f28343
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon Feb 1 18:50:02 2016 +0100

    lool - now the fill cursor type is mapped correctly
    
    Change-Id: I6d89df49b9f740b7f81394938222261f25a50dba
    (cherry picked from commit 4dae4ed81b82ea3f5ae5f1097e5c75c3b1f0644e)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a2b011c..6cdf89e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -198,6 +198,7 @@ static const std::map <PointerStyle, OString> aPointerMap {
     { PointerStyle::Text, "text" },
     { PointerStyle::Help, "help" },
     { PointerStyle::Cross, "crosshair" },
+    { PointerStyle::Fill, "fill" },
     { PointerStyle::Move, "move" },
     { PointerStyle::NSize, "n-resize" },
     { PointerStyle::SSize, "s-resize" },
@@ -1123,7 +1124,6 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
     pDoc->postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier);
 
     Pointer aPointer = pDoc->getPointer();
-
     // We don't map all possible pointers hence we need a default
     OString aPointerString = "default";
     auto aIt = aPointerMap.find(aPointer.GetStyle());
commit 8791c71122e02a0e8a3155cf457fb25cb66243ef
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 21 09:10:29 2016 +0100

    Clean up lok::Office::freeError()
    
    - let it take a non-const pointer, just like free() or g_free() does
    - remove lok::Document::freeError(), which was declared, but not
      implemented
    - move the declaration at the end of the stable API, but before the
      unstable section
    
    (cherry picked from commit 8e0c4694f89dd66314faf5cfd411f58f2f8e1bca)
    
    Change-Id: I5a8ced61fc87641dc2fa0ea3615a350361fae3a1

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6e65823..a2b011c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -435,7 +435,7 @@ static void                    lo_destroy       (LibreOfficeKit* pThis);
 static int                     lo_initialize    (LibreOfficeKit* pThis, const char* pInstallPath, const char* pUserProfilePath);
 static LibreOfficeKitDocument* lo_documentLoad  (LibreOfficeKit* pThis, const char* pURL);
 static char *                  lo_getError      (LibreOfficeKit* pThis);
-static void                    lo_freeError     (const char *pfree);
+static void                    lo_freeError     (char* pFree);
 static LibreOfficeKitDocument* lo_documentLoadWithOptions  (LibreOfficeKit* pThis,
                                                            const char* pURL,
                                                            const char* pOptions);
@@ -1552,9 +1552,10 @@ static char* lo_getError (LibreOfficeKit *pThis)
     strcpy(pMemory, aString.getStr());
     return pMemory;
 }
-static void lo_freeError(const char *pfree)
+
+static void lo_freeError(char* pFree)
 {
-    free(const_cast<char *>(pfree));
+    free(pFree);
 }
 
 static char* lo_getFilterTypes(LibreOfficeKit* pThis)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 50261bc..502c607 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -56,6 +56,8 @@ struct _LibreOfficeKitClass
     LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis,
                                                         const char* pURL,
                                                         const char* pOptions);
+    void (*freeError) (char* pFree);
+
 #ifdef LOK_USE_UNSTABLE_API
     void (*registerCallback) (LibreOfficeKit* pThis,
                               LibreOfficeKitCallback pCallback,
@@ -72,7 +74,6 @@ struct _LibreOfficeKitClass
             char const* pURL,
             char const* pPassword);
 #endif
-    void  (*freeError)     (const char *pfree);
 
 };
 
@@ -93,7 +94,6 @@ struct _LibreOfficeKitDocumentClass
                    const char* pUrl,
                    const char* pFormat,
                    const char* pFilterOptions);
-    void  (*freeError)     (const char *pfree);
 
 #ifdef LOK_USE_UNSTABLE_API
     /// @see lok::Document::getDocumentType().
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index cbbedb0..8a7361c 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -56,10 +56,6 @@ public:
 
     /// Gives access to the underlying C pointer.
     inline LibreOfficeKitDocument *get() { return mpDoc; }
-    inline void freeError(const char *pfree)
-    {
-        mpDoc->pClass->freeError(pfree);
-    }
 
 #ifdef LOK_USE_UNSTABLE_API
     /**
@@ -426,12 +422,13 @@ public:
     {
         return mpThis->pClass->getError(mpThis);
     }
-    inline void freeError(const char *pfree)
+
+    /// Frees the memory pointed to by pFree.
+    inline void freeError(char* pFree)
     {
-        mpThis->pClass->freeError(pfree);
+        mpThis->pClass->freeError(pFree);
     }
 
-
 #ifdef LOK_USE_UNSTABLE_API
     /**
      * Returns details of filter types.
commit 0ab6b2f30e561a0489ee4b249429f4cbf5e4a7c4
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 19 22:05:00 2016 +0100

    loplugin:cstylecast
    
    Change-Id: Ib4052fa88cce3b21d20d050fff9c8d32fcde4c20
    (cherry picked from commit 10c9f31ad7d0696327b67b6d2a4e3f244473d877)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4f7c2e2..6e65823 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1554,7 +1554,7 @@ static char* lo_getError (LibreOfficeKit *pThis)
 }
 static void lo_freeError(const char *pfree)
 {
-    free((void *) pfree);
+    free(const_cast<char *>(pfree));
 }
 
 static char* lo_getFilterTypes(LibreOfficeKit* pThis)
commit 325e193db0c212f81dd05105000bb79b2af939d8
Author: Oliver Specht <oliver.specht at cib.de>
Date:   Wed Jan 20 07:52:51 2016 +0100

    freeError function moved to the end of the list
    
    Change-Id: I4aed102b25ddcd5f2e8fa03395e2ffd89c858bb9
    Reviewed-on: https://gerrit.libreoffice.org/21619
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Oliver Specht <oliver.specht at cib.de>
    (cherry picked from commit 23c2c7c9cb86db4a36f8a798e63402a053816ef2)

diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 819a7e5..50261bc 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -52,7 +52,6 @@ struct _LibreOfficeKitClass
                                              const char* pURL);
 
     char* (*getError) (LibreOfficeKit* pThis);
-    void  (*freeError)     (const char *pfree);
 
     LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis,
                                                         const char* pURL,
@@ -73,6 +72,8 @@ struct _LibreOfficeKitClass
             char const* pURL,
             char const* pPassword);
 #endif
+    void  (*freeError)     (const char *pfree);
+
 };
 
 #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
commit e241fbf5fbf3c5bb95a7b63c551cb0a5ba9dcb70
Author: Oliver Specht <oliver.specht at cib.de>
Date:   Tue Jan 19 10:58:07 2016 +0100

    Make LibreOffice kit usable on windows
    
    Uses Ascii variants of LoadLibrary,Get/SetEnvironmentVariable_A_
    and adds a freeError function
    includes windows.h instead of pre/postwin.h
    
    Change-Id: I88b7e3ed3818078efec5688e207da47dc4049b98
    Reviewed-on: https://gerrit.libreoffice.org/21600
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Oliver Specht <oliver.specht at cib.de>
    (cherry picked from commit 442a022cf7baefbd5519ea55c7978cf839e1f44d)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 397448c..4f7c2e2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -435,6 +435,7 @@ static void                    lo_destroy       (LibreOfficeKit* pThis);
 static int                     lo_initialize    (LibreOfficeKit* pThis, const char* pInstallPath, const char* pUserProfilePath);
 static LibreOfficeKitDocument* lo_documentLoad  (LibreOfficeKit* pThis, const char* pURL);
 static char *                  lo_getError      (LibreOfficeKit* pThis);
+static void                    lo_freeError     (const char *pfree);
 static LibreOfficeKitDocument* lo_documentLoadWithOptions  (LibreOfficeKit* pThis,
                                                            const char* pURL,
                                                            const char* pOptions);
@@ -461,6 +462,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
         m_pOfficeClass->destroy = lo_destroy;
         m_pOfficeClass->documentLoad = lo_documentLoad;
         m_pOfficeClass->getError = lo_getError;
+        m_pOfficeClass->freeError = lo_freeError;
         m_pOfficeClass->documentLoadWithOptions = lo_documentLoadWithOptions;
         m_pOfficeClass->registerCallback = lo_registerCallback;
         m_pOfficeClass->getFilterTypes = lo_getFilterTypes;
@@ -1550,6 +1552,10 @@ static char* lo_getError (LibreOfficeKit *pThis)
     strcpy(pMemory, aString.getStr());
     return pMemory;
 }
+static void lo_freeError(const char *pfree)
+{
+    free((void *) pfree);
+}
 
 static char* lo_getFilterTypes(LibreOfficeKit* pThis)
 {
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index b31e5ee..819a7e5 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -52,6 +52,7 @@ struct _LibreOfficeKitClass
                                              const char* pURL);
 
     char* (*getError) (LibreOfficeKit* pThis);
+    void  (*freeError)     (const char *pfree);
 
     LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis,
                                                         const char* pURL,
@@ -91,6 +92,7 @@ struct _LibreOfficeKitDocumentClass
                    const char* pUrl,
                    const char* pFormat,
                    const char* pFilterOptions);
+    void  (*freeError)     (const char *pfree);
 
 #ifdef LOK_USE_UNSTABLE_API
     /// @see lok::Document::getDocumentType().
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index bc52c5c..cbbedb0 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -56,6 +56,10 @@ public:
 
     /// Gives access to the underlying C pointer.
     inline LibreOfficeKitDocument *get() { return mpDoc; }
+    inline void freeError(const char *pfree)
+    {
+        mpDoc->pClass->freeError(pfree);
+    }
 
 #ifdef LOK_USE_UNSTABLE_API
     /**
@@ -422,6 +426,11 @@ public:
     {
         return mpThis->pClass->getError(mpThis);
     }
+    inline void freeError(const char *pfree)
+    {
+        mpThis->pClass->freeError(pfree);
+    }
+
 
 #ifdef LOK_USE_UNSTABLE_API
     /**
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index 380383b..4fa1847 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -76,8 +76,7 @@ extern "C"
 
 #else
 
-    #include "prewin.h"
-    #include "postwin.h"
+    #include  <windows.h>
     #define TARGET_LIB        "sofficeapp" ".dll"
     #define TARGET_MERGED_LIB "mergedlo" ".dll"
     #define SEPARATOR         '\\'
@@ -85,7 +84,7 @@ extern "C"
 
     void *lok_loadlib(const char *pFN)
     {
-        return (void *) LoadLibrary(pFN);
+        return (void *) LoadLibraryA(pFN);
     }
 
     char *lok_dlerror(void)
@@ -111,11 +110,11 @@ extern "C"
             return;
 
         char* sEnvPath = NULL;
-        DWORD  cChars = GetEnvironmentVariable("PATH", sEnvPath, 0);
+        DWORD  cChars = GetEnvironmentVariableA("PATH", sEnvPath, 0);
         if (cChars > 0)
         {
             sEnvPath = new char[cChars];
-            cChars = GetEnvironmentVariable("PATH", sEnvPath, cChars);
+            cChars = GetEnvironmentVariableA("PATH", sEnvPath, cChars);
             //If PATH is not set then it is no error
             if (cChars == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND)
             {
@@ -125,17 +124,18 @@ extern "C"
         }
         //prepare the new PATH. Add the Ure/bin directory at the front.
         //note also adding ';'
-        char * sNewPath = new char[strlen(sEnvPath) + strlen(pPath) + strlen(UNOPATH) + 2];
+        char * sNewPath = new char[strlen(sEnvPath) + strlen(pPath) * 2 + strlen(UNOPATH) + 4];
         sNewPath[0] = L'\0';
-        strcat(sNewPath, pPath);
-        strcat(sNewPath, UNOPATH);
+        strcat(sNewPath, pPath);     // program to PATH
+        strcat(sNewPath, ";");
+        strcat(sNewPath, UNOPATH);   // UNO to PATH
         if (strlen(sEnvPath))
         {
             strcat(sNewPath, ";");
             strcat(sNewPath, sEnvPath);
         }
 
-        SetEnvironmentVariable("PATH", sNewPath);
+        SetEnvironmentVariableA("PATH", sNewPath);
 
         delete[] sEnvPath;
         delete[] sNewPath;
commit 61425bc36d9901839fcd1e197c4ef894256f5180
Author: Henry Castro <hcastro at collabora.com>
Date:   Fri Jan 22 16:47:51 2016 -0400

    sc lokit: update zoom values to graphic and text selection
    
    Reviewed-on: https://gerrit.libreoffice.org/21724
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Tested-by: Henry Castro <hcastro at collabora.com>
    (cherry picked from commit c99502a1c00ccec1b061dee10fe6a69715e14b8b)
    
    Change-Id: I750f31c5698d9dc5ed589a1812a6993991915dc5

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 5a65e3b..d92f129 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -631,7 +631,8 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
     ScDrawView* pDrawView = pViewData->GetScDrawView();
 
     // update the aLogicMode in ScViewData to something predictable
-    pViewData->SetZoom(Fraction(1, 1), Fraction(1, 1), true);
+    pViewData->SetZoom(Fraction(nTilePixelWidth * TWIPS_PER_PIXEL, nTileTwipWidth),
+                       Fraction(nTilePixelHeight * TWIPS_PER_PIXEL, nTileTwipHeight), true);
 
     bool bHandled = false;
 
@@ -786,7 +787,8 @@ void ScModelObj::setGraphicSelection(int nType, int nX, int nY)
     ScGridWindow* pGridWindow = pViewData->GetActiveWin();
 
     // update the aLogicMode in ScViewData to something predictable
-    pViewData->SetZoom(Fraction(1, 1), Fraction(1, 1), true);
+    pViewData->SetZoom(Fraction(nTilePixelWidth * TWIPS_PER_PIXEL, nTileTwipWidth),
+                       Fraction(nTilePixelHeight * TWIPS_PER_PIXEL, nTileTwipHeight), true);
 
     int nPixelX = nX * pViewData->GetPPTX();
     int nPixelY = nY * pViewData->GetPPTY();
commit eeec4fd4cef2927ab75909e040e137941634b565
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Jan 25 21:49:31 2016 +0100

    sd lok: Fix normal 'search' performed after a 'search all'.
    
    The DBG_ASSERT followed by the same test actually returning immediately
    prevents the actual 'search' after a 'search all' being performed.
    
    I hope this does not have any negative consequences; but if it does, we should
    fix the root cause, instead of having this kind of defensive programming here.
    
    (cherry picked from commit 1a83c2259498b070c8d38beb44017f319cbdbee4)
    
    Change-Id: I909533f301dda9c20cab1968de45e5fa7975e852

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 01c9bc5..a2fa0e7 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -60,6 +60,7 @@ public:
     void testResizeTable();
     void testResizeTableColumn();
     void testSearchAllNotifications();
+    void testSearchAllFollowedBySearch();
 #endif
 
     CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
@@ -77,6 +78,7 @@ public:
     CPPUNIT_TEST(testResizeTable);
     CPPUNIT_TEST(testResizeTableColumn);
     CPPUNIT_TEST(testSearchAllNotifications);
+    CPPUNIT_TEST(testSearchAllFollowedBySearch);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -613,6 +615,21 @@ void SdTiledRenderingTest::testSearchAllNotifications()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SdTiledRenderingTest::testSearchAllFollowedBySearch()
+{
+    comphelper::LibreOfficeKit::setActive();
+    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
+    pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this);
+
+    lcl_search("third", /*bFindAll=*/true);
+    lcl_search("match", /*bFindAll=*/false);
+
+    OString aUsedFormat;
+    // This used to give wrong result: 'search' after 'search all' still
+    // returned 'third'
+    CPPUNIT_ASSERT_EQUAL(OString("match"), pXImpressDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat));
+}
+
 #endif
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index dd0d797..d963d43 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -704,11 +704,8 @@ bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
     DetectChange ();
 
     OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
-    DBG_ASSERT(pOutlinerView!=nullptr && GetEditEngine().HasView( &pOutlinerView->GetEditView() ),
-        "SearchAndReplace without valid view!" );
-
-    if( nullptr == pOutlinerView || !GetEditEngine().HasView( &pOutlinerView->GetEditView() ) )
-        return true;
+    if (!pOutlinerView)
+        return true; // end of search
 
     std::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock());
     if (pViewShell != nullptr)
commit e150ed84be3dc676484631ff05d926fa19c78698
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jan 22 18:34:27 2016 +0100

    sw tiled rendering: avoid unnecessary invalidation in SwView::SetVisArea()
    
    SwWrtShell's visible area is set to the entire document since
    12e3b51abe883202af09769873f87b27d7de118b (tdf#94237 tiled rendering: Use
    the entire document as the visual area., 2015-09-15).
    
    Let's be consistent and do the same for SwView, so that
    SwView::PageDown() and all other similar functions do not cause
    unnecessary invalidations, as this way later we'll realize that SwView's
    and SwWrtShell's visible area is the same.
    
    (cherry picked from commit 7b48a8fb2f0a0d8b854ec00d5f03ec09e8cfa4da)
    
    Change-Id: Ia22f07ddfb18c6f5ab6cbafede7cf8799b1177a1

diff --git a/sw/qa/extras/tiledrendering/data/pagedown-invalidation.odt b/sw/qa/extras/tiledrendering/data/pagedown-invalidation.odt
new file mode 100644
index 0000000..0cad2d2
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/pagedown-invalidation.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 197ca6a..ed2c22f 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -48,6 +48,7 @@ public:
     void testDocumentSizeChanged();
     void testSearchAll();
     void testSearchAllNotifications();
+    void testPageDownInvalidation();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -64,6 +65,7 @@ public:
     CPPUNIT_TEST(testDocumentSizeChanged);
     CPPUNIT_TEST(testSearchAll);
     CPPUNIT_TEST(testSearchAllNotifications);
+    CPPUNIT_TEST(testPageDownInvalidation);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -78,12 +80,14 @@ private:
     std::vector<int> m_aSearchResultPart;
     int m_nSelectionBeforeSearchResult;
     int m_nSelectionAfterSearchResult;
+    int m_nInvalidations;
 };
 
 SwTiledRenderingTest::SwTiledRenderingTest()
     : m_bFound(true),
-    m_nSelectionBeforeSearchResult(0),
-    m_nSelectionAfterSearchResult(0)
+      m_nSelectionBeforeSearchResult(0),
+      m_nSelectionAfterSearchResult(0),
+      m_nInvalidations(0)
 {
 }
 
@@ -119,6 +123,7 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
             m_aInvalidation.setWidth(aSeq[2].toInt32());
             m_aInvalidation.setHeight(aSeq[3].toInt32());
         }
+        ++m_nInvalidations;
     }
     break;
     case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
@@ -487,6 +492,25 @@ void SwTiledRenderingTest::testSearchAllNotifications()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SwTiledRenderingTest::testPageDownInvalidation()
+{
+    comphelper::LibreOfficeKit::setActive();
+
+    SwXTextDocument* pXTextDocument = createDoc("pagedown-invalidation.odt");
+    uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+    {
+        {".uno:HideWhitespace", uno::makeAny(true)},
+    }));
+    pXTextDocument->initializeForTiledRendering(aPropertyValues);
+    pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
+    comphelper::dispatchCommand(".uno:PageDown", uno::Sequence<beans::PropertyValue>());
+
+    // This was 2.
+    CPPUNIT_ASSERT_EQUAL(0, m_nInvalidations);
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
index 4114011..326d251 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -49,6 +49,7 @@
 #include <IDocumentSettingAccess.hxx>
 
 #include <basegfx/tools/zoomtools.hxx>
+#include <comphelper/lok.hxx>
 
 // The SetVisArea of the DocShell must not be called from InnerResizePixel.
 // But our adjustments must take place.
@@ -212,7 +213,10 @@ m_aDocSz = rSz;
 
 void SwView::SetVisArea( const Rectangle &rRect, bool bUpdateScrollbar )
 {
-    const Size aOldSz( m_aVisArea.GetSize() );
+    Size aOldSz( m_aVisArea.GetSize() );
+    if (comphelper::LibreOfficeKit::isActive() && m_pWrtShell)
+        // If m_pWrtShell's visible area is the whole document, do the same here.
+        aOldSz = m_pWrtShell->VisArea().SSize();
 
     const Point aTopLeft(     AlignToPixel( rRect.TopLeft() ));
     const Point aBottomRight( AlignToPixel( rRect.BottomRight() ));
commit 1e914d3feaff318f36be504c68fac8c8851c99d4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 21 15:20:45 2016 +0100

    sw tiled editing: default to anchoring new images as-char
    
    (cherry picked from commit e7eca35148204d094dcdb7d8b3e4ec6c9d454159)
    
    Change-Id: I6aeb06fe1697b7a30e83a3b1b364f44e5822fe95

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index bda2256..7ac52c7 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -16,6 +16,7 @@
 #include <com/sun/star/awt/Toolkit.hpp>
 #include <basebmp/bitmapdevice.hxx>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <boost/property_tree/json_parser.hpp>
 #include <comphelper/processfactory.hxx>
 #include <sfx2/objsh.hxx>
@@ -433,6 +434,10 @@ void DesktopLOKTest::testPasteWriterJPEG()
     // This was 0, JPEG was not handled as a format for clipboard paste.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDrawPage->getCount());
 
+    uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+    // This was text::TextContentAnchorType_AT_PARAGRAPH.
+    CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, xShape->getPropertyValue("AnchorType").get<text::TextContentAnchorType>());
+
     comphelper::LibreOfficeKit::setActive(false);
 }
 
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 2c82d5c..c10e6ff 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -105,6 +105,7 @@
 #include "FrameControlsManager.hxx"
 
 #include <sfx2/msgpool.hxx>
+#include <comphelper/lok.hxx>
 #include <memory>
 
 using namespace sw::mark;
@@ -275,6 +276,10 @@ void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
         // because of the DEF-Framesize
         // These must be removed explicitly for the optimal size.
         pFrameMgr->DelAttr(RES_FRM_SIZE);
+
+        if (comphelper::LibreOfficeKit::isActive())
+            // LOK: anchor inserted images as-char by default.
+            pFrameMgr->SetAnchor(FLY_AS_CHAR);
     }
     else
     {


More information about the Libreoffice-commits mailing list