Open XML OLE embedding question

Has 1 Reputation point
2022-03-16T22:59:13.9+00:00

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 Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,966 questions
Office Open Specifications
Office Open Specifications
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Open Specifications: Technical documents for protocols, computer languages, standards support, and data portability. The goal with Open Specifications is to help developers open new opportunities to interoperate with Windows, SQL, Office, and SharePoint.
139 questions
Visio Management
Visio Management
Visio: A family of Microsoft products used to create diagrams and vector graphics.Management: The act or process of organizing, handling, directing or controlling something.
254 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tom Jebo 1,996 Reputation points Microsoft Employee
    2022-05-16T23:03:08.417+00:00

    To follow up on this for the benefit of the community, @Has 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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.