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.

783 lines
22 KiB

  1. // StrEdit.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "minidev.h"
  5. #include <gpdparse.h>
  6. #include "rcfile.h"
  7. #include "projrec.h"
  8. #include "projnode.h"
  9. #include "comctrls.h"
  10. #include "StrEdit.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CStringEditorView
  18. IMPLEMENT_DYNCREATE(CStringEditorView, CFormView)
  19. CStringEditorView::CStringEditorView()
  20. : CFormView(CStringEditorView::IDD)
  21. {
  22. //{{AFX_DATA_INIT(CStringEditorView)
  23. m_csGotoID = _T("");
  24. m_csSearchString = _T("");
  25. m_csLabel1 = _T("Press INS to add or insert a new string.\tDouble click an item or press ENTER to begin editing.");
  26. m_csLabel2 = _T("Press DEL to delete the selected strings.\tPress TAB to move between columns when editing.");
  27. //}}AFX_DATA_INIT
  28. m_bFirstActivate = true ;
  29. }
  30. CStringEditorView::~CStringEditorView()
  31. {
  32. }
  33. void CStringEditorView::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CFormView::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CStringEditorView)
  37. DDX_Control(pDX, IDC_SESearchBox, m_ceSearchBox);
  38. DDX_Control(pDX, IDC_SEGotoBox, m_ceGotoBox);
  39. DDX_Control(pDX, IDC_SEGotoBtn, m_cbGoto);
  40. DDX_Control(pDX, IDC_SELstCtrl, m_cflstStringData);
  41. DDX_Text(pDX, IDC_SEGotoBox, m_csGotoID);
  42. DDX_Text(pDX, IDC_SESearchBox, m_csSearchString);
  43. DDX_Text(pDX, IDC_SELabel1, m_csLabel1);
  44. DDX_Text(pDX, IDC_SELabel2, m_csLabel2);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(CStringEditorView, CFormView)
  48. //{{AFX_MSG_MAP(CStringEditorView)
  49. ON_BN_CLICKED(IDC_SEGotoBtn, OnSEGotoBtn)
  50. ON_BN_CLICKED(IDC_SESearchBtn, OnSESearchBtn)
  51. ON_WM_DESTROY()
  52. ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  53. //}}AFX_MSG_MAP
  54. ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CStringEditorView diagnostics
  58. #ifdef _DEBUG
  59. void CStringEditorView::AssertValid() const
  60. {
  61. CFormView::AssertValid();
  62. }
  63. void CStringEditorView::Dump(CDumpContext& dc) const
  64. {
  65. CFormView::Dump(dc);
  66. }
  67. #endif //_DEBUG
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CStringEditorView message handlers
  70. /******************************************************************************
  71. CStringEditorView::OnSEGotoBtn
  72. Find and select the list control row that contains the requested RC ID.
  73. ******************************************************************************/
  74. void CStringEditorView::OnSEGotoBtn()
  75. {
  76. CString cserrmsg ; // Used to display error messages
  77. // Get the RC ID string and trim it. Convert it to an integer to make sure
  78. // it is valid.
  79. UpdateData(TRUE) ;
  80. m_csGotoID.TrimLeft() ;
  81. m_csGotoID.TrimRight() ;
  82. int nrcid = atoi(m_csGotoID) ;
  83. if (nrcid <= 0) {
  84. cserrmsg.Format(IDS_BadGotoRCID, m_csGotoID) ;
  85. AfxMessageBox(cserrmsg, MB_ICONEXCLAMATION) ;
  86. return ;
  87. } ;
  88. // Now that we know what RC ID the user wants, try to find and select it.
  89. FindSelRCIDEntry(nrcid, true) ;
  90. }
  91. /******************************************************************************
  92. CStringEditorView::FindSelRCIDEntry
  93. Find and select the list control row that contains the requested RC ID.
  94. Return true if the entry was found. Otherwise, display an error message if
  95. berror = true and return false.
  96. ******************************************************************************/
  97. bool CStringEditorView::FindSelRCIDEntry(int nrcid, bool berror)
  98. {
  99. CString cserrmsg ; // Used to display error messages
  100. // Look for an item with the specified RC ID. Complain and return if it
  101. // is not found.
  102. LV_FINDINFO lvfi ;
  103. lvfi.flags = LVFI_STRING ;
  104. TCHAR acbuf[16] ;
  105. lvfi.psz = _itoa(nrcid, acbuf, 10) ;
  106. int nitem = m_cflstStringData.FindItem(&lvfi) ;
  107. if (nitem == -1) {
  108. if (berror) {
  109. cserrmsg.Format(IDS_NoGotoRCID, acbuf) ;
  110. AfxMessageBox(cserrmsg, MB_ICONEXCLAMATION) ;
  111. }
  112. return false ;
  113. } ;
  114. // Select the row containing the specified RC ID and deselect any other
  115. // selected rows.
  116. m_cflstStringData.SingleSelect(nitem) ;
  117. // All went well so...
  118. return true ;
  119. }
  120. /******************************************************************************
  121. CStringEditorView::OnSESearchBtn
  122. Find and select the list control row that contains the requested search
  123. string. The search begins with the row after the first selected row and
  124. will wrap around to the beginning of the table if needed and stop at the
  125. first selected row. Of course, it only happens that way if it doesn't
  126. find a matching field first. The fields (including the RC ID field) in
  127. each row are checked from left to right. A case insensitive search is
  128. performed. The search string must be contained within a field string.
  129. IE, "abc", "abcde", and "bc" will all match the search string "bc".
  130. ******************************************************************************/
  131. void CStringEditorView::OnSESearchBtn()
  132. {
  133. CString cserrmsg ; // Used to display error messages
  134. // Get the search string. Complain if it is empty.
  135. UpdateData(TRUE) ;
  136. if (m_csSearchString == _T("")) {
  137. AfxMessageBox(IDS_BadSearchString, MB_ICONEXCLAMATION) ;
  138. return ;
  139. } ;
  140. CWaitCursor cwc ;
  141. // Get the currently selected row number and the number of rows in the
  142. // table.
  143. int ncurrentrow = m_cflstStringData.GetNextItem(-1, LVNI_SELECTED) ;
  144. int numrows = m_cflstStringData.GetItemCount() ;
  145. // Make an uppercased copy of the search string.
  146. CString cssrchstr(m_csSearchString) ;
  147. cssrchstr.MakeUpper() ;
  148. // Search for the string in the part of the table starting after the
  149. // current row and ending at the end of the table. If a match is found,
  150. // select the row and return.
  151. if (SearchHelper(cssrchstr, ncurrentrow + 1, numrows))
  152. return ;
  153. // Search for the string in the part of the table starting at the first
  154. // row and ending at the first selected row. If a match is found, select
  155. // the row and return.
  156. if (SearchHelper(cssrchstr, 0, ncurrentrow + 1))
  157. return ;
  158. // Tell the user that a match was not found.
  159. cserrmsg.Format(IDS_NoSearchString, m_csSearchString) ;
  160. AfxMessageBox(cserrmsg, MB_ICONEXCLAMATION) ;
  161. }
  162. /******************************************************************************
  163. CStringEditorView::SearchHelper
  164. Search the specified rows for one that contains a field that contains the
  165. search string. See OnSESearchBtn() for more details.
  166. ******************************************************************************/
  167. bool CStringEditorView::SearchHelper(CString cssrchstr, int nfirstrow,
  168. int numrows)
  169. {
  170. CStringArray csafields ; // Used to hold fields in a row
  171. bool bfound = false ; // True iff a match is found
  172. // Search the specified rows.
  173. for (int nrow = nfirstrow ; nrow < numrows ; nrow++) {
  174. m_cflstStringData.GetRowData(nrow, csafields) ;
  175. // Check each field in the current row for a match.
  176. for (int nfld = 0 ; nfld < m_cflstStringData.GetNumColumns() ; nfld++) {
  177. csafields[nfld].MakeUpper() ;
  178. if (csafields[nfld].Find(cssrchstr) >= 0) {
  179. bfound = true ;
  180. break ;
  181. } ;
  182. } ;
  183. // Select the row and return success if a match was found.
  184. if (bfound) {
  185. m_cflstStringData.SingleSelect(nrow) ;
  186. return true ;
  187. } ;
  188. } ;
  189. // No match was found so...
  190. return false ;
  191. }
  192. /******************************************************************************
  193. CStringEditorView::OnInitialUpdate
  194. Resize the frame to better fit the controls in it. Then load the list
  195. control with the RC IDs and strings for this project.
  196. ******************************************************************************/
  197. void CStringEditorView::OnInitialUpdate()
  198. {
  199. CRect crtxt ; // Coordinates of first label
  200. CRect crbtnfrm ; // Coordinates of goto button and frame
  201. CFormView::OnInitialUpdate() ;
  202. CWaitCursor cwc ;
  203. // Get the dimensions of the first label
  204. HWND hlblhandle ;
  205. GetDlgItem(IDC_SELabel1, &hlblhandle) ;
  206. ::GetWindowRect(hlblhandle, crtxt) ;
  207. crtxt.NormalizeRect() ;
  208. // Get the dimensions of the Goto button and then combine them with the
  209. // dimensions of the label to get the dimensions for the form.
  210. m_cbGoto.GetWindowRect(crbtnfrm) ;
  211. crbtnfrm.top = crtxt.top ;
  212. crbtnfrm.right = crtxt.right ;
  213. // Make sure the frame is big enough for these 2 controls, everything in
  214. // between, plus a little bit more.
  215. crbtnfrm.right += 32 ;
  216. crbtnfrm.bottom += 32 ;
  217. GetParentFrame()->CalcWindowRect(crbtnfrm) ;
  218. GetParentFrame()->SetWindowPos(NULL, 0, 0, crbtnfrm.Width(), crbtnfrm.Height(),
  219. SWP_NOZORDER | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOACTIVATE) ;
  220. // Make a copy of the string table information for two reasons. First,
  221. // CFullEditListCtrl takes data in a different format. Second, the string
  222. // table can't be changed until the user says ok. The local variables can
  223. // be updated when needed. Begin by sizing the local arrays.
  224. CStringTable* pcst = ((CStringEditorDoc*) GetDocument())->GetRCData() ;
  225. m_uStrCount = pcst->Count() ;
  226. m_csaStrings.SetSize(m_uStrCount) ;
  227. m_cuiaRCIDs.SetSize(m_uStrCount) ;
  228. // Copy the string table if it has a nonzero length.
  229. CString cstmp ;
  230. if (m_uStrCount > 0) {
  231. WORD wkey ;
  232. for (unsigned u = 0 ; u < m_uStrCount ; u++) {
  233. pcst->Details(u, wkey, cstmp) ;
  234. m_cuiaRCIDs[u] = (unsigned) wkey ;
  235. m_csaStrings[u] = cstmp ;
  236. } ;
  237. } ;
  238. // Now, initialize the list control by telling it we want full row select
  239. // and the number of rows and columns needed.
  240. m_cflstStringData.InitControl(LVS_EX_FULLROWSELECT, m_uStrCount, 2) ;
  241. // Put the RC IDs into the list control's first column.
  242. cstmp.LoadString(IDS_StrEditRCIDColLab) ;
  243. m_cflstStringData.InitLoadColumn(0, cstmp, COMPUTECOLWIDTH, 20, true, true,
  244. COLDATTYPE_INT, (CObArray*) &m_cuiaRCIDs) ;
  245. // Put the strings into the list control's second column.
  246. cstmp.LoadString(IDS_StrEditStringColLab) ;
  247. m_cflstStringData.InitLoadColumn(1, cstmp, SETWIDTHTOREMAINDER, -36, true,
  248. true, COLDATTYPE_STRING,
  249. (CObArray*) &m_csaStrings) ;
  250. m_cflstStringData.SetFocus() ; // The list control gets the focus
  251. }
  252. /******************************************************************************
  253. CStringEditorView::OnActivateView
  254. If the editor has been invoked from the GPD Editor (or wherever) and there
  255. is a string entry that should be selected based on its RC ID, do it.
  256. ******************************************************************************/
  257. void CStringEditorView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
  258. {
  259. CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView) ;
  260. // Do nothing if the view is not being activated. Skip the first
  261. // activate too because the view hasn't been displayed yet. This
  262. // is a problem when there is an invalid RC ID.
  263. if (!bActivate || pActivateView != this || m_bFirstActivate) {
  264. m_bFirstActivate = false ;
  265. return ;
  266. } ;
  267. // Do nothing if the strings node pointer hasn't been set yet.
  268. CStringEditorDoc* pcsed = (CStringEditorDoc*) GetDocument() ;
  269. CStringsNode* pcsn = pcsed->GetStrNode() ;
  270. if (pcsn == NULL) { // raid 3176
  271. m_csLabel1.LoadString(IDS_StrEditNoEdit);
  272. m_csLabel2 = _T(" ");
  273. UpdateData(FALSE);
  274. m_cflstStringData.EnableWindow(FALSE);
  275. int rcid;
  276. CWinApp *cwa = AfxGetApp();
  277. rcid = cwa->GetProfileInt(_T("StrEditDoc"),_T("StrEditDoc"),1);
  278. if ( -1 != rcid ) {
  279. cwa->WriteProfileInt(_T("StrEditDoc"),_T("StrEditDoc"), -1);
  280. FindSelRCIDEntry(rcid,true);
  281. }
  282. return ;
  283. }
  284. // Select the entry containing the specified RC ID if the RC ID is valid.
  285. // Otherwise, just select row 0.
  286. int nrcid = pcsn->GetFirstSelRCID() ;
  287. if (nrcid != -1) {
  288. ((CStringEditorDoc*) GetDocument())->GetStrNode()->SetFirstSelRCID(-1) ;
  289. FindSelRCIDEntry(nrcid, true) ;
  290. } ;
  291. }
  292. /******************************************************************************
  293. CStringEditorView::OnDestroy
  294. When the view is being destroyed, called the parent string node and tell it
  295. to delete the corresponding document class and clear its pointer to the
  296. document class.
  297. ******************************************************************************/
  298. void CStringEditorView::OnDestroy()
  299. {
  300. CFormView::OnDestroy();
  301. if (((CStringEditorDoc*) GetDocument())->GetStrNode())
  302. ((CStringEditorDoc*) GetDocument())->GetStrNode()->OnEditorDestroyed() ;
  303. }
  304. /******************************************************************************
  305. CStringEditorView::SaveStringTable
  306. Update this project's string table if needed and (optionally) the user
  307. requests it.
  308. If the user wants to save the table (optional) and the table is valid, save
  309. it and return true. If the table hasn't changed or the user doesn't want to
  310. save the table, return true. Otherwise, return false.
  311. ******************************************************************************/
  312. bool CStringEditorView::SaveStringTable(CStringEditorDoc* pcsed, bool bprompt)
  313. {
  314. // Make sure the new table contents are sorted in ascending order by RC ID.
  315. m_cflstStringData.SortControl(0) ;
  316. if (!m_cflstStringData.GetColSortOrder(0))
  317. m_cflstStringData.SortControl(0) ;
  318. // Get the string table data out of the list control and into the member
  319. // variables. Then get a pointer to the project's string table.
  320. m_cflstStringData.GetColumnData((CObArray*) &m_cuiaRCIDs, 0) ;
  321. m_cflstStringData.GetColumnData((CObArray*) &m_csaStrings, 1) ;
  322. CStringTable* pcst = ((CStringEditorDoc*) GetDocument())->GetRCData() ;
  323. // Check the table/array lengths and the individual items to see if
  324. // anything has changed.
  325. bool bchanged = false ;
  326. CString cstmp ;
  327. WORD wkey ;
  328. unsigned unumitems = (unsigned)m_cuiaRCIDs.GetSize() ;
  329. if (pcst->Count() != unumitems)
  330. bchanged = true ;
  331. else {
  332. for (unsigned u = 0 ; u < unumitems ; u++) {
  333. pcst->Details(u, wkey, cstmp) ;
  334. if ((unsigned) wkey != m_cuiaRCIDs[u] || cstmp != m_csaStrings[u]) {
  335. bchanged = true ;
  336. break ;
  337. } ;
  338. } ;
  339. } ;
  340. // Return true if nothing is saved because nothing has changed.
  341. if (!bchanged)
  342. return true ;
  343. // If requested, ask the user if the changes should be saved. Return
  344. // true if he says no.
  345. CProjectRecord* pcpr = pcsed->GetOwner() ;
  346. if (bprompt) {
  347. cstmp.Format(IDS_SaveStrTabPrompt, pcpr->DriverName()) ;
  348. if (AfxMessageBox(cstmp, MB_ICONQUESTION + MB_YESNO) == IDNO)
  349. return true ;
  350. } ;
  351. // Check to see if there are any invalid or duplicate RC IDs or if there
  352. // are any missing strings. If any are found, complain, select the
  353. // offending row, and return false since nothing is saved.
  354. for (unsigned u = 0 ; u < unumitems ; u++) {
  355. if (((int) m_cuiaRCIDs[u]) <= 0) {
  356. m_cflstStringData.SingleSelect(u) ;
  357. cstmp.LoadString(IDS_InvalidRCID) ;
  358. AfxMessageBox(cstmp, MB_ICONEXCLAMATION) ;
  359. SetFocus() ;
  360. return false ;
  361. } ;
  362. if (m_cuiaRCIDs[u] >= 10000 && m_cuiaRCIDs[u] <= 20000) {
  363. m_cflstStringData.SingleSelect(u) ;
  364. cstmp.LoadString(IDS_ReservedRCIDUsed) ;
  365. AfxMessageBox(cstmp, MB_ICONEXCLAMATION) ;
  366. SetFocus() ;
  367. return false ;
  368. } ;
  369. if (u > 0 && m_cuiaRCIDs[u] == m_cuiaRCIDs[u - 1]) {
  370. m_cflstStringData.SingleSelect(u) ;
  371. cstmp.LoadString(IDS_DuplicateRCID) ;
  372. AfxMessageBox(cstmp, MB_ICONEXCLAMATION) ;
  373. SetFocus() ;
  374. return false ;
  375. } ;
  376. if (m_csaStrings[u].GetLength() == 0) {
  377. m_cflstStringData.SingleSelect(u) ;
  378. cstmp.LoadString(IDS_EmptyStringInStrTab) ;
  379. AfxMessageBox(cstmp, MB_ICONEXCLAMATION) ;
  380. SetFocus() ;
  381. return false ;
  382. } ;
  383. } ;
  384. // The new data is valid and should be saved so copy it into the project's
  385. // string table.
  386. pcst->Reset() ;
  387. for (u = 0 ; u < unumitems ; u++)
  388. pcst->Map((WORD) m_cuiaRCIDs[u], m_csaStrings[u]) ;
  389. // Mark the project's RC/MDW file data as being dirty and then return true
  390. // since the data was saved.
  391. pcpr->SetRCModifiedFlag(TRUE) ;
  392. pcpr->SetModifiedFlag(TRUE) ;
  393. return true ;
  394. }
  395. /******************************************************************************
  396. CStringEditorView::PreTranslateMessage
  397. Check for a return key being released while the Goto box or the Search box
  398. has the focus. Treat the key like the Goto button or the Search button
  399. being pressed when this is detected.
  400. ******************************************************************************/
  401. BOOL CStringEditorView::PreTranslateMessage(MSG* pMsg)
  402. {
  403. // When the return key was just released...
  404. if (pMsg->message == WM_KEYUP && pMsg->wParam == VK_RETURN) {
  405. // ...and the Goto box has the focus, perform a goto operation.
  406. if (GetFocus() == &m_ceGotoBox)
  407. OnSEGotoBtn() ;
  408. // ...or the Search box has the focus, perform a search operation.
  409. else if (GetFocus() == &m_ceSearchBox)
  410. OnSESearchBtn() ;
  411. } ;
  412. // Always process the key normally, too. I think this is ok in this case.
  413. return CFormView::PreTranslateMessage(pMsg) ;
  414. }
  415. LRESULT CStringEditorView::OnCommandHelp(WPARAM wParam, LPARAM lParam)
  416. {
  417. AfxGetApp()->WinHelp(HID_BASE_RESOURCE + IDR_STRINGEDITOR) ;
  418. return TRUE ;
  419. }
  420. /******************************************************************************
  421. CStringEditorView::OnFileSave()
  422. FILE SAVE message handler.
  423. just call SaveSTringTable(document, bprompt);
  424. //raid 27250
  425. ******************************************************************************/
  426. void CStringEditorView::OnFileSave()
  427. {
  428. CStringEditorDoc* pcsed = (CStringEditorDoc* )GetDocument();
  429. if( !pcsed ->GetOwner() ) { // R 3176
  430. CString cstmp;
  431. cstmp.LoadString(IDS_StrEditNoSave) ;
  432. AfxMessageBox(cstmp);
  433. return;
  434. }
  435. SaveStringTable(pcsed,0);
  436. }
  437. /////////////////////////////////////////////////////////////////////////////
  438. // CStringEditorDoc
  439. IMPLEMENT_DYNCREATE(CStringEditorDoc, CDocument)
  440. CStringEditorDoc::CStringEditorDoc()
  441. {
  442. // Raid 3176
  443. CDriverResources* pcdr = new CDriverResources();
  444. CStringArray csaTemp1, csaTemp2,csaTemp3,csaTemp4,csaTemp5;
  445. CStringTable cst, cstFonts, cstTemp2;
  446. CString csrcfile;
  447. m_pcstRCData = new CStringTable;
  448. // seek rc file
  449. CWinApp *cwa = AfxGetApp();
  450. csrcfile = cwa->GetProfileString(_T("StrEditDoc"),_T("StrEditDocS") );
  451. pcdr->LoadRCFile(csrcfile, csaTemp1, csaTemp2,csaTemp3,csaTemp4,csaTemp5,
  452. *m_pcstRCData, cstFonts, cstTemp2,Win2000);
  453. m_pcsnStrNode = NULL;
  454. m_pcprOwner = NULL;
  455. }
  456. /******************************************************************************
  457. CStringEditorDoc::CStringEditorDoc
  458. This is the only form of the constructor that should be called. It will save
  459. pointers to the project's string node, document class, and RC file string
  460. table. Blow if any of these pointers is NULL.
  461. ******************************************************************************/
  462. CStringEditorDoc::CStringEditorDoc(CStringsNode* pcsn, CProjectRecord* pcpr,
  463. CStringTable* pcst)
  464. {
  465. VERIFY(m_pcsnStrNode = pcsn) ;
  466. VERIFY(m_pcprOwner = pcpr) ;
  467. VERIFY(m_pcstRCData = pcst) ;
  468. //m_pcsnStrNode = NULL ;
  469. }
  470. BOOL CStringEditorDoc::OnNewDocument()
  471. {
  472. if (!CDocument::OnNewDocument())
  473. return FALSE;
  474. return TRUE;
  475. }
  476. CStringEditorDoc::~CStringEditorDoc()
  477. {
  478. }
  479. BEGIN_MESSAGE_MAP(CStringEditorDoc, CDocument)
  480. //{{AFX_MSG_MAP(CStringEditorDoc)
  481. // NOTE - the ClassWizard will add and remove mapping macros here.
  482. //}}AFX_MSG_MAP
  483. END_MESSAGE_MAP()
  484. /////////////////////////////////////////////////////////////////////////////
  485. // CStringEditorDoc diagnostics
  486. #ifdef _DEBUG
  487. void CStringEditorDoc::AssertValid() const
  488. {
  489. CDocument::AssertValid();
  490. }
  491. void CStringEditorDoc::Dump(CDumpContext& dc) const
  492. {
  493. CDocument::Dump(dc);
  494. }
  495. #endif //_DEBUG
  496. /////////////////////////////////////////////////////////////////////////////
  497. // CStringEditorDoc serialization
  498. void CStringEditorDoc::Serialize(CArchive& ar)
  499. {
  500. if (ar.IsStoring())
  501. {
  502. }
  503. else
  504. {
  505. }
  506. }
  507. /******************************************************************************
  508. CStringEditorDoc::CanCloseFrame
  509. Save the new string table if this is needed, the user says ok, and the new
  510. table's contents are valid. Don't let the frame close if the user wants
  511. the table saved but it couldn't be saved because the table is invalid.
  512. ******************************************************************************/
  513. BOOL CStringEditorDoc::CanCloseFrame(CFrameWnd* pFrame)
  514. {
  515. if (!SaveStringTable())
  516. return FALSE ;
  517. return CDocument::CanCloseFrame(pFrame);
  518. }
  519. /******************************************************************************
  520. CStringEditorDoc::SaveStringTable
  521. Save the new string table if this is needed, the user says ok, and the new
  522. table's contents are valid. Don't let the frame close if the user wants
  523. the table saved but it couldn't be saved because the table is invalid. This
  524. is done by returning false. True is returned in all other circumstances.
  525. ******************************************************************************/
  526. bool CStringEditorDoc::SaveStringTable()
  527. {
  528. // Begin looking for a view pointer. This should work but if it doesn't,
  529. // just say all is ok by returning true.
  530. POSITION pos = GetFirstViewPosition() ;
  531. if (pos == NULL)
  532. return true ;
  533. // Finish getting the view pointer and call the view to save the string
  534. // table when needed. Return whatever the view function returns.
  535. CStringEditorView* pcsev = (CStringEditorView*) GetNextView(pos) ;
  536. return (pcsev->SaveStringTable(this, true)) ;
  537. }
  538. /******************************************************************************
  539. CStringEditorDoc::SaveModified
  540. Make sure that the MFC's default saving mechanism never kicks in by always
  541. clearing the document's modified flag.
  542. ******************************************************************************/
  543. BOOL CStringEditorDoc::SaveModified()
  544. {
  545. SetModifiedFlag(FALSE) ;
  546. return CDocument::SaveModified();
  547. }
  548. BOOL CStringEditorDoc::OnOpenDocument(LPCTSTR lpszPathName)
  549. {
  550. if (!CDocument::OnOpenDocument(lpszPathName))
  551. return FALSE;
  552. return TRUE;
  553. }