public interface WordHelper<O>
Modifier and Type | Interface and Description |
---|---|
static interface |
WordHelper.PostProcessor
Used for testing only, to play with pure Word stuff, without the notion of the model.
|
Modifier and Type | Field and Description |
---|---|
static int |
PAGE_WIDTH
Page width in cm.
|
static double |
POINTS_FOR_1CM
Number of points for 1cm (from vba doc).
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
appendHtmlTextInNewParagraphWithStyle(Range<O> range,
java.lang.String newMarkup,
Style style) |
void |
appendNewLine(Range<O> range) |
java.lang.String |
appendRawTextInNewParagraphWithStyle(Range<O> range,
java.lang.String newText,
Style style) |
java.lang.String |
appendText(Range<O> range,
java.lang.String newText) |
java.lang.String |
appendTextInNewParagraph(Range<O> range,
java.lang.String newText) |
java.lang.String |
appendTextInNewParagraphWithStyle(Range<O> range,
TextDescription newText,
Style style) |
java.lang.String |
appendTextWithStyle(Range<O> range,
java.lang.String newText,
Style style) |
void |
clearUndoCache()
When you have large documents and you use a binary (COM) API, you will want to call this one
regularly (e.g., for each class doc), so you don't get Word pop-up windows "memory
insufficient.
|
Cursor<O> |
closeAndReopenDoc(CursorList<O> cursors,
Cursor<O> currentCursor) |
void |
closeDoc()
Closes and saves the MS Word document.
|
void |
collapseRangeToEnd(Range<O> range) |
void |
collapseRangeToStart(Range<O> range) |
java.util.Map<CaptionKind,java.util.List<Caption<O>>> |
collectCaptionParagraphsAndFixLabelsAlsoInTOCs()
Expected to be called after styles and caption labels get properly initialised from the
current open document.
|
Caption<O> |
createCaption(CaptionKind figure,
Range<O> range) |
Cursor<O> |
createCursor(Placeholder ph,
Range<O> limited) |
WordPatternFinder<O> |
createPatternFinder(java.lang.String pattern) |
Range<O> |
createRange(O object) |
void |
createWordApp()
Where applicable, launches (and caches) the MS Word application.
|
Range<O> |
duplicateRange(Range<O> range)
FIXME: could go to Range?
|
void |
exitAppAndSaveDocument()
Saves MS Word document (and where applicable, exits MS Word application).
|
CursorList<O> |
getCursors() |
java.util.Map<java.lang.String,java.lang.String> |
getCustomDocProperties() |
Range<O> |
getDocumentAsRange() |
java.util.Map<java.lang.String,ExistingStyle> |
getExistingStyles()
Returns non-empty map of non-null styles read from an open document, with style name as key.
|
int |
getRangeParagraphCount(Range<O> range) |
int |
getRangeParagraphOutlineLevel(Range<O> range,
int paraIdx) |
java.lang.String |
getRangeParagraphStyleName(Range<O> range,
int paraIdx) |
java.lang.String |
getWordAppName()
Returns the MS Word application name.
|
java.lang.String |
getWordAppVersion()
Returns the MS Word application version.
|
void |
initDocgenOptimisationOptions()
Where applicable, initialises and stores MS Word application options (speed of doc
generation) to original values.
|
void |
insertBookmark(Range<O> range,
java.lang.String label) |
void |
insertCaptionRef(Range<O> insertPointRange,
CaptionKind kind,
int tabNumber,
boolean introBeforeCaption)
Inserts reference to the caption
tabNumber at the start of
insertPointRange . |
void |
insertFigure(Range<O> range,
java.io.File pic)
Input
range includes any potential text within a paragraph. |
O |
insertFigureCaption(Range<O> range,
int expectedSeqNum,
java.lang.String captionText) |
void |
insertHyperlink(Range<O> range,
java.lang.String textToDisplay,
java.lang.String url) |
int |
insertTable(Range<O> range,
PropertiesDoc doc,
Style tabhead,
boolean addBookmarks) |
void |
insertTableCaption(Range<O> range,
int expectedSeqNum,
java.lang.String captionText) |
boolean |
isInTOC(Range<O> range) |
boolean |
isRangeWithTable(O range) |
void |
moveStartChar(Range<O> range,
int count) |
void |
openDoc()
Creates (and caches) the MS Word document.
|
void |
prependNewLine(Range<O> range) |
void |
prependText(Range<O> range,
java.lang.String newText)
Prepends text; prepended paragraph will have the same style as the one in range.
|
CursorList<O> |
scanHyperlinkPlaceholderRanges(java.lang.String pattern)
This one scans for the 3rd time the document, for hyperlinks, after all the writing has
completed after the 2nd scan.
|
CursorList<O> |
scanPlaceholderRanges(java.lang.String pattern,
java.util.List<Range<O>> figCaptionRanges,
java.util.List<Range<O>> tabCaptionRanges)
This one scans the whole initial document and initialises placeholders, with text, ranges and
counts of existing tables and figures (captions) before each of them.
|
void |
setCustomDocProperties(java.util.Map<java.lang.String,java.lang.String> newCustomProps) |
void |
setDocgenOptimisationOptions()
Where applicable, sets MS Word application options to speed performance of doc generation.
|
void |
unsetDocgenOptimisationOptions()
Where applicable, brings back the original MS Word application options to values stored with
the call to
initDocgenOptimisationOptions() . |
void |
updateFields() |
void |
updateTablesOf(java.lang.String what) |
void |
writeByTest(WordHelper.PostProcessor pp)
If test wants to only read, pass a null
pp . |
static final int PAGE_WIDTH
static final double POINTS_FOR_1CM
void writeByTest(WordHelper.PostProcessor pp)
pp
. Otherwise, to perform writing
different from the real implementation (for testing purposes), ensure to pass in non-null
pp
that implements test-specific writing.void createWordApp()
java.lang.String getWordAppName()
java.lang.String getWordAppVersion()
void openDoc() throws java.io.IOException
java.io.IOException
void closeDoc() throws java.io.IOException
java.io.IOException
void exitAppAndSaveDocument() throws java.io.IOException
java.io.IOException
void initDocgenOptimisationOptions()
void setDocgenOptimisationOptions()
void unsetDocgenOptimisationOptions()
initDocgenOptimisationOptions()
.void insertHyperlink(Range<O> range, java.lang.String textToDisplay, java.lang.String url)
java.util.Map<java.lang.String,ExistingStyle> getExistingStyles()
void updateFields()
void updateTablesOf(java.lang.String what)
java.util.Map<java.lang.String,java.lang.String> getCustomDocProperties()
void setCustomDocProperties(java.util.Map<java.lang.String,java.lang.String> newCustomProps)
CursorList<O> getCursors()
java.util.Map<CaptionKind,java.util.List<Caption<O>>> collectCaptionParagraphsAndFixLabelsAlsoInTOCs()
Cursor<O> createCursor(Placeholder ph, Range<O> limited)
Caption<O> createCaption(CaptionKind figure, Range<O> range)
CursorList<O> scanPlaceholderRanges(java.lang.String pattern, java.util.List<Range<O>> figCaptionRanges, java.util.List<Range<O>> tabCaptionRanges)
CursorList<O> scanHyperlinkPlaceholderRanges(java.lang.String pattern)
WordPatternFinder<O> createPatternFinder(java.lang.String pattern)
void clearUndoCache()
void prependText(Range<O> range, java.lang.String newText)
java.lang.String appendTextInNewParagraphWithStyle(Range<O> range, TextDescription newText, Style style)
java.lang.String appendRawTextInNewParagraphWithStyle(Range<O> range, java.lang.String newText, Style style)
java.lang.String appendHtmlTextInNewParagraphWithStyle(Range<O> range, java.lang.String newMarkup, Style style)
java.lang.String appendTextWithStyle(Range<O> range, java.lang.String newText, Style style)
O insertFigureCaption(Range<O> range, int expectedSeqNum, java.lang.String captionText)
void insertTableCaption(Range<O> range, int expectedSeqNum, java.lang.String captionText)
void insertCaptionRef(Range<O> insertPointRange, CaptionKind kind, int tabNumber, boolean introBeforeCaption)
tabNumber
at the start of
insertPointRange
.introBeforeCaption
- TODOvoid insertFigure(Range<O> range, java.io.File pic)
range
includes any potential text within a paragraph. The method will
overwrite that text with the figure from pic
, and resulting range spans to the
start of the paragraph following the inserted pic
.int insertTable(Range<O> range, PropertiesDoc doc, Style tabhead, boolean addBookmarks)
java.lang.String appendTextInNewParagraph(Range<O> range, java.lang.String newText)
boolean isRangeWithTable(O range)
Copyright 2009-2016 Tatjana (Tanja) Kostic