[Libreoffice-commits] .: xmlhelp/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 22 08:11:44 PDT 2012


 xmlhelp/source/treeview/tvread.cxx |   83 +++++++++++++++++++++++++++++++++----
 xmlhelp/source/treeview/tvread.hxx |    4 +
 2 files changed, 80 insertions(+), 7 deletions(-)

New commits:
commit d9eec8f0f0b4ff397dedbfc2041c79c45af4d4a1
Author: Bence Babati <b.baabsi at gmail.com>
Date:   Wed Aug 22 15:26:44 2012 +0200

    embed extension's help tree into main help tree
    
    Change-Id: Iddb3c542f50078b13c7d420b528aa704a5cb0767

diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx
index 8357a3b..387ba14 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 48e22b2..2afcd10 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
 
 


More information about the Libreoffice-commits mailing list