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
35 changes: 24 additions & 11 deletions docs/code-howtos/openoffice/code-reorganization.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ grand_parent: Code Howtos
The Writer integration separates GUI actions, citation rendering, persistent citation state, and low-level UNO access.
Use this guide to locate the code responsible for a change; the [architecture overview](overview.md), [ADR-0084](../../decisions/0084-canonical-writer-citations.md), and [requirements](../../requirements/openoffice.md) define the behavior and compatibility contract.

![Writer citation integration layers](writer-citation-layers.svg)
![Writer package layout and ownership](writer-package-layout.svg)

## Source roots and package boundaries

Expand All @@ -25,16 +25,22 @@ The logic and model packages below live under `jablib/src/main/java/org/jabref/`
| `logic.openoffice.backend` | Work with concrete Writer reference-mark ranges without interpreting citation names. | `WriterReferenceMark`, `WriterReferenceMarks`, `ReferenceMarkTextWriter`, `WriterTextContext` |
| `logic.openoffice.uno` | Access Writer services, interfaces, cursors, named content, and properties. | `UnoInterfaces`, `NamedTextContentInserter`, `NamedTextContentPlacement`, `NamedTextContentLookup`, `OOTextWriter` |
| `logic.openoffice.rangesort` | Order UNO ranges and detect overlaps. | `RangeSort`, `RangeSortVisual`, `RestorableTextViewCursor`, `WithinSetRangeOverlapFinder`, `BetweenSetsRangeOverlapFinder` |
| `logic.openoffice.style` | Load selectable Writer styles and perform JStyle-specific formatting. | `OOStyle`, `JStyle`, `BstStyle`, `JStyleLoader`, `BstStyleLoader`, `JStyleCitationProcessor` |
| `logic.openoffice.bst` | Convert BST output through Pandoc and normalize its markup. | `BstEntryRenderer`, `PandocLatexConverter`, `BSTFormatUtils` |
| `logic.openoffice.oocsltext` | Adapt CSL output to Writer-ready text. | `CSLFormatUtils` |
| `logic.openoffice.style` | Define the common selectable-style contract and family-neutral Writer style names. | `OOStyle`, `WriterParagraphStyles` |
| `logic.openoffice.jstyle` | Load JStyles and compute JStyle-specific citation and bibliography formatting. | `JStyle`, `JStyleLoader`, `JStyleCitationProcessor`, `JStyleBibliographyFormatter` |
| `logic.openoffice.bst` | Load Writer BST styles, select citation notation, and convert BST output through Pandoc. | `BstStyle`, `BstStyleLoader`, `BstCitationFormat`, `BstEntryRenderer`, `PandocLatexConverter`, `BSTFormatUtils` |
| `logic.openoffice.csl` | Adapt CSL output to Writer-ready text. | `CSLFormatUtils` |
| `model.openoffice.style` | Represent citations, groups, resolved sources, and presentation state without UNO access. | `Citation`, `CitationGroup`, `CitationGroupId`, `CitationGroups`, `CitedReference`, `CitedReferences` |
| `model.openoffice.ootext` | Describe formatted output independently of Writer. | `OOText`, `OOFormat` |
| `model.openoffice.util` | Supply result types and collection helpers used across the integration. | `OOResult`, `OOVoidResult`, `OOListUtil` |

CSL style loading and metadata live in `logic.citationstyle`, including `CitationStyle`, `CSLStyleLoader`, and `CSLStyleMetadata`.
Writer-specific family helpers are grouped in `jstyle`, `bst`, and `csl`; `style` contains common contracts and Writer paragraph-style identifiers.
`WriterParagraphStyles` owns the neutral catalogs; CSL-aware default selection stays in `CSLFormatUtils`.
`OOPreFormatter` belongs to `logic.layout.format`, shared by generic layouts and JStyle without depending on a citation family.
Shared CSL style loading and metadata remain in `logic.citationstyle`, including `CitationStyle`, `CSLStyleLoader`, and `CSLStyleMetadata`.
The `backend` package is concrete Writer infrastructure, not a family-specific citation backend interface.
UNO access and range sorting belong to `logic`, not to the pure model packages.
`JStyle` and `BstStyle` also belong in `logic`: they load and parse definitions and hold executable layouts or BST programs.
`OOStyle` describes the selection contract for those logic implementations, while citation identities, groups, page information, and formatted-output values belong in `model`.

## GUI gateway and document connection

Expand Down Expand Up @@ -95,6 +101,8 @@ A `RenderRequest` supplies groups in document order, libraries, and options; `Re
`CitationKeyResolution` resolves keys using the request's library precedence and prepares resolved entry data without treating entry IDs as citation keys.
`CitationNumbering` supplies shared numbering operations; each renderer applies its style-family ordering and label rules.
Renderers compute output without writing to Writer.
All three renderers and the package-private `BstCitationFormatter` remain in `logic.openoffice.engine`, alongside the render/action boundary.
This keeps `CitationKeyResolution`, `BibliographyText`, and native CSL rendering internal to the engine rather than exposing them to family helper packages.

`UpdatePipeline` coordinates preparation and application of canonical output.
`DocumentWriteSession` owns the write-phase undo context, controller locking, and suspension of change recording.
Expand Down Expand Up @@ -154,16 +162,18 @@ Numeric JStyle supports `NORMAL`, `IN_TEXT`, and `EMPTY`; citation-key mode rema

`JStyleRenderer` invokes the processor and uses `JStyleBibliographyFormatter.formatBibliographyEntry` for requested bibliography paragraphs before returning a `RenderResult`.
JStyle bibliography paragraph styles are validated only when bibliography output is requested.
`OOPreFormatter` converts LaTeX to Unicode and `OOText` tags for layout output.
`OOText` and `OOFormat` describe that output; only the logic-layer `OOTextWriter` interprets it into Writer text.
The JStyle processors, formatters, and loaders live in `logic.openoffice.jstyle`.
They use `logic.layout.format.OOPreFormatter` to convert LaTeX to Unicode and `OOText` tags for layout output; its registered layout name remains `OOPreFormatter`.
`OOText` and `OOFormat` describe that output without depending on logic implementations; only the logic-layer `OOTextWriter` interprets it into Writer text.

`OOStyle` is the common selectable-style interface for `JStyle`, `CitationStyle`, and `BstStyle`.
`OOStyle` in `logic.openoffice.style` is the common selectable-style interface for `JStyle`, `CitationStyle`, and `BstStyle`.
`BstStyle`, `BstStyleLoader`, and `BstCitationFormat` live with the Pandoc conversion helpers in `logic.openoffice.bst`.
`BstStyle.getBstVM()` exposes its cached parsed program rather than creating a new VM.
BST whole-cited-set rendering and citation labels belong to `BstRenderer` and `BstCitationFormatter`; Pandoc conversion helpers are in `logic.openoffice.bst`.
BST whole-cited-set rendering and citation labels belong to `BstRenderer` and `BstCitationFormatter` in `logic.openoffice.engine`.
BST supports `NORMAL` and `IN_TEXT` for all three notations: `NUMERIC`, `AUTHOR_YEAR`, and `STYLE_DEFINED`.
In-text groups preserve storage order, pairing each source's Natbib-formatted short author list with its number, year, or style-defined label; repeated sources and unresolved placeholders retain their positions.
For both normal and in-text groups, `AUTHOR_YEAR` without requested bibliography output skips BST source loading, VM execution, and Pandoc; numeric and style-defined notations still require BST execution for numbering, labels, and ordering.
`CSLFormatUtils` adapts CSL-generated markup rather than selecting a renderer or managing document citations.
`CSLFormatUtils` in `logic.openoffice.csl` adapts CSL-generated markup rather than selecting a renderer or managing document citations.

## Writer infrastructure and ordering

Expand Down Expand Up @@ -191,7 +201,10 @@ See the [ordering guide](order-of-appearance.md) for footnote mapping, merge adj

## Tests and further reading

Unit tests mirror the GUI, engine, storage, style, and Writer infrastructure packages.
Unit tests mirror the GUI, engine, storage, style-family helpers, and Writer infrastructure packages.
Under `jablib/src/test/java/org/jabref/logic/openoffice/`, `JStyle*` tests are in `jstyle`, `BstStyle*` tests are in `bst`, and `CSLFormatUtilsTest` is in `csl`.
`OOPreFormatterTest` mirrors its shared formatter under `logic/layout/format/`; model markup tests remain under `model/openoffice/ootext/`.
Package-relative JStyle fixtures live in `jablib/src/test/resources/org/jabref/logic/openoffice/jstyle/`; absolute built-in `/resource/openoffice/` paths are unchanged.
`JabRefMarkCodecTest` checks the canonical codec; `JabRefMarkCodecCompatibilityTest` checks its storage boundary against legacy names.
`BstCitationFormatterTest` exercises BST label/marker helpers, and `NonUndoableStylePropertiesTest` documents the ordinary style-property undo boundary.
`JStyleTestHelper` supports JStyle formatting tests; `JabRefCliPreferencesTest` checks preference serialization and style persistence.
Expand Down
4 changes: 4 additions & 0 deletions docs/code-howtos/openoffice/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ The [requirements](../../requirements/openoffice.md) and [ADR-0084](../../decisi
| Citation conversion | `CitationFormatConverter` | Prepare insertion-triggered, lossy canonical/native conversion and one-way legacy JStyle migration. |

The engine and renderers live in `jablib/src/main/java/org/jabref/logic/openoffice/engine/`; canonical storage is in its `storage` subpackage.
Writer-specific style helpers are grouped in `logic.openoffice.jstyle`, `logic.openoffice.bst`, and `logic.openoffice.csl`; `logic.openoffice.style` holds the common `OOStyle` contract and Writer paragraph-style catalogs.
Shared layout formatting, including `OOPreFormatter`, belongs to `logic.layout.format`, not a citation family.
Shared CSL styles, loading, and metadata remain in `logic.citationstyle`.
The render/action boundary, including the package-private `BstCitationFormatter`, stays in `engine`; see the [package layout and ownership guide](code-reorganization.md).
`DocumentCitations` and `DocumentOrder` are in `logic/openoffice/frontend/`.
`DocumentCitations` is an action-local facade combining a mutable `CitationGroups` model with live `MarkStore` and Writer range access, not a document subtype or immutable snapshot.
Core facade instances are named `documentCitations`; GUI controller instances are named `citationController`.
Expand Down
80 changes: 80 additions & 0 deletions docs/code-howtos/openoffice/writer-package-layout.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.jabref.gui.icon.IconTheme;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.style.BstStyle;
import org.jabref.logic.openoffice.bst.BstStyle;

/// Row model for a [BstStyle] entry in the BST styles table.
public class BstStyleSelectViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.jabref.gui.icon.IconTheme;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.style.JStyle;
import org.jabref.logic.openoffice.jstyle.JStyle;

public class JStyleSelectViewModel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

import org.jabref.logic.citationstyle.CitationStyle;
import org.jabref.logic.openoffice.OpenOfficePreferences;
import org.jabref.logic.openoffice.oocsltext.CSLFormatUtils;
import org.jabref.logic.openoffice.style.WriterParagraphStyles;

public class ModifyBibliographyPropertiesDialogViewModel {

private final StringProperty cslBibliographyTitle = new SimpleStringProperty();
private final StringProperty cslBibliographySelectedHeaderFormat = new SimpleStringProperty();
private final StringProperty cslBibliographySelectedBodyFormat = new SimpleStringProperty();
private final ReadOnlyListProperty<String> headerFormatListProperty =
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(CSLFormatUtils.BIBLIOGRAPHY_TITLE_FORMATS));
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(WriterParagraphStyles.BIBLIOGRAPHY_TITLE_FORMATS));
private final ReadOnlyListProperty<String> bodyFormatListProperty =
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(CSLFormatUtils.BIBLIOGRAPHY_BODY_FORMATS));
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(WriterParagraphStyles.BIBLIOGRAPHY_BODY_FORMATS));

private final OpenOfficePreferences openOfficePreferences;
private final BooleanProperty shouldDisableHeadingControls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.OpenOfficeFileSearch;
import org.jabref.logic.openoffice.OpenOfficePreferences;
import org.jabref.logic.openoffice.bst.BstStyleLoader;
import org.jabref.logic.openoffice.engine.StyleCapabilities;
import org.jabref.logic.openoffice.style.BstStyleLoader;
import org.jabref.logic.openoffice.style.JStyle;
import org.jabref.logic.openoffice.style.JStyleLoader;
import org.jabref.logic.openoffice.jstyle.JStyle;
import org.jabref.logic.openoffice.jstyle.JStyleLoader;
import org.jabref.logic.openoffice.style.OOStyle;
import org.jabref.logic.openoffice.uno.WriterOperationException;
import org.jabref.logic.util.BackgroundTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.OpenOfficePreferences;
import org.jabref.logic.openoffice.style.BstCitationFormat;
import org.jabref.logic.openoffice.style.BstStyleLoader;
import org.jabref.logic.openoffice.style.JStyleLoader;
import org.jabref.logic.openoffice.bst.BstCitationFormat;
import org.jabref.logic.openoffice.bst.BstStyleLoader;
import org.jabref.logic.openoffice.jstyle.JStyleLoader;
import org.jabref.logic.openoffice.style.OOStyle;
import org.jabref.logic.preview.BstPreviewLayout;
import org.jabref.logic.preview.CitationStylePreviewLayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.OpenOfficePreferences;
import org.jabref.logic.openoffice.style.BstCitationFormat;
import org.jabref.logic.openoffice.style.BstStyle;
import org.jabref.logic.openoffice.style.BstStyleLoader;
import org.jabref.logic.openoffice.style.JStyle;
import org.jabref.logic.openoffice.style.JStyleLoader;
import org.jabref.logic.openoffice.bst.BstCitationFormat;
import org.jabref.logic.openoffice.bst.BstStyle;
import org.jabref.logic.openoffice.bst.BstStyleLoader;
import org.jabref.logic.openoffice.jstyle.JStyle;
import org.jabref.logic.openoffice.jstyle.JStyleLoader;
import org.jabref.logic.openoffice.style.OOStyle;
import org.jabref.logic.preview.CitationStylePreviewLayout;
import org.jabref.logic.util.BackgroundTask;
Expand Down
Loading
Loading