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.
document: support for controlling paragraph numbering
Fixes unidoc#136
- Loading branch information
Showing
8 changed files
with
169 additions
and
15 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
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
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,46 @@ | ||
// Copyright 2017 Baliance. All rights reserved. | ||
// | ||
// Use of this source code is governed by the terms of the Affero GNU General | ||
// Public License version 3.0 as published by the Free Software Foundation and | ||
// appearing in the file LICENSE included in the packaging of this file. A | ||
// commercial license can be purchased by contacting [email protected]. | ||
|
||
package document | ||
|
||
import "baliance.com/gooxml/schema/soo/wml" | ||
|
||
// NumberingDefinition defines a numbering definition for a list of pragraphs. | ||
type NumberingDefinition struct { | ||
x *wml.CT_Num | ||
} | ||
|
||
// X returns the inner wrapped XML type. | ||
func (n NumberingDefinition) X() *wml.CT_Num { | ||
return n.x | ||
} | ||
|
||
// AbstractNumberID returns the ID that is unique within all numbering | ||
// definitions that is used to assign the definition to a paragraph. | ||
func (n NumberingDefinition) AbstractNumberID() int64 { | ||
if n.x.AbstractNumId == nil { | ||
return 0 | ||
} | ||
return n.x.AbstractNumId.ValAttr | ||
} | ||
|
||
// Levels returns all of the numbering levels defined in the definition. | ||
func (n NumberingDefinition) Levels() []NumberingLevel { | ||
ret := []NumberingLevel{} | ||
for _, nl := range n.x.LvlOverride { | ||
ret = append(ret, NumberingLevel{nl}) | ||
} | ||
return ret | ||
} | ||
|
||
// AddLevel adds a new numbering level to a NumberingDefinition. | ||
func (n NumberingDefinition) AddLevel() NumberingLevel { | ||
nl := wml.NewCT_NumLvl() | ||
nl.IlvlAttr = int64(len(n.x.LvlOverride)) | ||
n.x.LvlOverride = append(n.x.LvlOverride, nl) | ||
return NumberingLevel{nl} | ||
} |
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,34 @@ | ||
// Copyright 2017 Baliance. All rights reserved. | ||
// | ||
// Use of this source code is governed by the terms of the Affero GNU General | ||
// Public License version 3.0 as published by the Free Software Foundation and | ||
// appearing in the file LICENSE included in the packaging of this file. A | ||
// commercial license can be purchased by contacting [email protected]. | ||
|
||
package document | ||
|
||
import "baliance.com/gooxml/schema/soo/wml" | ||
|
||
// NumberingLevel is the definition for numbering for a particular level within | ||
// a NumberingDefinition. | ||
type NumberingLevel struct { | ||
x *wml.CT_NumLvl | ||
} | ||
|
||
// X returns the inner wrapped XML type. | ||
func (n NumberingLevel) X() *wml.CT_NumLvl { | ||
return n.x | ||
} | ||
|
||
func (n NumberingLevel) ensureLevel() { | ||
if n.x.Lvl == nil { | ||
n.x.Lvl = wml.NewCT_Lvl() | ||
} | ||
} | ||
|
||
// SetStartOverride sets the Numbering Level Starting Value Override. | ||
func (n NumberingLevel) SetStartOverride(v int64) { | ||
n.ensureLevel() | ||
n.x.StartOverride = wml.NewCT_DecimalNumber() | ||
n.x.StartOverride.ValAttr = v | ||
} |
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
Binary file not shown.
Binary file not shown.