]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/mathml_editor/src/TDocument.hh
* this is a large commit
[helm.git] / helm / DEVEL / mathml_editor / src / TDocument.hh
1
2 #ifndef __TDocument_hh__
3 #define __TDocument_hh__
4
5 #include "dom.hh"
6 #include "TNode.hh"
7
8 class TDocument : private DOM::EventListener
9 {
10 public:
11   TDocument(void);
12   ~TDocument();
13
14   TNode create(const std::string&, unsigned = 0) const;
15   TNode createG(unsigned id = 0) const { return create("g", id); };
16   TNode createC(const std::string&, unsigned = 0) const;
17   TNode createT(const std::string&, const std::string&, unsigned = 0) const;
18   TNode createI(const std::string& text, unsigned id = 0) const { return createT("i", text, id); };
19   TNode createN(const std::string& text, unsigned id = 0) const { return createT("n", text, id); };
20   TNode createO(const std::string& text, unsigned id = 0) const { return createT("o", text, id); };
21
22   DOM::Document document(void) const { return doc; };
23
24   TNode getNodeById(unsigned) const;
25   TNode root(void) { return doc.get_documentElement(); };
26   TNode dirtyNode(void) const { return dirty; };
27   void  clearDirty(void) { dirty = DOM::Element(0); };
28
29   void  serialize(const char*) const;
30
31 private:
32   DOM::Document doc;
33   DOM::Element dirty;
34
35   virtual void handleEvent(const DOM::Event&);
36   static std::string makeId(unsigned);
37   static TNode getNodeByIdAux(const TNode&, const std::string&);
38   static unsigned nodeDepth(const DOM::Node&);
39   static DOM::Node findCommonAncestor(const DOM::Node&, const DOM::Node&);
40   static DOM::Node findIdNode(const DOM::Node&);
41 };
42
43 #endif // __TDocument_hh__