Source code of Windows XP (NT5)
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.

573 lines
6.9 KiB

  1. /*++
  2. Copyright (c) 1994-95 Microsoft Corporation
  3. Module Name:
  4. llsdoc.cpp
  5. Abstract:
  6. Document implementation.
  7. Author:
  8. Don Ryan (donryan) 12-Feb-1995
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. --*/
  13. #include "stdafx.h"
  14. #include "llsmgr.h"
  15. #include "llsdoc.h"
  16. #include "llsview.h"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21. IMPLEMENT_DYNCREATE(CLlsmgrDoc, CDocument)
  22. BEGIN_MESSAGE_MAP(CLlsmgrDoc, CDocument)
  23. //{{AFX_MSG_MAP(CLlsmgrDoc)
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. BEGIN_DISPATCH_MAP(CLlsmgrDoc, CDocument)
  27. //{{AFX_DISPATCH_MAP(CLlsmgrDoc)
  28. //}}AFX_DISPATCH_MAP
  29. END_DISPATCH_MAP()
  30. CLlsmgrDoc::CLlsmgrDoc()
  31. /*++
  32. Routine Description:
  33. Constructor for document object.
  34. Arguments:
  35. None.
  36. Return Values:
  37. None.
  38. --*/
  39. {
  40. m_pDomain = NULL;
  41. m_pController = NULL;
  42. }
  43. CLlsmgrDoc::~CLlsmgrDoc()
  44. /*++
  45. Routine Description:
  46. Destructor for document object.
  47. Arguments:
  48. None.
  49. Return Values:
  50. None.
  51. --*/
  52. {
  53. //
  54. // Nothing to do here.
  55. //
  56. }
  57. #ifdef _DEBUG
  58. void CLlsmgrDoc::AssertValid() const
  59. /*++
  60. Routine Description:
  61. Validates object.
  62. Arguments:
  63. None.
  64. Return Values:
  65. None.
  66. --*/
  67. {
  68. CDocument::AssertValid();
  69. }
  70. #endif //_DEBUG
  71. #ifdef _DEBUG
  72. void CLlsmgrDoc::Dump(CDumpContext& dc) const
  73. /*++
  74. Routine Description:
  75. Dumps contents of object.
  76. Arguments:
  77. dc - dump context.
  78. Return Values:
  79. None.
  80. --*/
  81. {
  82. CDocument::Dump(dc);
  83. }
  84. #endif //_DEBUG
  85. CController* CLlsmgrDoc::GetController()
  86. /*++
  87. Routine Description:
  88. Retrieves current controller object.
  89. Arguments:
  90. None.
  91. Return Values:
  92. Object pointer or NULL.
  93. --*/
  94. {
  95. if (!m_pController)
  96. {
  97. m_pController = (CController*)MKOBJ(LlsGetApp()->GetActiveController());
  98. VALIDATE_OBJECT(m_pController, CController);
  99. if (m_pController)
  100. m_pController->InternalRelease(); // held open by CApplication
  101. }
  102. return m_pController;
  103. }
  104. CDomain* CLlsmgrDoc::GetDomain()
  105. /*++
  106. Routine Description:
  107. Retrieves current domain object.
  108. Arguments:
  109. None.
  110. Return Values:
  111. Object pointer or NULL.
  112. --*/
  113. {
  114. if (!m_pDomain)
  115. {
  116. m_pDomain = (CDomain*)MKOBJ(LlsGetApp()->GetActiveDomain());
  117. VALIDATE_OBJECT(m_pDomain, CDomain);
  118. if (m_pDomain)
  119. m_pDomain->InternalRelease(); // held open by CApplication
  120. }
  121. return m_pDomain;
  122. }
  123. CLicenses* CLlsmgrDoc::GetLicenses()
  124. /*++
  125. Routine Description:
  126. Retrieves current list of licenses.
  127. Arguments:
  128. None.
  129. Return Values:
  130. Object pointer or NULL.
  131. --*/
  132. {
  133. CLicenses* pLicenses = NULL;
  134. GetController(); // initialize if necessary
  135. if (m_pController)
  136. {
  137. VARIANT va;
  138. VariantInit(&va);
  139. pLicenses = (CLicenses*)MKOBJ(m_pController->GetLicenses(va));
  140. if (pLicenses)
  141. pLicenses->InternalRelease(); // held open by CController
  142. }
  143. return pLicenses;
  144. }
  145. CMappings* CLlsmgrDoc::GetMappings()
  146. /*++
  147. Routine Description:
  148. Retrieves current list of mappings.
  149. Arguments:
  150. None.
  151. Return Values:
  152. Object pointer or NULL.
  153. --*/
  154. {
  155. CMappings* pMappings = NULL;
  156. GetController(); // initialize if necessary
  157. if (m_pController)
  158. {
  159. VARIANT va;
  160. VariantInit(&va);
  161. pMappings = (CMappings*)MKOBJ(m_pController->GetMappings(va));
  162. if (pMappings)
  163. pMappings->InternalRelease(); // held open by CController
  164. }
  165. return pMappings;
  166. }
  167. CProducts* CLlsmgrDoc::GetProducts()
  168. /*++
  169. Routine Description:
  170. Retrieves current list of products.
  171. Arguments:
  172. None.
  173. Return Values:
  174. Object pointer or NULL.
  175. --*/
  176. {
  177. CProducts* pProducts = NULL;
  178. GetController(); // initialize if necessary
  179. if (m_pController)
  180. {
  181. VARIANT va;
  182. VariantInit(&va);
  183. pProducts = (CProducts*)MKOBJ(m_pController->GetProducts(va));
  184. if (pProducts)
  185. pProducts->InternalRelease(); // held open by CController
  186. }
  187. return pProducts;
  188. }
  189. CUsers* CLlsmgrDoc::GetUsers()
  190. /*++
  191. Routine Description:
  192. Retrieves current list of users.
  193. Arguments:
  194. None.
  195. Return Values:
  196. Object pointer or NULL.
  197. --*/
  198. {
  199. CUsers* pUsers = NULL;
  200. GetController(); // initialize if necessary
  201. if (m_pController)
  202. {
  203. VARIANT va;
  204. VariantInit(&va);
  205. pUsers = (CUsers*)MKOBJ(m_pController->GetUsers(va));
  206. if (pUsers)
  207. pUsers->InternalRelease(); // held open by CController
  208. }
  209. return pUsers;
  210. }
  211. void CLlsmgrDoc::OnCloseDocument()
  212. /*++
  213. Routine Description:
  214. Called by framework to close document.
  215. Arguments:
  216. None.
  217. Return Values:
  218. None.
  219. --*/
  220. {
  221. CDocument::OnCloseDocument();
  222. }
  223. BOOL CLlsmgrDoc::OnNewDocument()
  224. /*++
  225. Routine Description:
  226. Called by framework to open new document.
  227. Arguments:
  228. None.
  229. Return Values:
  230. Returns true if document successfully opened.
  231. --*/
  232. {
  233. return TRUE; // always succeeds
  234. }
  235. BOOL CLlsmgrDoc::OnOpenDocument(LPCTSTR lpszPathName)
  236. /*++
  237. Routine Description:
  238. Called by framework to open existing document.
  239. Arguments:
  240. lpszPathName - file name.
  241. Return Values:
  242. Returns true if document successfully opened.
  243. --*/
  244. {
  245. Update(); // invalidate info...
  246. CString strTitle;
  247. if (LlsGetApp()->IsFocusDomain())
  248. {
  249. CDomain* pDomain = GetDomain();
  250. VALIDATE_OBJECT(pDomain, CDomain);
  251. strTitle = pDomain->m_strName;
  252. POSITION position = GetFirstViewPosition();
  253. ((CLlsmgrView*)GetNextView(position))->AddToMRU(strTitle);
  254. }
  255. else
  256. {
  257. strTitle.LoadString(IDS_ENTERPRISE);
  258. }
  259. SetTitle(strTitle);
  260. return TRUE; // always succeeds
  261. }
  262. BOOL CLlsmgrDoc::OnSaveDocument(LPCTSTR lpszPathName)
  263. /*++
  264. Routine Description:
  265. Called by framework to save open document.
  266. Arguments:
  267. None.
  268. Return Values:
  269. Returns true if document successfully saved.
  270. --*/
  271. {
  272. return TRUE; // always succeeds
  273. }
  274. void CLlsmgrDoc::Update()
  275. /*++
  276. Routine Description:
  277. Resets information so its updated when queried.
  278. Arguments:
  279. None.
  280. Return Values:
  281. None.
  282. --*/
  283. {
  284. m_pDomain = NULL;
  285. }
  286. BOOL CLlsmgrDoc::SaveModified()
  287. /*++
  288. Routine Description:
  289. Called by framework to determine if document can be saved modified.
  290. Arguments:
  291. None.
  292. Return Values:
  293. Returns true if document can be saved.
  294. --*/
  295. {
  296. return TRUE; // always succeeds
  297. }
  298. void CLlsmgrDoc::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU)
  299. /*++
  300. Routine Description:
  301. Called by framework to save pathname in MRU list.
  302. Arguments:
  303. None.
  304. Return Values:
  305. None.
  306. --*/
  307. {
  308. //
  309. // Nothing to do here.
  310. //
  311. }
  312. void CLlsmgrDoc::Serialize(CArchive& ar)
  313. /*++
  314. Routine Description:
  315. Called by framework for document i/o.
  316. Arguments:
  317. ar - archive object.
  318. Return Values:
  319. None.
  320. --*/
  321. {
  322. //
  323. // Nothing to do here.
  324. //
  325. }