desktop/source/lib/lokinteractionhandler.cxx |   21 +++++++++++++++++++++
 desktop/source/lib/lokinteractionhandler.hxx |    2 ++
 sfx2/source/doc/sfxbasemodel.cxx             |    4 +++-
 uui/source/iahndl.cxx                        |    2 +-
 4 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit 0121412b57b0be847474547f00686aa335dcd2a5
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Fri Sep 22 11:11:06 2023 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Mon Sep 25 15:34:40 2023 +0200

    lok: add broken package interaction handler
    
    in case of repair don't use template flag to not make
    file readonly so we can overwrite it and upload to storage
    updated version
    
    Change-Id: Ia460009fc3b77582dde06dd6f94a85aef3aee11b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157168
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Ashod Nakashian <a...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157240

diff --git a/desktop/source/lib/lokinteractionhandler.cxx 
b/desktop/source/lib/lokinteractionhandler.cxx
index 1e794c0ff651..deebb5d2a30a 100644
--- a/desktop/source/lib/lokinteractionhandler.cxx
+++ b/desktop/source/lib/lokinteractionhandler.cxx
@@ -24,6 +24,7 @@
 #include <comphelper/processfactory.hxx>
 #include <cppuhelper/supportsservice.hxx>
 
+#include <com/sun/star/document/BrokenPackageRequest.hpp>
 #include <com/sun/star/task/XInteractionAbort.hpp>
 #include <com/sun/star/task/XInteractionApprove.hpp>
 #include <com/sun/star/task/XInteractionPassword2.hpp>
@@ -351,6 +352,23 @@ bool 
LOKInteractionHandler::handleMacroConfirmationRequest(const uno::Reference<
     return false;
 }
 
+bool LOKInteractionHandler::handlePackageReparationRequest(const 
uno::Reference<task::XInteractionRequest>& xRequest)
+{
+    uno::Any const request(xRequest->getRequest());
+
+    document::BrokenPackageRequest aBrokenPackageRequest;
+    if (request >>= aBrokenPackageRequest)
+    {
+        auto 
xInteraction(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(),
 nullptr));
+
+        if (xInteraction.is())
+            xInteraction->handleInteractionRequest(xRequest);
+
+        return true;
+    }
+    return false;
+}
+
 bool LOKInteractionHandler::handleFilterOptionsRequest(const 
uno::Reference<task::XInteractionRequest>& xRequest)
 {
     document::FilterOptionsRequest aFilterOptionsRequest;
@@ -390,6 +408,9 @@ sal_Bool SAL_CALL 
LOKInteractionHandler::handleInteractionRequest(
     if (handleMacroConfirmationRequest(xRequest))
         return true;
 
+    if (handlePackageReparationRequest(xRequest))
+        return true;
+
     // TODO: perform more interactions 'for real' like the above
     selectApproved(rContinuations);
 
diff --git a/desktop/source/lib/lokinteractionhandler.hxx 
b/desktop/source/lib/lokinteractionhandler.hxx
index 108343ec22e3..fdbea01c64f6 100644
--- a/desktop/source/lib/lokinteractionhandler.hxx
+++ b/desktop/source/lib/lokinteractionhandler.hxx
@@ -78,6 +78,8 @@ private:
 
     static bool handleFilterOptionsRequest(const 
::com::sun::star::uno::Reference<::com::sun::star::task::XInteractionRequest>& 
Request);
 
+    static bool handlePackageReparationRequest(const 
css::uno::Reference<css::task::XInteractionRequest>& xRequest);
+
 public:
     void SetPassword(char const* pPassword);
 
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 6554ed1f317e..c5768afc7493 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1941,9 +1941,11 @@ void SAL_CALL SfxBaseModel::load(   const Sequence< 
beans::PropertyValue >& seqA
                 xHandler->handle( aRequest.GetRequest() );
                 if( aRequest.isApproved() )
                 {
+                    // lok: we want to overwrite file in jail, so don't use 
template flag
+                    bool bIsLOK = comphelper::LibreOfficeKit::isActive();
                     // broken package: try second loading and allow repair
                     pMedium->GetItemSet()->Put( SfxBoolItem( 
SID_REPAIRPACKAGE, true ) );
-                    pMedium->GetItemSet()->Put( SfxBoolItem( SID_TEMPLATE, 
true ) );
+                    pMedium->GetItemSet()->Put( SfxBoolItem( SID_TEMPLATE, 
!bIsLOK ) );
                     pMedium->GetItemSet()->Put( SfxStringItem( 
SID_DOCINFO_TITLE, aDocName ) );
 
                     // the error must be reset and the storage must be 
reopened in new mode
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index 251a642e509f..a01e090c5d4c 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -948,7 +948,7 @@ executeMessageBox(
     SolarMutexGuard aGuard;
 
     std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(pParent, eMessageType,
-        eMessageType == VclMessageType::Question ? VclButtonsType::YesNo : 
VclButtonsType::Ok, rMessage));
+        eMessageType == VclMessageType::Question ? VclButtonsType::YesNo : 
VclButtonsType::Ok, rMessage, GetpApp()));
     xBox->set_title(rTitle);
 
     short nMessResult = xBox->run();

Reply via email to