InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CViewInterface.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Mat Marcus
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __CViewInterface__
25 #define __CViewInterface__
26 
27 
28 #include "CPMUnknown.h"
29 #include "IViewObjectChanges.h"
30 #include "MetaProgramming.h"
31 
32 //========================================================================================
33 // CViewInterface
34 //========================================================================================
35 
36 //
100 template <class Interface>
101 class CViewInterface : public Interface
102 {
103 public:
105  IPMUnknown *QueryInterface(PMIID interfaceID) const;
107  void AddRef() const;
109  void Release() const;
110 
115  void PreDirty(ImplementationID prop = kInvalidImpl, bool16 allowModification = kTrue);
116 
117  /*fViewIFaceConsistencyChecker is used only to produce compiler errors
118  if people by mistake to not use CREATE_VIEW_PMINTERFACE to go along with CViewInterface
119  */
120  void* fViewIFaceConsistencyChecker;
121 protected:
122  explicit CViewInterface(IPMUnknown *boss);
123  HelperInterface fHelperInterface;
124 };
125 
126 
127 template <class Interface>
129 fHelperInterface(boss), fViewIFaceConsistencyChecker(nil)
130 {
131 }
132 
133 template <class Interface>
135 {
136  fHelperInterface.AddRef();
137 }
138 
139 template <class Interface>
141 {
142  fHelperInterface.Release();
143 }
144 
145 template <class Interface>
147 {
148 #ifdef DEBUG
149  if (interfaceID == IID_IGETINTERFACEIMPL)
150  return const_cast<CViewInterface<Interface> *>(this);
151 #endif
152 
153  return fHelperInterface.QueryInterface(interfaceID);
154 }
155 
156 template <class Interface>
157 void CViewInterface<Interface>::PreDirty(ImplementationID prop, bool16 allowModification)
158 {
159  InterfacePtr<IViewObjectChanges>viewObjectChanges (this, UseDefaultIID());
160  if (viewObjectChanges)
161  {
162  InterfacePtr<IControllingUnknown>boss(this, IID_IUNKNOWN);
163  viewObjectChanges->SetDirty(boss, this, prop, allowModification);
164  }
165 }
166 
167 #endif //__CViewInterface__