Beispiel #1
0
BOOL CSyntaxDlg::ProcessTitles( CArchive & rar )
{
	BOOL bSuccess = FALSE;
	BOOL bDone = FALSE;
	while( ! bDone ) 
	{
		char sz[ 200 ];
		rar.ReadString( sz, 199 );	
		CString str( sz );
		str.TrimRight();
		str.TrimLeft();
		bDone = (str == "$end" ); 
		if( !bDone && str.GetLength() )
		{
			switch( Parameterize( str, 5 ) )
			{
			case IDCANCEL:
				return FALSE;
			case IDYES:
				bSuccess = TRUE;
				m_SF.m_Title.RecordSegment( str );
				break;
			}
		}
	}
	if( bSuccess)
		MessageBox( "Das Taggen der Titel-Syntagmen ist gelungen", "Erfolg" );	
	else
		MessageBox( "Keine Titel-Syntagmen wurden gefunden", "Fehler" );	
	return TRUE;
}
Beispiel #2
0
HMENU CFavMenu::DoLoadFavorites(CArchive& ar, CStringArray& data, UINT& id, int& menu_height)
{
	max_height = GetSystemMetrics(SM_CYSCREEN) - 64;
	item_height = GetSystemMetrics(SM_CYMENU);
	bool is_toplevel = (data.GetSize() == 0);

	HMENU menu = CreatePopupMenu();
	CString str;
	for (; ar.ReadString(str); ++id)
	{
		if (str.IsEmpty())	// end of dir
		{
			data.Add(sep);	// add separator
			::AppendMenu(menu, MF_SEPARATOR, id, NULL);
			++id;

			if (! is_toplevel)
			{
				// Add to Favorites
				data.Add(add_to_fav);
				AppendMenu(menu, MF_OWNERDRAW, id, LPCTSTR(id), menu_height);
				++id;

				// Open All
				data.Add(open_all);
				AppendMenu(menu, MF_OWNERDRAW, id, LPCTSTR(id), menu_height);
				++id;

				// Organize Favorites
				data.Add(org_fav);
				AppendMenu(menu, MF_OWNERDRAW, id, LPCTSTR(id), menu_height);
				++id;

				// end of sub menu
				data.Add(_T(""));		// afxEmptyString is no longer in mfc7 and above
			}
			break;
		}
		data.Add(str);
		if (str[0] == 'd') // dir
		{
			UINT submenu_id = id;	// reserve id for the menu item
			++id;
			int submenu_height = 0;
			HMENU sub = DoLoadFavorites(ar, data, id, submenu_height);	// create sub menu
			AppendMenu(menu, MF_OWNERDRAW | MF_POPUP,
					   UINT(sub), LPCTSTR(submenu_id), menu_height);
		}
		else
			AppendMenu(menu, MF_OWNERDRAW, id, LPCTSTR(id), menu_height);
	}
	favmenus.Add(menu);
	return menu;
}
// Returns the next function (including header),
// i.e. everything up to the second-next-function or end of file.
void CFormulaFileSplitter::ScanForNextFunctionOrList(CArchive &formula_file) {
  // Function-header is the first line, 
  // (usually the last line of last scan)
  // rest is content
  _function_header = _next_line;
  _function_text = ""; 
  while (true) {
    try {
      if (!formula_file.ReadString(_next_line)) {
	      break;
      }
    }
    catch (CException *e) {
	    // break;
    }
    ++_total_line_processed;
    // Avoid problems with "empty" lines before first function header
    // that contain spaces.
    _next_line.TrimRight();
#ifdef DEBUG_FORMULA_FILESPLITTER
    //printf("[CFormulaFileSplitter] next line: %s\n", _next_line);
#endif
    if (IsFunctionHeader(_next_line)
        && _first_function_processed) {
      // Next function found
      // Only continue, if we found the first one
      //
      // In case of break: keep that function-header for the next query
      _starting_line_of_current_function = _total_line_processed;
      break;
	  }
    if (_function_header.IsEmpty() || (_function_header.Find('#') < 0)) {
      // Escpecially meant to catch OpenGeeks newlines 
      // (which are not empty) at the beginning of the file.
      // Other cases can't happen, as we search for ## 
      // when looking for the next function-header. 
      _function_header = _next_line;
    } else {
      _first_function_processed = true;
      // Add non-function-header (content) to the functions body
      _function_text += _next_line;
      _function_text += "\n";
    }
  } 
#ifdef DEBUG_FORMULA_FILESPLITTER
  //printf("[CFormulaFileSplitter] next function: %s\n", _formula_content);
  OH_MessageBox_Interactive(_function_text, "Function", 0);
#endif
}
void SerializeAlias( CArchive & ar, CAliasArray & aAliases )
{
	char szFileMagic[]		=	"NETTSALIAS";
	DWORD	dwFileVersion	=	0x20040825;

	if( ar.IsStoring() )
	{
		ar.WriteString( szFileMagic );
		ar << dwFileVersion;

		ar << (int)aAliases.GetSize();
		for( int i=0; i<aAliases.GetSize(); i++ )
		{
			CAlias & a = aAliases.ElementAt(i);
			ar << a.m_strName;
			ar << a.m_strValue;
		}
	}
	else
	{
		TCHAR buffer[64];
		memset( buffer, 0, sizeof(buffer) );
		ar.ReadString( buffer, strlen(szFileMagic) );
		if( 0 != strncmp( szFileMagic, buffer, strlen(szFileMagic) ) )
			return;

		DWORD	dwVer;				
		ar >> dwVer;
		if( dwVer > dwFileVersion )
			return;

		int size;
		ar >> size;
		if( size < 0 || size > 10000 )	// too big
			return;

		aAliases.SetSize( 0, size+2 );
		for( int i=0; i<size; i++ )
		{
			CAlias a;
			ar >> a.m_strName;
			ar >> a.m_strValue;
			aAliases.Add( a );
		}
	}
}
Beispiel #5
0
BOOL CSyntaxDlg::ProcessText( CArchive & rar )
{
	CString strSegment;
	BOOL bSuccess = FALSE;
	BOOL bDone = FALSE;
	while( ! bDone ) 
	{
		char sz[ 200 ];
		rar.ReadString( sz, 199 );	
		CString str( sz );		
		bDone = (str == "$end" ); 
		if( !bDone && str.GetLength() )
		{
			int nAt = str.FindOneOf( ".!?" );
			if( nAt >= 0 )
			{
				strSegment += str.Left( nAt + 1 );	
				strSegment.TrimLeft();
				switch( Parameterize( strSegment, 20 ) )
				{
				case IDCANCEL:
					return FALSE;
				case IDYES:
					bSuccess = TRUE;
					m_SF.m_Text.RecordSegment( strSegment );
					break;
				}
				if( str.GetLength() > nAt + 2 )
					strSegment = str.Mid( nAt + 2 );
				else
					strSegment = "";
			}
			else
				strSegment += str + ' ';
		}
	}	
	
	if( bSuccess)
		MessageBox( "Das Taggen der Syntagmen ist gelungen", "Erfolg" );	
	else
		MessageBox( "Keine Syntagmen wurden gefunden", "Fehler" );	
	return TRUE;
}
Beispiel #6
0
void CBugTracksDoc::Serialize(CArchive& ar)
{
	if (!ar.IsStoring())
	{
		SBugData Data;
		CString strOneLine;

		while(ar.ReadString(strOneLine))
		{
			sscanf(strOneLine,"%g %g\n",&Data.x,&Data.y);
			m_BugDataArray.Add(Data);
		}
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}
Beispiel #7
0
LineCollection::LineCollection(CArchive &ar,int skip)
{
	if (ar.IsStoring())
	{
		return;
	}
	else
	{
		m_Skip=skip;
		CString s;
		int i,j;
		vect.SetSize(0);
		for(i=0,j=0;ar.ReadString(s);i++)
		{
			if(m_Skip && s=="") continue;
			vect.SetSize(j+1);
			vect[j]=s;
			j++;
		}
	}
}
Beispiel #8
0
void CPMPTxtDoc::Serialize(CArchive& ar)
{
	CString str;
	if (ar.IsStoring())
	{
		// TODO: add storing code here
		POSITION pos = this->GetFirstViewPosition();
		CPMPTxtView * p_cPMPTxtView = (CPMPTxtView *)this->GetNextView(pos);
		p_cPMPTxtView->m_ctrlRichEdit->GetWindowTextA(str);
		ar.Write(str,str.GetLength());
	}
	else
	{
		// TODO: add loading code here
		m_PathName = ar.m_strFileName;
		m_realfilename = ar.GetFile()->GetFileName();
		long size = 0;
		long filesize =  ar.GetFile()->GetLength();
		// 允许打开一个不超过20M的文本文件
		
		if(ar.GetFile()->GetLength()<=1024*1024*20){
			char * temp = (char * )malloc(sizeof(char)*filesize + 1);
			while(ar.ReadString(m_text)){
				m_text.Append("\n");
				strcpy(temp+size,m_text.GetBuffer(0));
				m_text.ReleaseBuffer();
				size+=m_text.GetLength();
			}
			//m_textContent.Add(temp);
			m_text = temp;
			free(temp);
		}else{
			::MessageBox(NULL,_T("Too large to open"),_T("Message"),MB_OK);
		}
	}
}
Beispiel #9
0
void NNLayer::Serialize(CArchive &ar)
{
	VectorNeurons::iterator nit;
	VectorWeights::iterator wit;
	VectorConnections::iterator cit;
	
	int ii, jj;
	
	if (ar.IsStoring())
	{
		// TODO: add storing code here
		
		ar.WriteString( label.c_str() );
		ar.WriteString( _T("\r\n") );  // ar.ReadString will look for \r\n when loading from the archive
		ar << m_Neurons.size();
		ar << m_Weights.size();
		
		
		
		for ( nit=m_Neurons.begin(); nit<m_Neurons.end(); nit++ )
		{
			NNNeuron& n = *(*nit);
			ar.WriteString( n.label.c_str() );
			ar.WriteString( _T("\r\n") );
			ar << n.m_Connections.size();
			
			for ( cit=n.m_Connections.begin(); cit<n.m_Connections.end(); cit++ )
			{
				ar << (*cit).NeuronIndex;
				ar << (*cit).WeightIndex;
			}
		}
		
		for ( wit=m_Weights.begin(); wit<m_Weights.end(); wit++ )
		{
			ar.WriteString( (*wit)->label.c_str() );
			ar.WriteString( _T("\r\n") );
			ar << (*wit)->value;
		}
		
		
	}
	else
	{
		// TODO: add loading code here
		
		CString str;
		ar.ReadString( str );
		
		label = str;
		
		int iNumNeurons, iNumWeights, iNumConnections;
		double value;
		
		NNNeuron* pNeuron;
		NNWeight* pWeight;
		NNConnection conn;
		
		ar >> iNumNeurons;
		ar >> iNumWeights;
		
		for ( ii=0; ii<iNumNeurons; ++ii )
		{
			ar.ReadString( str );
			pNeuron = new NNNeuron( (LPCTSTR)str );
			m_Neurons.push_back( pNeuron );
			
			ar >> iNumConnections;
			
			for ( jj=0; jj<iNumConnections; ++jj )
			{
				ar >> conn.NeuronIndex;
				ar >> conn.WeightIndex;
				
				pNeuron->AddConnection( conn );
			}
		}
		
		for ( jj=0; jj<iNumWeights; ++jj )
		{
			ar.ReadString( str );
			ar >> value;
			
			pWeight = new NNWeight( (LPCTSTR)str, value );
			m_Weights.push_back( pWeight );
		}
		
	}
	
}
Beispiel #10
0
// Reading a part of a formula, which may be spread
// between two files in case of an old style whf / whx formula.
void CFormula::ReadFormulaFile(CArchive& ar, bool ignoreFirstLine)
{
	CString		strOneLine = ""; 
	int			content = 0;
	char		funcname[256] = {0};
	int			start = 0, end = 0;
		
	SFunction	func;	
	SHandList	list;		

	CSLock lock(m_critsec);

	// Ignore first line (date/time)
	if (ignoreFirstLine)
		ar.ReadString(strOneLine);

	// read data in, one line at a time
	strOneLine = "";
	content = FTnone;
	func.func = "";
	while(ar.ReadString(strOneLine)) 
	{ 

		// If this line marks the beginning of a function, then save the previously
		// collected function, and start a new one
		if (strOneLine.Mid(0,2)=="##") 
		{

			// Save the previously collected function
			if (content == FTlist) 
			{
				// Strip the LFCR off the last line (we need to add CRLF for all but the last line)
				list.list_text.TrimRight("\r\n");
				_formula.mHandList.Add(list); 
			}
			else if (content == FTfunc) 
			{
				func.func_text.TrimRight("\r\n");
				_formula.mFunction.Add(func);
			}


			// Get the function name				
			start = strOneLine.Find("##",0);

			// No need to check the result of start,
			// as this code gets executed only,
			// if a line starts with "##"	
			end = strOneLine.Find("##", start+2);

			// Checking for malformed function header
			// without trailing "##"
			if (end == -1) 
			{
				// Trying to continue gracefully.				
				// Skipping is not possible,
				// as this crashes the formula editor.											
				strcpy_s(funcname, 256, strOneLine.GetString()+start+2);
				funcname[strOneLine.GetLength()]='\0';
				CString the_ErrorMessage = "Malformed function header!\nMissing trailing '##'.\n" 
					+ strOneLine + "\n"
					+ "Trying to continue...";
				MessageBox(0, the_ErrorMessage, "Syntax Error", 
					MB_OK | MB_ICONEXCLAMATION);
			}

			else 
			{
				strcpy_s(funcname, 256, strOneLine.GetString()+start+2);
				funcname[end-2]='\0';
			}

			if (strcmp(funcname, "bankroll") == 0) { _formula.dBankroll = 0.0; content = FTbankroll; }
			
			else if (strcmp(funcname, "defcon") == 0) { _formula.dDefcon = 0.0; content = FTdefcon; }
			
			else if (strcmp(funcname, "rake") == 0) { _formula.dRake = 0.0; content = FTrake; }
			
			else if (strcmp(funcname, "nit") == 0) { _formula.dNit = 0.0; content = FTnit; }
			
			else if (memcmp(funcname, "list", 4) == 0) 
			{ 
				content = FTlist;
				list.list = funcname;
				list.list_text = "";
			}

			else 
			{
				content = FTfunc;
				func.func = funcname;
				func.func_text = "";
				func.dirty = true;
			}
		}

		// Get the function content
		else 
		{
			switch (content) 
			{
				 case FTbankroll:
					 if (strOneLine.GetLength())
						 _formula.dBankroll = atof(strOneLine.GetString());
					 break;
				 case FTdefcon:
					 if (strOneLine.GetLength())
						 _formula.dDefcon = atof(strOneLine.GetString());
					 break;
				 case FTrake:
					 if (strOneLine.GetLength())
						 _formula.dRake = atof(strOneLine.GetString());
					 break;
				 case FTnit:
					 if (strOneLine.GetLength())
						 _formula.dNit = atof(strOneLine.GetString());
					 break;
				 case FTlist:
					 list.list_text.Append(strOneLine); list.list_text.Append("\r\n");
					 break;
				 case FTfunc:
					 func.func_text.Append(strOneLine); func.func_text.Append("\r\n");
					 break;
			}
		}	
	}  

	// Add the last list/function to the CArray on EOF, if it was a list being processed
	if (content == FTlist) 
	{
		list.list_text.TrimRight("\r\n");
		_formula.mHandList.Add(list); 
	}
	else if (content == FTfunc) 
	{
		func.func_text.TrimRight("\r\n");
		_formula.mFunction.Add(func);
	}
}
Beispiel #11
0
bool CChildView::LoadSettings(CArchive &ar)
{
	int k;
	try{
		ar >> k;
		if (k<0 || k>RGB(255,255,255)) {
			CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
			throw pfe;
		}
		m_crBackColor = k;
		ar >> k;
		if (k<0 || k>RGB(255,255,255)) {
			CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
			throw pfe;
		}
		m_WndTextColor = k;
		ar >> k;
		if (k<0 || k>RGB(255,255,255)) {
			CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
			throw pfe;
		}
		m_crGraphBkClr = k;

		ar >> k;
		if (k<0 || k>RGB(255,255,255)) {
			CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
			throw pfe;
		}
		m_crBorderClr = k;
		ar >> k;
		if (k<0 || k>100) {
			CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
			throw pfe;
		}
		m_iBorderStyle = k;
		ar >> k;
		if (k<0 || k>100) {
			CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
			throw pfe;
		}
		m_iBorderWidth = k;
		ar >> k;
		if (k!=1 && k!=0) {
			CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
			throw pfe;
		}
		if(k) m_bBorder = true;
		else m_bBorder = false;

		ar >> k;
		if (k!=1 && k!=0) {
			CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
			throw pfe;
		}
		if(k) SetBlackAndWhite(true);
		else SetBlackAndWhite(false);

		ar >> m_WndLogFont.lfCharSet;
		if(m_WndLogFont.lfCharSet == 0) m_WndLogFont.lfCharSet = DEFAULT_CHARSET;
		ar >> m_WndLogFont.lfClipPrecision;
		ar >> m_WndLogFont.lfEscapement;
		ar >> m_WndLogFont.lfHeight;
		ar >> m_WndLogFont.lfItalic;
		ar >> m_WndLogFont.lfOrientation;
		ar >> m_WndLogFont.lfOutPrecision;
		ar >> m_WndLogFont.lfPitchAndFamily;
		ar >> m_WndLogFont.lfQuality;
		ar >> m_WndLogFont.lfStrikeOut;
		ar >> m_WndLogFont.lfUnderline;
		ar >> m_WndLogFont.lfWeight;
		ar >> m_WndLogFont.lfWidth;

		ar >> k;
		if(k<0 || k>32) {
			CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
			throw pfe;
		}
		ar.ReadString(m_WndLogFont.lfFaceName, k);

		m_DefaultGraph.Serialize(ar);


//-------------	

	}
	catch (CArchiveException *ex){
//		AfxMessageBox("Failed to load settings",MB_OK);
		ex->Delete();
		m_pXDirect->SetDisplayDefault();
		return false;
	}
	catch (CException *ex){
//		AfxMessageBox("Failed to load settings",MB_OK);
		ex->Delete();
		return false;
	}
	return true;
}
Beispiel #12
0
void CWedDoc::Serialize(CArchive& ar, const char *docname)

{
    CString 	num, str;
    CString 	filename = docname;

    PathToFname(filename);

    if (ar.IsStoring())
    	{
		// Writing
		CWaitCursor cursor;

        POSITION pos;
		pos = strlist.GetHeadPosition();
		origlines = 0;
        while(TRUE)
        	{
        	CString line;
			if(!(origlines % 100))
				{
				num.Format("Writing %s line %d", filename, origlines);
				message(num);
				}
			origlines++;
            if (!pos)
            	break;

            line = strlist.GetNext(pos);

            // Obey tab save option
			if(Tab2Space ||	spaceify)
				ExpandTabs(line);

            // Dispose space from EOL
			line.TrimRight();

            // Write out to file
            ar.WriteString(line);

            // Do end of line according to settings
			if(unix)
				ar.WriteString("\n");
			else
				ar.WriteString("\r\n");
        	}
		num.Format("Wrote %s", filename);  message(num);

		// If user decides to save, save undo/redo info as well
		SaveUndo(); SaveRedo();
    	}
    else
    	{
		// Reading
		CWaitCursor cursor;
		char buff[DETECTSIZE];

        strlist.RemoveAll();

		// Determine file type
		CFile* fp = ar.GetFile();
		int rlen = fp->Read(buff, DETECTSIZE);

		// File without a newline ---> default to DOS
		if(!strstr(buff, "\n"))
			unix = FALSE;
		else if (strstr(buff, "\r\n"))
			unix = FALSE;
		else
			unix = TRUE;

		// Take a wild guess for tabs
		if(!strstr(buff, "\t") && rlen > DETECTSIZE/2 )
			{
			spaceify = TRUE;
			}

		// Start over on file
		fp->Seek(0,CFile::begin);
		origlines = 0;

		// Load file
        while(TRUE)
        	{
            str = "";
			if(!(origlines % 100))
				{
				CString num;
				num.Format("Reading %s line %d", filename, origlines);
				message(num);
				}
			if(YieldToWinEx())
				{
				readonly = TRUE;
				AfxMessageBox("Aborted load, partial buffer is readonly.");
				break;
				}
			TRY
            	{
            	if(!ar.ReadString(str))
                	break;
            	}
	        	CATCH_ALL(ee); END_CATCH_ALL
			origlines++;
            TRY
            	{
            	strlist.AddTail(str);
            	}
            	CATCH(CMemoryException, ee)
            		{
                	//P2N("Memory exception\r\n");
					break;
            		}
            	END_CATCH
        	}

		// So unix can see an unlocked file
		// Let others see it
		// ReleaseFile(fp, 1);

        // Patch things up
        if( strlist.IsEmpty())
        	{
            //P2N("Empty file\r\n");
            strlist.AddTail("");
        	}
    }
}
Beispiel #13
0
// Reading a part of a formula, which may be spread
// between two files in case of an old style whf / whx formula.
void CFormula::ReadFormulaFile(CArchive& ar, bool ignoreFirstLine)
{
	CString		strOneLine = ""; 
	int			content = 0;
	char		funcname[k_max_size_of_function_name] = {0};
	int			start = 0, end = 0;
		
	SFunction	func;	
	SHandList	list;		

	CSLock lock(m_critsec);

	// Ignore first line (date/time)
	if (ignoreFirstLine)
		ar.ReadString(strOneLine);

	// read data in, one line at a time
	strOneLine = "";
	content = FTnone;
	func.func = "";
	while(ar.ReadString(strOneLine)) 
	{ 
		// If this line marks the beginning of a function, then save the previously
		// collected function, and start a new one
		if (strOneLine.Mid(0,2)=="##") 
		{
			// Save the previously collected function
			if (content == FTlist) 
			{
				// Strip the LFCR off the last line (we need to add CRLF for all but the last line)
				list.list_text.TrimRight("\r\n");
				if (DoesFormulaAlreadyExist(list.list))
				{
					CString ErrorMessage = "Handlist does already exist: " + list.list;
					OH_MessageBox_Error_Warning(ErrorMessage, "Error");
				}
				else
				{
					_formula.mHandList.Add(list); 
				}
			}
			else if (content == FTfunc) 
			{
				func.func_text.TrimRight("\r\n");
				if (DoesFormulaAlreadyExist(func.func))
				{
					CString ErrorMessage = "Function does already exist: " + func.func;
					OH_MessageBox_Error_Warning(ErrorMessage, "Error");
				}
				else
				{
					_formula.mFunction.Add(func);
				}
			}
			// Get the function name				
			start = strOneLine.Find("##",0);

			// No need to check the result of start,
			// as this code gets executed only,
			// if a line starts with "##"	
			end = strOneLine.Find("##", start+2);

			// Checking for malformed function header
			// without trailing "##"
			if (end == k_undefined) 
			{
				// Trying to continue gracefully.				
				// Skipping is not possible,
				// as this crashes the formula editor.											
				int number_of_chars_to_copy = (strOneLine.GetLength() < k_max_size_of_function_name) ?
					strOneLine.GetLength() : k_max_size_of_function_name;
				strncpy_s(funcname, 
					k_max_size_of_function_name, 
					strOneLine.GetString()+start+2,
					number_of_chars_to_copy);
				funcname[number_of_chars_to_copy]='\0';
				
				CString the_ErrorMessage = "Malformed function header!\nMissing trailing '##'.\n" 
					+ strOneLine + "\n"
					+ "Trying to continue...";
				OH_MessageBox_Error_Warning(the_ErrorMessage, "Syntax Error");
			}

			else 
			{
				int size_of_function_name = end - start + 1;    
				assert(size_of_function_name < k_max_size_of_function_name);
				// strncpy_s: http://msdn.microsoft.com/de-de/library/5dae5d43(v=vs.80).aspx
				strncpy_s(funcname,                              // Destination
					k_max_size_of_function_name * sizeof(char),  // Size of destination
					strOneLine.GetString() + start + 2,          // Start of source (without leading "##")
					size_of_function_name);						 // Elements to copy	
				funcname[end-2] = '\0';							 // Remove trailing "##"	
			}

			if (memcmp(funcname, "list", 4) == 0) 
			{ 
				content = FTlist;
				list.list = funcname;
				list.list_text = "";
			}

			else 
			{
				content = FTfunc;
				func.func = funcname;
				func.func_text = "";
				func.dirty = true;
			}
		}

		// Get the function content
		else 
		{
			switch (content) 
			{
				 case FTlist:
					 list.list_text.Append(strOneLine); list.list_text.Append("\r\n");
					 break;
				 case FTfunc:
					 func.func_text.Append(strOneLine); func.func_text.Append("\r\n");
					 break;
			}
		}	
	}  

	// Add the last list/function to the CArray on EOF, if it was a list being processed
	if (content == FTlist) 
	{
		list.list_text.TrimRight("\r\n");
		if (DoesFormulaAlreadyExist(list.list))
		{
			CString ErrorMessage = "Handlist does already exist: " + list.list;
			OH_MessageBox_Error_Warning(ErrorMessage, "Error");
		}
		else
		{
			_formula.mHandList.Add(list); 
		}
	}
	else if (content == FTfunc) 
	{
		func.func_text.TrimRight("\r\n");
		if (DoesFormulaAlreadyExist(func.func))
		{
			CString ErrorMessage = "Function does already exist: " + func.func;
			OH_MessageBox_Error_Warning(ErrorMessage, "Error");
		}
		else
		{
			_formula.mFunction.Add(func);
		}
	}
}
Beispiel #14
0
void CProjectDoc::ReadArchive(CArchive &ar)
{
   CProjectView* pview = GetProjectView();
   CString s;
   unsigned short first;
   BOOL is_unicode;
   int ibufsize = 512;
   pview->UpdateData(FALSE);

   // Read first two bytes to check for Unicode,
   // now we can't undo with archive, so this presents
   // a problem when reading the first line and there
   // wasn't a unicode flag.  The answer is in ProcessLine
   // which accepts 'zirel' as well as 'amzirel' for the
   // first line attribute.
   ar.Read(&first, 2);
   if (first == 0xfeff)
      is_unicode = TRUE;
   else
      is_unicode = FALSE;

#ifdef _UNICODE
   // if unicode, just read it straight
   if (is_unicode)
   {
      while (ar.ReadString(s))
         ProcessLine(s, pview);
   }
   // if not unicode, read into an ascii buffer
   // and call mbstowcs().
   else
   {
      char* buf = new char[ibufsize+1];
      _TCHAR* sbuf = new _TCHAR[ibufsize+1];
      while (ReadLineA(buf, ar, ibufsize))
      {
         mbstowcs(sbuf, buf, ibufsize);
         s = sbuf;
         ProcessLine(s, pview);
      }
      delete[] buf;
      delete[] sbuf;
   }
#else
   // if not unicode, read it straight
   if (!is_unicode)
   {
      while (ar.ReadString(s))
         ProcessLine(s, pview);
   }
   // if unicode, get ReadLineW to read and
   // translate.
   else
   {
      wchar_t* buf = new wchar_t[ibufsize+1];
      _TCHAR* sbuf = new _TCHAR[ibufsize+1];
      while (ReadLineW(buf, ar, ibufsize))
      {
         wcstombs(sbuf, buf, ibufsize);
         s = buf;
         ProcessLine(s, pview);
      }
      delete[] buf;
      delete[] sbuf;
   }
#endif

   if (! m_amzirel == CString(_T("4")))
      AfxMessageBox(_T("Not a valid Amzi! project for this environment,\n please recreate."));

   return;
}
void CVertexCollection::Serialize(CArchive& Archive, CTriangulation *Triangulation)
{
 double x = 0;
 double y = 0;
 double z = 0;
 CVertex *Vertex = NULL;
 CString sLine;

 if (Archive.IsStoring())
 {
  for (long VertexIndex = 4; VertexIndex < m_Collection.GetCount(); VertexIndex++)
  {
   Vertex = (CVertex *)m_Collection[VertexIndex];

   sLine.Format(_T(" %.3lf %.3lf %.3lf"),Vertex->m_Coordinate[0],Vertex->m_Coordinate[1], Vertex->m_Coordinate[2]);
   Archive.WriteString(sLine);
   Archive.WriteString(_T("\n"));
   m_VertexNumber++;
  }
 }
 else
 {
//Let's check file extension.

	 CFile *File = Archive.GetFile();
	 CString FilePath = File->GetFilePath();
	 char Ext[256];
	 _splitpath(FilePath, NULL, NULL, NULL, Ext);

//First four verteces are verteces of bounding box/
  for (int VertexIndex = 0; VertexIndex < 4; VertexIndex++)
  {
   Vertex = new CVertex(0, 0, 0, CVertex::BoundingBox);
   Vertex->m_Index = m_Collection.Add(Vertex);
  }

  do
  {
	  if (!sLine.IsEmpty())
   {
   CString XString;
   CString YString;
   CString ZString;

   int Start = 0;

   XString = sLine.Tokenize(_T(" "), Start);
   YString = sLine.Tokenize(_T(" "), Start);
   ZString = sLine.Tokenize(_T(" "), Start);

   sscanf_s(XString,_T("%lf.2"), &x);
   sscanf_s(YString,_T("%lf.2"), &y);
   sscanf_s(ZString,_T("%lf.2"), &z);

   Vertex = new CVertex(x, y, z, CVertex::Standalone);

   Vertex->m_Index = m_Collection.Add(Vertex);

   if (m_Collection.GetCount() == 5)
   {
    m_Min.m_Coordinate[0] = x;
    m_Min.m_Coordinate[1] = y;
    m_Min.m_Coordinate[2] = z;
    m_Max.m_Coordinate[0] = x;
    m_Max.m_Coordinate[1] = y;
    m_Max.m_Coordinate[2] = z;
   }
   else
   {
//todo = min
   if (m_Min.m_Coordinate[0] > x)
     m_Min.m_Coordinate[0] = x;
   if (m_Min.m_Coordinate[1] > y)
     m_Min.m_Coordinate[1] = y;
   if (m_Min.m_Coordinate[2] > z)
     m_Min.m_Coordinate[2] = z;

   if (m_Max.m_Coordinate[0] < x)
     m_Max.m_Coordinate[0] = x;
   if (m_Max.m_Coordinate[1] < y)
     m_Max.m_Coordinate[1] = y;
   if (m_Max.m_Coordinate[2] < z)
     m_Max.m_Coordinate[2] = z;
   }
   }
	  if (m_Collection.GetSize() > 100)
		  break;
  }
  while(Archive.ReadString(sLine));
//////////////////////////////////////////

 m_DeltaX = 0.25 * fabs((m_Max.m_Coordinate[0] - m_Min.m_Coordinate[0]));
 m_DeltaY = 0.25 * fabs((m_Max.m_Coordinate[1] - m_Min.m_Coordinate[1]));
 
 m_Min.m_Coordinate[2] = (double)((long)m_Min.m_Coordinate[2]);

//////////////////////////////////////////////
  Vertex = (CVertex *)m_Collection[0];

  Vertex->m_Coordinate[0] = m_Min.m_Coordinate[0] - 2 * m_DeltaX;
  Vertex->m_Coordinate[1] = m_Min.m_Coordinate[1] - 2 * m_DeltaY;
  Vertex->m_Coordinate[2] = m_Min.m_Coordinate[2];

  Vertex = (CVertex *)m_Collection[1];

  Vertex->m_Coordinate[0] = m_Max.m_Coordinate[0] + 2 * m_DeltaX;
  Vertex->m_Coordinate[1] = m_Min.m_Coordinate[1] - 2 * m_DeltaY;
  Vertex->m_Coordinate[2] = m_Min.m_Coordinate[2];

  Vertex = (CVertex *)m_Collection[2];

  Vertex->m_Coordinate[0] = m_Max.m_Coordinate[0] + 2 * m_DeltaX;
  Vertex->m_Coordinate[1] = m_Max.m_Coordinate[1] + 2 * m_DeltaY;
  Vertex->m_Coordinate[2] = m_Min.m_Coordinate[2];

  Vertex = (CVertex *)m_Collection[3];

  Vertex->m_Coordinate[0] = m_Min.m_Coordinate[0] - 2 * m_DeltaX;
  Vertex->m_Coordinate[1] = m_Max.m_Coordinate[1] + 2 * m_DeltaY;
  Vertex->m_Coordinate[2] = m_Min.m_Coordinate[2];
 }
}
Beispiel #16
0
void CXFSFrame::Serialize(CArchive &ar)
{
	CString str = "";
	if(ar.IsStoring())
	{
		ar.Write("XFSFRAME", strlen("XFSFRAME"));
		ar.Write(" \"", 2);
		ar.Write(m_strFrameName,m_strFrameName.GetLength());
		ar.Write("\"\r\n", 3);
		ar.Write(" BEGIN\r\n", strlen(" BEGIN\r\n"));
	// POSITION
		if(m_dwPage == 0)
		{
			str.Format("  POSITION %d %d",position.m_wX,position.m_wY);
		}
		else
		{
			str.Format("  POSITION %d, (%d, %d)",position.m_wX,position.m_wY, m_dwPage);
		}
		ar.Write(str,str.GetLength());
		ar.Write("\r\n", 2);

		if(m_strFrames != "")
		{
			str.Format("  FRAMES %s",m_strFrames);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strHeader != "")
		{
			str.Format("  HEADER %s",m_strHeader);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strFooter != "")
		{
			str.Format("  FOOTER %s",m_strFooter);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strSide != "")
		{
			str.Format("  SIDE %s",m_strSide);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		
		str.Format("  SIZE %d,%d",size.m_wWidth,size.m_wHeight);
		ar.Write(str,str.GetLength());
		ar.Write("\r\n", 2);

		if((repeatonx.m_wRepeatCount != 0) || (repeatonx.m_wXoffset != 0))
		{
			str.Format(" REPEATONX %d,%d",repeatonx.m_wRepeatCount,repeatonx.m_wXoffset);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}

		if((repeatony.m_wRepeatCount != 0) || (repeatony.m_wYoffset != 0))
		{
			str.Format(" REPEATONX %d,%d",repeatony.m_wRepeatCount,repeatony.m_wYoffset);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		
		if(m_strType != "")
		{
			str.Format("  TYPE %s",m_strType);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strClass != "")
		{
			str.Format("  CLASS %s",m_strClass);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strOverflow != "")
		{
			str.Format("  OVERFLOW %s",m_strOverflow);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strStyle != "")
		{
			str.Format("  STYLE %s",m_strStyle);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strColor != "")
		{
			str.Format("  COLOR %s",m_strColor);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(rgbfillcolor.m_bRed || rgbfillcolor.m_bGreen || rgbfillcolor.m_bBlue)
		{
			str.Format(" RGBFILLCOLOR %d,%d,%d",rgbfillcolor.m_bRed,rgbfillcolor.m_bGreen,rgbfillcolor.m_bBlue);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strFillStyle != "")
		{
			str.Format("  FILLSTYLE %s",m_strFillStyle);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strSubStsign != "")
		{
			str.Format("  SUBSTSIGN %s",m_strSubStsign);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strTitle != "")
		{
			str.Format("  TITLE \"%s\"",m_strTitle);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strFooter != "")
		{
			str.Format("  FOOTER %s",m_strFooter);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strHorizontal != "")
		{
			str.Format("  HORIZONTAL %s",m_strHorizontal);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		if(m_strVertical != "")
		{
			str.Format("  VERTICAL %s",m_strVertical);
			ar.Write(str,str.GetLength());
		    ar.Write("\r\n", 2);
		}
		

		ar.Write(" END\r\n", strlen(" END\r\n"));
	}
	else
	{
		//CString str;
		BOOL bRet = FALSE;
		long nIndex = 0;
		if(!m_nNoHead)
		{
			bRet = ar.ReadString(str);
			if(!bRet) AfxThrowFileException(CFileException::generic);
			nIndex = str.Find("XFSFRAME");
			str = str.Mid(nIndex + strlen("XFSFRAME"));
			nIndex = str.Find("\"");
			str = str.Mid(nIndex + 1);
			nIndex = str.Find("\"");
			str = str.Left(nIndex);
			//strcpy(framename,(LPCSTR)str);
			m_strFrameName = str;
		}

		bRet = ar.ReadString(str);  // BEGIN
		if(!bRet) AfxThrowFileException(CFileException::generic);
		long lTemp;
		while(1)
		{
			bRet = ar.ReadString(str);
			if(!bRet) AfxThrowFileException(CFileException::generic);
			str.TrimLeft();
			str.TrimRight();
			if(str == "END") break;
			lTemp = str.Find(" ");
			if(lTemp > 0)
			{
				CString strAttribute = str.Left(lTemp);
				CString str1 = str.Mid(lTemp + 1);
				str1.TrimLeft();
				str = str1;
				if(strAttribute == "POSITION")
				{
					lTemp = str.Find("(");
					if(lTemp < 0)
					{
						m_dwPage = 0;
						sscanf(str,"%d,%d",&position.m_wX,&position.m_wY);
					}
					else
					{
						long n = str.Find("POSITION");
						str = str.Mid(lTemp + strlen("POSITION"));
						sscanf(str,"%d,(%d,%d)",&position.m_wX,&position.m_wY,&m_dwPage);
					}
				}
				else if(strAttribute == "FRAMES")
				{
				
					lTemp = str.Find("\"");
					CString str1 = str.Mid(lTemp + 1);
					str = str1;
					lTemp = str.Find("\"");
					//m_strFrames = str.Left(lTemp);
					str1 = str.Left(lTemp);
					m_strFrames = str1;
				
				}
				else if(strAttribute == "HEADER")
				{					
					m_strHeader = str;
				}
				else if(strAttribute == "FOOTER")
				{
					m_strFooter = str;
				}
				else if(strAttribute == "SIDE")
				{
					m_strSide = str;
				}
				else if(strAttribute == "SIZE")
				{
					sscanf(str,"%d,%d",	&size.m_wWidth ,&size.m_wHeight);
				}
				else if(strAttribute == "REPEATONX")
				{
					sscanf(str,"%d,%d",	&repeatonx.m_wRepeatCount,&repeatonx.m_wXoffset);
				}
				else if(strAttribute == "REPEATONY")
				{
					sscanf(str,"%d,%d",	&repeatony.m_wRepeatCount,&repeatony.m_wYoffset);
				}
				else if(strAttribute == "TYPE")
				{
					m_strType = str;
				}
				else if(strAttribute == "CLASS")
				{
					m_strClass = str;
				}
				else if(strAttribute == "OVERFLOW")
				{
					m_strOverflow = str;
				}
				else if(strAttribute == "STYLE")
				{
					m_strStyle = str;
				}
				else if(strAttribute == "COLOR")
				{
					m_strColor = str;
				}
				else if(strAttribute == "RGBCOLOR")
				{
					sscanf(str,"%d,%d,%d",&rgbcolor.m_bRed,&rgbcolor.m_bGreen,&rgbcolor.m_bBlue);
				}
				
				else if(strAttribute == "FILLCOLOR")
				{
					m_strFillColor = str;
				}
				else if(strAttribute == "RGBFILLCOLOR")
				{
					nIndex = str.Find(",");
					rgbfillcolor.m_bRed = atoi(str.Left(nIndex));
					
					str = str.Mid(nIndex+1);
					nIndex = str.Find(",");
					rgbfillcolor.m_bGreen = atoi(str.Left(nIndex));

					str = str.Mid(nIndex + 1);
					rgbfillcolor.m_bBlue = atoi(str);					
				}
				else if(strAttribute == "FILLSTYLE")
				{
					m_strFillStyle = str;
				}
				else if(strAttribute == "SUBSTSIGN")
				{					
					m_strSubStsign = str;
				}
				else if(strAttribute == "TITLE")
				{
					lTemp = str.Find("\"");
					str = str.Mid(lTemp + 1);
					lTemp = str.Find("\"");
					str = str.Left(lTemp);
					m_strTitle = str;
				}
				else if(strAttribute == "HORIZONTAL")
				{
					m_strHorizontal = str;
				}
				else if(strAttribute == "VERTICAL")
				{
					m_strVertical = str;
				}
			}
		}
		
		//bRet = ar.ReadString(str);  // END

	}
}