summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2008-07-01 09:59:47 +0000
committerVladimir Glazounov <vg@openoffice.org>2008-07-01 09:59:47 +0000
commit4aa9727d8feb60df0b13195353696a7bc4f2c7e2 (patch)
tree68dfa0d1fd7bba19a9508e57eb032c95694beb6c /writerfilter/source/dmapper
parentfff6b7b4b038edaee20981a06361e4be47c05dec (diff)
INTEGRATION: CWS xmlfilter05 (1.1.2); FILE ADDED
2008/05/21 13:27:14 dr 1.1.2.3: #i10000# new header 2008/04/25 07:57:49 hbrinkm 1.1.2.2: warning: unused variable nIntValue 2008/04/24 06:45:45 os 1.1.2.1: OLE handler
Diffstat (limited to 'writerfilter/source/dmapper')
-rw-r--r--writerfilter/source/dmapper/OLEHandler.cxx157
1 files changed, 157 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx
new file mode 100644
index 000000000000..715ba6b3faf9
--- /dev/null
+++ b/writerfilter/source/dmapper/OLEHandler.cxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: OLEHandler.cxx,v $
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <OLEHandler.hxx>
+#include <PropertyMap.hxx>
+#include <doctok/resourceids.hxx>
+#include <ooxml/resourceids.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <com/sun/star/embed/XEmbedObjectCreator.hpp>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace writerfilter {
+namespace dmapper {
+
+using namespace ::com::sun::star;
+/*-- 23.04.2008 10:46:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+OLEHandler::OLEHandler()
+{
+}
+/*-- 23.04.2008 10:46:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+OLEHandler::~OLEHandler()
+{
+}
+/*-- 23.04.2008 10:46:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void OLEHandler::attribute(Id rName, Value & rVal)
+{
+ rtl::OUString sStringValue = rVal.getString();
+ (void)rName;
+ /* WRITERFILTERSTATUS: table: OLEHandler_attributedata */
+ switch( rName )
+ {
+ /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
+ case NS_ooxml::LN_CT_OLEObject_Type:
+ m_sObjectType = sStringValue;
+ break;
+ case NS_ooxml::LN_CT_OLEObject_ProgID:
+ m_sProgId = sStringValue;
+ break;
+ case NS_ooxml::LN_CT_OLEObject_ShapeID:
+ m_sShapeId = sStringValue;
+ break;
+ case NS_ooxml::LN_CT_OLEObject_DrawAspect:
+ m_sDrawAspect = sStringValue;
+ break;
+ case NS_ooxml::LN_CT_OLEObject_ObjectID:
+ m_sObjectId = sStringValue;
+ break;
+ case NS_ooxml::LN_CT_OLEObject_r_id:
+ m_sr_id = sStringValue;
+ break;
+ case NS_ooxml::LN_inputstream:
+ rVal.getAny() >>= m_xInputStream;
+ break;
+ default:
+ OSL_ENSURE( false, "unknown attribute");
+ }
+}
+/*-- 23.04.2008 10:46:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void OLEHandler::sprm(Sprm & rSprm)
+{
+ (void)rSprm;
+}
+/*-- 23.04.2008 11:15:19---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString OLEHandler::copyOLEOStream( uno::Reference< text::XTextDocument > xTextDocument )
+{
+ ::rtl::OUString sRet;
+ if( !m_xInputStream.is() )
+ return sRet;
+ try{
+ uno::Reference < lang::XMultiServiceFactory > xFactory(xTextDocument, uno::UNO_QUERY_THROW);
+ uno::Reference< document::XEmbeddedObjectResolver > xEmbeddedResolver(
+ xFactory->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver" ))), uno::UNO_QUERY_THROW );
+ //hack to work with the ImportEmbeddedObjectResolver
+ static sal_Int32 nObjectCount = 100;
+ uno::Reference< container::XNameAccess > xNA( xEmbeddedResolver, uno::UNO_QUERY_THROW );
+ ::rtl::OUString aURL(RTL_CONSTASCII_USTRINGPARAM("Obj" ));
+ aURL += ::rtl::OUString::valueOf( nObjectCount++ );
+ uno::Reference < io::XOutputStream > xOLEStream;
+ if( (xNA->getByName( aURL ) >>= xOLEStream) && xOLEStream.is() )
+ {
+ const sal_Int32 nReadRequest = 0x1000;
+ uno::Sequence< sal_Int8 > aData;
+
+ while( true )
+ {
+ sal_Int32 nRead = m_xInputStream->readBytes( aData, nReadRequest );
+ xOLEStream->writeBytes( aData );
+ if( nRead < nReadRequest )
+ {
+ xOLEStream->closeOutput();
+ break;
+ }
+ }
+
+ static const ::rtl::OUString sProtocol = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.EmbeddedObject:" ));
+ ::rtl::OUString aPersistName( xEmbeddedResolver->resolveEmbeddedObjectURL( aURL ) );
+ sRet = aPersistName.copy( sProtocol.getLength() );
+
+ }
+ uno::Reference< lang::XComponent > xComp( xEmbeddedResolver, uno::UNO_QUERY_THROW );
+ xComp->dispose();
+ }
+ catch( const uno::Exception& rEx)
+ {
+ (void)rEx;
+ OSL_ENSURE(false, "exception in OLEHandler::createOLEObject");
+ }
+ return sRet;
+}
+
+} //namespace dmapper
+} //namespace writerfilter