Gettting Tab info

General TRichView support forum. Please post your questions here
Post Reply
zbozkurt
Posts: 8
Joined: Sun May 17, 2020 2:59 pm

Gettting Tab info

Post by zbozkurt »

hi;

I need to getting tab information. (Tab's position of a paragraph)
The document start look like this

...
text.tab.tab.text.tab.tab.text.tab.text
...


I tried to getting tab info using this code.

var
..
xitemno: TCustomRVItemInfo;
xparano : integer;
xtabinfo : TrvTabInfos ;

..
begin
..
xitemno:=RVE.Getitem(count);
xparano:=xitemno.Parano;
xtabinfo:=rvstyle.parastyles[xparano].Tabs;
// this line returns zero. but line contains more than one tabs.
showmessage(inttostr(xtabinfo.count));

end;

Can you help me getting tab information. (Tab.count, tab.position, tab.leader etc);

Thanks in advise.

Sergey Tkachenko
Site Admin
Posts: 15138
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Gettting Tab info

Post by Sergey Tkachenko »

The collection RVStyle.ParaStyles[].Tabs is a collection of potential tab positions. In the ActionTest demo, you can see these tab positions as checks on the ruler above the editor.

Tabs in document are added by pressing tabs, but stored in document not as a tab character, but as an item of TRVTabItemInfo class. When formatting, TRichView determines which tab position (from RVStyle.ParaStyles[].Tabs) is used by each tab item. However, it does not mean that each tab position is used, and not all tab items use tab positions (for example, if the tab is to the right of the last tab position, its position is calculated using RVStyle.DefTabWidth property).

TRichView does not store information which tab position is used for tabs. Instead, it assigns Leader and Align from the tab position to tab item.

zbozkurt
Posts: 8
Joined: Sun May 17, 2020 2:59 pm

Re: Gettting Tab info

Post by zbozkurt »

Thanks for your reply.

I need an analyse of document items. After loading and formatting a document which is saved RTF format.
I can take about information of texts (font, size, font syyle etc.)
I can take about information of tables (cell, row,col, etc)

If a default DefTabWidth is 50 (px) possible tab positions are 0, 50, 100, 150, 200, 250... so on.
How can I determine used tab s info?

Sergey Tkachenko
Site Admin
Posts: 15138
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Gettting Tab info

Post by Sergey Tkachenko »

Can you be more specific, what information do you want to receive?

You asked about tab count. What tab count do you mean? Count of tab stops in paragraph properties? Count of tab characters in a line (if yes, which line?). Or maybe something different?

zbozkurt
Posts: 8
Joined: Sun May 17, 2020 2:59 pm

Re: Gettting Tab info

Post by zbozkurt »

Hi;
I try to converting RTF document to a specific file format. (File format is not standart).So I need collecting item's info and item's type from RVE.
my codes is look likes

var
xitemstyle : integer;
xrvdata : TcustomRvdata;
xitemcount : integer;
..
xrvdata:=RVE.Rvdata;
for xitemcount:=0 to xrvdata.items.count-1 do begin
xitemstyle:=xrvdata.getitemstyle(xcount);

if xitemstyle>-1 then
gettextinfo; // Getting font properties and paragraph properties ... ?? Paragraf properties tab s info
if xitemstyle<0 then begin
case xitemstyle of
-3 : getpictureinfo(xitemcount);// This is ok.I retrive necessary information about picture
-10 : getpictureinfo(xitemcount);
-60 : gettableinfo(xitemcount); // This is ok. I retrive row,col,cell properties, rowspan, colspan etc.
-12 : gettabinfo(xitemcount); // Tab'sinformation needing
end;
end;
end;
-- // write all information to spec file format. it needs tab's position.

I need tab's info when xitemstyle=-12

PS: sory for my bad english :(

Sergey Tkachenko
Site Admin
Posts: 15138
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Gettting Tab info

Post by Sergey Tkachenko »

There is a huge difference between tabs and all these objects.

When you specify picture properties, you specify properties for this specific picture. This picture will still have these properties if you add other content in document, or if you move the picture in another location. Properties of pictures are stored in files (RTF, RTF, etc.). The same for tables and other objects.

But tabs are very different. There are no tab properties that are stored in files (except for text attributes, like font or color). Tab position (distance from the left size), alignment and leader characters do not belong to the tab properties. They are assigned when document is formatted. In TRichView, line wrapping depend on window width. This means that when you resize TRichView window, some tabs may be moved to the new line, so their positions, alignment and leader characters may be different.

For example. Let we have a paragraph having two tab stops in properties: (329px, no leader char), (729px, '.' as leader char), and a text that has two tabs that matches these tab stops:
tabs1.png
tabs1.png (26.05 KiB) Viewed 961 times

Now we just resize the window. Now there are two lines with tabs. Each of these lines has one tab, the both of them match the tab stop (329px, no leader char). The tab stop (729px, '.' as leader char) still exists in the paragraph properties, but it is unused:
tabs2.png
tabs2.png (30.92 KiB) Viewed 961 times
As I said, this behavior correspond to saving tabs in RTF, RVF and DocX. Properties like position, alignment, leader character are stored not as properties of the specific tab character, but as properties of paragraphs. And tabs and tabs stops are matched when document is formatted, and the result depend on how the document is displayed. Probably it is the same in this custom file format (?)

zbozkurt
Posts: 8
Joined: Sun May 17, 2020 2:59 pm

Re: Gettting Tab info

Post by zbozkurt »

The custom format's editor is a page based. No window or editable area based. Editor main windows is 1024*800 display full page, when main window size is 1024*400 display 1/2 of full page. The custom format save tabs are chr(9). The paragraph properties has got a tabset properties which is possible tab's position.

If I getting tab's position when display a specific window size (eg width=800 to equal custom formar editor's full page size. This 800px may be need some testing to same display same things to correctly displaying tabs and paragraf's). My convert program works onyl 800 px main window size.
It is enough for me.

Sergey Tkachenko
Site Admin
Posts: 15138
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Gettting Tab info

Post by Sergey Tkachenko »

So you have tabs stops in paragraph properties, and tab characters in text. Just like in RVF, RTF or DocX.
Matching between tab stops and tab characters is performed at the time of formatting/displaying, and may be different in different editors.
So I do not understand, why do you need this information for exporting?

Information about which tab stop is used for the given tab character (TRVTabItemInfo item) is not stored in TRichView. Of course, you can get coordinates of this tab character and find the proper position, but it can be easily done only by left-aligned tabs in left-aligned paragraphs.

However, you can get alignment and leader character.
In gettabinfo(), you can use GetItem, typecast the result to TRVTabItemInfo, use Align and Leader properties.

zbozkurt
Posts: 8
Joined: Sun May 17, 2020 2:59 pm

Re: Gettting Tab info

Post by zbozkurt »

Hi Sergey;

-->
Information about which tab stop is used for the given tab character (TRVTabItemInfo item) is not stored in TRichView. Of course, you can get coordinates of this tab character and find the proper position, but it can be easily done only by left-aligned tabs in left-aligned paragraphs.
-->

can you share some code examples?
(When I try to this I have got error tabs.count return always zero? Possible I have mistake but I didn't find my mistakes.)

Sergey Tkachenko
Site Admin
Posts: 15138
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Gettting Tab info

Post by Sergey Tkachenko »

Probably you still confuse tabs (tab characters) and tab stops.

On the picture below, I enumerated allowed tab stops, from 1 to 7:
tabs.png
tabs.png (25.89 KiB) Viewed 802 times
The first two tab stops are defined in Tabs collection, the ruler shows them as "L" sign. Subsequent tab stops are calculated automatically using DefTabWidth, the ruler shows them as small ticks.

Tab stops and tab characters are different things!

ParaStyle.Tabs (collection of tab stops) is empty by default. This collection can be edited in the paragraph dialog (page Tabs) and using the ruler (click adds a tab stop).

I have a problem in writing a code sample because I still do not understand what you want.

zbozkurt
Posts: 8
Joined: Sun May 17, 2020 2:59 pm

Re: Gettting Tab info

Post by zbozkurt »

Thanks for your reply ;
I understand that why always paragraph.tabs.count return zero.

is the defaultTab.Position changing when after loading and formatting RTF document?

Sergey Tkachenko
Site Admin
Posts: 15138
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Gettting Tab info

Post by Sergey Tkachenko »

No, this probably is not saved to and not loaded from RTF.
Probably, it will be future versions.

Post Reply