1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
<html dir="ltr"><head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="assetid" CONTENT="HV01086436"><META NAME="lcid" CONTENT="1033"><title>Working with a Shape's Text in DatadiagramML</title><link rel="stylesheet" type="text/css" href="office10.css"><script type="text/javascript" language="Javascript" src="ExpCollapse.js"></script><script type="text/javascript" language="JavaScript" src="inline.js"></script></head><body><p id="ExpandAllLine" class="ExpFav"><a href="#" onclick="ExpandAll()" onkeypress="ExpandAll()" class="DropDown"><img id="picHeader" border="0" src="expandtri.gif" alt="Show All"><span id="ExpandAll">Show All</span></a></p><h1>Working with a Shape's Text in DatadiagramML</h1><p>Several groups of elements are involved in working with the text of a shape<nbsp />— the elements that describe characteristics of the text, those elements that describe the beginning and end of text runs, and an element that contains the text itself.</p><p>The following table gives a brief description of these elements and their relationships.</p><table>
<tr>
<th>
<b class="bterm">Element</b>
</th>
<th>
<b class="bterm">Description</b>
</th>
</tr>
<tr>
<td>
<code><Shape></code>
</td>
<td>
<p>Opening tag for the <b class="bterm">Shape</b> element.</p>
</td>
</tr>
<tr>
<td>
<code><Text></code>
</td>
<td>
<p>Opening tag for the shape's text.</p>
</td>
</tr>
<tr>
<td>
<code><cp/></code>
</td>
<td>
<p>Marks character runs.</p>
</td>
</tr>
<tr>
<td>
<code><pp/></code>
</td>
<td>
<p>Marks paragraph runs.</p>
</td>
</tr>
<tr>
<td>
<code><tp/></code>
</td>
<td>
<p>Marks tab runs.</p>
</td>
</tr>
<tr>
<td>
<code><fld/></code>
</td>
<td>
<p>Marks <b class="bterm">Field</b> position.</p>
</td>
</tr>
<tr>
<td>
<code></Text></code>
</td>
<td>
<p>Closing tag for the shape's text.</p>
</td>
</tr>
<tr>
<td>
<code><Char></code>
</td>
<td>
<p>Contains character properties.</p>
</td>
</tr>
<tr>
<td>
<code><Para></code>
</td>
<td>
<p>Contains paragraph properties.</p>
</td>
</tr>
<tr>
<td>
<code><Tabs></code>
</td>
<td>
<p>Contains tab properties.</p>
</td>
</tr>
<tr>
<td>
<code><Field></code>
</td>
<td>
<p>Contains the shape's text field properties.</p>
</td>
</tr>
<tr>
<td>
<code></Shape></code>
</td>
<td>
<p>Closing tag for the <b class="bterm">Shape</b> element.</p>
</td>
</tr>
</table><p>For example, consider the following shape. It has text that consists of two character runs, one in bold and the other in italic.</p><p>
<img border="0" src="../img/XML_04.gif" alt="Text that consists of two character runs, one in bold and the other in italic">
</p><p>The portion of the shape's sheet that describes character text runs is called the Character section. The Character rows for this shape as viewed in the ShapeSheet window are as follows:
</p><p><img border="0" src="../img/XML_007_ZA01108249.gif" alt="Character rows from the ShapeSheet."></p><p>
Note that the column on the left indicates the length of each run, 4 characters and 7 characters, respectively. The only cells that vary between the two rows are the Style cell values. The Style cell determines if the run is bold, italic, or another style. The XML code for these rows follows:</p><pre><code><Char IX='0'>
<Font>4</Font>
<Color>0</Color>
<Style>17</Style>
<Case>0</Case>
<Pos>0</Pos>
<FontScale>1</FontScale>
<Size Unit='PT'>0.1666666666666667</Size>
<DblUnderline>0</DblUnderline>
<Overline>0</Overline>
<Strikethru>0</Strikethru>
<Highlight>0</Highlight>
<DoubleStrikethrough>0</DoubleStrikethrough>
<RTLText>0</RTLText>
<UseVertical>0</UseVertical>
<Letterspace>0</Letterspace>
<ColorTrans>0</ColorTrans>
<AsianFont>0</AsianFont>
<ComplexScriptFont>0</ComplexScriptFont>
<LocalizeFont>0</LocalizeFont>
<ComplexScriptSize>-1</ComplexScriptSize>
<LangID>1033</LangID>
</Char>
<Char IX='1'>
<Font>4</Font>
<Color>0</Color>
<Style>34</Style>
<Case>0</Case>
<Pos>0</Pos>
<FontScale>1</FontScale>
<Size Unit='PT'>0.1666666666666667</Size>
<DblUnderline>0</DblUnderline>
<Overline>0</Overline>
<Strikethru>0</Strikethru>
<Highlight>0</Highlight>
<DoubleStrikethrough>0</DoubleStrikethrough>
<RTLText>0</RTLText>
<UseVertical>0</UseVertical>
<Letterspace>0</Letterspace>
<ColorTrans>0</ColorTrans>
<AsianFont>0</AsianFont>
<ComplexScriptFont>0</ComplexScriptFont>
<LocalizeFont>0</LocalizeFont>
<ComplexScriptSize>-1</ComplexScriptSize>
<LangID>1033</LangID>
</Char>
</code></pre><p><b>Note</b> Although the size of the text is 12 points, the internal unit for points is inches. So the point size of "12" is represented in inches as "0.16666666666667."</p><p>The two <b class="bterm">Char</b> elements represent the two Character rows. Each has an <b class="bterm">IX</b> attribute describing the relative order of the rows. Each <b class="bterm">Char</b> element contains child elements that correspond to the cells viewed in the ShapeSheet window.</p><p>The <b class="bterm">Shape</b> element also contains an element called <b class="bterm">Text</b>, which contains the characters of the text and special elements (<b class="bterm">cp</b>, <b class="bterm">pp</b>, <b class="bterm">tp</b>, and <b class="bterm">fld</b>) that mark the end of one run and the beginning of the next. The <b class="bterm">Text</b> element is somewhat unusual because it contains both data (the text characters) and child elements (<b class="bterm">cp</b>, <b class="bterm">pp</b>, and so on).</p><p>The <b class="bterm">Text</b> element that describes the text on the preceding shape follows:</p><pre><code><Text><cp IX='0'/>Bold <cp IX='1'/>Italic</Text>
</code></pre><p>The <code><cp IX='0'></code> tag indicates that the character properties from the first <b class="bterm">Char</b> element (<code><Char IX='0'></code>) are to be applied to the text that follows. The <code><cp IX='1'/></code> tag indicates that the preceding character run (<code><Char IX='0'></code>) has ended and the run attributed to <code><Char IX='1'></code> has begun.</p>
<p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Inheritance for text elements</a></p>
<div id="ExpCol" class="collapsed" border="0">
<p>Inheritance for text elements follows the standard inheritance rules. Text row elements (<b class="bterm">Char</b>, <b class="bterm">Para</b>, <b class="bterm">Tabs</b> and <b class="bterm">Field</b>) need to contain child elements only for elements whose values are different from their inherited value. For example, the statement <code><Char IX='0'><Color>4</Color</Char></code> is sufficient to specify that a <b class="bterm">Char</b> element should have blue text; the remaining element values will automatically be inherited.
</p><p><b>Note</b> Microsoft® Office Visio® writes out all values<nbsp />— inherited or not<nbsp />— when it saves a DatadiagramML file.</p>
<p>The following special cases apply:</p><p><ul>
<li>If the text row elements are in a master or a non-instance shape (a shape that is not an instance of a master), the values are inherited from the shape's text style, that is, the ID of the <b class="bterm">StyleSheet</b> that is referenced in the shape's <b class="bterm">TextStyle</b> attribute. If the shape does not contain a <b class="bterm">TextStyle</b> attribute, the values are inherited from the default document style.</li>
<li>If the text row elements are in an instance shape (a shape that is an instance of a master), the values are inherited from the corresponding row in the master. If a corresponding row does not exist, values are inherited from the first row in the master. (An instance of a master that has a <b class="bterm">TextStyle</b> attribute inherits text properties from the style instead of the master.)</li>
</ul>
</p>
</div>
<p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Loading untrusted text</a></p>
<div id="ExpCol" class="collapsed" border="0">
<p>When Visio loads text from an XML file that is created or edited outside of Visio (an untrusted file), the first thing it does is <i>normalize</i> the text data, that is, it fills in, adds, or reorders missing elements and removes unused elements.</p>
<p>Following are some of the ways in which Visio normalizes untrusted text data in a VDX file at load time.</p>
<ul><li>When Visio emits a DatadiagramML file, all <b class="bterm">cp</b>, <b class="bterm">pp</b>, <b class="bterm">tp</b>, and <b class="bterm">fld</b> elements in the <b class="bterm">Text</b> element have <b class="bterm">IX</b> values that are sequential. In other words, a <code><cp IX ='0'/></code> tag always precedes a <code><cp IX ='1'/></code> tag, and so on.</li><li>If Visio encounters run markers that are out of order when it reads a DatadiagramML file, it inserts duplicates of the text run rows as needed. For example, say Visio reads the following file:<pre><code><Char IX='0'> <Style> 0 </Style> </Char>
<Char IX='1'> <Style> 1 </Style> </Char>
<Para IX='0'> <HorzAlign> 0 </HorzAlign> </Char>
<Para IX='1'> <HorzAlign> 1 </HorzAlign> </Char>
<Text><cp IX='0'/><pp IX='0'/>The quick <cp IX='1'/>brown fox
<pp IX='1'/>jumped <cp IX='0'/>over the lazy dog.</Text>
</code></pre><p>The code describes a text block that contains three character runs and two paragraph property runs. There is a single paragraph break after the word "fox." The block would be rendered like this:</p><p>
<img border="0" src="../img/XML_05.gif" alt="The quick brown fox jumped over the lazy dog. This text block contains three character runs and two paragraph property runs.">
</p><p>In the preceding example, the <b class="bterm">Char</b> row 0 is referenced twice (<code><cp IX ='0'/></code>). Visio normalizes this by creating a third <b class="bterm">Char</b> row (<code><Char IX='2'></code>), which is identical to <b class="bterm">Char</b> row 0.</p><p>When the file is resaved, it contains the third <b class="bterm">Char</b> row and an additional <b class="bterm">cp</b> element marking the third character run, which is demonstrated as follows. In addition, the XML file will contain all the child elements (<b class="bterm">Font</b>, <b class="bterm">Size</b>, <b class="bterm">FontScale</b>, and so on) for all the <b class="bterm">Char</b> and <b class="bterm">Para</b> elements.</p><pre><code><Char IX='0'>...<Style> 0 </Style>...</Char>
<Char IX='1'>...<Style> 1 </Style>...</Char>
<Char IX='2'>...<Style> 0 </Style>...</Char>
<Para IX='0'>...<HorzAlign> 0 </HorzAlign>...</Char>
<Para IX='1'>...<HorzAlign> 1 </HorzAlign>...</Char>
<Text><cp IX ='0'/><pp IX='0'>The quick <cp IX ='1'/>brown fox
<pp IX ='1'/>jumped <cp IX ='2'/>over the lazy dog.</Text>
</code></pre></li><li><p>Although it is not an error to omit the marker for the first run, it is recommended that you include it. Visio always emits the initial marker element when the DatadiagramML data is round-tripped.</p></li><li><p>Paragraph run markers (<code><pp IX='1'></code>) and tab run markers (<code><tp IX='1'></code>) are valid only at the beginning of a paragraph. If such a marker is encountered in the middle of a paragraph, it is ignored. A new line is required before each <b class="bterm">pp</b> and <b class="bterm">tp</b> element.</p></li><li><p>Visio normalizes untrusted text data when it is loaded into the application. This means that Visio performs further processing<nbsp />— for example, local overrides or local deletions<nbsp />— on the normalized data. When you are editing or generating your own DatadiagramML files, you'll get better performance results if you try to mimic the XML that Visio generates.</p></li></ul>
</div>
<center><a href="XMLSchemaCopyright_HV01147162.htm">©2003-2004 Microsoft Corporation. All rights reserved.</a>
Permission to copy, display and distribute this document is available at: <a
href="http://r.office.microsoft.com/r/rlidAWSContentRedir?AssetID=XT010988631033&CTT=11&Origin=HV011232471033"
target="_new">http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp</a></center></body></html>
|