MCPcopy Create free account
hub / github.com/ajkhoury/ReClassEx / OnFileOpen

Method OnFileOpen

ReClass/ReClassEx.cpp:1024–1280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1022}
1023
1024void CReClassExApp::OnFileOpen( )
1025{
1026 TCHAR Filters[] = _T( "ReClass (*.reclass)|*.reclass|All Files (*.*)|*.*||" );
1027
1028 CFileDialog fileDlg( TRUE, _T( "reclass" ), _T( "" ), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, Filters );
1029 if (fileDlg.DoModal( ) != IDOK)
1030 return;
1031
1032 CString pathName = fileDlg.GetPathName( );
1033
1034 CMDIFrameWnd* pFrame = STATIC_DOWNCAST( CMDIFrameWnd, m_pMainWnd );
1035 CMDIChildWnd* pChildWnd = pFrame->MDIGetActive( );
1036
1037 while ( pChildWnd )
1038 {
1039 pChildWnd->SendMessage( WM_CLOSE, 0, 0 );
1040 pChildWnd = pFrame->MDIGetActive( );
1041 }
1042
1043 m_Classes.clear( );
1044
1045 m_strHeader = _T( "" );
1046 m_strFooter = _T( "" );
1047 m_strNotes = _T( "" );
1048 m_strCurrentFilePath = _T( "" );
1049
1050 tinyxml2::XMLDocument XmlDoc;
1051
1052 #ifdef UNICODE
1053 #define _CA2W(psz) CA2W(psz)
1054 #else
1055 #define _CA2W(psz) (psz)
1056 #endif
1057
1058 FILE* fp = NULL;
1059 #ifdef UNICODE
1060 _wfopen_s( &fp, pathName, L"rb" );
1061 #else
1062 fopen_s( &fp, pathName, "rb" );
1063 #endif
1064 XMLError ret = XmlDoc.LoadFile( fp );
1065 fclose( fp );
1066
1067 if (ret != XML_SUCCESS)
1068 return;
1069
1070 m_strCurrentFilePath = pathName;
1071
1072 XMLHandle hDoc( &XmlDoc );
1073 XMLHandle hRoot( 0 );
1074 XMLElement* XmlCurrentElement;
1075 typedef std::pair<CString, CNodeBase*> Link;
1076 std::vector<Link> links;
1077
1078 XmlCurrentElement = hDoc.FirstChildElement( ).ToElement( );
1079 if (!XmlCurrentElement)
1080 return;
1081

Callers

nothing calls this directly

Calls 15

XMLHandleFunction · 0.85
clearMethod · 0.80
FirstChildElementMethod · 0.80
ValueMethod · 0.80
AttributeMethod · 0.80
SetCommentMethod · 0.80
SetOffsetMethod · 0.80
SetOffsetStringMethod · 0.80
SetCodeStringMethod · 0.80
SetHiddenMethod · 0.80
SetParentMethod · 0.80
AddNodeMethod · 0.80

Tested by

no test coverage detected