Neil Deakin <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> 
> If you're using an editor (nsIEditor), you can just call GetSelection to 
> get the selection. It will be an nsISelection. The text is available via 
> ToString() which has a return type of PRUnichar *;
> 
> / Neil


I can now easily retrieve a selected text with that GetSelection
method without resorting to the nsString class.  Now, what if I want
to insert text in the editor?  Can I do it without the obsolete
nsString class?

Once again looking at the spell checker code, I see that it inserts
text with the ReplaceWord method of the nsEditorSpellCheck class
(http://lxr.mozilla.org/seamonkey/source/editor/composer/src/nsEditorSpellCheck.cpp#246),
giving it a PRUnichar string as a parameter, and that method calls the
Replace method of the mozSpellChecker class
(http://lxr.mozilla.org/seamonkey/source/extensions/spellcheck/src/mozSpellChecker.cpp#151)
giving it a nsAString string as a parameter.  So far so good. 
However, this Replace method uses a nsAutoString (with a "// sigh"
comment), which is a subclass from nsString, so it can call the
InsertText method of the nsTextServicesDocument class
(http://lxr.mozilla.org/seamonkey/source/editor/txtsvc/src/nsTextServicesDocument.cpp#2143)

When I try to use a nsAutoString, I figure out that I need to link to
the string_s.lib library in the \mozilla\xpcom\string\src directory to
work around all the "unresolved external symbol" errors I get. 
However, since I also need to link to embedstring.lib in the
\mozilla\dist\sdk\embedstring\bin directory, I get the following
errors :

mozAntidote error LNK2005: "unsigned int __cdecl Distance(class
nsReadingIterator<char> const &,class nsReadingIterator<char> const
&)" (?Distance@@[EMAIL PROTECTED]@@[EMAIL PROTECTED]) already defined in
embedstring.lib(nsEmbedString.obj)
mozAntidote error LNK2005: "unsigned int __cdecl Distance(class
nsReadingIterator<unsigned short> const &,class
nsReadingIterator<unsigned short> const &)"
(?Distance@@[EMAIL PROTECTED]@@[EMAIL PROTECTED]) already defined in
embedstring.lib(nsEmbedString.obj)


I've tried other ways:
Using the InsertText method of the nsPlaintextEditor class, which only
requires a nsAString.  nsAString being abstract, I used a
nsEmbedString, which derives from nsAString, but that made Mozilla
crash.
Using the same function, I tried passing a nsDependentString, which is
supposed to let a constant litteral string act as a nsAString, but
that also made Mozilla crash.


That's about all the solutions I can think of right now, and none of
them seem to work.  Is there still a way to insert text into an editor
without using nsString? And if not, how can I use nsString while still
linking with embedstring.lib?


Thanks in advance


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

Reply via email to