comphelper/source/container/embeddedobjectcontainer.cxx    |    4 +++
 include/comphelper/embeddedobjectcontainer.hxx             |    3 ++
 include/svtools/strings.hrc                                |    1 
 officecfg/registry/schema/org/openoffice/Office/Common.xcs |    2 -
 sc/inc/strings.hrc                                         |    1 
 sc/source/ui/docshell/docsh4.cxx                           |   11 ++++++++
 sc/source/ui/view/tabvwshb.cxx                             |   10 +++++++
 sd/source/ui/func/fulink.cxx                               |   13 +++++++++
 sfx2/source/appl/linkmgr2.cxx                              |   10 +++++++
 sfx2/source/appl/lnkbase2.cxx                              |    4 +++
 svl/source/svdde/ddecli.cxx                                |   17 ++++++++-----
 svl/source/svdde/ddesvr.cxx                                |   17 ++++++++-----
 sw/source/uibase/app/docsh2.cxx                            |    2 +
 sw/source/uibase/shells/textfld.cxx                        |   13 +++++++++
 sw/source/uibase/uiview/view2.cxx                          |   11 ++++++++
 15 files changed, 106 insertions(+), 13 deletions(-)

New commits:
commit ec21a5935062175598d36c21d4484b777c915bff
Author:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
AuthorDate: Mon Dec 18 17:28:20 2023 +0300
Commit:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
CommitDate: Thu Dec 21 11:06:44 2023 +0100

    tdf#158375: adapt UI when DDE is disabled via DisableActiveContent
    
    When DisableActiveContent is set, provide now non-functional areas
    meaningful error messages / popup dialogs.
    
    Change-Id: I34bffee10fb0ba5c0194193f3d3d81b93d7dbd26
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160923
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit b693fba185df86fba6389ed564a12c0afeb33778)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161095
    Reviewed-by: Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>

diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc
index 53cefc48d8ff..ab18119242b3 100644
--- a/include/svtools/strings.hrc
+++ b/include/svtools/strings.hrc
@@ -264,6 +264,7 @@
 #define STR_FIELD_INVITE                        NC_("STR_FIELD_INVITE", 
"Invite")
 
 #define STR_WARNING_ACTIVE_CONTENT_DISABLED     
NC_("STR_WARNING_ACTIVE_CONTENT_DISABLED", "Active content is disabled.")
+#define STR_WARNING_EXTERNAL_LINK_EDIT_DISABLED 
NC_("STR_ERROR_EXTERNAL_LINK_EDIT_DISABLED", "It is not possible to edit 
external links. Active content is disabled in the security settings.")
 #define STR_SVT_DEFAULT_SERVICE_LABEL           
NC_("STR_SVT_DEFAULT_SERVICE_LABEL", "$user$'s $service$")
 
 #define STR_WARNING_JAVANOTFOUND                
NC_("STR_WARNING_JAVANOTFOUND", "%PRODUCTNAME requires a Java runtime 
environment (JRE) to perform this task. Please install a JRE and restart 
%PRODUCTNAME. %FAQLINK")
diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index d58777176e52..266cb4cc6c5b 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -371,6 +371,7 @@
 #define STR_ENABLE_CONTENT                          NC_("STR_ENABLE_CONTENT", 
"Allow updating")
 /*tooltip for the "Allow updating" infobar button*/
 #define STR_ENABLE_CONTENT_TOOLTIP                  
NC_("STR_ENABLE_CONTENT_TOOLTIP", "Only allow updating if you trust this 
document.")
+#define STR_ENABLE_CONTENT_TOOLTIP_DISABLED         
NC_("STR_ENABLE_CONTENT_TOOLTIP_DISABLED", "Active content is disabled in the 
security settings. It is not possible to allow updating.")
 /*Insert image dialog*/
 #define STR_ANCHOR_TO_CELL                          NC_("STR_ANCHOR_TO_CELL", 
"To cell")
 #define STR_ANCHOR_TO_CELL_RESIZE                   
NC_("STR_ANCHOR_TO_CELL_RESIZE", "To cell (resize with cell)")
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 964515743c27..4de5b1950183 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -566,6 +566,13 @@ void ScDocShell::Execute( SfxRequest& rReq )
                             rBtn.set_label(ScResId(STR_ENABLE_CONTENT));
                             
rBtn.set_tooltip_text(ScResId(STR_ENABLE_CONTENT_TOOLTIP));
                             rBtn.connect_clicked(LINK(this, ScDocShell, 
ReloadAllLinksHdl));
+
+                            // when active content is disabled the "Allow 
updating" button has no functionality.
+                            if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+                            {
+                                
rBtn.set_tooltip_text(ScResId(STR_ENABLE_CONTENT_TOOLTIP_DISABLED));
+                                rBtn.set_sensitive(false);
+                            }
                         }
                     }
                     rReq.Done();
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index f0415d03d9aa..ad0e757ce0aa 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -64,6 +64,7 @@
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 #include <svx/svdpagv.hxx>
 #include <o3tl/temporary.hxx>
+#include <officecfg/Office/Common.hxx>
 
 #include <comphelper/lok.hxx>
 
@@ -485,6 +486,15 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
         case SID_LINKS:
             {
                 SvxAbstractDialogFactory* pFact = 
SvxAbstractDialogFactory::Create();
+                if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+                {
+                    std::unique_ptr<weld::MessageDialog> 
xError(Application::CreateMessageDialog(
+                        nullptr, VclMessageType::Warning, VclButtonsType::Ok,
+                        SvtResId(STR_WARNING_EXTERNAL_LINK_EDIT_DISABLED)));
+                    xError->run();
+                    break;
+                }
+
                 ScopedVclPtr<SfxAbstractLinksDialog> 
pDlg(pFact->CreateLinksDialog(pWin->GetFrameWeld(), rDoc.GetLinkManager()));
                 pDlg->Execute();
                 rBindings.Invalidate( nSlot );
diff --git a/sd/source/ui/func/fulink.cxx b/sd/source/ui/func/fulink.cxx
index 8a6d726deca1..32b3b70ad880 100644
--- a/sd/source/ui/func/fulink.cxx
+++ b/sd/source/ui/func/fulink.cxx
@@ -28,6 +28,10 @@
 #include <ViewShell.hxx>
 #include <app.hrc>
 
+#include <svtools/strings.hrc>
+#include <svtools/svtresid.hxx>
+#include <officecfg/Office/Common.hxx>
+
 class SfxRequest;
 
 namespace sd {
@@ -52,6 +56,15 @@ rtl::Reference<FuPoor> FuLink::Create( ViewShell* pViewSh, 
::sd::Window* pWin, :
 
 void FuLink::DoExecute( SfxRequest& )
 {
+    if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+    {
+        std::unique_ptr<weld::MessageDialog> xError(
+            Application::CreateMessageDialog(nullptr, VclMessageType::Warning, 
VclButtonsType::Ok,
+                                             
SvtResId(STR_WARNING_EXTERNAL_LINK_EDIT_DISABLED)));
+        xError->run();
+        return;
+    }
+
     sfx2::LinkManager* pLinkManager = mpDoc->GetLinkManager();
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
diff --git a/sw/source/uibase/shells/textfld.cxx 
b/sw/source/uibase/shells/textfld.cxx
index 780a01f943da..68561d8b8ded 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -56,6 +56,8 @@
 #include <doc.hxx>
 #include <PostItMgr.hxx>
 #include <swmodule.hxx>
+#include <svtools/strings.hrc>
+#include <svtools/svtresid.hxx>
 
 #include <editeng/ulspitem.hxx>
 #include <xmloff/odffields.hxx>
@@ -68,6 +70,7 @@
 #include <svx/pageitem.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <IMark.hxx>
+#include <officecfg/Office/Common.hxx>
 #include <officecfg/Office/Compatibility.hxx>
 #include <ndtxt.hxx>
 #include <translatehelper.hxx>
@@ -137,6 +140,16 @@ void SwTextShell::ExecField(SfxRequest &rReq)
                                                 GetBaseLink();
                         if(rLink.IsVisible())
                         {
+                            if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+                            {
+                                std::unique_ptr<weld::MessageDialog> xError(
+                                    Application::CreateMessageDialog(
+                                        nullptr, VclMessageType::Warning, 
VclButtonsType::Ok,
+                                        
SvtResId(STR_WARNING_EXTERNAL_LINK_EDIT_DISABLED)));
+                                xError->run();
+                                break;
+                            }
+
                             SvxAbstractDialogFactory* pFact = 
SvxAbstractDialogFactory::Create();
                             ScopedVclPtr<SfxAbstractLinksDialog> 
pDlg(pFact->CreateLinksDialog(GetView().GetFrameWeld(), &rSh.GetLinkManager(), 
false, &rLink));
                             pDlg->Execute();
diff --git a/sw/source/uibase/uiview/view2.cxx 
b/sw/source/uibase/uiview/view2.cxx
index 6cb3aeedeece..cc6faf78a3c5 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -120,6 +120,8 @@
 #include <comphelper/lok.hxx>
 #include <comphelper/string.hxx>
 #include <comphelper/docpasswordhelper.hxx>
+#include <svtools/strings.hrc>
+#include <svtools/svtresid.hxx>
 
 #include <PostItMgr.hxx>
 
@@ -2454,6 +2456,15 @@ void SwView::InsFrameMode(sal_uInt16 nCols)
 /// show "edit link" dialog
 void SwView::EditLinkDlg()
 {
+    if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+    {
+        std::unique_ptr<weld::MessageDialog> xError(
+            Application::CreateMessageDialog(nullptr, VclMessageType::Warning, 
VclButtonsType::Ok,
+                                             
SvtResId(STR_WARNING_EXTERNAL_LINK_EDIT_DISABLED)));
+        xError->run();
+        return;
+    }
+
     bool bWeb = dynamic_cast<SwWebView*>( this ) !=  nullptr;
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     ScopedVclPtr<SfxAbstractLinksDialog> 
pDlg(pFact->CreateLinksDialog(GetViewFrame().GetFrameWeld(), 
&GetWrtShell().GetLinkManager(), bWeb));
commit e377a29bcf9bc383749edfb5a9d0c0dcbd8dfe59
Author:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
AuthorDate: Mon Dec 18 16:37:16 2023 +0300
Commit:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
CommitDate: Thu Dec 21 11:06:31 2023 +0100

    tdf#158375: disable DDE when DisableActiveContent is set
    
    Change-Id: I167f6ea5d740b5a53cd02a9b865e65ff980a8877
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160922
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit 21f8e08c60cde2599f45b9e02c2b7d0cead2f625)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161029
    Reviewed-by: Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>

diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx 
b/comphelper/source/container/embeddedobjectcontainer.cxx
index 9a971b41b3f6..23915d3e13ab 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -46,6 +46,8 @@
 #include <cppuhelper/weakref.hxx>
 #include <sal/log.hxx>
 
+#include <officecfg/Office/Common.hxx>
+
 #include <algorithm>
 #include <unordered_map>
 
@@ -1492,6 +1494,8 @@ bool EmbeddedObjectContainer::SetPersistentEntries(const 
uno::Reference< embed::
 
 bool EmbeddedObjectContainer::getUserAllowsLinkUpdate() const
 {
+    if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+        return false;
     return pImpl->mbUserAllowsLinkUpdate;
 }
 
diff --git a/include/comphelper/embeddedobjectcontainer.hxx 
b/include/comphelper/embeddedobjectcontainer.hxx
index cc040da152c3..8c75718dce35 100644
--- a/include/comphelper/embeddedobjectcontainer.hxx
+++ b/include/comphelper/embeddedobjectcontainer.hxx
@@ -182,7 +182,10 @@ public:
     */
     bool             SetPersistentEntries(const css::uno::Reference< 
css::embed::XStorage >& _xStorage,bool _bClearModifiedFlag = true);
 
+    // if DisableActiveContent configuration option is set, this always 
returns false
     bool getUserAllowsLinkUpdate() const;
+
+    // if DisableActiveContent configuration option is set, this has no effect
     void setUserAllowsLinkUpdate(bool bNew);
 };
 
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 27e7eba04007..53aa213ac80d 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -2520,7 +2520,7 @@
         <prop oor:name="DisableActiveContent" oor:type="xs:boolean" 
oor:nillable="false">
           <info>
             <desc>Specifies whether or not to disable active content. Right now
-            only disables active embedded content (OLE).</desc>
+            only disables active embedded content (OLE) and DDE.</desc>
           </info>
           <value>false</value>
         </prop>
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index f8a33f91d1e8..964515743c27 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -109,6 +109,7 @@
 #include <helpids.h>
 #include <editeng/eeitem.hxx>
 #include <editeng/langitem.hxx>
+#include <officecfg/Office/Common.hxx>
 
 #include <svx/xdef.hxx>
 
@@ -2501,6 +2502,9 @@ bool ScDocShell::DdeSetData( const OUString& rItem,
 
 ::sfx2::SvLinkSource* ScDocShell::DdeCreateLinkSource( const OUString& rItem )
 {
+    if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+        return nullptr;
+
     //  only check for valid item string - range is parsed again in 
ScServerObject ctor
 
     //  named range?
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index f529fb11d468..a20501a1bad6 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -21,6 +21,7 @@
 #include <sfx2/linkmgr.hxx>
 #include <sfx2/sfxsids.hrc>
 #include <com/sun/star/document/UpdateDocMode.hpp>
+#include <officecfg/Office/Common.hxx>
 #include <osl/file.hxx>
 #include <sfx2/objsh.hxx>
 #include <svl/urihelper.hxx>
@@ -281,6 +282,11 @@ void LinkManager::UpdateAllLinks(
     bool bUpdateGrfLinks,
     weld::Window* pParentWin )
 {
+    // when active content is disabled don't bother updating all links
+    // also (when bAskUpdate == true) don't show the pop up.
+    
if(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+        return;
+
     // First make a copy of the array in order to update links
     // links in ... no contact between them!
     std::vector<SvBaseLink*> aTmpArr;
@@ -354,8 +360,12 @@ SvLinkSourceRef LinkManager::CreateObj( SvBaseLink const * 
pLink )
         case SvBaseLinkObjectType::ClientOle:
             return new SvFileObject;
         case SvBaseLinkObjectType::Internal:
+            
if(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+                return SvLinkSourceRef();
             return new SvxInternalLink;
         case SvBaseLinkObjectType::ClientDde:
+            if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+                return SvLinkSourceRef();
             return new SvDDEObject;
         default:
             return SvLinkSourceRef();
diff --git a/sfx2/source/appl/lnkbase2.cxx b/sfx2/source/appl/lnkbase2.cxx
index 7fd3b3d530d5..eea1751cd57e 100644
--- a/sfx2/source/appl/lnkbase2.cxx
+++ b/sfx2/source/appl/lnkbase2.cxx
@@ -33,6 +33,7 @@
 #include <tools/debug.hxx>
 #include <svl/svdde.hxx>
 #include <osl/diagnose.h>
+#include <officecfg/Office/Common.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -301,6 +302,9 @@ void SvBaseLink::clearStreamToLoadFrom()
 
 bool SvBaseLink::Update()
 {
+    
if(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+        return false;
+
     if( isClientType(mnObjType) )
     {
         AddNextRef();
diff --git a/svl/source/svdde/ddecli.cxx b/svl/source/svdde/ddecli.cxx
index 7ad4c1e097b3..835bdf2269c6 100644
--- a/svl/source/svdde/ddecli.cxx
+++ b/svl/source/svdde/ddecli.cxx
@@ -22,6 +22,7 @@
 #include <algorithm>
 #include "ddeimp.hxx"
 #include <svl/svdde.hxx>
+#include <officecfg/Office/Common.hxx>
 #include <osl/thread.h>
 #include <comphelper/solarmutex.hxx>
 
@@ -150,12 +151,16 @@ DdeConnection::DdeConnection( const OUString& rService, 
const OUString& rTopic )
     pInst->nInstanceCli++;
     if ( !pInst->hDdeInstCli )
     {
-        pImp->nStatus = DdeInitializeW( &pInst->hDdeInstCli,
-                                        DdeInternal::CliCallback,
-                                        APPCLASS_STANDARD | APPCMD_CLIENTONLY |
-                                        CBF_FAIL_ALLSVRXACTIONS |
-                                        CBF_SKIP_REGISTRATIONS  |
-                                        CBF_SKIP_UNREGISTRATIONS, 0L );
+        pImp->nStatus = DMLERR_SYS_ERROR;
+        if ( 
!officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() )
+        {
+            pImp->nStatus = DdeInitializeW( &pInst->hDdeInstCli,
+                                            DdeInternal::CliCallback,
+                                            APPCLASS_STANDARD | 
APPCMD_CLIENTONLY |
+                                            CBF_FAIL_ALLSVRXACTIONS |
+                                            CBF_SKIP_REGISTRATIONS  |
+                                            CBF_SKIP_UNREGISTRATIONS, 0L );
+        }
     }
 
     pService = new DdeString( pInst->hDdeInstCli, rService );
diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx
index 327fb9a8f5d3..3df8b5a570a5 100644
--- a/svl/source/svdde/ddesvr.cxx
+++ b/svl/source/svdde/ddesvr.cxx
@@ -26,6 +26,7 @@
 #include <osl/thread.h>
 #include <o3tl/sorted_vector.hxx>
 #include <o3tl/char16_t2wchar_t.hxx>
+#include <officecfg/Office/Common.hxx>
 
 namespace {
 
@@ -354,12 +355,16 @@ DdeService::DdeService( const OUString& rService )
 
     if ( !pInst->hDdeInstSvr )
     {
-        nStatus = sal::static_int_cast< short >(
-            DdeInitializeW( &pInst->hDdeInstSvr,
-                            DdeInternal::SvrCallback,
-                            APPCLASS_STANDARD |
-                            CBF_SKIP_REGISTRATIONS |
-                            CBF_SKIP_UNREGISTRATIONS, 0 ) );
+        nStatus = DMLERR_SYS_ERROR;
+        if ( 
!officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() )
+        {
+            nStatus = sal::static_int_cast< short >(
+                DdeInitializeW( &pInst->hDdeInstSvr,
+                                DdeInternal::SvrCallback,
+                                APPCLASS_STANDARD |
+                                CBF_SKIP_REGISTRATIONS |
+                                CBF_SKIP_UNREGISTRATIONS, 0 ) );
+        }
         pInst->pServicesSvr = new DdeServices;
     }
     else
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index e812abb5d543..9e3e7317bf9d 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -1395,6 +1395,8 @@ bool SwDocShell::DdeSetData( const OUString& rItem, const 
OUString& /*rMimeType*
 
 ::sfx2::SvLinkSource* SwDocShell::DdeCreateLinkSource( const OUString& rItem )
 {
+    
if(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+        return nullptr;
     return m_xDoc->getIDocumentLinksAdministration().CreateLinkSource( rItem );
 }
 

Reply via email to