]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/mathml_editor/src/TDocument.hh
Initial revision
[helm.git] / helm / DEVEL / mathml_editor / src / TDocument.hh
diff --git a/helm/DEVEL/mathml_editor/src/TDocument.hh b/helm/DEVEL/mathml_editor/src/TDocument.hh
new file mode 100644 (file)
index 0000000..cf4b7c3
--- /dev/null
@@ -0,0 +1,40 @@
+
+#ifndef __TDocument_hh__
+#define __TDocument_hh__
+
+#include "dom.hh"
+#include "TNode.hh"
+
+class TDocument : private DOM::EventListener
+{
+public:
+  TDocument(void);
+  ~TDocument();
+
+  TNode create(const std::string&, unsigned = 0) const;
+  TNode createG(unsigned id = 0) const { return create("g", id); };
+  TNode createC(const std::string&, unsigned = 0) const;
+  TNode createT(const std::string&, const std::string&, unsigned = 0) const;
+  TNode createI(const std::string& text, unsigned id = 0) const { return createT("i", text, id); };
+  TNode createN(const std::string& text, unsigned id = 0) const { return createT("n", text, id); };
+  TNode createO(const std::string& text, unsigned id = 0) const { return createT("o", text, id); };
+
+  DOM::Document document(void) const { return doc; };
+
+  TNode root(void) { return doc.get_documentElement(); };
+  TNode dirtyNode(void) const { return dirty; };
+  void  clearDirty(void) { dirty = DOM::Element(0); };
+
+  void  serialize(const char*) const;
+
+private:
+  DOM::Document doc;
+  DOM::Element dirty;
+
+  virtual void handleEvent(const DOM::Event&);
+  static unsigned nodeDepth(const DOM::Node&);
+  static DOM::Node findCommonAncestor(const DOM::Node&, const DOM::Node&);
+  static DOM::Node findIdNode(const DOM::Node&);
+};
+
+#endif // __TDocument_hh__