2010-10-12 08:53:47 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2003-12-02 07:34:02 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 22:59:09 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-12-02 07:34:02 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2003-12-02 07:34:02 -06:00
|
|
|
*
|
2008-04-10 22:59:09 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-12-02 07:34:02 -06:00
|
|
|
*
|
2008-04-10 22:59:09 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-12-02 07:34:02 -06:00
|
|
|
*
|
2008-04-10 22:59:09 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-12-02 07:34:02 -06:00
|
|
|
*
|
2008-04-10 22:59:09 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-12-02 07:34:02 -06:00
|
|
|
*
|
2008-04-10 22:59:09 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-12-02 07:34:02 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 18:43:49 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_embeddedobj.hxx"
|
2003-12-02 07:34:02 -06:00
|
|
|
#include <com/sun/star/uno/Any.hxx>
|
|
|
|
#include <com/sun/star/uno/Reference.hxx>
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
2006-10-13 05:30:34 -05:00
|
|
|
#include <com/sun/star/embed/Aspects.hpp>
|
2009-12-10 08:12:53 -06:00
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
|
|
|
#include <com/sun/star/io/XOutputStream.hpp>
|
|
|
|
#include <com/sun/star/graphic/XGraphicProvider.hpp>
|
|
|
|
#include <com/sun/star/graphic/XGraphic.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2006-02-01 12:05:23 -06:00
|
|
|
#include <tools/link.hxx>
|
2010-10-16 03:18:35 -05:00
|
|
|
#include <osl/mutex.hxx>
|
2009-12-14 05:26:01 -06:00
|
|
|
#include <unotools/streamwrap.hxx>
|
2009-12-10 08:12:53 -06:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2009-12-14 05:26:01 -06:00
|
|
|
#include <comphelper/seqstream.hxx>
|
|
|
|
#include <tools/stream.hxx>
|
2009-12-10 08:12:53 -06:00
|
|
|
|
|
|
|
#include "mtnotification.hxx"
|
|
|
|
#include "oleembobj.hxx"
|
2006-02-01 12:05:23 -06:00
|
|
|
|
|
|
|
|
2003-12-02 07:34:02 -06:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
|
2003-12-12 05:50:52 -06:00
|
|
|
sal_Bool ConvertBufferToFormat( void* pBuf,
|
|
|
|
sal_uInt32 nBufSize,
|
2009-12-10 08:12:53 -06:00
|
|
|
const ::rtl::OUString& aMimeType,
|
2003-12-12 05:50:52 -06:00
|
|
|
uno::Any& aResult )
|
2003-12-02 07:34:02 -06:00
|
|
|
{
|
2003-12-12 05:50:52 -06:00
|
|
|
// produces sequence with data in requested format and returns it in aResult
|
2003-12-02 07:34:02 -06:00
|
|
|
if ( pBuf )
|
|
|
|
{
|
2009-12-14 05:26:01 -06:00
|
|
|
uno::Sequence < sal_Int8 > aData( (sal_Int8*)pBuf, nBufSize );
|
|
|
|
uno::Reference < io::XInputStream > xIn = new comphelper::SequenceInputStream( aData );
|
2009-12-10 08:12:53 -06:00
|
|
|
try
|
2003-12-02 07:34:02 -06:00
|
|
|
{
|
2010-11-20 11:21:10 -06:00
|
|
|
uno::Reference < graphic::XGraphicProvider > xGraphicProvider( comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")) ), uno::UNO_QUERY );
|
2009-12-10 08:12:53 -06:00
|
|
|
if( xGraphicProvider.is() )
|
2003-12-02 07:34:02 -06:00
|
|
|
{
|
2009-12-10 08:12:53 -06:00
|
|
|
uno::Sequence< beans::PropertyValue > aMediaProperties( 1 );
|
2010-11-20 11:21:10 -06:00
|
|
|
aMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "InputStream" ));
|
2009-12-10 08:12:53 -06:00
|
|
|
aMediaProperties[0].Value <<= xIn;
|
|
|
|
uno::Reference< graphic::XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties ) );
|
|
|
|
if( xGraphic.is() )
|
2003-12-02 07:34:02 -06:00
|
|
|
{
|
2009-12-10 08:12:53 -06:00
|
|
|
SvMemoryStream aNewStream( 65535, 65535 );
|
2009-12-14 05:26:01 -06:00
|
|
|
// uno::Reference < io::XOutputStream > xOut = new utl::OOutputStreamHelper( aNewStream.GetLockBytes() );
|
|
|
|
uno::Reference < io::XStream > xOut = new utl::OStreamWrapper( aNewStream );
|
2009-12-10 08:12:53 -06:00
|
|
|
uno::Sequence< beans::PropertyValue > aOutMediaProperties( 2 );
|
2010-11-20 11:21:10 -06:00
|
|
|
aOutMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "OutputStream" ));
|
2009-12-14 05:26:01 -06:00
|
|
|
aOutMediaProperties[0].Value <<= xOut;
|
2010-11-20 11:21:10 -06:00
|
|
|
aOutMediaProperties[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MimeType" ));
|
2009-12-14 05:26:01 -06:00
|
|
|
aOutMediaProperties[1].Value <<= aMimeType;
|
2009-12-10 08:12:53 -06:00
|
|
|
|
|
|
|
xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties );
|
|
|
|
aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aNewStream.GetData() ), aNewStream.Seek( STREAM_SEEK_TO_END ) );
|
2003-12-02 07:34:02 -06:00
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-10 08:12:53 -06:00
|
|
|
catch (uno::Exception&)
|
|
|
|
{}
|
2003-12-02 07:34:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
2006-02-01 12:05:23 -06:00
|
|
|
// =====================================================================
|
|
|
|
// MainThreadNotificationRequest
|
|
|
|
// =====================================================================
|
2007-01-23 00:32:56 -06:00
|
|
|
MainThreadNotificationRequest::MainThreadNotificationRequest( const ::rtl::Reference< OleEmbeddedObject >& xObj, sal_uInt16 nNotificationType, sal_uInt32 nAspect )
|
|
|
|
: m_pObject( xObj.get() )
|
|
|
|
, m_xObject( static_cast< embed::XEmbeddedObject* >( xObj.get() ) )
|
|
|
|
, m_nNotificationType( nNotificationType )
|
2006-10-13 05:30:34 -05:00
|
|
|
, m_nAspect( nAspect )
|
2006-02-01 12:05:23 -06:00
|
|
|
{}
|
|
|
|
|
2010-02-17 03:32:35 -06:00
|
|
|
void SAL_CALL MainThreadNotificationRequest::notify (const uno::Any& ) throw (uno::RuntimeException)
|
2006-02-01 12:05:23 -06:00
|
|
|
{
|
2009-12-10 08:12:53 -06:00
|
|
|
if ( m_pObject )
|
2006-02-01 12:05:23 -06:00
|
|
|
{
|
2009-12-10 08:12:53 -06:00
|
|
|
try
|
2006-02-01 12:05:23 -06:00
|
|
|
{
|
2009-12-10 08:12:53 -06:00
|
|
|
uno::Reference< uno::XInterface > xLock = m_xObject.get();
|
|
|
|
if ( xLock.is() )
|
2006-02-01 12:05:23 -06:00
|
|
|
{
|
2009-12-10 08:12:53 -06:00
|
|
|
// this is the main thread, the solar mutex must be locked
|
|
|
|
if ( m_nNotificationType == OLECOMP_ONCLOSE )
|
|
|
|
m_pObject->OnClosed_Impl();
|
|
|
|
else if ( m_nAspect == embed::Aspects::MSOLE_CONTENT )
|
|
|
|
m_pObject->OnViewChanged_Impl();
|
|
|
|
else if ( m_nAspect == embed::Aspects::MSOLE_ICON )
|
|
|
|
m_pObject->OnIconChanged_Impl();
|
2006-02-01 12:05:23 -06:00
|
|
|
}
|
|
|
|
}
|
2009-12-10 08:12:53 -06:00
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
// ignore all the errors
|
|
|
|
}
|
2006-02-01 12:05:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-10 08:12:53 -06:00
|
|
|
MainThreadNotificationRequest::~MainThreadNotificationRequest()
|
|
|
|
{
|
|
|
|
}
|
2010-10-12 08:53:47 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|