Skip to main content
Participating Frequently
November 22, 2007
Question

X Scale value of character

  • November 22, 2007
  • 7 replies
  • 929 views
I want the scale attribute of selected text.<br />I m using the following code:<br /> UID myID;<br /> InDesign::TextRange range(textFocus);<br /> rangeData = range.GetRange();<br /> <br /> // Query the compose scanner to access text attributes<br /> InterfacePtr<IComposeScanner> composeScanner(textModel, UseDefaultIID());<br /> if (composeScanner == nil) <br /> {<br /> ASSERT(composeScanner); return;<br /> }<br /> <br /> // Query attribute report interface<br /> int32 attrLen = 0;<br /> InterfacePtr<const IAttrReport> attrReport(composeScanner->QueryAttributeAt(rangeData, kTextAttrXGlyphScaleBoss, &attrLen));<br /> if (attrReport == nil) <br /> {<br /> return;<br /> }<br /> <br /> // Query the attribute interface<br /> InterfacePtr<ITextAttrUID> attr(attrReport, ITextAttrUID::kDefaultIID);<br /> if (attr == nil) <br /> {<br /> PMString msgrl("attr is nil");<br /> msgrl.SetTranslated();<br /> CAlert::InformationAlert(msgrl); <br /> return;//break;<br /> }<br /> <br /> // Get the attribute value.<br /> const ITextAttrUID::ValueType tempValue = attr->Get();<br /> myID = tempValue;<br /> IDataBase* db = ::GetDataBase(textModel);<br /> InterfacePtr<const ITextAttrRealNumber> attr1(db, myID, IID_ITEXTATTRREALNUMBER);<br /> if(attr1){<br /> PMReal rXScale = attr1->GetRealNumber();<br /> PMString msgrl("a");<br /> msgrl.AppendNumber(rXScale);<br /> msgrl.SetTranslated();<br /> CAlert::InformationAlert(msgrl); <br /> }<br /><br />I found value of attr is returned nil.
This topic has been closed for replies.

7 replies

Inspiring
November 22, 2007
InterfacePtr<const IAttrReport> attrReport(composeScanner->QueryAttributeAt(rangeData, kTextAttrXGlyphScaleBoss, &attrLen));<br /><br />/* deleted stuff in between here */<br /><br />// on the attribute boss of your attrReport<br />// retrieve the realnumber interface:<br />InterfacePtr<const ITextAttrRealNumber> attr1(attrReport, IID_ITEXTATTRREALNUMBER);
Participating Frequently
November 22, 2007
As you instructed.I omitted that portion from my code.<br />but it is giving me this ASSERT Message.<br /><br />DataBase::CreateInstance(): Can't get class ID from UID 6918!<br />..\..\..\source\components\database3\main\database.cpp (1699)<br /><br />DataBase::Instantiate(): Instantiation from UID failed!<br />..\..\..\source\components\database3\main\database.cpp (1552)<br /><br />The code is:<br />IDataBase* db = ::GetDataBase(textModel);<br /> InterfacePtr<const ITextAttrRealNumber> attr1(db,kTextAttrXGlyphScaleBoss , IID_ITEXTATTRREALNUMBER);<br /> if(attr1 == nil){<br /> PMReal rXScale = attr1->GetRealNumber();<br /> PMString msgrl("a");<br /> msgrl.AppendNumber(rXScale);<br /> msgrl.SetTranslated();<br /> CAlert::InformationAlert(msgrl);<br />}
Inspiring
November 22, 2007
The "nonsense" was referring to my recommendation of ITextAttrScalableMeasure. I hit send before revisiting the interface. There are several specialized of those data bearing text attribute interfaces (RealNumber, UnderlineMode etc.) and I had thought this was another one of them that I had missed.

Funny observation - the emails for my previous postings were delivered out of order.

Have a nice day,
Dirk
Participating Frequently
November 22, 2007
Many Thanks for your quick reply and What do you expect from a Newbie
except nonsense?.
Inspiring
November 22, 2007
Omit that step with ITextAttrUID. It is only used to look up a swatch by UID. The ITextAttrRealNumber is straight on the same boss of your attrReport variable.
Inspiring
November 22, 2007
oops. nonsense.
Inspiring
November 22, 2007
Use ITextAttrScalableMeasure instead of ITextAttrRealNumber