Expected behavior of the renderer for superscripts and subscripts in Word Open XML - openxml

It looks like ECMA specification for Word Open XML doesn't specify how to render "runs" with vertAlign attribute. Is there a document describing the expected behavior:
What font size to use for superscripts and subscripts?
For how much to shift the superscript/subscript text relatively to the baseline?
Just for reference, here's a document.xml generated by MS Word for a trivial document containing text "X²" (XML namespaces are omitted for brevity):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document>
<w:body>
<w:p w14:paraId="4B8ED8F1" w14:textId="3891D3E1"
w:rsidR="00CE1223" w:rsidRDefault="00886D56">
<w:r>
<w:t>X</w:t>
</w:r>
<w:r w:rsidRPr="00886D56">
<w:rPr>
<w:vertAlign w:val="superscript"/>
</w:rPr>
<w:t>2</w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
<w:bookmarkEnd w:id="0"/>
</w:p>
<w:sectPr w:rsidR="00CE1223">
<w:pgSz w:w="12240" w:h="15840"/>
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"
w:header="720" w:footer="720" w:gutter="0"/>
<w:cols w:space="720"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
</w:document>

The RunProperties elements has following two child elements which can be used to set the position and the font of a Run which has a VerticalTextAlignment:
The RunFonts element which can be used to set the type of font
The Position element which can be used to lower or raise the the run in relation to its default baseline.
Using these elements you can create a run which is in superscript and has an adjusted font:
// Creates an RunProperties instance and adds its children.
public RunProperties GenerateRunProperties()
{
RunProperties runProperties1 = new RunProperties();
RunFonts runFonts1 = new RunFonts(){ Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
FontSize fontSize1 = new FontSize(){ Val = "48" };
VerticalTextAlignment verticalTextAlignment1 = new VerticalTextAlignment(){ Val = VerticalPositionValues.Superscript };
runProperties1.Append(runFonts1);
runProperties1.Append(fontSize1);
runProperties1.Append(verticalTextAlignment1);
return runProperties1;
}
This will output the follwing openxml:
<w:rPr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:sz w:val="48" />
<w:vertAlign w:val="superscript" />
</w:rPr>
And you can shift the vertical aligned run using these elements:
// Creates an RunProperties instance and adds its children.
public RunProperties GenerateRunProperties()
{
RunProperties runProperties1 = new RunProperties();
RunFonts runFonts1 = new RunFonts(){ Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
Position position1 = new Position(){ Val = "-10" };
FontSize fontSize1 = new FontSize(){ Val = "48" };
VerticalTextAlignment verticalTextAlignment1 = new VerticalTextAlignment(){ Val = VerticalPositionValues.Superscript };
runProperties1.Append(runFonts1);
runProperties1.Append(position1);
runProperties1.Append(fontSize1);
runProperties1.Append(verticalTextAlignment1);
return runProperties1;
}
Generating the follwing openXML:
<w:rPr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:position w:val="-10" />
<w:sz w:val="48" />
<w:vertAlign w:val="superscript" />
</w:rPr>
Depending on the value that you assign to the position element the run will be raised or lowered in relation to its baseline:
Positve => Raised
Negative => Lowered

Related

How to put And and OR filter type when RetrieveMultiple query is Fetch Expression

Please advice how to filter CRM/Model Driven App Unified Client Interface View using below same query expression in RetrieveMultiple plugin when input parameter query is of type Fetch Expression:
FilterExpression filter = new FilterExpression(LogicalOperator.Or);
string[] sourceChannel = new string[] { "Central Bank", "AECB" };
FilterExpression filter1 = new FilterExpression(LogicalOperator.And);
filter1.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.NotIn, sourceChannel));
filter1.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter2 = new FilterExpression(LogicalOperator.And);
filter2.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter2.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 1));
filter2.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter3 = new FilterExpression(LogicalOperator.And);
filter3.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter3.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 2));
filter3.Conditions.Add(new ConditionExpression("reopeningcount", ConditionOperator.GreaterThan, 0));
filter3.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter4 = new FilterExpression(LogicalOperator.And);
filter4.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter4.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 2));
filter4.Conditions.Add(new ConditionExpression("statecode", ConditionOperator.NotEqual, 0));
filter4.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
filter.AddFilter(filter1);
filter.AddFilter(filter2);
filter.AddFilter(filter3);
filter.AddFilter(filter4);
qe.Criteria.AddFilter(filter);
I tried below by taking help from Microsoft documentation as described here:
https://learn.microsoft.com/en-us/powerapps/developer/data-platform/org-service/samples/modify-query-preoperation-stage
But I don't have any idea how to put And and OR filter type in below XML Document.
Any help or guidance would be appreciated a lot.
entityElement.Add(
new XElement("filter",
new XElement("condition",
new XAttribute("attribute", "sourcechannelidname"),
new XAttribute("operator", "not-in"), //not equal
new XElement("value", new XText("Central Bank")),
new XElement("value", new XText("AECB"))
),
new XElement("condition",
new XAttribute("attribute", "casetypecode"),
new XAttribute("operator", "eq"), //equal
new XAttribute("value", "1"), //Complaints
)
)
);
In FetchXml the expression you're trying to write is (see the type='and'):
<filter type='and' >
<condition attribute='sourcechannelidname' operator='not-in' >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute='casetypecode' operator='eq' value='1' >
</filter>
So I think you just need to specify an XAttribute on the "filter" XElement
entityElement.Add(
new XElement("filter",
new XAttribute("type", "and"),
new XElement("condition",
new XAttribute("attribute", "sourcechannelidname"),
new XAttribute("operator", "not-in"), //not equal
new XElement("value", new XText("Central Bank")),
new XElement("value", new XText("AECB"))
),
new XElement("condition",
new XAttribute("attribute", "casetypecode"),
new XAttribute("operator", "eq"), //equal
new XAttribute("value", "1"), //Complaints
)
)
);
XrmToolbox can now parse C# into a fetch expression. Just use the "View" menu and choose "QueryExpression" to get it to pull open the window, then type (or paste) your valid code into it and click "Parse" and it will turn it into FetchXml for you.
You didn't include the full fetchXml query, and I didn't recognize the field names, but I copied it to the OOTB incident query (since I knew it had a casetypecode field) and replaced the field names with the same type. I made them parameters so you can easily replace them with your own params. Here is the code I used:
// Instantiate QueryExpression query
var query = new QueryExpression("incident");
query.TopCount = 50;
// Add all columns to query.ColumnSet
query.ColumnSet.AllColumns = true;
FilterExpression filter = new FilterExpression(LogicalOperator.Or);
string[] sourceChannel = new string[] { "Central Bank", "AECB" };
var stringColName = "ticketnumber";
var intColName = "timezoneruleversionnumber";
var pickColName = "servicestage";
FilterExpression filter1 = new FilterExpression(LogicalOperator.And);
filter1.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.NotIn, sourceChannel));
filter1.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter2 = new FilterExpression(LogicalOperator.And);
filter2.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.In, sourceChannel));
filter2.Conditions.Add(new ConditionExpression(pickColName , ConditionOperator.Equal, 1));
filter2.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter3 = new FilterExpression(LogicalOperator.And);
filter3.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.In, sourceChannel));
filter3.Conditions.Add(new ConditionExpression(pickColName , ConditionOperator.Equal, 2));
filter3.Conditions.Add(new ConditionExpression(intColName, ConditionOperator.GreaterThan, 0));
filter3.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter4 = new FilterExpression(LogicalOperator.And);
filter4.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.In, sourceChannel));
filter4.Conditions.Add(new ConditionExpression(pickColName , ConditionOperator.Equal, 2));
filter4.Conditions.Add(new ConditionExpression("statecode", ConditionOperator.NotEqual, 0));
filter4.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
filter.AddFilter(filter1);
filter.AddFilter(filter2);
filter.AddFilter(filter3);
filter.AddFilter(filter4);
query.Criteria.AddFilter(filter);
and this is the filter it created:
<filter type="and" >
<filter type="or" >
<filter type="and" >
<condition attribute="ticketnumber" operator="not-in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
<filter type="and" >
<condition attribute="ticketnumber" operator="in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="servicestage" operator="eq" value="1" />
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
<filter type="and" >
<condition attribute="ticketnumber" operator="in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="servicestage" operator="eq" value="2" />
<condition attribute="timezoneruleversionnumber" operator="gt" value="0" />
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
<filter type="and" >
<condition attribute="ticketnumber" operator="in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="servicestage" operator="eq" value="2" />
<condition attribute="statecode" operator="ne" value="0" />
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
</filter>
</filter>

VSIX KeyBindings not assign

I need issgin CTRL+F12 and CTRL+G
This code not work
<KeyBindings>
<KeyBinding guid="guidCmdSet" id="cmdSolutionList" editor="guidVSStd97" key1="VK_F12" mod1="CONTROL" />
<KeyBinding guid="guidCmdSet" id="cmdCodeItemsList" editor="guidVSStd97" key1="G" mod1="CONTROL" />
</KeyBindings>
But this code work
<KeyBindings>
<KeyBinding guid="guidCmdSet" id="cmdCodeItemsList" editor="guidVSStd97" key1="0" mod1="CONTROL" />
</KeyBindings>
Why not work?
How assign CTRL+F12 and CTRL+G?
Set binding with code
Command command = SolutionList.DTE.Commands.Item("Name1", -1);
command.Bindings = "Global::Ctrl+F12";
command = SolutionList.DTE.Commands.Item("Name2", -1);
command.Bindings = "Global::Ctrl+G";

How to create a document and fill it with textboxes based on x and y coords or pixels?

Im trying to create a template to print some information on a blank document based in coordinates or pixels or cm, wtv is possible.
why? I have some accounting forms which is to bad fill it manual. Im wondering if it is possible to create a function with some parameters related to the text box positions in document.
eg. txtName goes to (3,15) position in a document. It may be necessary define the size of document
If it is possible, what language you recommend?
Yes, it is possible.
If you use Microsoft Word to insert a text box into a blank document, then save it, and inspect the resulting docx, you'll see Word inserts the text box in 2 formats:
<mc:AlternateContent>
<mc:Choice Requires="wps">
<w:drawing>
<wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="251659264" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1" wp14:anchorId="44014479" wp14:editId="7FACADD8">
<wp:simplePos x="0" y="0"/>
<wp:positionH relativeFrom="column">
<wp:align>center</wp:align>
</wp:positionH>
<wp:positionV relativeFrom="paragraph">
<wp:posOffset>0</wp:posOffset>
</wp:positionV>
<wp:extent cx="2374265" cy="1403985"/>
<wp:effectExtent l="0" t="0" r="22860" b="23495"/>
<wp:wrapTopAndBottom/>
<wp:docPr id="307" name="Text Box 2"/>
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
<wps:wsp>
<wps:cNvSpPr txBox="1">
<a:spLocks noChangeArrowheads="1"/>
</wps:cNvSpPr>
<wps:spPr bwMode="auto">
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="2374265" cy="1403985"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
<a:solidFill>
<a:srgbClr val="FFFFFF"/>
</a:solidFill>
<a:ln w="9525">
<a:solidFill>
<a:srgbClr val="000000"/>
</a:solidFill>
<a:miter lim="800000"/>
<a:headEnd/>
<a:tailEnd/>
</a:ln>
</wps:spPr>
<wps:txbx>
<w:txbxContent>
<w:p w:rsidR="006C2E97" w:rsidRDefault="006C2E97">
<w:proofErr w:type="gramStart"/>
<w:r>
<w:t>YOUR CONTENT GOES HERE</w:t>
</w:r>
</w:p>
</w:txbxContent>
</wps:txbx>
<wps:bodyPr rot="0" vert="horz" wrap="square" lIns="91440" tIns="45720" rIns="91440" bIns="45720" anchor="t" anchorCtr="0">
<a:spAutoFit/>
</wps:bodyPr>
</wps:wsp>
</a:graphicData>
</a:graphic>
<wp14:sizeRelH relativeFrom="margin">
<wp14:pctWidth>40000</wp14:pctWidth>
</wp14:sizeRelH>
<wp14:sizeRelV relativeFrom="margin">
<wp14:pctHeight>20000</wp14:pctHeight>
</wp14:sizeRelV>
</wp:anchor>
</w:drawing>
</mc:Choice>
<mc:Fallback>
<w:pict>
<v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe">
<v:stroke joinstyle="miter"/>
<v:path gradientshapeok="t" o:connecttype="rect"/>
</v:shapetype>
<v:shape id="Text Box 2" o:spid="_x0000_s1026" type="#_x0000_t202" style="position:absolute;margin-left:0;margin-top:0;width:186.95pt;height:110.55pt;z-index:251659264;visibility:visible;mso-wrap-style:square;mso-width-percent:400;mso-height-percent:200;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:center;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;mso-width-percent:400;mso-height-percent:200;mso-width-relative:margin;mso-height-relative:margin;v-text-anchor:top" >
<v:textbox style="mso-fit-shape-to-text:t">
<w:txbxContent>
<w:p w:rsidR="006C2E97" w:rsidRDefault="006C2E97">
<w:r>
<w:t>YOUR CONTENT GOES HERE</w:t>
</w:r>
</w:p>
</w:txbxContent>
</v:textbox>
<w10:wrap type="topAndBottom"/>
</v:shape>
</w:pict>
</mc:Fallback>
</mc:AlternateContent>
</w:r>
You can use either the w:drawing or the w:pict syntax. I quite like w:pict with its #style
As a first step you'll want to play in Word with how the boxes are positioned - I guess you want them positioned against the page, not a paragraph.
Then its just a matter of replicating the XML in your choice of language.
You could:
unzip, manipulate, then rezip
doing the manipulation with XML aware tool
or doing the manipulation without that
or use a lib, such as:
for .NET, Microsoft's Open XML SDK
for Java, POI, docx4j
for C, libopc
etc...

Full Serialization in Worfklow 4.0

I'm trying to serialize a workflow (using C#'s workflow 4.0) to retrieve the full workflow XAML and have hit a wall.
I've got an activity (myActivity) that I've created. The contents of the xaml file that describes this activity is:
<Activity mc:Ignorable="sap" x:Class="atest.MySuite" >
<Sequence sap:VirtualizedContainerService.HintSize="222,501">
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<Sequence DisplayName="First Sequence" sap:VirtualizedContainerService.HintSize="200,99">
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</Sequence>
<Sequence DisplayName="Second Sequence" sap:VirtualizedContainerService.HintSize="200,99">
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</Sequence>
<Sequence DisplayName="Third Sequence" sap:VirtualizedContainerService.HintSize="200,99">
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</Sequence>
</Sequence>
</Activity>
Note that the sub sequences show up in the XAML.
When I go to serialize this activity, I use the code I found on MSDN:
using (var sw = new StreamWriter(somePath))
{
sw.Write(a.Log.ToString());
StringBuilder sb = new StringBuilder();
StringWriter tw = new StringWriter(sb);
XamlWriter xw = ActivityXamlServices.CreateBuilderWriter(new XamlXmlWriter(tw, new XamlSchemaContext()));
XamlServices.Save(xw, myActivity);
string serializedActivity = sb.ToString();
}
But the string that comes out the other end is simply:
<?xml version="1.0" encoding="utf-16"?><MySuite xmlns="clr-namespace:atest;assembly=Wtf.Automation.atest" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" />
I've poked around on MSDN and on stackoverflow, but haven't found a way to retrive the full XAML of a custom activity (given an instance of that activity) like what I've described in my xaml file, not just this truncated version.
Does anyone know if there's a way? Code samples and/or pointers would be greatly appreciated.
Thanks!
I believe your issue is that ActivityXamlServices.CreateBuilderWriter works with ActivityBuilder instances. Try
XamlServices.Save(xw, new ActivityBuilder { Implementation = myActivity });
Serialize:
public static string ActivityToXaml(Activity activity)
{
StringBuilder xaml = new StringBuilder();
using (XmlWriter xmlWriter = XmlWriter.Create(xaml, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = false, }))
using (XamlWriter xamlWriter = new XamlXmlWriter(xmlWriter, new XamlSchemaContext()))
using (XamlWriter xamlServicesWriter = ActivityXamlServices.CreateBuilderWriter(xamlWriter))
{
XamlServices.Save(xamlServicesWriter, new ActivityBuilder { Implementation = activity });
}
return xaml.ToString();
}
Deserialize:
public static Activity ActivityFromXaml(string activityXaml)
{
using (var reader = new StringReader(activityXaml))
{
return ActivityXamlServices.Load(reader);
}
}

remove the spaces betwwen the tags in local xml file in iphone sdk

I am having an xml named test11.xml now when i pasrse the data into CXML there are spaces in the parsed xml i want to remove these space ..
Kindly Find my xml data as below
thanks
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" w:macrosPresent="no" w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve"><o:DocumentProperties></o:DocumentProperties><w:fonts><w:defaultFonts w:ascii="Times New Roman" w:fareast="Times New Roman" w:h-ansi="Times New Roman" w:cs="Times New Roman"/></w:fonts><w:docPr></w:docPr><w:body><wx:sect><w:p><w:pPr><w:ind w:left="560" w:first-line="-560"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Menlo" w:h-ansi="Menlo" w:cs="Menlo"/><wx:font wx:val="Menlo"/><w:sz w:val="22"/><w:sz-cs w:val="22"/><w:b/></w:rPr><w:t><CXMLDocument 0x5d16270 [0x5d1b0e0]> <?xml version="1.0"?></w:t></w:r></w:p><w:p><w:pPr><w:ind w:left="560" w:first-line="-560"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Menlo" w:h-ansi="Menlo" w:cs="Menlo"/><wx:font wx:val="Menlo"/><w:sz w:val="22"/><w:sz-cs w:val="22"/><w:b/></w:rPr><w:t><feed
One of the many options i suggest is read the xml in a string then use the function of the string replaceOccuranceOfString to replace space with blank and then parse the data into cxml.
Happy coding...