Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » Insert text data from file
Insert text data from file [message #40916] Mon, 07 October 2013 18:49 Go to next message
iST1 is currently offline  iST1
Messages: 107
Registered: August 2013
Experienced Member
I'm trying to load txt file with transform base code LoadImage, but occured 2 problem:
1) it seems that QTF doesn't work with RichPara, but i use it for create new line (&);
2) rus code page

File:
line 1
line 2
line 3
строка 4
строка 5
строка 6

=>

`[`& line 1`]`[`& line 2`]`[`& line 3`]`[`&  4`]`[`&  5`]`[`&  6`]


void RichEdit::LoadTxt()
{
	FileSel fsel;
 	fsel.Type("Текстовые файлы ", "*.txt");

	static String dir = fsel.GetActiveDir();
	fsel.ActiveDir(dir);
	
	if(fsel.ExecuteOpen(t_("Выберите текстовый файл для вставки"))) {
		dir = fsel.GetActiveDir();

		FileIn fi;
		if(!fi.Open(~fsel)) {
			Exclamation(NFormat(t_("Ошибка открытия файла [* \1%s\1]."), ~fsel));
			return;
		}

		RichPara para;
		RichPara::CharFormat fmt;
		while (!fi.IsEof()) {
			para.Cat(DeQtf("[& " + fi.GetLine() + "]"), fmt);
		}

		RichText clip;
		clip.Cat(para);
		
		RemoveSelection();
		Insert(GetCursor(), clip, false);
		Finish();		
	}
}
Re: Insert text data from file [message #40926 is a reply to message #40916] Tue, 08 October 2013 20:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
iST1 wrote on Mon, 07 October 2013 12:49

I'm trying to load txt file with transform base code LoadImage, but occured 2 problem:
1) it seems that QTF doesn't work with RichPara, but i use it for create new line (&);



RichPara represents a 'line' (in fact, a paragraph, but I guess in this context you mean that). Therefore, if you want more paragraphs, you need to Cat them...

                RichText clip;
		while (!fi.IsEof()) {
		        RichPara para;
		        RichPara::CharFormat fmt;
			para.Cat(fi.GetLine()), fmt);
		        clip.Cat(para);
		}
}


(Alternatively, there not much wrong creating the whole clip in Qtf, not using RichPara).

Mirek
Re: Insert text data from file [message #40944 is a reply to message #40926] Fri, 11 October 2013 10:47 Go to previous messageGo to next message
iST1 is currently offline  iST1
Messages: 107
Registered: August 2013
Experienced Member
Senks. And more one question: how to load file with Russian code page?
Re: Insert text data from file [message #40990 is a reply to message #40944] Fri, 18 October 2013 07:46 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Convert to UTF8... (ToCharset).
Previous Topic: Problem copying from RichEdit to Word
Next Topic: Allow line-break after '-' sign within a word?
Goto Forum:
  


Current Time: Thu Mar 28 10:16:02 CET 2024

Total time taken to generate the page: 0.01032 seconds