Rich Text Format

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Rich Text Format

Post by Wolfgang »

Is there already a complete implementation of the Rich Text Format from word?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Rich Text Format

Post by ONEEYEMAN »

Hi,
wxRichTextCtrl?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Rich Text Format

Post by doublemax »

There is no import or export of RTF format in wxWidgets. There was an RTF import implementation for wxRichTextCtrl from a Chinese programmer, but i can't find the link any more.
Use the source, Luke!
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Re: Rich Text Format

Post by Wolfgang »

doublemax wrote: Thu Mar 07, 2019 8:59 pm There is no import or export of RTF format in wxWidgets. There was an RTF import implementation for wxRichTextCtrl from a Chinese programmer, but i can't find the link any more.
I found a parser for phyton, but not for C++.

Did you mean this one:
https://github.com/cctags/gumpad2/blob/ ... FParser.py

Anyway implementing this into c++, is still to high for me, after all still a beginner.
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Re: Rich Text Format

Post by Wolfgang »

I need this for a database which has app. 15000 items in it, and all items are as rtf, otherwise I would have to convert them into something readable like html, and place it back in the database, which is not so easy either, But if i can stay with rtf, it is easier to use for other existing programms. So a lot of reason to stay with rtf.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Rich Text Format

Post by doublemax »

Do you really need the RTF import in the application? Can't you do the conversion "offline" with an external tool?

Anyway, I found the source code from the RTF importer i was talking about. I uploaded it here: https://www.sendspace.com/file/0uushz

I comes with no documentation except the comments in the header file and i also don't know if it works with the current wxRichTextCtrl.

There is also http://librtf.sourceforge.net/
Use the source, Luke!
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Re: Rich Text Format

Post by Wolfgang »

Just implemented a quick test, to read it from a file, and whis worked, now I have to change it to a memory file system, as it is working with stream, and not just strings, what would make it easier for me.

But thanks for the tipp, it looks at the moment like it will work.
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Re: Rich Text Format

Post by Wolfgang »

How is it best to get it from a string to a stream?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Rich Text Format

Post by doublemax »

Wolfgang wrote: Sun Mar 10, 2019 9:24 pm How is it best to get it from a string to a stream?
https://docs.wxwidgets.org/trunk/classw ... tream.html
or
https://docs.wxwidgets.org/trunk/classw ... tream.html
Use the source, Luke!
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Re: Rich Text Format

Post by Wolfgang »

Thanks managed to change it so it works with my string from the database.

Now only saving, but that will take still a bit.
If I have a question there I will ask.
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Re: Rich Text Format

Post by Wolfgang »

Did not check right away, but there are a lot of memory leaks in the rtf code. As soon as I implement it, I have memory leaks, if I leave it away there are none. But not easy to get rid of them, as I tried some delete, but then it gave errors.
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Re: Rich Text Format

Post by Wolfgang »

Doublemax

Can you check for the memory leaks, by the one you uploaded for me.

Yes it works with the current wxRichtextctrl but produces a lot of memory leaks, and I find no solution how to clean those.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Rich Text Format

Post by ONEEYEMAN »

Hi,
If you are on Windows with MSVC - did you try VLD?

Thank you.
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Re: Rich Text Format

Post by Wolfgang »

tried vld, my own code is also without leak, it is the external, and there are app. 1400 memory leaks, as it uses all the time new. and with a delete it generates an error, so I'm out of ideas. Even if I just make a delete before the next new call, it throughs an exception.
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 184
Joined: Mon Jan 28, 2019 8:22 am

Re: Rich Text Format

Post by Wolfgang »

the leak depend how long the rtf text is. had now 15.255 leaks;

Code: Select all

void RtfLayerNode::AddAttribute(wxString name,wxString value)
{
    RtfAttributes *attr = new RtfAttributes(name,value);
    m_Attrlist.Append(attr);
	
	delete attr;
}
Here the

Code: Select all

delete attr;
causes the error:
Unhandled unknown exception; terminating the apllication.
If I start it without the delete attr; it works, but it has a lot of memory leaks.

And that is just one of the places where it generates the memory leaks.
Post Reply