diff options
author | Bence Babati <b.baabsi@gmail.com> | 2012-08-22 15:26:44 +0200 |
---|---|---|
committer | Andras Timar <atimar@suse.com> | 2012-08-22 16:50:39 +0200 |
commit | d9eec8f0f0b4ff397dedbfc2041c79c45af4d4a1 (patch) | |
tree | 951b64c639e29e40c0c563d597717b4f842b3e54 /xmlhelp | |
parent | e47fe5cc409b4df2ee3ae58ecf911c1e155bf2e7 (diff) |
embed extension's help tree into main help tree
Change-Id: Iddb3c542f50078b13c7d420b528aa704a5cb0767
Diffstat (limited to 'xmlhelp')
-rw-r--r-- | xmlhelp/source/treeview/tvread.cxx | 83 | ||||
-rw-r--r-- | xmlhelp/source/treeview/tvread.hxx | 4 |
2 files changed, 80 insertions, 7 deletions
diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx index 8357a3bc7f0f..387ba141d436 100644 --- a/xmlhelp/source/treeview/tvread.cxx +++ b/xmlhelp/source/treeview/tvread.cxx @@ -75,6 +75,13 @@ namespace treeview { return children.back(); } + TVDom* newChild(TVDom* p) + { + children.push_back( p ); + p->parent = this; + return children.back(); + } + TVDom* getParent() const { @@ -485,8 +492,6 @@ extern "C" void data_handler( void *userData, (*tvDom)->setTitle( s,len ); } - - TVChildTarget::TVChildTarget( const ConfigData& configData,TVDom* tvDom ) { Elements.resize( tvDom->children.size() ); @@ -494,10 +499,6 @@ TVChildTarget::TVChildTarget( const ConfigData& configData,TVDom* tvDom ) Elements[i] = new TVRead( configData,tvDom->children[i] ); } - - - - TVChildTarget::TVChildTarget( const Reference< XMultiServiceFactory >& xMSF ) { ConfigData configData = init( xMSF ); @@ -534,8 +535,9 @@ TVChildTarget::TVChildTarget( const Reference< XMultiServiceFactory >& xMSF ) XML_ParserFree( parser ); delete[] s; - } + Check(pTVDom); + } // now TVDom holds the relevant information Elements.resize( tvDom.children.size() ); @@ -548,7 +550,74 @@ TVChildTarget::~TVChildTarget() { } +void TVChildTarget::Check(TVDom* tvDom) +{ + unsigned i = 0; + bool h = false; + + while((i<tvDom->children.size()-1) && (!h)) + { + if (((tvDom->children[i])->application == (tvDom->children[tvDom->children.size()-1])->application) && + ((tvDom->children[i])->id == (tvDom->children[tvDom->children.size()-1])->id)) + { + TVDom* p = tvDom->children[tvDom->children.size()-1]; + + for(unsigned k=0; k<p->children.size(); ++k) + if (!SearchAndInsert(p->children[k], tvDom->children[i])) tvDom->children[i]->newChild(p->children[k]); + tvDom->children.pop_back(); + h = true; + } + ++i; + } +} + +bool TVChildTarget::SearchAndInsert(TVDom* p, TVDom* tvDom) +{ + if (p->isLeaf()) return false; + + bool h = false; + sal_Int32 max = 0; + + std::vector< TVDom* >::iterator max_It, i; + max_It = tvDom->children.begin(); + + sal_Int32 c_int; + sal_Int32 p_int = p->id.toInt32(); + +////////////////////////////////check this level in the tree + for(i = tvDom->children.begin(); i!=tvDom->children.end(); ++i) + if (!((*i)->isLeaf()) && + ((*i)->id.getLength() == p->id.getLength()) && + (p->id.replaceAt((*i)->parent->id.getLength(), p->id.getLength()-(*i)->parent->id.getLength(), OUString("")) == (*i)->parent->id)) //prefix check + { + h = true; + c_int = (*i)->id.toInt32(); + + if (p_int==c_int) + { + (*(tvDom->children.insert(i+1, p)))->parent = tvDom; + return true; + } + else if(c_int>max && c_int < p_int) + { + max = c_int; + max_It = i+1; + } + } +////////////////////////////////recursive call if necessary + if (h) (*(tvDom->children.insert(max_It, p)))->parent = tvDom; + else + { + i = tvDom->children.begin(); + while ((i!=tvDom->children.end()) && (!h)) + { + h = SearchAndInsert(p, *i); + ++i; + } + } + return h; +} Any SAL_CALL TVChildTarget::getByName( const rtl::OUString& aName ) diff --git a/xmlhelp/source/treeview/tvread.hxx b/xmlhelp/source/treeview/tvread.hxx index 48e22b22fe30..2afcd10bef9f 100644 --- a/xmlhelp/source/treeview/tvread.hxx +++ b/xmlhelp/source/treeview/tvread.hxx @@ -319,6 +319,10 @@ namespace treeview { const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr, rtl::OUString& instpath ) const; + bool SearchAndInsert(TVDom* p, TVDom* tvDom); + + void Check(TVDom* tvDom); + }; // end class TVChildTarget |