summaryrefslogtreecommitdiff
path: root/embeddedobj/source/msole/xdialogcreator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'embeddedobj/source/msole/xdialogcreator.cxx')
-rw-r--r--embeddedobj/source/msole/xdialogcreator.cxx68
1 files changed, 38 insertions, 30 deletions
diff --git a/embeddedobj/source/msole/xdialogcreator.cxx b/embeddedobj/source/msole/xdialogcreator.cxx
index 2d162cf9608e..74b267eca22f 100644
--- a/embeddedobj/source/msole/xdialogcreator.cxx
+++ b/embeddedobj/source/msole/xdialogcreator.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/datatransfer/DataFlavor.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/ucb/CommandAbortedException.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
#include <osl/thread.h>
#include <osl/file.hxx>
@@ -38,8 +39,10 @@
#include "platform.h"
#include <comphelper/mimeconfighelper.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
+#include <comphelper/sequenceashashmap.hxx>
#include "xdialogcreator.hxx"
#include <oleembobj.hxx>
@@ -48,6 +51,7 @@
#ifdef _WIN32
#include <oledlg.h>
+#include <o3tl/char16_t2wchar_t.hxx>
#include <vcl/winscheduler.hxx>
namespace {
@@ -137,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<OleUIInsertObjectA_Type *>(
- 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(&io);
+ UINT uTemp = OleUIInsertObjectW(&io);
if ( OLEUI_OK != uTemp )
throw ucb::CommandAbortedException();
@@ -193,15 +184,13 @@ 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();
- uno::Sequence< beans::PropertyValue > aMediaDescr( 1 );
- aMediaDescr[0].Name = "URL";
- aMediaDescr[0].Value <<= aFileURL;
+ uno::Sequence< beans::PropertyValue > aMediaDescr{ comphelper::makePropertyValue("URL",
+ aFileURL) };
// TODO: use config helper for type detection
uno::Reference< embed::XEmbeddedObjectCreator > xEmbCreator;
@@ -215,8 +204,31 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia
if ( !xEmbCreator.is() )
throw uno::RuntimeException();
+ uno::Reference<task::XStatusIndicator> xProgress;
+ OUString aProgressText;
+ comphelper::SequenceAsHashMap aMap(aInObjArgs);
+ auto it = aMap.find("StatusIndicator");
+ if (it != aMap.end())
+ {
+ it->second >>= xProgress;
+ }
+ it = aMap.find("StatusIndicatorText");
+ if (it != aMap.end())
+ {
+ it->second >>= aProgressText;
+ }
+ if (xProgress.is())
+ {
+ xProgress->start(aProgressText, 100);
+ }
+
aObjectInfo.Object.set( xEmbCreator->createInstanceInitFromMediaDescriptor( xStorage, sEntName, aMediaDescr, aObjArgs ),
uno::UNO_QUERY );
+
+ if (xProgress.is())
+ {
+ xProgress->end();
+ }
}
if ( ( io.dwFlags & IOF_CHECKDISPLAYASICON) && io.hMetaPict != nullptr )
@@ -241,11 +253,8 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia
"Image WMF",
cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
- aObjectInfo.Options.realloc( 2 );
- aObjectInfo.Options[0].Name = "Icon";
- aObjectInfo.Options[0].Value <<= aMetafile;
- aObjectInfo.Options[1].Name = "IconFormat";
- aObjectInfo.Options[1].Value <<= aFlavor;
+ aObjectInfo.Options = { { "Icon", css::uno::Any(aMetafile) },
+ { "IconFormat", css::uno::Any(aFlavor) } };
}
GlobalUnlock( io.hMetaPict );
@@ -282,8 +291,7 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceInitF
2 );
uno::Reference< embed::XEmbeddedObject > xResult(
- static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xContext ) ),
- uno::UNO_QUERY );
+ new OleEmbeddedObject( m_xContext ) );
uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
xPersist->setPersistentEntry( xStorage,
@@ -329,7 +337,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
embeddedobj_MSOLEDialogObjectCreator_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
- return cppu::acquire(static_cast<cppu::OWeakObject*>(new MSOLEDialogObjectCreator(context)));
+ return cppu::acquire(new MSOLEDialogObjectCreator(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */