private string GetValue()
        {
            if (_type == WindowsEditBox.EditboxType.Password)
            {
                // Trying to retrieve the text (through WM_GETTEXT) from an edit box that has
                // the ES_PASSWORD style throws an UnauthorizedAccessException.
                throw new UnauthorizedAccessException();
            }

            if (IsDocument())
            {
                ITextRange range = _document.Range(0, 0);
                int        start = 0;
                int        end   = range.StoryLength;

                range.SetRange(start, end);

                string text = range.Text;
                // Empty edits contain a degenerate/empty range, and will return null
                // for their text - treat this as "", not null, since we do want to expose
                // a non-null value.
                if (string.IsNullOrEmpty(text))
                {
                    return("");
                }

                int embeddedObjectOffset = text.IndexOf((char)0xFFFC);
                if (embeddedObjectOffset != -1)
                {
                    StringBuilder sbText = new StringBuilder();
                    object        embeddedObject;
                    while (start < end && embeddedObjectOffset != -1)
                    {
                        sbText.Append(text.Substring(start, embeddedObjectOffset - start));
                        range.SetRange(embeddedObjectOffset, end);
                        if (range.GetEmbeddedObject(out embeddedObject) == NativeMethods.S_OK && embeddedObject != null)
                        {
                            GetEmbeddedObjectText(embeddedObject, sbText);
                        }
                        else
                        {
                            // If there is some kind of error, just append a space to the text.  In this way
                            // we will be no worse of then before implementing the embedded object get text.
                            sbText.Append(" ");
                        }
                        start = embeddedObjectOffset + 1;
                        embeddedObjectOffset = text.IndexOf((char)0xFFFC, start);
                    }

                    if (start < end)
                    {
                        sbText.Append(text.Substring(start, end - start));
                    }

                    text = sbText.ToString();
                }

                return(text);
            }
            else
            {
                return(Misc.ProxyGetText(_hwnd));
            }
        }