summaryrefslogtreecommitdiff
path: root/starmath/inc
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2016-05-31 15:01:49 +0900
committerMichael Stahl <mstahl@redhat.com>2016-05-31 16:15:30 +0000
commit09981cd6383ecb99e4b6c83b98b03af5cf3ff59b (patch)
treed06db24d172ea9f7e5b8c052618e268d3014cfe9 /starmath/inc
parenta61063ca2cce4753a061693a50cccab95865ad6b (diff)
Use std::vector for SmCaretPosGraph
instead of employing ad hoc linked list and its iterator. Change-Id: Ibc4709a2e67aa805cf54117303c47d9a8a5eede9 Reviewed-on: https://gerrit.libreoffice.org/25699 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'starmath/inc')
-rw-r--r--starmath/inc/caret.hxx71
1 files changed, 17 insertions, 54 deletions
diff --git a/starmath/inc/caret.hxx b/starmath/inc/caret.hxx
index 0dff68094a18..de13ac97a32f 100644
--- a/starmath/inc/caret.hxx
+++ b/starmath/inc/caret.hxx
@@ -15,6 +15,9 @@
#include "node.hxx"
+#include <memory>
+#include <vector>
+
/** Representation of caret position with an equation */
struct SmCaretPos{
SmCaretPos(SmNode* selectedNode = nullptr, int iIndex = 0) {
@@ -117,74 +120,34 @@ struct SmCaretPosGraphEntry{
}
};
-class SmCaretPosGraph;
-
-/** Iterator for SmCaretPosGraph */
-class SmCaretPosGraphIterator{
-public:
- SmCaretPosGraphIterator(SmCaretPosGraph* graph){
- pGraph = graph;
- nOffset = 0;
- pEntry = nullptr;
- }
- /** Get the next entry, NULL if none */
- SmCaretPosGraphEntry* Next();
- /** Get the current entry, NULL if none */
- SmCaretPosGraphEntry* Current(){
- return pEntry;
- }
- /** Get the current entry, NULL if none */
- SmCaretPosGraphEntry* operator->(){
- return pEntry;
- }
-private:
- /** Next entry to return */
- int nOffset;
- /** Current graph */
- SmCaretPosGraph* pGraph;
- /** Current entry */
- SmCaretPosGraphEntry* pEntry;
-};
-
-
/** A graph over all caret positions
* @remarks Graphs can only grow, entries cannot be removed!
*/
class SmCaretPosGraph{
public:
- SmCaretPosGraph(){
- pNext = nullptr;
- nOffset = 0;
- }
+ SmCaretPosGraph();
+
~SmCaretPosGraph();
- /** Add a caret position
- * @remarks If Left and/or Right are set NULL, they will point back to the entry.
- */
- SmCaretPosGraphEntry* Add(SmCaretPosGraphEntry entry);
+
/** Add a caret position
* @remarks If left and/or right are set NULL, they will point back to the entry.
*/
SmCaretPosGraphEntry* Add(SmCaretPos pos,
SmCaretPosGraphEntry* left = nullptr,
- SmCaretPosGraphEntry* right = nullptr){
- SAL_WARN_IF( pos.Index < 0, "starmath", "Index shouldn't be -1!" );
- return Add(SmCaretPosGraphEntry(pos, left, right));
+ SmCaretPosGraphEntry* right = nullptr);
+
+ std::vector<std::unique_ptr<SmCaretPosGraphEntry>>::iterator begin()
+ {
+ return mvEntries.begin();
}
- /** Get an iterator for this graph */
- SmCaretPosGraphIterator GetIterator(){
- return SmCaretPosGraphIterator(this);
+
+ std::vector<std::unique_ptr<SmCaretPosGraphEntry>>::iterator end()
+ {
+ return mvEntries.end();
}
- friend class SmCaretPosGraphIterator;
-private:
- /** Define SmCaretPosGraph to be less than one page 4096 */
- static const int SmCaretPosGraphSize = 255;
- /** Next graph, to be used when this graph is full */
- SmCaretPosGraph* pNext;
- /** Next free entry in graph */
- int nOffset;
- /** Entries in this graph segment */
- SmCaretPosGraphEntry Graph[SmCaretPosGraphSize];
+private:
+ std::vector<std::unique_ptr<SmCaretPosGraphEntry>> mvEntries;
};
/** \page visual_formula_editing Visual Formula Editing