How to get current page number (SDK, C++)

Community Beginner ,
Apr 16, 2022 Apr 16, 2022

Copy link to clipboard

Copied

Hi

 

I'm trying to get current page index / number inside a find text loop. Here's my code

 

 Utils<ILayoutUtils>()->InvalidateViews(document);
                    InterfacePtr<ILayoutControlData> layoutCData(ac->GetContextView(),UseDefaultIID() );

                    InterfacePtr<IHierarchy> layerHier(layoutCData->QueryActiveLayer());
                    UIDRef layerRef(::GetUIDRef(layerHier));
                    IDataBase* db = layerRef.GetDataBase();
                    UIDRef pageRef = UIDRef(db, layoutCData->GetPage());
                    
                    InterfacePtr<ISpread> cspread(layoutCData->GetSpreadRef(), IID_ISPREAD);
                    int32 pageIndx = cspread->GetPageIndex(pageRef.GetUID());
                    
                    PMString info("pidx: ");
                    info.AppendNumber(pageIndx);
                    CAlert::InformationAlert(info);

 

I used these too to refresh

sleep_for(10ms);

Utils<ILayoutUtils>()->InvalidateViews(document);

 

But it just gives me 0 always. Please guide me where im wrong.

 

thank you

 

TOPICS
SDK

Views

57

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 16, 2022 Apr 16, 2022

Copy link to clipboard

Copied

I guess indexes are redefined to every spread. If so, how to get page number?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 16, 2022 Apr 16, 2022

Copy link to clipboard

Copied

LATEST

I got a method to get page number.

 

                    InterfacePtr<ITextModel> tModel(textRange.QueryModel(), UseDefaultIID());
                    Utils<ITextUtils>()->GetTextFramesContaining(tModel, textRange.GetRange(), &stFrm, &endFrm);
                    InterfacePtr<IFrameList> frmList(tModel->QueryFrameList());
                    if(!frmList) break;
                    
                    UID pFrmUID = frmList->GetNthFrameUID(stFrm);
                    
                    int32 pageNum = Utils<ITextUtils>()->GetPageNumber(UIDRef(db, pFrmUID));

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines