ru.novosoft.dc.rtf_to_xml
Class RTF_TO_XMLContext
java.lang.Object
|
+--ru.novosoft.dc.core.NSDCContext
|
+--ru.novosoft.dc.rtf_to_xml.RTF_TO_XMLContext
- public class RTF_TO_XMLContext
- extends NSDCContext
An extension of the NSDCContext
is
intended for the management of RTF_TO_XML conversion. The following additional
options can be specified in this context:
define-options
- Specifies a name of XML file
containing description of internal RTF_TO_XML parameters and compatibility models.
The file is searched relative to the location specified in the
data-path
option. The default options definition file
is options.xml
;
model
- A compatibility model used in the
conversion. Its possible values are specified in the options definition
file. Using the model you can set the compatibility with popular
fo-renderers and their versions. The default compatibility model is
"w3c";
output-plugin
- A name of plug-in to be
applied in the
ConversionTask
after converting an rtf-file;
fo-file-extension
- An extension of XML FO file
produced when a template is not prepared;
fo-template-extension
- An extension of XSLT
file produced when a template is prepared;
fo-data-extension
- An extension of XML file
with data produced when a template is prepared;
prepare-template
- A flag (true/false)
of the preparing template mode. In prepare mode two files are prepared
from every rtf-file: a template-file and a data-file;
extract-data
- A flag (true/false) of
data extraction. If the preparing template mode is on and this flag is
true, all text data will be extracted from rtf-input;
extract-data-with-style
-
If the preparing template mode is on and this option is
specified, the value of this option specifies an XML file describing
styles to be extracted. While processing an rtf-input, the text data
with required RTF styles will be extracted. The value of the
"extract-data" flag is ignored in this case;
extract-fields
- A flag (true/false) of
fields extraction. If the preparing template mode is on and this flag is
true, fields of the type
DOCPROPERTY "name"
will
be extracted;
create-cycles-at
- Specifies a marker
to be recognized as a cycle point in tables, lists, and paragraphs.
Works if the preparing template mode is on.
A table row will be cycled if it has no vertically merged cells
and the content of the first cell is equal to the marker.
A list item will be cycled if its content is equal to the marker.
Surrounding spaces are ignored while comparing with the marker.
An empty marker or unspecified option mean no cycles;
show-data-location
- If this option is
turned on, "nsdc:text" elements will have optional attributes stecifying
style and location information for extracted text elements;
data-attributes-with-namespace
-
If this option is turned on, all attributes of elements from "nsdc"
namespaces will have "nsdc:" prefix. Otherwise the attributes will be
unprefixed;
font-substitution
- Specifies a name
of XML file containing font substitutions to be used in conversion.
Substitutions from a new font substitution file are added to the font
substitution table and override substitutions with the same template
name specified before;
track-changes
- If true, a document with
track changes shown with a strikethrough font is generated.
Default behavior is `no track changes'. In this case deleted and revised
text is ignored;
use-content-tabs
- A flag
(true/false). If false, the leader of "space" type is used. Otherwise,
the "use-content" type leader is used in conversion of tabs;
batch-logging
- If true, a unique log file
is created in batch conversion. Otherwise, an individual log is
created for every RTF file converted and is stored near the
conversion results;
log-name
- A template name for the log
file. It is used in the batch logging mode. A name of log file is
composed from this template and the ".log" extention.
The log file is stored in the destination directory if it is specified
or in the directory of the "log-path" option otherwise;
compare-pictures
- If false,
all pictures in a file are concidered as different pictures and
non-proportional picture resize while conversion with plug-ins is
available. But if the mode is turned on, the disk space is saved
if identic pictures found, because only one instance is stored on
the disk and the reference to the same picture is reused in XSL FO
references. The non-proportional resize while conversion is forbidden
in this case;
no-picture-conversion
- If true, a
conversion of pictures with plug-ins is suppressed;
xml-indent
- a numeric value of the
indent used for the serialization of documents in the indent mode.
The default value is 4;
xml-line-width
- a numeric value of
the approximate line width used for the serialization of documents in
the indent mode. The default value is 72; and
encoding
- If this option is specified,
its value is used as an output encoding. The default output encoding
is UTF-8.
Constructor Summary |
RTF_TO_XMLContext(java.lang.String homePath,
java.util.Properties properties,
java.io.PrintStream systemLog)
Construct an instance of the context, create a default logger of the
logging level INFO_LOG, and register the specified
properties. |
Method Summary |
java.lang.String |
defaultModel()
Return the name of default model or empty string if the default model
is undefined. |
java.lang.String |
getUserPreferencesPath()
Return a path to the user preferences file.
|
void |
logOptions(CommonLogger logger)
Logging of user-defined options to the specified logger. |
java.lang.Object[] |
models()
Return an array of valid models sorted alphabetically except the
default model stored as the last model in the array. |
CommonLogger |
newLogger(java.lang.String path,
int level)
Construct a new logger of the specified log-level and return it.
|
protected PictureConverter |
newPictureConverter()
Return null or a new picture converter to be attached to this instance.
|
PicturePool |
newPicturePool(java.lang.String path,
boolean relative)
Construct a new picture pool using the specified path as a parent
name for pictures: all pictures will be stored in the subdirectory
created from the path and the extension ".images". |
protected PictureConverter |
pictureConverter()
Return a picture converter attached to this instance. |
static RTF_TO_XMLContext |
prepareContext(java.io.PrintStream systemLog)
Prepare the RTF_TO_XML context loading its properties from the file
specified in the "rtf_to_xml.configuration" system property.
|
boolean |
validateOptions()
Validate the correctness of the "model" selection and return true if
the validation is successful. |
Methods inherited from class ru.novosoft.dc.core.NSDCContext |
configPath,
dataPath,
findConfigFile,
freezeCoreOptions,
getDefaultLogger,
getDouble,
getFileExtension,
getFloat,
getInt,
getNonemptyOption,
getOption,
getOption,
getOptionAsPath,
getSpecifiedOption,
homePath,
info,
isTrue,
loadConfiguration,
loadOptions,
loadUserPreferences,
loadUserPreferences,
logOption,
logOption,
logOptionIfNonempty,
logOptionIfTrue,
logPath,
options,
parseOption,
pluginExtension,
pluginPath,
setDefaultLogger,
setOption,
setOptionProcessor,
setOptions,
systemLog |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
RTF_TO_XMLContext
public RTF_TO_XMLContext(java.lang.String homePath,
java.util.Properties properties,
java.io.PrintStream systemLog)
- Construct an instance of the context, create a default logger of the
logging level INFO_LOG, and register the specified
properties. Properties with the following prefixes are considered:
starting from the "system." are registered as system properties
(this action is provided in the superclass); starting from the "nsdc."
are registered as options of this context (this action is also provided
in the superclass); starting from the "rtf_to_xml." are also registered
as options of this context (while registration, values of "nsdc." options
can be overlapped with values of "rtf_to_xml." options);
and starting from the "encoding." are registered in the input
encoding registry of rtf parser. Other properties are ignored.
Prefixes are trimmed while registration.
- Parameters:
homePath
- a canonical path to converter's home directoryproperties
- configuration properties of the convertersystemLog
- a print stream used as the system log in all loggers
newPictureConverter
protected PictureConverter newPictureConverter()
- Return null or a new picture converter to be attached to this instance.
The method is used in subclasses to override the default creation method.
pictureConverter
protected final PictureConverter pictureConverter()
- Return a picture converter attached to this instance.
newLogger
public final CommonLogger newLogger(java.lang.String path,
int level)
- Construct a new logger of the specified log-level and return it.
The path is used as a template name for log files. Files with the
same name and ".log" and ".log0" extensions will be used for logging.
The ".log" file is used if the log mode is not equal to the INFO_LOG and
NO_LOG. The ".log0" file is used if the log mode is equal to the
FULL_SILENT_LOG or FULL_LOG.
- Overrides:
- newLogger in class NSDCContext
validateOptions
public boolean validateOptions()
- Validate the correctness of the "model" selection and return true if
the validation is successful.
- Overrides:
- validateOptions in class NSDCContext
logOptions
public void logOptions(CommonLogger logger)
- Logging of user-defined options to the specified logger.
- Overrides:
- logOptions in class NSDCContext
getUserPreferencesPath
public final java.lang.String getUserPreferencesPath()
- Return a path to the user preferences file.
It is either a value of "rtf_to_xml.user-preferences" system property or
the "rtf_to_xml-user.properties" file in the RTF_TO_XML configuration
directory if the system property is undefined.
- Overrides:
- getUserPreferencesPath in class NSDCContext
newPicturePool
public final PicturePool newPicturePool(java.lang.String path,
boolean relative)
- Construct a new picture pool using the specified path as a parent
name for pictures: all pictures will be stored in the subdirectory
created from the path and the extension ".images".
- Overrides:
- newPicturePool in class NSDCContext
- Parameters:
path
- a path used for preparing of picture directory namerelative
- if true, the URL of a picture in FO files will contain
the path relative to the directory of this path.
Otherwise, the canonical path will be stored in the URL.- Returns:
- a new picture pool
defaultModel
public final java.lang.String defaultModel()
- Return the name of default model or empty string if the default model
is undefined.
models
public java.lang.Object[] models()
- Return an array of valid models sorted alphabetically except the
default model stored as the last model in the array.
prepareContext
public static RTF_TO_XMLContext prepareContext(java.io.PrintStream systemLog)
- Prepare the RTF_TO_XML context loading its properties from the file
specified in the "rtf_to_xml.configuration" system property.
If this property does not specified, the method loads the configuration
from the default location "/conf/nsdc.properties" relative to the RTF_TO_XML
home directory. The RTF_TO_XML home directory is specified by the "rtf_to_xml.home"
system property. If this property undefined, the home directory is set to
the first directory in the Java classpath list.
Other Novosoft LLC products:
Handy Backup Handy Password manager