Quantcast
Channel: Adobe Community : Popular Discussions - InDesign SDK
Viewing all articles
Browse latest Browse all 78596

InDesign crash while applying character style

$
0
0

Hi all,

 

 

A)I have problem with applying character style to selected text.

 

 

when character style is applied to selected text indesign get crashes.

 

 

my code snippet is as follow

 

 

input parameters

1.RangeData paraRange // start and end index of paragraph

2.storyUIDRef // uidref of current story

 

 

          code snippet

          // valid text model

          InterfacePtr<ITextModel> textModel(storyUIDRef, UseDefaultIID());

          if (!textModel)

   break;

          //wax strand

          InterfacePtr<IWaxStrand> waxStrand(((IWaxStrand*)textModel->QueryStrand(kFrameListBoss, IID_IWAXSTRAND)));

          if (waxStrand == nil)

   break;

          //WaxIterator

          K2::scoped_ptr<IWaxIterator> waxIterator(waxStrand->NewWaxIterator());

          if (waxIterator == nil)

    break;

          //first wax line of paragraph

          IWaxLine* waxLine = waxIterator->GetFirstWaxLine(paraRange.Start(nil));

          //iterate each waxline

          while (waxLine != nil && (waxLine->TextOrigin() < paraRange.End()))

          {

    //Iterate for all runs

   K2::scoped_ptr<IWaxRunIterator> waxRunIter( waxLine->QueryWaxRunIterator() ) ;

   IWaxRun * waxRun = waxRunIter->GetFirstRun();

   while (waxRun)

                    {

   int32 startPos  = waxRun->TextOrigin();

   int32 endPos = startPos + waxRun->GetCharCount();

   RangeData textRange(startPos ,endPos);

   ISelectionManager* selMgr = m_activeContext->GetContextSelection();

   if(!selMgr)

    break;

   //get valid textselection suite

  InterfacePtr<ITextSelectionSuite> suite(selMgr, UseDefaultIID());

                              if (!suite)

   break;

                              //select  text

  suite->SetTextSelection(storyRef, textRange, Selection::kScrollIntoView, nil);

                              //created style from selection using  " SnpManipulate::TextStyleCreateStyleFromSelection" method.

                    }

          }

 

my code get crashed at highlighted text( int32 startPos  = waxRun->TextOrigin();).

 

 

B)my next question is how to get textstyle ranges of a selected paragraph.

 

please help me.

 

Thanks

Tahir


Viewing all articles
Browse latest Browse all 78596


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>