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... » Clipboard: "RTF" before "IMAGES" format, patch provided (increase the priority of "RTF" before the IMAGE format when searching for clipboard content)
Clipboard: "RTF" before "IMAGES" format, patch provided [message #44545] Thu, 26 March 2015 20:14 Go to previous message
omari is currently offline  omari
Messages: 265
Registered: March 2010
Experienced Member
Hi,

When a table copied from Excel, pasted into QtfDesigner, the result is an image!

inspecting the clipboard content, it contain the copier content in RTF format (and html, xml, ..).

the idea is to retrieve the text when it is possible.

the patch:

RichEdit/Clip.cpp, remove the lines ( line 66)

	else
	if(d.Accept(RTFS))
		clip = ParseRTF(~d);


and add this at line 33
	if(d.Accept(RTFS))
	{
		clip = ParseRTF(~d);
		return true;
	}



here the function RichEdit::Accept() patched:

bool RichEdit::Accept(PasteClip& d, RichText& clip)
{
	if(IsReadOnly())
		return false;
	
	if(d.Accept(RTFS))
	{
		clip = ParseRTF(~d);
		return true;
	}
	
	for(int i = 0; i < RichObject::GetTypeCount(); i++) {
		RichObjectType& rt = RichObject::GetType(i);
		if(rt.Accept(d)) {
			Value data = rt.Read(d);
			if(!IsNull(data)) {
				RichPara p;
				p.Cat(RichObject(&rt, data, pagesz), formatinfo);
				clip.Cat(p);
			}
			return true;
		}
	}
	if(AcceptFiles(d)) {
		Vector<String> s = GetFiles(d);
		if(s.GetCount()) {
			String fn = s[0];
			String ext = ToUpper(GetFileExt(fn));
			if(ext == ".PNG" || ext == ".JPG" || ext == ".JPEG" || ext == ".GIF" || ext == ".TIF" || ext == ".TIFF") {
				if(d.Accept()) {
					if(StreamRaster::LoadFileAny(fn)) {
						RichPara p;
						p.Cat(CreateRawImageObject(LoadFile(fn)), formatinfo);
						clip.Cat(p);
					}
					return true;
				}
				return false;
			}
		}
		d.Reject();
	}
	if(d.Accept("text/QTF"))
		clip = ParseQTF(~d, 0, context);
	else
	if(AcceptText(d))
		clip = AsRichText(GetWString(d), formatinfo);
	else
		return false;
	return true;
}


regards
omari.

[Updated on: Thu, 26 March 2015 20:21]

Report message to a moderator

 
Read Message
Read Message
Previous Topic: Possible Bug with Printing under linux
Next Topic: patch ParseRTF, Add cell background colors
Goto Forum:
  


Current Time: Sat Apr 27 09:10:40 CEST 2024

Total time taken to generate the page: 0.05505 seconds