当前位置: 首页>>代码示例>>C++>>正文


C++ HyperTextAccessible::GetTextBeforeOffset方法代码示例

本文整理汇总了C++中HyperTextAccessible::GetTextBeforeOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ HyperTextAccessible::GetTextBeforeOffset方法的具体用法?C++ HyperTextAccessible::GetTextBeforeOffset怎么用?C++ HyperTextAccessible::GetTextBeforeOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HyperTextAccessible的用法示例。


在下文中一共展示了HyperTextAccessible::GetTextBeforeOffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

NS_IMETHODIMP
nsAccessiblePivot::MovePreviousByText(TextBoundaryType aBoundary, bool* aResult)
{
  NS_ENSURE_ARG(aResult);

  *aResult = false;

  int32_t oldStart = mStartOffset, oldEnd = mEndOffset;
  HyperTextAccessible* text = mPosition->AsHyperText();
  Accessible* oldPosition = mPosition;
  while (!text) {
    oldPosition = mPosition;
    mPosition = mPosition->Parent();
    text = mPosition->AsHyperText();
  }

  if (mStartOffset == -1)
    mStartOffset = text != oldPosition ? text->GetChildOffset(oldPosition) : 0;

  if (mStartOffset == 0)
    return NS_OK;

  AccessibleTextBoundary startBoundary, endBoundary;
  switch (aBoundary) {
    case CHAR_BOUNDARY:
      startBoundary = nsIAccessibleText::BOUNDARY_CHAR;
      endBoundary = nsIAccessibleText::BOUNDARY_CHAR;
      break;
    case WORD_BOUNDARY:
      startBoundary = nsIAccessibleText::BOUNDARY_WORD_START;
      endBoundary = nsIAccessibleText::BOUNDARY_WORD_END;
      break;
    default:
      return NS_ERROR_INVALID_ARG;
  }

  nsAutoString unusedText;
  int32_t newStart = 0, newEnd = 0;
  text->GetTextBeforeOffset(mStartOffset, startBoundary, &newStart, &newEnd,
                            unusedText);
  if (newStart < mStartOffset)
    mStartOffset = newEnd == mStartOffset ? newStart : newEnd;
  else // XXX: In certain odd cases newStart is equal to mStartOffset
    text->GetTextBeforeOffset(mStartOffset - 1, startBoundary, &newStart,
                              &mStartOffset, unusedText);
  text->GetTextAtOffset(mStartOffset, endBoundary, &newStart, &mEndOffset,
                        unusedText);

  *aResult = true;

  NotifyOfPivotChange(mPosition, oldStart, oldEnd,
                      nsIAccessiblePivot::REASON_TEXT);
  return NS_OK;
}
开发者ID:jsyeo,项目名称:mozilla-central,代码行数:54,代码来源:nsAccessiblePivot.cpp

示例2: cautoStr

static gchar*
getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
                      AtkTextBoundary aBoundaryType,
                      gint *aStartOffset, gint *aEndOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return nullptr;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return nullptr;

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

    NS_ENSURE_SUCCESS(rv, nullptr);

    ConvertTexttoAsterisks(accWrap, autoStr);
    NS_ConvertUTF16toUTF8 cautoStr(autoStr);
    return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:27,代码来源:nsMaiInterfaceText.cpp


注:本文中的HyperTextAccessible::GetTextBeforeOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。