Staff DotNet Blogs
Search :

According to information from some blogs (http://blogs.zdnet.com/BTL/?p=22595 ) Microsoft has been prohibited to sell any Microsoft Word product with the capability to use “custom xml parts”. 

The suit was presented by i4i (i4i.com).  They patented an XML authoring technology and developed a product called x40 (Xml 4 Office) which allows the user to create xml based template documents for authoring documents at Microsoft Word.

What x40 does seems very similar to me to what you can do by adding content controls to a Microsoft Word 2007 document and binding those content controls to xml files inserted into the Microsoft Word 2007document package (remember that a Microsoft Word 2007 document is actually a compressed –zip- file). 

I tried to read the original suit and i4i patent but it will take me some more hours (and tons of cups of coffee to fully understand it).  In the mean time I just want to ask your help in order to understand what this judgment against Microsoft means for those who are using custom xml parts in their software solutions.

To start, I have the following question: Does this court resolution include the use of content controls or just custom xml parts?

Your comments and/or emails to openxml@staffdotnet.com are really appreciated

Hi,

 

This is the first post on a series about integrating Open Xml and Microsoft Sharepoint in order to create powerful document automation and collaboration solutions.  In this post I'm creating a web part which displays metadata information (number of pages, paragraphs and characters for a WordProcessingML document) selected from a document library.  The web part (and source document library) will look like this:

OpenXmlMetaDataWebPart.jpg

Because displaying the step by step guide here will result in a very long post I've decided to create the step by step in a separate file you can download from here.  You can also download the source code from here.  Enjoy!!!

Content Controls are a new mechanism added at Office 2007 (actually it is part of the Open Xml Document Definition Standard) which allows software developers and Office advance users to add fields to an Office document whose value can be bound to a specific information source (so when the value in that source changes this change is immediately reflected at the document where the content control is defined).

Office Interop Layer 12.0 adds support to work with Content Controls in Office 2007.  It offers access to the Content Controls collection (please see this post for more information about that) as well as an event model to deal with user interaction with the content controls at the document.  By using this event model you are able to know when a user has entered a content control, exited a content control, deleted or added a new content control.  That is pretty handy if you want to create a fully interactive Office document… however… there is some important (and perhaps undocumented) information you should be aware of when using the Office Interop Layer Content Control event model: don’t use the events directly from the Word.Document Office Interop if you want to activate and deactivate those events along the application execution.  I mean don’t go like this:

Word.Document document = application.ActiveDocument;

Document.OnContentControlEnter += ContentControlEventDelegateMethod();

 

///Do something here

 

Document.OnContentControlenter -= ContentControlEventDelegateMethod();

 

Instead of that, create a wrapper class in .NET around the Word.Document and expose the same event model from that class (bubbling up the content control events raised at Word.Document).  Then, set the delegates to that wrapper class content control events (instead of setting the delegates to the Word.Document content controls events as discussed previously).

I got to that solution after hours and hours of breaking my head for a random Word 2007 crash issue with one application I was working on.  I hope this can be of help to many of you.

Hi.  This is a note I want to publish here about something I discovered recently when programmatically accessing Content Controls located inside a Word 2007 document by using the Office Automation API (Office Interop Layer).

The Office Automation API provides a Document class which contains a ContentControls collection.  According to my expectations the ContentControls collection should include all of the content controls located inside the document, however, it doesn’t.  It does not include the content controls located inside text boxes (or any kind of shape added to the document).  So, if you want to get ALL OF THE CONTENT CONTROLS located inside a document you also need to traverse the Document.Shapes collection and look into the Range.ContentControls collection for each one of those shapes (besides traversing the Document.ContentControls collection).

Hope this helps.

Hello everybody!!!

 

It’s been almost 3 months since I started the Open Xml Account at Twitter.  We are now 52 members including the following fellows who recently joined:

  • jasonharrop
  • znarknesor
  • jassand
  • DavidMarsolek
  • edmunbolton

Thanks a lot for joining and please spread the world about this initiative.

 

I’m also very happy to know that OpenXmlDeveloper.org and OpenXmlCommunity.com already have their Twitter accounts (OpenXmlDev and OpenXmlComm respectively).  We are following them of course!!! :D

 

Finally (for this post) I want to list the most recent entries:

·         RT @dmahugh Graphical example of code reduction when moving from System.IO.Packaging to the Open XML SDK.  http://tinyurl.com/orybje

·         Looking for an entry inside an SpreadsheetML document by using LINQ http://tinyurl.com/rbx9hg

·         Comparison of Navigating Parts between System.IO.Packaging and the Open XML SDK http://tinyurl.com/orybje

·         Retweeting @OpenXMLDev: new library article - see how to create a spreadsheet with formatting using PHPExcel SDK http://bit.ly/DYBh3

·         Adjusted ECMA 376 schemas http://tinyurl.com/pntdu8

·         Retrieving Word Content Based on Styles (post at Brian Jones blog) http://tinyurl.com/c2t866

·         RT @dmahugh ODF spreadsheet interoperability blog post: http://tinyurl.com/d76cer

·         Retweeting @OpenXMLDev: Simple OOXML Library available on Codeplex.  Create Word and Excel XML easily http://bit.ly/4keSY

·         Converting Content Controls to Straight Text in WordProcessingML documents http://tinyurl.com/c6kxlw

The following code shows how to look for a specific entry inside a SpreadsheetML document.  I’m using LINQ for XML and the Open Xml SDK April 2009 CTP to do that.  The solution was implemented by using VS 2008.  This sample code only looks for entries at the Shared Strings Part.  An improved version working with inline values is coming soon. 

Because source code is very well documented internally then I’m not going to spend many lines here explaining it (besides of that, it is very simple and straightforward).  Just to help you to get started, open the Windows Desktop Test App, double click on the “Look for entry” button, put a breakpoint there and start inspecting the code.  If you have some comments or questions please don’t hesitate to contact me at openxml@staffdotnet.com

Download source code here

I have good news for those of you who may have found some minor issues with ECMA 376 schemas when using them in a .NET Schema Set.  Mr. Alt Colman has published a revised and adjusted set of ECMA 376 schemas which fix up those issues.  You can get the adjusted schemas here:

http://schema-archive.com/openxmlformats.org/200812/sml.xsd
http://schema-archive.com/openxmlformats.org/200812/wml.xsd
etc.

Thanks Mr. Colman!!!

Collapsible Panel is a Windows Forms control to create collapsible regions at Windows Forms (similar to the regions for grouping controls at Visual Studio Toolbox form).

The following pictures show what you can accomplish by using this control:

CollapsiblePanel_AllPanelsCollapsed.jpgCollapsiblePanel_2PanelsExpanded.jpg

You can download the source code and user guide at CodePlex: http://www.codeplex.com/collapsiblepanel

I hope you find this control useful.

Johann



The following code contains an example showing how to convert content controls to straight text.  The trick to do that is replacing the content control markup with the markup corresponding to its “sdtContent” element.  You can see that by inspecting the “ConvertContentControls” method at WordProcessingDocumentManager class in StaffDotNet.OpenXml.Samples project.

Download the code here

The solution was developed by using Visual Studio 2008, XLINQ (contained in .NET Framework 3.5) and the Open Xml SDV v2.0 April 2009 CTP

This is a sample about how to create content controls and binding them to custom xml parts by using the Open Xml SDK v2.0 (April 2009 CTP)

For those of you who are hearing about content controls for the first time I recommend you to take a look at this .  Regarding Custom Xml Parts they are XML based files you can add to a Open Xml Document in order to store custom information you can bind with appropriated elements inside the document (content controls in this case).

In this sample, we are using the Open Xml SDK v2.0 to do so.  When you open the solution (written in VS 2008) you will find two projects: OpenXml.Helpers.ContentControl and OpenXml.Helpers.ContentControl.TestApp

The first one is a class library which contains a class named  WordDocumentManager containing the logics to add custom xml parts and content controls to a WordProcessingML document (setting the databinding between them) The second one is a Windows Desktop application used to test the class library.

Both projects are fully documented internally so I’m not going to spend a lot of words here explaining how they work.  What I’m going to say in order for you to get started is… “start your source code inspection by looking at the btnAddContentControl_Click at frmContentControlTestApp form class.  Put a breakpoint there, run the Test App project, look for the Word 2007 document you want to add the content control to and press the “Add Content Control” button.  You will be taken to the method mentioned previously so you can continue traversing the source by using the F11 shortcut key”.

I hope this helps to those of you wondering how to work with Content Controls and Custom Xml Parts by using the Open Xml SDK v2.0

If you have some comments or questions please don’t hesitate to contact me at openxml@staffdotnet.com

Get the source code here

The following code contains a class library and a test application for showing up how to embed an Open Xml document inside another Open Xml document.  The code is fully internal documented so I think I don’t need to make further explanations here.  The only thing I’m going to say about the code (in order to help you to get started) is… start by looking at the “EmbedOpenXmlDocument” method at the “OpenXmlEmbeddingPresentationML” class

If you have some comments, doubts or any kinds of feedback about it please don’t hesitate to contact me at openxml@staffdotnet.com. 

Please notice that this first version of the code only works with the following combination: embedding SpreadsheetML files into PresentationML files.  However, having this as a sample it is relatively easy to do the same for the rest of cases.  I’m going to do that in future versions of the source code.  In the meantime, I wanted to post the code as it is right know because I have seen many entries at forums asking for help on this topic and I want to give these people a hand.  Hope you find this code helpful J

Click here to get the code

OpenXmlDeveloper.org, a web site dedicated to provided very valuable info and assets  for developers interested in Open Xml and OpenXmlCommunity.org, a web site dedicated to promote a business oriented community around Open Xml have entered the Twitter world. 

They both have created an account at Twitter: OpenXmlDev for OpenXmlDeveloper.org and OpenXmlComm for OpenXmlCommunity.org.  From now on we can be informed about the latest news from those sites by becoming a follower of their Twitter accounts.  We (OpenXml account) have already done that so if you are already a follower of us you will be automatically informed about new developments coming from those sites. 

However, if you don’t want to miss any piece of information about OpenXml perhaps you would like to become a follower of the three accounts.  The more connected you are the better information you get J

Drawing objects like TextBoxes are stored in separated xml parts referenced inside the sheet part by using a relation.  You can get the xml markup for the TextBox (or drawing) by opening the [sheetName].xml part (where [sheetName] corresponds to the sheet where the drawing is located) and looking for the elements.  Then, you take the relationship id indicated by the r:id attribute , open the [sheetName].xml. rels files and look for the Relationship element whose Id attribute corresponds with value for the r:id attribute indicated previously.  The Target attribute for the Relationship element will tell you where the xml part containing the drawing definition is located.

Once you know the location for the drawing you want to modify you can open it and in order to set the row and column values you look for the following elements: xdr:From and xdr:To.  Inside these elements there are two sub elements named xdr:col and xdr:row.  These are the elements you need to modify in order to set the starting and ending row and column for the drawing.

Hi everybody,

It’s been a long time (6 weeks approximately since I updated this blog for the last time).  Thanks God I have had too much work to do so it was very complicated for me to post in my blog during this time.

 

But I’m back and the first thing I want to do is say “Thank you very much” to the people who have joined us since last post:

- Pplimmer

- Fiberartisan

- FabioBermudez

- AaronCutlip

- MsShields

- Denisum

- JerryViena

- Jerome_maraquin

- Ed_dodds

- Hansbos

- Lolomodusa

- Djandme

- ZippyNy

- A_jenkins

- Baseballplyr

- Sameers3

- Gray_knowlton

- Wnukowski

 

Regarding new resources posted during these weeks I can mention the following:

- Announcing the Release of PowerTools for Open XML V1.1 http://tinyurl.com/dl5flf

- Using XSLT with Open XML Documents, and an Open XML Crawler (post at Eric White blog) http://tinyurl.com/d5h4xj

- Importing Charts from Spreadsheets to Wordprocessing Documents (post at Brian Jones blog) http://tinyurl.com/c4blu4

- Interesting Code for Manipulating Open XML Documents using the Open XML SDK V2  (posted at Eric White blog) http://tinyurl.com/cf7lo3

 

I will be updating this blog and the Open Xml Twitter account very soon with more information and news from the SG 34 meeting at Praga.

 

Thanks again for your patience and stay tune!!!

Hello everybody!!!

This is what has being going on with the Open Xml Twitter Account:

These are our new friends (thanks for joining!!!)

·         danwygant

·         draakusa

·         rduclos

·         cauld

·         goodol

·         CSkardon

No new resources were mentioned in previous week updates.  I apologize about that.  This is going to change for this week.  I want to take the opportunity of this post to remain you that if you have some resource (blog post, software tool, etc) about Open Xml and you want to share it with the rest of the crew please send me and email to: openxml@staffdotnet.com Thanks in advance for your cooperation!!!

Johann
 

In the first post of this series about Content Control Types in Open Xml (Word 2007) I made an introduction about them and about using them for creating “living” documents (documents containing data coming from the software applications at the company backend).

In this second post I’m going to talk about the different content control types available in Open Xml in terms of using them to create “living” documents.

Content Control Types

The following are the content control types available in Word 2007 (Open Xml):

· Text Box

· Picture

·  Combo Box

·  Drop-Down List

·  Date Picker

·  Rich Text Box

·  Document Building Block

 The first 5 content control types in the previous list are single content controls.  The last two are containers.  This means that you can insert another content controls inside them (as well as fixed text and practically any other element available in Word 2007)

The following is a more detailed specs list of each content control type:

Text Box Content Control

·  Allows a single value

·  Not a container

·  Bind able

 Picture

·   Allows a single value (image)

·   Not a container

·   Not Bind able

Combo Box

·   Allows a single value (picked from a list of available items)

·   Not a container

·   Bind able

Drop Down List Box

·   Allows a single value (picked from a list of available items)

·   Not a container

·   Bind able

Date Picker

·   Allows a single value (date)

·   Not a container

·   Bind able

Rich Text Box

·   Allows multiple values

·   It may contain other content controls

·   Not Bind able

Document Building Block

·   Allows multiple values

·   It may contain other content controls

·   Not bind able

·   Allows inserting Word 2007 built-in elements inside the document

It is not my intention with this post (and the whole post series) to show you how to configure each one of these elements inside Word 2007.  However, I’m going to create a series of screen cast about that soon. In the meantime I’m preparing the third post of this series where I’m going to show you how to bind the content controls with a custom xml part (custom xml file)

 

Hello everybody…

It’s been two weeks since Open Xml Twitter Account was created and I want to share with you what happened during the last week (first week review is here):

 

First of all I want to welcome again our new fellow members:

·  Mark_Baker

·  Phpmind

·  Jccim

·  Speront

·  HairyHighlander

·  Alexfalk

·  MCAMSDN

·  Jlundstocholm

 

These are the resources about Open Xml we shared with you last week:

·  Removing Comments from a WordProcessing Document http://tinyurl.com/ap7nwj

·  ECMA-376 (Open Xml) specification online http://tinyurl.com/dzayax

·  Move/Insert/Delete Paragraphs in Word Processing Documents using the Open XML SDK http://tinyurl.com/dz54eu

·  Using PHPExcel + Google Docs http://tinyurl.com/dlw7n4

·   Creating SpreadsheetML (Excel 2007) documents in PHP: http://www.codeplex.com/PHPExcel

·   Open Xml Community Web Site: http://www.openxmlcommunity.org/

·   News from Okinawa Meetings about ISO29500 (Open Xml) Maintenance process at Dough Mahugh blog: http://tinyurl.com/benn2r

·   Difference between .Elements and .Descendants in LINQ http://tinyurl.com/dk6z29

 

 Thanks again to the “old” and “new” fellows for joining and please keep spreading the word about this Open Xml Twitter Account.  Open Xml Community around the world is growing up quickly and that only means more and better opportunities for everyone who’s involved.

 

See you during the week…

 

Best regards,

 

Johann

Hello,

I’m far from being an expert in LINQ (well, at least that is what I think) however I been working with this technology for a while because of my work with Open Xml.  During this time I have discovered some interesting things that I want to share with you.  Some of them may seem trivial to some of you but I’m pretty sure they are going to save a lot of time for many others.

 

The first thing about LINQ I want to share with you is the difference between the .Elements and .Descendants XElement class methods.  

 

Let’s do that by using the following piece of XML markup:

 

<orders>

  <order id="1">

    <suborders>

      <order id = "2"/>

    suborders>

  order>

orders>

 

If we execute the following piece of code…

 

XDocument xDoc = XDocument.Load("orders.xml");

 

            XElement[] xResultWithElements = xDoc.Root.Elements("order").ToArray();

 

            XElement[] xResultWithDescendants = xDoc.Root.Descendants("order").ToArray();

 

xResultWithElements XElement array will contain 1 item and the xResultWithDescendants XElement array will contain 2 items

 

Why?

 

Well… because the .Elements property look for elements only at the XElement being searched children nodes, meanwhile .Descendants traverse all of the xml markup looking for matching nodes starting from the XElement being searched. 

 

.Elements will only get order 1 and .Descendants will get order 1 and order 2 (located at the suborders child node for order 1)

 

Well… it’s been a week since I started the Open Xml Twitter Account so I want to share with you what is going on with it…

First, I want to thank the following people who became the Open Xml Twitter account first followers

·        ferglo

·        CAMURPHY

·        oocx

·        PaulBunting

·        pskelly

·        JChable

·        Dmahugh

·        Maartenballiauw

 

I want to thank everyone for joining.  Particularly, I want to welcome Dough Mahugh, Open Xml Product Manager at Microsoft.  Dough, I’m pretty sure you will have a lot of good and very interesting news to share with us about Open Xml and any other related technology.

 

Finally, I want to remain you some of the interesting resources which have been mentioned at the received messages:

·   Embedding Office 2007 documents into Windows Desktop Applications http://tinyurl.com/csajn8

·   Nice set of demos about possible Open Xml usage scenarios: http://www.codeplex.com/OpenXmlDemos

·   Open Xml recommended tool: Open Xml Power Tools http://www.codeplex.com/PowerTools

·   Extra recommended blog for Open Xml and other Office Document Automation related stuff: http://blogs.msdn.com/brianjones

·   Dough Mahugh (Microsoft Open Xml Product Manager) blog: http://blogs.msdn.com/dmahugh/

 

Well… we will be in touch during the week!!! If you have already joined, thanks again and please tell your friends.  If you haven’t,  please join the crew and tell your friends as well!! J

Recently we were asked by a client to create a Desktop Applications which embeds Word 2007 documents in order to interact with them.  We were worked previously interacting with Word 2003 and 2007 documents by using the Microsoft Office Interop (COM based API) but we haven’t hosted Word documents in an application before.  Then, one of our client developers came to us with this: http://www.microsoft.com/downloads/details.aspx?FamilyId=CE2CA4FD-2169-4FAC-82AF-770AA9B60D77&displaylang=en .  That link if for downloading the “Microsoft Developer Support Office Framer Control”, a VC++ ActiveX control to host Microsoft Office 2003 and 2007 documents.

We have use the Framer Control and it works pretty well.   We have detected it some sort of instability when you have both an application containing the Framer and Microsoft Word (in our case) open.   However, we have been using the framer just for a while so we will manage to fix it up (I will write a post when we do that). 

Well, I just wanted to share with you this information in case you were wondering how to embed a Microsoft Office Document into your application.  Of course, if you know about any other solution you are kindly invite to share that information with us.  Thanks!!! J