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
ocpart.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectComponents
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4/// \file
5/// Definition of TOcPart class
6//----------------------------------------------------------------------------
7
8#if !defined(OCF_OCPART_H)
9#define OCF_OCPART_H
10
11#include <owl/private/defs.h>
12#if defined(BI_HAS_PRAGMA_ONCE)
13# pragma once
14#endif
15
16#include <owl/geometry.h>
17#include <owl/contain.h>
18
19#include <ocf/ocbocole.h>
20#include <ocf/ocobject.h>
21#include <ocf/autodefs.h>
22
23
24namespace ocf {
25
26//
27// Classes referenced
28//
31class TOcVerb;
32
33//
34/// \class TOcPart
35// ~~~~~ ~~~~~~~
36/// OC part class represents an embeded or linked part in a document
37//
38class _ICLASS TOcPart : public TUnknown, protected IBSite2 {
39 public:
40 TOcPart(TOcDocument& document, int id = 0);
41 TOcPart(TOcDocument& document, LPCTSTR name);
42 TOcPart(TOcDocument& document, TOcInitInfo & initInfo, owl::TRect pos,
43 int id = 0);
44
45 virtual bool Init(TOcInitInfo * initInfo, owl::TRect pos);
46
47 void Delete();
48
49 bool operator ==(const TOcPart& other) {return owl::ToBool(&other == this);}
50
51 // Delegated doc functions from TOcDocument
52 //
53 IBPart* GetBPartI() {return BPartI;}
54 TOcStorage* GetStorage() {return Storage;}
55 void SetStorage(IStorage* storage, bool remember = true);
56 bool Save(bool SameAsLoad = true, bool remember = true);
57 bool Load();
58 int Detach();
59 void FinishLoading();
60
61 // Position & size information
62 //
63 owl::TPoint GetPos() const {return Pos;}
64 void SetPos(const owl::TPoint& pos);
65 owl::TSize GetSize() const;
66 void SetSize(const owl::TSize& size);
67 owl::TRect GetRect() const {return owl::TRect(Pos, Size);}
68 void UpdateRect();
69 bool IsVisible(const owl::TRect& logicalRect) const
70 {return owl::ToBool(IsVisible() && logicalRect.Touches(GetRect()));}
71
72 // Flag accessor functions
73 //
74 void Select(bool select)
75 {if (select) Flags |= Selected; else Flags &= ~Selected;}
76 bool IsSelected() const {return owl::ToBool(Flags&Selected);}
77 void SetVisible(bool visible);
78 bool IsVisible() const {return owl::ToBool(Flags&Visible);}
79 bool IsActive() const {return owl::ToBool(Flags&Active);}
80 void SetActive() {Flags |= Active;}
81 bool IsLink() const {return owl::ToBool(Flags&Link);}
82
83 // Naming
84 //
85 // Changed the following line as there seems to be a problem with the
86 // destruction of TString objects when they are constructed from an
87 // owl::tstring. This causes an exception when the TString returned from
88 // GetName() goes out of scope. MH - 19/06/02
89 //
90 // TString GetName() {return Name;}
91 owl::TString GetName() {return Name.c_str();}
92 void Rename();
93
94 // Pass thru functions to corresponding IBPart
95 //
96 bool Save(IStorage* storage, bool sameAsLoad, bool remember);
97 bool Draw(HDC dc, const owl::TRect& pos, const owl::TRect& clip, TOcAspect aspect = asDefault);
98 bool Activate(bool activate);
99 bool Show(bool show) {return HRSucceeded(BPartI->Show(show));}
100 bool Open(bool open) {return HRSucceeded(BPartI->Open(open));}
101 HWND OpenInPlace(HWND hwnd) {return BPartI->OpenInPlace(hwnd);}
102 bool CanOpenInPlace() {return HRSucceeded(BPartI->CanOpenInPlace());}
103 bool Close();
104 bool SetHost(IBContainer * container)
105 {return HRSucceeded(BPartI->SetHost(container));}
106
107 bool EnumVerbs(const TOcVerb&);
108 bool DoVerb(owl::uint);
109 LPCOLESTR GetServerName(TOcPartName partName)
110 {return const_cast<LPOLESTR>(BPartI->GetName((TOcPartName)partName));}
111 HRESULT QueryServer(const IID & iid, void * * iface);
112
113 bool SetFormatData(TOcFormatInfo * fmt, HANDLE data, bool release);
114
115 // Object reference & lifetime managment
116 // For internal OCF use only
117 //
118 owl::ulong _IFUNC AddRef() {return GetOuter()->AddRef();}
119 owl::ulong _IFUNC Release() {return GetOuter()->Release();}
120 HRESULT _IFUNC QueryInterface(const GUID & iid, void ** iface)
121 {return GetOuter()->QueryInterface(iid, iface);}
122
123 protected:
124 ~TOcPart();
125
126 virtual bool InitObj (TOcInitInfo * initInfo);
127
128 // TUnknown virtual overrides
129 //
130 HRESULT QueryObject(const IID & iid, void * * iface);
131
132 // IBSite implementation for BOle to use
133 //
134 HRESULT _IFUNC SiteShow(BOOL);
135 HRESULT _IFUNC DiscardUndo();
136 HRESULT _IFUNC GetSiteRect(owl::TRect *, owl::TRect *);
137 HRESULT _IFUNC SetSiteRect(const owl::TRect *);
138 HRESULT _IFUNC SetSiteExtent(const owl::TSize *);
139 HRESULT _IFUNC GetZoom(TOcScaleInfo * scale);
140 void _IFUNC Invalidate(TOcInvalidate);
141 void _IFUNC OnSetFocus(BOOL set);
142 HRESULT _IFUNC Init(IBDataProvider *, IBPart *, LPCOLESTR, BOOL);
143 void _IFUNC Disconnect();
144
145 // IBSite2 implementation for BOle to use
146 //
147 HRESULT _IFUNC GetParentWindow(HWND *);
148
149 protected:
150 IUnknown* BPart; ///< Our corresponding helper object & interfaces
153
154 TOcDocument& OcDocument; ///< The OC document we are imbeded in
155 TOcStorage* Storage; ///< The storage we are in
156
160 enum TFlag { Visible=0x01, Selected=0x02, Active=0x04, Link=0x08,
161 Closing=0x10, OcxDefault=0x20, OcxCancel=0x40 };
162 owl::uint16 Flags; ///< Is this part Selected/Visible/Active/ALink?
163
164 friend class TOcPartCollection;
165};
166
167//
168/// \class TOcPartCollection
169// ~~~~~ ~~~~~~~~~~~~~~~~~
170/// Container of parts with iterator
171//
173 private:
175 public:
178
179 void Clear();
180 int Add(TOcPart* const& part)
181 { return Base::Add(part); }
182 int IsEmpty() const {return Base::Empty();}
183 int Find(TOcPart* const& part)
184 { return Base::Find(part);}
185 virtual unsigned Count() const {return Base::Size();}
186 int Detach(TOcPart* const& part, int del = 0);
187
188 TOcPart* Locate(owl::TPoint& point);
189 bool SelectAll(bool select = false);
190};
191
192//
193// class TOcPartCollectionIter
194// ~~~~~ ~~~~~~~~~~~~~~~~~~~~~
196
197//
198// class TOcVerb
199// ~~~~~ ~~~~~~~
201 public:
202 TOcVerb();
203
204 public:
205 LPCOLESTR TypeName;
206 LPCOLESTR VerbName;
209};
210
211//
212/// \class TOcPartChangeInfo
213// ~~~~~ ~~~~~~~~~~~~~~~~~
214/// View/Data change info
215//
217 public:
219 : Part(part), Type(type) {}
220
221 bool IsDataChange() {return Type & invData;}
222 bool IsViewChange() {return Type & invView;}
223
224 void SetDataChange() {Type |= invData;}
225 void SetViewChange() {Type |= invView;}
226
227 TOcPart* GetPart() {return Part;}
228 void SetPart(TOcPart* part) {Part = part;}
229
230 int GetType() {return Type;}
231
232 protected:
233 int Type; // what type of change
235};
236
237
238} // OCF namespace
239
240#endif // OCF_OCPART_H
OLE Automation Class Definitions.
IBContainer – Supported by container app's document window.
Definition ocbocole.h:398
IBDataProvider – Supported by parts and/or sites which can be copied to the OLE2 clipboard.
Definition ocbocole.h:219
ILinkable abstract base class.
Definition ocbocole.h:321
IBPart – Supported by server objects.
Definition ocbocole.h:241
IBSite2 – Add flexibility to have parent of site not be container.
Definition ocbocole.h:454
OC Document class, holds parts & is a owner of views.
Definition ocdoc.h:43
View/Data change info.
Definition ocpart.h:216
void SetPart(TOcPart *part)
Definition ocpart.h:228
TOcPartChangeInfo(TOcPart *part, TOcInvalidate type=invView)
Definition ocpart.h:218
TOcPart * GetPart()
Definition ocpart.h:227
Container of parts with iterator.
Definition ocpart.h:172
virtual unsigned Count() const
Definition ocpart.h:185
int IsEmpty() const
Definition ocpart.h:182
int Find(TOcPart *const &part)
Definition ocpart.h:183
int Add(TOcPart *const &part)
Definition ocpart.h:180
OC part class represents an embeded or linked part in a document.
Definition ocpart.h:38
owl::TString GetName()
Definition ocpart.h:91
bool IsVisible() const
Definition ocpart.h:78
bool Open(bool open)
Definition ocpart.h:100
TOcDocument & OcDocument
The OC document we are imbeded in.
Definition ocpart.h:154
void SetActive()
Definition ocpart.h:80
owl::tstring Name
Definition ocpart.h:157
bool IsVisible(const owl::TRect &logicalRect) const
Definition ocpart.h:69
owl::uint16 Flags
Is this part Selected/Visible/Active/ALink?
Definition ocpart.h:162
LPCOLESTR GetServerName(TOcPartName partName)
Definition ocpart.h:109
IBPart * GetBPartI()
Definition ocpart.h:53
HWND OpenInPlace(HWND hwnd)
Definition ocpart.h:101
TOcStorage * Storage
The storage we are in.
Definition ocpart.h:155
IBLinkable * BLPartI
Definition ocpart.h:152
owl::ulong _IFUNC Release()
Definition ocpart.h:119
owl::TPoint GetPos() const
Definition ocpart.h:63
IBPart * BPartI
Definition ocpart.h:151
bool SetHost(IBContainer *container)
Definition ocpart.h:104
IUnknown * BPart
Our corresponding helper object & interfaces.
Definition ocpart.h:150
owl::ulong _IFUNC AddRef()
Definition ocpart.h:118
bool IsSelected() const
Definition ocpart.h:76
bool IsLink() const
Definition ocpart.h:81
owl::TSize Size
Definition ocpart.h:159
TOcStorage * GetStorage()
Definition ocpart.h:54
void Select(bool select)
Definition ocpart.h:74
bool IsActive() const
Definition ocpart.h:79
bool Show(bool show)
Definition ocpart.h:99
owl::TPoint Pos
Definition ocpart.h:158
bool CanOpenInPlace()
Definition ocpart.h:102
HRESULT _IFUNC QueryInterface(const GUID &iid, void **iface)
Definition ocpart.h:120
owl::TRect GetRect() const
Definition ocpart.h:67
LPCOLESTR TypeName
Definition ocpart.h:205
owl::uint VerbIndex
Definition ocpart.h:207
bool CanDirty
Definition ocpart.h:208
LPCOLESTR VerbName
Definition ocpart.h:206
Standard implementation of a controlling IUnknown for an object, to be inherited with other COM inter...
Definition oleutil.h:264
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
Array of pointers of simple types.
Definition template.h:942
Iterator for Pointer Container.
Definition template.h:602
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
bool Touches(const TRect &other) const
Returns true if the other rectangle shares any interior points with this rectangle; otherwise,...
Definition geometry.h:1222
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
Definition of container classes used and made available by OWL.
Classes for window system geometry.
Object Component Framework (COM encapsulation)
Definition appdesc.h:22
TOcAspect
Definition ocobject.h:64
TOcInvalidate
Definition ocobject.h:59
@ invView
Definition ocobject.h:61
@ invData
Definition ocobject.h:60
bool HRSucceeded(HRESULT hr)
Definition defs.h:131
const GUID & iid
Definition appdesc.h:328
TOcPartCollection::Iterator TOcPartCollectionIter
Definition ocpart.h:195
TOcPartName
Definition ocobject.h:87
class _ICLASS TOcStorage
Definition ocdoc.h:32
unsigned long ulong
Definition number.h:26
bool ToBool(const T &t)
Definition defs.h:291
unsigned short uint16
Definition number.h:33
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
ObjectComponents BOcOle engine linking & embedding interfaces.
interface _ICLASS IStorage
Definition ocdoc.h:25
#define _OCFCLASS
Definition defs.h:45
Various general OC enums and structs.
#define _IFUNC
Definition oleutil.h:28
#define _ICLASS
Definition oleutil.h:25