more styling
[roojs1] / Roo / rtf / Document.js
1
2 // this looks like it's normally the {rtf{ .... }}
3 Roo.rtf.Document = function()
4 {
5     // we dont want to acutally store parent - it will make debug a nightmare..
6     this.rtlch  = [];
7     this.content = [];
8     this.cn = [];
9     
10 };
11 Roo.extend(Roo.rtf.Document, Roo.rtf.Group, { 
12     addChild : function(cn)
13     {
14         this.cn.push(cn);
15         switch(cn.type) {
16             case 'rtlch': // most content seems to be inside this??
17             case 'listtext':
18             case 'shpinst':
19                 this.rtlch.push(cn);
20                 return;
21             default:
22                 this[cn.type] = cn;
23         }
24         
25     },
26     
27     getElementsByType : function(type)
28     {
29         var ret =  [];
30         this._getElementsByType(type, ret, this.cn, 'rtf');
31         return ret;
32     },
33     _getElementsByType : function (type, ret, search_array, path)
34     {
35         search_array.forEach(function(n,i) {
36             if (n.type == type) {
37                 n.path = path + '/' + n.type + ':' + i;
38                 ret.push(n);
39             }
40             if (n.cn.length > 0) {
41                 this._getElementsByType(type, ret, n.cn, path + '/' + n.type+':'+i);
42             }
43         },this);
44     }
45     
46 });