OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ocapp.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectComponents
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Implementation of TOcApp Class
7//----------------------------------------------------------------------------
8#include <ocf/pch.h>
9#include <ocf/autodefs.h>
10#include <ocf/appdesc.h>
11#include <ocf/ocreg.h>
12#include <ocf/ocapp.h>
13#include <ocf/ocpart.h>
14# include <winver.h>
15
16namespace ocf {
17
18using namespace owl;
19
20using namespace std;
21
25
26//
27/// Compatibility constructor & SetupWindow for TOcApp
28//
30:
31 Host(0),
32 FrameHost(new TOcAppFrameHostMsg(this)), // Use default, msg based host
33 OcAppPtr(&retOcApp),
34 Options(options),
35 DisableDlgs(false),
37 Registered(false)
38{
39 Registrar.AppCount++;
40 Init();
42
43 *OcAppPtr = this; // Setup the client's pointer last if all else is OK
44 TRACEX(OcfRefCount, 1, "TOcApp() @" << (void*)this);
45
46 // !CQ Could calculate Host from OcAppPtr, assuming a TOcAppHost
47 // Host = (char*)OcAppPtr - int(&(TOcAppHost*)0->OcAppPtr);
48}
49
50//
52{
53 FrameHost->SetWindow(frameWnd); // Pass frame's hWnd over to frame host
54
55 Registrar.SetApp(this);
56}
57
58//
59/// New constructor for TOcApp using host interfaces
60//
63:
64 Host(host),
65 FrameHost(frameHost),
66 OcAppPtr(0),
67 Options(options),
68 DisableDlgs(false),
70 Registered(false)
71{
74
75 Registrar.AppCount++;
76 Init();
78
79 if (Host)
80 Host->AttachHost(this);
81
82 TRACEX(OcfRefCount, 1, "TOcApp() @" << (void*)this);
83}
84
85//
90
91//
92/// Common constructor initialization
93//
94void
95TOcApp::Init()
96{
97 // Initialize BOle service ptrs that may or may not get setup later
98 //
99 BService = 0;
100 BServiceI = 0;
101
102 AddRef(); // TUnknown defaults to 0, we need 1
103
104 // Create a BOle class manager for this app
105 //
106 BCmI = Registrar.CreateBOleClassMgr();
107
108 // Create BOle service object & get its interface
109 //
111 if (BService && HRSucceeded(BService->QueryInterface(IID_IBService2,
112 (LPVOID *)&BServiceI))) {
113 Release();
114 BServiceI->Init(this);
115 }
116 else
117 TXObjComp::Throw(TXObjComp::xBOleBindFail); // give up if no IBService2
118
119 // Get the clipboard format strings
120 //
121 for (uint i = IDS_CFFIRST; i <= IDS_CFLAST; i++) {
122 TCHAR name[128];
123 if(GetGlobalModule().LoadString(i, name, 128)){
124 _TCHAR* resultName = _tcschr(name, _T('\n'));
125 *resultName++ = 0;
126 NameList.Add(new TOcFormatName(name, resultName));
127 }
128 }
129
130 // Get & copy the appname from the reginfo
131 //
132 Name = Registrar.GetAppDescriptor().GetAppName(LangSysDefault);
133}
134
135//
136/// Clean up this object be releasing all helpers.
137//
139{
140 // We're gone, make sure nobody calls us through unref'd ptr
141 //
142 if (OcAppPtr) // !CQ OcAppPtr for compatibility
143 *OcAppPtr = 0;
144 if (Host) {
146 Host = 0;
147 }
148
150
151 // RefCnt was held by controller
152 //
153 if (FrameHost) {
154 if (FrameHost->EvOcAppShutdown() &&
156 Registrar.Shutdown(0, Options);
157 }
159 FrameHost = 0;
160 }
161
162 if (BService)
163 BService->Release();
164 Registrar.AppCount--;
165 if (BCmI)
166 BCmI->Release();
167}
168
169//
170/// Should only be called by the owner/creator of this object
171//
172void
174{
175 if (Host) {
177 Host = 0;
178 }
179 if (FrameHost) {
181 FrameHost = 0;
182 }
184 Release(); // if our container app holds the refcnt, then release it
185}
186
187//
188/// Callback from TUnknown's implementation of QueryInterface
189//
192{
193 HRESULT hr;
194
195 static_cast<void>
196 (
197 // interfaces
200
201 // helpers
202 || (BService && SUCCEEDED(hr = BService->QueryInterface(iid, iface)))
203 );
204 return hr;
205}
206
207//----------------------------------------------------------------------------
208
209//
210/// Create a BOle helper for one of our OC objects in this app
211//
214{
215 return BCmI->ComponentCreate(iface, outer, idClass);
216}
217
218//----------------------------------------------------------------------------
219// Runtime document factory registration
220
221//
222/// Register doc factories based on their 'progid' and their templates
223//
224void
226{
227 if (Registered)
228 return;
229
230 // No class registration for InProc Servers
231 //
232 if (!(IsOptionSet(amExeModule)))
233 return;
234
235 // No class registration for single use apps unless embedded
236 //
239 return;
240
241 // Loop thru all templates, registering registerable classes
242 //
244 for ( ; link; link = link->GetNext()) {
245 TRegList& regList = link->GetRegList();
246 const _TCHAR* progid = regList[IsOptionSet(amDebug) ? "debugprogid" : "progid" ];
247 if (progid) {
248
249 // Don't register container classes unless embedding
250 //
251 if (!IsOptionSet(amEmbedding) &&
252 !(const _TCHAR*)regList["insertable"])
253 continue;
254
256 if (multiUse) {
257 const _TCHAR* usage = regList.Lookup("usage");
259 multiUse = ToBool(!(usage && *usage == *su));
260 }
261 if (!RegisterClass(progid, reinterpret_cast<BCID>(link), multiUse))
263 }
264 }
265 Registered = true;
266}
267
268//
269/// Unregister doc class factories based on their 'progid' and their templates
270//
271void
273{
274 if (!Registered)
275 return;
276
277 // Loop thru all templates, unregistering registerable classes
278 //
280 for ( ; link; link = link->GetNext()) {
281 TRegList& regList = link->GetRegList();
282 const _TCHAR* progid = regList[IsOptionSet(amDebug) ? "debugprogid" : "progid" ];
283 if (progid)
284 if (!UnregisterClass(progid))
286 }
287 Registered = false;
288}
289
290//
291/// Add a user defined clipboard format name
292//
293void
298
299
300//----------------------------------------------------------------------------
301// OC side exposure of selected IBService functions
302
303bool
305{
306 if (BServiceI)
307 return HRSucceeded(BServiceI->UnregisterClass(OleStr(className.c_str())));
308 return false;
309}
310
311//
312/// Let BOle know that the main window has resized. In-place servers may need to
313/// adjust their toolbars
314//
315void
317{
318 if (BServiceI)
319 BServiceI->OnResize();
320}
321
322//
323/// Let BOle know that the main window has [de]activated.
324//
325void
327{
328 if (BServiceI)
329 BServiceI->OnActivate(active);
330}
331
332bool
334{
335 // Self-embedding works only if the app is multi-use
336 //
337 if (BServiceI)
338 return HRSucceeded(BServiceI->RegisterClass(OleStr(className.c_str()),
340 return false;
341}
342
343bool
345{
346 return BServiceI ? HRIsOK(BServiceI->CanClose()) : true; // there are no servers running
347}
348
349uint
351{
352 return BServiceI ? BServiceI->EnableEditMenu(menuEnable, ocView) : 0;
353}
354
355bool
357{
358 return BServiceI ? HRIsOK(BServiceI->Browse(&init)) : false;
359}
360
361bool
363{
364 return BServiceI ? HRIsOK(BServiceI->BrowseControls(&init)) : false;
365}
366
367bool
369{
370 return BServiceI ? HRIsOK(BServiceI->BrowseClipboard(&init)): false;
371}
372
373bool
375{
376 return BServiceI ? HRIsOK(BServiceI->Paste(&init)) : false;
377}
378
379//
380/// Copy Selected embedded object
381//
382bool
384{
385 IBPart* bPartI;
386 if (ocPart && SUCCEEDED(ocPart->QueryInterface(IID_IBPart, (LPVOID *)&bPartI))) {
387 ocPart->Release();
388
389 // Copy part with delayed rendering done by Bolero
390 //
391 return BServiceI ? HRIsOK(BServiceI->Clip(bPartI, true, true, true)) : false;
392 }
393 return false;
394}
395
396//
397/// Copy a selection in server document
398//
399bool
401{
403
404 if (BServiceI)
405 BServiceI->Clip(0, false, false, false);
406 else
407 return false;
408
409 return HRIsOK(BServiceI->Clip(ocData, true, true, false));
410}
411
412//
413/// Drag a selection
414//
415bool
417{
419
420 return BServiceI? HRSucceeded(BServiceI->Drag(ocData, inAction, &outAction)) : false;
421}
422
423//
424/// Drag an embedded object
425//
426bool
428{
429#if 1
430 IBPart * bPartI;
431 if (ocPart && SUCCEEDED(ocPart->QueryInterface(IID_IBPart, (LPVOID *)&bPartI))) {
432 ocPart->Release();
433 // Drag part with delayed rendering done by Bolero
434 //
435 return HRSucceeded(BServiceI->Drag(bPartI, inAction, &outAction));
436 }
437 return false;
438#else
439 return BServiceI? HRSucceeded(BServiceI->Drag(ocPart, inAction, &outAction)) : false;
440#endif
441}
442
443//
444/// Open the Convert dialog, and perform the conversion if OK. return true if
445/// conversion was perfromed successfully.
446//
447bool
449{
451
452 if (BServiceI == 0)
453 return false;
454
455 // The Convert dialog is split into two pieces: one to run the dialog box
456 // and one to do the actual work. This way, the caller can record the
457 // actions of the dialog box for playback later.
458 //
460 if (HRIsOK(BServiceI->ConvertUI(ocPart->GetBPartI(), b, &ci)))
461 return HRSucceeded(BServiceI->ConvertGuts(ocPart->GetBPartI(), b, &ci));
462
463 return false;
464}
465
466//----------------------------------------------------------------------------
467// IBApplication implementation
468
469//
470/// Return the application's name
471//
473TOcApp::GetAppName()
474{
475 return Name;
476}
477
479TOcApp::HelpMode(TOcHelp /*newMode*/)
480{
481 // No built in help support
482 //
483 return hlpExit;
484}
485
486//
487/// Insert the container's menus into a provided menubar
488//
490TOcApp::InsertContainerMenus(HMENU hMenu, TOcMenuWidths * omw)
491{
493 if (!hMenu)
494 return HR_NOERROR;
495
496 TOcMenuDescr md;
497 md.HMenu = hMenu;
498
499 int i;
500 for (i = 0; i < 6; i++) {
501 md.Width[i] = 0; // make sure the server's are zeroed
502 omw->Width[i] = 0; // make sure the server's are zeroed
503 i++;
504 md.Width[i] = (int)omw->Width[i];
505 }
506
508 return HR_FAIL;
509
510 for (i = 0; i < 6; i++)
511 omw->Width[i] = md.Width[i];
512
513 return HR_NOERROR;
514}
515
516//
517/// Now set the provided menubar into the container's main frame window
518//
520TOcApp::SetFrameMenu(HMENU hMenu)
521{
522 TOcMenuDescr md;
523 md.HMenu = hMenu;
525}
526
527//
528//
529//
531TOcApp::Accelerator(MSG* msg)
532{
534
536}
537
538//
539/// Let BOle know if we (container app) have an accelerator table
540//
542TOcApp::GetAccelerators(HACCEL * phAccel, int * pcAccel)
543{
544 TOcGetAccel acc;
545 if (FrameHost) {
547 *phAccel = acc.Accel;
548 *pcAccel = acc.Count;
549 return HR_NOERROR;
550 }
551 }
552 return HR_FAIL; // would retrieve or generate an accelerator table here
553}
554
555//
556/// Let BOle know if this app can/will accept links
557//
559TOcApp::CanLink()
560{
561 return HR_OK; // return HR_FAIL to disallow Linking
562}
563
564//
565/// Let BOle know if this app can/will accept embeddings
566//
568TOcApp::CanEmbed()
569{
570 return HR_OK; // return HR_FAIL to disallow Embedding
571}
572
573//
574/// Get and return the app frame's HWND
575//
577TOcApp::GetWindow()
578{
579 return FrameHost ? FrameHost->EvOcGetWindow() : 0;
580}
581
582//
583// Get client rectangle of app's main frame window
584//
586TOcApp::GetWindowRect(TRect* r)
587{
589
591}
592
593//
594/// Return the app's title, same as GetAppName()
595//
597TOcApp::GetWindowTitle()
598{
599 return Name;
600}
601
602//
603/// The server is asking for space along the app borders to put toolbars, etc.
604/// This call is used to determine whether the container is willing and able to
605/// provide a given combination.
606//
608TOcApp::RequestBorderSpace(const TRect* space)
609{
610 TRect* nc_space = CONST_CAST(TRect*, space); /// Ack!
612}
613
614//
615/// Now, actually provide the space along the app frame borders for inplace
616/// server adornments
617//
619TOcApp::SetBorderSpace(const TRect* space)
620{
621 TRect * nc_space = CONST_CAST(TRect*, space); /// Ack!
623}
624
625//
626/// Append supplied Ole title to frame's title, saving old title
627//
628void _IFUNC
629TOcApp::AppendWindowTitle(LPCOLESTR /*title*/)
630{
631 ///
632}
633
634//
635/// Pass status bar text to container app to have app display it
636//
638TOcApp::SetStatusText(LPCOLESTR text)
639{
640 // Convert OLE str into ANSI
641 //
642 if (FrameHost) {
644 return HR_OK;
645 }
646 return HR_FAIL;
647// return HRFailIfZero(FrameHost && FrameHost->EvOcAppStatusText(OleStr(text)));
648}
649
650//
651/// Respond to let BOle know if our app is MDI or not
652//
654TOcApp::IsMDI()
655{
656 // Since this flag is used only to do toolbar negotiation,
657 // we're always MDI as far as BOle is concerned.
658 //
659 return HR_NOERROR;
660}
661
662//
663/// The server is entering or leaving a modal state. Keep track so that we don't
664/// interfere when it is modal.
665//
667TOcApp::OnModalDialog(BOOL svrModal)
668{
669 DisableDlgs = (bool)svrModal;
670 return HR_NOERROR;
671}
672
673//
674/// The in-place server is done. Tell the container to restore its normal UI.
675/// We can handle the window text here, let the app do the rest.
676//
677void _IFUNC
678TOcApp::RestoreUI()
679{
680 SetStatusText(0);
681 if (FrameHost)
683}
684
685//
686//
687//
688void _IFUNC
689TOcApp::DialogHelpNotify(TOcDialogHelp help)
690{
691 if (FrameHost)
693}
694
695//
696/// Called by BOle when last embedding is closed
697/// If that's the only reason the app is up we need to shut ourselves down
698//
699void _IFUNC
700TOcApp::ShutdownMaybe()
701{
702 TRACEX(OcfApp, 1,
703 "ShutdownMaybe() on " << (void*)this <<
704 " Embedding:" << (int)ToBool(IsOptionSet(amEmbedding)) <<
705 " Win:" << hex << static_cast<void*>(GetWindow()));
706
707 // Check first to see if TOcApp should initiate a shutdown
708 //
709 if (!FrameHost || FrameHost->EvOcAppShutdown() || !GetWindow()) {
710 // The server initiated the shutdown
711 //
712 if (!IsOptionSet(amExeMode)) { // DLL server
713 AddRef(); // Prevent destroying ourselves yet
714 Registrar.Shutdown((IUnknown*)(void*)this, Options);
715 Release(); // This should do us in now
716 }
717 }
718}
719
720//-----------------------------------------------------------------------------
721// TOcClassMgr, IBClassMgr implementation for TOcRegistrar
722//
723
724class _ICLASS TOcClassMgr : private TUnknown, public IBClassMgr {
725 public:
726 TOcClassMgr(TComponentFactory cc, uint32 options);
727 ~TOcClassMgr();
728 ulong _IFUNC AddRef() ;
729 ulong _IFUNC Release();
730
731 void SetApp(TOcApp* app) {OcApp = app;}
732
733 private:
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);
740 // TUnknown virtual overrides
741 //
742 HRESULT QueryObject(const IID & iid, void * * iface);
743
744 TComponentFactory OcCallback; // Callback for creating component
745 uint32 Options; // Options flags from TOcRegistrar
746 TOcApp* OcApp;
747 friend class TOcApp; // could delegate the interface instead...
748};
749
750TOcClassMgr::TOcClassMgr(TComponentFactory cc, uint32 options)
751:
752 OcCallback(cc),
753 Options(options),
754 OcApp (0)
755{
756}
757
758TOcClassMgr::~TOcClassMgr()
759{
760}
761
763TOcClassMgr::AddRef()
764{
765 return GetOuter()->AddRef();
766}
767
769TOcClassMgr::Release()
770{
771 return GetOuter()->Release();
772}
773
774//
775// IBClassMgr implementation for TOcRegistrar
776//
778TOcClassMgr::ComponentCreate(IUnknown * * retIface, IUnknown * outer, BCID idClass)
779{
781
782 *retIface = 0;
783 if (!OcCallback)
784 return HR_FAIL;
785
786 try {
787
788 // Test for special condition to force run as an EXE
789 //
790 void * v;
791 if (outer && !(Options & amExeModule) && outer->QueryInterface(IID_NULL, &v) == HR_NOERROR)
792 *retIface = OcCallback(0, Options | amExeMode | amRun, idClass);
793 else
794 *retIface = OcCallback(outer, Options | amEmbedding, idClass);
795 return *retIface ? HR_OK : HR_FAIL;
796 }
797 catch (...) { // we can't throw any exception through OLE
798 // if an exception occur shutdown the application if it needs to be so
799 if (OcApp)
800 OcApp->ShutdownMaybe ();
801
802 return HR_OUTOFMEMORY; // probably a resource problem, better error code?
803 }
804}
805
807TOcClassMgr::ComponentInfoGet(IUnknown * * info, IUnknown * /*outer*/,
808 BCID /*idClass*/)
809{
810 *info = 0;
811 return HR_FAIL;
812}
813
815TOcClassMgr::QueryObject(const IID & iid, void * * iface)
816{
817 HRESULT hr;
818
819 // interfaces
821 ;
822 return hr;
823}
824
825//----------------------------------------------------------------------------
826// IBClassMgr implementation for TOcApp
827//
828
830TOcApp::ComponentCreate(IUnknown * * ret, IUnknown * outer, BCID classId)
831{
832 return Registrar.OcClassMgr->ComponentCreate(ret, outer, classId);
833}
834
836TOcApp::ComponentInfoGet(IUnknown * * info, IUnknown * outer, BCID classId)
837{
838 return Registrar.OcClassMgr->ComponentInfoGet(info, outer, classId);
839}
840
841//-----------------------------------------------------------------------------
842// TOcRegistrar
843//
844/// The 'preselectedOptions' parameter enables to preserve old (pre 6.40)
845/// behaviour (see Bug #376):
846/// Set to amQuietReg, no exception is thrown on registration failures
847/// which nowadays occur frequently due to restricted user rights during
848/// registration updates.
849/// This option should only be set when cmdLine is empty, otherwise wanted
850/// exceptions on registration failures will be suppressed too.
851/// The amNoRegValidate bit may be set to suppress the automatic registration
852/// update at all.
853//
857 TModule* module)
858:
860 BOleInstance(0),
861 BCmI(0),
862 OcClassMgr(0),
863 AppCount(0)
864{
865 OcClassMgr = new TOcClassMgr(callback, GetOptions());
866 OcClassMgr->AddRef();
867}
868
870{
871 if (BCmI)
872 BCmI->Release();
873 if (OcClassMgr)
874 OcClassMgr->Release();
875 if (BOleInstance > HINSTANCE(32))
876 ::FreeLibrary(BOleInstance);
877}
878
879//
880// Create and return a BOle class manager helper interface with 1 ref on it
881//
882
883typedef HRESULT (PASCAL *TCreateClassMgr)(IUnknown**, IUnknown*, IMalloc*);
884
887{
888 if (!BOleInstance)
889 LoadBOle();
890 TCreateClassMgr createClassMgr = (TCreateClassMgr)::GetProcAddress(BOleInstance, BOLEBIND);
891 if (createClassMgr) {
892
893 // Call thru the exported function to get a BOle class manager
894 // Don't aggregate it to anything
895 //
896 IUnknown* bcm;
897 createClassMgr(&bcm, 0, 0);
898 if (bcm) {
899 IBClassMgr* bcmi = nullptr;
900 bcm->QueryInterface(IID_IBClassMgr, (LPVOID *)&bcmi);
901 bcm->Release();
902 if (bcmi)
903 return bcmi;
904 }
905 }
907 return 0; // never reached
908}
909
910//
911/// Override TRegistrar's GetFactory to provide additional factory support
912/// using BOle factories
913//
914void*
916{
917 void* factory = TRegistrar::GetFactory(clsid, iid);
918 if (factory)
919 return factory;
920
921 if (!BCmI)
922 BCmI = CreateBOleClassMgr();
923
924 IUnknown* objFactory = 0;
925 IBClass* classMgr = 0;
926
928 if (!link)
929 return 0;
930
931 TRegList& regList = link->GetRegList();
932 LPCTSTR progid = regList[IsOptionSet(amDebug) ? "debugprogid" : "progid" ];
933
934 // Create BoleFactory helper object & init it, giving it our OcClassMgr
935 // object to work with
936 //
938 HRSucceeded(objFactory->QueryInterface(IID_IBClass, (LPVOID *)&classMgr)) &&
939 HRSucceeded(classMgr->Init(false, OleStr(progid), OcClassMgr, reinterpret_cast<BCID>(link))) &&
940 HRSucceeded(classMgr->QueryInterface(iid, &factory)))) {
941 if (objFactory)
942 objFactory->Release();
943 if (classMgr)
944 classMgr->Release();
945
946 return 0;
947 }
948
949 return factory;
950}
951
952bool
954{
955 TRACEX(OcfDll, 1, "CanUnload() AppCount:" << AppCount);
956 return TRegistrar::CanUnload() && AppCount == 0;
957}
958
959void
961{
962 OcClassMgr->SetApp(app);
963}
964
965static bool
966sGetFileVersionInfo(LPCTSTR fileName, VS_FIXEDFILEINFO& vInfo)
967{
968 OLECHAR* viBuff; // version buffer
969 uint32 infoSize; // Size of version info resource in file
970
971 // Find out how big the file version info buffer is supposed to be and
972 // create a buffer of that size
973 //
975 infoSize = ::GetFileVersionInfoSize(OleStr(fileName), &infoHandle);
976 if (infoSize == 0)
977 return false;
978
979 viBuff = new OLECHAR[(int)infoSize];
980
981 // Copy the file version info buffer from the file into viBuff
982 //
983 if (::GetFileVersionInfo(OleStr(fileName), 0, infoSize, viBuff)) {
984
985 // Perform some magic on the phantom buffer to get an actual structure with
986 // the version information
987 //
990 if (::VerQueryValue(viBuff, _T("\\"), (LPVOID *)&vInfoPtr, &vInfoLen)) {
991 vInfo = *vInfoPtr;
992 delete[] viBuff;
993 return true;
994 }
995 }
996 delete[] viBuff;
997 return false;
998}
999
1000//
1001/// Dynamically load the OcOle Dll, get the one entry point that we need &
1002/// make the class manager object that we use
1003//
1004void
1006{
1007 // Check BOle DLL existance & version first, failing if it is incompatible
1008 // (old)
1009 //
1010 char name[30];
1011 OFSTRUCT ofs;
1012 ofs.cBytes = sizeof ofs;
1013
1014#ifdef NT_PREFERS_UNICODE_INSTEAD_OF_ANSI
1015 bool winNT = !ToBool(::GetVersion()&0x80000000);
1016 if (winNT) // NT platform
1017 {
1019
1020 // Try the ANSI dll if couldn't find Unicode version
1023 }
1024 else
1025#endif
1028
1029 if (::OpenFile(name, &ofs, OF_EXIST) >= 0) {
1031 if (!sGetFileVersionInfo(_A2W(name), vInfo) ||
1032 vInfo.dwFileVersionMS < BOLE_FILEVER_MS ||
1033 (
1034 vInfo.dwFileVersionMS == BOLE_FILEVER_MS &&
1035 vInfo.dwFileVersionLS < BOLE_FILEVER_LS
1036 ))
1038
1039 BOleInstance = ::LoadLibraryA(ofs.szPathName);
1040 }
1041
1042 // If we failed to load the DLL, throw a general cannot-load exception.
1043 // Otherwise get the class manager interface
1044 //
1045 if (BOleInstance <= HINSTANCE(32))
1047}
1048
1049//-----------------------------------------------------------------------------
1050// TOcFormatName
1051//
1052
1056
1058:
1059 Name(name),
1060 ResultName(resultName),
1061 Id( id ? id : _T(""))
1062{
1063}
1064
1065//----------------------------------------------------------------------------
1066// TOcNameList
1067//
1068
1072
1074{
1075 Clear();
1076}
1077
1078//
1079/// Find the format name with the corresponding id
1080//
1083{
1084 for (uint i = 0; i < Count(); i++) {
1085 TOcFormatName* formatName = (*this)[i];
1086 if (_tcscmp(formatName->GetId(), id) == 0)
1087 return formatName;
1088 }
1089
1090 return 0;
1091}
1092
1093//----------------------------------------------------------------------------
1094// TOcInitInfo
1095//
1096
1098:
1099 How(ihEmbed),
1100 Where(iwNew),
1101 Container(container),
1102 HIcon(0),
1103 Storage(0)
1104{
1105}
1106
1108:
1109 How(how),
1110 Where(where),
1111 Container(container),
1112 HIcon(0),
1113 Storage(0)
1114{
1115}
1116
1117//----------------------------------------------------------------------------
1118// Default FrameHost class implementation for compatibility. Forwards events
1119// to FrameWindow using windows messages
1120//
1121
1122//
1123bool
1128
1129bool
1134
1135bool
1140
1141bool
1146
1147bool
1152
1153bool
1158
1159void
1164
1165void
1170
1171void
1176
1177bool
1182
1183bool
1188
1189TResult
1191{
1193 if (::IsWindow(hWnd))
1194 return ::SendMessage(hWnd, WM_OCEVENT, eventId, (LPARAM)param);
1195
1196 return 0;
1197}
1198
1199TResult
1201{
1203 if (::IsWindow(hWnd))
1204 return ::SendMessage(hWnd, WM_OCEVENT, eventId, param);
1205
1206 return 0;
1207}
1208
1209} // OCF namespace
1210
1211//==============================================================================
1212
TAppDescriptor - OLE application descriptor definitions.
OLE Automation Class Definitions.
#define PRECONDITION(condition)
Definition checks.h:227
#define DIAG_DECLARE_GROUP(group)
Definition checks.h:404
#define TRACEX(group, level, message)
Definition checks.h:263
#define DIAG_DEFINE_GROUP_INIT(f, g, e, l)
Definition checks.h:429
IBClass – Supported by BOleFactory.
Definition ocbocole.h:557
IClassMgr abstract base class.
Definition ocbocole.h:184
virtual HRESULT _IFUNC ComponentCreate(IUnknown **ppRet, IUnknown *pAggregator, BCID classId)=0
IBContainer – Supported by container app's document window.
Definition ocbocole.h:398
IBDataConsumer – Supported by containers who want to accept drag/drop and paste.
Definition ocbocole.h:212
IBPart – Supported by server objects.
Definition ocbocole.h:241
const owl::TRegLink * GetRegLinkHead() const
Definition appdesc.h:66
LPCTSTR GetAppName(owl::TLangId lang)
Definition appdesc.h:110
owl::TRegLink * GetRegLink(const GUID &clsid)
Get the document template with the given GUID.
Definition appdesc.cpp:548
OCF Application frame window host class. Receives window events from OcApp.
Definition ocapp.h:402
virtual void EvOcAppRestoreUI()=0
virtual HWND EvOcGetWindow() const =0
virtual bool EvOcAppInsMenus(TOcMenuDescr &sharedMenu)=0
virtual void SetWindow(HWND)
Definition ocapp.h:423
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()
Definition ocapp.h:406
Default implementation of frame window host that uses messages.
Definition ocapp.h:434
bool EvOcAppBorderSpaceReq(owl::TRect *rect)
Definition ocapp.cpp:1148
bool EvOcAppBorderSpaceSet(owl::TRect *rect)
Definition ocapp.cpp:1154
void EvOcAppStatusText(const char *rect)
Definition ocapp.cpp:1160
owl::TResult ForwardEvent(int eventId, const void *param)
Definition ocapp.cpp:1190
HWND EvOcGetWindow() const
Definition ocapp.h:452
bool EvOcAppMenus(TOcMenuDescr &md)
Definition ocapp.cpp:1130
bool EvOcAppInsMenus(TOcMenuDescr &sharedMenu)
Definition ocapp.cpp:1124
bool EvOcAppProcessMsg(MSG *msg)
Definition ocapp.cpp:1136
bool EvOcAppGetAccel(TOcGetAccel *acc)
Definition ocapp.cpp:1184
void EvOcAppDialogHelp(TOcDialogHelp &dh)
Definition ocapp.cpp:1172
bool EvOcAppFrameRect(owl::TRect *rect)
Definition ocapp.cpp:1142
OCF Application host class. Owner of & host for a TOcApp object.
Definition ocapp.h:367
virtual void ReleaseOcObject()
Definition ocapp.h:378
virtual void AttachHost(TOcApp *ocApp)
Definition ocapp.h:377
OCF Application class.
Definition ocapp.h:144
HRESULT BOleComponentCreate(IUnknown **retIface, IUnknown *outer, owl::uint32 idClass)
Create a BOle helper for one of our OC objects in this app.
Definition ocapp.cpp:213
void UnregisterClasses()
Unregister doc class factories based on their 'progid' and their templates.
Definition ocapp.cpp:272
bool Convert(TOcPart *ocPart, bool b)
Open the Convert dialog, and perform the conversion if OK.
Definition ocapp.cpp:448
bool Paste(TOcInitInfo &initInfo)
Definition ocapp.cpp:374
void AddUserFormatName(LPCTSTR name, LPCTSTR resultName, LPCTSTR id=0)
Add a user defined clipboard format name.
Definition ocapp.cpp:294
owl::ulong _IFUNC AddRef()
Definition ocapp.h:215
TOcApp ** OcAppPtr
Definition ocapp.h:229
bool BrowseClipboard(TOcInitInfo &initInfo)
Definition ocapp.cpp:368
bool BrowseControls(TOcInitInfo &initInfo)
Definition ocapp.cpp:362
void EvResize()
Let BOle know that the main window has resized.
Definition ocapp.cpp:316
bool Copy(TOcPart *ocPart)
Copy Selected embedded object.
Definition ocapp.cpp:383
TOcAppHost * Host
Definition ocapp.h:225
bool Registered
Definition ocapp.h:223
~TOcApp()
Clean up this object be releasing all helpers.
Definition ocapp.cpp:138
owl::ulong _IFUNC Release()
Definition ocapp.h:216
void SetupWindow(TOcAppFrameHost *frameHost)
Definition ocapp.cpp:86
TOcAppFrameHost * FrameHost
Definition ocapp.h:226
bool RegisterClass(const owl::tstring &progid, BCID classId, bool multiUse)
Definition ocapp.cpp:333
virtual void ReleaseObject()
Should only be called by the owner/creator of this object.
Definition ocapp.cpp:173
HRESULT QueryObject(const IID &iid, void **iface)
Callback from TUnknown's implementation of QueryInterface.
Definition ocapp.cpp:191
bool Browse(TOcInitInfo &initInfo)
Definition ocapp.cpp:356
bool IsOptionSet(owl::uint32 option) const
Definition ocapp.h:302
owl::uint EnableEditMenu(TOcMenuEnable enable, IBDataConsumer *ocview)
Definition ocapp.cpp:350
bool UnregisterClass(const owl::tstring &progid)
Definition ocapp.cpp:304
owl::uint32 Options
Definition ocapp.h:222
void RegisterClasses()
Register doc factories based on their 'progid' and their templates.
Definition ocapp.cpp:225
TOcApp(TOcRegistrar &registrar, owl::uint32 options, TOcAppHost *host, TOcAppFrameHost *frameHost)
New constructor for TOcApp using host interfaces.
Definition ocapp.cpp:61
bool CanClose()
Definition ocapp.cpp:344
void EvActivate(bool)
Let BOle know that the main window has [de]activated.
Definition ocapp.cpp:326
bool Drag(TOcDataProvider *ocData, TOcDropAction inAction, TOcDropAction &outAction)
Drag a selection.
Definition ocapp.cpp:416
TOcRegistrar & GetRegistrar()
Definition ocapp.h:162
Data Provider object for a container document.
Definition ocdata.h:30
Clipboard format name.
Definition ocapp.h:52
TOcInitInfo(IBContainer *container)
Definition ocapp.cpp:1097
int Add(TOcFormatName *name)
Definition ocapp.h:82
owl::uint Count() const
Definition ocapp.h:85
void Clear(int del=1)
Definition ocapp.h:81
TOcFormatName *& operator[](unsigned index)
Definition ocapp.h:79
OC part class represents an embeded or linked part in a document.
Definition ocpart.h:38
Linking & embeding version of the Registrar.
Definition ocapp.h:109
void LoadBOle()
Dynamically load the OcOle Dll, get the one entry point that we need & make the class manager object ...
Definition ocapp.cpp:1005
TOcRegistrar(owl::TRegList &regInfo, 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...
Definition ocapp.cpp:854
void SetApp(TOcApp *app)
Definition ocapp.cpp:960
IBClassMgr * CreateBOleClassMgr()
Definition ocapp.cpp:886
void * GetFactory(const GUID &clsid, const GUID &iid)
Override TRegistrar's GetFactory to provide additional factory support using BOle factories.
Definition ocapp.cpp:915
Application registration manager interface class.
Definition ocreg.h:109
bool IsOptionSet(owl::uint32 option) const
Definition ocreg.h:343
TAppDescriptor & GetAppDescriptor()
Definition ocreg.h:153
owl::uint32 GetOptions() const
Definition ocreg.h:350
virtual void Shutdown(IUnknown *releasedObj, owl::uint32 options)
Definition ocreg.cpp:469
virtual void * GetFactory(const GUID &clsid, const GUID &iid)
Definition ocreg.cpp:427
virtual bool CanUnload()
Definition ocreg.cpp:439
IUnknown * GetOuter()
Definition oleutil.h:269
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
A registration parameter table, composed of a list of TRegItems.
Definition registry.h:531
char TCHAR
Definition cygwin.h:42
#define _tcscmp
Definition cygwin.h:75
#define _T(x)
Definition cygwin.h:51
#define _tcschr
Definition cygwin.h:85
#define ocrSingleUse
Single client per instance.
Definition registry.h:726
Include for OC, gets common headers when precompiled headers are enabled.
#define _W2A(lpw)
Definition memory.h:219
#define _A2W(lpw)
Definition memory.h:220
#define _USES_CONVERSION
Definition memory.h:217
Object Component Framework (COM encapsulation)
Definition appdesc.h:22
bool HRIsOK(HRESULT hr)
Definition defs.h:132
TOcDialogHelp
Definition ocobject.h:27
TOcMenuEnable
Definition ocobject.h:145
owl::uint32 BCID
Definition ocbocole.h:109
IUnknown *(* TComponentFactory)(IUnknown *outer, owl::uint32 options, owl::uint32 id)
Definition appdesc.h:35
HRESULT HRFailIfZero(int bexpr)
Definition defs.h:126
TOcInitWhere
Definition ocobject.h:100
@ iwNew
Definition ocobject.h:104
TOcInitHow
Definition ocobject.h:93
@ ihEmbed
Definition ocobject.h:95
class _ICLASS IBClassMgr
Definition ocbocole.h:129
bool HRSucceeded(HRESULT hr)
Definition defs.h:131
class _ICLASS TOcClassMgr
Definition ocapp.h:35
HRESULT(PASCAL * TCreateClassMgr)(IUnknown **, IUnknown *, IMalloc *)
Definition ocapp.cpp:883
const BCID cidBOleFactory
Definition ocbocole.h:117
const GUID & iid
Definition appdesc.h:328
class _ICLASS TOcApp
Definition ocapp.h:36
TOcHelp
Definition ocobject.h:152
@ hlpExit
Definition ocobject.h:153
@ amAutomation
set from cmdline when EXE lauched for automation
Definition ocreg.h:81
@ amSingleUse
set from app reg, may be forced on per instance
Definition ocreg.h:90
@ amServedApp
per instance flag, app refcnt held by container
Definition ocreg.h:89
@ amExeMode
may be overridden per instance if running DLL
Definition ocreg.h:88
@ amExeModule
set for EXE components, 0 if DLL inproc server
Definition ocreg.h:87
@ amDebug
user requested launching for debugging
Definition ocreg.h:85
@ amEmbedding
cmdline, overridden per Instance if embedded DLL
Definition ocreg.h:82
@ amRun
set in factory call to run application msg loop
Definition ocreg.h:92
TOcDropAction
Definition ocobject.h:39
const BCID cidBOleService
Definition ocbocole.h:110
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long ulong
Definition number.h:26
unsigned long uint32
Definition number.h:34
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
bool ToBool(const T &t)
Definition defs.h:291
LRESULT TResult
Result type.
Definition dispatch.h:52
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
TModule & GetGlobalModule()
Definition global.cpp:48
const TLangId LangSysDefault
Definition lclstrng.h:30
Definition of TOcApp application connection class.
#define OC_APPBORDERSPACESET
Definition ocapp.h:347
#define OC_APPBORDERSPACEREQ
Definition ocapp.h:346
#define OC_APPGETACCEL
Definition ocapp.h:352
#define OC_APPSHUTDOWN
Definition ocapp.h:351
#define OC_APPINSMENUS
Definition ocapp.h:342
#define WM_OCEVENT
Definition ocapp.h:337
#define OC_APPFRAMERECT
Definition ocapp.h:345
#define OC_APPRESTOREUI
Definition ocapp.h:349
#define OC_APPPROCESSMSG
Definition ocapp.h:344
#define OC_APPMENUS
Definition ocapp.h:343
#define OC_APPDIALOGHELP
Definition ocapp.h:350
#define OC_APPSTATUSTEXT
Definition ocapp.h:348
#define BOLE_FILEVER_LS
Definition ocbocole.h:44
#define BOLEDLL
Definition ocbocole.h:39
#define BOLEDLLW
Definition ocbocole.h:40
#define BOLEBIND
Definition ocbocole.h:43
#define BOLE_FILEVER_MS
Definition ocbocole.h:45
#define HR_OK
Definition defs.h:74
#define HR_NOERROR
Definition defs.h:73
#define HR_OUTOFMEMORY
Definition defs.h:77
#define HR_FAIL
Definition defs.h:83
Definition of TOcPart class.
OLE Registration definitions.
owl::TPointer< ocf::TRegistrar > Registrar
Global registrar object defined by the client application.
#define _IFUNC
Definition oleutil.h:28
#define _ICLASS
Definition oleutil.h:25
#define OWL_INI
Definition defs.h:170
#define CONST_CAST(targetType, object)
Definition defs.h:273
#define OleStr(s)
Definition string.h:128