forked from unidoc/unioffice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,796 changed files
with
281,726 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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 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,11 @@ | ||
language: go | ||
go: | ||
- 1.8.x | ||
- 1.9.x | ||
- tip | ||
script: | ||
- mkdir -p /home/travis/gopath/src/baliance.com/ | ||
- ln -s /home/travis/gopath/src/github.com/baliance/gooxml /home/travis/gopath/src/baliance.com/gooxml | ||
- go vet ./... | ||
- go test -v ./... | ||
- GOFMT=$(gofmt -d -s .) && echo $GOFMT && test -z "$GOFMT" |
This file contains 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,149 @@ | ||
Thank you for your interest in contributing to gooxml ("We" or "Us"). | ||
|
||
The purpose of this contributor agreement ("Agreement") is to clarify and | ||
document the rights granted by contributors to Us. | ||
|
||
|
||
# 1. DEFINITIONS | ||
|
||
"YOU" means the Individual Copyright owner who submits a Contribution to Us. If | ||
You are an employee and submit the Contribution as part of your employment, You | ||
have had Your employer approve this Agreement or sign the Entity version of this | ||
document. | ||
|
||
"CONTRIBUTION" means any original work of authorship (software and/or | ||
documentation) including any modifications or additions to an existing work, | ||
Submitted by You to Us, in which You own the Copyright. If You do not own the | ||
Copyright in the entire work of authorship, please contact Us at | ||
[email protected]. | ||
|
||
"COPYRIGHT" means all rights protecting works of authorship owned or controlled | ||
by You, including copyright, moral and neighboring rights, as appropriate, for | ||
the full term of their existence including any extensions by You. | ||
|
||
"MATERIAL" means the software or documentation made available by Us to third | ||
parties. When this Agreement covers more than one software project, the Material | ||
means the software or documentation to which the Contribution was Submitted. | ||
After You Submit the Contribution, it may be included in the Material. | ||
|
||
"SUBMIT" means any form of physical, electronic, or written communication sent | ||
to Us, including but not limited to electronic mailing lists, source code | ||
control systems, and issue tracking systems that are managed by, or on behalf | ||
of, Us, but excluding communication that is conspicuously marked or otherwise | ||
designated in writing by You as "Not a Contribution." | ||
|
||
"SUBMISSION DATE" means the date You Submit a Contribution to Us. | ||
|
||
"DOCUMENTATION" means any non-software portion of a Contribution. | ||
|
||
|
||
# 2. LICENSE GRANT | ||
|
||
## 2.1 Copyright License to Us | ||
|
||
Subject to the terms and conditions of this Agreement, You hereby grant to Us a | ||
worldwide, royalty-free, NON-exclusive, perpetual and irrevocable license, with | ||
the right to transfer an unlimited number of non-exclusive licenses or to grant | ||
sublicenses to third parties, under the Copyright covering the Contribution to | ||
use the Contribution by all means, including, but not limited to: | ||
|
||
* to publish the Contribution, | ||
|
||
* to modify the Contribution, to prepare derivative works based upon or | ||
containing the Contribution and to combine the Contribution with other | ||
software code, | ||
|
||
* to reproduce the Contribution in original or modified form, | ||
|
||
* to distribute, to make the Contribution available to the public, display and | ||
publicly perform the Contribution in original or modified form. | ||
|
||
2.2 Moral Rights remain unaffected to the extent they are recognized and not | ||
waivable by applicable law. Notwithstanding, You may add your name in the header | ||
of the source code files of Your Contribution and We will respect this | ||
attribution when using Your Contribution. | ||
|
||
|
||
# 3. PATENTS | ||
|
||
## 3.1 Patent License | ||
|
||
Subject to the terms and conditions of this Agreement You hereby grant to us a | ||
worldwide, royalty-free, non-exclusive, perpetual and irrevocable (except as | ||
stated in Section 3.2) patent license, with the right to transfer an unlimited | ||
number of non-exclusive licenses or to grant sublicenses to third parties, to | ||
make, have made, use, sell, offer for sale, import and otherwise transfer the | ||
Contribution and the Contribution in combination with the Material (and portions | ||
of such combination). This license applies to all patents owned or controlled by | ||
You, whether already acquired or hereafter acquired, that would be infringed by | ||
making, having made, using, selling, offering for sale, importing or otherwise | ||
transferring of Your Contribution(s) alone or by combination of Your | ||
Contribution(s) with the Material. | ||
|
||
##3.2 Revocation of Patent License | ||
|
||
You reserve the right to revoke the patent license stated in section 3.1 if we | ||
make any infringement claim that is targeted at your Contribution and not | ||
asserted for a Defensive Purpose. An assertion of claims of the Patents shall be | ||
considered for a "Defensive Purpose" if the claims are asserted against an | ||
entity that has filed, maintained, threatened, or voluntarily participated in a | ||
patent infringement lawsuit against Us or any of Our licensees. | ||
|
||
|
||
# 4. DISCLAIMER | ||
|
||
THE CONTRIBUTION IS PROVIDED "AS IS". MORE PARTICULARLY, ALL EXPRESS OR IMPLIED | ||
WARRANTIES INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTY OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE | ||
EXPRESSLY DISCLAIMED BY YOU TO US AND BY US TO YOU. TO THE EXTENT THAT ANY SUCH | ||
WARRANTIES CANNOT BE DISCLAIMED, SUCH WARRANTY IS LIMITED IN DURATION TO THE | ||
MINIMUM PERIOD PERMITTED BY LAW. | ||
|
||
|
||
# 5. CONSEQUENTIAL DAMAGE WAIVER | ||
|
||
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL YOU OR US BE | ||
LIABLE FOR ANY LOSS OF PROFITS, LOSS OF ANTICIPATED SAVINGS, LOSS OF DATA, | ||
INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL AND EXEMPLARY DAMAGES ARISING OUT | ||
OF THIS AGREEMENT REGARDLESS OF THE LEGAL OR EQUITABLE THEORY (CONTRACT, TORT OR | ||
OTHERWISE) UPON WHICH THE CLAIM IS BASED. | ||
|
||
|
||
# 6. APPROXIMATION OF DISCLAIMER AND DAMAGE WAIVER | ||
|
||
IF THE DISCLAIMER AND DAMAGE WAIVER MENTIONED IN SECTION 4 AND SECTION 5 CANNOT | ||
BE GIVEN LEGAL EFFECT UNDER APPLICABLE LOCAL LAW, REVIEWING COURTS SHALL APPLY | ||
LOCAL LAW THAT MOST CLOSELY APPROXIMATES AN ABSOLUTE WAIVER OF ALL CIVIL | ||
LIABILITY IN CONNECTION WITH THE CONTRIBUTION. | ||
|
||
|
||
# 7. TERM | ||
|
||
7.1 This Agreement shall come into effect upon Your acceptance of the terms and | ||
conditions. | ||
|
||
7.2 In the event of a termination of this Agreement Sections 4, 5, 6, 7 and 8 | ||
shall survive such termination and shall remain in full force thereafter. For | ||
the avoidance of doubt, Contributions that are already licensed under a free and | ||
open source license at the date of the termination shall remain in full force | ||
after the termination of this Agreement. | ||
|
||
|
||
# 8. MISCELLANEOUS | ||
|
||
8.1 This Agreement and all disputes, claims, actions, suits or other proceedings | ||
arising out of this agreement or relating in any way to it shall be governed by | ||
the laws of the United States excluding its private international law provisions. | ||
|
||
8.2 This Agreement sets out the entire agreement between You and Us for Your | ||
Contributions to Us and overrides all other agreements or understandings. | ||
|
||
8.3 If any provision of this Agreement is found void and unenforceable, such | ||
provision will be replaced to the extent possible with a provision that comes | ||
closest to the meaning of the original provision and that is enforceable. The | ||
terms and conditions set forth in this Agreement shall apply notwithstanding any | ||
failure of essential purpose of this Agreement or any limited remedy to the | ||
maximum extent possible under law. | ||
|
||
8.4 You agree to notify Us of any facts or circumstances of which you become | ||
aware that would make this Agreement inaccurate in any respect. |
This file contains 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 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,21 @@ | ||
.PHONY: examples clean test | ||
|
||
EXDIRS = $(wildcard _examples/*/*) | ||
%.ex_run : % | ||
@echo Building $< | ||
@cd $< && go run *.go && touch .ex_run | ||
EXRUN = $(addsuffix /.ex_run, $(EXDIRS)) | ||
|
||
examples: $(EXRUN) | ||
|
||
clean: | ||
rm -f $(EXRUN) | ||
|
||
|
||
GOPKGS = $(shell go list ./...) | ||
test: | ||
@echo "mode: count" > coverage-all.out | ||
@$(foreach PKG, $(GOPKGS), \ | ||
go test -coverprofile=coverage.out $(PKG) || exit 1; \ | ||
tail -n +2 coverage.out >> coverage-all.out; ) | ||
@go tool cover -func=coverage-all.out |
This file contains 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 |
---|---|---|
@@ -1 +1,61 @@ | ||
# gooxml | ||
**gooxml** is a library for creation of OpenOffice documents (.docx, .xlsx and | ||
.pptx). | ||
|
||
[![Build Status](https://travis-ci.org/baliance/gooxml.svg?branch=master)](https://travis-ci.org/baliance/gooxml) | ||
|
||
## Status ## | ||
|
||
The current focus is on documents (.docx). Some other code exists for | ||
spreadsheets and presentations, but it is not as far as long. The current plan | ||
is to get documents working well, then spreadsheets, and finally presentations. | ||
|
||
|
||
## Installation ## | ||
|
||
go get baliance.com/gooxml/ | ||
|
||
## Raw Types ## | ||
|
||
The OOXML specification is large and creating a friendly API to cover the entire | ||
specification is a very time consuming endeavor. This library attempts to | ||
provide an easy to use API for common use cases in creating OOXML documents | ||
while allowing users to fall back to raw document manipulation should the | ||
library's API not cover a specific use case. | ||
|
||
The raw XML based types reside in the ```schema/``` directory. These types are | ||
accessible from the wrapper types via a ```X()``` method that returns the raw | ||
type. | ||
|
||
For example, the library currently doesn't have an API for setting a document | ||
background color. However it's easy to do manually via editing the | ||
```CT_Background``` element of the document. | ||
|
||
dox := document.New() | ||
doc.X().Background = wordprocessingml.NewCT_Background() | ||
doc.X().Background.ColorAttr = &wordprocessingml.ST_HexColor{} | ||
doc.X().Background.ColorAttr.ST_HexColorRGB = color.RGB(50, 50, 50).AsRGBString() | ||
|
||
### Contribution guidelines ### | ||
|
||
[![CLA assistant](https://cla-assistant.io/readme/badge/baliance/gooxml)](https://cla-assistant.io/baliance/gooxml) | ||
|
||
All contributors are must sign a contributor license agreement before their code | ||
will be reviewed and merged. | ||
|
||
|
||
### Licensing ### | ||
|
||
This library is offered under a dual license. It is freely available for use | ||
under the terms of AGPLv3. If you would like to use this library for a closed | ||
source project, please contact [email protected]. | ||
|
||
There are no differences in functionality between the open source and commercial | ||
versions. You are encouraged to use the open source version to evaluate the library | ||
before purchasing a commercial license. | ||
|
||
### Consulting ### | ||
|
||
Baliance also offers consulting services related to enhancing the gooxml library | ||
on a case by case basis. All changes made to the library will be available for | ||
all users under with the same terms as Please contact [email protected] for a | ||
quote if interested. |
Empty file.
Binary file added
BIN
+22.2 KB
_examples/document/header-footer-multiple/header-footer-multiple.docx
Binary file not shown.
This file contains 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,56 @@ | ||
// Copyright 2017 Baliance. All rights reserved. | ||
package main | ||
|
||
import ( | ||
"baliance.com/gooxml/document" | ||
"baliance.com/gooxml/measurement" | ||
wml "baliance.com/gooxml/schema/schemas.openxmlformats.org/wordprocessingml" | ||
) | ||
|
||
var lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin lobortis, lectus dictum feugiat tempus, sem neque finibus enim, sed eleifend sem nunc ac diam. Vestibulum tempus sagittis elementum` | ||
|
||
func main() { | ||
doc := document.New() | ||
|
||
// Headers/footers apply to the preceeding paragraphs in the document. There | ||
// is a section properties on the document body itself acessible via | ||
// BodySection(). To have multiple different headers (aside from the | ||
// supported even/odd/first), we need to add multiple sections. | ||
|
||
// First add some content | ||
for i := 0; i < 5; i++ { | ||
para := doc.AddParagraph() | ||
run := para.AddRun() | ||
run.AddText(lorem) | ||
} | ||
|
||
// Construct our header | ||
hdr := doc.AddHeader() | ||
para := hdr.AddParagraph() | ||
para.AddTabStop(2.5*measurement.Inch, wml.ST_TabJcCenter, wml.ST_TabTlcNone) | ||
run := para.AddRun() | ||
run.AddTab() | ||
run.AddText("My Document Title") | ||
|
||
// Create a new section and apply the header | ||
para = doc.AddParagraph() | ||
section := para.AddSection(wml.ST_SectionMarkNextPage) | ||
section.SetHeader(hdr, wml.ST_HdrFtrDefault) | ||
|
||
// Add some more content | ||
for i := 0; i < 5; i++ { | ||
para := doc.AddParagraph() | ||
run := para.AddRun() | ||
run.AddText(lorem) | ||
} | ||
|
||
hdr = doc.AddHeader() | ||
para = hdr.AddParagraph() | ||
para.AddTabStop(2.5*measurement.Inch, wml.ST_TabJcCenter, wml.ST_TabTlcNone) | ||
run = para.AddRun() | ||
run.AddTab() | ||
run.AddText("Different Title") | ||
doc.BodySection().SetHeader(hdr, wml.ST_HdrFtrDefault) | ||
|
||
doc.SaveToFile("header-footer-multiple.docx") | ||
} |
Empty file.
Binary file not shown.
Oops, something went wrong.