summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2003-03-05 14:50:11 +0000
committerMikhail Voitenko <mav@openoffice.org>2003-03-05 14:50:11 +0000
commita934115b3ea90d7883681a6ca8922a4b859be36f (patch)
tree8d6be1f32a0ce089bbac62dad7c121b52fde00f3
parent43a73f08a8ac97574d8dbd0f81a512c184917af0 (diff)
Initial revision
-rwxr-xr-xembedserv/source/embed/ed_idataobj.cxx344
-rwxr-xr-xembedserv/source/embed/ed_ioleobject.cxx179
-rwxr-xr-xembedserv/source/embed/ed_ipersiststr.cxx623
-rwxr-xr-xembedserv/source/embed/esdll.cxx90
-rwxr-xr-xembedserv/source/embed/guid.cxx157
-rwxr-xr-xembedserv/source/embed/makefile.mk101
-rwxr-xr-xembedserv/source/embed/register.cxx170
-rwxr-xr-xembedserv/source/embed/servprov.cxx286
-rwxr-xr-xembedserv/source/embed/stdafx.cpp13
-rwxr-xr-xembedserv/source/inc/common.h120
-rwxr-xr-xembedserv/source/inc/embeddoc.hxx164
-rwxr-xr-xembedserv/source/inc/servprov.hxx142
-rwxr-xr-xembedserv/source/inc/stdafx.h26
13 files changed, 2415 insertions, 0 deletions
diff --git a/embedserv/source/embed/ed_idataobj.cxx b/embedserv/source/embed/ed_idataobj.cxx
new file mode 100755
index 000000000000..07eed89576be
--- /dev/null
+++ b/embedserv/source/embed/ed_idataobj.cxx
@@ -0,0 +1,344 @@
+/*************************************************************************
+ *
+ * $RCSfile: ed_idataobj.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:50:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+// actually this workaround should be in presys.h!
+//#define UINT64 USE_WIN_UINT64
+//#define INT64 USE_WIN_INT64
+//#define UINT32 USE_WIN_UINT32
+//#define INT32 USE_WIN_INT32
+
+//#include <tools/presys.h>
+#include "embeddoc.hxx"
+//#include <tools/postsys.h>
+
+//#undef UINT64
+//#undef INT64
+//#undef UINT32
+//#undef INT32
+
+
+#ifndef _COM_SUN_STAR_UNO_ANY_H_
+#include <com/sun/star/uno/Any.h>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
+#include <com/sun/star/uno/Exception.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#endif
+
+
+#ifndef _OSL_THREAD_H_
+#include <osl/thread.h>
+#endif
+
+using namespace ::com::sun::star;
+
+//===============================================================================
+// EmbedDocument_Impl
+//===============================================================================
+
+sal_uInt64 EmbedDocument_Impl::getMetaFileHandle_Impl( sal_Bool isEnhMeta )
+{
+ sal_uInt64 pResult = NULL;
+
+ uno::Reference< datatransfer::XTransferable > xTransferable( m_xDocument, uno::UNO_QUERY );
+ if ( xTransferable.is() )
+ {
+ uno::Sequence< sal_Int8 > aMetaBuffer;
+ datatransfer::DataFlavor aFlavor;
+
+ if ( isEnhMeta )
+ {
+ aFlavor.MimeType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "application/x-openoffice;windows_formatname=\"Image EMF\"" ) );
+ aFlavor.HumanPresentableName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enhanced Windows MetaFile" ) );
+ }
+ else
+ {
+ aFlavor.MimeType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "application/x-openoffice;windows_formatname=\"Image WMF\"" ) );
+ aFlavor.HumanPresentableName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Windows GDIMetaFile" ) );
+ }
+
+ aFlavor.DataType = getCppuType( (const sal_uInt64*) 0 );
+
+ uno::Any aAny = xTransferable->getTransferData( aFlavor );
+ aAny >>= pResult;
+ }
+
+ return pResult;
+}
+
+//-------------------------------------------------------------------------------
+// IDataObject
+
+STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pMedium )
+{
+ if ( !pFormatetc )
+ return DV_E_FORMATETC;
+
+ if ( !pMedium )
+ return STG_E_MEDIUMFULL;
+
+ if ( pFormatetc->dwAspect == DVASPECT_THUMBNAIL
+ || pFormatetc->dwAspect == DVASPECT_ICON
+ || pFormatetc->dwAspect == DVASPECT_DOCPRINT )
+ return DV_E_DVASPECT;
+
+ if ( pFormatetc->cfFormat == CF_ENHMETAFILE )
+ {
+ if ( !( pFormatetc->tymed & TYMED_ENHMF ) )
+ return DV_E_TYMED;
+
+ HENHMETAFILE hMeta = reinterpret_cast<HENHMETAFILE>( getMetaFileHandle_Impl( sal_True ) );
+
+ if ( hMeta )
+ {
+ pMedium->tymed = TYMED_ENHMF;
+ pMedium->hEnhMetaFile = hMeta;
+ pMedium->pUnkForRelease = NULL;
+
+ return S_OK;
+ }
+
+ return STG_E_MEDIUMFULL;
+ }
+ else if ( pFormatetc->cfFormat == CF_METAFILEPICT )
+ {
+ if ( !( pFormatetc->tymed & TYMED_MFPICT ) )
+ return DV_E_TYMED;
+
+ HMETAFILEPICT hMeta = reinterpret_cast<HMETAFILEPICT>( getMetaFileHandle_Impl( sal_False ) );
+
+ if ( hMeta )
+ {
+ pMedium->tymed = TYMED_MFPICT;
+ pMedium->hMetaFilePict = hMeta;
+ pMedium->pUnkForRelease = NULL;
+
+ return S_OK;
+ }
+
+ return STG_E_MEDIUMFULL;
+ }
+ else
+ {
+ CLIPFORMAT cf_embSource = RegisterClipboardFormatA( "Embed Source" );
+ if ( pFormatetc->cfFormat == cf_embSource )
+ {
+ if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) )
+ return DV_E_TYMED;
+
+ CComPtr< IStorage > pNewStg;
+ HRESULT hr = StgCreateDocfile( NULL, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, 0, &pNewStg );
+ if ( FAILED( hr ) || !pNewStg ) return STG_E_MEDIUMFULL;
+
+ hr = SaveTo_Impl( pNewStg );
+ if ( FAILED( hr ) ) return STG_E_MEDIUMFULL;
+
+ pMedium->tymed = TYMED_ISTORAGE;
+ pMedium->pstg = pNewStg;
+ pMedium->pstg->AddRef();
+ pMedium->pUnkForRelease = ( IUnknown* )pNewStg;
+
+ return S_OK;
+ }
+ }
+
+ return DV_E_FORMATETC;
+}
+
+STDMETHODIMP EmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGMEDIUM * pMedium )
+{
+ if ( !pFormatetc )
+ return DV_E_FORMATETC;
+
+ if ( !pMedium )
+ return STG_E_MEDIUMFULL;
+
+ if ( pFormatetc->dwAspect == DVASPECT_THUMBNAIL
+ || pFormatetc->dwAspect == DVASPECT_ICON
+ || pFormatetc->dwAspect == DVASPECT_DOCPRINT )
+ return DV_E_DVASPECT;
+
+ CLIPFORMAT cf_embSource = RegisterClipboardFormatA( "Embed Source" );
+ if ( pFormatetc->cfFormat == cf_embSource )
+ {
+ if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) )
+ return DV_E_TYMED;
+
+ if ( !pMedium->pstg ) return STG_E_MEDIUMFULL;
+
+ HRESULT hr = SaveTo_Impl( pMedium->pstg );
+ if ( FAILED( hr ) ) return STG_E_MEDIUMFULL;
+
+ pMedium->tymed = TYMED_ISTORAGE;
+ pMedium->pUnkForRelease = NULL;
+
+ return S_OK;
+ }
+
+ return DV_E_FORMATETC;
+}
+
+STDMETHODIMP EmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc )
+{
+ if ( pFormatetc )
+ {
+ if ( pFormatetc->dwAspect == DVASPECT_THUMBNAIL
+ || pFormatetc->dwAspect == DVASPECT_ICON
+ || pFormatetc->dwAspect == DVASPECT_DOCPRINT )
+ return DV_E_DVASPECT;
+
+ if ( pFormatetc->cfFormat == CF_ENHMETAFILE )
+ {
+ if ( !( pFormatetc->tymed & TYMED_ENHMF ) )
+ return DV_E_TYMED;
+
+ return S_OK;
+ }
+ else if ( pFormatetc->cfFormat == CF_METAFILEPICT )
+ {
+ if ( !( pFormatetc->tymed & TYMED_MFPICT ) )
+ return DV_E_TYMED;
+
+ return S_OK;
+ }
+ else
+ {
+ CLIPFORMAT cf_embSource = RegisterClipboardFormatA( "Embed Source" );
+ if ( pFormatetc->cfFormat == cf_embSource )
+ {
+ if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) )
+ return DV_E_TYMED;
+
+ return S_OK;
+ }
+ }
+ }
+
+ return DV_E_FORMATETC;
+
+}
+
+STDMETHODIMP EmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut )
+{
+ if ( !pFormatetcIn || !pFormatetcOut )
+ return DV_E_FORMATETC;
+
+ pFormatetcOut->ptd = NULL;
+ pFormatetcOut->cfFormat = pFormatetcIn->cfFormat;
+ pFormatetcOut->dwAspect = DVASPECT_CONTENT;
+
+ if ( pFormatetcIn->cfFormat == CF_ENHMETAFILE )
+ {
+ pFormatetcOut->tymed = TYMED_ENHMF;
+ return S_OK;
+ }
+ else if ( pFormatetcIn->cfFormat == CF_METAFILEPICT )
+ {
+ pFormatetcOut->tymed = TYMED_MFPICT;
+ return S_OK;
+ }
+ else
+ {
+ CLIPFORMAT cf_embSource = RegisterClipboardFormatA( "Embed Source" );
+ if ( pFormatetcIn->cfFormat == cf_embSource )
+ {
+ pFormatetcOut->tymed = TYMED_ISTORAGE;
+ return S_OK;
+ }
+ }
+
+ return DV_E_FORMATETC;
+}
+
+STDMETHODIMP EmbedDocument_Impl::SetData( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease )
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc )
+{
+ if ( dwDirection == DATADIR_GET )
+ return OLE_S_USEREG;
+
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::DAdvise( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection )
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::DUnadvise( DWORD dwConnection )
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::EnumDAdvise( IEnumSTATDATA ** ppenumAdvise )
+{
+ return OLE_E_ADVISENOTSUPPORTED;
+}
+
diff --git a/embedserv/source/embed/ed_ioleobject.cxx b/embedserv/source/embed/ed_ioleobject.cxx
new file mode 100755
index 000000000000..1a11b34c634b
--- /dev/null
+++ b/embedserv/source/embed/ed_ioleobject.cxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * $RCSfile: ed_ioleobject.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:50:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "embeddoc.hxx"
+
+STDMETHODIMP EmbedDocument_Impl::SetClientSite( IOleClientSite* pSite )
+{
+ m_pClientSite = pSite;
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::GetClientSite( IOleClientSite** pSite )
+{
+ *pSite = m_pClientSite;
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj )
+{
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::Close( DWORD dwSaveOption)
+{
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::SetMoniker( DWORD dwWhichMoniker, IMoniker *pmk )
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk )
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::InitFromData( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved )
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::GetClipboardData( DWORD dwReserved, IDataObject **ppDataObject )
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::DoVerb( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect )
+{
+ if ( iVerb == OLEIVERB_PRIMARY || iVerb == OLEIVERB_OPEN || iVerb == OLEIVERB_SHOW )
+ return S_OK;
+
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::EnumVerbs( IEnumOLEVERB **ppEnumOleVerb )
+{
+ return OLE_S_USEREG;
+}
+
+STDMETHODIMP EmbedDocument_Impl::Update()
+{
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::IsUpToDate()
+{
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::GetUserClassID( CLSID *pClsid )
+{
+ return GetClassID( pClsid );
+}
+
+STDMETHODIMP EmbedDocument_Impl::GetUserType( DWORD dwFormOfType, LPOLESTR *pszUserType )
+{
+ return OLE_S_USEREG;
+}
+
+STDMETHODIMP EmbedDocument_Impl::SetExtent( DWORD dwDrawAspect, SIZEL *psizel )
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, SIZEL *psizel )
+{
+ if ( psizel )
+ {
+ psizel->cx = 10000;
+ psizel->cy = 10000;
+ }
+
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::Advise( IAdviseSink *pAdvSink, DWORD *pdwConnection )
+{
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::Unadvise( DWORD dwConnection )
+{
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::EnumAdvise( IEnumSTATDATA **ppenumAdvise )
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP EmbedDocument_Impl::GetMiscStatus( DWORD dwAspect, DWORD *pdwStatus )
+{
+ return OLE_S_USEREG;
+}
+
+STDMETHODIMP EmbedDocument_Impl::SetColorScheme( LOGPALETTE *pLogpal )
+{
+ return E_NOTIMPL;
+}
+
diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx
new file mode 100755
index 000000000000..f8d8dafe7a17
--- /dev/null
+++ b/embedserv/source/embed/ed_ipersiststr.cxx
@@ -0,0 +1,623 @@
+/*************************************************************************
+ *
+ * $RCSfile: ed_ipersiststr.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:50:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "embeddoc.hxx"
+
+#ifndef _COM_SUN_STAR_UNO_ANY_H_
+#include <com/sun/star/uno/Any.h>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
+#include <com/sun/star/uno/Exception.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
+#include <com/sun/star/io/XSeekable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XLOADABLE_HPP_
+#include <com/sun/star/frame/XLoadable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_
+#include <com/sun/star/frame/XStorable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+using namespace ::com::sun::star;
+
+extern ::rtl::OUString getServiceNameFromGUID_Impl( GUID* );
+extern ::rtl::OUString getFilterNameFromGUID_Impl( GUID* );
+// extern CLIPFORMAT getClipFormatFromGUID_Impl( GUID* );
+
+const ::rtl::OUString aOfficeEmbedStreamName( RTL_CONSTASCII_USTRINGPARAM ( "package_stream" ) );
+
+uno::Reference< io::XInputStream > createTempXInStreamFromIStream(
+ uno::Reference< lang::XMultiServiceFactory > xFactory,
+ IStream *pStream )
+{
+ uno::Reference< io::XInputStream > xResult;
+
+ if ( !pStream )
+ return xResult;
+
+ const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.io.TempFile" ) );
+ uno::Reference < io::XOutputStream > xTempOut = uno::Reference < io::XOutputStream > (
+ xFactory->createInstance ( aServiceName ),
+ uno::UNO_QUERY );
+ if ( xTempOut.is() )
+ {
+ ULARGE_INTEGER nNewPos;
+ LARGE_INTEGER aZero = { 0L, 0L };
+ HRESULT hr = pStream->Seek( aZero, STREAM_SEEK_SET, &nNewPos );
+ if ( FAILED( hr ) ) return xResult;
+
+ STATSTG aStat;
+ hr = pStream->Stat( &aStat, STATFLAG_NONAME );
+ if ( FAILED( hr ) ) return xResult;
+
+ sal_uInt32 nSize = (sal_uInt32)aStat.cbSize.QuadPart;
+ sal_uInt32 nCopied = 0;
+ uno::Sequence< sal_Int8 > aBuffer( nConstBufferSize );
+ try
+ {
+ sal_uInt32 nRead = 0;
+ do
+ {
+ pStream->Read( (void*)aBuffer.getArray(), nConstBufferSize, &nRead );
+
+ if ( nRead < nConstBufferSize )
+ aBuffer.realloc( nRead );
+
+ xTempOut->writeBytes( aBuffer );
+ nCopied += nRead;
+ } while( nRead == nConstBufferSize );
+
+ if ( nCopied == nSize )
+ {
+ uno::Reference < io::XSeekable > xTempSeek ( xTempOut, uno::UNO_QUERY );
+ if ( xTempSeek.is() )
+ {
+ xTempSeek->seek ( 0 );
+ xResult = uno::Reference< io::XInputStream >( xTempOut, uno::UNO_QUERY );
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
+ return xResult;
+}
+
+HRESULT copyXTempOutToIStream( uno::Reference< io::XOutputStream > xTempOut, IStream* pStream )
+{
+ if ( !xTempOut.is() || !pStream )
+ return E_FAIL;
+
+ uno::Reference < io::XSeekable > xTempSeek ( xTempOut, uno::UNO_QUERY );
+ if ( !xTempSeek.is() )
+ return E_FAIL;
+
+ xTempSeek->seek ( 0 );
+
+ uno::Reference< io::XInputStream > xTempIn ( xTempOut, uno::UNO_QUERY );
+ if ( !xTempSeek.is() )
+ return E_FAIL;
+
+ ULARGE_INTEGER nNewPos;
+ LARGE_INTEGER aZero = { 0L, 0L };
+ HRESULT hr = pStream->Seek( aZero, STREAM_SEEK_SET, &nNewPos );
+ if ( FAILED( hr ) ) return E_FAIL;
+
+ uno::Sequence< sal_Int8 > aBuffer( nConstBufferSize );
+ sal_uInt32 nReadBytes = 0;
+
+ do
+ {
+ try {
+ nReadBytes = xTempIn->readBytes( aBuffer, nConstBufferSize );
+ }
+ catch( uno::Exception& )
+ {
+ return E_FAIL;
+ }
+
+ sal_uInt32 nWritten = 0;
+ HRESULT hr = pStream->Write( (void*)aBuffer.getArray(), nReadBytes, &nWritten );
+ if ( !SUCCEEDED( hr ) || nWritten != nReadBytes )
+ return E_FAIL;
+
+ } while( nReadBytes == nConstBufferSize );
+
+ return S_OK;
+}
+
+
+//===============================================================================
+// EmbedDocument_Impl
+//===============================================================================
+
+EmbedDocument_Impl::EmbedDocument_Impl( const uno::Reference< lang::XMultiServiceFactory >& xFactory, const GUID* guid )
+: m_refCount( 0L )
+, m_xFactory( xFactory )
+, m_guid( *guid )
+, m_bIsDirty( sal_False )
+{
+}
+
+EmbedDocument_Impl::~EmbedDocument_Impl()
+{
+ if ( m_xDocument.is() )
+ {
+ uno::Reference< lang::XComponent > xComponent( m_xDocument, uno::UNO_QUERY );
+
+ OSL_ENSURE( xComponent.is(), "Can not dispose created model!\n" );
+ if ( xComponent.is() )
+ xComponent->dispose();
+
+ m_xDocument = uno::Reference< frame::XModel >();
+ }
+}
+
+uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Impl( uno::Reference< io::XInputStream > xStream, DWORD nStreamMode )
+{
+ uno::Sequence< beans::PropertyValue > aArgs( 4 );
+
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "URL" ) );
+ aArgs[0].Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "private:stream" ) );
+ aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "FilterName" ) );
+ aArgs[1].Value <<= getFilterNameFromGUID_Impl( &m_guid );
+ aArgs[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "InputStream" ) );
+ aArgs[2].Value <<= xStream;
+ aArgs[3].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ReadOnly" ) );
+ aArgs[3].Value <<= ( ( nStreamMode & ( STGM_READWRITE | STGM_WRITE ) ) ? sal_True : sal_False );
+
+ return aArgs;
+}
+
+uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForStoring_Impl( uno::Reference< io::XOutputStream > xStream)
+{
+ uno::Sequence< beans::PropertyValue > aArgs( 2 );
+
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "FilterName" ) );
+ aArgs[0].Value <<= getFilterNameFromGUID_Impl( &m_guid );
+ aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "OutputStream" ) );
+ aArgs[1].Value <<= xStream;
+
+ return aArgs;
+}
+
+HRESULT EmbedDocument_Impl::SaveTo_Impl( IStorage* pStg )
+{
+ if ( !pStg || pStg == m_pMasterStorage )
+ return E_FAIL;
+
+ // for saveto operation the master storage
+ // should not enter NoScribble mode
+ CComPtr< IStream > pOrigOwn = m_pOwnStream;
+ HRESULT hr = Save( pStg, sal_False );
+ m_pOwnStream = pOrigOwn;
+
+ return hr;
+}
+
+//-------------------------------------------------------------------------------
+// IUnknown
+
+STDMETHODIMP EmbedDocument_Impl::QueryInterface( REFIID riid, void FAR* FAR* ppv )
+{
+ if(IsEqualIID(riid, IID_IUnknown))
+ {
+ AddRef();
+ *ppv = (IUnknown*) (IPersistStorage*) this;
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, IID_IPersist))
+ {
+ AddRef();
+ *ppv = (IPersist*) (IPersistStorage*) this;
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, IID_IPersistStorage))
+ {
+ AddRef();
+ *ppv = (IPersistStorage*) this;
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, IID_IDataObject))
+ {
+ AddRef();
+ *ppv = (IDataObject*) this;
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, IID_IOleObject))
+ {
+ AddRef();
+ *ppv = (IOleObject*) this;
+ return S_OK;
+ }
+
+ *ppv = NULL;
+ return ResultFromScode(E_NOINTERFACE);
+}
+
+STDMETHODIMP_(ULONG) EmbedDocument_Impl::AddRef()
+{
+ return osl_incrementInterlockedCount( &m_refCount);
+}
+
+STDMETHODIMP_(ULONG) EmbedDocument_Impl::Release()
+{
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex());
+ m_refCount--;
+ if ( m_refCount == 0 )
+ {
+ delete this;
+ }
+
+ return m_refCount;
+}
+
+//-------------------------------------------------------------------------------
+// IPersist
+
+STDMETHODIMP EmbedDocument_Impl::GetClassID( CLSID* pClassId )
+{
+ *pClassId = *&m_guid;
+ return S_OK;
+}
+
+//-------------------------------------------------------------------------------
+// IPersistStorage
+
+STDMETHODIMP EmbedDocument_Impl::IsDirty()
+{
+ return m_bIsDirty ? S_OK : S_FALSE;
+}
+
+STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg )
+{
+ HRESULT hr = CO_E_ALREADYINITIALIZED;
+
+ if ( !m_xDocument.is() )
+ {
+
+ STATSTG aStat;
+ hr = pStg->Stat( &aStat, STATFLAG_NONAME );
+ if ( FAILED( hr ) ) return E_FAIL;
+
+ DWORD nStreamMode = aStat.grfMode;
+
+ hr = E_FAIL;
+ if ( m_xFactory.is() && pStg )
+ {
+ uno::Reference < frame::XComponentLoader > xComponentLoader(
+ m_xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop" ) ) ),
+ uno::UNO_QUERY );
+
+ rtl::OUString sDocUrl( rtl::OUString::createFromAscii( "file:///d:/test.sxw" ) );
+
+ uno::Reference< lang::XComponent > xComponent = xComponentLoader->loadComponentFromURL(
+ sDocUrl, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ), 0,
+ uno::Sequence < ::com::sun::star::beans::PropertyValue >() );
+
+
+ m_xDocument = uno::Reference< frame::XModel >( xComponent, uno::UNO_QUERY );
+ /*
+ m_xDocument = uno::Reference< frame::XModel >(
+ m_xFactory->createInstance( getServiceNameFromGUID_Impl( &m_guid ) ),
+ uno::UNO_QUERY );
+ */
+ if ( m_xDocument.is() )
+ {
+ /*
+ uno::Reference< frame::XLoadable > xLoadable( m_xDocument, uno::UNO_QUERY );
+ if( xLoadable.is() )
+ {
+ try
+ {
+ xLoadable->initNew();
+ */
+ hr = S_OK;
+ /*
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ */
+
+ if ( hr == S_OK )
+ {
+ ::rtl::OUString aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ???
+ CLIPFORMAT cf = RegisterClipboardFormatA( "Embedded Object" );
+ hr = WriteFmtUserTypeStg( pStg,
+ cf, // ???
+ ( sal_Unicode* )aCurType.getStr() );
+
+ if ( hr == S_OK )
+ {
+ hr = pStg->CreateStream( aOfficeEmbedStreamName,
+ STGM_CREATE | nStreamMode,
+ 0,
+ 0,
+ &m_pOwnStream );
+
+ if ( hr == S_OK && m_pOwnStream )
+ {
+ m_pMasterStorage = pStg;
+ m_bIsDirty = sal_True;
+ }
+ else
+ hr = E_FAIL;
+ }
+ else
+ hr = E_FAIL;
+ }
+
+ if ( hr != S_OK )
+ {
+ uno::Reference< lang::XComponent > xComponent( m_xDocument, uno::UNO_QUERY );
+
+ OSL_ENSURE( xComponent.is(), "Can not dispose created model!\n" );
+ if ( xComponent.is() )
+ xComponent->dispose();
+
+ m_xDocument = uno::Reference< frame::XModel >();
+ }
+ }
+ }
+ }
+
+ return hr;
+}
+
+STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg )
+{
+
+ if ( m_xDocument.is() )
+ return CO_E_ALREADYINITIALIZED;
+
+ if ( !m_xFactory.is() || !pStg )
+ return E_FAIL;
+
+ HRESULT hr = E_FAIL;
+
+ STATSTG aStat;
+ hr = pStg->Stat( &aStat, STATFLAG_NONAME );
+ if ( FAILED( hr ) ) return E_FAIL;
+
+ DWORD nStreamMode = aStat.grfMode;
+ hr = pStg->OpenStream( aOfficeEmbedStreamName,
+ 0,
+ nStreamMode,
+ 0,
+ &m_pOwnStream );
+ if ( FAILED( hr ) || !m_pOwnStream ) return E_FAIL;
+
+ hr = E_FAIL;
+
+ uno::Reference < io::XInputStream > xTempIn = createTempXInStreamFromIStream( m_xFactory, m_pOwnStream );
+ if ( xTempIn.is() )
+ {
+ m_xDocument = uno::Reference< frame::XModel >(
+ m_xFactory->createInstance( getServiceNameFromGUID_Impl( &m_guid ) ),
+ uno::UNO_QUERY );
+ if ( m_xDocument.is() )
+ {
+ uno::Reference< frame::XLoadable > xLoadable( m_xDocument, uno::UNO_QUERY );
+ if( xLoadable.is() )
+ {
+ try
+ {
+ xLoadable->load( fillArgsForLoading_Impl( xTempIn, nStreamMode ) );
+ m_pMasterStorage = pStg;
+ hr = S_OK;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
+ if ( FAILED( hr ) )
+ {
+ uno::Reference< lang::XComponent > xComponent( m_xDocument, uno::UNO_QUERY );
+
+ OSL_ENSURE( xComponent.is(), "Can not dispose created model!\n" );
+ if ( xComponent.is() )
+ xComponent->dispose();
+
+ m_xDocument = uno::Reference< frame::XModel >();
+ }
+ }
+ }
+
+ if ( FAILED( hr ) )
+ {
+ m_pOwnStream = CComPtr< IStream >();
+ hr = pStg->DestroyElement( aOfficeEmbedStreamName );
+
+ OSL_ENSURE( SUCCEEDED( hr ), "Can not destroy created stream!\n" );
+ if ( FAILED( hr ) )
+ hr = E_FAIL;
+ }
+
+ return hr;
+}
+
+STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad )
+{
+ if ( !m_xDocument.is() || !m_xFactory.is() || !pStgSave || !m_pOwnStream )
+ return E_FAIL;
+
+ CComPtr< IStream > pTargetStream;
+
+ if ( !fSameAsLoad && pStgSave != m_pMasterStorage )
+ {
+ OSL_ENSURE( m_pMasterStorage, "How could the document be initialized without storage!??\n" );
+ HRESULT hr = m_pMasterStorage->CopyTo( NULL, NULL, NULL, pStgSave );
+ if ( FAILED( hr ) ) return E_FAIL;
+
+ hr = pStgSave->OpenStream( aOfficeEmbedStreamName,
+ 0,
+ STGM_WRITE,
+ 0,
+ &pTargetStream );
+ if ( FAILED( hr ) || !m_pOwnStream ) return E_FAIL;
+ }
+ else
+ pTargetStream = m_pOwnStream;
+
+ HRESULT hr = E_FAIL;
+
+ const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.io.TempFile" ) );
+ uno::Reference < io::XOutputStream > xTempOut = uno::Reference < io::XOutputStream > (
+ m_xFactory->createInstance ( aServiceName ),
+ uno::UNO_QUERY );
+
+ if ( xTempOut.is() )
+ {
+ uno::Reference< frame::XStorable > xStorable( m_xDocument, uno::UNO_QUERY );
+ if( xStorable.is() )
+ {
+ try
+ {
+ xStorable->storeToURL( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "private:stream" ) ),
+ fillArgsForStoring_Impl( xTempOut ) );
+ hr = copyXTempOutToIStream( xTempOut, pTargetStream );
+ if ( SUCCEEDED( hr ) )
+ {
+ m_pOwnStream = CComPtr< IStream >();
+ if ( fSameAsLoad || pStgSave == m_pMasterStorage )
+ m_bIsDirty = sal_False;
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ }
+
+ return hr;
+}
+
+STDMETHODIMP EmbedDocument_Impl::SaveCompleted( IStorage *pStgNew )
+{
+ // m_pOwnStream == NULL && m_pMasterStorage != NULL means the object is in NoScribble mode
+ // m_pOwnStream == NULL && m_pMasterStorage == NULL means the object is in HandsOff mode
+
+ if ( m_pOwnStream )
+ return E_UNEXPECTED;
+
+ if ( !m_pMasterStorage && !pStgNew )
+ return E_INVALIDARG;
+
+ if ( pStgNew )
+ m_pMasterStorage = pStgNew;
+
+ STATSTG aStat;
+ HRESULT hr = pStgNew->Stat( &aStat, STATFLAG_NONAME );
+ if ( FAILED( hr ) ) return E_OUTOFMEMORY;
+
+ DWORD nStreamMode = aStat.grfMode;
+ hr = m_pMasterStorage->OpenStream( aOfficeEmbedStreamName,
+ 0,
+ nStreamMode,
+ 0,
+ &m_pOwnStream );
+ if ( FAILED( hr ) || !m_pOwnStream ) return E_OUTOFMEMORY;
+
+ return S_OK;
+}
+
+STDMETHODIMP EmbedDocument_Impl::HandsOffStorage()
+{
+ m_pMasterStorage = CComPtr< IStorage >();
+ m_pOwnStream = CComPtr< IStream >();
+
+ return S_OK;
+}
+
+
diff --git a/embedserv/source/embed/esdll.cxx b/embedserv/source/embed/esdll.cxx
new file mode 100755
index 000000000000..a7b0ffc90f67
--- /dev/null
+++ b/embedserv/source/embed/esdll.cxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * $RCSfile: esdll.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:50:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#define STRICT
+#define _WIN32_WINNT 0x0400
+#define _WIN32_DCOM
+
+#include <atlbase.h>
+CComModule _Module;
+#include <atlcom.h>
+
+BEGIN_OBJECT_MAP(ObjectMap)
+END_OBJECT_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// DLL Entry Point
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ _Module.Init(ObjectMap, hInstance, NULL);
+ DisableThreadLibraryCalls(hInstance);
+ }
+ else if (dwReason == DLL_PROCESS_DETACH)
+ {
+ _Module.Term();
+ }
+ return TRUE; // ok
+}
+
diff --git a/embedserv/source/embed/guid.cxx b/embedserv/source/embed/guid.cxx
new file mode 100755
index 000000000000..ab62b048acf3
--- /dev/null
+++ b/embedserv/source/embed/guid.cxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * $RCSfile: guid.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:50:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "common.h"
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+
+
+::rtl::OUString getServiceNameFromGUID_Impl( GUID* guid )
+{
+ if ( *guid == OID_WriterTextServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.TextDocument" ) );
+
+ if ( *guid == OID_WriterWebServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.WebDocument" ) );
+
+ if ( *guid == OID_WriterGlobalServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.GlobalDocument" ) );
+
+ if ( *guid == OID_CalcServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Calc.SpreadsheetDocument" ) );
+
+ if ( *guid == OID_DrawingServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.DrawingDocument" ) );
+
+ if ( *guid == OID_PresentationServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.PresentationDocument" ) );
+
+ if ( *guid == OID_MathServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Math.FormulaDocument" ) );
+
+ return ::rtl::OUString();
+}
+
+::rtl::OUString getFilterNameFromGUID_Impl( GUID* guid )
+{
+ if ( *guid == OID_WriterTextServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Writer)" ) );
+
+ if ( *guid == OID_WriterWebServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "HTML" ) );
+
+ if ( *guid == OID_WriterGlobalServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "writer_globaldocument_StarOffice_XML_Writer_GlobalDocument" ) );
+
+ if ( *guid == OID_CalcServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Calc)" ) );
+
+ if ( *guid == OID_DrawingServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Draw)" ) );
+
+ if ( *guid == OID_PresentationServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Impress)" ) );
+
+ if ( *guid == OID_MathServer )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Math)" ) );
+
+ return ::rtl::OUString();
+}
+
+/*
+::rtl::OUString getCurTypeNameFromGUID_Impl( const uno::Reference< lang::XMultiServiceFactory > xFactory, GUID* guid )
+{
+ ::rtl::OUString aResult;
+
+ const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.document.FilterFactory" ) );
+ uno::Reference < container::XNameAccess > xFilters = uno::Reference < io::XOutputStream > (
+ xFactory->createInstance ( aServiceName ),
+ uno::UNO_QUERY );
+
+ if ( xFilters.is() )
+ {
+ ::rtl::OUString aFilterName = getFilterNameFromGUID_Impl( guid );
+ if ( aFilterName.getLength() )
+ {
+ uno::Any aAnyProp = xFilters->getByName( aFilterName );
+ uno::Sequence< beans::PropertyValue > aProperties;
+ if ( aAnyProp >>= aProperties ) )
+ {
+ for ( sal_Int32 nInd = 0; nInd < aProperties.getLength; nInd++ )
+ if ( aProperties[nInd].Name.equalsAscii( "UIName" )
+ {
+ aProperties[nInd].Value >>= aResult;
+ break;
+ }
+ }
+ }
+ }
+
+ return aResult;
+}
+*/
+
+
diff --git a/embedserv/source/embed/makefile.mk b/embedserv/source/embed/makefile.mk
new file mode 100755
index 000000000000..399ae29027b4
--- /dev/null
+++ b/embedserv/source/embed/makefile.mk
@@ -0,0 +1,101 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: mav $ $Date: 2003-03-05 15:50:09 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+#MKDEPENDSOLVER=YES
+
+PRJ=..$/..
+
+PRJNAME=embedserv
+TARGET=emser
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+LIBTARGET=NO
+USE_DEFFILE=NO
+
+INCPRE+= $(SOLARINCDIR)$/external$/atl
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/register.obj \
+ $(SLO)$/servprov.obj \
+ $(SLO)$/ed_ipersiststr.obj \
+ $(SLO)$/ed_idataobj.obj \
+ $(SLO)$/ed_ioleobject.obj \
+ $(SLO)$/guid.obj \
+ $(SLO)$/esdll.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/register.obj \
+ $(SLO)$/ed_ipersiststr.obj \
+ $(SLO)$/ed_idataobj.obj
+
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/embedserv/source/embed/register.cxx b/embedserv/source/embed/register.cxx
new file mode 100755
index 000000000000..38ca40034d8a
--- /dev/null
+++ b/embedserv/source/embed/register.cxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * $RCSfile: register.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:50:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//#include <rtl/unload.h>
+//#include <osl/time.h>
+#include "servprov.hxx"
+
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_INVALIDREGISTRYEXCEPTION_HPP_
+#include <com/sun/star/registry/InvalidRegistryException.hpp>
+#endif
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+using namespace ::com::sun::star;
+
+
+uno::Reference<uno::XInterface> SAL_CALL EmbedServer_createInstance(
+ const uno::Reference<lang::XMultiServiceFactory> & xSMgr)
+ throw (uno::Exception)
+{
+ uno::Reference<uno::XInterface > xService = *new EmbedServer_Impl( xSMgr );
+ return xService;
+}
+
+::rtl::OUString SAL_CALL EmbedServer_getImplementationName() throw()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.EmbedServer") );
+
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL EmbedServer_getSupportedServiceNames() throw()
+{
+ uno::Sequence< ::rtl::OUString > aServiceNames( 1 );
+ aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.bridge.OleApplicationRegistration" ) );
+ return aServiceNames;
+}
+
+extern "C" {
+
+void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplName ) );
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
+
+ if(pServiceManager && aImplName.equals( EmbedServer_getImplementationName() ) )
+ {
+ xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>(pServiceManager),
+ EmbedServer_getImplementationName(),
+ EmbedServer_createInstance,
+ EmbedServer_getSupportedServiceNames() );
+ }
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+
+ return pRet;
+}
+
+sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ uno::Reference< registry::XRegistryKey > xKey( reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ) );
+
+ uno::Reference< registry::XRegistryKey > xNewKey;
+
+ xNewKey = xKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
+ EmbedServer_getImplementationName() +
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
+
+ uno::Sequence< ::rtl::OUString > &rServices = EmbedServer_getSupportedServiceNames();
+ for( sal_Int32 ind = 0; ind < rServices.getLength(); ind++ )
+ xNewKey->createKey( rServices.getConstArray()[ind] );
+
+ return sal_True;
+ }
+ catch (registry::InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+
+} // extern "C"
+
diff --git a/embedserv/source/embed/servprov.cxx b/embedserv/source/embed/servprov.cxx
new file mode 100755
index 000000000000..9efcb668761a
--- /dev/null
+++ b/embedserv/source/embed/servprov.cxx
@@ -0,0 +1,286 @@
+/*************************************************************************
+ *
+ * $RCSfile: servprov.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:50:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "servprov.hxx"
+#include "embeddoc.hxx"
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#include <vos/thread.hxx>
+
+using namespace com::sun::star;
+
+const GUID* guidList[ SUPPORTED_FACTORIES_NUM ] = {
+ &OID_WriterTextServer,
+ &OID_WriterWebServer,
+ &OID_WriterGlobalServer,
+ &OID_CalcServer,
+ &OID_DrawingServer,
+ &OID_PresentationServer,
+ &OID_MathServer
+};
+
+
+// CoInitializeEx *
+typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInitEx)( LPVOID, DWORD);
+// CoInitialize *
+typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInit)( LPVOID);
+
+void o2u_attachCurrentThread()
+{
+ static ::vos::OThreadData oleThreadData;
+
+ if ((sal_Bool)oleThreadData.getData() != sal_True)
+ {
+ HINSTANCE inst= LoadLibrary( _T("ole32.dll"));
+ if( inst )
+ {
+ HRESULT hr;
+ ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress( inst, _T("CoInitializeEx"));
+ if( initFuncEx)
+ hr= initFuncEx( NULL, COINIT_MULTITHREADED);
+ else
+ {
+ ptrCoInit initFunc= (ptrCoInit)GetProcAddress( inst,_T("CoInitialize"));
+ if( initFunc)
+ hr= initFunc( NULL);
+ }
+ }
+ oleThreadData.setData((void*)sal_True);
+ }
+}
+
+
+//===============================================================================
+// EmbedServer_Impl
+
+EmbedServer_Impl::EmbedServer_Impl( const uno::Reference<lang::XMultiServiceFactory>& xFactory):
+ m_xFactory( xFactory)
+{
+ for( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ )
+ {
+ m_pOLEFactories[nInd] = new EmbedProviderFactory_Impl( m_xFactory, guidList[nInd] );
+ m_pOLEFactories[nInd]->registerClass();
+ }
+}
+
+EmbedServer_Impl::~EmbedServer_Impl()
+{
+ for( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ )
+ {
+ if ( m_pOLEFactories[nInd] )
+ m_pOLEFactories[nInd]->deregisterClass();
+ }
+}
+
+// XInterface --------------------------------------------------
+uno::Any SAL_CALL EmbedServer_Impl::queryInterface( const uno::Type& aType ) throw(uno::RuntimeException)
+{
+ uno::Any a= ::cppu::queryInterface( aType, static_cast<lang::XTypeProvider*>(this));
+ if( a == uno::Any())
+ return OWeakObject::queryInterface( aType);
+ else
+ return a;
+}
+
+void SAL_CALL EmbedServer_Impl::acquire( ) throw(uno::RuntimeException)
+{
+ OWeakObject::acquire();
+}
+
+void SAL_CALL EmbedServer_Impl::release( ) throw (uno::RuntimeException)
+{
+ OWeakObject::release();
+}
+
+
+// XTypeProvider --------------------------------------------------
+uno::Sequence< uno::Type > SAL_CALL EmbedServer_Impl::getTypes( ) throw(uno::RuntimeException)
+{
+ static ::cppu::OTypeCollection *pCollection = 0;
+ if( ! pCollection )
+ {
+ ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! pCollection )
+ {
+ static ::cppu::OTypeCollection collection(
+ getCppuType(reinterpret_cast< uno::Reference< uno::XWeak>*>(0)),
+ getCppuType(reinterpret_cast< uno::Reference< lang::XTypeProvider>*>(0)) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL EmbedServer_Impl::getImplementationId() throw(uno::RuntimeException)
+{
+ static ::cppu::OImplementationId *pId = 0;
+ if( ! pId )
+ {
+ ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! pId )
+ {
+ static ::cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//===============================================================================
+// EmbedProviderFactory_Impl
+
+EmbedProviderFactory_Impl::EmbedProviderFactory_Impl(const uno::Reference<lang::XMultiServiceFactory>& xFactory, const GUID* pGuid)
+ : m_refCount( 0L )
+ , m_xFactory( xFactory )
+ , m_guid( *pGuid )
+{
+}
+
+EmbedProviderFactory_Impl::~EmbedProviderFactory_Impl()
+{
+}
+
+sal_Bool EmbedProviderFactory_Impl::registerClass()
+{
+ HRESULT hresult;
+
+ o2u_attachCurrentThread();
+
+ hresult = CoRegisterClassObject(
+ m_guid,
+ this,
+ CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &m_factoryHandle);
+
+ return (hresult == NOERROR);
+}
+
+sal_Bool EmbedProviderFactory_Impl::deregisterClass()
+{
+ HRESULT hresult = CoRevokeClassObject( m_factoryHandle );
+
+ return (hresult == NOERROR);
+}
+
+STDMETHODIMP EmbedProviderFactory_Impl::QueryInterface(REFIID riid, void FAR* FAR* ppv)
+{
+ if(IsEqualIID(riid, IID_IUnknown))
+ {
+ AddRef();
+ *ppv = (IUnknown*) (IClassFactory*) this;
+ return NOERROR;
+ }
+ else if (IsEqualIID(riid, IID_IClassFactory))
+ {
+ AddRef();
+ *ppv = (IClassFactory*) this;
+ return NOERROR;
+ }
+
+ *ppv = NULL;
+ return ResultFromScode(E_NOINTERFACE);
+}
+
+STDMETHODIMP_(ULONG) EmbedProviderFactory_Impl::AddRef()
+{
+ return osl_incrementInterlockedCount( &m_refCount);
+}
+
+STDMETHODIMP_(ULONG) EmbedProviderFactory_Impl::Release()
+{
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex());
+ m_refCount--;
+ if (m_refCount == 0)
+ {
+ delete this;
+ }
+
+ return m_refCount;
+}
+
+STDMETHODIMP EmbedProviderFactory_Impl::CreateInstance(IUnknown FAR* punkOuter,
+ REFIID riid,
+ void FAR* FAR* ppv)
+{
+ punkOuter = NULL;
+
+ IUnknown* pEmbedDocument = (IUnknown*)(IPersistStorage*)( new EmbedDocument_Impl( m_xFactory, &m_guid ) );
+
+ return pEmbedDocument->QueryInterface( riid, ppv );
+}
+
+STDMETHODIMP EmbedProviderFactory_Impl::LockServer( int fLock )
+{
+ return NOERROR;
+}
+
diff --git a/embedserv/source/embed/stdafx.cpp b/embedserv/source/embed/stdafx.cpp
new file mode 100755
index 000000000000..7f85904a1610
--- /dev/null
+++ b/embedserv/source/embed/stdafx.cpp
@@ -0,0 +1,13 @@
+// stdafx1.cpp : source file that includes just the standard includes
+// stdafx1.pch will be the pre-compiled header
+// stdafx1.obj will contain the pre-compiled type information
+
+#include "stdafx2.h"
+
+#ifdef _ATL_STATIC_REGISTRY
+#include <statreg.h>
+#include <statreg.cpp>
+#endif
+
+#include <atlimpl.cpp>
+
diff --git a/embedserv/source/inc/common.h b/embedserv/source/inc/common.h
new file mode 100755
index 000000000000..f61bb4228cf9
--- /dev/null
+++ b/embedserv/source/inc/common.h
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * $RCSfile: common.h,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:49:19 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#include "stdafx.h"
+#include <initguid.h>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+
+#define SUPPORTED_FACTORIES_NUM 7
+
+namespace com { namespace sun { namespace star {
+ namespace lang {
+ class XMultiServiceFactory;
+ }
+ namespace frame {
+ class XModel;
+ }
+ namespace beans {
+ struct PropertyValue;
+ }
+ namespace io {
+ class XInputStream;
+ class XOutputStream;
+ }
+} } }
+
+const sal_Int32 nConstBufferSize = 32000;
+
+
+// {30A2652A-DDF7-45e7-ACA6-3EAB26FC8A4E}
+DEFINE_GUID(OID_WriterTextServer, 0x30a2652a, 0xddf7, 0x45e7, 0xac, 0xa6, 0x3e, 0xab, 0x26, 0xfc, 0x8a, 0x4e );
+
+// {43FEEA23-228B-4726-AFFE-214598F47289}
+DEFINE_GUID(OID_WriterWebServer, 0x43feea23, 0x228b, 0x4726, 0xaf, 0xfe, 0x21, 0x45, 0x98, 0xf4, 0x72, 0x89 );
+
+// {1386E9B2-8706-438b-BF51-5CA7864770C5}
+DEFINE_GUID(OID_WriterGlobalServer, 0x1386e9b2, 0x8706, 0x438b, 0xbf, 0x51, 0x5c, 0xa7, 0x86, 0x47, 0x70, 0xc5 );
+
+// {7B342DC4-139A-4a46-8A93-DB0827CCEE9C}
+DEFINE_GUID(OID_CalcServer, 0x7b342dc4, 0x139a, 0x4a46, 0x8a, 0x93, 0xdb, 0x8, 0x27, 0xcc, 0xee, 0x9c );
+
+// {41662FC2-0D57-4aff-AB27-AD2E12E7C273}
+DEFINE_GUID(OID_DrawingServer, 0x41662fc2, 0xd57, 0x4aff, 0xab, 0x27, 0xad, 0x2e, 0x12, 0xe7, 0xc2, 0x73 );
+
+// {E5A0B632-DFBA-4549-9346-E414DA06E6F8}
+DEFINE_GUID(OID_PresentationServer, 0xe5a0b632, 0xdfba, 0x4549, 0x93, 0x46, 0xe4, 0x14, 0xda, 0x6, 0xe6, 0xf8 );
+
+// {D0484DE6-AAEE-468a-991F-8D4B0737B57A}
+DEFINE_GUID(OID_MathServer, 0xd0484de6, 0xaaee, 0x468a, 0x99, 0x1f, 0x8d, 0x4b, 0x7, 0x37, 0xb5, 0x7a );
+
+
+#endif
+
diff --git a/embedserv/source/inc/embeddoc.hxx b/embedserv/source/inc/embeddoc.hxx
new file mode 100755
index 000000000000..e581ce904326
--- /dev/null
+++ b/embedserv/source/inc/embeddoc.hxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ *
+ * $RCSfile: embeddoc.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:49:20 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _EMBEDDOC_HXX_
+#define _EMBEDDOC_HXX_
+
+#include "common.h"
+#include <oleidl.h>
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#include <com/sun/star/uno/Reference.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
+#include <com/sun/star/uno/SEQUENCE.h>
+#endif
+
+
+class GDIMetaFile;
+
+class EmbedDocument_Impl : public IPersistStorage
+ , public IDataObject
+ , public IOleObject
+{
+protected:
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ fillArgsForLoading_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xStream,
+ DWORD nStreamMode );
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ fillArgsForStoring_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xStream );
+
+ HRESULT SaveTo_Impl( IStorage* pStg );
+
+ sal_uInt64 getMetaFileHandle_Impl( sal_Bool isEnhMeta );
+
+public:
+ EmbedDocument_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& smgr,
+ const GUID* guid );
+ ~EmbedDocument_Impl();
+
+ /* IUnknown methods */
+ STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
+ STDMETHOD_(ULONG, AddRef)();
+ STDMETHOD_(ULONG, Release)();
+
+ /* IPersistMethod */
+ STDMETHOD(GetClassID)(CLSID *pClassID);
+
+ /* IPersistStorage methods */
+ STDMETHOD(IsDirty) ();
+ STDMETHOD(InitNew) ( IStorage *pStg );
+ STDMETHOD(Load) ( IStorage* pStr );
+ STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad );
+ STDMETHOD(SaveCompleted) ( IStorage *pStgNew );
+ STDMETHOD(HandsOffStorage) (void);
+
+ /* IDataObject methods */
+ STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
+ STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
+ STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc );
+ STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut );
+ STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease );
+ STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc );
+ STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection );
+ STDMETHOD(DUnadvise) ( DWORD dwConnection );
+ STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise );
+
+ /* IOleObject methods */
+ STDMETHOD(SetClientSite) ( IOleClientSite* pSite );
+ STDMETHOD(GetClientSite) ( IOleClientSite** pSite );
+ STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj );
+ STDMETHOD(Close) ( DWORD dwSaveOption);
+ STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk );
+ STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk );
+ STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved );
+ STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject );
+ STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect );
+ STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb );
+ STDMETHOD(Update) ();
+ STDMETHOD(IsUpToDate) ();
+ STDMETHOD(GetUserClassID) ( CLSID *pClsid );
+ STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType );
+ STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
+ STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
+ STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection );
+ STDMETHOD(Unadvise) ( DWORD dwConnection );
+ STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise );
+ STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus );
+ STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal );
+
+protected:
+ oslInterlockedCount m_refCount;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocument;
+
+ CComPtr< IStorage > m_pMasterStorage;
+ CComPtr< IStream > m_pOwnStream;
+ GUID m_guid;
+
+ sal_Bool m_bIsDirty;
+
+ CComPtr< IOleClientSite > m_pClientSite;
+};
+
+#endif //_EMBEDDOC_HXX_
+
diff --git a/embedserv/source/inc/servprov.hxx b/embedserv/source/inc/servprov.hxx
new file mode 100755
index 000000000000..8a4f1ccf581c
--- /dev/null
+++ b/embedserv/source/inc/servprov.hxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * $RCSfile: servprov.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2003-03-05 15:49:20 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SERVPROV_HXX
+#define _SERVPROV_HXX
+
+#include "common.h"
+#include <oleidl.h>
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#include <com/sun/star/uno/Reference.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
+#include <com/sun/star/uno/Sequence.h>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
+#include <com/sun/star/uno/XInterface.hpp>
+#endif
+#ifndef __COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+
+class EmbedProviderFactory_Impl;
+
+class EmbedServer_Impl : public ::cppu::OWeakObject, ::com::sun::star::lang::XTypeProvider
+{
+public:
+ EmbedServer_Impl( const ::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> &xFactory );
+ ~EmbedServer_Impl();
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL release() throw (::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+
+ CComPtr< EmbedProviderFactory_Impl > m_pOLEFactories[ SUPPORTED_FACTORIES_NUM ];
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
+};
+
+class EmbedProviderFactory_Impl : public IClassFactory
+{
+public:
+
+ EmbedProviderFactory_Impl( const ::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory>& xFactory, const GUID* pGuid);
+ ~EmbedProviderFactory_Impl();
+
+ sal_Bool registerClass();
+ sal_Bool deregisterClass();
+
+ /* IUnknown methods */
+ STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
+ STDMETHOD_(ULONG, AddRef)();
+ STDMETHOD_(ULONG, Release)();
+
+ /* IClassFactory methods */
+ STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv);
+ STDMETHOD(LockServer)(int fLock);
+
+protected:
+
+ oslInterlockedCount m_refCount;
+ GUID m_guid;
+ DWORD m_factoryHandle;
+
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
+};
+
+#endif
+
diff --git a/embedserv/source/inc/stdafx.h b/embedserv/source/inc/stdafx.h
new file mode 100755
index 000000000000..51530f054cd8
--- /dev/null
+++ b/embedserv/source/inc/stdafx.h
@@ -0,0 +1,26 @@
+#if !defined(AFX_STDAFX_H_)
+#define AFX_STDAFX_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#define _ATL_APARTMENT_THREADED
+// #define _ATL_STATIC_REGISTRY
+
+#include <atlbase.h>
+//You may derive a class from CComModule and use it if you want to override
+//something, but do not change the name of _Module
+extern CComModule _Module;
+#include <atlcom.h>
+#include <atlctl.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif
+