44 TRACEX(OcfRefCount, 1,
"TOcApp() @" << (
void*)
this);
55 Registrar.SetApp(
this);
82 TRACEX(OcfRefCount, 1,
"TOcApp() @" << (
void*)
this);
111 if (BService &&
HRSucceeded(BService->QueryInterface(IID_IBService2,
112 (LPVOID *)&BServiceI))) {
114 BServiceI->Init(
this);
121 for (
uint i = IDS_CFFIRST; i <= IDS_CFLAST; i++) {
124 _TCHAR* resultName =
_tcschr(name,
_T(
'\n'));
156 Registrar.Shutdown(0,
Options);
164 Registrar.AppCount--;
198 SUCCEEDED(hr = IBApplication_QueryInterface(
this,
iid, iface))
199 || SUCCEEDED(hr = IBClassMgr_QueryInterface(
this,
iid, iface))
202 || (BService && SUCCEEDED(hr = BService->QueryInterface(
iid, iface)))
215 return BCmI->ComponentCreate(iface, outer, idClass);
244 for ( ; link; link = link->
GetNext()) {
252 !(
const _TCHAR*)regList[
"insertable"])
257 const _TCHAR* usage = regList.Lookup(
"usage");
259 multiUse =
ToBool(!(usage && *usage == *su));
280 for ( ; link; link = link->
GetNext()) {
319 BServiceI->OnResize();
329 BServiceI->OnActivate(active);
346 return BServiceI ?
HRIsOK(BServiceI->CanClose()) :
true;
352 return BServiceI ? BServiceI->EnableEditMenu(menuEnable, ocView) : 0;
358 return BServiceI ?
HRIsOK(BServiceI->Browse(&init)) :
false;
364 return BServiceI ?
HRIsOK(BServiceI->BrowseControls(&init)) :
false;
370 return BServiceI ?
HRIsOK(BServiceI->BrowseClipboard(&init)):
false;
376 return BServiceI ?
HRIsOK(BServiceI->Paste(&init)) :
false;
386 if (ocPart && SUCCEEDED(ocPart->
QueryInterface(IID_IBPart, (LPVOID *)&bPartI))) {
391 return BServiceI ?
HRIsOK(BServiceI->Clip(bPartI,
true,
true,
true)) :
false;
405 BServiceI->Clip(0,
false,
false,
false);
409 return HRIsOK(BServiceI->Clip(ocData,
true,
true,
false));
420 return BServiceI?
HRSucceeded(BServiceI->Drag(ocData, inAction, &outAction)) :
false;
431 if (ocPart && SUCCEEDED(ocPart->
QueryInterface(IID_IBPart, (LPVOID *)&bPartI))) {
435 return HRSucceeded(BServiceI->Drag(bPartI, inAction, &outAction));
439 return BServiceI?
HRSucceeded(BServiceI->Drag(ocPart, inAction, &outAction)) :
false;
490TOcApp::InsertContainerMenus(HMENU hMenu,
TOcMenuWidths * omw)
500 for (i = 0; i < 6; i++) {
504 md.Width[i] = (int)omw->Width[i];
510 for (i = 0; i < 6; i++)
511 omw->Width[i] = md.Width[i];
520TOcApp::SetFrameMenu(HMENU hMenu)
531TOcApp::Accelerator(MSG* msg)
542TOcApp::GetAccelerators(HACCEL * phAccel,
int * pcAccel)
547 *phAccel = acc.Accel;
548 *pcAccel = acc.Count;
586TOcApp::GetWindowRect(
TRect* r)
608TOcApp::RequestBorderSpace(
const TRect* space)
619TOcApp::SetBorderSpace(
const TRect* space)
629TOcApp::AppendWindowTitle(LPCOLESTR )
638TOcApp::SetStatusText(LPCOLESTR text)
667TOcApp::OnModalDialog(BOOL svrModal)
669 DisableDlgs = (bool)svrModal;
703 "ShutdownMaybe() on " << (
void*)
this <<
705 " Win:" << hex <<
static_cast<void*
>(GetWindow()));
714 Registrar.Shutdown((IUnknown*)(
void*)
this,
Options);
731 void SetApp(TOcApp* app) {OcApp = app;}
734 HRESULT
_IFUNC QueryInterface(
const GUID & iid,
void ** iface)
735 {
return GetOuter()->QueryInterface(iid, iface);}
736 HRESULT
_IFUNC ComponentCreate(IUnknown * * iface,
737 IUnknown * outer, BCID classId);
738 HRESULT
_IFUNC ComponentInfoGet(IUnknown * * info,
739 IUnknown * outer, BCID classId);
742 HRESULT QueryObject(
const IID & iid,
void * * iface);
758TOcClassMgr::~TOcClassMgr()
769TOcClassMgr::Release()
778TOcClassMgr::ComponentCreate(IUnknown * * retIface, IUnknown * outer,
BCID idClass)
794 *retIface = OcCallback(outer, Options |
amEmbedding, idClass);
800 OcApp->ShutdownMaybe ();
807TOcClassMgr::ComponentInfoGet(IUnknown * * info, IUnknown * ,
815TOcClassMgr::QueryObject(
const IID &
iid,
void * * iface)
830TOcApp::ComponentCreate(IUnknown * * ret, IUnknown * outer,
BCID classId)
832 return Registrar.OcClassMgr->ComponentCreate(ret, outer, classId);
836TOcApp::ComponentInfoGet(IUnknown * * info, IUnknown * outer,
BCID classId)
838 return Registrar.OcClassMgr->ComponentInfoGet(info, outer, classId);
865 OcClassMgr =
new TOcClassMgr(callback,
GetOptions());
866 OcClassMgr->AddRef();
874 OcClassMgr->Release();
875 if (BOleInstance > HINSTANCE(32))
876 ::FreeLibrary(BOleInstance);
891 if (createClassMgr) {
897 createClassMgr(&bcm, 0, 0);
900 bcm->QueryInterface(IID_IBClassMgr, (LPVOID *)&bcmi);
924 IUnknown* objFactory = 0;
938 HRSucceeded(objFactory->QueryInterface(IID_IBClass, (LPVOID *)&classMgr)) &&
942 objFactory->Release();
955 TRACEX(OcfDll, 1,
"CanUnload() AppCount:" << AppCount);
962 OcClassMgr->SetApp(app);
966sGetFileVersionInfo(LPCTSTR fileName, VS_FIXEDFILEINFO& vInfo)
975 infoSize = ::GetFileVersionInfoSize(
OleStr(fileName), &infoHandle);
979 viBuff =
new OLECHAR[(int)infoSize];
983 if (::GetFileVersionInfo(
OleStr(fileName), 0, infoSize, viBuff)) {
989 VS_FIXEDFILEINFO * vInfoPtr;
990 if (::VerQueryValue(viBuff,
_T(
"\\"), (LPVOID *)&vInfoPtr, &vInfoLen)) {
1006sSearchFile(LPCTSTR dir, LPCTSTR name) ->
tstring
1011 const auto n = ::SearchPath(dir, name,
nullptr,
static_cast<DWORD
>(path.size()), &path[0],
nullptr);
1013 if (n < path.size()) { path.resize(n);
break; }
1016 const auto attributes = ::GetFileAttributes(path.c_str());
1017 const auto isFile = attributes != INVALID_FILE_ATTRIBUTES && !(attributes & FILE_ATTRIBUTE_DIRECTORY);
1018 return isFile ? path :
tstring{};
1030sFindBOle(LPCTSTR name) ->
tstring
1032 static const int anchor = 0;
1033 auto ocfModule = HMODULE{};
1034 const auto flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT;
1035 if (::GetModuleHandleEx(flags,
reinterpret_cast<LPCTSTR
>(&anchor), &ocfModule))
1040 const auto n = ::GetModuleFileName(ocfModule, &modulePath[0],
static_cast<DWORD
>(modulePath.size()));
1041 if (n == 0) { modulePath.clear();
break; }
1042 if (n < modulePath.size()) { modulePath.resize(n);
break; }
1043 modulePath.resize(modulePath.size() * 2);
1045 const auto i = modulePath.find_last_of(
_T(
"\\/"));
1046 if (i != tstring::npos)
1048 const auto path = sSearchFile(modulePath.substr(0, i).c_str(), name);
1049 if (!path.empty())
return path;
1052 return sSearchFile(
nullptr, name);
1075 if (!(path = sFindBOle(name)).empty())
1082 VS_FIXEDFILEINFO vInfo;
1083 if (!sGetFileVersionInfo(path.c_str(), vInfo) ||
1091 BOleInstance = ::LoadLibraryEx(path.c_str(),
nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
1097 if (BOleInstance <= HINSTANCE(32))
1112 ResultName(resultName),
1113 Id( id ? id :
_T(
""))
1245 if (::IsWindow(hWnd))
1246 return ::SendMessage(hWnd,
WM_OCEVENT, eventId, (LPARAM)param);
1255 if (::IsWindow(hWnd))
1256 return ::SendMessage(hWnd,
WM_OCEVENT, eventId, param);
TAppDescriptor - OLE application descriptor definitions.
OLE Automation Class Definitions.
#define PRECONDITION(condition)
#define TRACEX(group, level, message)
virtual void _IFUNC ShutdownMaybe()=0
virtual HRESULT _IFUNC IsMDI()=0
virtual LPCOLESTR _IFUNC GetAppName()=0
virtual HRESULT _IFUNC CanEmbed()=0
virtual HRESULT _IFUNC CanLink()=0
IBClass – Supported by BOleFactory.
virtual HRESULT _IFUNC Init(BOOL selfEmbed, LPCOLESTR pszProgId, IBClassMgr *pCM, BCID rid)=0
IClassMgr abstract base class.
IBContainer – Supported by container app's document window.
IBDataConsumer – Supported by containers who want to accept drag/drop and paste.
IBPart – Supported by server objects.
virtual LPCOLESTR _IFUNC GetWindowTitle()=0
virtual void _IFUNC RestoreUI()=0
virtual HWND _IFUNC GetWindow()=0
const owl::TRegLink * GetRegLinkHead() const
owl::TRegLink * GetRegLink(const GUID &clsid)
Get the document template with the given GUID.
OCF Application frame window host class. Receives window events from OcApp.
virtual void EvOcAppRestoreUI()=0
virtual HWND EvOcGetWindow() const =0
virtual bool EvOcAppInsMenus(TOcMenuDescr &sharedMenu)=0
virtual void SetWindow(HWND)
virtual bool EvOcAppProcessMsg(MSG *msg)=0
virtual bool EvOcAppGetAccel(TOcGetAccel *acc)=0
virtual void EvOcAppDialogHelp(TOcDialogHelp &dh)=0
virtual bool EvOcAppShutdown()=0
virtual bool EvOcAppBorderSpaceReq(owl::TRect *rect)=0
virtual bool EvOcAppFrameRect(owl::TRect *rect)=0
virtual void EvOcAppStatusText(const char *rect)=0
virtual bool EvOcAppMenus(TOcMenuDescr &md)=0
virtual bool EvOcAppBorderSpaceSet(owl::TRect *rect)=0
virtual void ReleaseOcObject()
Default implementation of frame window host that uses messages.
bool EvOcAppBorderSpaceReq(owl::TRect *rect)
bool EvOcAppBorderSpaceSet(owl::TRect *rect)
void EvOcAppStatusText(const char *rect)
owl::TResult ForwardEvent(int eventId, const void *param)
HWND EvOcGetWindow() const
bool EvOcAppMenus(TOcMenuDescr &md)
bool EvOcAppInsMenus(TOcMenuDescr &sharedMenu)
bool EvOcAppProcessMsg(MSG *msg)
bool EvOcAppGetAccel(TOcGetAccel *acc)
void EvOcAppDialogHelp(TOcDialogHelp &dh)
bool EvOcAppFrameRect(owl::TRect *rect)
OCF Application host class. Owner of & host for a TOcApp object.
virtual void ReleaseOcObject()
virtual void AttachHost(TOcApp *ocApp)
HRESULT BOleComponentCreate(IUnknown **retIface, IUnknown *outer, owl::uint32 idClass)
Create a BOle helper for one of our OC objects in this app.
void UnregisterClasses()
Unregister doc class factories based on their 'progid' and their templates.
bool Convert(TOcPart *ocPart, bool b)
Open the Convert dialog, and perform the conversion if OK.
friend class _ICLASS TOcPart
bool Paste(TOcInitInfo &initInfo)
void AddUserFormatName(LPCTSTR name, LPCTSTR resultName, LPCTSTR id=0)
Add a user defined clipboard format name.
owl::ulong _IFUNC AddRef()
bool BrowseClipboard(TOcInitInfo &initInfo)
bool BrowseControls(TOcInitInfo &initInfo)
void EvResize()
Let BOle know that the main window has resized.
bool Copy(TOcPart *ocPart)
Copy Selected embedded object.
~TOcApp()
Clean up this object be releasing all helpers.
owl::ulong _IFUNC Release()
void SetupWindow(TOcAppFrameHost *frameHost)
TOcAppFrameHost * FrameHost
bool RegisterClass(const owl::tstring &progid, BCID classId, bool multiUse)
virtual void ReleaseObject()
Should only be called by the owner/creator of this object.
HRESULT QueryObject(const IID &iid, void **iface)
Callback from TUnknown's implementation of QueryInterface.
bool Browse(TOcInitInfo &initInfo)
bool IsOptionSet(owl::uint32 option) const
owl::uint EnableEditMenu(TOcMenuEnable enable, IBDataConsumer *ocview)
bool UnregisterClass(const owl::tstring &progid)
void RegisterClasses()
Register doc factories based on their 'progid' and their templates.
TOcApp(TOcRegistrar ®istrar, owl::uint32 options, TOcAppHost *host, TOcAppFrameHost *frameHost)
New constructor for TOcApp using host interfaces.
void EvActivate(bool)
Let BOle know that the main window has [de]activated.
bool Drag(TOcDataProvider *ocData, TOcDropAction inAction, TOcDropAction &outAction)
Drag a selection.
TOcRegistrar & GetRegistrar()
Data Provider object for a container document.
TOcInitInfo(IBContainer *container)
int Add(TOcFormatName *name)
TOcFormatName *& operator[](unsigned index)
owl::ulong _IFUNC Release()
HRESULT _IFUNC QueryInterface(const GUID &iid, void **iface)
Linking & embeding version of the Registrar.
void LoadBOle()
Dynamically load the OcOle Dll, get the one entry point that we need & make the class manager object ...
friend class _ICLASS TOcApp
TOcRegistrar(owl::TRegList ®Info, TComponentFactory callback, owl::uint32 preselectedOptions, owl::tstring &cmdLine, owl::TRegLink *linkHead=0, owl::TModule *module=&owl::GetGlobalModule())
The 'preselectedOptions' parameter enables to preserve old (pre 6.40) behaviour (see Bug #376): Set t...
IBClassMgr * CreateBOleClassMgr()
void * GetFactory(const GUID &clsid, const GUID &iid)
Override TRegistrar's GetFactory to provide additional factory support using BOle factories.
bool IsOptionSet(owl::uint32 option) const
TAppDescriptor & GetAppDescriptor()
owl::uint32 GetOptions() const
virtual void * GetFactory(const GUID &clsid, const GUID &iid)
TRegistrar(owl::TRegList ®Info, TComponentFactory callback, owl::tstring &cmdLine, owl::TModule *module=&owl::GetGlobalModule())
Standard implementation of a controlling IUnknown for an object, to be inherited with other COM inter...
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TRect is a mathematical class derived from tagRect.
A linked structure in which each node points to a list of TRegList objects (or TRegList-derived objec...
TRegLink * GetNext() const
Returns a pointer to the next link.
TRegList & GetRegList() const
Returns a pointer to the registration parameter table (reglist).
A registration parameter table, composed of a list of TRegItems.
#define ocrSingleUse
Single client per instance.
Include for OC, gets common headers when precompiled headers are enabled.
Object Component Framework (COM encapsulation).
HRESULT HRFailIfZero(int bexpr)
HRESULT(PASCAL *) TCreateClassMgr(IUnknown **, IUnknown *, IMalloc *)
bool HRSucceeded(HRESULT hr)
class _ICLASS TOcClassMgr
const BCID cidBOleFactory
IUnknown *(*) TComponentFactory(IUnknown *outer, owl::uint32 options, owl::uint32 id)
@ amAutomation
set from cmdline when EXE lauched for automation
@ amSingleUse
set from app reg, may be forced on per instance
@ amServedApp
per instance flag, app refcnt held by container
@ amExeMode
may be overridden per instance if running DLL
@ amExeModule
set for EXE components, 0 if DLL inproc server
@ amDebug
user requested launching for debugging
@ amEmbedding
cmdline, overridden per Instance if embedded DLL
@ amRun
set in factory call to run application msg loop
const BCID cidBOleService
LPARAM TParam2
Second parameter type.
LRESULT TResult
Result type.
const tchar ** candidates
TModule & GetGlobalModule()
DIAG_DEFINE_GROUP_INIT(OWL_INI, OwlApp, 1, 0)
const TLangId LangSysDefault
DIAG_DECLARE_GROUP(OwlThread)
Definition of TOcApp application connection class.
#define OC_APPBORDERSPACESET
#define OC_APPBORDERSPACEREQ
Definition of TOcPart class.
OLE Registration definitions.
owl::TPointer< ocf::TRegistrar > Registrar
Global registrar object defined by the client application.
#define CONST_CAST(targetType, object)