Article View: adobe.indesign.sdk
Article #113Number of lines
From: Badr
Date: Mon, 02 Mar 2009 10:43
Date: Mon, 02 Mar 2009 10:43
41 lines
1528 bytes
1528 bytes
hi ,
I need to calculate the number of lines from TextModel.
number of Paragraphs and Words are corrects
Can you help me please.
InterfacePtr<ITextStrand> txtStrand (static_cast<ITextStrand* >(textModel->QueryStrand(kTextDataStrandBoss, IID_ITEXTSTRAND)));
if (txtStrand == nil)
break;
TextIndex index= 0;
int32 numberOfParagraphs = 0,
numberOfLines = 0,
numberOfWords = 0 ;
while (index < textModel->GetPrimaryStoryThreadSpan()){
int32 length;
DataWrapper<textchar> chunk = txtStrand->FindChunk(index,&length);
int32 indexChunk = 0;
while(indexChunk < length){ if(chunk[indexChunk] == kTextChar_Space) numberOfWords++;
else if(chunk[indexChunk] == kTextChar_LF)
numberOfLines++;
else if(chunk[indexChunk] == kTextChar_CR)
numberOfParagraphs++;
++indexChunk;
}
index += length;
}
Best regards.
Badr
Technical Details
Message-ID:
<59b8166e.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!newshub.sdsu.edu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f63e9,d0ba11f3907d46f7,start X-Google-Attributes: gidf63e9,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Badr@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.indesign.sdk Subject: Number of lines Message-ID: <59b8166e.-1@webcrossing.la2eafNXanI> Date: Mon, 2 Mar 2009 02:43:50 -0800 Lines: 42 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit