diff options
author | Vishv Brahmbhatt <vishvbrahmbhatt19@gmail.com> | 2013-07-25 19:25:01 +0530 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2013-08-26 14:47:22 +0200 |
commit | c9b06499f43429452fcfb2dc8fdc33717fb6e3e5 (patch) | |
tree | 5d4b550d474e892d28156e727a1fcfb2def538ac /sd/source | |
parent | ac5b9651a471d9ee28d5c7996d592ac2df08ca2b (diff) |
Added a for loop to "CalcAutoLayoutRectangles" to change logic.
Changed the logic of switch case in "CalcAutoLayoutRectangles".This for loop basically traverse through the "layoutlist.xml" and
find the appropriate node to a particular "layout" and then fills in the property values to all of it's presobj in the layout.
Currently,I have not deleted the switch case,but this 'for loop' aims to replace it.
Change-Id: I114614292934af179f9380277021aea350e3b35d
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/core/sdpage.cxx | 96 |
1 files changed, 93 insertions, 3 deletions
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 906137080fd1..a75ade518b23 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -1261,7 +1261,8 @@ void readLayoutPropFromFile(const Reference<XElement>& root, const rtl::OUString 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++) - { rtl::OUString nodename; + { + 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 @@ -1299,10 +1300,40 @@ void readLayoutPropFromFile(const Reference<XElement>& root, const rtl::OUString } } -static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRectangle ) +rtl::OUString enumtoString(AutoLayout aut) +{ + rtl::OUString retstr; + switch (aut) + { + case AUTOLAYOUT_TITLE_CONTENT: + retstr="AUTOLAYOUT_TITLE_CONTENT"; + break; + case AUTOLAYOUT_TITLE_2VTEXT: + retstr="AUTOLAYOUT_TITLE_2VTEXT"; + break; + case AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT: + retstr="AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT"; + break; + case AUTOLAYOUT_TITLE_CONTENT_2CONTENT: + retstr="AUTOLAYOUT_TITLE_CONTENT_2CONTENT"; + break; + default: + retstr="unknown"; + break; + // case AUTOLAYOUT_TITLE_4SCONTENT: return "AUTOLAYOUT_TITLE_4SCONTENT"; + } + return retstr; +} + +static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRectangle ,const rtl::OUString& autolayout) { Rectangle aTitleRect; Rectangle aLayoutRect; + long presobjsize; + 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 ) @@ -1345,6 +1376,63 @@ 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++) + { + 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) + + if(sLayoutAttName==sLayoutType) + { + 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 + { + 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); + } + } + bnoprop=false; + } + } + else + break; + } + switch( nLayout ) { case 0: // default layout using only the title and layout area @@ -1736,6 +1824,7 @@ void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescripto void SdPage::SetAutoLayout(AutoLayout eLayout, sal_Bool bInit, sal_Bool bCreate ) { + rtl::OUString autolayout; sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement ); const bool bSwitchLayout = eLayout != GetAutoLayout(); @@ -1756,7 +1845,8 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, sal_Bool bInit, sal_Bool bCreate Rectangle aRectangle[MAX_PRESOBJS]; const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout ); - CalcAutoLayoutRectangles( *this, aDescriptor.mnLayout, aRectangle ); + autolayout=enumtoString(meAutoLayout); + CalcAutoLayoutRectangles( *this, aDescriptor.mnLayout, aRectangle, autolayout); std::set< SdrObject* > aUsedPresentationObjects; |