Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oobranch c : ootext and rangesort #7788

Merged
merged 25 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a50cc79
step0 : start model/openoffice, logic/openoffice/style
antalk2 May 27, 2021
d93bd56
correction: import order
antalk2 May 27, 2021
c9b72e9
add general utilities
antalk2 May 27, 2021
381a549
add UNO utilities, move CreationException, NoDocumentException
antalk2 May 27, 2021
f94c1f6
Xlint:unchecked model/openoffice/util
antalk2 May 28, 2021
f9a8176
add ootext
antalk2 May 28, 2021
6d013f1
add rangesort
antalk2 May 28, 2021
0434579
add compareStartsUnsafe, compareStartsThenEndsUnsafe
antalk2 Jun 3, 2021
3c45a8a
add Tuple3
antalk2 Jun 3, 2021
32f7a43
add ootext
antalk2 May 28, 2021
6bae6b4
add rangesort
antalk2 May 28, 2021
314902c
delNamesArray size correction
antalk2 Jun 3, 2021
dfe18bc
rangeSort update
antalk2 Jun 3, 2021
c9f4e57
Merge remote-tracking branch 'origin/oobranch-C' into oobranch-C
antalk2 Jun 3, 2021
6e4c7c2
cleanup
antalk2 Jun 3, 2021
66ac767
Merge remote-tracking branch 'upstream/main' into oobranch-C
antalk2 Jun 18, 2021
24375e9
ootext changes from improve-reversibility-rebased-03
antalk2 Jun 18, 2021
8c92db7
rangesort changes from improve-reversibility-rebased-03
antalk2 Jun 18, 2021
119149c
rangesort update from improve-reversibility-rebased-03
antalk2 Jun 19, 2021
91a3086
use longer lines in comments
antalk2 Jun 19, 2021
7533e8f
deleted src/main/java/org/jabref/model/openoffice/rangesort/RangeS…
antalk2 Jun 19, 2021
5fe0c36
use StringUtil.isNullOrEmpty
antalk2 Jun 22, 2021
65e1781
no natural sort for ComparableMark
antalk2 Jun 22, 2021
89f9aa6
in response to review
antalk2 Jul 7, 2021
373f467
use {@code }, PMD suggestions
antalk2 Jul 9, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.jabref.logic.openoffice.CitationEntry;
import org.jabref.model.openoffice.CitationEntry;

public class CitationEntryViewModel {

Expand Down
13 changes: 0 additions & 13 deletions src/main/java/org/jabref/gui/openoffice/CreationException.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.jabref.gui.DialogService;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.CitationEntry;
import org.jabref.model.openoffice.CitationEntry;

import com.sun.star.beans.IllegalTypeException;
import com.sun.star.beans.NotRemoveableException;
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/org/jabref/gui/openoffice/NoDocumentException.java

This file was deleted.

6 changes: 4 additions & 2 deletions src/main/java/org/jabref/gui/openoffice/OOBibBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
import org.jabref.logic.bibtex.comparator.FieldComparatorStack;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.layout.Layout;
import org.jabref.logic.openoffice.OOBibStyle;
import org.jabref.logic.openoffice.OOPreFormatter;
import org.jabref.logic.openoffice.OOUtil;
import org.jabref.logic.openoffice.UndefinedBibtexEntry;
import org.jabref.logic.openoffice.UndefinedParagraphFormatException;
import org.jabref.logic.openoffice.style.OOBibStyle;
import org.jabref.logic.openoffice.style.OOPreFormatter;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.openoffice.uno.CreationException;
import org.jabref.model.openoffice.uno.NoDocumentException;

import com.sun.star.awt.Point;
import com.sun.star.beans.IllegalTypeException;
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@
import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.OOBibStyle;
import org.jabref.logic.openoffice.OpenOfficeFileSearch;
import org.jabref.logic.openoffice.OpenOfficePreferences;
import org.jabref.logic.openoffice.StyleLoader;
import org.jabref.logic.openoffice.UndefinedParagraphFormatException;
import org.jabref.logic.openoffice.style.OOBibStyle;
import org.jabref.logic.openoffice.style.StyleLoader;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.openoffice.uno.CreationException;
import org.jabref.model.openoffice.uno.NoDocumentException;
import org.jabref.preferences.PreferencesService;

import com.sun.star.beans.IllegalTypeException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.jabref.gui.util.ViewModelTableRowFactory;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.layout.TextBasedPreviewLayout;
import org.jabref.logic.openoffice.OOBibStyle;
import org.jabref.logic.openoffice.StyleLoader;
import org.jabref.logic.openoffice.style.OOBibStyle;
import org.jabref.logic.openoffice.style.StyleLoader;
import org.jabref.logic.util.TestEntry;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.types.StandardEntryType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.OOBibStyle;
import org.jabref.logic.openoffice.OpenOfficePreferences;
import org.jabref.logic.openoffice.StyleLoader;
import org.jabref.logic.openoffice.style.OOBibStyle;
import org.jabref.logic.openoffice.style.StyleLoader;
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.preferences.PreferencesService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import javafx.scene.Node;

import org.jabref.gui.icon.IconTheme;
import org.jabref.logic.openoffice.OOBibStyle;
import org.jabref.logic.openoffice.style.OOBibStyle;

public class StyleSelectItemViewModel {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/logic/layout/LayoutEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
import org.jabref.logic.layout.format.WrapContent;
import org.jabref.logic.layout.format.WrapFileLinks;
import org.jabref.logic.layout.format.XMLChars;
import org.jabref.logic.openoffice.OOPreFormatter;
import org.jabref.logic.openoffice.style.OOPreFormatter;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jabref.logic.openoffice;

import org.jabref.logic.openoffice.style.OOBibStyle;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jabref.logic.openoffice;
package org.jabref.logic.openoffice.style;

import java.io.File;
import java.io.FileInputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jabref.logic.openoffice;
package org.jabref.logic.openoffice.style;

import java.util.Map;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jabref.logic.openoffice;
package org.jabref.logic.openoffice.style;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -10,6 +10,7 @@
import java.util.Objects;

import org.jabref.logic.layout.LayoutFormatterPreferences;
import org.jabref.logic.openoffice.OpenOfficePreferences;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jabref.logic.openoffice;
package org.jabref.model.openoffice;

import java.util.Objects;
import java.util.Optional;
Expand Down
73 changes: 73 additions & 0 deletions src/main/java/org/jabref/model/openoffice/ootext/OOFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.jabref.model.openoffice.ootext;

public class OOFormat {

/**
* Mark {@code s} as using a character locale known to OO.
*
* @param locale language[-country[-territory]]
*
* https://www.openoffice.org/api/docs/common/ref/com/sun/star/lang/Locale.html
*
* The country part is optional.
*
* The territory part is not only optional, the allowed "codes are
* vendor and browser-specific", so probably best to avoid them if possible.
*
*/
public static OOText setLocale(OOText s, String locale) {
Copy link
Member

@Siedlerchr Siedlerchr Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please no single character variables, better give it a more meaningful variable. Same applies for others

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to OOText ootext

return OOText.fromString(String.format("<span lang=\"%s\">", locale) + s.asString() + "</span>");
}

/**
* Mark {@code s} as using the character locale "zxx", which means
* "no language", "no linguistic content".
*
* Used around citation marks, probably to turn off spellchecking.
*
*/
public static OOText setLocaleNone(OOText s) {
return OOFormat.setLocale(s, "zxx");
}

/**
* Mark {@code s} using a character style {@code charStyle}
*
* @param charStyle Name of a character style known to OO. May be
* empty for "Standard", which in turn means do not override any properties.
*
*/
public static OOText setCharStyle(OOText s, String charStyle) {
return OOText.fromString(String.format("<span oo:CharStyleName=\"%s\">", charStyle)
+ s.asString()
+ "</span>");
}

/**
* Mark {@code s} as part of a paragraph with style {@code paraStyle}
*/
public static OOText paragraph(OOText s, String paraStyle) {
if (paraStyle == null || "".equals(paraStyle)) {
antalk2 marked this conversation as resolved.
Show resolved Hide resolved
return paragraph(s);
}
String startTag = String.format("<p oo:ParaStyleName=\"%s\">", paraStyle);
return OOText.fromString(startTag + s.asString() + "</p>");
}

/**
* Mark {@code s} as part of a paragraph.
*/
public static OOText paragraph(OOText s) {
return OOText.fromString("<p>" + s.asString() + "</p>");
}

/**
* Format an OO cross-reference showing the target's page number
* as label to a reference mark.
*/
public static OOText formatReferenceToPageNumberOfReferenceMark(String referencMarkName) {
String s = String.format("<oo:referenceToPageNumberOfReferenceMark target=\"%s\">",
referencMarkName);
return OOText.fromString(s);
}
}
62 changes: 62 additions & 0 deletions src/main/java/org/jabref/model/openoffice/ootext/OOText.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.jabref.model.openoffice.ootext;

import java.util.Objects;

/**
* Text with HTML-like markup as understood by OOTextIntoOO.write
*
* Some of the tags can be added using OOFormat methods. Others come
* from the layout engine, either by interpreting LaTeX markup or from
* settings in the jstyle file.
*/
public class OOText {

private final String data;

private OOText(String data) {
Objects.requireNonNull(data);
this.data = data;
}

/* null input is passed through */
k3KAW8Pnf7mkmdSMPHz27 marked this conversation as resolved.
Show resolved Hide resolved
public static OOText fromString(String s) {
if (s == null) {
return null;
}
return new OOText(s);
}

/* null input is passed through */
k3KAW8Pnf7mkmdSMPHz27 marked this conversation as resolved.
Show resolved Hide resolved
public static String toString(OOText s) {
if (s == null) {
return null;
}
return s.data;
}

public String asString() {
return data;
}

/* Object.equals */
k3KAW8Pnf7mkmdSMPHz27 marked this conversation as resolved.
Show resolved Hide resolved
@Override
public boolean equals(Object o) {

if (o == this) {
return true;
}

if (!(o instanceof OOText)) {
return false;
}

OOText c = (OOText) o;

return data.equals(c.data);
}

@Override
public int hashCode() {
return data.hashCode();
}
}
Loading