public class OdgReader
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
(package private) OFBconv.CmdArgs |
args |
(package private) static java.util.Comparator<XY_FBcl> |
compareX |
(package private) static java.util.Comparator<XY_FBcl> |
compareX2 |
(package private) int |
currPage |
static java.util.Map<java.lang.String,FBkind_FBcl> |
idxFBkindFromStyle
Assignment between style string in LibreOffice odg and the
EBlock |
(package private) java.util.Map<java.lang.String,OdgModule> |
idxOdgMdl
Index of all Modules which are available here.
|
static java.util.Map<java.lang.String,PinKind_FBcl> |
idxPinKindFromStyle
Assignment between style string in LibreOffice odg and the
PinKind |
(package private) java.util.List<OdgGBlock> |
listBlocks_x
List sorted to left top positions of all graphic block frames.
|
(package private) java.util.List<OdgGBlock> |
listBlocks_y
List sorted to left top positions of all graphic block frames.
|
(package private) LogMessage |
log |
private OdgModule |
odgMdlCurr
The current module of the page, also valid for the next pages without module name.
|
(package private) Prj_FBcl |
prj |
(package private) long |
timeEnd |
(package private) long |
timeGatherGraphic |
(package private) long |
timeOutFBcl |
(package private) long |
timeReadXml |
(package private) long |
timeSortData |
(package private) long |
timeStart |
static java.lang.String |
version
Version, License and History:
Use own
OdgModule#idxGExprVarByName for variable after expression
and their free usage in the module's graphic. |
protected XmlJzReader |
xmlReader |
private XmlForOdg |
xOdgCurr |
| Constructor and Description |
|---|
OdgReader(Prj_FBcl prj,
OFBconv.CmdArgs args,
LogMessage log) |
| Modifier and Type | Method and Description |
|---|---|
private OdgGPin |
addExprInput(OdgGBlock fbg,
OdgShape shape,
OdgModule odgMdl)
Adds an expression part or an expression connection input.
|
private void |
addExprOutVar(OdgShape shape,
OdgModule odgMdl) |
private void |
addFbgxy(OdgGBlock fbg)
|
private OdgGPin |
addGPinToGBlock(PinKind_FBcl pinKind,
OdgGBlock fbg,
OdgShape shape,
OdgModule odgMdl)
Before used only as addExprOutput
Adds a pin to the FBexpr
OdgGBlock |
private OdgGPin |
addTHIZexpr(OdgGBlock fbg,
OdgShape shape,
OdgModule odgMdl) |
static void |
analyzeXmlStruct(java.io.File fXmlIn)
Analyzes the given XML file example and creates a proper xmlcfg.xml file from that.
|
private void |
assignFBlockNameTypeIdCreateFBlock(OdgShape shape,
OdgGBlock fbg,
OdgModule odgMdl)
Creates the FBlock(s) due to the GBlock
either with given text in GBlock or with the extra provided ofnClassTypeName shape
|
private void |
assignFreeVarToExpr(OdgNameTypeArray freeVar,
OdgModule odgMdl)
Merge pins which presents free variables with the OdgPinInstance
used as variable after expression or as variable as output of return and reference pins.
|
private void |
associateColumnsToFbg() |
static int |
binarySearchX(java.util.List<OdgGBlock> list,
int x)
Note: Use only one position, x1 for both comparison
|
static int |
binarySearchY(java.util.List<OdgGBlock> list,
int y) |
private void |
checkStateEnclosing(OdgGState gState,
OdgModule odgMdl)
Adds the
OdgGBlock.sName of a found enclosing state to the given state. |
void |
completeLastModuleBuildFBclData(XmlForOdg xOdg)
Completes the full read module last module after read all files.
|
private void |
createXref(java.lang.String name,
java.lang.String id,
java.lang.String sPosxy,
XY_FBcl xy,
OdgModule odgMdl)
|
private static java.lang.String |
detectFuncSpec(java.lang.String name,
char[] spec) |
void |
errorMsg(java.lang.String msg,
java.lang.Object... params) |
private void |
gatherConnection(OdgPage page,
OdgModule odgMdl,
XmlForOdg.Draw_connector xmlConnection,
XmlForOdg xOdg,
java.util.Map<java.lang.String,java.lang.String> idxStyle)
Read out the connection info from the odg graphic.
|
private void |
gatherDemuxPin(OdgGBlock fbg,
OdgShape shape,
OdgModule odgMdl,
XmlForOdg xOdg) |
private void |
gatherExprPin(OdgGBlock fbg,
OdgShape shape,
OdgModule odgMdl,
XmlForOdg xOdg)
Reads out the data for an expression in from the given shape.
|
private void |
gatherFBlockPin(OdgGBlock fbg,
OdgShape shape,
OdgModule odgMdl)
Processes a shape which has
OdgShape.ePin recognized as FBlock pin. |
private OdgGBlock |
gatherFBlockShape(OdgShape shape,
OdgModule odgMdl)
Gather a main block shapes in the graphic.
|
private void |
gatherFreeText_drawFrame_inGroup(XmlForOdg.Draw_g group,
XmlForOdg xOdg,
OdgGBlock fbi,
java.util.Map<java.lang.String,java.lang.String> idxStyle)
A free text field in a group.
|
void |
gatherGraphic(XmlForOdg xOdg,
java.lang.String fName)
Evaluates the content from the parsed XML file stored in XmlForOdg and builds GBlocks and GPins.
|
private void |
gatherStates(OdgPage page,
OdgModule odgMdl) |
void |
infoMsg(java.lang.String msg,
java.lang.Object... params) |
java.lang.Iterable<OdgModule> |
iterOdgModule() |
private OdgGPin |
prcFBexprOutput(OdgGBlock fbsrc,
OdgGPin piDst,
XY_FBcl posXY,
java.lang.String text,
java.lang.String posXySrc,
OdgModule odgMdl)
This operation is called in
#gatherConnection(org.vishia.fbcl.readOdg.xml.XmlForOdg.Draw_connector, XmlForOdg)
for a connection for output from an expression without extra pin. |
private void |
prepareAlias(java.lang.String sAliasLines,
XY_FBcl xy,
OdgModule odgMdl,
java.lang.String sXmlId)
Read the content of a 'ofbAlias' shape.
|
private void |
processGraphicConnectionsOfAllModulePages(OdgModule odgMdl,
XmlForOdg xOdg)
Processes all graphic connections from XML and associated it to the
OdgGBlock pins. |
XmlForOdg |
readOdgFile(java.io.File fIn)
Reads one odg file and converts it in the adequate
OdgModule instances as controlled by the ofpTitle shape. |
private XmlForOdg |
readXml(java.io.File fInOdg)
Reads completely the content.xml from the given odg file
and stores the data in the returned instance.
|
(package private) OdgGBlock |
searchEnclosingGBlock(XY_FBcl pos)
Search a block which encloses full the pos, for state in state etc.
|
(package private) OdgGBlock |
searchFbg(XY_FBcl pos)
Searches a given graphic block with positions pos in the
listBlocks_x, listBlocks_y
to associated this graphic element to the found block
The Algorith searches in the listBlocks_x etc with binarySearchX(List, int) and binarySearchY(List, int)
with the right bottom edge first. |
private void |
storeConnectorId(XmlForOdg.Draw_connector conn,
XmlForOdg xOdg,
OdgModule odgMdl,
int page) |
public static final java.lang.String version
OdgModule#idxGExprVarByName for variable after expression
and their free usage in the module's graphic. See version text in OdgReader.
The problem is, that the expressions to the variable has not unique name strategies,
hence use the variable name as key.
Changed in
gatherExprPin(OdgGBlock, OdgShape, OdgModule, XmlForOdg):
their the variable after expression is first detected with its correct name as graphic pin.
assignFreeVarToExpr(OdgNameTypeArray, OdgModule): here the free variable are correct associated.
public static final java.util.Map<java.lang.String,FBkind_FBcl> idxFBkindFromStyle
EBlockpublic static final java.util.Map<java.lang.String,PinKind_FBcl> idxPinKindFromStyle
PinKindfinal LogMessage log
final OFBconv.CmdArgs args
final Prj_FBcl prj
protected final XmlJzReader xmlReader
private OdgModule odgMdlCurr
#gatherofbTitle(org.vishia.fbcl.readOdg.xml.XmlForOdg.Draw_custom_shape, XmlForOdg)
or the style "ofpTitle".private XmlForOdg xOdgCurr
final java.util.Map<java.lang.String,OdgModule> idxOdgMdl
int currPage
long timeStart
long timeReadXml
long timeGatherGraphic
long timeSortData
long timeOutFBcl
long timeEnd
java.util.List<OdgGBlock> listBlocks_x
#addFbgxy(org.vishia.fbcl.readOdg.XY_FBcl),
It is cleaned on any new page!java.util.List<OdgGBlock> listBlocks_y
#addFbgxy(org.vishia.fbcl.readOdg.XY_FBcl),
It is cleaned on any new page!static java.util.Comparator<XY_FBcl> compareX
static java.util.Comparator<XY_FBcl> compareX2
public OdgReader(Prj_FBcl prj, OFBconv.CmdArgs args, LogMessage log) throws java.io.IOException
java.io.IOExceptionpublic static void analyzeXmlStruct(java.io.File fXmlIn)
throws java.io.IOException
fXmlIn - The example file. The xmlCfg will be write beside as xmlcfg.xmljava.io.IOExceptionpublic XmlForOdg readOdgFile(java.io.File fIn)
OdgModule instances as controlled by the ofpTitle shape.fIn - The file to read (OpenOffice standard)public java.lang.Iterable<OdgModule> iterOdgModule()
private XmlForOdg readXml(java.io.File fInOdg) throws java.io.IOException
fInOdg - The file to readjava.io.IOException - On file read problemspublic void gatherGraphic(XmlForOdg xOdg, java.lang.String fName)
OdgModule.buildFBclData() is called,
which builds the graphic independent mapping of the FBlock data.
OdgGBlock stored in OdgModule.idxGBlock and also OdgModule.idxGBlockById etc. for connections
OdgGPin stored firstly to the GBlock in OdgGBlock.idxPin with detection of affiliation because of its graphic position
into or near to the GBlock,
and also in OdgModule.idxGMdlPins for module pins and also OdgModule.idxGPinById for connections
OdgGBlock also the FBcl-instances of the FBlock_FBcl are created or associated,
referenced by Write_FBlock_FBwr, and they are aggregated in the Write_Module_FBwr.
OdgGBlock also the instances of the FBtype_FBcl referenced by Write_FBtype_FBwr are created
and they are aggregated in the FBlock_FBcl.
FBlock_FBcl, also FBtype_FBcl are not completed,
and also the Pin_FBcl are not firstly created yet.
The pins will be created in the called OdgModule.buildFBclData() for each module after parsing of all its pages.
readOdgFile(File)
XmlForOdg.Draw_page_Base#
XmlForOdg.getContent() => drawing : XmlForOdg.Office_drawing __getContent__
XmlForOdg.Office_drawing#get_draw_page() => XmlForOdg.Draw_page __xpage__
OdgPage.OdgPage(int, org.vishia.fbcl.readOdg.xml.XmlForOdg.Draw_page, XmlForOdg) __newPage__
OdgPage#gatherTitle(org.vishia.fbcl.readOdg.xml.XmlForOdg.Draw_page, XmlForOdg) __gatherTitle__
processGraphicConnectionsOfAllModulePages(OdgModule, XmlForOdg) __prcGraphicConn__
OdgModule.buildFBclData() __buildFBcl__
OdgPage.shTitle if starts with '#', ignore page. __TitleDisabled__
OdgPage#gatherDisabledAreas(org.vishia.fbcl.readOdg.xml.XmlForOdg.Draw_page, XmlForOdg) __gthDisAreas__
OdgPage#gatherShapes(org.vishia.fbcl.readOdg.xml.XmlForOdg.Draw_page, XmlForOdg),
it ignores all shapes inside in disable areas: __gthShapes__
odgMdlCurr is null then create the new OdgModule for the page and next pages,
but check whether the module is already existing: idxOdgMdl. Then we have a faulty page order. __newOdgModule__
OdgModule.listPage __addListPage__
OdgPage.shImport => #prepareAlias(String, String, OdgModule) __shImport__
OdgPage.shExpr, FOR: OdgPage.shMdlPins, FOR: OdgPage.shDemux, FOR: OdgPage.shFBlock, FOR: OdgPage.shReq, FOR: OdgPage.shDocu
gatherFBlockShape(OdgShape, OdgModule) __gthFBlockShapes__
OdgPage.shFBname => __gthFBname__
OdgGBlock fbg = #searchFbg(OdgShape, String)
assignFBlockNameTypeIdCreateFBlock(OdgShape, OdgGBlock, OdgModule)
gatherFBlockShape(OdgShape, OdgModule)
if a name is detected in its GBlock shape.
OdgPage.shEvPin: __shEvinPins__
OdgGBlock fbg = #searchFbg(OdgShape, String)
gatherFBlockPin(OdgGBlock, OdgShape, OdgModule) as event pin.
OdgPage.shCBlock => do adequate, that are the small connection points to a FBlock instead GBlock glue points: __shCBlock__
OdgPage.shPin => #prepareAlias(String, String, OdgModule) __shPins__
Here TODO do not create the pins here!! Do it later after connection.
OdgGBlock fbg = #searchFbg(OdgShape, String)
addExprOutVar(OdgShape, OdgModule), a free variable to access.
OdgGBlock.eKindBlock: The style in graphic:
#gatherAccessPin(OdgGBlock, OdgShape, OdgModule, XmlForOdg)
gatherExprPin(OdgGBlock, OdgShape, OdgModule, XmlForOdg)
gatherFBlockPin(OdgGBlock, OdgShape, OdgModule)
gatherFBlockPin(OdgGBlock, OdgShape, OdgModule)
gatherFBlockPin(OdgGBlock, OdgShape, OdgModule)
OdgPage.shDemuxPin FOR: OdgPage.shExprPart
OdgPage.shExprOut FOR: OdgPage.shXref FOR: OdgPage.shConnPoint
OdgPage.shAttr
XmlForOdg.Draw_page#get_draw_connector(): __storeConn__
storeConnectorId(org.vishia.fbcl.readOdg.xml.XmlForOdg.Draw_connector, XmlForOdg, OdgModule, int)
associateColumnsToFbg()
processGraphicConnectionsOfAllModulePages(OdgModule, XmlForOdg) for the last module,
but this is faulty here because the module can be continued with the next file: TODO
xOdg - The whole paresed and prepared XML datafName - file name for logprivate OdgGBlock gatherFBlockShape(OdgShape shape, OdgModule odgMdl)
eBlock - it is the style of the graphic converted to this enum.
Used: P O C X D R I ( FBkind_FBcl.cfn )
other should not applied, test it before.shape - The shape read from XMLodgMdl - module to store results.private void assignFBlockNameTypeIdCreateFBlock(OdgShape shape, OdgGBlock fbg, OdgModule odgMdl)
shape - either the ofbFBlock or the ofnCalssTypeName shape.fbg - The GBlock already created.odgMdl - The moduleprivate void gatherFBlockPin(OdgGBlock fbg, OdgShape shape, OdgModule odgMdl)
OdgShape.ePin recognized as FBlock pin.fbg - The found OdgGBlock where the pin shape is localized to or member of a group
The Block in the graphic appearance, may be a FBlockType or a FBlock.
Note that both a FBlock and a FBlockType can be occur more as one time in the graphic.
But the instance of FBlock_FBcl in OdgGBlock.fbw
and the associated type instance of FBtype_FBcl in OdgGBlock.fbtw is unique,
searched by name. This is done because the rectangle of the FBlock (style "ofbFBlock")
and the name (style "ofnClassTypeName" and style "ofnClassObjName") is gathered before, builds the fbg instance.shape - The shape which has OdgShape.ePin recognized as FBlock pinodgMdl - the moduleprivate void gatherDemuxPin(OdgGBlock fbg, OdgShape shape, OdgModule odgMdl, XmlForOdg xOdg)
private void gatherExprPin(OdgGBlock fbg, OdgShape shape, OdgModule odgMdl, XmlForOdg xOdg)
OdgModule#completePins(OdgReader)xShape - the shape in the xml datafbg - used only for new OdgGPinxOdg - all xml data, only used: XmlForOdg#getStyleFromid(String).private void gatherFreeText_drawFrame_inGroup(XmlForOdg.Draw_g group, XmlForOdg xOdg, OdgGBlock fbi, java.util.Map<java.lang.String,java.lang.String> idxStyle)
group - xOdg - fbi - private void prepareAlias(java.lang.String sAliasLines,
XY_FBcl xy,
OdgModule odgMdl,
java.lang.String sXmlId)
Prj_FBcl#idxAlias
listImport - posxy - odgMdl - private void createXref(java.lang.String name,
java.lang.String id,
java.lang.String sPosxy,
XY_FBcl xy,
OdgModule odgMdl)
OdgXref in OdgModule#idxXrefByName
and creates a OdgGBlock which refers the Xref als fbb
and stores the OdgGBlock in #idxGBlockById to find it for connections
and stores it in #idxXrefGraphicByName to find it for output-odg (only for report).
It returns nothing, the Xref will be found on connection.name - id - sPosxy - private void storeConnectorId(XmlForOdg.Draw_connector conn, XmlForOdg xOdg, OdgModule odgMdl, int page)
private static java.lang.String detectFuncSpec(java.lang.String name,
char[] spec)
private void gatherConnection(OdgPage page, OdgModule odgMdl, XmlForOdg.Draw_connector xmlConnection, XmlForOdg xOdg, java.util.Map<java.lang.String,java.lang.String> idxStyle)
OdgGPin.connections via OdgGPin.addConnection(OdgConnection, LogMessage).
OdgConnection.eKind is adjusted by the OdgGPin.kind of the source pin and also the destination pin.
Hence a simple "Default drawing style" is possible to use if the kind of pins can determine the kind of the connection.
OdgGBlock not an OdgGBlock.fbPinDst is created,
instead the dedicated pin is created due to the kind of connection:
OdgGPin.pinType is set.
OdgGPin is never be done here, because information about connections via XRef and Demux
are not evaluated here. It is better always use the OdgGBlock.fbPinDst to connect first,
and create the pins later after OdgModule#connectViaDemuxXref(OdgGPin, OdgGPin, String, String, int, int).
page - It works page by page with the given page stored in OdgModule.listPage.
This list was filled in gatherGraphic(XmlForOdg, String) for this module.odgMdl - the modulexmlConnection - data of connection from odg.xml, this is element of OdgPage.xpage
and their XmlForOdg.Draw_page#get_draw_connector().
It is one connection on the page.xOdg - whole xml result only used to get the style TODO shift to calling env.xmlStyle - Association of the inner style id to the common style id in styles.xml,
it is the resolving from direct formatted styles.private OdgGPin prcFBexprOutput(OdgGBlock fbsrc, OdgGPin piDst, XY_FBcl posXY, java.lang.String text, java.lang.String posXySrc, OdgModule odgMdl)
#gatherConnection(org.vishia.fbcl.readOdg.xml.XmlForOdg.Draw_connector, XmlForOdg)
for a connection for output from an expression without extra pin.
It is either a constant expression or a PinKind_FBcl.Dout.fbsrc - the graphic block which is connected as sourcepiDst - the dst of the connection to enter a constant value.text - on the connection, usual nullposXySrc - TODO ??private void associateColumnsToFbg()
public static int binarySearchX(java.util.List<OdgGBlock> list, int x)
list - public static int binarySearchY(java.util.List<OdgGBlock> list, int y)
private void addFbgxy(OdgGBlock fbg)
OdgGBlock with positions to the lists listBlocks_x and listBlocks_y.
It adds sorted using Collections.binarySearch(List, Object, Comparator)
using the compareX and #compareYfbg - add this instance.private void checkStateEnclosing(OdgGState gState, OdgModule odgMdl)
OdgGBlock.sName of a found enclosing state to the given state.
It searches the enclosing state using searchFbg(XY_FBcl).
As result:
OdgGState#idxGStateByName with the name as written in the graphic
inclusively completion of the name with the parent state due to nesting.
If a state with same name would be twice, it is stored with name-parent*77 with a number.
This is a unique state name for each GState block.
OdgGState.gStateChildren and OdgGState.gStateDefaultChildren are filled.
gState - called for all states of this page only.OdgGBlock searchFbg(XY_FBcl pos)
listBlocks_x, listBlocks_y
to associated this graphic element to the found block
listBlocks_x etc with binarySearchX(List, int) and binarySearchY(List, int)
with the right bottom edge first. It means the first block found is that FBlock which top left position is less or equal the right bottom edge of pos
+--+
| | pos
+--+....+-------------+
: |listFBlocks_y|
: +-------------+
:
+-------------+
|listFBlocks_x|
+-------------+
To assure that both pos.x2 and pos.y2 touch the same block, now it is iterated backward first one step over listBlocks_x
and in this step over the whole range of listBlocks_y backward, etc:
+-------------+
|listFBlocks_x|
+-------------+
+-------------+ :
|listFBlocks_y| :
+-------------+..+--+
| | pos
+--+
till the same block is found in both lists, which touches both the pos.
+-------------+
| FBlock ++-+
+------------++ | pos
+--+
Because the first binary search, and break if the same block is found,
this search needs not too much time. The number of blocks in one page may be in range 100.
Unfortunately the lists does not contain the right bottom border to limit search, hence it should go till 0.
Because on position 0 they may be a block with right bottom edge touching the pos.
This can be improved by notation the most right position of all blocks before in each block, maybe with an extra array
(can be done in future to optimize).pos - The area should only overlap one of the given graphic blocks.
If the given block with pos overlaps two or more blocks, one of them is found.
It means the behavior is not very deterministic. Avoid such situations in the graphic.OdgGBlock exists with proper positions, else the proper graphic blockOdgGBlock searchEnclosingGBlock(XY_FBcl pos)
pos - private OdgGPin addExprInput(OdgGBlock fbg, OdgShape shape, OdgModule odgMdl)
fbg - The graphic GBlockshape - The shape describing the ofpExprPartodgMdl - the moduleFBlock_FBcl.din but first with odg specific data.private OdgGPin addGPinToGBlock(PinKind_FBcl pinKind, OdgGBlock fbg, OdgShape shape, OdgModule odgMdl)
OdgGBlockfbg - the GBlockshape - the shapeodgMdl - the moduleOdgGBlock#putPin(OdgGPin, XY_FBcl) in OdgGBlock#idxPinInstance.private void assignFreeVarToExpr(OdgNameTypeArray freeVar, OdgModule odgMdl)
addExprOutVar(OdgShape, OdgModule), all Shapes which's OdgShape.ePin
is 'D', 'V' or 'Z' (ofpVout... or ofpZout) and which are not assigned to an expression shape,
are stored in OdgModule.listFreeVar which its XML connection id in OdgNameTypeArray.pinC,
and the name in this instance ...#descr.
Because of the name, the OdgGPin with this name is searched in OdgModule.idxVarGPinByName,
and the XML connection id is stored with the OdgGPin in OdgModule.idxGPinById
freeVar - the description of the variable pin, OdgNameTypeArray.descr contains the name,
OdgNameTypeArray.pinC contains the id. Due to OdgModule.listFreeVar.odgMdl - the moduleprivate void processGraphicConnectionsOfAllModulePages(OdgModule odgMdl, XmlForOdg xOdg)
OdgGBlock pins.
First all connections in the XML are stored page by page in OdgPage.xpage of type XmlForOdg.Draw_page.
This are the data original read from the content.xml via the config.xml.
It contains the XML data for the element
Reads all connections from XML file, for all pages of this module,
because connections using Xref are related to different pages.
TODO is it really necessary to handle connections via Xref here? Problem is, if a Module is dispersed over some files.
Then the idxStyle is not the same over all.
Hence this algorithm must call only from only one XML input file-public void completeLastModuleBuildFBclData(XmlForOdg xOdg)
OdgModule.buildFBclData() is called
for this current finished module.
Then one file can contain exact one module, or also more as one modules, also if more as one files are read.
But if a module uses more as one file, it is finished only after read all files.public void errorMsg(java.lang.String msg,
java.lang.Object... params)
public void infoMsg(java.lang.String msg,
java.lang.Object... params)