Skip to content

Commit

Permalink
Update XmlDocumentLayoutLoader.java
Browse files Browse the repository at this point in the history
Allow full image paths in XML
  • Loading branch information
chris1010010 committed Mar 9, 2020
1 parent b91eb98 commit b394dad
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/org/primaresearch/page/viewer/dla/XmlDocumentLayoutLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
public class XmlDocumentLayoutLoader extends Task {
private String filePath;
private Page page = null;
private String imageFilePath = null;
private String resolveDir;

/**
Expand Down Expand Up @@ -68,18 +67,23 @@ public Page getPage() {
* @return The file path or an empty string if no image was specified
*/
public String getImageFilePath() {
//Get root folder from XML file path
//Do we have a full path in the XML?
if (page.getImageFilename() != null
&& (page.getImageFilename().startsWith("/") || page.getImageFilename().contains(":"))) {
return page.getImageFilename();
}

//Get root folder from XML file path or use resolveDir
String rootFolder = "";
if (resolveDir != null)
rootFolder = resolveDir;
else if (filePath.contains(File.separator)) {
rootFolder = filePath.substring(0, filePath.lastIndexOf(File.separator));
}
if (!rootFolder.isEmpty())
imageFilePath = rootFolder + (rootFolder.endsWith(File.separator) ? "" : File.separator) + page.getImageFilename();
else
imageFilePath = page.getImageFilename();
return imageFilePath;
return rootFolder + (rootFolder.endsWith(File.separator) ? "" : File.separator) + page.getImageFilename();

return page.getImageFilename();
}

/**
Expand Down

0 comments on commit b394dad

Please sign in to comment.