[Libreoffice-commits] core.git: Branch 'feature/gsoc-impresslayout' - sd/source
Vishv Brahmbhatt
vishvbrahmbhatt19 at gmail.com
Thu Jul 25 07:03:11 PDT 2013
sd/source/core/sdpage.cxx | 96 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 93 insertions(+), 3 deletions(-)
New commits:
commit 047017b3b0d33a88334459697efc46467cc69e0a
Author: Vishv Brahmbhatt <vishvbrahmbhatt19 at gmail.com>
Date: Thu Jul 25 19:25:01 2013 +0530
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
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index ecd481f..0aace256 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;
More information about the Libreoffice-commits
mailing list