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/source/ui/docshell/docsh4.cxx                           |    4 +++
 sc/source/ui/drawfunc/fuins2.cxx                           |   11 ++++++++
 sd/source/ui/func/fuinsert.cxx                             |   11 ++++++++
 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/wrtsh/wrtsh1.cxx                          |   12 +++++++++
 13 files changed, 85 insertions(+), 13 deletions(-)

New commits:
commit 9157d8de8d8a7a2707179f371f4e4771f41777be
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: Wed Dec 20 20:15:29 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

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 537220b79be2..1ea33be5ba77 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -2512,7 +2512,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 );
 }
 
commit 7bb50fd2398220c3b162e7242c1cc8d6c4c31463
Author:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
AuthorDate: Wed Dec 20 12:46:54 2023 +0300
Commit:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
CommitDate: Wed Dec 20 20:15:18 2023 +0100

    tdf#158375: adapt UI when embedded content is disabled via option
    
    When DisableActiveContent is set, embedded active content is
    disabled (e.g. OLE). Therefore the existing ui insertion bits don't
    function either. Disable them with a warning pop-up hinting "Active
    content is disabled."
    
    Change-Id: I14984684f22df6aff81af79d5a15589b5cae75fc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161055
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc
index 3aa1e9770d66..53cefc48d8ff 100644
--- a/include/svtools/strings.hrc
+++ b/include/svtools/strings.hrc
@@ -263,6 +263,7 @@
 #define STR_FIELD_CALENDAR                      NC_("STR_FIELD_CALENDAR", 
"Calendar")
 #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_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/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 07d076fe26d6..959424b40b87 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -32,6 +32,8 @@
 #include <unotools/moduleoptions.hxx>
 #include <svtools/insdlg.hxx>
 #include <svtools/embedhlp.hxx>
+#include <svtools/strings.hrc>
+#include <svtools/svtresid.hxx>
 #include <svx/svxdlg.hxx>
 #include <comphelper/classids.hxx>
 #include <svx/svdpagv.hxx>
@@ -57,6 +59,7 @@
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
 #include <cppuhelper/bootstrap.hxx>
 #include <svtools/dialogclosedlistener.hxx>
+#include <officecfg/Office/Common.hxx>
 
 #include <PivotTableDataProvider.hxx>
 #include <chart2uno.hxx>
@@ -252,6 +255,14 @@ FuInsertOLE::FuInsertOLE(ScTabViewShell& rViewSh, 
vcl::Window* pWin, ScDrawView*
         switch ( nSlot )
         {
             case SID_INSERT_OBJECT :
+                if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+                {
+                    std::unique_ptr<weld::MessageDialog> 
xError(Application::CreateMessageDialog(
+                        nullptr, VclMessageType::Warning, VclButtonsType::Ok,
+                        SvtResId(STR_WARNING_ACTIVE_CONTENT_DISABLED)));
+                    xError->run();
+                    break;
+                }
                 aServerLst.FillInsertObjects();
                 aServerLst.Remove( ScDocShell::Factory().GetClassId() );   // 
Do not show Starcalc
                 //TODO/LATER: currently no inserting of ClassId into 
SfxRequest!
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 5f80abc89ebd..31b286c822e3 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -42,6 +42,8 @@
 #include <sfx2/request.hxx>
 #include <svl/globalnameitem.hxx>
 #include <svtools/embedhlp.hxx>
+#include <svtools/strings.hrc>
+#include <svtools/svtresid.hxx>
 #include <svx/linkwarn.hxx>
 #include <avmedia/mediawindow.hxx>
 #include <comphelper/classids.hxx>
@@ -453,6 +455,15 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
             {
                 case SID_INSERT_OBJECT :
                 {
+                    if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+                    {
+                        std::unique_ptr<weld::MessageDialog> xError(
+                            Application::CreateMessageDialog(
+                                nullptr, VclMessageType::Warning, 
VclButtonsType::Ok,
+                                
SvtResId(STR_WARNING_ACTIVE_CONTENT_DISABLED)));
+                        xError->run();
+                        break;
+                    }
                     aServerLst.FillInsertObjects();
                     if (mpDoc->GetDocumentType() == DocumentType::Draw)
                     {
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 912283dd20fc..4b2402fc93c8 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -89,6 +89,7 @@
 #include <vcl/uitest/eventdescription.hxx>
 #include <osl/diagnose.h>
 #include <o3tl/unit_conversion.hxx>
+#include <officecfg/Office/Common.hxx>
 
 #include <PostItMgr.hxx>
 #include <FrameControlsManager.hxx>
@@ -100,6 +101,8 @@
 #include <sfx2/msgpool.hxx>
 #include <sfx2/msg.hxx>
 #include <svtools/embedhlp.hxx>
+#include <svtools/strings.hrc>
+#include <svtools/svtresid.hxx>
 #include <svx/postattr.hxx>
 #include <comphelper/lok.hxx>
 #include <comphelper/propertyvalue.hxx>
@@ -433,6 +436,15 @@ void SwWrtShell::InsertObject( const 
svt::EmbeddedObjectRef& xRef, SvGlobalName
             {
                 case SID_INSERT_OBJECT:
                 {
+                    if 
(officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
+                    {
+                        std::unique_ptr<weld::MessageDialog> xError(
+                            Application::CreateMessageDialog(
+                                nullptr, VclMessageType::Warning, 
VclButtonsType::Ok,
+                                
SvtResId(STR_WARNING_ACTIVE_CONTENT_DISABLED)));
+                        xError->run();
+                        break;
+                    }
                     aServerList.FillInsertObjects();
                     aServerList.Remove( SwDocShell::Factory().GetClassId() );
                     [[fallthrough]];

Reply via email to