sd/source/core/sdpage.cxx |  108 +++++++++++++++++++++++++---------------------
 sd/xml/layoutlist.xml     |    2 
 2 files changed, 60 insertions(+), 50 deletions(-)

New commits:
commit 57866f97931e789b33e650d1c2bf81afe1a6ed11
Author: Vishv Brahmbhatt <vishvbrahmbhat...@gmail.com>
Date:   Sun Jul 28 12:33:45 2013 +0530

    Changed the logic of parsing
    
    Have added a vector list of XNode to store the parse XML and referring it 
instead of XML eveytime.
    Need to make scope level changes for vector and parseXml() in the next 
commit.
    
    Change-Id: I2f270fc18058772fbf30a2a44e564c8290c316c4

diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 0aace256..c244da6 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -1117,6 +1117,7 @@ Rectangle SdPage::GetLayoutRect() const
 const int MAX_PRESOBJS = 7; // maximum number of presentation objects per 
layout
 const int VERTICAL = 0x8000;
 const int PRESOBJPROP = 4;
+std::vector<Reference<XNode>> layoutinfo; //temporarily at global scope
 
 struct LayoutDescriptor
 {
@@ -1317,6 +1318,9 @@ rtl::OUString enumtoString(AutoLayout aut)
         case AUTOLAYOUT_TITLE_CONTENT_2CONTENT:
         retstr="AUTOLAYOUT_TITLE_CONTENT_2CONTENT";
         break;
+        case AUTOLAYOUT_TITLE_4CONTENT:
+        retstr="AUTOLAYOUT_TITLE_4CONTENT";
+        break;
         default:
         retstr="unknown";
         break;
@@ -1325,6 +1329,19 @@ rtl::OUString enumtoString(AutoLayout aut)
     return retstr;
 }
 
+void parseXml()
+{
+    int layoutlistsize;
+    const Reference<XElement> root= getRootElement();//get the root element of 
my xml file
+    const Reference<XNodeList> layoutlist = 
root->getElementsByTagName("layout");
+    layoutlistsize=layoutlist->getLength();
+    for( long index=0; index<layoutlistsize ;index++)
+    {
+        Reference<XNode> layoutnode = layoutlist->item(index);      //get i'th 
layout element
+        layoutinfo.push_back(layoutnode);
+    }
+}
+
 static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* 
rRectangle ,const rtl::OUString& autolayout)
 {
     Rectangle aTitleRect;
@@ -1333,7 +1350,6 @@ static void CalcAutoLayoutRectangles( SdPage& rPage, int 
nLayout, Rectangle* rRe
     long layoutlistsize;
     rtl::OUString sLayoutAttName;
     rtl::OUString sPresObjKindAttName;
-    bool bnoprop=true;                   //use it to skip the remaining loop 
,once propvalue is obtained
     double propvalue[4];
 
     if( rPage.GetPageKind() != PK_HANDOUT )
@@ -1376,61 +1392,55 @@ static void CalcAutoLayoutRectangles( SdPage& rPage, 
int nLayout, Rectangle* rRe
 
     sal_Bool    bRightToLeft = ( rPage.GetModel() && static_cast< 
SdDrawDocument* >( rPage.GetModel() )->GetDefaultWritingMode() == 
::com::sun::star::text::WritingMode_RL_TB );
 
-    const Reference<XNodeList> layoutlist = 
root->getElementsByTagName("layout");
-    layoutlistsize=layoutlist->getLength();
-    rtl::OUString sLayoutType = autolayout;
-    for( long index=0; index<layoutlistsize ;index++)
+    parseXml(); //calling this for temporary reference,have to use it 
somewhere else.
+    for(int y=0; y < layoutinfo.size(); y++) //loop through vector of Xnodes
     {
-        if(bnoprop)
-        {
-            Reference<XNode> layoutnode = layoutlist->item(index);      //get 
i'th layout element
-            Reference<XNamedNodeMap> layoutattrlist 
=layoutnode->getAttributes();
-            Reference<XNode> layoutattr = layoutattrlist->getNamedItem("type");
-            sLayoutAttName=layoutattr->getNodeValue();              //get the 
attribute value of layout(i.e it's type)
+        Reference<XNode> layoutnode = layoutinfo[y];      //get i'th layout 
element
+        Reference<XNamedNodeMap> layoutattrlist =layoutnode->getAttributes();
+        Reference<XNode> layoutattr = layoutattrlist->getNamedItem("type");
+        sLayoutAttName=layoutattr->getNodeValue();              //get the 
attribute value of layout(i.e it's type)
+        rtl::OUString sLayoutType = autolayout;
 
-            if(sLayoutAttName==sLayoutType)
+        if(sLayoutAttName==sLayoutType)
+        {
+            int count=0;
+            Reference<XNodeList> layoutchildrens = layoutnode->getChildNodes();
+            presobjsize = layoutchildrens->getLength();         //get the 
length of that of the layout(number of pres objects)
+            for( long j=0; j< presobjsize ; j++)
             {
-                Reference<XNodeList> layoutchildrens = 
layoutnode->getChildNodes();
-                presobjsize = layoutchildrens->getLength();         //get the 
length of that of the layout(number of pres objects)
-                for( long j=1; j< presobjsize ; j++)
+                rtl::OUString nodename;
+                Reference<XNode> presobj = layoutchildrens->item(j);    //get 
the j'th presobj for that layout
+                nodename=presobj->getNodeName();
+                if(nodename=="presobj")//check whether children is blank 
'text-node' or 'presobj' node
                 {
-                    rtl::OUString nodename;
-                    Reference<XNode> presobj = layoutchildrens->item(j);    
//get the j'th presobj for that layout
-                    nodename=presobj->getNodeName();
-                    if(nodename=="presobj")//check whether children is blank 
'text-node' or 'presobj' node
-                    {
-                        Reference<XNamedNodeMap> presObjAttributes = 
presobj->getAttributes();
-                        Reference<XNode> presObjKindAttr = 
presObjAttributes->getNamedItem("kind");
-                        sPresObjKindAttName = presObjKindAttr->getNodeValue(); 
 //get the value of it's presobj kind
-
-                        Reference<XNode> presObjPosX = 
presObjAttributes->getNamedItem("layout-pos-x");
-                        rtl::OUString sValue = presObjPosX->getNodeValue();
-                        propvalue[0] = sValue.toDouble();
-
-                        Reference<XNode> presObjPosY = 
presObjAttributes->getNamedItem("layout-pos-y");
-                        sValue = presObjPosY->getNodeValue();
-                        propvalue[1] = sValue.toDouble();
-
-                        Reference<XNode> presObjSizeHeight = 
presObjAttributes->getNamedItem("layout-size-height");
-                        sValue = presObjSizeHeight->getNodeValue();
-                        propvalue[2] = sValue.toDouble();
-
-                        Reference<XNode> presObjSizeWidth = 
presObjAttributes->getNamedItem("layout-size-width");
-                        sValue = presObjSizeWidth->getNodeValue();
-                        propvalue[3] = sValue.toDouble();
-
-                        aLayoutPos.X() = propvalue[0];
-                        aLayoutPos.Y() = propvalue[1];
-                        aLayoutSize.Height() = propvalue[2];
-                        aLayoutSize.Width() = propvalue[3];
-                        rRectangle[j] = Rectangle (aLayoutPos, aLayoutSize);
-                    }
+                    Reference<XNamedNodeMap> presObjAttributes = 
presobj->getAttributes();
+
+                    Reference<XNode> presObjPosX = 
presObjAttributes->getNamedItem("layout-pos-x");
+                    rtl::OUString sValue = presObjPosX->getNodeValue();
+                    propvalue[0] = sValue.toDouble();
+
+                    Reference<XNode> presObjPosY = 
presObjAttributes->getNamedItem("layout-pos-y");
+                    sValue = presObjPosY->getNodeValue();
+                    propvalue[1] = sValue.toDouble();
+
+                    Reference<XNode> presObjSizeHeight = 
presObjAttributes->getNamedItem("layout-size-height");
+                    sValue = presObjSizeHeight->getNodeValue();
+                    propvalue[2] = sValue.toDouble();
+
+                    Reference<XNode> presObjSizeWidth = 
presObjAttributes->getNamedItem("layout-size-width");
+                    sValue = presObjSizeWidth->getNodeValue();
+                    propvalue[3] = sValue.toDouble();
+
+                    aLayoutPos.X() = propvalue[0];
+                    aLayoutPos.Y() = propvalue[1];
+                    aLayoutSize.Height() = propvalue[2];
+                    aLayoutSize.Width() = propvalue[3];
+                    rRectangle[count] = Rectangle (aLayoutPos, aLayoutSize);
+                    count=count+1;
                 }
-                bnoprop=false;
             }
-        }
-        else
             break;
+        }
     }
 
     switch( nLayout )
diff --git a/sd/xml/layoutlist.xml b/sd/xml/layoutlist.xml
index cfe1f1e..88ec811 100644
--- a/sd/xml/layoutlist.xml
+++ b/sd/xml/layoutlist.xml
@@ -22,7 +22,7 @@
         <presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="1400" 
layout-pos-y="11274" layout-size-height="5809" layout-size-width="12297"/>
         <presobj kind="PRESOBJ_OUTLINE3" layout-pos-x="14311" 
layout-pos-y="11274" layout-size-height="5809" layout-size-width="12297"/>
     </layout>
-    <layout type="AUTOLAYOUT_TITLE_4SCONTENT">
+    <layout type="AUTOLAYOUT_TITLE_4CONTENT">
         <presobj kind="PRESOBJ_TITLE" layout-pos-x="1400" layout-pos-y="837" 
layout-size-height="4400" layout-size-width="25600"/>
         <presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="5809" layout-size-width="12297"/>
         <presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="14311" 
layout-pos-y="5914" layout-size-height="4509" layout-size-width="12297"/>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to