21#include <com/sun/star/embed/EmbedStates.hpp>
22#include <com/sun/star/embed/EmbedVerbs.hpp>
23#include <com/sun/star/embed/XStorage.hpp>
24#include <com/sun/star/embed/EmbedUpdateModes.hpp>
25#include <com/sun/star/embed/XInplaceClient.hpp>
26#include <com/sun/star/lang/DisposedException.hpp>
27#include <com/sun/star/lang/NoSupportException.hpp>
28#include <com/sun/star/beans/NamedValue.hpp>
30#include <com/sun/star/ucb/SimpleFileAccess.hpp>
31#include <com/sun/star/io/TempFile.hpp>
42#include <osl/file.hxx>
58 const uno::Sequence< beans::NamedValue >& aObjProps )
64, m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE )
67, m_bEmbeddedScriptSupport( true )
68, m_bDocumentRecoverySupport( true )
69, m_bWaitSaveCompleted( false )
70, m_bIsLinkURL( false )
71, m_bLinkTempFileChanged( false )
73, m_bOleUpdate( false )
74, m_bInHndFunc( false )
75, m_bLinkHasPassword( false )
77, m_bHasClonedSize( false )
78, m_nClonedMapUnit( 0 )
80 CommonInit_Impl( aObjProps );
85 uno::Reference< uno::XComponentContext > xContext,
86 const uno::Sequence< beans::NamedValue >& aObjProps,
87 const uno::Sequence< beans::PropertyValue >& aMediaDescr,
88 const uno::Sequence< beans::PropertyValue >& aObjectDescr )
92, m_nObjectState( embed::EmbedStates::LOADED )
94, m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE )
97, m_bEmbeddedScriptSupport( true )
98, m_bDocumentRecoverySupport( true )
99, m_bWaitSaveCompleted( false )
100, m_bIsLinkURL( true )
101, m_bLinkTempFileChanged( false )
103, m_bOleUpdate( false )
104, m_bInHndFunc( false )
105, m_bLinkHasPassword( false )
107, m_bHasClonedSize( false )
108, m_nClonedMapUnit( 0 )
111 LinkInit_Impl( aObjProps, aMediaDescr, aObjectDescr );
117 OSL_ENSURE(
m_xContext.is(),
"No ServiceFactory is provided!" );
119 throw uno::RuntimeException();
125 for ( beans::NamedValue
const & prop : aObjectProps )
127 if ( prop.Name ==
"ClassID" )
129 else if ( prop.Name ==
"ObjectDocumentServiceName" )
131 else if ( prop.Name ==
"ObjectDocumentFilterName" )
133 else if ( prop.Name ==
"ObjectMiscStatus" )
135 else if ( prop.Name ==
"ObjectVerbs" )
140 throw uno::RuntimeException();
145 if ( verb.VerbID == embed::EmbedVerbs::MS_OLEVERB_PRIMARY )
147 m_aVerbTable.insert( { verb.VerbID, embed::EmbedStates::UI_ACTIVE } );
149 else if ( verb.VerbID == embed::EmbedVerbs::MS_OLEVERB_SHOW )
151 m_aVerbTable.insert( { verb.VerbID, embed::EmbedStates::UI_ACTIVE } );
153 else if ( verb.VerbID == embed::EmbedVerbs::MS_OLEVERB_OPEN )
155 m_aVerbTable.insert( { verb.VerbID, embed::EmbedStates::ACTIVE } );
157 else if ( verb.VerbID == embed::EmbedVerbs::MS_OLEVERB_IPACTIVATE )
159 m_aVerbTable.insert( { verb.VerbID, embed::EmbedStates::INPLACE_ACTIVE } );
161 else if ( verb.VerbID == embed::EmbedVerbs::MS_OLEVERB_UIACTIVATE )
163 m_aVerbTable.insert( { verb.VerbID, embed::EmbedStates::UI_ACTIVE } );
165 else if ( verb.VerbID == embed::EmbedVerbs::MS_OLEVERB_HIDE )
167 m_aVerbTable.insert( { verb.VerbID, embed::EmbedStates::RUNNING } );
174 const uno::Sequence< beans::NamedValue >& aObjectProps,
175 const uno::Sequence< beans::PropertyValue >& aMediaDescr,
176 const uno::Sequence< beans::PropertyValue >& aObjectDescr )
180 for ( beans::PropertyValue
const & prop : aMediaDescr )
181 if ( prop.Name ==
"URL" )
183 else if ( prop.Name ==
"FilterName" )
218 uno::Sequence< beans::PropertyValue > aAlternativeMediaDescr(aMediaDescr.getLength());
219 auto aAlternativeMediaDescrRange = asNonConstRange(aAlternativeMediaDescr);
221 for ( sal_Int32
a(0);
a < aMediaDescr.getLength();
a++ )
223 const beans::PropertyValue& rSource(aMediaDescr[
a]);
224 beans::PropertyValue& rDestination(aAlternativeMediaDescrRange[
a]);
226 rDestination.Name = rSource.Name;
227 if(rSource.Name ==
"URL")
230 rDestination.Value = rSource.Value;
240 uno::Reference< frame::XDispatchProviderInterceptor > xDispatchInterceptor;
241 for ( beans::PropertyValue
const & prop : aObjectDescr )
242 if ( prop.Name ==
"OutplaceDispatchInterceptor" )
244 prop.Value >>= xDispatchInterceptor;
247 else if ( prop.Name ==
"Parent" )
254 if ( xDispatchInterceptor.is() )
255 m_xDocHolder->SetOutplaceDispatchInterceptor( xDispatchInterceptor );
270 }
catch(
const uno::Exception& ) {}
280 }
catch (
const uno::Exception& ) {}
285 }
catch(
const uno::Exception& ) {}
293 OSL_ENSURE(
m_xClientSite.is(),
"The client site must be set for inplace active object!" );
297 uno::Reference< embed::XInplaceClient > xInplaceClient(
m_xClientSite, uno::UNO_QUERY );
299 OSL_ENSURE( xInplaceClient.is(),
"The client site must support XInplaceClient to allow inplace activation!" );
300 if ( xInplaceClient.is() )
303 xInplaceClient->changedPlacement( aRect );
305 catch(
const uno::Exception& )
323 document::EventObject
aEvent;
324 aEvent.EventName = aEventName;
334 static_cast<document::XEventListener *
>(aIt.
next())->notifyEvent(
aEvent );
336 catch(
const uno::RuntimeException& )
353 OUString aTemp = sFileName;
355 osl::FileBase::getSystemPathFromFileURL( sFileName, aTemp );
357 aMsg = aMsg.replaceFirst(
"%{filename}", aTemp );
361 VclMessageType::Warning, VclButtonsType::NONE, aMsg ) );
362 xQueryBox->add_button( aBtn,
RET_YES );
364 xQueryBox->set_default_response(
RET_CANCEL );
366 return xQueryBox->run();
379 bool bLnkFileChg =
m_pLinkFile->hasFileChanged(
false );
408 auto writeFile = [ this ](
const OUString& SrcName,
const OUString& DesName )
410 uno::Reference < ucb::XSimpleFileAccess2 > xWriteAccess( ucb::SimpleFileAccess::create(
m_xContext ) );
411 uno::Reference < ucb::XSimpleFileAccess > xReadAccess( ucb::SimpleFileAccess::create(
m_xContext ) );
415 uno::Reference < io::XInputStream > xInStream( xReadAccess->openFileRead (SrcName ) );
420 uno::Reference < io::XSeekable > xSeek( xInStream, uno::UNO_QUERY_THROW );
423 xWriteAccess->writeFile( DesName, xInStream );
428 catch (
const uno::Exception&
ex )
431 osl::FileBase::getSystemPathFromFileURL( SrcName, aMsg );
432 aMsg =
ex.Message +
"\n\n" + aMsg;
435 VclMessageType::Error, VclButtonsType::Ok, aMsg ) );
471 void *
p =
static_cast< embed::XEmbeddedObject *
>( this );
476 void*
p =
static_cast<embed::XEmbedPersist2*
>(
this);
481 void*
p =
static_cast<lang::XServiceInfo*
>(
this);
486 void*
p =
static_cast<lang::XInitialization*
>(
this);
491 void*
p =
static_cast<lang::XTypeProvider*
>(
this);
495 aReturn = ::cppu::queryInterface(
497 static_cast< embed::XInplaceObject*
>(
this ),
498 static_cast< embed::XVisualObject*
>(
this ),
499 static_cast< embed::XCommonEmbedPersist*
>(
static_cast< embed::XEmbedPersist*
>(
this ) ),
500 static_cast< embed::XEmbedPersist*
>(
this ),
501 static_cast< embed::XLinkageSupport*
>(
this ),
502 static_cast< embed::XStateChangeBroadcaster*
>(
this ),
503 static_cast< embed::XClassifiedObject*
>(
this ),
504 static_cast< embed::XComponentSupplier*
>(
this ),
505 static_cast< util::XCloseable*
>(
this ),
506 static_cast< container::XChild*
>(
this ),
507 static_cast< chart2::XDefaultSizeTransmitter*
>(
this ),
508 static_cast< document::XEventBroadcaster*
>(
this ) );
513 return ::cppu::OWeakObject::queryInterface( rType ) ;
535 throw lang::DisposedException();
543 throw lang::DisposedException();
549 const uno::Sequence< sal_Int8 >& ,
const OUString& )
552 throw lang::NoSupportException();
560 throw lang::DisposedException();
566 throw uno::RuntimeException(
"Can't store object without persistence!",
578 throw lang::DisposedException();
589 const uno::Reference< embed::XStateChangeListener >& xListener )
602 throw lang::DisposedException();
604 uno::Reference< uno::XInterface > xSelfHold(
static_cast< ::
cppu::OWeakObject*
>(
this ) );
611 if ( pContainer !=
nullptr )
618 static_cast<util::XCloseListener*
>(pIterator.
next())->queryClosing( aSource, bDeliverOwnership );
620 catch(
const uno::RuntimeException& )
629 if ( pContainer !=
nullptr )
636 static_cast<util::XCloseListener*
>(pCloseIterator.
next())->notifyClosing( aSource );
638 catch(
const uno::RuntimeException& )
660 m_xDocHolder->CloseDocument( bDeliverOwnership, bDeliverOwnership );
662 catch(
const uno::Exception& )
664 if ( bDeliverOwnership )
684 }
catch (
const uno::Exception& ) {}
698 throw lang::DisposedException();
720 throw lang::DisposedException();
739 return "com.sun.star.comp.embed.OCommonEmbeddedObject";
749 return {
"com.sun.star.comp.embed.OCommonEmbeddedObject" };
754 static const uno::Sequence<uno::Type>
aTypes{
770 return uno::Sequence<sal_Int8>();
775 if (!rArguments.hasElements())
781 auto it =
aMap.find(
"ReadOnly");
782 if (it !=
aMap.end())
Reference< XComponentContext > m_xContext
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString m_aDocServiceName
std::map< sal_Int32, sal_Int32 > m_aVerbTable
css::uno::Sequence< css::beans::PropertyValue > m_aDocMediaDescriptor
virtual css::uno::Reference< css::util::XCloseable > SAL_CALL getComponent() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::document::XEventListener > &Listener) override
virtual void SAL_CALL addCloseListener(const css::uno::Reference< css::util::XCloseListener > &Listener) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getClassID() override
OUString m_aLinkFilterName
std::unique_ptr<::comphelper::OMultiTypeInterfaceContainerHelper2 > m_pInterfaceContainer
virtual void SAL_CALL release() noexcept override
css::uno::Reference< css::uno::XInterface > m_xParent
void PostEvent_Impl(const OUString &aEventName)
OCommonEmbeddedObject(css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Sequence< css::beans::NamedValue > &aObjectProps)
css::uno::Reference< css::embed::XStorage > m_xRecoveryStorage
css::uno::Sequence< css::embed::VerbDescriptor > m_aObjectVerbs
css::uno::Reference< css::awt::XWindow > m_xClientWindow
css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
void requestPositioning(const css::awt::Rectangle &aRect)
int ShowMsgDialog(TranslateId Msg, const OUString &sFileName)
virtual void SAL_CALL setClassInfo(const css::uno::Sequence< sal_Int8 > &aClassID, const OUString &aClassName) override
void LinkInit_Impl(const css::uno::Sequence< css::beans::NamedValue > &aObjectProps, const css::uno::Sequence< css::beans::PropertyValue > &aMediaDescr, const css::uno::Sequence< css::beans::PropertyValue > &aObjectDescr)
css::uno::Reference< css::io::XTempFile > m_aLinkTempFile
virtual void SAL_CALL removeStateChangeListener(const css::uno::Reference< css::embed::XStateChangeListener > &xListener) override
virtual ~OCommonEmbeddedObject() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::document::XEventListener > &Listener) override
css::uno::Sequence< sal_Int8 > m_aClassID
bool m_bLinkTempFileChanged
virtual OUString SAL_CALL getClassName() override
OUString SAL_CALL getImplementationName() override
rtl::Reference< DocumentHolder > m_xDocHolder
virtual void SAL_CALL close(sal_Bool DeliverOwnership) override
::std::unique_ptr< FileChangedChecker > m_pLinkFile
void handleLinkedOLE(CopyBackToOLELink eState)
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::embed::XEmbeddedClient > m_xClientSite
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
OUString m_aPresetFilterName
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
void CommonInit_Impl(const css::uno::Sequence< css::beans::NamedValue > &aObjectProps)
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL removeCloseListener(const css::uno::Reference< css::util::XCloseListener > &Listener) override
virtual void SAL_CALL addStateChangeListener(const css::uno::Reference< css::embed::XStateChangeListener > &xListener) override
void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
css::uno::Reference< css::embed::XStorage > m_xObjectStorage
static bool fileExists(const OUString &rBaseURL)
css::uno::XInterface * next()
bool hasMoreElements() const
oslInterlockedCount m_refCount
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
css::uno::Type const & get()
#define TOOLS_WARN_EXCEPTION(area, stream)
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
OUString get(TranslateId sContextAndId, const std::locale &loc)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
HashMap_OWString_Interface aMap
uno::Sequence< beans::PropertyValue > GetValuableArgs_Impl(const uno::Sequence< beans::PropertyValue > &aMedDescr, bool bCanUseDocumentBaseURL)
OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton)