Skip to main content
Known Participant
February 5, 2008
Question

Getting the ITextModel of selected textframe

  • February 5, 2008
  • 6 replies
  • 827 views
Hi list,

tought this was an easy one but i spend the whole afternoon getting this to work and still nothing.
I have a routine that performs some action on the ITextModel of selected text.
The same routine should also work with all the text of the currently selected frame, but i don't succeed in getting access to the ITextModel.

Here's my code (without asserts for reading purposes), but the InterfacePointer to ILayoutTarget always returns nil. Can anyone help me out?
Florian.

IActiveContext *myContext = gSession->GetActiveContext();
InterfacePtr<ILayoutTarget> layoutTarget(myContext), UseDefaultIID());
UIDList itemList = layoutTarget->GetUIDList(kStripStandoffs);
UIDRef graphicFrameUIDRef = itemList.GetRef(0);
This topic has been closed for replies.

6 replies

Participating Frequently
March 20, 2008
Florian,

The snippet runner also implemented selection suite in order to work on proper active context. If you look at most of the snippet's run method, the first thing a snippet does is usually query ILayoutTarget or ITextTarget, they will give you the selected active target. Snippet runner just add an extra layer so snippet code does not need to worry about writing selection code.

Since you mentioned you have a routine that performs some action on the ITextModel of selected text, it almost sounds like you need to implement selection suite. Unless you can find an existing suite that acts on selected text with the functionality you want. Then you can call the suite function directly without worrying about implementing your own CSB. The whole selection concept is kind of complex to explain in here, I suggested you read the programming guide's chapter on selection, and then take a look at many SDK samples that implements selection suite. It is one topic you can't really avoid in ID plug-in development.

Regards,
lee
Known Participant
March 20, 2008
Lee,

yes i did but all the snippets use ISnpRunnableContext* and i have no clue on how to implement this in my own code.
That whole ASB / CSB implementation is still not obvious to me...

Thanks,
Florian.
Participating Frequently
March 20, 2008
Have you checked out SnpManipulateTextFrame.cpp in the SDK? That maybe what you're looking for?

Thanks!
lee
Known Participant
March 17, 2008
I'm going to rephrase my problem, i just need the uid of the currently selected textframe.
There must be a way, but i'm clueless at the moment.
Participating Frequently
February 20, 2008
Florian,

To get to ITextModel of selected text, you will need to do it from ITextTarget. It appears to me what you need is to write selection suite as Dirk suggested. SDK's Programming Guide has a chapter called "Selection Fundamentals", please check it out. Also do a search on the SDK samples with the keyword, kTexttSuiteBoss, you would find a lot of text suite implementation examples.

Thanks!
lee
Inspiring
February 5, 2008
Target interfaces are only on the CSB side of suites.
Active context is the ASB side.

It is bad style to pass pointers (UIDRef etc.) from CSB to ASB, suites are designed for decoupling. If you don't find your functionality in other suites, you'll probably have to write your own. So move your working code into the CSB and keep the methods at high abstraction level, follow the patterns of other suites.

Dirk