core.git: embeddedobj/Library_emboleobj.mk embeddedobj/source

2024-02-25 Thread Mike Kaganski (via logerrit)
 embeddedobj/Library_emboleobj.mk|1 +
 embeddedobj/source/msole/xdialogcreator.cxx |   25 ++---
 2 files changed, 7 insertions(+), 19 deletions(-)

New commits:
commit 74185b8edf7f046a3372319da86a1d8ca0024c87
Author: Mike Kaganski 
AuthorDate: Sun Feb 25 19:28:24 2024 +0600
Commit: Mike Kaganski 
CommitDate: Mon Feb 26 04:18:07 2024 +0100

Link to oledlg, and use OleUIInsertObjectW directly

... instead of manually loading and using OleUIInsertObjectA.

Change-Id: I597dd44e13edf8c94d83f434b57142c88e5aca6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163922
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/embeddedobj/Library_emboleobj.mk b/embeddedobj/Library_emboleobj.mk
index d92f86f2c7d3..661bd655358b 100644
--- a/embeddedobj/Library_emboleobj.mk
+++ b/embeddedobj/Library_emboleobj.mk
@@ -55,6 +55,7 @@ $(eval $(call gb_Library_use_system_win32_libs,emboleobj,\
gdi32 \
ole32 \
oleaut32 \
+   oledlg \
uuid \
 ))
 
diff --git a/embeddedobj/source/msole/xdialogcreator.cxx 
b/embeddedobj/source/msole/xdialogcreator.cxx
index 7e4e99156291..74b267eca22f 100644
--- a/embeddedobj/source/msole/xdialogcreator.cxx
+++ b/embeddedobj/source/msole/xdialogcreator.cxx
@@ -51,6 +51,7 @@
 #ifdef _WIN32
 
 #include 
+#include 
 #include 
 
 namespace {
@@ -140,34 +141,21 @@ embed::InsertedObjectInfo SAL_CALL 
MSOLEDialogObjectCreator::createInstanceByDia
 
 InitializedOleGuard aGuard;
 
-OLEUIINSERTOBJECT io = {};
-char szFile[MAX_PATH];
-UINT uTemp;
-
-io.cbStruct = sizeof(io);
+OLEUIINSERTOBJECTW io{ sizeof(io) };
 io.hWndOwner = GetActiveWindow();
 
+wchar_t szFile[MAX_PATH];
 szFile[0] = 0;
 io.lpszFile = szFile;
-io.cchFile = MAX_PATH;
+io.cchFile = std::size(szFile);
 
 io.dwFlags = IOF_SELECTCREATENEW | IOF_DISABLELINK;
 
-
-::osl::Module aOleDlgLib;
-if( !aOleDlgLib.load( "oledlg" ))
-throw uno::RuntimeException();
-
-OleUIInsertObjectA_Type * pInsertFct = 
reinterpret_cast(
-aOleDlgLib.getSymbol( "OleUIInsertObjectA" ));
-if( !pInsertFct )
-throw uno::RuntimeException();
-
 // Disable any event loop shortcuts by enabling a real timer.
 // This way the native windows dialog won't block our own processing.
 WinScheduler::SetForceRealTimer();
 
-uTemp=pInsertFct();
+UINT uTemp = OleUIInsertObjectW();
 
 if ( OLEUI_OK != uTemp )
 throw ucb::CommandAbortedException();
@@ -196,8 +184,7 @@ embed::InsertedObjectInfo SAL_CALL 
MSOLEDialogObjectCreator::createInstanceByDia
 }
 else
 {
-OUString aFileName
-= OStringToOUString( std::string_view( szFile ), 
osl_getThreadTextEncoding() );
+OUString aFileName(o3tl::toU(szFile));
 OUString aFileURL;
 if ( osl::FileBase::getFileURLFromSystemPath( aFileName, aFileURL ) != 
osl::FileBase::E_None )
 throw uno::RuntimeException();


core.git: embeddedobj/Library_emboleobj.mk embeddedobj/source

2023-12-20 Thread Sarper Akdemir (via logerrit)
 embeddedobj/Library_emboleobj.mk|4 
 embeddedobj/source/commonembedding/xfactory.cxx |   16 
 embeddedobj/source/msole/xolefactory.cxx|   13 +
 3 files changed, 33 insertions(+)

New commits:
commit 75df80e34efcd2d39a49ec91654480e156bcec1f
Author: Sarper Akdemir 
AuthorDate: Mon Dec 18 16:23:27 2023 +0300
Commit: Sarper Akdemir 
CommitDate: Wed Dec 20 20:15:02 2023 +0100

tdf#158375: further disable embedded objects

there was the possibility of constructing an OOoEmbeddedObjectFactory
or OleEmbeddedObjectFactory directly instead of
UNOEmbeddedObjectCreator.

So disable all createInstance calls for them too. Securing there won't
be active embedded objects.

Change-Id: Ib47ad920d4951790c12d1a8587505cab2f1e126d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160921
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/embeddedobj/Library_emboleobj.mk b/embeddedobj/Library_emboleobj.mk
index b7fde953c466..d92f86f2c7d3 100644
--- a/embeddedobj/Library_emboleobj.mk
+++ b/embeddedobj/Library_emboleobj.mk
@@ -10,6 +10,10 @@
 
 $(eval $(call gb_Library_Library,emboleobj))
 
+$(eval $(call gb_Library_use_custom_headers,emboleobj,\
+   officecfg/registry \
+))
+
 $(eval $(call 
gb_Library_set_componentfile,emboleobj,embeddedobj/source/msole/emboleobj$(if 
$(filter WNT,$(OS)),.windows),services))
 
 $(eval $(call gb_Library_set_include,emboleobj,\
diff --git a/embeddedobj/source/commonembedding/xfactory.cxx 
b/embeddedobj/source/commonembedding/xfactory.cxx
index c6f57aa9c643..1460b31fd54b 100644
--- a/embeddedobj/source/commonembedding/xfactory.cxx
+++ b/embeddedobj/source/commonembedding/xfactory.cxx
@@ -23,9 +23,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #include "xfactory.hxx"
 #include 
@@ -41,6 +43,8 @@ uno::Reference< uno::XInterface > SAL_CALL 
OOoEmbeddedObjectFactory::createInsta
 const 
uno::Sequence< beans::PropertyValue >& aMediaDescr,
 const 
uno::Sequence< beans::PropertyValue >& lObjArgs )
 {
+if ( 
officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() )
+throw lang::NoSupportException("Active embedded content is disabled!");
 if ( !xStorage.is() )
 throw lang::IllegalArgumentException( "No parent storage is provided!",
 static_cast< ::cppu::OWeakObject* 
>(this),
@@ -118,6 +122,8 @@ uno::Reference< uno::XInterface > SAL_CALL 
OOoEmbeddedObjectFactory::createInsta
 const uno::Sequence< beans::PropertyValue >& aMediaDescr,
 const uno::Sequence< beans::PropertyValue >& lObjArgs )
 {
+if ( 
officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() )
+throw lang::NoSupportException("Active embedded content is disabled!");
 if ( !xStorage.is() )
 throw lang::IllegalArgumentException( "No parent storage is provided!",
 static_cast< ::cppu::OWeakObject* 
>(this),
@@ -169,6 +175,8 @@ uno::Reference< uno::XInterface > SAL_CALL 
OOoEmbeddedObjectFactory::createInsta
 const OUString& sEntName,
 const uno::Sequence< 
beans::PropertyValue >& lObjArgs )
 {
+if ( 
officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() )
+throw lang::NoSupportException("Active embedded content is disabled!");
 uno::Reference< uno::XInterface > xResult;
 
 if ( !xStorage.is() )
@@ -212,6 +220,8 @@ uno::Reference< uno::XInterface > SAL_CALL 
OOoEmbeddedObjectFactory::createInsta
 const uno::Sequence< beans::PropertyValue >& lObjArgs )
 {
 // the initialization is completely controlled by user
+if ( 
officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() )
+throw lang::NoSupportException("Active embedded content is disabled!");
 if ( !xStorage.is() )
 throw lang::IllegalArgumentException( "No parent storage is provided!",
 uno::Reference< uno::XInterface >( 
static_cast< ::cppu::OWeakObject* >(this) ),
@@ -257,6 +267,8 @@ uno::Reference< uno::XInterface > SAL_CALL 
OOoEmbeddedObjectFactory::createInsta
 const uno::Sequence< 
beans::PropertyValue >& aMediaDescr,
 const uno::Sequence< 
beans::PropertyValue >& lObjArgs )
 {
+if ( 
officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() )
+throw lang::NoSupportException("Active embedded content is disabled!");
 uno::Reference< uno::XInterface > xResult;
 
 uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );

[Libreoffice-commits] core.git: embeddedobj/Library_emboleobj.mk embeddedobj/source include/vcl vcl/Library_vcl.mk vcl/source

2018-12-13 Thread Libreoffice Gerrit user
 embeddedobj/Library_emboleobj.mk|1 
 embeddedobj/source/msole/xdialogcreator.cxx |8 +
 include/vcl/winscheduler.hxx|   39 
 vcl/Library_vcl.mk  |1 
 vcl/source/app/winscheduler.cxx |   37 ++
 5 files changed, 79 insertions(+), 7 deletions(-)

New commits:
commit 7b148b0edfb217196c171f8e64e79b49669fc36f
Author: Jan-Marek Glogowski 
AuthorDate: Thu Dec 13 11:50:41 2018 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Thu Dec 13 16:33:58 2018 +0100

WIN move native dialog hack into WinScheduler

The "hides" the hack for native Windows dialogs introduced in
commit 5bb798a99e7b ("tdf#117295 WIN no main loop shortcut for
OLE dialog") in its own header.

Change-Id: I1f36aad20dec50ae1f296001b51085989afb19f6
Reviewed-on: https://gerrit.libreoffice.org/65100
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/embeddedobj/Library_emboleobj.mk b/embeddedobj/Library_emboleobj.mk
index 3bfbec56d89d..9e3c1b5950d2 100644
--- a/embeddedobj/Library_emboleobj.mk
+++ b/embeddedobj/Library_emboleobj.mk
@@ -14,7 +14,6 @@ $(eval $(call 
gb_Library_set_componentfile,emboleobj,embeddedobj/source/msole/em
 
 $(eval $(call gb_Library_set_include,emboleobj,\
-I$(SRCDIR)/embeddedobj/source/inc \
-   $(if $(filter WNT,$(OS)),-I$(SRCDIR)/vcl/inc) \
$$(INCLUDE) \
 ))
 
diff --git a/embeddedobj/source/msole/xdialogcreator.cxx 
b/embeddedobj/source/msole/xdialogcreator.cxx
index be26a300d298..836f198eb867 100644
--- a/embeddedobj/source/msole/xdialogcreator.cxx
+++ b/embeddedobj/source/msole/xdialogcreator.cxx
@@ -43,10 +43,7 @@
 #ifdef _WIN32
 
 #include 
-
-#include 
-#include 
-#include 
+#include 
 
 class InitializedOleGuard
 {
@@ -180,8 +177,7 @@ embed::InsertedObjectInfo SAL_CALL 
MSOLEDialogObjectCreator::createInstanceByDia
 
 // Disable any event loop shortcuts by enabling a real timer.
 // This way the native windows dialog won't block our own processing.
-BOOL const ret = PostMessageW(GetSalData()->mpInstance->mhComWnd, 
SAL_MSG_FORCE_REAL_TIMER, 0, 0);
-SAL_WARN_IF(0 == ret, "embeddedobj.ole", "ERROR: PostMessage() failed!");
+WinScheduler::SetForceRealTimer();
 
 uTemp=pInsertFct();
 
diff --git a/include/vcl/winscheduler.hxx b/include/vcl/winscheduler.hxx
new file mode 100644
index ..02d86116bb38
--- /dev/null
+++ b/include/vcl/winscheduler.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_WINSCHEDULER_HXX
+#define INCLUDED_VCL_WINSCHEDULER_HXX
+
+#ifndef _WIN32
+#error This header is just useable on Windows
+#else
+
+#include 
+
+struct VCL_DLLPUBLIC WinScheduler final
+{
+/// Hack for Windows native dialogs, which run the main loop, so we can't
+/// use the direct processing shortcut.
+static void SetForceRealTimer();
+};
+
+#endif // _WIN32
+#endif // INCLUDED_VCL_WINSCHEDULER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 4bd1469a6d34..da9bc387ca2f 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -380,6 +380,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/app/unohelp2 \
 vcl/source/app/unohelp \
 vcl/source/app/vclevent \
+vcl/source/app/winscheduler \
 vcl/source/components/dtranscomp \
 vcl/source/components/factory \
 vcl/source/components/fontident \
diff --git a/vcl/source/app/winscheduler.cxx b/vcl/source/app/winscheduler.cxx
new file mode 100644
index ..f8a90f3f638d
--- /dev/null
+++ b/vcl/source/app/winscheduler.cxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the 

[Libreoffice-commits] core.git: embeddedobj/Library_emboleobj.mk embeddedobj/source vcl/inc vcl/win

2018-12-12 Thread Libreoffice Gerrit user
 embeddedobj/Library_emboleobj.mk|1 +
 embeddedobj/source/msole/xdialogcreator.cxx |9 +
 vcl/inc/win/saldata.hxx |2 ++
 vcl/win/app/salinst.cxx |5 +
 4 files changed, 17 insertions(+)

New commits:
commit 5bb798a99e7b178ac57ee8c15238534723000bf9
Author: Jan-Marek Glogowski 
AuthorDate: Wed Dec 12 16:11:35 2018 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Wed Dec 12 23:10:56 2018 +0100

tdf#117295 WIN no main loop shortcut for OLE dialog

Normally we handle Idle events directly without posting events
to the main event queue, as there seem to be no way to post them
to the end of the queue and this starves system events.

This prevents using this short-cut, as the default Windows event
processing doesn't know of this special handling.
Eventually this hack should be removed by simply always processing
all pending events...

Change-Id: If9ae81ca7e847743f9251343e106dbf566371584
Reviewed-on: https://gerrit.libreoffice.org/65040
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/embeddedobj/Library_emboleobj.mk b/embeddedobj/Library_emboleobj.mk
index 9e3c1b5950d2..3bfbec56d89d 100644
--- a/embeddedobj/Library_emboleobj.mk
+++ b/embeddedobj/Library_emboleobj.mk
@@ -14,6 +14,7 @@ $(eval $(call 
gb_Library_set_componentfile,emboleobj,embeddedobj/source/msole/em
 
 $(eval $(call gb_Library_set_include,emboleobj,\
-I$(SRCDIR)/embeddedobj/source/inc \
+   $(if $(filter WNT,$(OS)),-I$(SRCDIR)/vcl/inc) \
$$(INCLUDE) \
 ))
 
diff --git a/embeddedobj/source/msole/xdialogcreator.cxx 
b/embeddedobj/source/msole/xdialogcreator.cxx
index f94020a65a8f..be26a300d298 100644
--- a/embeddedobj/source/msole/xdialogcreator.cxx
+++ b/embeddedobj/source/msole/xdialogcreator.cxx
@@ -44,6 +44,10 @@
 
 #include 
 
+#include 
+#include 
+#include 
+
 class InitializedOleGuard
 {
 public:
@@ -174,6 +178,11 @@ embed::InsertedObjectInfo SAL_CALL 
MSOLEDialogObjectCreator::createInstanceByDia
 if( !pInsertFct )
 throw uno::RuntimeException();
 
+// Disable any event loop shortcuts by enabling a real timer.
+// This way the native windows dialog won't block our own processing.
+BOOL const ret = PostMessageW(GetSalData()->mpInstance->mhComWnd, 
SAL_MSG_FORCE_REAL_TIMER, 0, 0);
+SAL_WARN_IF(0 == ret, "embeddedobj.ole", "ERROR: PostMessage() failed!");
+
 uTemp=pInsertFct();
 
 if ( OLEUI_OK != uTemp )
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index d036ffb30a23..74be79774db5 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -269,6 +269,8 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const 
char* pStr2 );
 #define SAL_MSG_TIMER_CALLBACK  (WM_USER+162)
 // Stop the timer from the main thread; wParam = 0, lParam = 0
 #define SAL_MSG_STOPTIMER   (WM_USER+163)
+// Start a real timer while GUI is blocked by native dialog
+#define SAL_MSG_FORCE_REAL_TIMER(WM_USER+164)
 
 inline void SetWindowPtr( HWND hWnd, WinSalFrame* pThis )
 {
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 7011f8b2404b..6e0e3057ae40 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -620,6 +620,11 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM 
wParam, LPARAM lParam, b
 pTimer->ImplHandle_WM_TIMER( wParam );
 break;
 
+case SAL_MSG_FORCE_REAL_TIMER:
+assert(pTimer != nullptr);
+pTimer->SetForceRealTimer(true);
+break;
+
 case SAL_MSG_DUMMY:
 break;
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: embeddedobj/Library_emboleobj.mk embeddedobj/source

2014-04-07 Thread Miklos Vajna
 embeddedobj/Library_emboleobj.mk  |1 +
 embeddedobj/source/msole/graphconvert.cxx |   12 
 2 files changed, 13 insertions(+)

New commits:
commit 2a7fdf2a7bb7345c49c988dfd1fcdb41cebb8a1e
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Mon Apr 7 16:51:29 2014 +0200

fdo#77140 embeddedobj: avoid unneeded conversion in ConvertBufferToFormat()

The primary reason is not performance: on export currently we loose some
EMF+ properties. While it would be good to fix all those problems one by
one, this is a small fix to avoid all kind of roundtrip problems in this
situation.

Change-Id: If5e1c1eabd8290f36b538e374c9707ae17097786

diff --git a/embeddedobj/Library_emboleobj.mk b/embeddedobj/Library_emboleobj.mk
index 96f03ee..e10110b 100644
--- a/embeddedobj/Library_emboleobj.mk
+++ b/embeddedobj/Library_emboleobj.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_Library_use_libraries,emboleobj,\
sal \
tl \
utl \
+   vcl \
$(gb_UWINAPI) \
 ))
 
diff --git a/embeddedobj/source/msole/graphconvert.cxx 
b/embeddedobj/source/msole/graphconvert.cxx
index ad8e910..37aeb69 100644
--- a/embeddedobj/source/msole/graphconvert.cxx
+++ b/embeddedobj/source/msole/graphconvert.cxx
@@ -32,6 +32,7 @@
 #include comphelper/processfactory.hxx
 #include comphelper/seqstream.hxx
 #include tools/stream.hxx
+#include vcl/graphicfilter.hxx
 
 #include mtnotification.hxx
 #include oleembobj.hxx
@@ -48,6 +49,17 @@ sal_Bool ConvertBufferToFormat( void* pBuf,
 // produces sequence with data in requested format and returns it in 
aResult
 if ( pBuf )
 {
+// First, in case the buffer is already in the requested format, then 
avoid a conversion.
+SvMemoryStream aMemoryStream(pBuf, nBufSize, STREAM_READ);
+GraphicFilter rFilter = GraphicFilter::GetGraphicFilter();
+sal_uInt16 nRetFormat = 0;
+if (rFilter.CanImportGraphic(OUString(), aMemoryStream, 
GRFILTER_FORMAT_DONTKNOW, nRetFormat) == GRFILTER_OK 
+rFilter.GetImportFormatMediaType(nRetFormat) == aMimeType)
+{
+aResult = uno::Sequence sal_Int8 ( reinterpret_cast const 
sal_Int8* ( aMemoryStream.GetData() ), aMemoryStream.Seek( STREAM_SEEK_TO_END 
) );
+return sal_True;
+}
+
 uno::Sequence  sal_Int8  aData( (sal_Int8*)pBuf, nBufSize );
 uno::Reference  io::XInputStream  xIn = new 
comphelper::SequenceInputStream( aData );
 try
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits