Page 1 of 1
[Help] Save style to ini file
Posted: Wed Mar 08, 2006 1:53 pm
by sliver80
hi, i need to save a runtime created style to an ini file.
my style has 3 textstyles and 3 parastyles (used for alignment), and i save it with:
StileRich->SaveINI(filename,index);
but it save all 3 textstyles, but noone parastyles.
and also...what should the index value be?
thanks and bye
Posted: Thu Mar 09, 2006 3:50 pm
by Sergey Tkachenko
I cannot reproduce this problem.
For example, I saved RVStyle from RichViewActions demo, and it worked fine. The saved ini-file contains the line
and a number Para*=* lines.
Note that only properties with changed (not default) values are saved.
Posted: Thu Mar 09, 2006 3:55 pm
by sliver80
hi,
the problem is that in the ini file i have all the textstyles information, but only ParasCount and ParaStyleName information of the parastyles, so i lost alignment information.
however i'll see the RichViewActions demo.
thanks
Posted: Thu Mar 09, 2006 4:49 pm
by Sergey Tkachenko
I uses RichViewActions only because it's easy to test.
Ok, I created a new document in RichViewActions (one text and one paragraph style by default), added a text line, centered it (so the second, centered, paragraph style is added).
Saved to ini-file.
The following
Para* lines are saved:
Code: Select all
ParasCount=2
ParaStyleName0=Left
ParaStyleName1=Left
ParaStandard1=0
ParaAlignment1=2
As you can see, two paragraph styles are saved. Both have name "Left" (because when RichViewActions creates a new style, it names it by its parent style), and you can see "ParaAlignment1=2" line, telling that the alignment of ParaStyles[1] is centered.
All as expected.
Posted: Thu Mar 09, 2006 6:20 pm
by sliver80
problem solved !!!
i forgot to do:
"boxTemp->StileRich->ParaStyles->Add();"
before defining the Items[2] of ParaStyles and maybe the saveini doesn't save the 0 and 1 because go crazy.
thanks Sergey
ps: i don't understand why without ParaStyles->Add(), i haven't "List index out of bound" error.
Posted: Thu Mar 09, 2006 8:42 pm
by Sergey Tkachenko
Collections of TextStyles and ParaStyles are special.
When accessing an out of bounds item, TextStyles.InvalidItem/ParaStyles.InvalidItem is returned, instead of raising an exception.
By default, TextStyles.InvalidStyles is white on red text, ParaStyles.InvalidItem has a red border.
It was implemented in this way because it's usually simpler to find an error in document generation if incorrect text is displayed in red than if the component generates an exception on formatting/drawing.
Posted: Thu Mar 09, 2006 9:25 pm
by sliver80
great, it's a nice idea.
i really didn't think in this way and i masked like a stupid the red border (and before saveini problem it seem all ok)
thank a lot, sergey