I am trying to build an extension that I would install on Mozilla 1.6
and up.  In that extension, I need to retrieve the currently selected
text (for now, only in an editor such as the Compose Mail or the
Composer, will eventually need the same thing for a "text-viewer" like
the Navigator).

To get me started, I thought I would look at some of the code of the
Composer, since the spell checker kinda does what I need to do, which
is retrieve the selected text to do its work on it.  The spell checker
module does a couple of calls on a nsITextServicesDocument interface
to get what it needs about the text.  On that interface, the
GetCurrentTextBlock method seems to be what I need.  This method
requires a nsString as its parameter, in which it returns the string
I'm looking for.

The problem I have is, the nsString.h file is located in the
/xpcom/string/obsolete/ folder.  For obvious reasons, I would prefer
not to use stuff that is located in a folder called /obsolete/.  Since
I haven't found a way around so far, I'm still trying to use the
nsString class.  Unfortunately, when I do, I get linking errors.  I
found the header file of the nsString class for the declaration, but I
can't seem to find the library file for the linking.  That is probably
why I get the following errors :

mozFoo error LNK2019: unresolved external symbol "public: __thiscall
nsString::nsString(void)" (??0nsString@@[EMAIL PROTECTED]) referenced in function
"public: virtual unsigned int __stdcall MozFoo::DonneTexte(class
nsIEditor *,char * *)" ([EMAIL PROTECTED]@@UAGIPAVnsIEditor@@[EMAIL PROTECTED])
mozFoo error LNK2019: unresolved external symbol "public: virtual
__thiscall nsString::~nsString(void)" (??1nsString@@[EMAIL PROTECTED]) referenced
in function "public: virtual unsigned int __stdcall
MozFoo::DonneTexte(class nsIEditor *,char * *)"
([EMAIL PROTECTED]@@UAGIPAVnsIEditor@@[EMAIL PROTECTED])

The GetCurrentTextBlock method won't accept anything else than a
nsString, so I need to use that.  I tried using a nsEmbedString, then
casting the pointer to a nsString* when I passed it to the function,
and it worked partially.  I then needed to retrieve each letter of the
string individually

So basically, my questions are the following:

How can I use the nsString class without getting those linking errors?
 Where is that class defined?
Is there a way to retrieve the selected text other than the
GetCurrentTextBlock method from the nsITextServicesDocument interface?
How safe is it to use a class that has been marked as obsolete?

Thanks a lot.


Antoine.
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to