Kaydet (Commit) d9eec8f0 authored tarafından Bence Babati's avatar Bence Babati Kaydeden (comit) Andras Timar

embed extension's help tree into main help tree

Change-Id: Iddb3c542f50078b13c7d420b528aa704a5cb0767
üst e47fe5cc
...@@ -75,6 +75,13 @@ namespace treeview { ...@@ -75,6 +75,13 @@ namespace treeview {
return children.back(); return children.back();
} }
TVDom* newChild(TVDom* p)
{
children.push_back( p );
p->parent = this;
return children.back();
}
TVDom* getParent() const TVDom* getParent() const
{ {
...@@ -485,8 +492,6 @@ extern "C" void data_handler( void *userData, ...@@ -485,8 +492,6 @@ extern "C" void data_handler( void *userData,
(*tvDom)->setTitle( s,len ); (*tvDom)->setTitle( s,len );
} }
TVChildTarget::TVChildTarget( const ConfigData& configData,TVDom* tvDom ) TVChildTarget::TVChildTarget( const ConfigData& configData,TVDom* tvDom )
{ {
Elements.resize( tvDom->children.size() ); Elements.resize( tvDom->children.size() );
...@@ -494,10 +499,6 @@ TVChildTarget::TVChildTarget( const ConfigData& configData,TVDom* tvDom ) ...@@ -494,10 +499,6 @@ TVChildTarget::TVChildTarget( const ConfigData& configData,TVDom* tvDom )
Elements[i] = new TVRead( configData,tvDom->children[i] ); Elements[i] = new TVRead( configData,tvDom->children[i] );
} }
TVChildTarget::TVChildTarget( const Reference< XMultiServiceFactory >& xMSF ) TVChildTarget::TVChildTarget( const Reference< XMultiServiceFactory >& xMSF )
{ {
ConfigData configData = init( xMSF ); ConfigData configData = init( xMSF );
...@@ -534,8 +535,9 @@ TVChildTarget::TVChildTarget( const Reference< XMultiServiceFactory >& xMSF ) ...@@ -534,8 +535,9 @@ TVChildTarget::TVChildTarget( const Reference< XMultiServiceFactory >& xMSF )
XML_ParserFree( parser ); XML_ParserFree( parser );
delete[] s; delete[] s;
}
Check(pTVDom);
}
// now TVDom holds the relevant information // now TVDom holds the relevant information
Elements.resize( tvDom.children.size() ); Elements.resize( tvDom.children.size() );
...@@ -548,7 +550,74 @@ TVChildTarget::~TVChildTarget() ...@@ -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 Any SAL_CALL
TVChildTarget::getByName( const rtl::OUString& aName ) TVChildTarget::getByName( const rtl::OUString& aName )
......
...@@ -319,6 +319,10 @@ namespace treeview { ...@@ -319,6 +319,10 @@ namespace treeview {
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr,
rtl::OUString& instpath ) const; rtl::OUString& instpath ) const;
bool SearchAndInsert(TVDom* p, TVDom* tvDom);
void Check(TVDom* tvDom);
}; // end class TVChildTarget }; // end class TVChildTarget
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment