NVDA Helper
In-process and lite high-speed utilities for NVDA
|
a buffer that can store text with overlaying fields. More...
#include <storage.h>
Public Member Functions | |
VBufStorage_buffer_t () | |
~VBufStorage_buffer_t () | |
Destructor. | |
VBufStorage_controlFieldNode_t * | addControlFieldNode (VBufStorage_controlFieldNode_t *parent, VBufStorage_fieldNode_t *previous, int docHandle, int ID, bool isBlock) |
Adds a control field in to the buffer. | |
VBufStorage_controlFieldNode_t * | addControlFieldNode (VBufStorage_controlFieldNode_t *parent, VBufStorage_fieldNode_t *previous, VBufStorage_controlFieldNode_t *node) |
VBufStorage_textFieldNode_t * | addTextFieldNode (VBufStorage_controlFieldNode_t *parent, VBufStorage_fieldNode_t *previous, const std::wstring &text) |
Adds a text field in to the buffer. | |
VBufStorage_textFieldNode_t * | addTextFieldNode (VBufStorage_controlFieldNode_t *parent, VBufStorage_fieldNode_t *previous, VBufStorage_textFieldNode_t *node) |
virtual bool | isNodeInBuffer (VBufStorage_fieldNode_t *node) |
finds out if the given node exists in this buffer. | |
bool | replaceSubtrees (std::map< VBufStorage_fieldNode_t *, VBufStorage_buffer_t * > &m) |
Removes the given nodes from the buffer and then merges the content of the new buffers in the removed node's position. | |
bool | removeFieldNode (VBufStorage_fieldNode_t *node, bool removeDescendants=true) |
disassociates from this buffer, and deletes, the given field and its descendants. | |
void | clearBuffer () |
virtual bool | getFieldNodeOffsets (VBufStorage_fieldNode_t *node, int *startOffset, int *endOffset) |
Calculates the start and end character offsets of the given node in the buffer. | |
virtual bool | isFieldNodeAtOffset (VBufStorage_fieldNode_t *node, int offset) |
finds out if a given field is positioned at a given character offset in this buffer. | |
virtual VBufStorage_textFieldNode_t * | locateTextFieldNodeAtOffset (int offset, int *nodeStartOffset, int *nodeEndOffset) |
locates the text field node at the given offset | |
virtual VBufStorage_controlFieldNode_t * | locateControlFieldNodeAtOffset (int offset, int *startOffset, int *endOffset, int *docHandle, int *ID) |
locates the deepest control field node at the given offset | |
virtual VBufStorage_controlFieldNode_t * | getControlFieldNodeWithIdentifier (int docHandle, int ID) |
locates the controlFieldNode with the given identifier | |
virtual bool | getIdentifierFromControlFieldNode (VBufStorage_controlFieldNode_t *node, int *docHandle, int *ID) |
Retreaves the identifier for the given controlFieldNode. | |
virtual VBufStorage_fieldNode_t * | findNodeByAttributes (int offset, VBufStorage_findDirection_t direction, const std::wstring &attribs, const std::wstring ®exp, int *startOffset, int *endOffset) |
Finds a field node that contains particular attributes. | |
virtual bool | getSelectionOffsets (int *startOffset, int *endOffset) const |
Retreaves the current selection offsets for the buffer. | |
virtual bool | setSelectionOffsets (int startOffset, int endOffset) |
sets the selection offsets for the buffer. | |
virtual int | getTextLength () const |
retreaves the length of all the text in the buffer. | |
virtual bool | getTextInRange (int startOffset, int endOffset, std::wstring &text, bool useMarkup=false) |
Retreaves the text in the buffer between given offsets, optionally containing markup. | |
virtual bool | getLineOffsets (int offset, int maxLineLength, bool useScreenLayout, int *startOffset, int *endOffset) |
Expands the given offset to the start and end offsets of the containing line. | |
virtual bool | hasContent () |
Does this buffer have content? true if there is content, false otherwise. | |
virtual bool | isDescendantNode (VBufStorage_fieldNode_t *parent, VBufStorage_fieldNode_t *descendant) |
Is one node a descendant of another. | |
VBufStorage_referenceNode_t * | addReferenceNodeToBuffer (VBufStorage_controlFieldNode_t *parent, VBufStorage_fieldNode_t *previous, VBufStorage_controlFieldNode_t *node) |
Adds a reference node to the buffer at the location given by parent and previous, pointing to the given existing node in another buffer. | |
virtual std::wstring | getDebugInfo () const |
Protected Member Functions | |
bool | unlinkFieldNode (VBufStorage_fieldNode_t *node, bool removeDescendants=true) |
Unlinks this node from its parent and siblings. | |
void | forgetControlFieldNode (VBufStorage_controlFieldNode_t *node) |
removes the controlFieldNode from the buffer's controlFieldNodesByIdentifier set. | |
bool | insertNode (VBufStorage_controlFieldNode_t *parent, VBufStorage_fieldNode_t *previous, VBufStorage_fieldNode_t *node) |
Inserts the given fieldNode in to the buffer's tree of nodes. | |
void | deleteSubtree (VBufStorage_fieldNode_t *node) |
disassociates the given node and its descendants from this buffer and deletes the node and its descendants. | |
void | deleteNode (VBufStorage_fieldNode_t *node) |
disassociates the given node from this buffer and deletes the node. | |
Protected Attributes | |
std::list< VBufStorage_referenceNode_t * > | referenceNodes |
Holds all the reference nodes for this buffer. | |
VBufStorage_fieldNode_t * | rootNode |
points to the first node in the tree of nodes. | |
std::set< VBufStorage_fieldNode_t * > | nodes |
Holds pointers to all nodes in the buffer. | |
std::map< VBufStorage_controlFieldNodeIdentifier_t, VBufStorage_controlFieldNode_t * > | controlFieldNodesByIdentifier |
holds pointers to all control field nodes in this buffer, searchable by the control's unique identifier. | |
int | selectionStart |
the offset at where the current selection starts. | |
int | selectionLength |
The length of the selection. | |
Friends | |
class | VBufStorage_fieldNode_t |
class | VBufStorage_controlFieldNode_t |
class | VBufStorage_textFieldNode_t |
a buffer that can store text with overlaying fields.
it stores the text and fields in an internal tree of nodes.
VBufStorage_buffer_t::VBufStorage_buffer_t | ( | ) |
References LOG_DEBUG.
Referenced by VBufBackend_t::update().
VBufStorage_buffer_t::~VBufStorage_buffer_t | ( | ) |
Destructor.
References clearBuffer(), and LOG_DEBUG.
|
protected |
Unlinks this node from its parent and siblings.
Note that this does not actually delete the node, nore unregister it from the buffer in any other way. This is used internally by removeFieldNode and replaceSubtrees.
node | the node to unlink |
removeDescendants | if true then its simblings will be appropriately linked to close the gab, but if false, this node's children will be reparented on this node's parent, linking with this node's siblings. |
References VBufStorage_fieldNode_t::firstChild, isNodeInBuffer(), VBufStorage_fieldNode_t::lastChild, VBufStorage_fieldNode_t::length, LOG_DEBUG, LOG_DEBUGWARNING, VBufStorage_fieldNode_t::next, nhAssert, VBufStorage_fieldNode_t::parent, VBufStorage_fieldNode_t::previous, and rootNode.
Referenced by removeFieldNode(), and replaceSubtrees().
|
protected |
removes the controlFieldNode from the buffer's controlFieldNodesByIdentifier set.
References controlFieldNodesByIdentifier, VBufStorage_controlFieldNode_t::identifier, and nhAssert.
Referenced by VBufStorage_controlFieldNode_t::disassociateFromBuffer().
|
protected |
Inserts the given fieldNode in to the buffer's tree of nodes.
Makes all needed connections with other nodes in the buffer's node tree.
parent | a control field already in the buffer that should be the inserted node's parent, note if also specifying previous then parent can be NULL. |
previous | the field already in the buffer that the inserted node will come directly after, note previous's parent will always be used over the parent argument. |
node | the node being inserted. |
References VBufStorage_fieldNode_t::firstChild, VBufStorage_controlFieldNode_t::getDebugInfo(), VBufStorage_fieldNode_t::getDebugInfo(), isNodeInBuffer(), VBufStorage_fieldNode_t::lastChild, VBufStorage_fieldNode_t::length, LOG_DEBUG, LOG_DEBUGWARNING, VBufStorage_fieldNode_t::next, nhAssert, nodes, VBufStorage_fieldNode_t::parent, VBufStorage_fieldNode_t::previous, and rootNode.
Referenced by addControlFieldNode(), addTextFieldNode(), and replaceSubtrees().
|
protected |
disassociates the given node and its descendants from this buffer and deletes the node and its descendants.
node | the node you wish to delete. |
References deleteNode(), deleteSubtree(), VBufStorage_fieldNode_t::firstChild, VBufStorage_fieldNode_t::getDebugInfo(), LOG_DEBUG, VBufStorage_fieldNode_t::next, and nhAssert.
Referenced by deleteSubtree(), and removeFieldNode().
|
protected |
disassociates the given node from this buffer and deletes the node.
node | the node you wish to delete. |
References VBufStorage_fieldNode_t::disassociateFromBuffer(), LOG_DEBUG, nhAssert, and nodes.
Referenced by deleteSubtree(), and removeFieldNode().
VBufStorage_controlFieldNode_t * VBufStorage_buffer_t::addControlFieldNode | ( | VBufStorage_controlFieldNode_t * | parent, |
VBufStorage_fieldNode_t * | previous, | ||
int | docHandle, | ||
int | ID, | ||
bool | isBlock ) |
Adds a control field in to the buffer.
parent | the control field which should be the new field's parent, note that if also specifying previous parent can be NULL. |
previous | the field which the new field should come directly after, note that previous's parent will be used over the parent argument, and previous can also not be the buffer's root node (first field added). |
docHandle | the docHandle you wish the new control field node to have |
ID | the ID you wish the new control field node to have. |
isBlock | if true then the buffer will force a line break at the start and end of the new control. |
References addControlFieldNode(), VBufStorage_controlFieldNode_t::getDebugInfo(), LOG_DEBUG, LOG_DEBUGWARNING, nhAssert, and VBufStorage_controlFieldNode_t.
Referenced by addControlFieldNode(), addReferenceNodeToBuffer(), MshtmlVBufBackend_t::fillVBuf(), and lotusNotesRichTextVBufBackend_t::render().
VBufStorage_controlFieldNode_t * VBufStorage_buffer_t::addControlFieldNode | ( | VBufStorage_controlFieldNode_t * | parent, |
VBufStorage_fieldNode_t * | previous, | ||
VBufStorage_controlFieldNode_t * | node ) |
VBufStorage_textFieldNode_t * VBufStorage_buffer_t::addTextFieldNode | ( | VBufStorage_controlFieldNode_t * | parent, |
VBufStorage_fieldNode_t * | previous, | ||
const std::wstring & | text ) |
Adds a text field in to the buffer.
parent | the control field which should be the new field's parent, note that if also specifying previous, parent can be NULL. |
previous | the field which the new field should come directly after, note that previous's parent will be used over the parent argument, and previous can also not be the buffer's root node (first field added). |
text | the text that this field will contain. |
References VBufStorage_fieldNode_t::addAttribute(), addTextFieldNode(), VBufStorage_textFieldNode_t::getDebugInfo(), isPrivateCharacter(), LOG_DEBUG, LOG_DEBUGWARNING, nhAssert, and VBufStorage_textFieldNode_t.
Referenced by addTextFieldNode(), MshtmlVBufBackend_t::fillVBuf(), and renderText().
VBufStorage_textFieldNode_t * VBufStorage_buffer_t::addTextFieldNode | ( | VBufStorage_controlFieldNode_t * | parent, |
VBufStorage_fieldNode_t * | previous, | ||
VBufStorage_textFieldNode_t * | node ) |
References insertNode(), LOG_DEBUG, and LOG_DEBUGWARNING.
|
virtual |
finds out if the given node exists in this buffer.
node | the node you wish to check. |
References nodes.
Referenced by getFieldNodeOffsets(), getIdentifierFromControlFieldNode(), insertNode(), VBufBackend_t::invalidateSubtree(), isFieldNodeAtOffset(), and unlinkFieldNode().
bool VBufStorage_buffer_t::replaceSubtrees | ( | std::map< VBufStorage_fieldNode_t *, VBufStorage_buffer_t * > & | m | ) |
Removes the given nodes from the buffer and then merges the content of the new buffers in the removed node's position.
It also tries to keep the selection relative to the control field it was in before the replacement.
m | the map of nodes to buffers |
References clearBuffer(), controlFieldNodesByIdentifier, getControlFieldNodeWithIdentifier(), getFieldNodeOffsets(), getTextLength(), VBufStorage_controlFieldNode_t::identifier, insertNode(), VBufStorage_fieldNode_t::length, locateControlFieldNodeAtOffset(), LOG_DEBUGWARNING, nhAssert, nodes, VBufStorage_fieldNode_t::parent, VBufStorage_fieldNode_t::previous, removeFieldNode(), rootNode, selectionStart, and unlinkFieldNode().
Referenced by VBufBackend_t::update().
bool VBufStorage_buffer_t::removeFieldNode | ( | VBufStorage_fieldNode_t * | node, |
bool | removeDescendants = true ) |
disassociates from this buffer, and deletes, the given field and its descendants.
node | the node you wish to remove. |
removeDescedants | true if descendants should be removed, false otherwise. |
References deleteNode(), deleteSubtree(), LOG_DEBUGWARNING, and unlinkFieldNode().
Referenced by replaceSubtrees().
void VBufStorage_buffer_t::clearBuffer | ( | ) |
|
virtual |
Calculates the start and end character offsets of the given node in the buffer.
node | the node you want the offsets of. |
startOffset | memory where this method can place the found start offset. |
endOffset | memory where this method can place the found end offset. |
References VBufStorage_fieldNode_t::calculateOffsetInTree(), isNodeInBuffer(), VBufStorage_fieldNode_t::length, LOG_DEBUG, and LOG_DEBUGWARNING.
Referenced by isFieldNodeAtOffset(), replaceSubtrees(), and VBufRemote_getFieldNodeOffsets().
|
virtual |
finds out if a given field is positioned at a given character offset in this buffer.
node | the field you are interested in. |
offset | the character offset you are interested in. |
References getFieldNodeOffsets(), getTextLength(), isNodeInBuffer(), LOG_DEBUG, and LOG_DEBUGWARNING.
Referenced by VBufRemote_isFieldNodeAtOffset().
|
virtual |
locates the text field node at the given offset
offset | the offset to use |
nodeStartOffset | memory where the found text field's start offset will be placed. |
nodeEndOffset | memory where the found text field's end offset will be placed. |
References getTextLength(), VBufStorage_fieldNode_t::length, VBufStorage_fieldNode_t::locateTextFieldNodeAtOffset(), LOG_DEBUG, LOG_DEBUGWARNING, and rootNode.
Referenced by findNodeByAttributes(), getLineOffsets(), locateControlFieldNodeAtOffset(), and VBufRemote_locateTextFieldNodeAtOffset().
|
virtual |
locates the deepest control field node at the given offset
offset | the offset to use |
startOffset | memory where the found text field's start offset will be placed. |
endOffset | memory where the found text field's end offset will be placed. |
docHandle | memory where the docHandle of the found control field node will be placed. |
ID | memory where the ID of the found control field node will be placed. |
References VBufStorage_controlFieldNodeIdentifier_t::docHandle, VBufStorage_controlFieldNode_t::getDebugInfo(), VBufStorage_controlFieldNodeIdentifier_t::ID, VBufStorage_controlFieldNode_t::identifier, VBufStorage_fieldNode_t::length, locateTextFieldNodeAtOffset(), LOG_DEBUG, LOG_DEBUGWARNING, nhAssert, VBufStorage_fieldNode_t::parent, and VBufStorage_fieldNode_t::previous.
Referenced by replaceSubtrees(), and VBufRemote_locateControlFieldNodeAtOffset().
|
virtual |
locates the controlFieldNode with the given identifier
docHandle | the docHandle of the control field node you wish to find |
ID | the ID of the control field node you wish to find |
References controlFieldNodesByIdentifier, LOG_DEBUG, and nhAssert.
Referenced by MshtmlVBufBackend_t::fillVBuf(), MshtmlVBufBackend_t::getDeepestControlFieldNodeForHTMLElement(), AdobeAcrobatVBufBackend_t::renderThread_winEventProcHook(), GeckoVBufBackend_t::renderThread_winEventProcHook(), lotusNotesRichTextVBufBackend_t::renderThread_winEventProcHook(), WebKitVBufBackend_t::renderThread_winEventProcHook(), replaceSubtrees(), VBufBackend_t::reuseExistingNodeInRender(), and VBufRemote_getControlFieldNodeWithIdentifier().
|
virtual |
Retreaves the identifier for the given controlFieldNode.
node | the controlFieldNode who's identifier should be retreaved. |
docHandle | a memory address where the docHandle should be placed. |
ID | a memory address where the ID should be placed. |
References VBufStorage_controlFieldNodeIdentifier_t::docHandle, VBufStorage_controlFieldNodeIdentifier_t::ID, VBufStorage_controlFieldNode_t::identifier, isNodeInBuffer(), and LOG_DEBUGWARNING.
Referenced by VBufRemote_getIdentifierFromControlFieldNode().
|
virtual |
Finds a field node that contains particular attributes.
offset | offset in the buffer to start searching from, if -1 then starts at the root of the buffer. |
direction | which direction to search |
attribs | the attributes to search |
regexp | regular expression the requested attributes must match |
startOffset | memory where the start offset of the found node can be placed |
endOffset | memory where the end offset of the found node will be placed |
References VBufStorage_fieldNode_t::getDebugInfo(), VBufStorage_fieldNode_t::isHidden, VBufStorage_fieldNode_t::length, locateTextFieldNodeAtOffset(), LOG_DEBUG, LOG_DEBUGWARNING, LOG_ERROR, VBufStorage_fieldNode_t::matchAttributes(), VBufStorage_fieldNode_t::nextNodeInTree(), VBufStorage_fieldNode_t::parent, VBufStorage_fieldNode_t::previous, rootNode, TREEDIRECTION_BACK, TREEDIRECTION_FORWARD, VBufStorage_findDirection_back, VBufStorage_findDirection_forward, and VBufStorage_findDirection_up.
Referenced by VBufRemote_findNodeByAttributes().
Retreaves the current selection offsets for the buffer.
startOffset | memory where the start offset of the selection will be placed |
endOffset | memory where the end offset of the selection will be placed |
References VBufStorage_fieldNode_t::length, LOG_DEBUG, nhAssert, rootNode, selectionLength, and selectionStart.
Referenced by VBufRemote_getSelectionOffsets().
sets the selection offsets for the buffer.
startOffset | the offset the start of the selection should be set to. |
endOffset | the offset the end of the selection should be set to. |
References LOG_DEBUG, LOG_DEBUGWARNING, selectionLength, and selectionStart.
Referenced by VBufRemote_setSelectionOffsets().
|
virtual |
retreaves the length of all the text in the buffer.
References VBufStorage_fieldNode_t::length, LOG_DEBUG, and rootNode.
Referenced by isFieldNodeAtOffset(), locateTextFieldNodeAtOffset(), replaceSubtrees(), and VBufRemote_getTextLength().
|
virtual |
Retreaves the text in the buffer between given offsets, optionally containing markup.
startOffset | the offset to start from |
endOffset | the offset to end at. Use -1 to mean end of buffer. |
text | where to place the found text |
useMarkup | if true then markup is included in the text denoting field starts and ends. |
References VBufStorage_fieldNode_t::getTextInRange(), VBufStorage_fieldNode_t::length, LOG_DEBUG, LOG_DEBUGWARNING, and rootNode.
Referenced by VBufRemote_getTextInRange().
|
virtual |
Expands the given offset to the start and end offsets of the containing line.
offset | the offset to expand. |
maxLineLength | the maximum length of a line. |
useScreenLayout | if true then lines will only break on block controls or line feed characters, if false then lines will break on all field nodes. |
startOffset | memory to place the calculated line start offset |
endOffset | memory to place the calculated line end offset |
References VBufStorage_fieldNode_t::firstChild, VBufStorage_fieldNode_t::getDebugInfo(), VBufStorage_fieldNode_t::getTextInRange(), VBufStorage_fieldNode_t::isBlock, VBufStorage_fieldNode_t::length, locateTextFieldNodeAtOffset(), LOG_DEBUG, LOG_DEBUGWARNING, VBufStorage_fieldNode_t::nextNodeInTree(), VBufStorage_fieldNode_t::parent, rootNode, TREEDIRECTION_FORWARD, and TREEDIRECTION_SYMMETRICAL_BACK.
Referenced by VBufRemote_getLineOffsets().
|
virtual |
Does this buffer have content? true if there is content, false otherwise.
References rootNode.
Referenced by VBufBackend_t::update().
|
virtual |
Is one node a descendant of another.
parent | the parent node. |
descendant | the descendant node. |
References LOG_DEBUG, nhAssert, and VBufStorage_fieldNode_t::parent.
VBufStorage_referenceNode_t * VBufStorage_buffer_t::addReferenceNodeToBuffer | ( | VBufStorage_controlFieldNode_t * | parent, |
VBufStorage_fieldNode_t * | previous, | ||
VBufStorage_controlFieldNode_t * | node ) |
Adds a reference node to the buffer at the location given by parent and previous, pointing to the given existing node in another buffer.
parent | the parent in this buffer of the added reference node. |
previous | the previous node in this buffer of the added reference node. |
node | the existing node from another buffer that the reference node should point to. |
References addControlFieldNode(), VBufStorage_controlFieldNodeIdentifier_t::docHandle, VBufStorage_controlFieldNodeIdentifier_t::ID, VBufStorage_controlFieldNode_t::identifier, and referenceNodes.
|
virtual |
References selectionLength, and selectionStart.
|
friend |
|
friend |
Referenced by addControlFieldNode().
|
friend |
Referenced by addTextFieldNode().
|
protected |
Holds all the reference nodes for this buffer.
Referenced by addReferenceNodeToBuffer().
|
protected |
points to the first node in the tree of nodes.
Referenced by clearBuffer(), findNodeByAttributes(), getLineOffsets(), getSelectionOffsets(), getTextInRange(), getTextLength(), hasContent(), insertNode(), locateTextFieldNodeAtOffset(), replaceSubtrees(), and unlinkFieldNode().
|
protected |
Holds pointers to all nodes in the buffer.
Referenced by clearBuffer(), deleteNode(), insertNode(), isNodeInBuffer(), and replaceSubtrees().
|
protected |
holds pointers to all control field nodes in this buffer, searchable by the control's unique identifier.
Referenced by addControlFieldNode(), clearBuffer(), forgetControlFieldNode(), getControlFieldNodeWithIdentifier(), and replaceSubtrees().
|
protected |
the offset at where the current selection starts.
Referenced by clearBuffer(), getDebugInfo(), getSelectionOffsets(), replaceSubtrees(), and setSelectionOffsets().
|
protected |
The length of the selection.
Referenced by clearBuffer(), getDebugInfo(), getSelectionOffsets(), and setSelectionOffsets().