Skip to main content
AYS__HAKKIM
Inspiring
April 21, 2010
Frage

I've a doubt in basic thing.

  • April 21, 2010
  • 2 Antworten
  • 774 Ansichten

Hi all

I've a doubt in basic thing.

IActiveContext* myContext;

InterfacePtr<ITextEditSuite> textEditSuite(myContext->GetContextSelection(), UseDefaultIID());

textEditSuite->InsertText(WideString(rString));

in above lines, myContext->GetContextSelection() returns ISelectionManager. Then how textEditSuite can be created. could any one please explain?

thanks in advance

Ays.Hakkim

Dieses Thema wurde für Antworten geschlossen.

2 Antworten

pardalek
Inspiring
April 22, 2010

Hi,

search for the information about InDesign object model (The chapter is called Adobe InDesign object model implementation in the CS2 programming guide). There you will find the answer about what is boss, that a boss has interfaces and that if you already have a pointer to a particular interface on a particular boss, you can easily obtain a pointer to any interface of that boss.

So: boss class is kAbstractSelectionBoss which aggregates both ISelectionManager and ITextEditSuite.

When coming to selections in InDesign, read the Selection architecture chapter. The slection architecture is quite complex and allows what you have just done: you are asking for an interface on "any" context selection. You probably will crash InDesign when you call your code without some text selection. Always assert your pointers to see if you got a meaningful values.

AYS__HAKKIM
Inspiring
April 22, 2010

thank both. Now I understood.

regards

Ays.Hakkim

Bartek_Kropaczewski
Inspiring
April 21, 2010

As i see you have created pointer ITextEditSuite. What i could add i CanEditText() before InsertText()

Regards

Bartek

AYS__HAKKIM
Inspiring
April 21, 2010

Hi Cropas

Actually my doubt is how "textEditSuite" can be created from ISelectionManager. There is no methods in ISelectionManager to get ITextEditSuite.

thanks

Ays.Hakkim

Bartek_Kropaczewski
Inspiring
April 21, 2010

HI

But you already creating "textEditSuite" from ISelectionManager. In That code that you pasted above.

To get ISelectionManager you can either use IActiveContext::GetContextSelection or ISelectionUtils.

Let's say you have a an interface pointer to ISelectionManager named mySelectionMgr;

All you need to do is create your interface pointer to ITextEditSuite - textEditSuite:

InterfacePtr<ITextEditSuite> textEditSuite(mySelectionMgr, UseDefaultIID());

if (textEditSuite && textEditSuite->CanEditText())

{

     ErrorCode status = textEditSuite->InsertText(WideString(resultString));

     ASSERT_MSG(status == kSuccess, "WFPDialogController::ApplyFields: can't insert text");

}

This is code from InDesign SDK Documentation. You can find there more examples of "How to use ITextEditSuite".

Regards

Bartek