Hiding parts of OpenXml documents programmatically - ms-word

Is it possible to programmatically hide parts of an OpenXML document, without actually removing it?
The reason I would want to do this: This is a template file, dynamic parts are filled using databindig. And some parts should be hidden, if there is no backing data. But don't want to actually remove parts from the document, so the document could be "refreshed" later with new data.
Something like display: none in html/css.

The is no exact equivalent to hiding content in Word using the open xml sdk. However there are two approaches that might work for you:
Hidden paragraph trick
Create a style, let's call it HiddenParagraph. Define it in your styles.xml as follows:
<w:style w:type="paragraph" w:customStyle="1" w:styleId="HiddenParagraph">
<w:name w:val="HiddenParagraph" />
<w:next w:val="Normal" />
<w:pPr>
<w:spacing w:line="14" w:lineRule="auto" />
</w:pPr>
<w:rPr>
<w:rFonts w:asciiTheme="minorHAnsi" w:eastAsiaTheme="minorEastAsia" w:hAnsiTheme="minorHAnsi" w:cstheme="minorBidi" />
<w:sz w:val="22" />
<w:szCs w:val="22" />
</w:rPr>
</w:style>
The w:line=14 makes the paragraph effectively invisible.
Now render the content your don't want to see using this paragraph style.
<w:p>
<w:pPr>
<w:pStyle w:val="HiddenParagraph" />
</w:pPr>
<w:r>
<w:text>you should not be able to see me
</w:r>
</w:p>
To show the content again just change the paragraph style to normal or some other more sane style.
Custom XML Part
Store data you don't want to display in the document in a custom xml data store, although this might not work in your specific scenario
Reference
http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2010/10/27/59361.aspx

Related

Pass the VisualState of CollectionView Item VisualElement to its child VisualElements

I am having the following situation:
CollectionView, each item is Border, that contains other controls.
When selected, the VisualState of the Border changes to selected. The child controls however do not have a change in their state.
Is there an easy way to link/pass those VisualStates to all child controls?
(cascade, 2,3,4 and more levels deeper)
Edit: I know how to use Triggers, Setters in Styles and other approaches to change the UI of the application. The question is specifically for changing the VisualState of the nested VisualElements. Cannot find anything anywhere on this matter.
You can try to set state on multiple elements.
Visual states could be attached to and operated on single elements. And it's also possible to create visual states that are attached to a single element, but that set properties on other elements within the same scope. This avoids having to repeat visual states on each element the states operate on.
The following example shows how to set state on multiple objects, from a single visual state group:
<StackLayout>
<Label Text="What is the capital of France?" />
<Entry x:Name="entry"
Placeholder="Enter answer" />
<Button Text="Reveal answer">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Property="Scale"
Value="0.8" />
<Setter TargetName="entry"
Property="Entry.Text"
Value="Paris" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Button>
</StackLayout>
Note: Property paths are unsupported in Setter elements that specify the TargetName property.
You can also try to define custom visual states, for more information, you can check: Define custom visual states .

adding style to bullets for word document in openxml

My client have a requirement to add particular style to bullet numbers and character in all levels.
Till now i tried to get NumberingDefinitionsPart from MainDocumentPart and trying to find out any style id for my paragraph.
Unfortunately i am not able to crack it this way since i am getting NumberingDefinitionsPart as null.
my list is
This
Is
The inner Xml looks like
<w:pPr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:pStyle w:val="ListParagraph" />
<w:numPr><w:ilvl w:val="0" />
<w:numId w:val="3" />
</w:numPr><w:spacing w:before="80" w:line="220" w:lineRule="exact" />
</w:pPr>
<w:r xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:t>This</w:t>
</w:r>
<w:pPr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:pStyle w:val="ListParagraph" />
<w:numPr>
<w:ilvl w:val="0" />
<w:numId w:val="3" />
</w:numPr>
<w:spacing w:before="80" w:line="220" w:lineRule="exact" />
</w:pPr>
<w:r xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:t>Is</w:t>
</w:r>
Is there anything i am missing in my document?
Can i archive it any other way?
Thanks in advance.

GWTBootstrap3 equivalent of android's "match-parent"

Is there any way to fix the size of a Panel to take up the full space inside its Column instead of wrapping around the content?
My parent column has 2 panels side by side- one for stacked Navpils menu (with variable number of items) and one to show the data based on menu choice. I need the data panel to match the height of the menu panel.
Here's the relevant section of code:
<b:Column size="MD_3">
<b:Panel>
<b:PanelHeader>
<b:Heading size="H3" text="Services" />
</b:PanelHeader>
<b:PanelBody>
<b:NavPills stacked="true">
<b:AnchorListItem text="ClockService" ui:field="clockService" />
<b:AnchorListItem text="CloudService" ui:field="cloudService" />
<b:AnchorListItem text="CommandService" ui:field="commandService" />
<b:AnchorListItem text="WebConsole" ui:field="webConsole" />
<b:AnchorListItem text="DataService" ui:field="dataService" />
<b:AnchorListItem text="MqttDataTransport" ui:field="mqttDataTransport" />
<b:AnchorListItem text="SslManagerService" ui:field="sslManagerService" />
<b:AnchorListItem text="WatchdogService" ui:field="watchdogService" />
</b:NavPills>
</b:PanelBody>
</b:Panel>
</b:Column>
<b:Column size="MD_9">
<b:Panel ui:field="contentPanel">
<b:PanelHeader ui:field="contentPanelHeader">
</b:PanelHeader>
<b:PanelBody ui:field="contentPanelBody">
</b:PanelBody>
</b:Panel>
</b:Column>
Any help or suggestions are appreciated, I'm also open to using other widgets as long as they provide a similar view.
If you want the contents of a *Panel to use up all the available space, just wrap its contents in a Column with the appropriate size (like MD_12). Depending on your layout, it might be sufficient to reverse the hierarchy - the Panel should be the parent and the Column its child. If you have a lot of situations like this (or this is a widget that's used a lot), you can avoid "unnecessary" wrapping by just applying the CSS style .col-md-12 to your widget (the Panel's contents) directly.

How to open a URL (generated using XMLNode in MS Word) open in a new window?

I am creating a word document report where a website hyperlink will be generated using below code.
Here I am using w:tgtFrame='_blank' but no use that it still gets opened in the same browser.
Please let me know for the solution.
<w:document>
<w:p w:rsidR='00CA103F' w:rsidRDefault='00CA103F' w:rsidP='00264350'>
<w:r>
<w:t>Website: </w:t>
</w:r>
<w:hyperlink r:id='rId100' w:history='1' w:tgtFrame='_blank'>
<w:r w:rsidRPr='00CA103F'>
<w:rPr>
<w:rStyle w:val='Hyperlink' />
<w:rFonts w:cs='Arial' />
<w:u w:val='single' />
</w:rPr>
<w:t>" + Website + "</w:t>
</w:r>
</w:hyperlink>
</w:p>
</w:document>"
I got this from another forum:
http://answers.microsoft.com/en-us/office/forum/office_2010-word/hyperlinks-in-msword-2010-target-frame-issue/e65c6ee2-6b3c-475f-8d01-1f5b49f91a09
It looks like Adobe issue that the URL will display in the same window and now solution yet from Adobe.

Word 2007, Open XML - embedding an image

Do you know what basic information MUST include a paragraph (<w:p/>) in document.xml inside a *.docx document, that specifies an image? I do know there must be:
<a:blip r:embed="rId4" />
specifing the relationship id, but what else?
It's very hard to find it in Google and experimenting with cutting out tags from a ready document or reading the specification takes a lot of time.
An example with all the required tags would be greatly appreciated.
Word is rather picky concerning the input XML provided. To embed an image, you have to provide quite some information. Here is a simple example:
document.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:body>
<w:p>
<w:r>
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="5943600" cy="3717290"/>
<wp:docPr id="1" name="Picture 0" descr="vlcsnap-325726.png"/>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="0" name="myImage.png"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId4"/>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="5943600" cy="3717290"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</w:r>
</w:p>
</w:body>
</w:document>
document.xml.rels
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<!-- other relationships go here -->
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.png"/>
</Relationships>
And of course the image must be added to the package at the correct location (media/image1.png)
Since all this is rather complicated I would recommend you to use the OpenXML SDK 2.0 provided by Microsoft or another library, e.g. OpenXML4J. These libraries, especially the one from Microsoft can make your work a lot easier.