question

Has-4041 avatar image
0 Votes"
Has-4041 asked TomJebo-9587 edited

Open XML OLE embedding question

I have an OLE server and I am embedding it in Visio. When Visio is saved as vsdm file, I like my part to be also in xml (compressed) so when the file is unzipped, emmbeddings will show as xml file.
I know if I embed Excel in Visio (or other way around), this happens. Excel saved the Binary data to IStorage in two IStream parts.
Package and CompObj. I tried to alse have a Package Stream and used WritePackageToStream of IOpcFactory converting my XML data to stream and placed it in Package. But when uncompressed, all show as a binary entry.
What is the format for third party Servers\controls so that Visio will save it like it does with office applications?
This question is very specific to OLE embedding format!

office-addins-devoffice-visio-itproopenspecs-office-fileformats
· 22
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Has-4041

As your issue is related to Open XML, I would modify the tag.
Thanks for your understanding.

0 Votes 0 ·

I can't find Open XML tag, can you help?

0 Votes 0 ·

Hi @Has-4041,

The Visio file format is not described in the Office Open XML standard and Open Specifications documents (i.e. the tag [openspecs-office-fileformats]) so I'm not sure if Visio is doing something different than the core apps (Word, PowerPoint and Excel). But for those, the embeddings will follow the ISO standard which is described in ISO 29500-1 section 15.2.9, 10, 11. And you're right that Excel will write the .xlsb (MS-XLSB) format into the embeddings part, but that is .xls (binary) in an OPC wrapped package. Word uses the .docx package when embedded.

Perhaps @emilyhua-msft can confirm the Visio format used when embedding Word, PowerPoint, Excel or other apps. I have also added the tag [office-visio-itpro] in case someone monitoring that topic can help.


For strictly binary format (i.e. 97-2003), the embedding structures are described in MS-OLEDS here:
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oleds/85583d21-c1cf-4afe-a35f-d6701c5fbb6f

But it looks like you're talking about Office Open XML.

Best regards,
Tom Jebo
Sr Escalation Engineer
Microsoft Open Specifications Support

0 Votes 0 ·
Show more comments

Tom, my server does not start at all when the saved file (vsdm file) is opened with Visio if IPersistStorageType is 2. But the file looks fine with xml package in the embedding hive.
If I change the value to 1, it starts and loads fine but when I uncompressed the file, it is binary as expected and I dont want that. I still think Container is looking for some additional information if type is 2, but I do not know the internals of it so I cant come up with a solution.
Do you have any more ideas?

0 Votes 0 ·

@Has-4041 & @TomJebo-9587

Both of you can ignore the above comment. I converted the Answer into Comment. It appeared, this very same comment were answered by Tom already.

0 Votes 0 ·

1 Answer

TomJebo-9587 avatar image
0 Votes"
TomJebo-9587 answered TomJebo-9587 edited

To follow up on this for the benefit of the community, @Has-4041 and I worked offline to determine the missing pieces needed for package embedding in Office.
I will summarize what was needed for this poster's specific scenario, removing company, project or personally specific information. Regarding the more generalized documentation, there will be some updates needed in our MS-OI29500: Office Implementation Information for ISO/IEC 29500 Standards Support specification and I'll file a bug to get these added.

NOTE 1: for this scenario, Visio was the main Office app of interest but the following should apply to Word, PowerPoint and Excel as well.
NOTE 2: there is a check in Office for the specific "main part content type" and some hard coded expectations as you see below. The Office team has filed a bug (which is fixed and in the pipeline for publishing but no ETA right now) to remove that check which should allow for main part content types to be other than officeDocument.

In this scenario, the OP's OLE server object is an inprocserver32 based object (i.e. DLL) and other than that is a basic OLE document server that uses an OPC (Open Packaging Convention) XML format for it's document persistence.

Registration for the object should be similar to below (shown for
InprocServer32). Pay attention to the MainPartContentType and extension
information ( .zirt and Extension):


 HKCR
 {
  MIME
  {
  Database
  {
  'Content Type'
  {
  application/zirt 
  {
  val CLSID = s '{558d5b9b-36c2-4f29-ad9d-f563a8ce107d}'
  val Extension = s '.zirt'
  }
  }
  }
  }
  .zirt = s 'EmbedToOffice.EmbedToOfficeObj'
  {
  val 'Content Type' = s 'application/zirt'
  }
  EmbedToOffice.EmbedToOfficeObj = s 'EmbedToOfficeObj class'
  {
  CLSID = s '{558d5b9b-36c2-4f29-ad9d-f563a8ce107d}'
  Insertable
  }
  NoRemove CLSID
  {
  ForceRemove {558d5b9b-36c2-4f29-ad9d-f563a8ce107d} = s 'EmbedToOfficeObj class'
  {
  ProgID = s 'EmbedToOffice.EmbedToOfficeObj'
  VersionIndependentProgID = s 'EmbedToOffice.EmbedToOfficeObj'
  InprocServer32 = s '%MODULE%'
  {
  val ThreadingModel = s 'Apartment'
  }
  ForceRemove Insertable
  MiscStatus = s '0'
    
  val IPersistStorageType =  d '2'
  val MainPartContentType = s 'application/xml'
  AuxUserType
  {
  2 = s 'EmbedToOffice.EmbedToOfficeObj'
  3 = s 'EmbedToOfficeObj class'
  }
  DefaultExtension = s '.zirt, EmbedToOfficeObj class (*.zirt)'
  DataFormats
  {
  DefaultFile = s 'xml'
  }
  }
  }
 }


In the package that the object creates (i.e. it's document content), the _rels/.rels part will need to look like the below. Pay attention to the Relationship Type attribute for the main part relationship (in this case rId1):


 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <Relationships xmlns=http://schemas.openxmlformats.org/package/2006/relationships>
   <Relationship Id="rId1" Type=http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument Target="MyAppZurt/MyAppZurt.xml"/>
 </Relationships>

UPDATE: recently we found that Office will skip the check for the
http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument
relationship if the MainPartContentType registry entry is omitted. This means that you can use a custom (i.e. non-Microsoft) relationship type instead.



Best regards,
Tom Jebo
Sr Escalation Engineer
Microsoft Open Specifications Support

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.