Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

991 lines
46 KiB

  1. /****************************************************************************
  2. MsoCI.h
  3. Owner: ClarG
  4. Copyright (c) 1995 Microsoft Corporation
  5. This file contains the exported interfaces and declarations for
  6. Office Component Integration.
  7. ****************************************************************************/
  8. #ifndef MSOCI_H
  9. #define MSOCI_H
  10. #if !defined(MSOSTD_H)
  11. #include <msostd.h>
  12. #endif
  13. #if !defined(MSOUSER_H)
  14. #include <msouser.h>
  15. #endif
  16. #if !defined(MSODEBUG_H)
  17. #include <msodebug.h>
  18. #endif
  19. #if MAC
  20. #include <events.h>
  21. #endif
  22. /****************************************************************************
  23. Component integration structures and constants
  24. ****************************************************************************/
  25. // Component registration flags
  26. enum
  27. {
  28. msocrfNeedIdleTime = 1, // needs idle time
  29. msocrfNeedPeriodicIdleTime = 2, // needs idle time every N milliseconds
  30. msocrfPreTranslateKeys = 4, // must process keyboard msgs
  31. // before translation
  32. msocrfPreTranslateAll = 8, // must process all msgs
  33. // before translation
  34. msocrfNeedSpecActiveNotifs = 16, // needs to be notified for special
  35. // activation changes (currently, this will
  36. // notify comp if ExclusiveBorderSpace
  37. // or ExclusiveActivation mode changes)
  38. // Top-level comps should reg this flag.
  39. msocrfNeedTopActiveNotifs = msocrfNeedSpecActiveNotifs, // old name
  40. msocrfNeedAllActiveNotifs = 32, // needs to be notified for every
  41. // change in activation state
  42. msocrfExclusiveBorderSpace = 64, // needs exclusive border space when
  43. // active (normally only used by TopLevel
  44. // Mac components)
  45. msocrfExclusiveActivation = 128, // comp becomes exclusively active
  46. // when activated
  47. };
  48. // Component registration advise flags (see msocstate enumeration)
  49. enum
  50. {
  51. msocadvfModal = 1, // needs modal state change notification
  52. // (must be registered by components
  53. // managing a toplevel window)
  54. msocadvfRedrawOff = 2, // needs redrawOff state change notif
  55. msocadvfWarningsOff = 4, // needs warningsOff state change notif
  56. msocadvfRecording = 8, // needs Recording state change notif
  57. };
  58. // Component registration information
  59. typedef struct _MSOCRINFO
  60. {
  61. ULONG cbSize; // size of MSOCRINFO structure in bytes.
  62. ULONG uIdleTimeInterval; // If msocrfNeedPeriodicIdleTime is registered
  63. // in grfcrf, component needs to perform
  64. // periodic idle time tasks during an idle phase
  65. // every uIdleTimeInterval milliseconds.
  66. DWORD grfcrf; // bit flags taken from msocrf values (above)
  67. DWORD grfcadvf; // bit flags taken from msocadvf values (above)
  68. } MSOCRINFO;
  69. // Component Host flags
  70. enum
  71. {
  72. msochostfExclusiveBorderSpace = 1, // needs exclusive border space when
  73. // active (normally only used by
  74. // TopLevel Mac hosts)
  75. };
  76. // Component Host information
  77. typedef struct _MSOCHOSTINFO
  78. {
  79. ULONG cbSize; // size of MSOCHOSTINFO structure in bytes.
  80. DWORD grfchostf; // bit flags taken from msochostf values (above)
  81. } MSOCHOSTINFO;
  82. // idle flags, passed to IMsoComponent::FDoIdle and
  83. // IMsoStdComponentMgr::FDoIdle.
  84. enum
  85. {
  86. msoidlefPeriodic = 1, // periodic idle tasks
  87. msoidlefNonPeriodic = 2, // any nonperiodic idle task
  88. msoidlefPriority = 4, // high priority, nonperiodic idle tasks
  89. msoidlefAll = -1 // all idle tasks
  90. };
  91. // Reasons for pushing a message loop, passed to
  92. // IMsoComponentManager::FPushMessageLoop and
  93. // IMsoComponentHost::FPushMessageLoop. The host should remain in message
  94. // loop until IMsoComponent::FContinueMessageLoop
  95. // (or IMsoStdComponentMgr::FContinueMessageLoop) returns FALSE.
  96. enum
  97. {
  98. msoloopFocusWait = 1, // component is activating host
  99. msoloopDoEvents = 2, // component is asking host to process messages
  100. msoloopDebug = 3, // component has entered debug mode
  101. msoloopModalForm = 4 // component is displaying a modal form
  102. };
  103. /* msocstate values: state IDs passed to
  104. IMsoComponent::OnEnterState,
  105. IMsoComponentManager::OnComponentEnterState/FOnComponentExitState/FInState,
  106. IMsoComponentHost::OnComponentEnterState,
  107. IMsoStdComponentMgr::OnHostEnterState/FOnHostExitState/FInState.
  108. When the host or a component is notified through one of these methods that
  109. another entity (component or host) is entering or exiting a state
  110. identified by one of these state IDs, the host/component should take
  111. appropriate action:
  112. msocstateModal (modal state):
  113. If app is entering modal state, host/component should disable
  114. its toplevel windows, and reenable them when app exits this
  115. state. Also, when this state is entered or exited, host/component
  116. should notify approprate inplace objects via
  117. IOleInPlaceActiveObject::EnableModeless.
  118. msocstateRedrawOff (redrawOff state):
  119. If app is entering redrawOff state, host/component should disable
  120. repainting of its windows, and reenable repainting when app exits
  121. this state.
  122. msocstateWarningsOff (warningsOff state):
  123. If app is entering warningsOff state, host/component should disable
  124. the presentation of any user warnings, and reenable this when
  125. app exits this state.
  126. msocstateRecording (Recording state):
  127. Used to notify host/component when Recording is turned on or off. */
  128. enum
  129. {
  130. msocstateModal = 1, // modal state; disable toplevel windows
  131. msocstateRedrawOff = 2, // redrawOff state; disable window repainting
  132. msocstateWarningsOff = 3, // warningsOff state; disable user warnings
  133. msocstateRecording = 4, // Recording state
  134. };
  135. /* ** Comments on State Contexts **
  136. IMsoComponentManager::FCreateSubComponentManager allows one to create a
  137. hierarchical tree of component managers. This tree is used to maintain
  138. multiple contexts with regard to msocstateXXX states. These contexts are
  139. referred to as 'state contexts'.
  140. Each component manager in the tree defines a state context. The
  141. components registered with a particular component manager or any of its
  142. descendents live within that component manager's state context. Calls
  143. to IMsoComponentManager::OnComponentEnterState/FOnComponentExitState
  144. can be used to affect all components, only components within the component
  145. manager's state context, or only those components that are outside of the
  146. component manager's state context. IMsoComponentManager::FInState is used
  147. to query the state of the component manager's state context at its root.
  148. msoccontext values: context indicators passed to
  149. IMsoComponentManager::OnComponentEnterState/FOnComponentExitState.
  150. These values indicate the state context that is to be affected by the
  151. state change.
  152. In IMsoComponentManager::OnComponentEnterState/FOnComponentExitState,
  153. the comp mgr informs only those components/host that are within the
  154. specified state context. */
  155. enum
  156. {
  157. msoccontextAll = 0, // all state contexts in state context tree
  158. msoccontextMine = 1, // component manager's state context
  159. msoccontextOthers = 2, // all other state contexts outside of comp mgr's
  160. };
  161. /* ** WM_MOUSEACTIVATE Note (for top level compoenents and host) **
  162. If the active (or tracking) comp's reg info indicates that it
  163. wants mouse messages, then no MA_xxxANDEAT value should be returned
  164. from WM_MOUSEACTIVATE, so that the active (or tracking) comp will be able
  165. to process the resulting mouse message. If one does not want to examine
  166. the reg info, no MA_xxxANDEAT value should be returned from
  167. WM_MOUSEACTIVATE if any comp is active (or tracking).
  168. One can query the reg info of the active (or tracking) component at any
  169. time via IMsoComponentManager::FGetActiveComponent. */
  170. /* msogac values: values passed to
  171. IMsoComponentManager::FGetActiveComponent. */
  172. enum
  173. {
  174. msogacActive = 0, // retrieve true active component
  175. msogacTracking = 1, // retrieve tracking component
  176. msogacTrackingOrActive = 2, // retrieve tracking component if one exists,
  177. // otherwise retrieve true active component
  178. };
  179. /* msocWindow values: values passed to IMsoComponent::HwndGetWindow. */
  180. enum
  181. {
  182. msocWindowFrameToplevel = 0,
  183. /* MDI Apps should return the MDI frame (not MDI client) or App frame
  184. window, and SDI Apps should return the frame window which hosts the
  185. component. Basically it should be the topmost window which owns the
  186. component. For a toolbar set this will be the toplevel owner of
  187. TBS::m_hwnd. */
  188. msocWindowFrameOwner = 1,
  189. /* This is the window which owns the component. It could be same as
  190. the window obtained by msocWindowFrameTopLevel or be an owned window
  191. of that window. For a toolbar set this will be TBS::m_hwnd. */
  192. msocWindowComponent = 2,
  193. /* This is the "main" window of the component (if it has one). */
  194. msocWindowDlgOwner = 3,
  195. /* Caller wishes to display a dialog to be parented by the component.
  196. Component should return a window suitable for use as the dialog's
  197. owner window. */
  198. };
  199. /****************************************************************************
  200. Defines the IMsoComponent interface
  201. Any component that needs idle time, the ability to process
  202. messages before they are translated
  203. (for example, to call TranslateAccelerator or IsDialogMessage),
  204. notification about modal states,
  205. or the ability push message loops
  206. must implement this interface and register with the Component Manager.
  207. ****************************************************************************/
  208. #undef INTERFACE
  209. #define INTERFACE IMsoComponent
  210. DECLARE_INTERFACE_(IMsoComponent, IUnknown)
  211. {
  212. BEGIN_MSOINTERFACE
  213. // *** IUnknown methods ***
  214. MSOMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppvObj) PURE;
  215. MSOMETHOD_(ULONG, AddRef) (THIS) PURE;
  216. MSOMETHOD_(ULONG, Release) (THIS) PURE;
  217. /* Standard FDebugMessage method.
  218. Since IMsoComponent is a reference counted interface,
  219. MsoDWGetChkMemCounter should be used when processing the
  220. msodmWriteBe message. */
  221. MSODEBUGMETHOD
  222. /* Give component a chance to process the message pMsg before it is
  223. translated and dispatched. Component can do TranslateAccelerator,
  224. do IsDialogMessage, modify pMsg, or take some other action.
  225. Return TRUE if the message is consumed, FALSE otherwise. */
  226. MSOMETHOD_(BOOL, FPreTranslateMessage) (THIS_ MSG *pMsg) PURE;
  227. #if MAC
  228. /* Give Macintosh component a chance to process the event pEvt
  229. before it is processed by the host.
  230. Return TRUE if the event is consumed, FALSE otherwise.
  231. (WLM components can simply return FALSE.) */
  232. MSOMETHOD_(BOOL, FPreProcessMacEvent) (THIS_ EventRecord *pEvt) PURE;
  233. #endif // MAC
  234. /* Notify component when app enters or exits (as indicated by fEnter)
  235. the state identified by uStateID (a value from msocstate enumeration).
  236. Component should take action depending on value of uStateID
  237. (see msocstate comments, above).
  238. Note: If n calls are made with TRUE fEnter, component should consider
  239. the state to be in effect until n calls are made with FALSE fEnter.
  240. Note: Components should be aware that it is possible for this method to
  241. be called with FALSE fEnter more times than it was called with TRUE
  242. fEnter (so, for example, if component is maintaining a state counter
  243. (incremented when this method is called with TRUE fEnter, decremented
  244. when called with FALSE fEnter), the counter should not be decremented
  245. for FALSE fEnter if it is already at zero.) */
  246. MSOMETHOD_(void, OnEnterState) (THIS_ ULONG uStateID, BOOL fEnter) PURE;
  247. /* Notify component when the host application gains or loses activation.
  248. If fActive is TRUE, the host app is being activated and dwOtherThreadID
  249. is the ID of the thread owning the window being deactivated.
  250. If fActive is FALSE, the host app is being deactivated and
  251. dwOtherThreadID is the ID of the thread owning the window being
  252. activated.
  253. Note: this method is not called when both the window being activated
  254. and the one being deactivated belong to the host app. */
  255. MSOMETHOD_(void, OnAppActivate) (THIS_
  256. BOOL fActive, DWORD dwOtherThreadID) PURE;
  257. /* Notify the active component that it has lost its active status because
  258. the host or another component has become active. */
  259. MSOMETHOD_(void, OnLoseActivation) (THIS) PURE;
  260. /* Notify component when a new object is being activated.
  261. If pic is non-NULL, then it is the component that is being activated.
  262. In this case, fSameComponent is TRUE if pic is the same component as
  263. the callee of this method, and pcrinfo is the reg info of pic.
  264. If pic is NULL and fHostIsActivating is TRUE, then the host is the
  265. object being activated, and pchostinfo is its host info.
  266. If pic is NULL and fHostIsActivating is FALSE, then there is no current
  267. active object.
  268. If pic is being activated and pcrinfo->grf has the
  269. msocrfExclusiveBorderSpace bit set, component should hide its border
  270. space tools (toolbars, status bars, etc.);
  271. component should also do this if host is activating and
  272. pchostinfo->grfchostf has the msochostfExclusiveBorderSpace bit set.
  273. In either of these cases, component should unhide its border space
  274. tools the next time it is activated.
  275. If pic is being activated and pcrinfo->grf has the
  276. msocrfExclusiveActivation bit is set, then pic is being activated in
  277. "ExclusiveActive" mode.
  278. Component should retrieve the top frame window that is hosting pic
  279. (via pic->HwndGetWindow(msocWindowFrameToplevel, 0)).
  280. If this window is different from component's own top frame window,
  281. component should disable its windows and do other things it would do
  282. when receiving OnEnterState(msocstateModal, TRUE) notification.
  283. Otherwise, if component is top-level,
  284. it should refuse to have its window activated by appropriately
  285. processing WM_MOUSEACTIVATE (but see WM_MOUSEACTIVATE NOTE, above).
  286. Component should remain in one of these states until the
  287. ExclusiveActive mode ends, indicated by a future call to
  288. OnActivationChange with ExclusiveActivation bit not set or with NULL
  289. pcrinfo. */
  290. MSOMETHOD_(void, OnActivationChange) (THIS_
  291. IMsoComponent *pic,
  292. BOOL fSameComponent,
  293. const MSOCRINFO *pcrinfo,
  294. BOOL fHostIsActivating,
  295. const MSOCHOSTINFO *pchostinfo,
  296. DWORD dwReserved) PURE;
  297. /* Give component a chance to do idle time tasks. grfidlef is a group of
  298. bit flags taken from the enumeration of msoidlef values (above),
  299. indicating the type of idle tasks to perform.
  300. Component may periodically call IMsoComponentManager::FContinueIdle;
  301. if this method returns FALSE, component should terminate its idle
  302. time processing and return.
  303. Return TRUE if more time is needed to perform the idle time tasks,
  304. FALSE otherwise.
  305. Note: If a component reaches a point where it has no idle tasks
  306. and does not need FDoIdle calls, it should remove its idle task
  307. registration via IMsoComponentManager::FUpdateComponentRegistration.
  308. Note: If this method is called on while component is performing a
  309. tracking operation, component should only perform idle time tasks that
  310. it deems are appropriate to perform during tracking. */
  311. MSOMETHOD_(BOOL, FDoIdle) (THIS_ DWORD grfidlef) PURE;
  312. /* Called during each iteration of a message loop that the component
  313. pushed. uReason and pvLoopData are the reason and the component private
  314. data that were passed to IMsoComponentManager::FPushMessageLoop.
  315. This method is called after peeking the next message in the queue
  316. (via PeekMessage) but before the message is removed from the queue.
  317. The peeked message is passed in the pMsgPeeked param (NULL if no
  318. message is in the queue). This method may be additionally called when
  319. the next message has already been removed from the queue, in which case
  320. pMsgPeeked is passed as NULL.
  321. Return TRUE if the message loop should continue, FALSE otherwise.
  322. If FALSE is returned, the component manager terminates the loop without
  323. removing pMsgPeeked from the queue. */
  324. MSOMETHOD_(BOOL, FContinueMessageLoop) (THIS_
  325. ULONG uReason, void *pvLoopData, MSG *pMsgPeeked) PURE;
  326. /* Called when component manager wishes to know if the component is in a
  327. state in which it can terminate. If fPromptUser is FALSE, component
  328. should simply return TRUE if it can terminate, FALSE otherwise.
  329. If fPromptUser is TRUE, component should return TRUE if it can
  330. terminate without prompting the user; otherwise it should prompt the
  331. user, either 1.) asking user if it can terminate and returning TRUE
  332. or FALSE appropriately, or 2.) giving an indication as to why it
  333. cannot terminate and returning FALSE. */
  334. MSOMETHOD_(BOOL, FQueryTerminate) (THIS_ BOOL fPromptUser) PURE;
  335. /* Called when component manager wishes to terminate the component's
  336. registration. Component should revoke its registration with component
  337. manager, release references to component manager and perform any
  338. necessary cleanup. */
  339. MSOMETHOD_(void, Terminate) (THIS) PURE;
  340. /* Called to retrieve a window associated with the component, as specified
  341. by dwWhich, a msocWindowXXX value (see msocWindow, above).
  342. dwReserved is reserved for future use and should be zero.
  343. Component should return the desired window or NULL if no such window
  344. exists. */
  345. MSOMETHOD_(HWND, HwndGetWindow) (THIS_
  346. DWORD dwWhich, DWORD dwReserved) PURE;
  347. };
  348. /****************************************************************************
  349. Defines the IMsoComponentManager interface
  350. A component manager is an object implementing the IMsoComponentManager
  351. interface. The component manager coordinates components with its message
  352. loop for proper distribution of idle time and pre-translation message
  353. processing.
  354. It also coordinates modalities and the pushing of message loops.
  355. The host application can implement its own component manager and register
  356. it via MsoFSetComponentManager or it can make use of the office supplied
  357. component manager via MsoFCreateStdComponentManager.
  358. ****************************************************************************/
  359. #undef INTERFACE
  360. #define INTERFACE IMsoComponentManager
  361. DECLARE_INTERFACE_(IMsoComponentManager, IUnknown)
  362. {
  363. BEGIN_MSOINTERFACE
  364. // *** IUnknown methods ***
  365. MSOMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppvObj) PURE;
  366. MSOMETHOD_(ULONG, AddRef) (THIS) PURE;
  367. MSOMETHOD_(ULONG, Release) (THIS) PURE;
  368. /* Return in *ppvObj an implementation of interface iid for service
  369. guidService (same as IServiceProvider::QueryService).
  370. Return NOERROR if the requested service is supported, otherwise return
  371. NULL in *ppvObj and an appropriate error (eg E_FAIL, E_NOINTERFACE). */
  372. MSOMETHOD(QueryService) (THIS_
  373. REFGUID guidService, REFIID iid, void **ppvObj) PURE;
  374. /* Standard FDebugMessage method.
  375. Since IMsoComponentManager is a reference counted interface,
  376. MsoDWGetChkMemCounter should be used when processing the
  377. msodmWriteBe message. */
  378. MSODEBUGMETHOD
  379. /* Register component piComponent and its registration info pcrinfo with
  380. this component manager. Return in *pdwComponentID a cookie which will
  381. identify the component when it calls other IMsoComponentManager
  382. methods.
  383. Return TRUE if successful, FALSE otherwise. */
  384. MSOMETHOD_(BOOL, FRegisterComponent) (THIS_
  385. IMsoComponent *piComponent, const MSOCRINFO *pcrinfo,
  386. DWORD *pdwComponentID) PURE;
  387. /* Undo the registration of the component identified by dwComponentID
  388. (the cookie returned from the FRegisterComponent method).
  389. Return TRUE if successful, FALSE otherwise. */
  390. MSOMETHOD_(BOOL, FRevokeComponent) (THIS_ DWORD dwComponentID) PURE;
  391. /* Update the registration info of the component identified by
  392. dwComponentID (the cookie returned from FRegisterComponent) with the
  393. new registration information pcrinfo.
  394. Typically this is used to update the idle time registration data, but
  395. can be used to update other registration data as well.
  396. Return TRUE if successful, FALSE otherwise. */
  397. MSOMETHOD_(BOOL, FUpdateComponentRegistration) (THIS_
  398. DWORD dwComponentID, const MSOCRINFO *pcrinfo) PURE;
  399. /* Notify component manager that component identified by dwComponentID
  400. (cookie returned from FRegisterComponent) has been activated.
  401. The active component gets the chance to process messages before they
  402. are dispatched (via IMsoComponent::FPreTranslateMessage) and typically
  403. gets first crack at idle time after the host.
  404. This method fails if another component is already Exclusively Active.
  405. In this case, FALSE is returned and SetLastError is set to
  406. msoerrACompIsXActive (comp usually need not take any special action
  407. in this case).
  408. Return TRUE if successful. */
  409. MSOMETHOD_(BOOL, FOnComponentActivate) (THIS_ DWORD dwComponentID) PURE;
  410. /* Called to inform component manager that component identified by
  411. dwComponentID (cookie returned from FRegisterComponent) wishes
  412. to perform a tracking operation (such as mouse tracking).
  413. The component calls this method with fTrack == TRUE to begin the
  414. tracking operation and with fTrack == FALSE to end the operation.
  415. During the tracking operation the component manager routes messages
  416. to the tracking component (via IMsoComponent::FPreTranslateMessage)
  417. rather than to the active component. When the tracking operation ends,
  418. the component manager should resume routing messages to the active
  419. component.
  420. Note: component manager should perform no idle time processing during a
  421. tracking operation other than give the tracking component idle
  422. time via IMsoComponent::FDoIdle.
  423. Note: there can only be one tracking component at a time.
  424. Return TRUE if successful, FALSE otherwise. */
  425. MSOMETHOD_(BOOL, FSetTrackingComponent) (THIS_
  426. DWORD dwComponentID, BOOL fTrack) PURE;
  427. /* Notify component manager that component identified by dwComponentID
  428. (cookie returned from FRegisterComponent) is entering the state
  429. identified by uStateID (msocstateXXX value). (For convenience when
  430. dealing with sub CompMgrs, the host can call this method passing 0 for
  431. dwComponentID.)
  432. Component manager should notify all other interested components within
  433. the state context indicated by uContext (a msoccontextXXX value),
  434. excluding those within the state context of a CompMgr in rgpicmExclude,
  435. via IMsoComponent::OnEnterState (see "Comments on State Contexts",
  436. above).
  437. Component Manager should also take appropriate action depending on the
  438. value of uStateID (see msocstate comments, above).
  439. dwReserved is reserved for future use and should be zero.
  440. rgpicmExclude (can be NULL) is an array of cpicmExclude CompMgrs (can
  441. include root CompMgr and/or sub CompMgrs); components within the state
  442. context of a CompMgr appearing in this array should NOT be notified of
  443. the state change (note: if uContext is msoccontextMine, the only
  444. CompMgrs in rgpicmExclude that are checked for exclusion are those that
  445. are sub CompMgrs of this Component Manager, since all other CompMgrs
  446. are outside of this Component Manager's state context anyway.)
  447. Note: Calls to this method are symmetric with calls to
  448. FOnComponentExitState.
  449. That is, if n OnComponentEnterState calls are made, the component is
  450. considered to be in the state until n FOnComponentExitState calls are
  451. made. Before revoking its registration a component must make a
  452. sufficient number of FOnComponentExitState calls to offset any
  453. outstanding OnComponentEnterState calls it has made.
  454. Note: inplace objects should not call this method with
  455. uStateID == msocstateModal when entering modal state. Such objects
  456. should call IOleInPlaceFrame::EnableModeless instead. */
  457. MSOMETHOD_(void, OnComponentEnterState) (THIS_
  458. DWORD dwComponentID,
  459. ULONG uStateID,
  460. ULONG uContext,
  461. ULONG cpicmExclude,
  462. IMsoComponentManager **rgpicmExclude,
  463. DWORD dwReserved) PURE;
  464. /* Notify component manager that component identified by dwComponentID
  465. (cookie returned from FRegisterComponent) is exiting the state
  466. identified by uStateID (a msocstateXXX value). (For convenience when
  467. dealing with sub CompMgrs, the host can call this method passing 0 for
  468. dwComponentID.)
  469. uContext, cpicmExclude, and rgpicmExclude are as they are in
  470. OnComponentEnterState.
  471. Component manager should notify all appropriate interested components
  472. (taking into account uContext, cpicmExclude, rgpicmExclude) via
  473. IMsoComponent::OnEnterState (see "Comments on State Contexts", above).
  474. Component Manager should also take appropriate action depending on
  475. the value of uStateID (see msocstate comments, above).
  476. Return TRUE if, at the end of this call, the state is still in effect
  477. at the root of this component manager's state context
  478. (because the host or some other component is still in the state),
  479. otherwise return FALSE (ie. return what FInState would return).
  480. Caller can normally ignore the return value.
  481. Note: n calls to this method are symmetric with n calls to
  482. OnComponentEnterState (see OnComponentEnterState comments, above). */
  483. MSOMETHOD_(BOOL, FOnComponentExitState) (THIS_
  484. DWORD dwComponentID,
  485. ULONG uStateID,
  486. ULONG uContext,
  487. ULONG cpicmExclude,
  488. IMsoComponentManager **rgpicmExclude) PURE;
  489. /* Return TRUE if the state identified by uStateID (a msocstateXXX value)
  490. is in effect at the root of this component manager's state context,
  491. FALSE otherwise (see "Comments on State Contexts", above).
  492. pvoid is reserved for future use and should be NULL. */
  493. MSOMETHOD_(BOOL, FInState) (THIS_ ULONG uStateID, void *pvoid) PURE;
  494. /* Called periodically by a component during IMsoComponent::FDoIdle.
  495. Return TRUE if component can continue its idle time processing,
  496. FALSE if not (in which case component returns from FDoIdle.) */
  497. MSOMETHOD_(BOOL, FContinueIdle) (THIS) PURE;
  498. /* Component identified by dwComponentID (cookie returned from
  499. FRegisterComponent) wishes to push a message loop for reason uReason.
  500. uReason is one the values from the msoloop enumeration (above).
  501. pvLoopData is data private to the component.
  502. The component manager should push its message loop,
  503. calling IMsoComponent::FContinueMessageLoop(uReason, pvLoopData)
  504. during each loop iteration (see IMsoComponent::FContinueMessageLoop
  505. comments). When IMsoComponent::FContinueMessageLoop returns FALSE, the
  506. component manager terminates the loop.
  507. Returns TRUE if component manager terminates loop because component
  508. told it to (by returning FALSE from IMsoComponent::FContinueMessageLoop),
  509. FALSE if it had to terminate the loop for some other reason. In the
  510. latter case, component should perform any necessary action (such as
  511. cleanup). */
  512. MSOMETHOD_(BOOL, FPushMessageLoop) (THIS_
  513. DWORD dwComponentID, ULONG uReason, void *pvLoopData) PURE;
  514. /* Cause the component manager to create a "sub" component manager, which
  515. will be one of its children in the hierarchical tree of component
  516. managers used to maintiain state contexts (see "Comments on State
  517. Contexts", above).
  518. piunkOuter is the controlling unknown (can be NULL), riid is the
  519. desired IID, and *ppvObj returns the created sub component manager.
  520. piunkServProv (can be NULL) is a ptr to an object supporting
  521. IServiceProvider interface to which the created sub component manager
  522. will delegate its IMsoComponentManager::QueryService calls.
  523. (see objext.h or docobj.h for definition of IServiceProvider).
  524. Returns TRUE if successful. */
  525. MSOMETHOD_(BOOL, FCreateSubComponentManager) (THIS_
  526. IUnknown *piunkOuter,
  527. IUnknown *piunkServProv,
  528. REFIID riid,
  529. void **ppvObj) PURE;
  530. /* Return in *ppicm an AddRef'ed ptr to this component manager's parent
  531. in the hierarchical tree of component managers used to maintain state
  532. contexts (see "Comments on State Contexts", above).
  533. Returns TRUE if the parent is returned, FALSE if no parent exists or
  534. some error occurred. */
  535. MSOMETHOD_(BOOL, FGetParentComponentManager) (THIS_
  536. IMsoComponentManager **ppicm) PURE;
  537. /* Return in *ppic an AddRef'ed ptr to the current active or tracking
  538. component (as indicated by dwgac (a msogacXXX value)), and
  539. its registration information in *pcrinfo. ppic and/or pcrinfo can be
  540. NULL if caller is not interested these values. If pcrinfo is not NULL,
  541. caller should set pcrinfo->cbSize before calling this method.
  542. Returns TRUE if the component indicated by dwgac exists, FALSE if no
  543. such component exists or some error occurred.
  544. dwReserved is reserved for future use and should be zero. */
  545. MSOMETHOD_(BOOL, FGetActiveComponent) (THIS_
  546. DWORD dwgac,
  547. IMsoComponent **ppic,
  548. MSOCRINFO *pcrinfo,
  549. DWORD dwReserved) PURE;
  550. };
  551. /****************************************************************************
  552. Defines the IMsoStdComponentMgr interface
  553. IMsoStdComponentMgr is an interface exposed by the office supplied
  554. standard component manager, created by MsoFCreateStdComponentMgr.
  555. The host application uses this interface to communicate directly with
  556. the standard component manager and indirectly with registered components.
  557. By making appropriate calls to this interface and implementing
  558. IMsoComponentHost the host can avoid implementing its own
  559. IMsoComponentManager interface.
  560. ****************************************************************************/
  561. #undef INTERFACE
  562. #define INTERFACE IMsoStdComponentMgr
  563. DECLARE_INTERFACE_(IMsoStdComponentMgr, IUnknown)
  564. {
  565. BEGIN_MSOINTERFACE
  566. // *** IUnknown methods ***
  567. MSOMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppvObj) PURE;
  568. MSOMETHOD_(ULONG, AddRef) (THIS) PURE;
  569. MSOMETHOD_(ULONG, Release) (THIS) PURE;
  570. /* Standard FDebugMessage method.
  571. Since IMsoStdComponentMgr is a reference counted interface,
  572. MsoDWGetChkMemCounter is used when processing the
  573. msodmWriteBe message. */
  574. MSODEBUGMETHOD
  575. /* Set *pchostinfo as the host info. Can be called multiple times.
  576. Returns TRUE if successful. */
  577. MSOMETHOD_(BOOL, FSetHostInfo) (THIS_
  578. const MSOCHOSTINFO *pchostinfo) PURE;
  579. /* Host calls this method to give the active component a chance to
  580. process messages before they are translated and dispatched.
  581. The host need not call this method if no component is active.
  582. When this method is called on message pMsg, StdComponentMgr in turn
  583. calls IMsoComponent::FPreTranslateMessage on the active component if
  584. its registration info indicates that it is interested.
  585. Returns TRUE if message is consumed, in which case the host should
  586. perform no further processing on the message.
  587. Returns FALSE otherwise. */
  588. MSOMETHOD_(BOOL, FPreTranslateMessage) (THIS_ MSG *pMsg) PURE;
  589. #if MAC
  590. /* On Macintosh, host calls this method to give the active component a
  591. chance to process events before they are processed by the host.
  592. The host need not call this method if no component is active.
  593. When this method is called on event pEvt, StdComponentMgr in turn
  594. calls IMsoComponent::FPreProcessMacEvent on the active component if
  595. its registration info indicates that it is interested.
  596. Returns TRUE if event is consumed, in which case the host should
  597. perform no further processing on the event.
  598. Returns FALSE otherwise. */
  599. MSOMETHOD_(BOOL, FPreProcessMacEvent) (THIS_ EventRecord *pEvt) PURE;
  600. #endif // MAC
  601. /* Called by host to notify StdComponentMgr that one of the host's windows
  602. has been activated. This causes the current active component to lose
  603. its active status. However, host should not assume that the component
  604. is no longer active until
  605. IMsoComponentHost::OnComponentActivate(NULL) is called.
  606. This method fails if a component is already Exclusively Active.
  607. In this case, FALSE is returned and SetLastError is set to
  608. msoerrACompIsXActive (host usually need not take any special action
  609. in this case).
  610. Returns TRUE if successful. */
  611. MSOMETHOD_(BOOL, FOnHostActivate) (THIS) PURE;
  612. /* Called by host to notify StdComponentMgr that host is entering the
  613. state identified by uStateID (a msocstateXXX value).
  614. StdComponentMgr in turn notifies all interested components excluding
  615. those within the context of a CompMgr appearing in rgpicmExclude (an
  616. array (can be NULL) of cpicmExclude CompMgrs (can include root CompMgr
  617. and/or sub CompMgrs)).
  618. dwReserved is reserved for future use and should be zero.
  619. Note: Calls to this method are symmetric with FOnHostExitState calls.
  620. That is, if n OnHostEnterState calls are made, the host is
  621. considered to be in the state until n FOnHostExitState calls are
  622. made. */
  623. MSOMETHOD_(void, OnHostEnterState) (THIS_
  624. ULONG uStateID,
  625. ULONG cpicmExclude,
  626. IMsoComponentManager **rgpicmExclude,
  627. DWORD dwReserved) PURE;
  628. /* Called by host to notify StdComponentMgr that host is exiting the state
  629. identified by uStateID (a msocstateXXX value).
  630. StdComponentMgr in turn notifies all interested components excluding
  631. those within the context of a CompMgr appearing in rgpicmExclude (an
  632. array (can be NULL) of cpicmExclude CompMgrs (can include root CompMgr
  633. and/or sub CompMgrs)).
  634. Returns TRUE if the state is still in effect at the end of this call
  635. (because some component is still in the state), otherwise returns
  636. FALSE (ie. returns what FInState would return). Caller can normally
  637. ignore the return value.
  638. Note: n calls to this method are symmetric with n calls to
  639. OnHostEnterState (see OnHostEnterState comments, above). */
  640. MSOMETHOD_(BOOL, FOnHostExitState) (THIS_
  641. ULONG uStateID,
  642. ULONG cpicmExclude,
  643. IMsoComponentManager **rgpicmExclude) PURE;
  644. /* Returns TRUE if state identified by uStateID (a value from msocstate
  645. enumeration) is in effect, FALSE otherwise.
  646. pvoid is reserved for future use and should be NULL. */
  647. MSOMETHOD_(BOOL, FInState) (THIS_ ULONG uStateID, void *pvoid) PURE;
  648. /* Called by host to give registered components the chance to perform idle
  649. time tasks of the type indicated by grfidlef, a group of bit flags
  650. taken from the enumeration of msoidlef values (above).
  651. During a component tracking operation, StdComponentMgr only gives the
  652. tracking component idle time.
  653. Returns TRUE if any component needs more time to perform the idle time
  654. tasks, FALSE otherwise. */
  655. MSOMETHOD_(BOOL, FDoIdle) (THIS_ DWORD grfidlef) PURE;
  656. /* Called by host just before it enters the 'wait mode' resulting from a
  657. call to WaitMessage, GetMessage, or MsgWaitForMultipleObjects. Such a
  658. 'wait mode' would prevent any components from receiving periodic idle
  659. time. If any registered components need periodic idle time, StdCompMgr
  660. starts an appropriate timer. The resulting WM_TIMER message will cause
  661. the host to exit the 'wait mode', allowing the processing of periodic
  662. idle time tasks when the host calls IMsoStdComponentMgr::FDoIdle. */
  663. MSOMETHOD_(void, OnWaitForMessage) (THIS) PURE;
  664. /* Called by host during each iteration of a message loop that a component
  665. pushed.
  666. This method is to be called after peeking the next message in the queue
  667. (via PeekMessage) but before the message is removed from the queue.
  668. The peeked message is passed in the pMsgPeeked param (NULL if no
  669. message is in the queue). If this method is additionally called when
  670. the next message has already been removed from the queue, pMsgPeeked
  671. should be passed as NULL.
  672. StdComponentMgr in turn calls IMsoComponent::FContinueMessageLoop
  673. on the component, and returns the value returned by that call.
  674. Returns TRUE if the message loop should continue, FALSE otherwise.
  675. If FALSE is returned, the loop should be terminated without removing
  676. pMsgPeeked from the queue. */
  677. MSOMETHOD_(BOOL, FContinueMessageLoop) (THIS_ MSG *pMsgPeeked) PURE;
  678. /* Called by host to determine if all registered components can terminate.
  679. StdComponentMgr asks each component whether it can terminate via
  680. IMsoComponent::FQueryTerminate(fPromptUser). If all components
  681. return TRUE, then StdComponentMgr returns TRUE. If any one of the
  682. components returns FALSE, then StdComponentMgr immediately returns
  683. FALSE without asking any more components. */
  684. MSOMETHOD_(BOOL, FQueryTerminate) (THIS_ BOOL fPromptUser) PURE;
  685. /* Called by host to terminate the StdComponentMgr.
  686. If fRevoke is TRUE and StdComponentMgr is registered as the current
  687. thread's component manager, this registration is revoked.
  688. Then, for each registered component, StdComponentMgr calls
  689. IMsoComponent::Terminate and revokes its registration. */
  690. MSOMETHOD_(void, Terminate) (THIS_ BOOL fRevoke) PURE;
  691. };
  692. /****************************************************************************
  693. Defines the IMsoComponentHost interface
  694. IMsoComponentHost is a host implemented interface that the standard
  695. component manager uses to communicate with the host. By implementing
  696. this interface and making use of the standard component manager, the host
  697. can avoid having to implement its own component manager.
  698. ****************************************************************************/
  699. #undef INTERFACE
  700. #define INTERFACE IMsoComponentHost
  701. DECLARE_INTERFACE_(IMsoComponentHost, IUnknown)
  702. {
  703. BEGIN_MSOINTERFACE
  704. // *** IUnknown methods ***
  705. MSOMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppvObj) PURE;
  706. MSOMETHOD_(ULONG, AddRef) (THIS) PURE;
  707. MSOMETHOD_(ULONG, Release) (THIS) PURE;
  708. /* StdComponentMgr delegates calls to IMsoComponentManager::QueryService
  709. to the host by calling this method.
  710. Return in *ppvObj an implementation of interface iid for service
  711. guidService (same as IServiceProvider::QueryService).
  712. Return NOERROR if the requested service is supported, otherwise return
  713. NULL in *ppvObj and an appropriate error (eg E_FAIL, E_NOINTERFACE). */
  714. MSOMETHOD(QueryService) (THIS_
  715. REFGUID guidService, REFIID iid, void **ppvObj) PURE;
  716. /* Standard FDebugMessage method.
  717. Since IMsoComponentHost is a reference counted interface,
  718. MsoDWGetChkMemCounter should be used when processing the
  719. msodmWriteBe message. */
  720. MSODEBUGMETHOD
  721. /* Called when component pic is activated (or should be treated as active
  722. by virtue of beginning a "tracking" operation
  723. (see IMsoComponentManager::FSetTrackingComponent)).
  724. pcrinfo contains component's registration information.
  725. fTracking indicates whether the component is in tracking mode or not.
  726. If pic is NULL (in which case pcrinfo will be NULL), then this
  727. indicates that no component is active.
  728. When a component is active and its registration info indicates that it
  729. needs to process untranslated messages, the host must call
  730. IMsoStdComponentMgr::FPreTranslateMessage for each appropriate message
  731. retrieved from the queue before processing it, so that the active
  732. component gets a chance to process the message appropriately.
  733. (A simple host could avoid examining the component's registration info,
  734. and simply call IMsoStdComponentMgr::FPreTranslateMessage for all
  735. retrieved messages.)
  736. If the component is in tracking mode, as indicated by fTracking, then
  737. the host app should perform no idle time processing other than to give
  738. the tracking component idle time via IMsoStdComponentMgr::FDoIdle,
  739. until the tracking operation is completed (communicated to host via a
  740. subsequent call to OnComponentActivate with fTracking == FALSE).
  741. Additionally, if pic is nonNULL and fTracking is FALSE, then host
  742. should check if pcrinfo->grfcrf has the ExclusiveActive or
  743. ExclusiveBorderSpace bit set.
  744. If ExclusiveBorderSpace bit is set, then host should hide its border
  745. space tools (toolbars, status bars, etc.) and not show them again until
  746. the host is reactivated.
  747. If ExclusiveActivation bit is set, then pic is being activated in
  748. "ExclusiveActive" mode.
  749. Host should retrieve the top frame window that is hosting pic
  750. (via pic->HwndGetWindow(msocWindowFrameToplevel, 0)).
  751. If this window is different from host's own top frame window,
  752. host should disable its windows and do other things it would do
  753. when receiving OnComponentEnterState(msocstateModal, TRUE)
  754. notification.
  755. Otherwise,
  756. host should refuse to have its window activated by appropriately
  757. processing WM_MOUSEACTIVATE (but see WM_MOUSEACTIVATE NOTE, above).
  758. Host should remain in this state until the ExclusiveActive mode ends,
  759. indicated by a future call to OnComponentActivate (with FALSE
  760. fTracking) with ExclusiveActivation bit not set or NULL pcrinfo. */
  761. MSOMETHOD_(void, OnComponentActivate) (THIS_
  762. IMsoComponent *pic, const MSOCRINFO *pcrinfo, BOOL fTracking) PURE;
  763. /* Notify host that a component is entering or exiting (indicated by
  764. fEnter) the state identified by uStateID (a msocstateXXX value).
  765. Host should take action depending on value of uStateID (see msocstate
  766. comments, above).
  767. Note: If n calls are made with TRUE fEnter, the host should consider
  768. the state to be in effect until n calls are made with FALSE fEnter.
  769. Note: Hosts should be aware that it is possible for this method to
  770. be called with FALSE fEnter more times than it was called with TRUE
  771. fEnter (so, for example, if host is maintaining a state counter
  772. (incremented when this method is called with TRUE fEnter, decremented
  773. when called with FALSE fEnter), the counter should not be decremented
  774. for FALSE fEnter if it is already at zero.) */
  775. MSOMETHOD_(void, OnComponentEnterState) (THIS_
  776. ULONG uStateID, BOOL fEnter) PURE;
  777. /* Called periodically by StdComponentMgr during
  778. IMsoStdComponentMgr::FDoIdle.
  779. Return TRUE if idle time processing can continue, FALSE if not. */
  780. MSOMETHOD_(BOOL, FContinueIdle) (THIS) PURE;
  781. /* Called by StdComponentMgr when a component wishes to push a message
  782. loop for reason uReason.
  783. uReason is one the values from the msoloop enumeration (above).
  784. The host should push its message loop, calling
  785. IMsoStdComponentMgr::FContinueMessageLoop during each loop iteration
  786. (see IMsoStdComponentMgr::FContinueMessageLoop comments).
  787. When IMsoStdComponentMgr::FContinueMessageLoop returns FALSE, the host
  788. should terminate the loop.
  789. If host terminates the loop because StdComponentMgr told it to
  790. (by returning FALSE from IMsoStdComponentMgr::FContinueMessageLoop),
  791. host should return TRUE from this method. If host had to terminate
  792. the loop for some other reason, it should return FALSE. */
  793. MSOMETHOD_(BOOL, FPushMessageLoop) (THIS_ ULONG uReason) PURE;
  794. };
  795. /****************************************************************************
  796. Structures and constants for simple recording.
  797. ****************************************************************************/
  798. // Simple recorder context values passed to IMsoSimpleRecorder::FGetContext
  799. enum
  800. {
  801. msosrctxCommandBars = 0, // pv will be the IMsoToolbarSet object
  802. msosrctxEscher = 1,
  803. msosrctxDrawing = 2,
  804. msosrctxDrawingSelection = 3,
  805. msosrctxDrawingSchemeColor = 4,
  806. msosrctxDrawingDefault = 5,
  807. };
  808. /****************************************************************************
  809. Defines the IMsoSimpleRecorder interface
  810. ****************************************************************************/
  811. #undef INTERFACE
  812. #define INTERFACE IMsoSimpleRecorder
  813. DECLARE_INTERFACE_(IMsoSimpleRecorder, IUnknown)
  814. {
  815. BEGIN_MSOINTERFACE
  816. // *** IUnknown methods ***
  817. MSOMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppvObj) PURE;
  818. MSOMETHOD_(ULONG, AddRef) (THIS) PURE;
  819. MSOMETHOD_(ULONG, Release) (THIS) PURE;
  820. /* Standard FDebugMessage method.
  821. Since IMsoSimpleRecorder is a reference counted interface,
  822. MsoDWGetChkMemCounter is used when processing the
  823. msodmWriteBe message. */
  824. MSODEBUGMETHOD
  825. /* Returns a string specifying the position of the requested context
  826. in the host's object model. The context is specified by msosrctx,
  827. and the additional value pv if needed to disambiguate different
  828. objects of that type. The string buffer should have room for
  829. 255 characters. Returns TRUE if successful, FALSE otherwise. */
  830. MSOMETHOD_(BOOL, FGetContext)(THIS_ int msosrctx, void *pv, WCHAR *wz) PURE;
  831. /* Asks the host to record a line of text at the current position
  832. in the recorder stream. Returns TRUE if the line was successfully
  833. recorded, FALSE otherwise. */
  834. MSOMETHOD_(BOOL, FRecordLine)(THIS_ WCHAR *wz) PURE;
  835. /* Returns TRUE if the host currently has recording turned on, and
  836. FALSE otherwise. */
  837. MSOMETHOD_(BOOL, FRecording)(THIS) PURE;
  838. };
  839. /****************************************************************************
  840. Global DLL API's
  841. ****************************************************************************/
  842. /* Called by host application to register picm as the component manager for
  843. the calling thread. Standard reference counting rules apply.
  844. picm can be NULL, indicating that the currently registered component
  845. manager should be revoked.
  846. If there is a previously registered component manager it is Released.
  847. Returns TRUE if successful. */
  848. MSOAPI_(BOOL) MsoFSetComponentManager(IMsoComponentManager *picm);
  849. /* Return in *ppicm an AddRef'ed pointer to the currently registered
  850. component manager for the calling thread.
  851. Returns TRUE if successful. */
  852. MSOAPI_(BOOL) MsoFGetComponentManager(IMsoComponentManager **ppicm);
  853. /* Create an object which has the Office supplied standard implementation
  854. of IMsoStdComponentMgr and IMsoComponentManager, and return it in *ppvObj.
  855. piUnkOuter is the controlling unknown for aggregation (can be NULL).
  856. pich (cannot be NULL) is the pointer to the IMsoComponentHost
  857. that will use the object.
  858. riid is the id of the desired interface.
  859. If fRegister is TRUE, the created object is registered as the calling
  860. thread's component manager.
  861. Returns TRUE if successful. */
  862. MSOAPI_(BOOL) MsoFCreateStdComponentManager(
  863. IUnknown *piUnkOuter,
  864. IMsoComponentHost *pich,
  865. BOOL fRegister,
  866. REFIID riid,
  867. void **ppvObj);
  868. #endif // MSOCI_H