Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsMaiInterfaceText.cpp File Reference
#include "nsMaiInterfaceText.h"
#include "nsString.h"

Go to the source code of this file.

Functions

static G_BEGIN_DECLS void interfaceInitCB (AtkTextIface *aIface)
static gchar * getTextCB (AtkText *aText, gint aStartOffset, gint aEndOffset)
static gchar * getTextAfterOffsetCB (AtkText *aText, gint aOffset, AtkTextBoundary aBoundaryType, gint *aStartOffset, gint *aEndOffset)
static gchar * getTextAtOffsetCB (AtkText *aText, gint aOffset, AtkTextBoundary aBoundaryType, gint *aStartOffset, gint *aEndOffset)
static gunichar getCharacterAtOffsetCB (AtkText *aText, gint aOffset)
static gchar * getTextBeforeOffsetCB (AtkText *aText, gint aOffset, AtkTextBoundary aBoundaryType, gint *aStartOffset, gint *aEndOffset)
static gint getCaretOffsetCB (AtkText *aText)
static AtkAttributeSet * getRunAttributesCB (AtkText *aText, gint aOffset, gint *aStartOffset, gint *aEndOffset)
static AtkAttributeSet * getDefaultAttributesCB (AtkText *aText)
static void getCharacterExtentsCB (AtkText *aText, gint aOffset, gint *aX, gint *aY, gint *aWidth, gint *aHeight, AtkCoordType aCoords)
static gint getCharacterCountCB (AtkText *aText)
static gint getOffsetAtPointCB (AtkText *aText, gint aX, gint aY, AtkCoordType aCoords)
static gint getSelectionCountCB (AtkText *aText)
static gchar * getSelectionCB (AtkText *aText, gint aSelectionNum, gint *aStartOffset, gint *aEndOffset)
static gboolean addSelectionCB (AtkText *aText, gint aStartOffset, gint aEndOffset)
static gboolean removeSelectionCB (AtkText *aText, gint aSelectionNum)
static gboolean setSelectionCB (AtkText *aText, gint aSelectionNum, gint aStartOffset, gint aEndOffset)
static gboolean setCaretOffsetCB (AtkText *aText, gint aOffset)
void ConvertTexttoAsterisks (nsAccessibleWrap *accWrap, nsAString &aString)

Function Documentation

gboolean addSelectionCB ( AtkText *  aText,
gint  aStartOffset,
gint  aEndOffset 
) [static]

Definition at line 448 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, FALSE);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, FALSE);

    nsresult rv = accText->AddSelection(aStartOffset, aEndOffset);

    return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ConvertTexttoAsterisks ( nsAccessibleWrap accWrap,
nsAString &  aString 
)

Definition at line 155 of file nsMaiInterfaceText.cpp.

{
    // convert each char to "*" when it's "password text" 
    PRUint32 accRole;
    accWrap->GetRole(&accRole);
    if (NS_STATIC_CAST(AtkRole, accRole) == ATK_ROLE_PASSWORD_TEXT) {
        for (PRUint32 i = 0; i < aString.Length(); i++)
            aString.Replace(i, 1, NS_LITERAL_STRING("*"));
    }
}

Here is the caller graph for this function:

gint getCaretOffsetCB ( AtkText *  aText) [static]

Definition at line 300 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, 0);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, 0);

    PRInt32 offset;
    nsresult rv = accText->GetCaretOffset(&offset);
    return (NS_FAILED(rv)) ? 0 : NS_STATIC_CAST(gint, offset);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gunichar getCharacterAtOffsetCB ( AtkText *  aText,
gint  aOffset 
) [static]

Definition at line 245 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, 0);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, 0);

    /* PRUnichar is unsigned short in Mozilla */
    /* gnuichar is guint32 in glib */
    PRUnichar uniChar;
    nsresult rv =
        accText->GetCharacterAtOffset(aOffset, &uniChar);

    // convert char to "*" when it's "password text" 
    PRUint32 accRole;
    accWrap->GetRole(&accRole);
    if (NS_STATIC_CAST(AtkRole, accRole) == ATK_ROLE_PASSWORD_TEXT) {
        uniChar = '*';
    }

    return (NS_FAILED(rv)) ? 0 : NS_STATIC_CAST(gunichar, uniChar);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gint getCharacterCountCB ( AtkText *  aText) [static]

Definition at line 378 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, 0);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, 0);

    PRInt32 count = 0;
    nsresult rv = accText->GetCharacterCount(&count);
    return (NS_FAILED(rv)) ? 0 : NS_STATIC_CAST(gint, count);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getCharacterExtentsCB ( AtkText *  aText,
gint  aOffset,
gint *  aX,
gint *  aY,
gint *  aWidth,
gint *  aHeight,
AtkCoordType  aCoords 
) [static]

Definition at line 349 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    if(!accWrap)
        return;

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    if (!accText)
        return;

    PRInt32 extY = 0, extX = 0;
    PRInt32 extWidth = 0, extHeight = 0;
    nsresult rv = accText->GetCharacterExtents(aOffset, &extX, &extY,
                                               &extWidth, &extHeight,
                                               aCoords);
    *aX = extX;
    *aY = extY;
    *aWidth = extWidth;
    *aHeight = extHeight;
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
                     "MaiInterfaceText::GetCharacterExtents, failed\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

AtkAttributeSet * getDefaultAttributesCB ( AtkText *  aText) [static]

Definition at line 342 of file nsMaiInterfaceText.cpp.

{
    /* not supported ??? */
    return nsnull;
}

Here is the caller graph for this function:

gint getOffsetAtPointCB ( AtkText *  aText,
gint  aX,
gint  aY,
AtkCoordType  aCoords 
) [static]

Definition at line 394 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, 0);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, 0);

    PRInt32 offset = 0;
    nsresult rv = accText->GetOffsetAtPoint(aX, aY, aCoords, &offset);
    return (NS_FAILED(rv)) ? 0 : NS_STATIC_CAST(gint, offset);
}

Here is the call graph for this function:

Here is the caller graph for this function:

AtkAttributeSet * getRunAttributesCB ( AtkText *  aText,
gint  aOffset,
gint *  aStartOffset,
gint *  aEndOffset 
) [static]

Definition at line 316 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, nsnull);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, nsnull);

    nsCOMPtr<nsISupports> attrSet;
    PRInt32 startOffset = 0, endOffset = 0;
    nsresult rv = accText->GetAttributeRange(aOffset,
                                             &startOffset, &endOffset,
                                             getter_AddRefs(attrSet));
    *aStartOffset = startOffset;
    *aEndOffset = endOffset;
    NS_ENSURE_SUCCESS(rv, nsnull);

    /* what to do with the nsISupports ? ??? */
    return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gchar * getSelectionCB ( AtkText *  aText,
gint  aSelectionNum,
gint *  aStartOffset,
gint *  aEndOffset 
) [static]

Definition at line 423 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, nsnull);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, nsnull);

    PRInt32 startOffset = 0, endOffset = 0;
    nsresult rv = accText->GetSelectionBounds(aSelectionNum,
                                              &startOffset, &endOffset);

    *aStartOffset = startOffset;
    *aEndOffset = endOffset;

    NS_ENSURE_SUCCESS(rv, nsnull);

    return getTextCB(aText, *aStartOffset, *aEndOffset);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gint getSelectionCountCB ( AtkText *  aText) [static]

Definition at line 412 of file nsMaiInterfaceText.cpp.

{
    /* no implemetation in nsIAccessibleText??? */

    //new attribuate will be added in nsIAccessibleText.idl
    //readonly attribute long selectionCount;

    return 0;
}

Here is the caller graph for this function:

gchar * getTextAfterOffsetCB ( AtkText *  aText,
gint  aOffset,
AtkTextBoundary  aBoundaryType,
gint *  aStartOffset,
gint *  aEndOffset 
) [static]

Definition at line 189 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, nsnull);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, nsnull);

    nsAutoString autoStr;
    PRInt32 startOffset = 0, endOffset = 0;
    nsresult rv =
        accText->GetTextAfterOffset(aOffset, aBoundaryType,
                                    &startOffset, &endOffset, autoStr);
    *aStartOffset = startOffset;
    *aEndOffset = endOffset;

    NS_ENSURE_SUCCESS(rv, nsnull);

    ConvertTexttoAsterisks(accWrap, autoStr);
    NS_ConvertUTF16toUTF8 cautoStr(autoStr);
    return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gchar * getTextAtOffsetCB ( AtkText *  aText,
gint  aOffset,
AtkTextBoundary  aBoundaryType,
gint *  aStartOffset,
gint *  aEndOffset 
) [static]

Definition at line 217 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, nsnull);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, nsnull);

    nsAutoString autoStr;
    PRInt32 startOffset = 0, endOffset = 0;
    nsresult rv =
        accText->GetTextAtOffset(aOffset, aBoundaryType,
                                 &startOffset, &endOffset, autoStr);
    *aStartOffset = startOffset;
    *aEndOffset = endOffset;

    NS_ENSURE_SUCCESS(rv, nsnull);

    ConvertTexttoAsterisks(accWrap, autoStr);
    NS_ConvertUTF16toUTF8 cautoStr(autoStr);
    return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gchar * getTextBeforeOffsetCB ( AtkText *  aText,
gint  aOffset,
AtkTextBoundary  aBoundaryType,
gint *  aStartOffset,
gint *  aEndOffset 
) [static]

Definition at line 272 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, nsnull);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, nsnull);

    nsAutoString autoStr;
    PRInt32 startOffset = 0, endOffset = 0;
    nsresult rv =
        accText->GetTextBeforeOffset(aOffset, aBoundaryType,
                                     &startOffset, &endOffset, autoStr);
    *aStartOffset = startOffset;
    *aEndOffset = endOffset;

    NS_ENSURE_SUCCESS(rv, nsnull);

    ConvertTexttoAsterisks(accWrap, autoStr);
    NS_ConvertUTF16toUTF8 cautoStr(autoStr);
    return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gchar * getTextCB ( AtkText *  aText,
gint  aStartOffset,
gint  aEndOffset 
) [static]

Definition at line 167 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, nsnull);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, nsnull);

    nsAutoString autoStr;
    nsresult rv = accText->GetText(aStartOffset, aEndOffset, autoStr);
    NS_ENSURE_SUCCESS(rv, nsnull);

    ConvertTexttoAsterisks(accWrap, autoStr);
    NS_ConvertUTF16toUTF8 cautoStr(autoStr);

    //copy and return, libspi will free it.
    return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void interfaceInitCB ( AtkTextIface *  aIface) [static]

Definition at line 127 of file nsMaiInterfaceText.cpp.

{
    NS_ASSERTION(aIface, "Invalid aIface");
    if (!aIface)
        return;

    aIface->get_text = getTextCB;
    aIface->get_text_after_offset = getTextAfterOffsetCB;
    aIface->get_text_at_offset = getTextAtOffsetCB;
    aIface->get_character_at_offset = getCharacterAtOffsetCB;
    aIface->get_text_before_offset = getTextBeforeOffsetCB;
    aIface->get_caret_offset = getCaretOffsetCB;
    aIface->get_run_attributes = getRunAttributesCB;
    aIface->get_default_attributes = getDefaultAttributesCB;
    aIface->get_character_extents = getCharacterExtentsCB;
    aIface->get_character_count = getCharacterCountCB;
    aIface->get_offset_at_point = getOffsetAtPointCB;
    aIface->get_n_selections = getSelectionCountCB;
    aIface->get_selection = getSelectionCB;

    // set methods
    aIface->add_selection = addSelectionCB;
    aIface->remove_selection = removeSelectionCB;
    aIface->set_selection = setSelectionCB;
    aIface->set_caret_offset = setCaretOffsetCB;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean removeSelectionCB ( AtkText *  aText,
gint  aSelectionNum 
) [static]

Definition at line 466 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, FALSE);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, FALSE);

    nsresult rv = accText->RemoveSelection(aSelectionNum);

    return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean setCaretOffsetCB ( AtkText *  aText,
gint  aOffset 
) [static]

Definition at line 500 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, FALSE);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, FALSE);

    nsresult rv = accText->SetCaretOffset(aOffset);
    return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean setSelectionCB ( AtkText *  aText,
gint  aSelectionNum,
gint  aStartOffset,
gint  aEndOffset 
) [static]

Definition at line 483 of file nsMaiInterfaceText.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, FALSE);

    nsCOMPtr<nsIAccessibleText> accText;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                            getter_AddRefs(accText));
    NS_ENSURE_TRUE(accText, FALSE);

    nsresult rv = accText->SetSelectionBounds(aSelectionNum,
                                              aStartOffset, aEndOffset);
    return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function: