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 next message
omari is currently offline  omari
Messages: 264
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

Re: Clipboard: "RTF" before "IMAGES" format, patch provided [message #44872 is a reply to message #44545] Sun, 12 July 2015 09:35 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thanks, fixed (in the end, I reorganized the code a bit more). Sorry for the delay.
Previous Topic: Possible Bug with Printing under linux
Next Topic: patch ParseRTF, Add cell background colors
Goto Forum:
  


Current Time: Thu Mar 28 21:30:42 CET 2024

Total time taken to generate the page: 0.01732 seconds