开发者

In PowerPoint 2007, how can I position a Callout's Tail programatically?

I'm looking at the DrawingML of 开发者_开发知识库a PowerPoint 2007 file and this is what it has for the Callout object's coordinates and geometry:

<p:spPr>
    <a:xfrm>
        <a:off x="2819400" y="5181600"/> // X,Y Position of Callout Box
        <a:ext cx="609600" cy="457200"/> // Width,Height of Callout Box
    </a:xfrm>
    <a:prstGeom prst="wedgeRectCallout">
        <a:avLst>
            <a:gd name="adj1" fmla="val 257853"/> // X Position Of Tail
            <a:gd name="adj2" fmla="val -532360"/> // Y Position of Tail
        </a:avLst>
    </a:prstGeom>
    <a:solidFill>
        <a:schemeClr val="accent1">
            <a:alpha val="50000"/>
        </a:schemeClr>
    </a:solidFill>
</p:spPr>

What I'm having trouble with is the formula for telling it to place the tail at a particular coordinate on the slide. I've tried this to calculate it, but it does not work correctly.

//This gives me the distance between the Coordinate and the Center of the Callout.
DistanceX = Coordinate.X - (Callout.X + Callout.X_Ext)/2
DistanceY = Coordinate.Y - (Callout.Y + Callout.Y_Ext)/2

But, the geometric value is not the distance between the two points.

Anybody know what the formula is for calculating this?


I think I've figured out the formula:

DistanceX = Coordinate.X - (Callout.X + (Callout.X_Ext/2))
DistanceY = Coordinate.Y - (Callout.Y + (Callout.Y_Ext/2))

TailX = (DistanceX/Callout.X_Ext) * 100000
TailY = (DistanceY/Callout.Y_Ext) * 100000


That may be a good quick way to do this if the adjustments are available - I haven't tested it. However, if I understand what you're asking, it is how get the x/y of the wedgeRectCallout's tail point at a particular location on screen, including the case where the size/location of the tail is adjusted. I assume you have a predefined size of the wedgeRectCallout.

The value you want needs to be calculated from presetShapeDefinitions.xml (find it with the Ecma downloads). The value you want is here in the wedgeRectCallout element:

<lnTo>
<pt x="xb" y="yb" />
</lnTo>

So how do you calculate x=xb and y=yb? Go to the Ecma docs and view how to read formulas in DrawingML - Framework Reference Material -> Drawing ML - Main -> Shape Definitions and Attributes -> gd (Shape Guide) and calculate the shape guides in gdLst (which takes the value of default or modified adjustments). In this case, you'll need to calculate all/most guides to ensure you get the values for xb and yb.

Let me know if you run into any issues or have more questions on this.


in presetShapeDefinitions.xml file , Which defines the parametrs and formulas needed to draw the shapes,if youe look about the shape "wedgeRectCallout" you will see number of tags like : <avLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> , <gdLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> , <ahLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main">, <cxnLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main">, <rect l="l" t="t" r="r" b="b" xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> and <pathLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main">.
The important tags the needed to understand how to draw the shape are: <gdLst> and <pathLst>.<gdLst> Contains the formulas of the shape , and <pathLst> says how to draw the shape.
I wrote a small program that translates to javascript all the formulas in the file presetShapeDefinitions.xml.
To the website page of the program click here.
This program helped me build the PPTXjs plugin that converts PPTX files to HTML.
Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜