dotnet / Open-XML-SDK

Open XML SDK by Microsoft
https://www.nuget.org/packages/DocumentFormat.OpenXml/
MIT License
4.05k stars 547 forks source link

DocumentFormat.OpenXml.Packaging.CoreFilePropertiesPart has no functional properties #389

Open daniel-white opened 6 years ago

daniel-white commented 6 years ago

Description

DocumentFormat.OpenXml.Packaging.CoreFilePropertiesPart has no functional properties. I'd like to access at least the tags, description and title elements. There seems to be a well defined schema for it.

Information

Concept API surface

public class CoreProperties
{
    public string Category { get; set; } 
    public ContentStatusType ContentStatus { get; set; }
    public DateTimeOffset CreatedAt {get; set;}
    public string CreatedBy {get; set; }
    public string Summary {get; set; }
    public IReadOnlyCollection<Keyword> Keywords {get; }
    public string Language {get; set; }
    public string LastModifiedBy {get; set; }
    public DateTimeOffset? LastModifiedAt {get; set; }
    public DateTimeOffset? LastPrintedAt {get; set; }
    public int? Revision {get; set; }
    public int? Version {get; set; }
    public string Subject {get; set; }
    public string Title {get; set; }
}

public class Keyword
{
    public string Language { get; set; }
    public string Value { get; set; }
}

public enum ContentStatusType 
{
    Draft,
    Reviewed,
    Final
}
tomjebo commented 6 years ago

@daniel-white I haven't played with it much but System.IO.Packaging has the core properties, perhaps as a workaround you can use these: https://msdn.microsoft.com/en-us/library/system.io.packaging.packageproperties(v=vs.110).aspx?

tomjebo commented 6 years ago

and for implementer reference, the properties are defined in 29500-2 11.1 Core Properties Part. @daniel-white confirm that's what your looking for in the generated package.g.cs CoreFilePropertiesPart class? so this likely will be another enhancement to the schema gen code on the back end. (thanks for the suggestion!)

daniel-white commented 6 years ago

Yea. That has it. The productivity tool knows its a CoreFilePropertiesPart, but with a blob of xml.

tomjebo commented 6 years ago

For the community, 29500-2 can be downloaded here: http://standards.iso.org/ittf/PubliclyAvailableStandards/c061796_ISO_IEC_29500-2_2012.zip

twsouthwick commented 6 years ago

Is this request to just expose a well defined set of properties? If so, we can do that without the schema generator updated. @daniel-white can you provide a C# example of what the properties should look like?

daniel-white commented 6 years ago

I'm guessing it should match the PackageProperties. perhaps

CoreFilePropertiesPart part = ....
part.PackageProperties...
twsouthwick commented 6 years ago

In order to decide whether to add it or not, we'll need the actual API surface area that should be considered for the discussion. Would you want to do that?

daniel-white commented 6 years ago

I'm thinking something like this based on the standard:

class CoreProperties
{
    public string Category { get; set; } // category
    public ContentStatusType ContentStatus { get; set; } // contentStatus
    public DateTime CreatedAt {get; set;} //created
    public string CreatedBy {get; set; } // creator
    public string Summary {get; set; } // description
    public List<Keyword> Keywords {get; set; } // keywords
    public string Language {get; set; } // language
    public string LastModifiedBy {get; set; } // lastModifiedBy
    public DateTime? LastModifiedAt {get; set; } // modified
    public DateTime? LastPrintedAt {get; set; } // lastPrinted
    public int? Revision {get; set; } // revision
    public int? Version {get; set; } // version
    public string Subject {get; set; } // subject
    public string Title {get; set; } // title
}
twsouthwick commented 6 years ago

This is package level, right? So it would be something like:

public abstract class OpenXmlPackage
{
   public CoreFilePropertiesPart CoreFilePropertiesPart { get; }
}

Are there any other places this would need to be accessible from?

daniel-white commented 6 years ago

Yea I think it is, thats where i found it. Not sure if its used elsewhere. I dont know the standard well enough.

twsouthwick commented 6 years ago

A couple items on your API:

twsouthwick commented 6 years ago

Yeah, I'm not well versed enough in the standard to know off the top of my head, either. @tomjebo @tarunchopra can you guys comment here?

daniel-white commented 6 years ago
twsouthwick commented 6 years ago

Cool. Can you update the initial issue to have the APIs discussed here? We'll want someone who knows the spec a bit more than I do to sign off as well (@tomjebo @tarunchopra @ThomasBarnekow) but this looks good to me.

twsouthwick commented 6 years ago

@daniel-white I cleaned up the API proposal a bit.

We may want to consider making Keyword a struct.

Still34 commented 5 years ago

Has this feature been added? It's been a year since the last discussion comment.

github-actions[bot] commented 4 years ago

Stale issue message

Still34 commented 4 years ago

Bump for refreshing the issue; has this been implemented anywhere yet?

megapro17 commented 8 months ago

Bruh. Why it was closed if it was almost done?

twsouthwick commented 8 months ago

Not sure why it was closed - reopening so if anyone wants to continue with the design/implementation

AlfredHellstern commented 3 months ago

@megapro17 - Please feel free to submit a PR with your proposed changes.