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
oclink.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 TOcLinkView Class
7//----------------------------------------------------------------------------
8#include <ocf/pch.h>
9
10#include <ocf/oclink.h>
11#include <ocf/ocapp.h>
12#include <ocf/ocremvie.h>
13
14namespace ocf {
15
16using namespace owl;
17
18//
19//
20//
22:
23 BSiteI(0), OcView(ocView),
24 Origin(0,0),
25 Extent(0,0)
26{
27 PRECONDITION(OcView);
29 AddRef(); // TUnknown defaults to 0, we need 1
30
31 // Create a site for this remote view
32 //
33 if (SUCCEEDED(OcView->OcApp.BOleComponentCreate(&BSite, (IUnknown*)(IBPart*)this,
35
36 if (SUCCEEDED(BSite->QueryInterface(IID_IBSite, (LPVOID *)&BSiteI)))
37 Release();
38
39 // Connect the part and the site
40 //
41 if (BSiteI) {
42 const _TCHAR* progid = regList->Lookup(OcView->OcApp.IsOptionSet(amDebug) ?
43 "debugprogid" : "progid");
44 BSiteI->Init(this, this, OleStr(progid), true);
45 }
46
47 if (SUCCEEDED(BSite->QueryInterface(IID_IBApplication, (LPVOID *)&BAppI)))
48 BAppI->Release(); // avoid deadlock
49 }
50}
51
52//
53//
54//
55TOcLinkView::~TOcLinkView()
56{
57 // Detach the link view
58 //
59 //Detach();
60 if (BSite) {
61 BSite->Release();
62 }
63}
64
65//
66/// Remove this link view from the document
67//
68int
70{
71 return OcView->OcDocument.GetViews().Detach(this);
72}
73
74//
75//
76//
79{
81 HRESULT hr;
82
83 static_cast<void>
84 (
85 // interfaces
86 //
89
90 // helpers
91 //
92 || (BSite && SUCCEEDED(hr = BSite->QueryInterface(iid, iface)))
93 );
94
95 return hr;
96}
97
98//----------------------------------------------------------------------------
99// IBSite pass-thrus
100
101//
102/// Invalidate the site corresponding to this view
103//
104void
106{
107 if (BSiteI)
108 BSiteI->Invalidate(invalid);
109}
110
111//
112/// Disconnect from the client site
113//
114void
116{
117 if (BSiteI)
118 BSiteI->Disconnect();
119}
120
121//
122/// Remember the name of the moniker
123//
124void
126{
127 Moniker = const_cast<LPTSTR>(name); // force TString to copy
128}
129
130
131//----------------------------------------------------------------------------
132// IDataNegotiator implementation -- delegate to our owning OcView
133
134//
135//
136//
139{
140 return OcView->CountFormats();
141}
142
143//
144//
145//
148{
150
151 return OcView->GetFormat(index, fmt);
152}
153
154//----------------------------------------------------------------------------
155// IBDataNegotiator implementation
156
157//
158/// Request native data for pasting into client application.
159/// This is only called at paste time (not at copy time).
160//
163{
165
166 TOcFormat* format = OcView->FormatList.Find(fmt->Id);
167 if (format) {
170 return formatData.Handle;
171 }
172
173 return 0;
174}
175
176//
177/// Get the initial size and position from the host app into our members
178//
179void
181{
182 TOcPartSize ps(true, &Moniker);
183
184 // Ask the app for initial server extent
185 //
186 if (!OcView->ServerHost->EvOcViewPartSize(ps)) {
187 // An empty rect as default means that the container
188 // decides the size for this server
189 //
190 ps.PartRect.SetNull();
191 }
192
193 Extent = ps.PartRect.Size();
194 Origin = ps.PartRect.TopLeft();
195}
196
197//
198/// Render the view in the DC provided. Should be a MetaFile
199/// Packup all the args & forward message to real view to paint
200//
204{
205 PRECONDITION(dc);
206
207 // Rely on the bolero shading
208 //
209 if (bd == drShadingOnly)
210 return HR_NOERROR;
211
212 TRect p((int)pos->left, (int)pos->top, (int)pos->right, (int)pos->bottom);
213 TRect c((int)clip->left, (int)clip->top, (int)clip->right, (int)clip->bottom);
214
215 p.SetEmpty();
216 ::SetMapMode(dc, MM_ANISOTROPIC);
217
218 ::SetWindowExtEx(dc, Extent.cx, Extent.cy, 0);
219 ::SetWindowOrgEx(dc, 0, 0, 0);
220
221 p.Normalize();
222 c.Normalize();
223
224 // Find out where the TOleLinkView is
225 //
226 GetLinkRect();
227 *(TPoint*)&p = Origin;
228
229 TOcViewPaint vp = { dc, &p, &c, (TOcAspect)aspect, false, &Moniker, 0 };
230
231 return HRFailIfZero(OcView->ServerHost->EvOcViewPaint(vp));
232}
233
234//
235/// Return the 'size' of the document that this view in on
236//
239{
240 *size = Extent;
241 return HR_NOERROR;
242}
243
244//
245/// Save the document that we are a view on
246//
256
257#if 0
258//
259//
260//
262TOcLinkView::SetFormatData(TOcFormatInfo * /*fmt*/, HANDLE /*data*/, BOOL /*release*/)
263{
264 return HR_NOTIMPL;
265}
266#endif
267
268//----------------------------------------------------------------------------
269// IBPart implementation
270
271//
272/// Load the associated document and activate the remote view
273//
276{
277 return HR_NOERROR;
278}
279
280//
281/// Close the remote view window, & if canShutDown is true, try to close the server
282/// app too
283//
286{
287 OcView->ServerHost->EvOcViewBreakLink(*this); // !CQ check return?
288 return HR_NOERROR;
289}
290
291//
292/// Query to determine if this view can open in place
293//
296{
297 return HR_FAIL; // Links never open in place
298}
299
300//
301/// Set a new position for our document within its container
302//
305{
306 Origin = *(POINT*)&r->left;
307 return HR_NOERROR;
308}
309
310//
311//
312//
315{
316 Extent = *size;
317 return HR_NOERROR;
318}
319
320//
321/// Activate this view
322//
325{
326 return HR_NOERROR;
327}
328
329//
330/// Show/Hide the server view window
331//
334{
335 return HR_NOERROR;
336}
337
338//
339/// Start or end open editing
340/// Work with the window Z-order and parenting
341//
344{
345 if (open) {
347 if (ocRemView)
348 ocRemView->SetOpenEditing();
349
350 OcView->ServerHost->EvOcViewAttachWindow(true);
351 OcView->BringToFront();
352 }
353
354 return HR_NOERROR;
355}
356
357//
358/// Enumerate the verbs for our document
359//
362{
363 return HR_FAIL; // Not called on BOle parts
364}
365
366//
367/// Perform a verb on our document
368//
371{
372 return HR_FAIL; // Assume that links don't need to do verbs
373}
374
375//
376/// Open or close this view as an in-place edit session. If hWndParent is 0, then
377/// in-place is closing
378//
381{
382 return 0;
383}
384
385//
386/// Insert the server's menus into the shared menubar
387//
390{
391 return HR_NOERROR;
392}
393
394//
395/// Show or hide the tool windows used by our view
396//
399{
400 return HR_NOERROR;
401}
402
403//
404/// A container window has resized. Perform any necessary adjustment of our
405/// tools.
406//
407void _IFUNC
408TOcLinkView::FrameResized(const TRect * /*contFrameR*/, BOOL /*isMainFrame*/)
409{
410}
411
412//
413/// Let the server provide drag feedback
414//
417{
419 TOcDragDrop dd = { 0, &awhere, 0 };
420 return HRFailIfZero(OcView->ServerHost->EvOcViewDrag(dd));
421}
422
423//
424/// Optional palette query for
425//
433
434//
435//
436//
439{
440 return HR_FAIL; // Not called on BOle parts.
441}
442
443//
444//
445//
448{
450
451 return OcView->QueryInterface(iid, iface); // Unused on server side
452}
453
454//
455//
456//
459{
460 return 0; // Not called on BOle parts.
461}
462
463
464//----------------------------------------------------------------------------
465// TOcLinkCollection
466//
467
468//
469//
470//
474
475//
476//
477//
482
483//
484/// Release Views in the collection
485//
486void
488{
489 for (int i = Count() - 1; i >= 0; i--) {
490 TOcLinkView* view = (TOcLinkView*)(*this)[i];
491 view->Release();
492 Base::Detach(i); ///DR why do we want to keep data after a clear? Remove it.
493 }
494}
495
496//
497//
498//
499int
501{
502 int ret = Base::Detach(Find(view));
503 if (ret && del)
504 const_cast<TOcLinkView*>(view)->Release();
505 return ret;
506}
507
508//
509//
510//
513{
514 for (TOcViewCollectionIter j((TOcViewCollection&)*this); j; j++) {
515 TOcLinkView* view = (TOcLinkView*)j.Current();
516 if (view && strcmp(view->GetMoniker(), moniker) == 0) {
517 return view;
518 }
519 }
520
521 return 0;
522}
523
524} // OCF namespace
525
526//==============================================================================
527
#define PRECONDITION(condition)
Definition checks.h:227
IBContainer – Supported by container app's document window.
Definition ocbocole.h:398
IBPart – Supported by server objects.
Definition ocbocole.h:241
IBSite – Supported by container apps for each linked/embedded object.
Definition ocbocole.h:437
virtual void _IFUNC Invalidate(TOcInvalidate)=0
virtual HRESULT _IFUNC Init(IBDataProvider *, IBPart *, LPCOLESTR, BOOL)=0
virtual void _IFUNC Disconnect()=0
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
bool IsOptionSet(owl::uint32 option) const
Definition ocapp.h:302
TOcLinkCollection & GetViews()
Definition ocdoc.h:53
Used to obtain the native clipboard format data.
Definition ocview.h:416
Clipboard format wrapper.
Definition ocview.h:55
int Find(const TOcFormat *format) const
Definition ocview.h:111
Used to obtain the size of the rectangle that encloses the selection.
Definition ocview.h:364
Remote Viewer object for a server document.
Definition ocremvie.h:26
Use when doing parts save and load.
Definition ocview.h:326
virtual bool EvOcViewBreakLink(TOcLinkView &view)=0
virtual bool EvOcViewPartSize(TOcPartSize &size)=0
virtual bool EvOcViewGetPalette(LOGPALETTE **palette)=0
virtual bool EvOcViewDrag(TOcDragDrop &ddInfo)=0
virtual bool EvOcViewPaint(TOcViewPaint &vp)=0
virtual bool EvOcViewClipData(TOcFormatData &format)=0
virtual bool EvOcViewAttachWindow(bool attach)=0
virtual bool EvOcViewSavePart(TOcSaveLoad &ocSave)=0
The TOcView partner is a container (viewer) of a given (server/client) document.
Definition ocview.h:136
TOcDocument & OcDocument
Our OC document object.
Definition ocview.h:270
HRESULT _IFUNC BringToFront()
Definition ocview.cpp:795
owl::uint _IFUNC CountFormats()
Format count.
Definition ocview.cpp:543
HRESULT _IFUNC QueryInterface(const GUID &iid, void **iface)
Definition ocview.h:199
HRESULT _IFUNC GetFormat(owl::uint, TOcFormatInfo *)
Format retrieval.
Definition ocview.cpp:552
TOcFormatList FormatList
Definition ocview.h:285
TOcApp & OcApp
Our OC application object.
Definition ocview.h:269
TOcServerHost * ServerHost
The hosting app's server object.
Definition ocview.h:273
IUnknown * SetOuter(IUnknown *outer=0)
Definition oleutil.h:298
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
Iterator for Pointer Container.
Definition template.h:602
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
void SetEmpty()
Empties this rectangle by setting left, top, right, and bottom to 0.
Definition geometry.h:898
TRect & Normalize()
Normalizes this rectangle by switching the left and right data member values if left > right,...
Definition geometry.cpp:99
A registration parameter table, composed of a list of TRegItems.
Definition registry.h:531
The tagSIZE struct is defined as.
Definition geometry.h:234
Reference to reference counted string object TUString Lightweight reference object consisting of a po...
Definition string.h:67
bool Detach(int loc)
Definition template.h:1573
Include for OC, gets common headers when precompiled headers are enabled.
Object Component Framework (COM encapsulation)
Definition appdesc.h:22
TOcAspect
Definition ocobject.h:64
const BCID cidBOleInProcSite
Definition ocbocole.h:114
HRESULT HRFailIfZero(int bexpr)
Definition defs.h:126
const BCID cidBOleSite
Definition ocbocole.h:113
TOcInvalidate
Definition ocobject.h:59
const GUID & iid
Definition appdesc.h:328
@ amExeModule
set for EXE components, 0 if DLL inproc server
Definition ocreg.h:87
@ amDebug
user requested launching for debugging
Definition ocreg.h:85
TOcPartName
Definition ocobject.h:87
TOcDraw
Definition ocobject.h:81
@ drShadingOnly
Definition ocobject.h:83
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
bool ToBool(const T &t)
Definition defs.h:291
unsigned int uint
Definition number.h:25
Definition of TOcApp application connection class.
interface _ICLASS IStorage
Definition ocdoc.h:25
#define HR_NOTIMPL
Definition defs.h:76
#define HR_NOERROR
Definition defs.h:73
#define HR_FAIL
Definition defs.h:83
Definition of TOcRemView Class.
#define _IFUNC
Definition oleutil.h:28
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269
#define OleStr(s)
Definition string.h:128
For viewdrop & viewdrag.
Definition ocview.h:303
For part adornment painting over part, & painting views.
Definition ocview.h:312