home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / gw / oddev.exe / ODMASAMP.H < prev    next >
C/C++ Source or Header  |  1994-07-15  |  6KB  |  174 lines

  1. /*  odmasamp.h - This file contains definitions, prototypes, etc. for the
  2.      sample ODMA implementation.  */
  3.  
  4. #include <windows.h>
  5. #include "odmacom.h"
  6. #include "odmasamp.rh"
  7.  
  8. #define MAXDOCS    20    // Max. # of documents the sample app. supports
  9. #define DMSNAME "ODMA 1.0 Sample DMS"
  10. #define DMSID    "ODMASAMP"
  11.  
  12. // Flags for Profile dialog window procedure
  13. #define PROFILE_EDIT    1
  14.  
  15. #define NC(a,b) a##::##b
  16.  
  17. class Application {
  18.  
  19.   public:
  20.     Application( LPUNKNOWN pUnkOuter, DWORD dwEnvData );
  21.     ~Application();
  22.     HRESULT GetInterface( REFIID riid, LPVOID FAR *ppvObj );
  23.  
  24.   private:
  25.     //----------------------------------------------------------------
  26.     // IUnknown implementation
  27.     //----------------------------------------------------------------
  28.       struct CUnknown : IUnknown {
  29.         CUnknown(Application *pObject) { m_pObject = pObject; }
  30.  
  31.         //*** IUnknown ***
  32.             STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppvObj);
  33.         STDMETHOD_(ULONG,AddRef) (VOID);
  34.         STDMETHOD_(ULONG,Release) (VOID);
  35.  
  36.         private:
  37.         Application *m_pObject;    // pointer to parent object
  38.       };
  39.       friend CUnknown;
  40.       CUnknown m_Unknown;
  41.  
  42.     //----------------------------------------------------------------
  43.     // IODMDocMan interface
  44.     //----------------------------------------------------------------
  45.       struct CODMDocMan : IODMDocMan {
  46.         CODMDocMan(Application *pObject) { m_pObject = pObject; }
  47.         ~CODMDocMan() {};
  48.  
  49.         //*** IUnknown ***
  50.             STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppvObj);
  51.         STDMETHOD_(ULONG,AddRef) (VOID);
  52.         STDMETHOD_(ULONG,Release) (VOID);
  53.  
  54.         // *** IODMDocMan methods ***
  55.         STDMETHOD_(ODMSTATUS, SelectDoc)(LPSTR lpszDocId, LPDWORD pdwFlags );
  56.         STDMETHOD_(ODMSTATUS, OpenDoc)(DWORD flags, LPSTR lpszDocId,
  57.             LPSTR lpszDocLocation );
  58.         STDMETHOD_(ODMSTATUS, SaveDoc)(LPSTR lpszDocId, LPSTR lpszNewDocId );
  59.         STDMETHOD_(ODMSTATUS, CloseDoc)(LPSTR lpszDocId, DWORD activeTime,
  60.             DWORD pagesPrinted, LPVOID sessionData, WORD dataLen );
  61.         STDMETHOD_(ODMSTATUS, NewDoc)(LPSTR lpszDocId, DWORD dwFlags,
  62.             LPSTR lpszFormat, LPSTR lpszDocLocation  );
  63.         STDMETHOD_(ODMSTATUS, SaveAs)(LPSTR lpszDocId, LPSTR lpszNewDocId,
  64.             LPSTR lpszFormat, ODMSAVEASCALLBACK pcbCallBack,
  65.             LPVOID pInstanceData );
  66.         STDMETHOD_(ODMSTATUS, Activate)(WORD action, LPSTR lpszDocId );
  67.         STDMETHOD_(ODMSTATUS, GetDocInfo)(LPSTR lpszDocId, WORD item,
  68.             LPSTR lpszData, WORD dataLen );
  69.         STDMETHOD_(ODMSTATUS, SetDocInfo)(LPSTR lpszDocId, WORD item,
  70.             LPSTR lpszData );
  71.         STDMETHOD_(ODMSTATUS, GetDMSInfo) (LPSTR lpszDmsId, LPWORD pwVerNo,
  72.             LPDWORD pdwExtensions );
  73.         STDMETHOD_(ODMSTATUS, GetLeadMoniker)(LPSTR lpszDocId,
  74.             LPMONIKER FAR *ppMoniker );
  75.  
  76.         private:
  77.         Application *m_pObject;                    // pointer to parent object
  78.     };
  79.     friend CODMDocMan;
  80.     CODMDocMan m_ODMDocMan;
  81.  
  82.   private:
  83.     // Internal data
  84.     DWORD m_dwRefs;             // reference count
  85.     LPUNKNOWN m_pUnkOuter;      // controlling IUnknown
  86.     HWND m_clientWind;            // window handle from client
  87. };  // Application
  88.  
  89. class Document {
  90.  
  91. private:
  92.     char DocId[80];
  93.     int SaveFlag;
  94.     char Author[30];
  95.     char Name[80];
  96.     char DocType[30];
  97.     char Format[30];
  98.     char DocLocation[ODM_FILENAME_MAX];
  99.     int OpenCount;
  100.     int DocAccessed;    /* This flag tracks whether or not the application has
  101.                             ever had a chance to access the document.  It is u
  102.                             used during SaveAs. */
  103.  
  104.     void Init(void);
  105.  
  106. friend BOOL CALLBACK _export ProfileProc( HWND hwndDlg, UINT message, WPARAM wParam,
  107.     LPARAM lParam);
  108.     
  109. public:
  110.     Document();
  111.     ~Document() {};
  112.     Document( LPSTR lpszFormat, LPSTR lpszDocLocation );
  113.     Document( Document *pOldDoc );
  114.     Document( LPSTR lpszDocId );
  115.     char *GetId( void ) { return DocId; };
  116.     int GetOpenCount( void ) { return OpenCount; };
  117.     ODMSTATUS Open( LPSTR lpszFileName );
  118.     ODMSTATUS Save() { SaveFlag = 1; return 0; };
  119.     ODMSTATUS Close( DWORD activeTime, DWORD pagesPrinted,
  120.         LPVOID sessionData, WORD dataLen );
  121.     ODMSTATUS EditAttributes( HWND hParent );
  122.     ODMSTATUS ShowAttributes( HWND hParent );
  123.     ODMSTATUS GetInfo( WORD item, LPSTR lpszData, WORD dataLen );
  124.     ODMSTATUS SetInfo( WORD item, LPSTR lpszData );
  125.     void SaveInfo( void );
  126.     int HasBeenAccessed( void ) { return DocAccessed; };
  127. };
  128.  
  129. class DocumentList {
  130.  
  131. private:
  132.     Document *List[MAXDOCS];
  133.  
  134. public:
  135.     DocumentList();
  136.     ~DocumentList();
  137.     void SaveList();
  138.     Document *GetDocumentByIndex( int n );
  139.     Document *GetDocumentById( LPSTR lpszDocId );
  140.     int GetDocumentIndexById( LPSTR lpszDocId );
  141.     ODMSTATUS NewDocument( LPSTR lpszFormat, LPSTR lpszDocLocation,
  142.         Document **ppDoc, DWORD dwFlags, HWND hParent );
  143.     ODMSTATUS CopyDocument( LPSTR lpszDocId, Document **ppDoc, HWND hParent );
  144.     ODMSTATUS DeleteDocument( LPSTR lpszDocId );
  145. };  // DocumentList
  146.  
  147. // Structure definitions
  148. typedef struct {
  149.     LPVOID pInstanceData;
  150.     ODMSAVEASCALLBACK pcbCallBack;
  151.     char Format[50];
  152. } SaveAsData;
  153.  
  154. typedef struct {
  155.     Document *pDocument;
  156.     int Mode;
  157. } ProDlgData;
  158.  
  159. // Globals
  160. extern HINSTANCE NEAR hInst;
  161. extern DocumentList NEAR DocList;
  162.  
  163. // Prototypes
  164. BOOL CALLBACK _export SelectDocProc( HWND hwndDlg, UINT message, WPARAM wParam,
  165.     LPARAM lParam);
  166. BOOL CALLBACK _export SaveAsProc( HWND hwndDlg, UINT message, WPARAM wParam,
  167.     LPARAM lParam);
  168. BOOL CALLBACK _export ProfileProc( HWND hwndDlg, UINT message, WPARAM wParam,
  169.     LPARAM lParam);
  170.  
  171.  
  172.  
  173.  
  174.