summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2002-08-14 13:41:00 +0000
committerMikhail Voitenko <mav@openoffice.org>2002-08-14 13:41:00 +0000
commit11b436d3ec0296e1d9886a3c1b2048e782181a50 (patch)
treeac0ffd1055f930740ddd3c6fc2f7f3e706e0ce38 /extensions
parentcc2a3b29a6c15226637b03f6ab01b5728af6dc9c (diff)
#101937# initial revision
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/activex/main/README.txt33
-rw-r--r--extensions/source/activex/main/SOActiveX.cpp661
-rw-r--r--extensions/source/activex/main/SOActiveX.h137
-rw-r--r--extensions/source/activex/main/SOActiveX.rgs33
-rw-r--r--extensions/source/activex/main/SOComWindowPeer.cpp24
-rw-r--r--extensions/source/activex/main/SOComWindowPeer.h128
-rw-r--r--extensions/source/activex/main/SOComWindowPeer.rgs23
-rw-r--r--extensions/source/activex/main/SODispatchInterceptor.cpp169
-rw-r--r--extensions/source/activex/main/SODispatchInterceptor.h151
-rw-r--r--extensions/source/activex/main/SODispatchInterceptor.rgs23
-rw-r--r--extensions/source/activex/main/StdAfx2.cpp12
-rw-r--r--extensions/source/activex/main/StdAfx2.h31
-rw-r--r--extensions/source/activex/main/com_uno_helper.h24
-rw-r--r--extensions/source/activex/main/example.html26
-rw-r--r--extensions/source/activex/main/makefile.mk89
-rw-r--r--extensions/source/activex/main/resource.h24
-rw-r--r--extensions/source/activex/main/so_activex.cpp259
-rw-r--r--extensions/source/activex/main/so_activex.rc105
18 files changed, 1952 insertions, 0 deletions
diff --git a/extensions/source/activex/main/README.txt b/extensions/source/activex/main/README.txt
new file mode 100644
index 000000000000..9d647987aaa7
--- /dev/null
+++ b/extensions/source/activex/main/README.txt
@@ -0,0 +1,33 @@
+ Description.
+
+The StarOffice ActiveX control shows an example of access to UNO through COM technology.
+It requires a properly installed StarOffice version 6.0/6.1 or OpenOffice 1.0.
+This is a Lite ActiveX control so it can be used only in containers that
+allows to use such controls.
+
+Pressing to any link to staroffice document should activate the control.
+So the document will be opened in ReadOnly mode.
+
+Also it can be activated with an <OBJECT> tag from a html-page.
+Without any parameters for an object tag a new writer document will be
+opened for editing. Possible parameters are
+ src - full URL to the file that should be edited/viewed;
+ it can contain "private:factory/..." URLs to open new documents
+ for edit, for example "private:factory/swriter"
+ readonly - the default value is "true", in case it is set to any other
+ value the document is opened for editing
+
+As any ActiveX control this one should be registered.
+To let MSIE register it itself the "CODEBASE" parameter
+for the "OBJECT" tag should be specified
+with an URL to the library "so_activex.dll".
+The example of registration with "OBJECT" tag is in example.html.
+
+Also it can be done using regsvr32 application.
+To do it please write
+<Path to Windows installation>\System32\regsvr32 so_activex.dll
+
+To unregister the control please use /u option:
+<Path to Windows installation>\system32\regsvr32 so_activex.dll /u
+
+
diff --git a/extensions/source/activex/main/SOActiveX.cpp b/extensions/source/activex/main/SOActiveX.cpp
new file mode 100644
index 000000000000..d93e87b2a02e
--- /dev/null
+++ b/extensions/source/activex/main/SOActiveX.cpp
@@ -0,0 +1,661 @@
+// SOActiveX.cpp : Implementation of CSOActiveX
+
+#include "stdafx2.h"
+#include "so_activex.h"
+#include "SOActiveX.h"
+#include "SOComWindowPeer.h"
+#include "SODispatchInterceptor.h"
+
+#define STAROFFICE_WINDOWCLASS "SOParentWindow"
+
+/////////////////////////////////////////////////////////////////////////////
+
+HRESULT ExecuteFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComVariant* pResult )
+{
+ if( !idispUnoObject )
+ return E_FAIL;
+
+ DISPID id;
+ HRESULT hr = idispUnoObject->GetIDsOfNames( IID_NULL, &sFuncName, 1, LOCALE_USER_DEFAULT, &id);
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ DISPPARAMS dispparams= { params, 0, count, 0};
+
+ // DEBUG
+ EXCEPINFO myInfo;
+ return idispUnoObject->Invoke( id, IID_NULL,LOCALE_USER_DEFAULT, DISPATCH_METHOD,
+ &dispparams, pResult, &myInfo, 0);
+}
+
+HRESULT GetIDispByFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComPtr<IDispatch>& pdispResult )
+{
+ if( !idispUnoObject )
+ return E_FAIL;
+
+ CComVariant result;
+ HRESULT hr = ExecuteFunc( idispUnoObject, sFuncName, params, count, &result );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( result.vt != VT_DISPATCH || result.pdispVal == NULL )
+ return E_FAIL;
+
+ pdispResult = CComPtr<IDispatch>( result.pdispVal );
+
+ return S_OK;
+}
+
+HRESULT PutPropertiesToIDisp( IDispatch* pdispObject,
+ OLECHAR** sMemberNames,
+ CComVariant* pVariant,
+ unsigned int count )
+{
+ for( unsigned int ind = 0; ind < count; ind++ )
+ {
+ DISPID id;
+ HRESULT hr = pdispObject->GetIDsOfNames( IID_NULL, &sMemberNames[ind], 1, LOCALE_USER_DEFAULT, &id );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = CComDispatchDriver::PutProperty( pdispObject, id, &pVariant[ind] );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ return S_OK;
+}
+
+HRESULT GetPropertiesFromIDisp( IDispatch* pdispObject,
+ OLECHAR** sMemberNames,
+ CComVariant* pVariant,
+ unsigned int count )
+{
+ for( unsigned int ind = 0; ind < count; ind++ )
+ {
+ DISPID id;
+ HRESULT hr = pdispObject->GetIDsOfNames( IID_NULL, &sMemberNames[ind], 1, LOCALE_USER_DEFAULT, &id );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = CComDispatchDriver::GetProperty( pdispObject, id, &pVariant[ind] );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ return S_OK;
+}
+/////////////////////////////////////////////////////////////////////////////
+// CSOActiveX
+
+CSOActiveX::CSOActiveX()
+: mCookie(0)
+, mCurFileUrl( L"private:factory/swriter" )
+, mbLoad( FALSE )
+, mParentWin( NULL )
+, mOffWin( NULL )
+, mbViewOnly( TRUE )
+, mpDispatchInterceptor( NULL )
+{
+ CLSID clsFactory = {0x82154420,0x0FBF,0x11d4,{0x83, 0x13,0x00,0x50,0x04,0x52,0x6A,0xB4}};
+ HRESULT hr = CoCreateInstance( clsFactory, NULL, CLSCTX_ALL, __uuidof(IDispatch), (void**)&mpDispFactory);
+
+ mPWinClass.style = CS_HREDRAW|CS_VREDRAW;
+ mPWinClass.lpfnWndProc = ::DefWindowProc;
+ mPWinClass.cbClsExtra = 0;
+ mPWinClass.cbWndExtra = 0;
+ mPWinClass.hInstance = (HINSTANCE) GetModuleHandle(NULL); //myInstance;
+ mPWinClass.hIcon = NULL;
+ mPWinClass.hCursor = NULL;
+ mPWinClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
+ mPWinClass.lpszMenuName = NULL;
+ mPWinClass.lpszClassName = STAROFFICE_WINDOWCLASS;
+
+ RegisterClass(&mPWinClass);
+}
+
+CSOActiveX::~CSOActiveX()
+{
+ Cleanup();
+
+}
+
+HRESULT CSOActiveX::Cleanup()
+{
+ CComVariant dummyResult;
+
+ /*
+ if( mpDispatchInterceptor )
+ {
+ mpDispatchInterceptor->ClearParent();
+ if( mpDispFrame )
+ {
+ // remove dispatch interceptor
+ CComQIPtr< IDispatch, &IID_IDispatch > pIDispDispInter( mpDispatchInterceptor );
+ ExecuteFunc( mpDispFrame,
+ L"releaseDispatchProviderInterceptor",
+ &CComVariant( pIDispDispInter ),
+ 1,
+ &dummyResult );
+ mpDispatchInterceptor->Release();
+ mpDispatchInterceptor = NULL;
+ }
+ }
+ */
+
+ if( mpDispFrame )
+ {
+ // mpDispFrame->dispose();
+ ExecuteFunc( mpDispFrame, L"dispose", NULL, 0, &dummyResult );
+ mpDispFrame = CComPtr< IDispatch >();
+ }
+
+ if( ::IsWindow( mOffWin ) )
+ ::DestroyWindow( mOffWin );
+
+ return S_OK;
+}
+
+
+STDMETHODIMP CSOActiveX::InitNew ()
+{
+ mbLoad = TRUE;
+ return S_OK;
+}
+
+STDMETHODIMP CSOActiveX::Load ( LPSTREAM pStm )
+{
+ mbLoad = TRUE;
+
+ // may be later?
+ // for now just ignore
+
+ return S_OK;
+}
+
+STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog )
+{
+ IPropertyBag2* pPropBag2;
+ HRESULT hr = pPropBag->QueryInterface( IID_IPropertyBag2, (void**)&pPropBag2 );
+ ATLASSERT( hr >= 0 );
+
+ if( !SUCCEEDED( hr ) )
+ return hr;
+
+ unsigned long aNum;
+ hr = pPropBag2->CountProperties( &aNum );
+ ATLASSERT( hr >= 0 );
+ if( !SUCCEEDED( hr ) )
+ return hr;
+
+ PROPBAG2* aPropNames = new PROPBAG2[aNum];
+ unsigned long aReaded;
+
+ hr = pPropBag2->GetPropertyInfo( 0,
+ aNum,
+ aPropNames,
+ &aReaded );
+ ATLASSERT( hr >= 0 );
+ if( !SUCCEEDED( hr ) )
+ {
+ delete[] aPropNames;
+ return hr;
+ }
+
+ CComVariant* aVal = new CComVariant[aNum];
+ HRESULT* hvs = new HRESULT[aNum];
+ hr = pPropBag2->Read( aNum,
+ aPropNames,
+ NULL,
+ aVal,
+ hvs );
+ ATLASSERT( hr >= 0 );
+ if( !SUCCEEDED( hr ) )
+ {
+ delete[] hvs;
+ delete[] aVal;
+ delete[] aPropNames;
+ return hr;
+ }
+
+ USES_CONVERSION;
+ for( unsigned long ind = 0; ind < aNum; ind++ )
+ {
+ // all information from the 'object' tag is in strings
+ if( aVal[ind].vt == VT_BSTR && !strcmp( OLE2T( aPropNames[ind].pstrName ), "src" ) )
+ {
+ mCurFileUrl = wcsdup( aVal[ind].bstrVal );
+ }
+ else if( aVal[ind].vt == VT_BSTR
+ && !strcmp( OLE2T( aPropNames[ind].pstrName ), "readonly" ) )
+ {
+ if( !strcmp( OLE2T( aVal[ind].bstrVal ), "true" ) )
+ {
+ // the default value
+ mbViewOnly = TRUE;
+ }
+ else
+ {
+ mbViewOnly = FALSE;
+ }
+ }
+ }
+
+ delete[] hvs;
+ delete[] aVal;
+ delete[] aPropNames;
+
+ if( !mpDispFactory )
+ return hr;
+
+ mbLoad = TRUE;
+
+ Invalidate();
+ UpdateWindow();
+
+ return hr;
+}
+
+HRESULT CSOActiveX::GetUnoStruct( OLECHAR* sStructName, CComPtr<IDispatch>& pdispResult )
+{
+ return GetIDispByFunc( mpDispFactory, L"Bridge_GetStruct", &CComVariant( sStructName ), 1, pdispResult );
+}
+
+HRESULT CSOActiveX::GetUrlStruct( OLECHAR* sUrl, CComPtr<IDispatch>& pdispUrl )
+{
+ HRESULT hr = GetUnoStruct( L"com.sun.star.util.URL", pdispUrl );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sURLMemberName = L"Complete";
+ DISPID nURLID;
+ hr = pdispUrl->GetIDsOfNames( IID_NULL, &sURLMemberName, 1, LOCALE_USER_DEFAULT, &nURLID );
+ if( !SUCCEEDED( hr ) ) return hr;
+ hr = CComDispatchDriver::PutProperty( pdispUrl, nURLID, &CComVariant( sUrl ) );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComPtr<IDispatch> pdispTransformer;
+ hr = GetIDispByFunc( mpDispFactory,
+ L"createInstance",
+ &CComVariant( L"com.sun.star.util.URLTransformer" ),
+ 1,
+ pdispTransformer );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant dummyResult;
+ CComVariant aInOutParam;
+ aInOutParam.ppdispVal = &pdispUrl;
+ aInOutParam.vt = VT_DISPATCH | VT_BYREF;
+ hr = ExecuteFunc( pdispTransformer, L"parseStrict", &aInOutParam, 1, &dummyResult );
+ if( !SUCCEEDED( hr ) || dummyResult.vt != VT_BOOL || !dummyResult.boolVal ) return hr;
+
+ return S_OK;
+}
+
+
+HRESULT CSOActiveX::CreateFrameOldWay( HWND hwnd, int width, int height )
+{
+ if( !mpDispFactory )
+ return E_FAIL;
+
+ // create window handle holder
+ CComPtr< CComObject< SOComWindowPeer > > pPeerToSend = new CComObject<SOComWindowPeer>();
+ pPeerToSend->SetHWNDInternally( hwnd );
+ CComQIPtr< IDispatch, &IID_IDispatch > pIDispToSend( pPeerToSend );
+
+ // create rectangle structure
+ CComPtr<IDispatch> pdispRectangle;
+ HRESULT hr = GetUnoStruct( L"com.sun.star.awt.Rectangle", pdispRectangle );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sRectMemberNames[4] = { L"X",
+ L"Y",
+ L"Width",
+ L"Height" };
+ CComVariant pRectVariant[4];
+ pRectVariant[0] = pRectVariant[1] = pRectVariant[2] = pRectVariant[3] = CComVariant( 0 );
+
+ hr = PutPropertiesToIDisp( pdispRectangle, sRectMemberNames, pRectVariant, 4 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create WindowDescriptor structure
+ CComPtr<IDispatch> pdispWinDescr;
+ hr = GetUnoStruct( L"com.sun.star.awt.WindowDescriptor", pdispWinDescr );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // fill in descriptor with info
+ OLECHAR* sDescriptorMemberNames[6] = { L"Type",
+ L"WindowServiceName",
+ L"ParentIndex",
+ L"Parent",
+ L"Bounds",
+ L"WindowAttributes" };
+ CComVariant pDescriptorVar[6];
+ pDescriptorVar[0] = CComVariant( 0 );
+ pDescriptorVar[1] = CComVariant( L"workwindow" );
+ pDescriptorVar[2] = CComVariant( 1 );
+ pDescriptorVar[3] = CComVariant( pIDispToSend );
+ pDescriptorVar[4] = CComVariant( pdispRectangle );
+ pDescriptorVar[5] = CComVariant( 33 );
+ hr = PutPropertiesToIDisp( pdispWinDescr, sDescriptorMemberNames, pDescriptorVar, 6 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create XToolkit instance
+ CComPtr<IDispatch> pdispToolkit;
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &CComVariant( L"com.sun.star.awt.Toolkit" ), 1, pdispToolkit );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create window with toolkit
+ hr = GetIDispByFunc( pdispToolkit, L"createWindow", &CComVariant( pdispWinDescr ), 1, mpDispWin );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create frame
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &CComVariant( L"com.sun.star.frame.Task" ), 1, mpDispFrame );
+ if( !SUCCEEDED( hr ) || !mpDispFrame )
+ {
+ // the interface com.sun.star.frame.Task is removed in 6.1
+ // but the interface com.sun.star.frame.Frame has some bugs in 6.0
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &CComVariant( L"com.sun.star.frame.Frame" ), 1, mpDispFrame );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ // initialize frame
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispFrame, L"initialize", &CComVariant( mpDispWin ), 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create desktop
+ CComPtr<IDispatch> pdispDesktop;
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &CComVariant( L"com.sun.star.frame.Desktop" ), 1, pdispDesktop );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create tree of frames
+ CComPtr<IDispatch> pdispChildren;
+ hr = GetIDispByFunc( pdispDesktop, L"getFrames", NULL, 0, pdispChildren );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // insert new frame into desctop hierarchy
+ hr = ExecuteFunc( pdispChildren, L"append", &CComVariant( mpDispFrame ), 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // initialize window
+ hr = ExecuteFunc( mpDispWin, L"setBackground", &CComVariant( (long)0xFFFFFFFF ), 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = ExecuteFunc( mpDispWin, L"setVisible", &CComVariant( TRUE ), 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant aPosArgs[5];
+ aPosArgs[4] = CComVariant( 0 );
+ aPosArgs[3] = CComVariant( 0 );
+ aPosArgs[2] = CComVariant( width );
+ aPosArgs[1] = CComVariant( height );
+ aPosArgs[0] = CComVariant( 12 );
+ hr = ExecuteFunc( mpDispWin, L"setPosSize", aPosArgs, 5, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::CallLoadComponentFromURL1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal )
+{
+ SAFEARRAY FAR* pPropVals = SafeArrayCreateVector( VT_DISPATCH, 0, 1 );
+ long ix = 0;
+ CComPtr<IDispatch> pdispPropVal;
+ HRESULT hr = GetUnoStruct( L"com.sun.star.beans.PropertyValue", pdispPropVal );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sPropMemberNames[2] = { L"Name", L"Value" };
+ CComVariant pPropVar[2];
+ pPropVar[0] = CComVariant( sArgName );
+ pPropVar[1] = CComVariant(); pPropVar[1].vt = VT_BOOL; pPropVar[1].boolVal = sArgVal ? VARIANT_TRUE : VARIANT_FALSE ;
+ hr = PutPropertiesToIDisp( pdispPropVal, sPropMemberNames, pPropVar, 2 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ SafeArrayPutElement( pPropVals, &ix, pdispPropVal );
+
+ CComVariant aDispArgs[4];
+ aDispArgs[3] = CComVariant( sUrl );
+ aDispArgs[2] = CComVariant( L"_self" );
+ aDispArgs[1] = CComVariant( 0 );
+ // aDispArgs[0] = CComVariant( pPropVals ); such constructor is not defined ??!
+ aDispArgs[0] = CComVariant(); aDispArgs[0].vt = VT_ARRAY | VT_DISPATCH; aDispArgs[0].parray = pPropVals;
+
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispFrame, L"loadComponentFromURL", aDispArgs, 4, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::CallDispatch1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal )
+{
+ CComPtr<IDispatch> pdispURL;
+ HRESULT hr = GetUrlStruct( sUrl, pdispURL );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComPtr<IDispatch> pdispXDispatch;
+ CComVariant aArgs[3];
+ aArgs[2] = CComVariant( pdispURL );
+ aArgs[1] = CComVariant( L"" );
+ aArgs[0] = CComVariant( (int)0 );
+ hr = GetIDispByFunc( mpDispFrame,
+ L"queryDispatch",
+ aArgs,
+ 3,
+ pdispXDispatch );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ SAFEARRAY FAR* pPropVals = SafeArrayCreateVector( VT_DISPATCH, 0, 1 );
+ long ix = 0;
+ CComPtr<IDispatch> pdispPropVal;
+ hr = GetUnoStruct( L"com.sun.star.beans.PropertyValue", pdispPropVal );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sPropMemberNames[2] = { L"Name", L"Value" };
+ CComVariant pPropVar[2];
+ pPropVar[0] = CComVariant( sArgName );
+ pPropVar[1] = CComVariant(); pPropVar[1].vt = VT_BOOL; pPropVar[1].boolVal = sArgVal ? VARIANT_TRUE : VARIANT_FALSE ;
+ hr = PutPropertiesToIDisp( pdispPropVal, sPropMemberNames, pPropVar, 2 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ SafeArrayPutElement( pPropVals, &ix, pdispPropVal );
+
+ CComVariant aDispArgs[2];
+ aDispArgs[1] = CComVariant( pdispURL );
+ // aDispArgs[0] = CComVariant( pPropVals ); such constructor is not defined ??!
+ aDispArgs[0] = CComVariant(); aDispArgs[0].vt = VT_ARRAY | VT_DISPATCH; aDispArgs[0].parray = pPropVals;
+
+ CComVariant dummyResult;
+ hr = ExecuteFunc( pdispXDispatch, L"dispatch", aDispArgs, 2, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::LoadURLToFrame( )
+{
+ HRESULT hr = CallDispatch1PBool( mCurFileUrl, L"ReadOnly", mbViewOnly );
+
+ // can be used later
+ // HRESULT hr = CallLoadComponentFromURL1PBool( mCurFileUrl, L"ReadOnly", mbViewOnly );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ /*
+ // create dispatch interceptor
+ mpDispatchInterceptor = new CComObject< SODispatchInterceptor >();
+ mpDispatchInterceptor->AddRef();
+ mpDispatchInterceptor->SetParent( this );
+ CComQIPtr< IDispatch, &IID_IDispatch > pIDispDispInter( mpDispatchInterceptor );
+
+ // register dispatch interceptor in the frame
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispFrame,
+ L"registerDispatchProviderInterceptor",
+ &CComVariant( pIDispDispInter ),
+ 1,
+ &dummyResult );
+
+ if( !SUCCEEDED( hr ) ) return hr;
+ */
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di )
+{
+ if( m_spInPlaceSite && mCurFileUrl )
+ {
+ HWND hwnd;
+ HRESULT hr = m_spInPlaceSite->GetWindow( &hwnd );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( mParentWin != hwnd || !mOffWin )
+ {
+ if( mpDispFrame )
+ {
+ CComVariant dummyResult;
+ ExecuteFunc( mpDispFrame, L"dispose", NULL, 0, &dummyResult );
+ mpDispFrame = CComPtr<IDispatch>();
+ }
+
+ mParentWin = hwnd;
+ mOffWin = CreateWindow(
+ STAROFFICE_WINDOWCLASS,
+ "OfficeContainer",
+ WS_CHILD | WS_CLIPCHILDREN | WS_BORDER,
+ di.prcBounds->left,
+ di.prcBounds->top,
+ di.prcBounds->right - di.prcBounds->left,
+ di.prcBounds->bottom - di.prcBounds->top,
+ mParentWin,
+ NULL,
+ NULL,
+ NULL );
+
+ ::ShowWindow( mOffWin, SW_SHOW );
+ }
+ else
+ {
+ RECT aRect;
+ ::GetWindowRect( mOffWin, &aRect );
+
+ if( aRect.left != di.prcBounds->left || aRect.top != di.prcBounds->top
+ || aRect.right != di.prcBounds->right || aRect.bottom != di.prcBounds->bottom )
+ {
+ // on this state the office window should exist already
+ ::SetWindowPos( mOffWin,
+ HWND_TOP,
+ di.prcBounds->left,
+ di.prcBounds->top,
+ di.prcBounds->right - di.prcBounds->left,
+ di.prcBounds->bottom - di.prcBounds->top,
+ SWP_NOZORDER );
+
+ CComVariant aPosArgs[5];
+ aPosArgs[4] = CComVariant( 0 );
+ aPosArgs[3] = CComVariant( 0 );
+ aPosArgs[2] = CComVariant( int(di.prcBounds->right - di.prcBounds->left) );
+ aPosArgs[1] = CComVariant( int(di.prcBounds->bottom - di.prcBounds->top) );
+ aPosArgs[0] = CComVariant( 12 );
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispWin, L"setPosSize", aPosArgs, 5, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+ }
+
+ if( ! mpDispFrame )
+ {
+ hr = CreateFrameOldWay( mOffWin,
+ di.prcBounds->right - di.prcBounds->left,
+ di.prcBounds->bottom - di.prcBounds->top );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ if( mbLoad )
+ {
+ hr = LoadURLToFrame();
+ if( !SUCCEEDED( hr ) ) return hr;
+ mbLoad = FALSE;
+ }
+ }
+
+ return S_OK;
+}
+
+
+STDMETHODIMP CSOActiveX::SetClientSite( IOleClientSite* aClientSite )
+{
+ HRESULT hr = IOleObjectImpl<CSOActiveX>::SetClientSite( aClientSite );
+
+ if( !aClientSite )
+ {
+ ATLASSERT( mWebBrowser2 );
+ if( mWebBrowser2 )
+ AtlUnadvise( mWebBrowser2, DIID_DWebBrowserEvents2, mCookie );
+ return hr;
+ }
+
+ CComPtr<IOleContainer> aContainer;
+ m_spClientSite->GetContainer( &aContainer );
+ ATLASSERT( aContainer );
+
+ if( SUCCEEDED( hr ) && aContainer )
+ {
+ CComQIPtr<IServiceProvider, &IID_IServiceProvider> aServiceProvider( aContainer );
+ ATLASSERT( aServiceProvider );
+
+ if( aServiceProvider )
+ {
+ aServiceProvider->QueryService( SID_SInternetExplorer,
+ IID_IWebBrowser,
+ (void**)&mWebBrowser2 );
+ ATLASSERT( mWebBrowser2 );
+ if( mWebBrowser2 )
+ AtlAdvise( mWebBrowser2, GetUnknown(), DIID_DWebBrowserEvents2, &mCookie );
+ }
+ }
+
+ return hr;
+}
+
+STDMETHODIMP CSOActiveX::Invoke(DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS* pDispParams,
+ VARIANT* pvarResult,
+ EXCEPINFO* pExcepInfo,
+ UINT* puArgErr)
+{
+ if (riid != IID_NULL)
+ return DISP_E_UNKNOWNINTERFACE;
+
+ if (!pDispParams)
+ return DISP_E_PARAMNOTOPTIONAL;
+
+ if ( dispidMember == DISPID_ONQUIT )
+ Cleanup();
+
+ IDispatchImpl<ISOActiveX, &IID_ISOActiveX,
+ &LIBID_SO_ACTIVEXLib>::Invoke(
+ dispidMember, riid, lcid, wFlags, pDispParams,
+ pvarResult, pExcepInfo, puArgErr);
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::GetURL( const OLECHAR* url,
+ const OLECHAR* target )
+{
+ return mWebBrowser2->Navigate2( &CComVariant( url ),
+ &CComVariant(),
+ &CComVariant( target ),
+ &CComVariant(),
+ &CComVariant() );
+}
+
+
+// ---------------------------------------------------------------------------
+
diff --git a/extensions/source/activex/main/SOActiveX.h b/extensions/source/activex/main/SOActiveX.h
new file mode 100644
index 000000000000..89e2c88b43c5
--- /dev/null
+++ b/extensions/source/activex/main/SOActiveX.h
@@ -0,0 +1,137 @@
+// SOActiveX.h : Declaration of the CSOActiveX
+
+#ifndef __SOACTIVEX_H_
+#define __SOACTIVEX_H_
+
+#include "resource.h" // main symbols
+#include <ExDispID.h>
+#include <ExDisp.h>
+#include <shlguid.h>
+#include <atlctl.h>
+
+#include "so_activex.h"
+
+class SODispatchInterceptor;
+
+/////////////////////////////////////////////////////////////////////////////
+// CSOActiveX
+class ATL_NO_VTABLE CSOActiveX :
+ public CComObjectRootEx<CComSingleThreadModel>,
+ public IDispatchImpl<ISOActiveX, &IID_ISOActiveX, &LIBID_SO_ACTIVEXLib>,
+ public CComControl<CSOActiveX>,
+ public IPersistStreamInitImpl<CSOActiveX>,
+ public IOleControlImpl<CSOActiveX>,
+ public IOleObjectImpl<CSOActiveX>,
+ public IOleInPlaceActiveObjectImpl<CSOActiveX>,
+ public IViewObjectExImpl<CSOActiveX>,
+ public IOleInPlaceObjectWindowlessImpl<CSOActiveX>,
+// public IConnectionPointContainerImpl<CSOActiveX>,
+ public CComCoClass<CSOActiveX, &CLSID_SOActiveX>,
+// public CProxy_ItryPluginEvents< CSOActiveX >,
+ public IPersistPropertyBagImpl< CSOActiveX >,
+ public IProvideClassInfo2Impl< &CLSID_SOActiveX,
+ &DIID__ISOActiveXEvents,
+ &LIBID_SO_ACTIVEXLib >,
+ public IObjectSafetyImpl< CSOActiveX,
+ INTERFACESAFE_FOR_UNTRUSTED_DATA >
+{
+protected:
+ CComPtr<IWebBrowser2> mWebBrowser2;
+ DWORD mCookie;
+
+ CComPtr<IDispatch> mpDispFactory;
+ CComPtr<IDispatch> mpDispFrame;
+ CComPtr<IDispatch> mpDispWin;
+ OLECHAR* mCurFileUrl;
+ BOOL mbLoad;
+ BOOL mbViewOnly;
+ WNDCLASS mPWinClass;
+ HWND mParentWin;
+ HWND mOffWin;
+
+ SODispatchInterceptor* mpDispatchInterceptor;
+public:
+ CSOActiveX();
+ ~CSOActiveX();
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SOACTIVEX)
+
+DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+BEGIN_COM_MAP(CSOActiveX)
+ COM_INTERFACE_ENTRY(ISOActiveX)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(IViewObjectEx)
+ COM_INTERFACE_ENTRY(IViewObject2)
+ COM_INTERFACE_ENTRY(IViewObject)
+ COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
+ COM_INTERFACE_ENTRY(IOleInPlaceObject)
+ COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
+ COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
+ COM_INTERFACE_ENTRY(IOleControl)
+ COM_INTERFACE_ENTRY(IOleObject)
+ COM_INTERFACE_ENTRY(IPersistStreamInit)
+ COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
+// COM_INTERFACE_ENTRY(IConnectionPointContainer)
+ COM_INTERFACE_ENTRY(IProvideClassInfo)
+ COM_INTERFACE_ENTRY(IProvideClassInfo2)
+ COM_INTERFACE_ENTRY(IPersistPropertyBag)
+ COM_INTERFACE_ENTRY(IObjectSafety)
+END_COM_MAP()
+
+BEGIN_PROP_MAP(CSOActiveX)
+ PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
+ PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
+ // Example entries
+ // PROP_ENTRY("Property Description", dispid, clsid)
+ // PROP_PAGE(CLSID_StockColorPage)
+END_PROP_MAP()
+
+BEGIN_CONNECTION_POINT_MAP(CSOActiveX)
+END_CONNECTION_POINT_MAP()
+
+BEGIN_MSG_MAP(CSOActiveX)
+ CHAIN_MSG_MAP(CComControl<CSOActiveX>)
+ DEFAULT_REFLECTION_HANDLER()
+END_MSG_MAP()
+// Handler prototypes:
+// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
+
+
+
+// IViewObjectEx
+ DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
+
+// ISOActiveX
+public:
+
+ STDMETHOD(SetClientSite)( IOleClientSite* aClientSite );
+ STDMETHOD(Invoke)( DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS* pDispParams,
+ VARIANT* pvarResult,
+ EXCEPINFO* pExcepInfo,
+ UINT* puArgErr);
+ STDMETHOD(Load) ( LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog );
+ STDMETHOD(Load) ( LPSTREAM pStm );
+ STDMETHOD(InitNew) ();
+ HRESULT OnDrawAdvanced(ATL_DRAWINFO& di);
+ HRESULT OnDraw(ATL_DRAWINFO& di) { return S_OK; }
+
+ HRESULT CreateFrameOldWay( HWND hwnd, int width, int height );
+ HRESULT GetUnoStruct( OLECHAR* sStructName, CComPtr<IDispatch>& pdispResult );
+ HRESULT LoadURLToFrame();
+ HRESULT CallDispatch1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal );
+ HRESULT CallLoadComponentFromURL1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal );
+ HRESULT GetUrlStruct( OLECHAR* sUrl, CComPtr<IDispatch>& pdispUrl );
+ HRESULT Cleanup();
+ HRESULT CSOActiveX::GetURL( const OLECHAR* url,
+ const OLECHAR* target );
+};
+
+#endif //__SOACTIVEX_H_
+
diff --git a/extensions/source/activex/main/SOActiveX.rgs b/extensions/source/activex/main/SOActiveX.rgs
new file mode 100644
index 000000000000..d3814df3b241
--- /dev/null
+++ b/extensions/source/activex/main/SOActiveX.rgs
@@ -0,0 +1,33 @@
+HKCR
+{
+ so_activex.SOActiveX.1 = s 'SOActiveX Class'
+ {
+ CLSID = s '{67F2A879-82D5-4A6D-8CC5-FFB3C114B69D}'
+ }
+ so_activex.SOActiveX = s 'SOActiveX Class'
+ {
+ CLSID = s '{67F2A879-82D5-4A6D-8CC5-FFB3C114B69D}'
+ CurVer = s 'so_activex.SOActiveX.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {67F2A879-82D5-4A6D-8CC5-FFB3C114B69D} = s 'SOActiveX Class'
+ {
+ ProgID = s 'so_activex.SOActiveX.1'
+ VersionIndependentProgID = s 'so_activex.SOActiveX'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ ForceRemove 'Control'
+ ForceRemove 'ToolboxBitmap32' = s '%MODULE%, 101'
+ 'MiscStatus' = s '0'
+ {
+ '1' = s '131473'
+ }
+ 'TypeLib' = s '{61FA3F13-8061-4796-B055-3697ED28CB38}'
+ 'Version' = s '1.0'
+ }
+ }
+}
diff --git a/extensions/source/activex/main/SOComWindowPeer.cpp b/extensions/source/activex/main/SOComWindowPeer.cpp
new file mode 100644
index 000000000000..8e63835efc2a
--- /dev/null
+++ b/extensions/source/activex/main/SOComWindowPeer.cpp
@@ -0,0 +1,24 @@
+// SOComWindowPeer.cpp : Implementation of CHelpApp and DLL registration.
+
+#include "stdafx2.h"
+#include "so_activex.h"
+#include "SOComWindowPeer.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+
+STDMETHODIMP SOComWindowPeer::InterfaceSupportsErrorInfo(REFIID riid)
+{
+ static const IID* arr[] =
+ {
+ &IID_ISOComWindowPeer,
+ };
+
+ for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
+ {
+ if (InlineIsEqualGUID(*arr[i],riid))
+ return S_OK;
+ }
+ return S_FALSE;
+}
+
diff --git a/extensions/source/activex/main/SOComWindowPeer.h b/extensions/source/activex/main/SOComWindowPeer.h
new file mode 100644
index 000000000000..76221ed47868
--- /dev/null
+++ b/extensions/source/activex/main/SOComWindowPeer.h
@@ -0,0 +1,128 @@
+// SOComWindowPeer.h: Definition of the SOComWindowPeer class
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined __SOCOMWINDOWPEER_H_
+#define __SOCOMWINDOWPEER_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "resource.h" // main symbols
+#include <ExDispID.h>
+#include <ExDisp.h>
+#include <shlguid.h>
+#include <atlctl.h>
+
+#include "so_activex.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// SOComWindowPeer
+
+class SOComWindowPeer :
+ public IDispatchImpl<ISOComWindowPeer, &IID_ISOComWindowPeer, &LIBID_SO_ACTIVEXLib>,
+ public ISupportErrorInfo,
+ public CComObjectRoot,
+ public CComCoClass<SOComWindowPeer,&CLSID_SOComWindowPeer>
+{
+ HWND m_hwnd;
+public:
+ SOComWindowPeer() : m_hwnd( NULL ) {}
+
+BEGIN_COM_MAP(SOComWindowPeer)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(ISOComWindowPeer)
+ COM_INTERFACE_ENTRY(ISupportErrorInfo)
+END_COM_MAP()
+DECLARE_NOT_AGGREGATABLE(SOComWindowPeer)
+// Remove the comment from the line above if you don't want your object to
+// support aggregation.
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SOCOMWINDOWPEER)
+
+// ISupportsErrorInfo
+ STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
+
+// ISOComWindowPeer
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getWindowHandle(
+ /* [in] */ SAFEARRAY __RPC_FAR * procId,
+ /* [in] */ short s,
+ /* [retval][out] */ long __RPC_FAR *ret)
+ {
+ *ret = (long) m_hwnd;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getToolkit(
+ /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
+ {
+ *retVal = NULL;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setPointer(
+ /* [in] */ IDispatch __RPC_FAR *xPointer)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setBackground(
+ /* [in] */ int nColor)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidate(
+ /* [in] */ short __MIDL_0015)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidateRect(
+ /* [in] */ IDispatch __RPC_FAR *aRect,
+ /* [in] */ short nFlags)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispose( void)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addEventListener(
+ /* [in] */ IDispatch __RPC_FAR *xListener)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeEventListener(
+ /* [in] */ IDispatch __RPC_FAR *xListener)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
+ {
+ *pVal = SafeArrayCreateVector( VT_BSTR, 0, 2 );
+
+ if( !*pVal )
+ return E_FAIL;
+
+ long ix = 0;
+ CComBSTR aInterface( OLESTR( "com.sun.star.awt.XSystemDependentWindowPeer" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ ix = 1;
+ aInterface = CComBSTR( OLESTR( "com.sun.star.awt.XWindowPeer" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ return S_OK;
+ }
+
+ void SetHWNDInternally( HWND hwnd ) { m_hwnd = hwnd; }
+};
+
+#endif // __SOCOMWINDOWPEER_H_
diff --git a/extensions/source/activex/main/SOComWindowPeer.rgs b/extensions/source/activex/main/SOComWindowPeer.rgs
new file mode 100644
index 000000000000..42e985a31a1b
--- /dev/null
+++ b/extensions/source/activex/main/SOComWindowPeer.rgs
@@ -0,0 +1,23 @@
+HKCR
+{
+ so_activex.SOComWindowPeer.1 = s 'SOComWindowPeer Class'
+ {
+ CLSID = s '{EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D}'
+ }
+ so_activex.SOComWindowPeer = s 'SOComWindowPeer Class'
+ {
+ CLSID = s '{EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D}'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D} = s 'SOComWindowPeer Class'
+ {
+ ProgID = s 'so_activex.SOComWindowPeer.1'
+ VersionIndependentProgID = s 'so_activex.SOComWindowPeer'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'both'
+ }
+ }
+ }
+}
diff --git a/extensions/source/activex/main/SODispatchInterceptor.cpp b/extensions/source/activex/main/SODispatchInterceptor.cpp
new file mode 100644
index 000000000000..048f0e606734
--- /dev/null
+++ b/extensions/source/activex/main/SODispatchInterceptor.cpp
@@ -0,0 +1,169 @@
+// SODispatchInterceptor.cpp : Implementation of CHelpApp and DLL registration.
+
+#include "stdio.h"
+#include "stdafx2.h"
+#include "so_activex.h"
+#include "SOActiveX.h"
+#include "SODispatchInterceptor.h"
+#include "com_uno_helper.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+
+STDMETHODIMP SODispatchInterceptor::InterfaceSupportsErrorInfo(REFIID riid)
+{
+ static const IID* arr[] =
+ {
+ &IID_ISODispatchInterceptor,
+ };
+
+ for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
+ {
+ if (InlineIsEqualGUID(*arr[i],riid))
+ return S_OK;
+ }
+ return S_FALSE;
+}
+
+STDMETHODIMP SODispatchInterceptor::queryDispatch( IDispatch FAR* aURL,
+ BSTR aTargetFrameName,
+ long nSearchFlags,
+ IDispatch FAR* FAR* retVal )
+{
+ if ( !aURL || !retVal ) return E_FAIL;
+
+ CComVariant aTargetUrl;
+ OLECHAR* sURLMemberName = L"Complete";
+ DISPID nURLID;
+ HRESULT hr = aURL->GetIDsOfNames( IID_NULL, &sURLMemberName, 1, LOCALE_USER_DEFAULT, &nURLID );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = CComDispatchDriver::GetProperty( aURL, nURLID, &aTargetUrl );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( aTargetUrl.vt != VT_BSTR ) return E_FAIL;
+
+ USES_CONVERSION;
+ if( !strncmp( OLE2T( aTargetUrl.bstrVal ), "ftp://", 6 )
+ || !strncmp( OLE2T( aTargetUrl.bstrVal ), "http://", 7 )
+ || !strncmp( OLE2T( aTargetUrl.bstrVal ), "file://", 7 ) )
+ *retVal = this;
+ else
+ {
+ if( !m_xSlave )
+ return E_FAIL;
+
+ CComVariant aResult;
+ CComVariant aArgs[3];
+ aArgs[0] = CComVariant( nSearchFlags );
+ aArgs[1] = CComVariant( aTargetFrameName );
+ aArgs[2] = CComVariant( aURL );
+
+ hr = ExecuteFunc( m_xSlave, L"queryDispatch", aArgs, 3, &aResult );
+ if( !SUCCEEDED( hr ) || aResult.vt != VT_DISPATCH || aResult.pdispVal == NULL ) return E_FAIL;
+
+ *retVal = aResult.pdispVal;
+ CComQIPtr< IUnknown, &IID_IUnknown > pIUnk( *retVal );
+ if( pIUnk )
+ (*retVal)->AddRef();
+ }
+
+ return S_OK;
+}
+
+STDMETHODIMP SODispatchInterceptor::queryDispatches( SAFEARRAY FAR* aDescripts, SAFEARRAY FAR* FAR* retVal)
+{
+ if ( !aDescripts || !retVal || SafeArrayGetDim( aDescripts ) != 1 )
+ return E_FAIL;
+
+ long nLB, nUB;
+
+ HRESULT hr = SafeArrayGetLBound( aDescripts, 1, &nLB );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = SafeArrayGetUBound( aDescripts, 1, &nUB );
+ if( !SUCCEEDED( hr ) ) return hr;
+ if( nUB <= nLB ) return E_FAIL;
+
+ *retVal = SafeArrayCreateVector( VT_DISPATCH, 0, nUB - nLB );
+
+ for ( long ind = nLB; ind < nUB; ind ++ )
+ {
+ CComPtr<IDispatch> pElem;
+ SafeArrayGetElement( aDescripts, &ind, pElem );
+ if( pElem )
+ {
+ OLECHAR* pMemberNames[3] = { L"FeatureURL", L"FrameName", L"SearchFlags" };
+ CComVariant pValues[3];
+ hr = GetPropertiesFromIDisp( pElem, pMemberNames, pValues, 3 );
+ if( !SUCCEEDED( hr ) ) return hr;
+ if( pValues[0].vt != VT_DISPATCH || pValues[0].pdispVal == NULL
+ || pValues[1].vt != VT_BSTR || pValues[2].vt != VT_I4 )
+ return E_FAIL;
+
+ CComPtr<IDispatch> aRes;
+ hr = queryDispatch( pValues[0].pdispVal, pValues[1].bstrVal, pValues[2].lVal, &aRes );
+ SafeArrayPutElement( *retVal, &ind, aRes );
+ }
+ }
+
+ return S_OK;
+}
+
+
+STDMETHODIMP SODispatchInterceptor::dispatch( IDispatch FAR* aURL, SAFEARRAY FAR* aArgs)
+{
+ // get url from aURL
+ OLECHAR* pUrlName = L"Complete";
+ CComVariant pValue;
+ HRESULT hr = GetPropertiesFromIDisp( aURL, &pUrlName, &pValue, 1 );
+ if( !SUCCEEDED( hr ) ) return hr;
+ if( pValue.vt != VT_BSTR || pValue.bstrVal == NULL )
+ return E_FAIL;
+
+ EnterCriticalSection( &mMutex );
+ if( m_xParentControl )
+ {
+ // call GetUrl to the browser instance
+ m_xParentControl->GetURL( pValue.bstrVal, L"_blank" );
+ }
+ LeaveCriticalSection( &mMutex );
+
+ return S_OK;
+}
+
+STDMETHODIMP SODispatchInterceptor::addStatusListener( IDispatch FAR* xControl, IDispatch FAR* aURL)
+{
+ // not implemented
+ return S_OK;
+}
+
+STDMETHODIMP SODispatchInterceptor::removeStatusListener( IDispatch FAR* xControl, IDispatch FAR* aURL)
+{
+ // not implemented
+ return S_OK;
+}
+
+STDMETHODIMP SODispatchInterceptor::getInterceptedURLs( SAFEARRAY FAR* FAR* pVal )
+{
+ *pVal = SafeArrayCreateVector( VT_BSTR, 0, 3 );
+
+ if( !*pVal )
+ return E_FAIL;
+
+ long ix = 0;
+ CComBSTR aPattern( OLESTR( "ftp://*" ) );
+ SafeArrayPutElement( *pVal, &ix, aPattern );
+
+ ix = 1;
+ aPattern = CComBSTR( OLESTR( "http://*" ) );
+ SafeArrayPutElement( *pVal, &ix, aPattern );
+
+ ix = 2;
+ aPattern = CComBSTR( OLESTR( "file://*" ) );
+ SafeArrayPutElement( *pVal, &ix, aPattern );
+
+ return S_OK;
+}
+
+
diff --git a/extensions/source/activex/main/SODispatchInterceptor.h b/extensions/source/activex/main/SODispatchInterceptor.h
new file mode 100644
index 000000000000..922349bd0d38
--- /dev/null
+++ b/extensions/source/activex/main/SODispatchInterceptor.h
@@ -0,0 +1,151 @@
+// SODispatchInterceptor.h: Definition of the SODispatchInterceptor class
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined __SODISPATCHINTERCEPTOR_H_
+#define __SODISPATCHINTERCEPTOR_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "resource.h" // main symbols
+#include <ExDispID.h>
+#include <ExDisp.h>
+#include <shlguid.h>
+#include <atlctl.h>
+
+#include "so_activex.h"
+
+class CSOActiveX;
+
+/////////////////////////////////////////////////////////////////////////////
+// SODispatchInterceptor
+
+class SODispatchInterceptor :
+ public IDispatchImpl<ISODispatchInterceptor, &IID_ISODispatchInterceptor, &LIBID_SO_ACTIVEXLib>,
+ public ISupportErrorInfo,
+ public CComObjectRoot,
+ public CComCoClass<SODispatchInterceptor,&CLSID_SODispatchInterceptor>
+{
+ CComPtr<IDispatch> m_xMaster;
+ CComPtr<IDispatch> m_xSlave;
+ CSOActiveX* m_xParentControl;
+ CRITICAL_SECTION mMutex;
+public:
+ SODispatchInterceptor() : m_xParentControl( NULL ) { InitializeCriticalSection(&mMutex); }
+ ~SODispatchInterceptor() { ATLASSERT( !m_xParentControl ); DeleteCriticalSection(&mMutex); }
+
+BEGIN_COM_MAP(SODispatchInterceptor)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(ISODispatchInterceptor)
+ COM_INTERFACE_ENTRY(ISupportErrorInfo)
+END_COM_MAP()
+DECLARE_NOT_AGGREGATABLE(SODispatchInterceptor)
+// Remove the comment from the line above if you don't want your object to
+// support aggregation.
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SODISPATCHINTERCEPTOR)
+
+ void SetParent( CSOActiveX* pParent )
+ {
+ ATLASSERT( !m_xParentControl );
+ EnterCriticalSection( &mMutex );
+ m_xParentControl = pParent;
+ LeaveCriticalSection( &mMutex );
+ }
+
+ void ClearParent()
+ {
+ EnterCriticalSection( &mMutex );
+ m_xParentControl = NULL;
+ LeaveCriticalSection( &mMutex );
+ }
+
+// ISupportsErrorInfo
+ STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
+
+// ISODispatchInterceptor
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getSlaveDispatchProvider(
+ /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
+ {
+ *retVal = m_xSlave;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setSlaveDispatchProvider(
+ /* [in] */ IDispatch __RPC_FAR *xNewDispatchProvider)
+ {
+ m_xSlave = xNewDispatchProvider;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getMasterDispatchProvider(
+ /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
+ {
+ *retVal = m_xMaster;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setMasterDispatchProvider(
+ /* [in] */ IDispatch __RPC_FAR *xNewSupplier)
+ {
+ m_xMaster = xNewSupplier;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatch(
+ /* [in] */ IDispatch __RPC_FAR *aURL,
+ /* [in] */ BSTR aTargetFrameName,
+ /* [in] */ long nSearchFlags,
+ /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatches(
+ /* [in] */ SAFEARRAY __RPC_FAR * aDescripts,
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *retVal);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispatch(
+ /* [in] */ IDispatch __RPC_FAR *aURL,
+ /* [in] */ SAFEARRAY __RPC_FAR * aArgs);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addStatusListener(
+ /* [in] */ IDispatch __RPC_FAR *xControl,
+ /* [in] */ IDispatch __RPC_FAR *aURL);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeStatusListener(
+ /* [in] */ IDispatch __RPC_FAR *xControl,
+ /* [in] */ IDispatch __RPC_FAR *aURL);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getInterceptedURLs(
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal);
+
+ virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
+ {
+ *pVal = SafeArrayCreateVector( VT_BSTR, 0, 3 );
+
+ if( !*pVal )
+ return E_FAIL;
+
+ long ix = 0;
+ CComBSTR aInterface( OLESTR( "com.sun.star.frame.XDispatchProviderInterceptor" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ ix = 1;
+ aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatchProvider" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ ix = 2;
+ aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatch" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+ /*
+ ix = 3;
+ aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XInterceptorInfo" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+ */
+ return S_OK;
+ }
+};
+
+#endif // __SODISPATCHINTERCEPTOR_H_
diff --git a/extensions/source/activex/main/SODispatchInterceptor.rgs b/extensions/source/activex/main/SODispatchInterceptor.rgs
new file mode 100644
index 000000000000..19fe0b5f0e4c
--- /dev/null
+++ b/extensions/source/activex/main/SODispatchInterceptor.rgs
@@ -0,0 +1,23 @@
+HKCR
+{
+ so_activex.SODispatchInterceptor.1 = s 'SODispatchInterceptor Class'
+ {
+ CLSID = s '{C5D6D568-57DA-4D6C-819A-451CB565E682}'
+ }
+ so_activex.SODispatchInterceptor = s 'SODispatchInterceptor Class'
+ {
+ CLSID = s '{C5D6D568-57DA-4D6C-819A-451CB565E682}'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {C5D6D568-57DA-4D6C-819A-451CB565E682} = s 'SODispatchInterceptor Class'
+ {
+ ProgID = s 'so_activex.SODispatchInterceptor.1'
+ VersionIndependentProgID = s 'so_activex.SODispatchInterceptor'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'both'
+ }
+ }
+ }
+}
diff --git a/extensions/source/activex/main/StdAfx2.cpp b/extensions/source/activex/main/StdAfx2.cpp
new file mode 100644
index 000000000000..06274f78824d
--- /dev/null
+++ b/extensions/source/activex/main/StdAfx2.cpp
@@ -0,0 +1,12 @@
+// 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/extensions/source/activex/main/StdAfx2.h b/extensions/source/activex/main/StdAfx2.h
new file mode 100644
index 000000000000..ff5d87e57dc3
--- /dev/null
+++ b/extensions/source/activex/main/StdAfx2.h
@@ -0,0 +1,31 @@
+// stdafx1.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#if !defined(AFX_STDAFX_H__C1799EA0_62CC_44DE_A2DD_C9F0410FF7F1__INCLUDED_)
+#define AFX_STDAFX_H__C1799EA0_62CC_44DE_A2DD_C9F0410FF7F1__INCLUDED_
+
+#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
+
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+
+#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 // !defined(AFX_STDAFX_H__C1799EA0_62CC_44DE_A2DD_C9F0410FF7F1__INCLUDED)
diff --git a/extensions/source/activex/main/com_uno_helper.h b/extensions/source/activex/main/com_uno_helper.h
new file mode 100644
index 000000000000..19be354f9bf0
--- /dev/null
+++ b/extensions/source/activex/main/com_uno_helper.h
@@ -0,0 +1,24 @@
+#include "stdafx2.h"
+
+HRESULT ExecuteFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComVariant* pResult );
+
+HRESULT GetIDispByFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComPtr<IDispatch>& pdispResult );
+
+HRESULT PutPropertiesToIDisp( IDispatch* pdispObject,
+ OLECHAR** sMemberNames,
+ CComVariant* pVariant,
+ unsigned int count );
+
+HRESULT GetPropertiesFromIDisp( IDispatch* pdispObject,
+ OLECHAR** sMemberNames,
+ CComVariant* pVariant,
+ unsigned int count );
+
diff --git a/extensions/source/activex/main/example.html b/extensions/source/activex/main/example.html
new file mode 100644
index 000000000000..3efee1f75a03
--- /dev/null
+++ b/extensions/source/activex/main/example.html
@@ -0,0 +1,26 @@
+<HTML>
+<HEAD>
+<TITLE>Document Title</TITLE>
+</HEAD>
+<BODY>
+
+<center>
+First you should edit the example.html file!!!
+</center>
+<center>
+<!-- Please edit CODEBASE parameter -->
+<!-- In case ActiveX control is already registered the parameter can be removed -->
+<OBJECT CLASSID="clsid:67F2A879-82D5-4A6D-8CC5-FFB3C114B69D" width="500" height="500"
+ CODEBASE="..\..\..\WINexample.out\bin\so_activex.dll">
+<!-- Full URL to a document
+ <PARAM NAME="src" VALUE="file:///d:/example.sxw">
+-->
+<!-- Just view the document, do not edit
+ <PARAM NAME="readonly" VALUE="true">
+-->
+</OBJECT>
+
+</center>
+
+</BODY>
+</HTML>
diff --git a/extensions/source/activex/main/makefile.mk b/extensions/source/activex/main/makefile.mk
new file mode 100644
index 000000000000..094958bbb34d
--- /dev/null
+++ b/extensions/source/activex/main/makefile.mk
@@ -0,0 +1,89 @@
+#**************************************************************************
+#
+# $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/extensions/source/activex/main/makefile.mk,v 1.1 2002-08-14 14:40:52 mav Exp $
+#
+# =========================================================================
+#
+# $Date: 2002-08-14 14:40:52 $
+# $Author: mav $
+# $Revision: 1.1 $
+#
+# =========================================================================
+#
+# Created: 1999/08/23
+# Creator: obr
+#
+# Copyright (c) 1999 StarOffice Software Entwicklungs GmbH
+#
+#**************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=extensions
+TARGET=so_activex
+
+use_shl_versions=
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(GUI)" == "WNT"
+
+VERSIONOBJ=
+LIBTARGET=NO
+USE_DEFFILE=YES
+INCPRE+=$(SOLARINCDIR)$/external$/atl \
+ -I$(MISC) \
+
+# --- Files -------------------------------------
+
+
+.IF "$(PRODUCT)"!=""
+RC+=-DPRODUCT
+.ENDIF
+
+RCFILES=\
+ $(TARGET).rc
+RCDEPN=$(MISC)$/envsettings.h
+
+SLOFILES=\
+ $(SLO)$/so_activex.obj \
+ $(SLO)$/SOActiveX.obj \
+ $(SLO)$/SOComWindowPeer.obj \
+ $(SLO)$/SODispatchInterceptor.obj \
+ $(SLO)$/StdAfx2.obj
+
+SHL1TARGET=$(TARGET)
+SHL1STDLIBS=\
+ uuid.lib \
+ advapi32.lib \
+ ole32.lib \
+ oleaut32.lib \
+ gdi32.lib \
+ urlmon.lib \
+ Shlwapi.lib
+
+# kernel32.lib \
+# rpcndr.lib \
+# rpcns4.lib \
+# rpcrt4.lib
+
+#kernel32.lib rpcndr.lib rpcns4.lib rpcrt4.lib
+
+SHL1OBJS=$(SLOFILES)
+
+SHL1LIBS=
+SHL1DEF=$(TARGET).def
+SHL1RES=$(RES)$/$(TARGET).res
+
+.ENDIF
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+$(MISC)$/envsettings.h :
+ +-$(RM) $@
+# it looks wrong; but rc likes it that way...
+ +echo #define MISC .$/..$/$(INPATH)$/misc > $@
+
diff --git a/extensions/source/activex/main/resource.h b/extensions/source/activex/main/resource.h
new file mode 100644
index 000000000000..d521b29fa4f3
--- /dev/null
+++ b/extensions/source/activex/main/resource.h
@@ -0,0 +1,24 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by so_activex.rc
+//
+#define IDS_PROJNAME 100
+#define IDB_SOACTIVEX 101
+#define IDR_SOACTIVEX 102
+#define IDB_SOCOMWINDOWPEER 103
+#define IDR_SOCOMWINDOWPEER 104
+#define IDB_SODISPATCHINTERCEPTOR 105
+#define IDR_SODISPATCHINTERCEPTOR 106
+
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 201
+#define _APS_NEXT_COMMAND_VALUE 32768
+#define _APS_NEXT_CONTROL_VALUE 201
+#define _APS_NEXT_SYMED_VALUE 107
+#endif
+#endif
+
diff --git a/extensions/source/activex/main/so_activex.cpp b/extensions/source/activex/main/so_activex.cpp
new file mode 100644
index 000000000000..52dcf4fe7aa5
--- /dev/null
+++ b/extensions/source/activex/main/so_activex.cpp
@@ -0,0 +1,259 @@
+// so_activex.cpp : Implementation of DLL Exports.
+
+
+// Note: Proxy/Stub Information
+// To build a separate proxy/stub DLL,
+// run nmake -f so_activexps.mk in the project directory.
+
+#include "stdio.h"
+#include "stdafx2.h"
+#include "resource.h"
+#include <initguid.h>
+#include "so_activex.h"
+
+#include "so_activex_i.c"
+#include "SOActiveX.h"
+
+
+CComModule _Module;
+
+BEGIN_OBJECT_MAP(ObjectMap)
+OBJECT_ENTRY(CLSID_SOActiveX, CSOActiveX)
+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, &LIBID_SO_ACTIVEXLib);
+ DisableThreadLibraryCalls(hInstance);
+ }
+ else if (dwReason == DLL_PROCESS_DETACH)
+ _Module.Term();
+ return TRUE; // ok
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Used to determine whether the DLL can be unloaded by OLE
+
+STDAPI DllCanUnloadNow(void)
+{
+ return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Returns a class factory to create an object of the requested type
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
+{
+ return _Module.GetClassObject(rclsid, riid, ppv);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - Adds entries to the system registry
+
+#define SUPPORTED_EXT_NUM 17
+const char* aFileExt[] = { ".sds", ".sda", ".sdd", ".sdc", ".vor", ".sdw", ".rvp",
+ ".sxw", ".sxc", ".sxi", ".sxd", ".sxs",
+ ".stw", ".stc", ".sti", ".std", ".sts" };
+const char* aMimeType[] = { "application/vnd.stardivision.chart",
+ "application/vnd.stardivision.draw",
+ "application/vnd.stardivision.impress",
+ "application/vnd.stardivision.calc",
+ "application/vnd.sun.office.template",
+ "application/vnd.staroffice.writer",
+ "application/vnd.sun.rvp",
+
+ "application/vnd.sun.xml.writer",
+ "application/vnd.sun.xml.calc",
+ "application/vnd.sun.xml.impress",
+ "application/vnd.sun.xml.draw",
+ "application/vnd.sun.xml.chart",
+
+ "application/vnd.sun.xml.writer.template",
+ "application/vnd.sun.xml.calc.template",
+ "application/vnd.sun.xml.impress.template",
+ "application/vnd.sun.xml.draw.template",
+ "application/vnd.sun.xml.chart.template" };
+
+const char* aClassID = "{67F2A879-82D5-4A6D-8CC5-FFB3C114B69D}";
+const char* aTypeLib = "{61FA3F13-8061-4796-B055-3697ED28CB38}";
+const char* aLocalPrefix = "Software\\Classes\\";
+
+BOOL createKey( HKEY hkey,
+ const char* aKeyToCreate,
+ const char* aValue = NULL,
+ const char* aChildName = NULL,
+ const char* aChildValue = NULL )
+{
+ HKEY hkey1;
+
+ return ( ERROR_SUCCESS == RegCreateKey( hkey, aKeyToCreate, &hkey1 )
+ && ( !aValue || ERROR_SUCCESS == RegSetValueEx( hkey1,
+ "",
+ 0,
+ REG_SZ,
+ (const BYTE*)aValue,
+ strlen( aValue ) ) )
+ && ( !aChildName || ERROR_SUCCESS == RegSetValueEx( hkey1,
+ aChildName,
+ 0,
+ REG_SZ,
+ (const BYTE*)aChildValue,
+ strlen( aChildValue ) ) )
+ && ERROR_SUCCESS == RegCloseKey( hkey1 ) );
+
+}
+
+STDAPI DllRegisterServer(void)
+{
+ BOOL aResult = SUCCEEDED( _Module.RegisterServer(TRUE) );
+
+ HKEY hkey = NULL;
+ HKEY hkey1 = NULL;
+ HKEY hkey2 = NULL;
+ HKEY hkey3 = NULL;
+ HKEY hkey4 = NULL;
+ char aSubKey[513];
+ int ind;
+ BOOL localEnv = FALSE;
+ const char* aPrefix = "";
+
+
+ if( !aResult )
+ {
+ aPrefix = aLocalPrefix;
+ localEnv = TRUE;
+
+ // get iervp.dll path
+ char aActiveXPath[1019];
+ char aActiveXPath101[1024];
+
+
+ HMODULE aCurModule = GetModuleHandleA( "iervp.dll" );
+ if( aCurModule && GetModuleFileNameA( aCurModule, aActiveXPath, 1019 ) )
+ {
+ sprintf( aActiveXPath101, "%s, 101", aActiveXPath );
+
+ if( aActiveXPath )
+ {
+ wsprintf( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+ aResult =
+ ( ERROR_SUCCESS == RegCreateKey( HKEY_CURRENT_USER, aSubKey, &hkey )
+ && ERROR_SUCCESS == RegSetValueEx( hkey, "", 0, REG_SZ, (const BYTE*)"SOActiveX Class", 17 )
+ && createKey( hkey, "Control" )
+ && createKey( hkey, "EnableFullPage" )
+ && createKey( hkey, "InprocServer32", aActiveXPath, "ThreadingModel", "Apartment" )
+ && createKey( hkey, "MiscStatus", "0" )
+ && createKey( hkey, "MiscStatus\\1", "131473" )
+ && createKey( hkey, "ProgID", "so_activex.SOActiveX.1" )
+ && createKey( hkey, "Programmable" )
+ && createKey( hkey, "ToolboxBitmap32", aActiveXPath101 )
+ && createKey( hkey, "TypeLib", aTypeLib )
+ && createKey( hkey, "Version", "1.0" )
+ && createKey( hkey, "VersionIndependentProgID", "so_activex.SOActiveX" )
+ && ERROR_SUCCESS == RegCloseKey( hkey )
+ && ERROR_SUCCESS == RegCreateKey( HKEY_CURRENT_USER, aLocalPrefix, &hkey )
+ && createKey( hkey, "so_activex.SOActiveX", "SOActiveX Class" )
+ && ERROR_SUCCESS == RegCreateKey( hkey, "so_activex.SOActiveX", &hkey1 )
+ && createKey( hkey1, "CLSID", aClassID )
+ && createKey( hkey1, "CurVer", "so_activex.SOActiveX.1" )
+ && ERROR_SUCCESS == RegCloseKey( hkey1 )
+ && createKey( hkey, "so_activex.SOActiveX.1", "SOActiveX Class" )
+ && ERROR_SUCCESS == RegCreateKey( hkey, "so_activex.SOActiveX.1", &hkey1 )
+ && createKey( hkey1, "CLSID", aClassID )
+ && ERROR_SUCCESS == RegCloseKey( hkey1 )
+ && ERROR_SUCCESS == RegCloseKey( hkey ) );
+ }
+ }
+ }
+
+ for( ind = 0; ind < SUPPORTED_EXT_NUM && aResult; ind++ )
+ {
+ wsprintf( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMimeType[ind] );
+ if ( ERROR_SUCCESS != RegCreateKey(localEnv ? HKEY_CURRENT_USER : HKEY_CLASSES_ROOT, aSubKey, &hkey)
+ || ERROR_SUCCESS != RegSetValueEx(hkey, "Extension", 0, REG_SZ,
+ (const BYTE *)aFileExt[ind], strlen( aFileExt[ind] ) )
+ || ERROR_SUCCESS != RegSetValueEx(hkey, "CLSID", 0, REG_SZ,
+ (const BYTE *)aClassID, strlen(aClassID)) )
+ aResult = FALSE;
+
+ if( hkey )
+ RegCloseKey(hkey);
+
+ wsprintf( aSubKey, "%s%s", aPrefix, aFileExt[ind] );
+ if ( ERROR_SUCCESS != RegCreateKey(localEnv ? HKEY_CURRENT_USER : HKEY_CLASSES_ROOT, aSubKey, &hkey)
+ || ERROR_SUCCESS != RegSetValueEx(hkey, "Content Type", 0, REG_SZ,
+ (const BYTE *)aMimeType[ind], strlen( aMimeType[ind] ) ) )
+ aResult = FALSE;
+
+ if( hkey )
+ RegCloseKey(hkey);
+ }
+
+
+ wsprintf( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+ if ( aResult && ERROR_SUCCESS == RegOpenKey(localEnv ? HKEY_CURRENT_USER : HKEY_CLASSES_ROOT, aSubKey, &hkey) )
+ {
+ for( ind = 0; ind < SUPPORTED_EXT_NUM; ind++ )
+ {
+ wsprintf( aSubKey, "EnableFullPage\\%s", aFileExt[ind] );
+ if ( ERROR_SUCCESS != RegCreateKey( hkey, aSubKey, &hkey1 ) )
+ aResult = FALSE;
+
+ if ( hkey1 )
+ RegCloseKey(hkey1);
+ }
+ }
+ else
+ aResult = FALSE;
+
+ if ( hkey )
+ RegCloseKey(hkey);
+
+ return aResult;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - Removes entries from the system registry
+
+STDAPI DllUnregisterServer(void)
+{
+ HRESULT aResult = _Module.UnregisterServer(TRUE);
+
+ HKEY hkey = NULL;
+ BOOL fErr = FALSE;
+ char aSubKey[513];
+ HKEY aIter[2] = { HKEY_CLASSES_ROOT, HKEY_CURRENT_USER };
+ const char* aPrefix = "";
+
+ for( int keyInd = 0; keyInd < 2; keyInd++, aPrefix=aLocalPrefix )
+ {
+ for( int ind = 0; ind < SUPPORTED_EXT_NUM; ind++ )
+ {
+ wsprintf( aSubKey, "%sMIME\\DataBase\\Content Type\\%s\\CLSID", aPrefix, aMimeType[ind] );
+ if( ERROR_SUCCESS != SHDeleteKey( HKEY_CLASSES_ROOT, aSubKey ) )
+ fErr = TRUE;
+ }
+
+ wsprintf( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+ if( ERROR_SUCCESS != SHDeleteKey( HKEY_CLASSES_ROOT, aSubKey ) )
+ fErr = TRUE;
+
+ wsprintf( aSubKey, "%sso_activex.SOActiveX", aPrefix, aClassID );
+ if( ERROR_SUCCESS != SHDeleteKey( HKEY_CLASSES_ROOT, aSubKey ) )
+ fErr = TRUE;
+
+ wsprintf( aSubKey, "%sso_activex.SOActiveX.1", aPrefix, aClassID );
+ if( ERROR_SUCCESS != SHDeleteKey( HKEY_CLASSES_ROOT, aSubKey ) )
+ fErr = TRUE;
+
+ }
+
+ return aResult;
+}
+
diff --git a/extensions/source/activex/main/so_activex.rc b/extensions/source/activex/main/so_activex.rc
new file mode 100644
index 000000000000..17d229bc2d12
--- /dev/null
+++ b/extensions/source/activex/main/so_activex.rc
@@ -0,0 +1,105 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian resources
+
+//#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+//#ifdef _WIN32
+//LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+//#pragma code_page(1251)
+//#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+//IDB_SOACTIVEX BITMAP DISCARDABLE "soacti.bmp"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_SOACTIVEX REGISTRY DISCARDABLE "SOActiveX.rgs"
+IDR_SOCOMWINDOWPEER REGISTRY DISCARDABLE "SOComWindowPeer.rgs"
+IDR_SODISPATCHINTERCEPTOR REGISTRY DISCARDABLE "SODispatchInterceptor.rgs"
+//#endif // Russian resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "1 TYPELIB ""so_activex.tlb""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_PROJNAME "so_activex"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+#include "envsettings.h"
+
+1 TYPELIB MISC\so_activex.tlb
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+