LoadRVFFromStream and problems with bullets
LoadRVFFromStream and problems with bullets
I'm working on a old project where the Richview component is used. I have a problem when I try to load a stream with LoadRVFFromStream.
The LoadRVFFromStream function returns False some time, but not all the time. It seems that it's when I have used indent or bullets/numbering in the richview.
Is there a way that I can see why hi returns false? I have feeling that it might be something with styles? But I'm new to richview and don't know where to look first.
JP
The LoadRVFFromStream function returns False some time, but not all the time. It seems that it's when I have used indent or bullets/numbering in the richview.
Is there a way that I can see why hi returns false? I have feeling that it might be something with styles? But I'm new to richview and don't know where to look first.
JP
Last edited by jp on Tue May 27, 2008 7:33 pm, edited 1 time in total.
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I think your old documents were saved without styles, so they can be loaded properly only if collections of styles in RVStyle are the same as at the moment of saving.
If you cannot reproduce these collections, you can still load them, including rvfoConvUnknownStylesToZero in RVE.RVFOptions.
For text and paragraph styles, all is ok.
But for list styles, converting invalid ListNo to 0 still produces invalid documents, of there are no list styles in the collection.
Solution: add one item in RVStyle.ListStyles, with one list level.
If you cannot reproduce these collections, you can still load them, including rvfoConvUnknownStylesToZero in RVE.RVFOptions.
For text and paragraph styles, all is ok.
But for list styles, converting invalid ListNo to 0 still produces invalid documents, of there are no list styles in the collection.
Solution: add one item in RVStyle.ListStyles, with one list level.
Dear Sergey of some one else
I'm not getting any further - I have tried all what I could think off.
I think your are right in that the old rvf is saved whit out any styles. But the user can set the numbering and the indent. I think that this result in that his saving these styles and by rereading them hi don't recognize them.
But how can I load those user created styles?
Are those styles saved with the item?
Something like you do in this thread:
http://www.trichview.com/forums/viewtop ... liststyles
JP
I'm not getting any further - I have tried all what I could think off.
I think your are right in that the old rvf is saved whit out any styles. But the user can set the numbering and the indent. I think that this result in that his saving these styles and by rereading them hi don't recognize them.
But how can I load those user created styles?
Are those styles saved with the item?
Something like you do in this thread:
http://www.trichview.com/forums/viewtop ... liststyles
JP
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
If styles were not saved, they are lost. That includes all text and paragraph attributes, as well as all properties of bullets&numbering (except for list level and initial numbering counter that are stored with list markers)
In this case, all what you can do is to load documents with loss of formatting and properties of bullets&numbering.
You can send me an example of your documents to svt@trichview.com
In this case, all what you can do is to load documents with loss of formatting and properties of bullets&numbering.
You can send me an example of your documents to svt@trichview.com
I'm not getting any further. I can not send you the file, it's incorporated in bigger project file.
But I can show you the code wher I get the error.
In the component TRVStyle we have defined 3 ListStyles and they each got 3 Levels.
In code between the "//----------" I count the ListStyle and Levels, here I can see that in the part where I get the error, hi count's 6 ListStyles.
ListStyles, but in all others max 3.
My Idea was to check how many ListStyles and Levels and if thats 0 or >3 to set a default ListStyles and Levels.
I have tried to set those with "ApplyListStyle" and "SetListMarkerInfo", both without result.
I get the error in the LoadRVFFromStream.
Any one who can help me in the right direction?
JP
But I can show you the code wher I get the error.
In the component TRVStyle we have defined 3 ListStyles and they each got 3 Levels.
In code between the "//----------" I count the ListStyle and Levels, here I can see that in the part where I get the error, hi count's 6 ListStyles.
ListStyles, but in all others max 3.
My Idea was to check how many ListStyles and Levels and if thats 0 or >3 to set a default ListStyles and Levels.
I have tried to set those with "ApplyListStyle" and "SetListMarkerInfo", both without result.
I get the error in the LoadRVFFromStream.
Any one who can help me in the right direction?
JP
Code: Select all
procedure TRVEditFrame.SetStream(var stream: TMemoryStream; clear: boolean = true);
var
res: boolean;
lastItem, lastOfs: integer;
i, n: Integer;
begin
if stream <> nil then
begin
if clear then
begin
RVE.Clear;
RVE.Format;
end;
//-------------------------
i := RVStyleText.ListStyles.Count;
n := RVStyleText.ListStyles[0].Levels.Count;
if (RVStyleText.ListStyles.Count = 0) or (RVStyleText.ListStyles.Count > 3) or
(RVStyleText.ListStyles[0].Levels.Count = 0) or (RVStyleText.ListStyles[0].Levels.Count > 3) then
// RVE.ApplyListStyle(1, 1, 0, False, False);
RVE.SetListMarkerInfo(-1, 0, 0, 1, 0, False);
//--------------------------
stream.Position := 0;
if clear then
res := RVE.LoadRVFFromStream(stream)
else
res := RVE.AppendRVFFromStream(stream, 0);
if not res then
begin
ShowMessage('Could not load richview data');
end;
changed := false;
RVE.Format;
lastItem := rve.ItemCount - 1;
lastOfs := rve.GetOffsAfterItem(lastItem);
//RVE.SetSelectionBounds(lastItem,lastOfs,lastItem,lastOfs);
end;
if stream = nil then
begin
stream := internalStream;
end;
currentStream := stream;
end;
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You cannot set the default ListNo for RVF loading.
The default ListNo is always 0, and it is used for list styles with invalid ListNo (i.e. when ListNo>=RVStyleText.ListStyles.Count).
Of course, only if rvfoConvUnknownStylesToZero is included in RVFOptions. Otherwise, invalid indices cause loading error.
Are you sure that RVStyleText.ListStyles.Count>0 before loading RVF?
The default ListNo is always 0, and it is used for list styles with invalid ListNo (i.e. when ListNo>=RVStyleText.ListStyles.Count).
Of course, only if rvfoConvUnknownStylesToZero is included in RVFOptions. Otherwise, invalid indices cause loading error.
Are you sure that RVStyleText.ListStyles.Count>0 before loading RVF?
Dear Sergey
That I can't set the ListNo before loading the rvf sound logical
(I presume that ListNo = ListStyle number?)
Yes I'm sure that "i := RVStyleText.ListStyles.Count;" > than 0 is.
In the part where I get the error the variables are:
i: 6
n: 2
x: 0
y: 6
How can I catch the wrong Styles/Levels and convert them to something that will work?
Please help me resolve this problem.
JP
That I can't set the ListNo before loading the rvf sound logical
(I presume that ListNo = ListStyle number?)
Yes I'm sure that "i := RVStyleText.ListStyles.Count;" > than 0 is.
Code: Select all
i := RVStyleText.ListStyles.Count;
n := RVStyleText.ListStyles[0].Levels.Count;
x := RVE.Style.ItemNo;
y := RVE.Style.ListStyles.Count;
i: 6
n: 2
x: 0
y: 6
How can I catch the wrong Styles/Levels and convert them to something that will work?
Please help me resolve this problem.
JP
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Sergey Tkachenko
I have solved my problem. I found that very deep in the code that the Richview editor object destroyed and a new where created. In the create process I believe that some proproties where set that did that the styles where initialized.
And just for this piece where I had the troubles the Richview editor where not destroyed and so where thy styles not set as I thought.
But not that I can say that I understand how this all work, but I have my problem solved for now and later I will look deeper into Richview editor and its styles. I verily think it´s a great component.
Thanks for your help and I will surely be back with more questions
JP
I have solved my problem. I found that very deep in the code that the Richview editor object destroyed and a new where created. In the create process I believe that some proproties where set that did that the styles where initialized.
And just for this piece where I had the troubles the Richview editor where not destroyed and so where thy styles not set as I thought.
But not that I can say that I understand how this all work, but I have my problem solved for now and later I will look deeper into Richview editor and its styles. I verily think it´s a great component.
Thanks for your help and I will surely be back with more questions
JP
I thought that I had solved the problem, I just did a free and nil for the RVEdit and created him again - every one happy. But that was only until another functionality did work any more.
It look like that creating the RVEdit in code initialize some thing in the Styles and I have tried every thing I can think of to do this initializing my self but I can't get it working.
The error I get wen trying load the rvf from stream (RVE.LoadRVFFromStream) is the RVFWarning "[rvfwConvUnknownStyles]".
What can I further try to get this working=
JP
It look like that creating the RVEdit in code initialize some thing in the Styles and I have tried every thing I can think of to do this initializing my self but I can't get it working.
The error I get wen trying load the rvf from stream (RVE.LoadRVFFromStream) is the RVFWarning "[rvfwConvUnknownStyles]".
What can I further try to get this working=
JP
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: