-
Notifications
You must be signed in to change notification settings - Fork 491
Schema for: CT_ImageData, CT_OleObject, CT_Shape and support inside (CT_Object). #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zhexiao
wants to merge
10
commits into
unidoc:master
Choose a base branch
from
zhexiao:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8d5685b
get inline image from Run
zhexiao a5cddfa
新增对word文档中oleObject公式的解析!!!
zhexiao 5673a58
Merge branch 'master' into master
gunnsth b94216a
新增对文档中公式、图片的数据解析
zhexiao f49b051
Merge branch 'master' of github.com:zhexiao/unioffice
zhexiao 05ce52b
新增读取图片尺寸大小
zhexiao fd53f3f
Merge branch 'master' into master
gunnsth 9a043bd
update code by follow the developer ruler
zhexiao 28f0610
update code by follow the developer ruler
zhexiao 01c74ee
add oleObejct test example
zhexiao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| //name: zhexiao(肖哲) | ||
zhexiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| //date: 2019-10-10 | ||
| //一些与公式相关的数据结构体 | ||
| //================================start | ||
| package document | ||
|
|
||
| import "github.com/unidoc/unioffice/schema/soo/wml" | ||
|
|
||
| type OleObjectPath struct { | ||
| rid string | ||
| path string | ||
| } | ||
|
|
||
| type OleObjectWmfPath struct { | ||
| rid string | ||
| path string | ||
| } | ||
|
|
||
| type OleObject struct { | ||
| oleobject *wml.CT_OleObject | ||
| shape *wml.CT_Shape | ||
| } | ||
|
|
||
| func (o OleObject) Shape() *wml.CT_Shape { | ||
| return o.shape | ||
| } | ||
|
|
||
| func (o OleObject) OleObject() *wml.CT_OleObject { | ||
| return o.oleobject | ||
| } | ||
|
|
||
| func (o OleObject) OleRid() string { | ||
| return *o.oleobject.IdAttr | ||
| } | ||
|
|
||
| func (o OleObject) ImagedataRid() string { | ||
| return *o.shape.Imagedata.IdAttr | ||
| } | ||
|
|
||
| func (o OleObjectPath) Rid() string { | ||
| return o.rid | ||
| } | ||
|
|
||
| func (o OleObjectPath) Path() string { | ||
| return o.path | ||
| } | ||
|
|
||
| func (o OleObjectWmfPath) Rid() string { | ||
| return o.rid | ||
| } | ||
|
|
||
| func (o OleObjectWmfPath) Path() string { | ||
| return o.path | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| //name: zhexiao(肖哲) | ||
| //date: 2019-10-10 | ||
| //新增CT_Shape下面的imagedata解析 | ||
| //================================start | ||
| package wml | ||
|
|
||
| import ( | ||
| "encoding/xml" | ||
| "fmt" | ||
| "github.com/unidoc/unioffice" | ||
| ) | ||
|
|
||
| type CT_Imagedata struct { | ||
| //r:id | ||
| IdAttr *string | ||
|
|
||
| TitleAttr *string | ||
| } | ||
|
|
||
| func NewCT_Imagedata() *CT_Imagedata { | ||
| ret := &CT_Imagedata{} | ||
| return ret | ||
| } | ||
|
|
||
| func (m *CT_Imagedata) MarshalXML(e *xml.Encoder, start xml.StartElement) error { | ||
| if m.IdAttr != nil { | ||
| start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "r:id"}, | ||
| Value: fmt.Sprintf("%v", *m.IdAttr)}) | ||
| } | ||
|
|
||
| if m.TitleAttr != nil { | ||
| start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "title"}, | ||
| Value: fmt.Sprintf("%v", *m.TitleAttr)}) | ||
| } | ||
|
|
||
| _ = e.EncodeToken(start) | ||
| _ = e.EncodeToken(xml.EndElement{Name: start.Name}) | ||
| return nil | ||
| } | ||
|
|
||
| func (m *CT_Imagedata) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { | ||
| // initialize to default | ||
| for _, attr := range start.Attr { | ||
| if attr.Name.Space == "http://schemas.openxmlformats.org/officeDocument/2006/relationships" && attr.Name.Local == "id" { | ||
| parsed, err := attr.Value, error(nil) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| m.IdAttr = &parsed | ||
| continue | ||
| } | ||
|
|
||
| if attr.Name.Space == "urn:schemas-microsoft-com:office:office" && attr.Name.Local == "title" { | ||
| parsed, err := attr.Value, error(nil) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| m.TitleAttr = &parsed | ||
| continue | ||
| } | ||
| } | ||
| lCT_Imagedata: | ||
| for { | ||
| tok, err := d.Token() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| switch el := tok.(type) { | ||
| case xml.StartElement: | ||
| switch el.Name { | ||
| default: | ||
| unioffice.Log("skipping unsupported element on CT_Imagedata %v", el.Name) | ||
| if err := d.Skip(); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| case xml.EndElement: | ||
| break lCT_Imagedata | ||
| case xml.CharData: | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // Validate validates the CT_OleObject and its children | ||
| func (m *CT_Imagedata) Validate() error { | ||
| return m.ValidateWithPath("CT_Imagedata") | ||
| } | ||
|
|
||
| // ValidateWithPath validates the CT_OleObject and its children, prefixing error messages with path | ||
| func (m *CT_Imagedata) ValidateWithPath(path string) error { | ||
| return nil | ||
| } | ||
|
|
||
| //================================end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.