O
- technology-specific type to access range object.public abstract class AbstractWordWriter<O> extends AbstractWriter implements WordWriter<O>, WordHelper<O>
WordHelper.PostProcessor
Modifier and Type | Field and Description |
---|---|
private int |
_closeReopenEveryCounter |
private CursorList<O> |
_cursors |
private WordWriterInput |
_input |
private static org.apache.log4j.Logger |
_logger |
TOOL_CUSTOM_DOC_PROP, UML_CUSTOM_DOC_PROP
PAGE_WIDTH, POINTS_FOR_1CM
Modifier | Constructor and Description |
---|---|
protected |
AbstractWordWriter(WordWriterInput input)
Constructor; copies input template into output file that will be filled with this writer.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
appendTextInNewParagraphWithStyle(Range<O> range,
TextDescription newText,
Style style)
You'll always use this one for regular text and tables.
|
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) |
private void |
collectFigureAndTableCaptionRanges(java.util.List<Range<O>> figCaptionRanges,
java.util.List<Range<O>> tabCaptionRanges)
Gets the map from Word and initialises caption range lists - homegrown range housekeeping for
performance reasons.
|
private void |
copyTemplateAsOutput(java.io.File src,
java.io.File dst) |
Caption<O> |
createCaption(Caption.CaptionKind figure,
Range<O> range) |
Cursor<O> |
createCursor(Placeholder ph,
Range<O> limited) |
void |
createWordApp()
Where applicable, launches (and caches) the MS Word application.
|
private java.lang.String |
determineTextForAttributePh(Placeholder ph) |
private java.lang.String |
determineTextForDiagramPhAndInsertDiagram(Range<O> range,
Placeholder ph) |
private java.lang.String |
determineTextForPackagePh(Placeholder ph) |
private java.lang.String |
determineTextForQualifiedClassPh(Placeholder ph,
java.lang.String separator) |
private void |
doIt(boolean scanOnly,
WordHelper.PostProcessor pp) |
void |
exitAppAndSaveDocument()
Saves MS Word document (and where applicable, exits MS Word application).
|
CursorList<O> |
getCursors() |
WordWriterInput |
getInput()
Returns input used for writing.
|
java.lang.String |
getInputFileNames()
Return names of one or more input files used by this writer.
|
java.lang.String |
getOutputFileNames()
Return names of one or more output files created by this writer.
|
CursorList<O> |
initCursorsFromPlaceholders(java.util.List<Range<O>> figCaptionRanges,
java.util.List<Range<O>> tabCaptionRanges) |
void |
initDocgenOptimisationOptions()
Where applicable, initialises and stores MS Word application options (speed of doc
generation) to original values.
|
private void |
initStyleNames() |
private void |
insertDocIntoPlaceholders()
When actually writing packages, we cath the exceptions and try to continue, so you see the
most of result possible.
|
boolean |
isInTOC(Range<O> range) |
private void |
logReplacementFailures() |
protected static double |
pointForPerc(int perc) |
void |
scanAndPostprocess(WordHelper.PostProcessor pp) |
private CursorList<O> |
scanPlaceholderRanges(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 |
setDocgenOptimisationOptions()
Where applicable, sets MS Word application options to speed performance of doc generation.
|
java.lang.String |
toString() |
void |
unsetDocgenOptimisationOptions()
Where applicable, brings back the original MS Word application options to values stored with
the call to
WordHelper.initDocgenOptimisationOptions() . |
private void |
updateAllFields(boolean skipTiming) |
void |
write()
Writes the content from input.
|
Cursor<O> |
writeAbbrTable(Cursor<O> initCursor,
PackageDoc packageDoc) |
Cursor<O> |
writeClass(Cursor<O> initCursor,
ClassDoc doc)
Writes all related to a class at the end of range in
initCursor . |
Cursor<O> |
writeDataIndex(Cursor<O> initCursor,
PackageDoc packageDoc) |
Cursor<O> |
writeDiagram(Cursor<O> cursor,
FigureDoc doc)
Writes all related to a diagram at the end of range in
cursor . |
Cursor<O> |
writeFcTable(Cursor<O> initCursor,
PackageDoc packageDoc) |
Cursor<O> |
writeLnMapPackage(Cursor<O> initCursor,
PackageDoc packageDoc) |
Cursor<O> |
writePackage(Cursor<O> initCursor,
PackageDoc doc,
boolean isRoot)
Writes all related to a package.
|
Cursor<O> |
writePresCondTable(Cursor<O> initCursor,
PackageDoc packageDoc) |
Cursor<O> |
writeProperties(Cursor<O> initCursor,
PropertiesDoc doc)
Writes a set of properties as a table at the end of range in
cursor . |
Cursor<O> |
writeSclEnum(Cursor<O> cursor,
PackageDoc packageDoc) |
Cursor<O> |
writeTrgOpTable(Cursor<O> initCursor,
PackageDoc packageDoc) |
getDocumentMetadata
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
applyCloseReopen
getDocumentMetadata, getSupportedFormats
appendHtmlTextInNewParagraphWithStyle, appendNewLine, appendRawTextInNewParagraphWithStyle, appendText, appendTextInNewParagraph, appendTextWithStyle, closeDoc, collapseRangeToEnd, collectCaptions, createPatternFinder, createRange, duplicateRange, getCustomDocProperties, getDocumentAsRange, getExistingStyleNames, getRangeParagraphCount, getRangeParagraphOutlineLevel, getRangeParagraphStyleName, getWordAppName, getWordAppVersion, insertFigure, insertFigureCaption, insertFigureRef, insertTable, insertTableCaption, insertTableRef, isRangeWithTable, openDoc, prependNewLine, prependText, setCustomDocProperties, updateFields, updateTablesOf
private static final org.apache.log4j.Logger _logger
private final WordWriterInput _input
private CursorList<O> _cursors
private int _closeReopenEveryCounter
protected AbstractWordWriter(WordWriterInput input) throws UnsupportedInputFormatException, UnsupportedOutputFormatException, java.io.IOException
input
- UnsupportedInputFormatException
UnsupportedOutputFormatException
java.io.IOException
private void copyTemplateAsOutput(java.io.File src, java.io.File dst) throws java.io.IOException
java.io.IOException
private void doIt(boolean scanOnly, WordHelper.PostProcessor pp)
private void logReplacementFailures()
public void createWordApp()
This default implementation does nothing.
createWordApp
in interface WordHelper<O>
public void exitAppAndSaveDocument()
This default implementation does nothing.
exitAppAndSaveDocument
in interface WordHelper<O>
public void initDocgenOptimisationOptions()
This default implementation does nothing.
initDocgenOptimisationOptions
in interface WordHelper<O>
public void setDocgenOptimisationOptions()
This default implementation does nothing.
setDocgenOptimisationOptions
in interface WordHelper<O>
public void unsetDocgenOptimisationOptions()
WordHelper.initDocgenOptimisationOptions()
.
This default implementation does nothing.
unsetDocgenOptimisationOptions
in interface WordHelper<O>
private void initStyleNames()
private void updateAllFields(boolean skipTiming)
private void collectFigureAndTableCaptionRanges(java.util.List<Range<O>> figCaptionRanges, java.util.List<Range<O>> tabCaptionRanges)
private CursorList<O> scanPlaceholderRanges(java.util.List<Range<O>> figCaptionRanges, java.util.List<Range<O>> tabCaptionRanges)
private void insertDocIntoPlaceholders()
private java.lang.String determineTextForAttributePh(Placeholder ph)
private java.lang.String determineTextForDiagramPhAndInsertDiagram(Range<O> range, Placeholder ph)
private java.lang.String determineTextForQualifiedClassPh(Placeholder ph, java.lang.String separator)
private java.lang.String determineTextForPackagePh(Placeholder ph)
protected static double pointForPerc(int perc)
public void clearUndoCache()
This default implementation does nothing.
clearUndoCache
in interface WordHelper<O>
public final void scanAndPostprocess(WordHelper.PostProcessor pp)
scanAndPostprocess
in interface WordHelper<O>
public final CursorList<O> getCursors()
getCursors
in interface WordHelper<O>
public final boolean isInTOC(Range<O> range)
isInTOC
in interface WordHelper<O>
public final Cursor<O> createCursor(Placeholder ph, Range<O> limited)
createCursor
in interface WordHelper<O>
public final Caption<O> createCaption(Caption.CaptionKind figure, Range<O> range)
createCaption
in interface WordHelper<O>
public CursorList<O> initCursorsFromPlaceholders(java.util.List<Range<O>> figCaptionRanges, java.util.List<Range<O>> tabCaptionRanges)
initCursorsFromPlaceholders
in interface WordHelper<O>
public Cursor<O> closeAndReopenDoc(CursorList<O> cursors, Cursor<O> currentCursor)
This default implementation just returns currentCursor
, without any
closing/reopening. If you need to actually close/reopen the document (as a means of
optimising performance), override this method.
closeAndReopenDoc
in interface WordHelper<O>
public java.lang.String appendTextInNewParagraphWithStyle(Range<O> range, TextDescription newText, Style style)
appendTextInNewParagraphWithStyle
in interface WordHelper<O>
public Cursor<O> writePackage(Cursor<O> initCursor, PackageDoc doc, boolean isRoot)
WordWriter
initCursor
.writePackage
in interface WordWriter<O>
public Cursor<O> writeDataIndex(Cursor<O> initCursor, PackageDoc packageDoc)
writeDataIndex
in interface WordWriter<O>
public Cursor<O> writeLnMapPackage(Cursor<O> initCursor, PackageDoc packageDoc)
writeLnMapPackage
in interface WordWriter<O>
public Cursor<O> writePresCondTable(Cursor<O> initCursor, PackageDoc packageDoc)
writePresCondTable
in interface WordWriter<O>
public Cursor<O> writeFcTable(Cursor<O> initCursor, PackageDoc packageDoc)
writeFcTable
in interface WordWriter<O>
public Cursor<O> writeTrgOpTable(Cursor<O> initCursor, PackageDoc packageDoc)
writeTrgOpTable
in interface WordWriter<O>
public Cursor<O> writeAbbrTable(Cursor<O> initCursor, PackageDoc packageDoc)
writeAbbrTable
in interface WordWriter<O>
public Cursor<O> writeSclEnum(Cursor<O> cursor, PackageDoc packageDoc)
writeSclEnum
in interface WordWriter<O>
public Cursor<O> writeClass(Cursor<O> initCursor, ClassDoc doc)
WordWriter
initCursor
.writeClass
in interface WordWriter<O>
public Cursor<O> writeProperties(Cursor<O> initCursor, PropertiesDoc doc)
WordWriter
cursor
. Used to
write all related to a set of class properties (attributes/literals, or association ends, or
operations), or for a collection of one type of properties from one or more packages or
classes that need to be put in a table format.writeProperties
in interface WordWriter<O>
public Cursor<O> writeDiagram(Cursor<O> cursor, FigureDoc doc)
WordWriter
cursor
.writeDiagram
in interface WordWriter<O>
public final WordWriterInput getInput()
Writer
public final java.lang.String getInputFileNames()
Writer
getInputFileNames
in interface Writer
public final java.lang.String getOutputFileNames()
Writer
getOutputFileNames
in interface Writer
public final void write()
Writer
public java.lang.String toString()
toString
in class java.lang.Object
Copyright 2009-2015 Tatjana (Tanja) Kostic