Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion brailleblaster-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${mavensurefireplugin.version}</version>
<configuration>
<systemPropertyVariables>
<ciBuild>true</ciBuild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,9 @@ class ArchiverRecoverThread(private val m: Manager) {
return "${path.nameWithoutExtension} $dateTimeString.${path.extension}"
}

@JvmStatic
val recentSaves: List<Path>
get() = RECENT_SAVE_FILES

@JvmStatic
fun readRecentSaves(): MutableList<Path> {
try {
return Files.readAllLines(BBIni.recentSaves, BBIni.charset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class NimasZipArchiverLoader : ArchiverFactory.FileLoader {

var bookPath: Path? = null
val opfFiles = findOPFFilesInFolder(zipRoot)
if (!opfFiles.isEmpty()) {
if (opfFiles.isNotEmpty()) {
if (opfFiles.size > 1) {
log.warn("Detected multiple OPF files, picking first: {}", opfFiles)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import java.util.stream.Collectors
object OPFUtils {
private val log: Logger = LoggerFactory.getLogger(OPFUtils::class.java)

@JvmStatic
fun findOPFFilesInFolder(folder: Path): List<Path> {
fun findOPFFilesInFolder(folder: Path): List<Path> {
try {
val opfs = Files.walk(folder)
.filter { obj: Path -> pathNotHiddenOrInHiddenDirectory(obj) && obj.toString().endsWith(".opf") }
Expand All @@ -50,11 +49,15 @@ object OPFUtils {
}
}

@JvmStatic
fun getDCElementValueCaseInsensitive(opfDocument: Document?, opfElemName: String?): String? {
fun getDCElementValueCaseInsensitive(opfDocument: Document?, opfElemName: String?): String? {
val results = FastXPath.descendant(opfDocument)
.filterIsInstance<Element>()
.filter { curElem: Element -> curElem.namespacePrefix == "dc" && curElem.localName.equals(opfElemName, ignoreCase = true) }.toList()
.filter { curElem: Element ->
curElem.namespacePrefix == "dc" && curElem.localName.equals(
opfElemName,
ignoreCase = true
)
}.toList()
if (results.isEmpty()) {
return null
} else if (results.size > 1) {
Expand All @@ -63,8 +66,7 @@ object OPFUtils {
return results[0].value
}

@JvmStatic
fun getManifestItems(opfDocument: Document): List<ManifestEntry> {
fun getManifestItems(opfDocument: Document): List<ManifestEntry> {
val namespace = opfDocument.rootElement.namespaceURI
val manifestRoot = opfDocument.rootElement.getFirstChildElement(
"manifest",
Expand All @@ -90,8 +92,7 @@ object OPFUtils {
* @param path
* @return
*/
@JvmStatic
fun pathNotHiddenOrInHiddenDirectory(path: Path): Boolean {
fun pathNotHiddenOrInHiddenDirectory(path: Path): Boolean {
if (path.fileName == null) {
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ open class TextArchiveLoader : ArchiverFactory.FileLoader {
val bbxDoc = BBX.newDocument()
val root = BBX.SECTION.ROOT.create()
bbxDoc.rootElement.appendChild(root)
file.readLines(BBIni.charset).flatMap { it.split('\u000c') }.filter { it.isNotBlank() }.mapNotNull { getUsableText(it) }.fold(root) { r, v ->
file.readLines(BBIni.charset).flatMap { it.split('\u000c') }.filter { it.isNotBlank() }
.mapNotNull { getUsableText(it) }.fold(root) { r, v ->
r.also {
it.appendChild(createBlock(v))
}
}
val archiver: Archiver2 = BBZArchiver.createImportedBBZ(file, bbxDoc)
var fileStr = file.toString()
fileStr = (if (fileStr.lowercase(Locale.getDefault()).endsWith(".txt")) fileStr.dropLast(4) else fileStr) + ".bbz"
fileStr =
(if (fileStr.lowercase(Locale.getDefault()).endsWith(".txt")) fileStr.dropLast(4) else fileStr) + ".bbz"
archiver.newPath = Paths.get(fileStr)
return archiver
}
Expand Down Expand Up @@ -67,8 +69,7 @@ open class TextArchiveLoader : ArchiverFactory.FileLoader {
* @param line
* @return
*/
@JvmStatic
fun getUsableText(line: String): Text? {
fun getUsableText(line: String): Text? {
return try {
Text(line)
} catch (_: IllegalCharacterDataException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ protected String marshall(ArrayList<String> input) {
int numChars = string.length();
String sizeString = String.valueOf(numChars);
int digitLength = sizeString.length();
Matrix.matrixLog("StringBuilder digits {} length {} and string {}" + digitLength + sizeString + string);
Matrix.Companion.matrixLog("StringBuilder digits {} length {} and string {}" + digitLength + sizeString + string);
s.append(digitLength).append(sizeString).append(string);
}
return s.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,10 @@ fun Node.getAncestorListLevel(): Int = BBX.CONTAINER.LIST.ATTRIB_LIST_LEVEL[XMLH
object BBXUtils {
private val log: Logger = LoggerFactory.getLogger(BBXUtils::class.java)

@JvmStatic
fun isPageNumAncestor(node: Node): Boolean = node.isPageNumAncestor()

@JvmStatic
fun findBlockChild(node: Element): Element = node.findBlockChild()

@JvmStatic
fun findBlock(node: Node): Element = node.findBlock()

/**
Expand Down Expand Up @@ -280,7 +277,6 @@ object BBXUtils {
* only images to image containers. Node is any child of
* the block, or the block itself. Returns the parent of the removed element
*/
@JvmStatic
fun cleanupBlock(node: Node): Node? {
val block = node.findBlockOrNull() ?: return null
block.stripUTDRecursive()
Expand Down Expand Up @@ -376,8 +372,7 @@ object BBXUtils {
transElement.appendChild(textToWrap)
return transElement
}

@JvmStatic

fun wrapAsTransNote(element: Element): Element {
val newEl = wrapAsTransNote(element.value)
element.removeChildren()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ class BookToBBXConverter(
DEBUG_ASK_SWT_DIALOG = !unitTest.isNullOrBlank() && unitTest.startsWith("org.brailleblaster")
}

@JvmStatic
@JvmOverloads
fun fromConfig(bookType: String = "nimas"): BookToBBXConverter {
if (BBDocument.TEST_MODE && TEST_CONFIG == bookType) {
return TEST_CONVERTER
Expand All @@ -259,7 +257,6 @@ class BookToBBXConverter(
return converter
}

@JvmStatic
fun upgradeFormat(doc: Document) {
val formatVersion = BBX.getFormatVersion(doc)
if (formatVersion >= BBX.FORMAT_VERSION) {
Expand Down Expand Up @@ -351,7 +348,6 @@ class BookToBBXConverter(
}
}

@JvmStatic
fun devSetup(args: Array<String>): Array<String> {
return if (File("/home/leon/").exists()) {
System.setProperty(NodeException.SAVE_TO_DISK_FOLDER_PROPERTY, "exception.xml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ object NodeTreeSplitter {
* @param splitAt The root of what gets duplicated in the split element
* @return The after root or null if empty
*/
@JvmStatic
fun split(root: Element?, splitAt: Node?): Element? {
fun split(root: Element?, splitAt: Node?): Element? {
if (root == null) {
throw NullPointerException("oldRootElement")
} else if (splitAt == null) {
throw NullPointerException("oldTrigger")
} else if (root === splitAt) {
log.error("root " + XMLHandler.toXMLSimple(root))
log.error("splitAt " + XMLHandler.toXMLSimple(
splitAt
)
log.error(
"splitAt " + XMLHandler.toXMLSimple(
splitAt
)
)
throw NodeException("root == splitAt, splitAt: ", splitAt)
} else if (FastXPath.descendant(root).none { node: Node -> node === splitAt }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class TableImportFixer : AbstractFixer() {
* Detect table type when given table has no braille, without changing the
* source document with table copies
*/
@JvmStatic
fun detectTableTypeUntranslated(table: Element): TableTypes {
BBX.CONTAINER.TABLE.assertIsA(table)
val utdMan = ImportFixerCommon.UTD_MANAGER
Expand Down Expand Up @@ -196,7 +195,6 @@ class TableImportFixer : AbstractFixer() {
* @param bbxTable
* @return List of elements (blocks and maybe containers) that were under the table cell
*/
@JvmStatic
fun stripTable(bbxTable: Element): List<Element> {
BBX.CONTAINER.TABLE.assertIsA(bbxTable)
val cells: MutableList<Element> = ArrayList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ class ImageBlockToContainerImportFixer : AbstractFixer() {
}

companion object {
@JvmStatic
fun convertImageBlockToContainer(imgElem: Element) {
fun convertImageBlockToContainer(imgElem: Element) {
if (!BBX.SPAN.IMAGE.isA(imgElem) && !BBX.CONTAINER.IMAGE.isA(imgElem)) {
throw NodeException("Not an image", imgElem)
}
val parentBlock = requireNotNull(
XMLHandler.ancestorVisitorElement(imgElem) { node -> BBX.BLOCK.isA(node) }) {
"Cannot find a parent block"
}
}
if (BBX.SPAN.IMAGE.isA(imgElem) && imgElem.childCount != 0) {
val wrappingBlock = BBX.BLOCK.DEFAULT.create()
val children = imgElem.childNodes.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.brailleblaster.utd.internal.xml.FastXPath
import org.brailleblaster.utd.internal.xml.XMLHandler

object BBXTo4Upgrader {
@JvmStatic
fun upgrade(doc: Document) {
if (BBX.getFormatVersion(doc) != 4) {
fixStyleExtend(doc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import org.brailleblaster.utd.internal.xml.FastXPath
import org.brailleblaster.utd.utils.TableUtils

object BBXTo5Upgrader {
@JvmStatic
fun upgrade(doc: Document) {
fun upgrade(doc: Document) {
tableCleanup(doc)
BBX.setFormatVersion(doc, 5)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.brailleblaster.bbx.BBX
import org.brailleblaster.utd.internal.xml.FastXPath

object BBXTo6Upgrader {
@JvmStatic
fun upgrade(doc: Document) {
tabCleanup(doc)
BBX.setFormatVersion(doc, 6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,20 @@ class EmbosserOptionsView(parent: Composite, style: Int = SWT.BORDER or SWT.H_SC
fun removeValidateListener(listener: ValidateListener) {
validateListeners -= listener
}
private val scrolledComposite = ScrolledComposite(parent, style).apply {
expandHorizontal = true
expandVertical = true
showFocusedControl = true
}

val control: Control
get() = scrolledComposite
field = ScrolledComposite(parent, style).apply {
expandHorizontal = true
expandVertical = true
showFocusedControl = true
}

private fun updateOptionsView(options: Map<OptionIdentifier, EmbosserOption>) {
scrolledComposite.content?.dispose()
control.content?.dispose()
val newContent = if (options.isEmpty()) {
EasySWT.makeLabel(scrolledComposite).text(LocaleHandler.getDefault()["EmbosserEditDialog.optionsView.noOptions"]).get()
EasySWT.makeLabel(control).text(LocaleHandler.getDefault()["EmbosserEditDialog.optionsView.noOptions"]).get()
} else {
val optionsContainer = Composite(scrolledComposite, SWT.NONE)
val optionsContainer = Composite(control, SWT.NONE)
optionsContainer.layout = GridLayout(2, false)
for ((k, v) in options) {
EasySWT.makeLabel(optionsContainer).text(k.getDisplayName(Locale.getDefault()))
Expand Down Expand Up @@ -100,8 +101,8 @@ class EmbosserOptionsView(parent: Composite, style: Int = SWT.BORDER or SWT.H_SC
}
optionsContainer
}
scrolledComposite.content = newContent
scrolledComposite.setMinSize(newContent.computeSize(SWT.DEFAULT, SWT.DEFAULT))
control.content = newContent
control.setMinSize(newContent.computeSize(SWT.DEFAULT, SWT.DEFAULT))
}
init {
embosserOptions = options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ class TOCBuilderBBX(private var manager: Manager) : CheckMenuTool, MenuToolModul

// Only give last word
pageStart = indexOfPage(lastTextNode.value)
if (pageStart != -1 && !lastTextNode.value.substring(0, pageStart).isBlank()) {
if (pageStart != -1 && lastTextNode.value.substring(0, pageStart).isNotBlank()) {
// found text before page in next entry
log.debug("ignoring as most likely found another toc entry")
return
Expand Down Expand Up @@ -1249,7 +1249,6 @@ class TOCBuilderBBX(private var manager: Manager) : CheckMenuTool, MenuToolModul
/**
* Ancestor Block that can be unwrapped and moved
*/
@JvmStatic
fun isPageMovable(input: Node): Element? {
if (input.document == null) {
throw NodeException("Node not attached to document", input)
Expand Down Expand Up @@ -1299,20 +1298,13 @@ class TOCBuilderBBX(private var manager: Manager) : CheckMenuTool, MenuToolModul
TOCAttributes.TYPE.add(elem, type)
}

@JvmStatic
fun isEnabled(m: Manager): Boolean {
return m.simpleManager.getModule(
TOCBuilderBBX::class.java
)!!.enabled
}
fun isEnabled(m: Manager): Boolean = m.simpleManager.getModule(
TOCBuilderBBX::class.java
)!!.enabled

private fun isTocTitle(curNode: Node): Boolean {
return isTocElement(curNode, "title")
}
private fun isTocTitle(curNode: Node): Boolean = isTocElement(curNode, "title")

private fun isTocPage(curNode: Node): Boolean {
return isTocElement(curNode, "page")
}
private fun isTocPage(curNode: Node): Boolean = isTocElement(curNode, "page")

private fun isTocElement(curNode: Node, key: String): Boolean {
if (curNode !is Element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,10 +1015,10 @@ class TPagesDialog : DebugMenuToolModule {
//Dumb SWT manipulation
val values = items.map { it.getText(0) to it.getText(1) }
symbolsTable.removeAll()
for (i in values) {
for ((first, second) in values) {
val newItem = TableItem(symbolsTable, SWT.NONE)
newItem.setText(0, i.first)
newItem.setText(1, i.second)
newItem.setText(0, first)
newItem.setText(1, second)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class VolumeSaveDialog(
}

val finalBrf = finalBrfMut!!
check(!finalBrf.isBlank()) { "No finalBrf?! $LINE_BREAK$finalBrf$LINE_BREAK=------=" }
check(finalBrf.isNotBlank()) { "No finalBrf?! $LINE_BREAK$finalBrf$LINE_BREAK=------=" }

//Remove lingering empty page from resetting the page to restart the BRF output
val linesPerPage = engine.brailleSettings.cellType.getLinesForHeight(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object ASCII2MathML {
* @param st
* @return math root node, detached from document,, or null
*/
@JvmStatic

fun translate(st: String): Node {
var s = st
if (s.contains("\r")) {
Expand Down Expand Up @@ -64,7 +64,7 @@ object ASCII2MathML {
* @param st
* @return math root node, detached from document,, or null
*/
@JvmStatic
fun translateUseHTML(st: String): org.w3c.dom.Element {
var s = st
if (s.contains("\r")) {
Expand Down
Loading