20#include <com/sun/star/uno/Reference.hxx>
21#include <com/sun/star/uno/Sequence.hxx>
22#include <com/sun/star/uno/Any.hxx>
23#include <com/sun/star/lang/XMultiServiceFactory.hpp>
24#include <com/sun/star/configuration/theDefaultProvider.hpp>
25#include <com/sun/star/container/XNameAccess.hpp>
26#include <com/sun/star/embed/XEmbeddedObject.hpp>
27#include <com/sun/star/embed/XEmbedPersist.hpp>
28#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
29#include <com/sun/star/embed/EmbedStates.hpp>
30#include <com/sun/star/frame/XStorable.hpp>
31#include <com/sun/star/awt/Size.hpp>
32#include <com/sun/star/embed/Aspects.hpp>
72 return "LibreOffice.MathDocument.1";
74 return "LibreOffice.WriterDocument.1";
76 return "LibreOffice.CalcDocument.1";
78 return "LibreOffice.DrawDocument.1";
80 return "LibreOffice.ImpressDocument.1";
82 return "LibreOffice.ChartDocument.1";
88 uno::Reference< lang::XMultiServiceFactory > xProvider(
89 configuration::theDefaultProvider::get(
92 uno::Sequence< uno::Any > aArg{
uno::Any(
93 OUString(
"/org.openoffice.Office.Common/InternalMSExport" )) };
94 uno::Reference< container::XNameAccess > xNameAccess(
95 xProvider->createInstanceWithArguments(
96 "com.sun.star.configuration.ConfigurationUpdateAccess",
99 if ( xNameAccess.is() )
101 uno::Any aResult = xNameAccess->getByName(
"UseOldExport" );
104 if ( aResult >>= bResult )
108 catch(
const uno::Exception& )
112 OSL_FAIL(
"Could not get access to configuration entry!" );
126 std::shared_ptr<const SfxFilter> pExpFilter;
128 static struct ObjExpType {
130 const char* pFilterNm;
132 struct GlobalNameIds {
135 sal_uInt8 b8, b9, b10, b11, b12, b13, b14, b15;
163 for(
const ObjExpType* pArr =
aArr; !pExpFilter && ( pArr->nFlag != 0xffff ); ++pArr )
165 for (
const ObjExpType::GlobalNameIds& rId : pArr->aGlNmIds)
168 rId.b8, rId.b9, rId.b10, rId.b11,
169 rId.b12, rId.b13, rId.b14, rId.b15 );
170 if( aObjName == aGlbNm )
172 aOwnGlobalName = aGlbNm;
189 if ( rObj->getCurrentState() == embed::EmbedStates::LOADED )
190 rObj->changeState( embed::EmbedStates::RUNNING );
194 ::uno::Reference < io::XOutputStream > xOut = new ::utl::OOutputStreamWrapper( *pStream );
195 uno::Sequence < beans::PropertyValue >
aSeq{
199 uno::Reference < frame::XStorable > xStor( rObj->getComponent(), uno::UNO_QUERY );
202 xStor->storeToURL(
"private:stream",
aSeq );
204 catch(
const uno::Exception& ) {}
207 xOLEStor->CopyTo( &rDestStg );
210 catch(
const uno::Exception& )
213 OSL_FAIL(
"The object could not be exported!" );
225 SotClipboardFormatId::EMBEDDED_OBJ_OLE,
228 "properties_stream");
230 bool bExtentSuccess =
false;
231 if( !xExtStm->GetError() )
243 aSize = rObj->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
245 catch(
const embed::NoVisualAreaSizeException& )
247 OSL_FAIL(
"Could not get visual area size!" );
251 catch(
const uno::Exception& )
254 "filter.ms",
"Unexpected exception while getting visual area size!");
261 pRect[1] = aSize.Width;
263 pRect[3] = aSize.Height;
266 for (
int ind = 0; ind < 4; ind++ )
268 sal_Int32 nVal = pRect[ind];
269 for (
int nByte = 0; nByte < 4; nByte++ )
271 aWriteSet[ind*4+nByte] =
static_cast<sal_Int8>(nVal) % 0x100;
276 bExtentSuccess = (xExtStm->WriteBytes(aWriteSet, 16) == 16);
280 if ( bExtentSuccess )
284 if( !xEmbStm->GetError() )
288 if ( rObj->getCurrentState() == embed::EmbedStates::LOADED )
289 rObj->changeState( embed::EmbedStates::RUNNING );
292 ::uno::Reference < io::XOutputStream > xOut = new ::utl::OOutputStreamWrapper( *xEmbStm );
294 "OutputStream", xOut) };
295 uno::Reference < frame::XStorable > xStor( rObj->getComponent(), uno::UNO_QUERY );
296 xStor->storeToURL(
"private:stream",
aSeq );
298 catch(
const uno::Exception& )
301 OSL_FAIL(
"The object could not be exported!" );
308 OSL_FAIL(
"Own binary format inside own container document!");
317 uno::Reference < embed::XEmbedPersist > xPers( rObj.
GetObject(), uno::UNO_QUERY );
320 uno::Sequence < beans::PropertyValue > aEmptySeq;
321 OUString aTempName(
"bla" );
324 xPers->storeToEntry( xStor, aTempName, aEmptySeq, aEmptySeq );
326 catch (
const uno::Exception& )
330 xOLEStor->CopyTo( &rDestStg );
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
bool Remove(const OUString &rEleName)
void SetVersion(sal_Int32 nVersion)
tools::SvRef< SotStorageStream > OpenSotStream(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE)
void SetClass(const SvGlobalName &rClass, SotClipboardFormatId bOriginalClipFormat, const OUString &rUserTypeName)
static SotStorage * OpenOLEStorage(css::uno::Reference< css::embed::XStorage > const &xStorage, OUString const &rEleName, StreamMode=StreamMode::STD_READWRITE)
void ExportOLEObject(svt::EmbeddedObjectRef const &rObj, SotStorage &rDestStg)
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
#define SO3_SW_CLASSID_40
#define SO3_SDRAW_CLASSID_50
#define SO3_SCH_CLASSID_40
#define SO3_SC_CLASSID_30
#define SO3_SDRAW_CLASSID_60
#define SO3_SIMPRESS_CLASSID_50
#define SO3_SW_CLASSID_50
#define SO3_SM_CLASSID_50
#define SO3_SC_CLASSID_60
#define SO3_SIMPRESS_CLASSID_30
#define SO3_SM_CLASSID_60
#define SO3_SW_OLE_EMBED_CLASSID_8
#define SO3_SCH_CLASSID_30
#define SO3_SCH_CLASSID_50
#define SO3_SW_CLASSID_30
#define SO3_SW_CLASSID_60
#define SO3_SC_CLASSID_40
#define SO3_SCH_CLASSID_60
#define SO3_SIMPRESS_CLASSID_40
#define SO3_SM_CLASSID_30
#define SO3_SM_CLASSID_40
#define SO3_SIMPRESS_CLASSID_60
#define SO3_SM_OLE_EMBED_CLASSID_8
#define SO3_SDRAW_OLE_EMBED_CLASSID_8
#define SO3_SC_CLASSID_50
#define SO3_SCH_OLE_EMBED_CLASSID_8
#define SO3_SC_OLE_EMBED_CLASSID_8
#define SO3_SIMPRESS_OLE_EMBED_CLASSID_8
const css::uno::Reference< css::embed::XEmbeddedObject > & GetObject() const
#define TOOLS_WARN_EXCEPTION(area, stream)
Sequence< sal_Int8 > aSeq
constexpr OUStringLiteral SVEXT_PERSIST_STREAM
static SvGlobalName GetEmbeddedVersion(const SvGlobalName &aAppName)
static OUString GetStorageType(const SvGlobalName &aEmbName)
static bool UseOldMSExport()
#define OLE_STARIMPRESS_2_POWERPOINT
#define OLE_STARWRITER_2_WINWORD
#define OLE_STARCALC_2_EXCEL
#define OLE_STARMATH_2_MATHTYPE
Shape IDs per cluster in DGG atom.
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)