Highlighted

Character count values in C++

Community Beginner ,
Jun 30, 2020

Copy link to clipboard

Copied

Hi,

I have used this code to find the characters present in the document but at the sametime I need to get the character count values. So please help me to get the count values...

 

IDocument* document = Utils<ILayoutUIUtils>()->GetFrontDocument();
if (document != nil) // use the document interface
{

InterfacePtr<ISpreadList> spreadList(document, UseDefaultIID());

IDataBase* database = document->GetDocWorkSpace().GetDataBase();
int32 spreadCount = spreadList->GetSpreadCount();

for (int32 spreadIndex = 0; spreadIndex < 1; spreadIndex++)
{
UIDRef spreadUIDRef(database, spreadList->GetNthSpreadUID(spreadIndex));
InterfacePtr<ISpread> spread(spreadUIDRef, UseDefaultIID());
for (int32 pageIndex = 0; pageIndex < spread->GetNumPages(); pageIndex++)
{
UIDList itemsOnPage(database);
const bool16 bIncludePage = kFalse;
const bool16 bIncludePasteboard = kFalse;
spread->GetItemsOnPage(pageIndex, &itemsOnPage, bIncludePage, bIncludePasteboard);
int32 pageItemListLength = itemsOnPage.Length();
for (int32 i = 0; i < pageItemListLength; i++)
{
UIDRef pageItemRef = itemsOnPage.GetRef(i);


InterfacePtr<IGraphicFrameData> graphicFrameData(pageItemRef, UseDefaultIID());
if (!graphicFrameData) { break; }

InterfacePtr<IMultiColumnTextFrame> multiColumnTextFrame(graphicFrameData->QueryMCTextFrame());
if (!multiColumnTextFrame) { break; }
InterfacePtr<ITextModel> textModel(multiColumnTextFrame->QueryTextModel());
if (textModel) {
RangeData range = textModel->GetStoryThreadRange(0);
TextIterator begin(textModel, range.Start(0));
TextIterator end(textModel, range.End());
for (TextIterator iter = begin; iter != end; iter++) {
const UTF32TextChar characterCount = *iter;
result.Append(characterCount);

}//for
}//textModel

PMString Display;
Display = PMString(result);

CAlert::InformationAlert(Display);
}
}
}

Rajendran
TOPICS
SDK

Views

90

Likes

Translate

Translate

Report

Report
This conversation has been locked.

Character count values in C++

Community Beginner ,
Jun 30, 2020

Copy link to clipboard

Copied

Hi,

I have used this code to find the characters present in the document but at the sametime I need to get the character count values. So please help me to get the count values...

 

IDocument* document = Utils<ILayoutUIUtils>()->GetFrontDocument();
if (document != nil) // use the document interface
{

InterfacePtr<ISpreadList> spreadList(document, UseDefaultIID());

IDataBase* database = document->GetDocWorkSpace().GetDataBase();
int32 spreadCount = spreadList->GetSpreadCount();

for (int32 spreadIndex = 0; spreadIndex < 1; spreadIndex++)
{
UIDRef spreadUIDRef(database, spreadList->GetNthSpreadUID(spreadIndex));
InterfacePtr<ISpread> spread(spreadUIDRef, UseDefaultIID());
for (int32 pageIndex = 0; pageIndex < spread->GetNumPages(); pageIndex++)
{
UIDList itemsOnPage(database);
const bool16 bIncludePage = kFalse;
const bool16 bIncludePasteboard = kFalse;
spread->GetItemsOnPage(pageIndex, &itemsOnPage, bIncludePage, bIncludePasteboard);
int32 pageItemListLength = itemsOnPage.Length();
for (int32 i = 0; i < pageItemListLength; i++)
{
UIDRef pageItemRef = itemsOnPage.GetRef(i);


InterfacePtr<IGraphicFrameData> graphicFrameData(pageItemRef, UseDefaultIID());
if (!graphicFrameData) { break; }

InterfacePtr<IMultiColumnTextFrame> multiColumnTextFrame(graphicFrameData->QueryMCTextFrame());
if (!multiColumnTextFrame) { break; }
InterfacePtr<ITextModel> textModel(multiColumnTextFrame->QueryTextModel());
if (textModel) {
RangeData range = textModel->GetStoryThreadRange(0);
TextIterator begin(textModel, range.Start(0));
TextIterator end(textModel, range.End());
for (TextIterator iter = begin; iter != end; iter++) {
const UTF32TextChar characterCount = *iter;
result.Append(characterCount);

}//for
}//textModel

PMString Display;
Display = PMString(result);

CAlert::InformationAlert(Display);
}
}
}

Rajendran
TOPICS
SDK

Views

91

Likes

Translate

Translate

Report

Report
Jun 30, 2020 0
Adobe Employee ,
Jul 01, 2020

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Jul 01, 2020 0