Skip to content

Commit

Permalink
## 1.0 alpha 2
Browse files Browse the repository at this point in the history
### General
- Migrated from Bitbucket to GitHub
- Dark mode using FlafLaf 1.0
- Added Applet that allows to start Joeffice embedded in any software accepting applets

### Word Processor
- Created component not dependant of NetBeans Platform that can be embedded in other Java application
- Use paragraph style for attributes not defined on text
- Use a default font (instead of previously used font) when no font is defined
- Scale fonts to 96/72 for Windows

### Spreadsheet
- Fixed missing background color for spreadsheets
- Fixed copy values of cells when the cell has a formula
- Added option to limit the size of the sheet up to the filled in cell
- Made SheetComponent independant of SpreadsheetComponent
- Scale fonts to 96/72 for Windows

### Presentation
- Fixed position and size of images in slide
  • Loading branch information
japplis committed Jun 28, 2023
1 parent b34bcbf commit 60214ea
Show file tree
Hide file tree
Showing 33 changed files with 628 additions and 216 deletions.
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@

## 1.0 alpha 2

### New features
### General
- Migrated from Bitbucket to GitHub
- Dark mode using FlafLaf 1.0
- Fixed missing background color for spreadsheets
- Added Applet that allows to start Joeffice embedded in any software accepting applets

### Word Processor
- Created component not dependant of NetBeans Platform that can be embedded in other Java application
- Use paragraph style for attributes not defined on text
- Use a default font (instead of previously used font) when no font is defined
- Scale fonts to 96/72 for Windows

### Spreadsheet
- Fixed missing background color for spreadsheets
- Fixed copy values of cells when the cell has a formula
- Added option to limit the size of the sheet up to the filled in cell
- Made SheetComponent independant of SpreadsheetComponent
- Scale fonts to 96/72 for Windows

### Presentation
- Fixed position and size of images in slide

### libraries
- Upgraded to NetBeans 12.3 (from NetBeans 8.1)
-- Many improvements including the migration to the Apache license: https://github.com/apache/netbeans
Expand All @@ -21,4 +36,4 @@

## 1.0 alpha 1

- Everything was done
- Everything was done: https://www.youtube.com/playlist?list=PLsezR6w8oWsJAKvFuv3JI34PLFFMIxLVA
79 changes: 79 additions & 0 deletions Desktop/src/org/joeffice/desktop/actions/EditorFindable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright 2023 Japplis.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.joeffice.desktop.actions;

import static java.awt.font.TextAttribute.*;
import static org.joeffice.desktop.actions.ExtraTextAttribute.*;
import static javax.swing.text.StyleConstants.*;

import java.text.AttributedCharacterIterator;
import java.text.AttributedCharacterIterator.Attribute;
import java.text.AttributedString;
import java.util.EnumSet;
import java.util.Enumeration;

import javax.swing.JTextPane;
import javax.swing.text.*;

import org.joeffice.desktop.ui.Findable;

/**
* Class that applies the style to the editor.
*
* This involves converting the {@link AttributedString} to an {@link AttributeSet} and vice versa.
*
* @author Anthony Goubard - Japplis
*/
public class EditorFindable implements Findable {

private JTextPane textPane;
private int position = 0;
private String lastSearch;
private EnumSet<FindOption> lastOptions;

public EditorFindable(JTextPane textPane) {
this.textPane = textPane;
}

@Override
public boolean find(String search, EnumSet<FindOption> options) {
lastSearch = search;
lastOptions = options;
return find(0);
}

private boolean find(int fromPosition) {
try {
String text = textPane.getDocument().getText(0, textPane.getDocument().getLength());
position = find(text, lastSearch, fromPosition, lastOptions);
if (position != -1) {
textPane.setCaretPosition(position);
}
return position != -1;
} catch (BadLocationException ex) {
return false;
}

}

@Override
public boolean findNext(boolean forward) {
if (position == textPane.getCaretPosition()) {
position++;
}
return find(position);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.joeffice.desktop.actions.ExtraTextAttribute.*;
import static javax.swing.text.StyleConstants.*;

import java.awt.font.TextAttribute;
import java.text.AttributedCharacterIterator;
import java.text.AttributedCharacterIterator.Attribute;
import java.text.AttributedString;
Expand Down
3 changes: 2 additions & 1 deletion Desktop/src/org/joeffice/desktop/file/OfficeDataObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ private OfficeTopComponent findTopComponent() {
Set<TopComponent> openTopComponents = WindowManager.getDefault().getRegistry().getOpened();
for (TopComponent officeComponent : openTopComponents) {
if (officeComponent.getLookup().lookup(OfficeDataObject.class) != null
&& officeComponent.getLookup().lookup(OfficeDataObject.class).getPrimaryFile().equals(getPrimaryFile())) {
&& officeComponent.getLookup().lookup(OfficeDataObject.class).getPrimaryFile().equals(getPrimaryFile())
&& officeComponent instanceof OfficeTopComponent) {
return (OfficeTopComponent) officeComponent;
}
}
Expand Down
42 changes: 42 additions & 0 deletions Desktop/src/org/joeffice/desktop/ui/Findable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.joeffice.desktop.ui;

import java.util.EnumSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Interface for finding text within the document.
*
* @author Anthony Goubard - Japplis
*/
public interface Findable {

public enum FindOption {MATCH_CASE, WHOLE_WORD, REG_EXP};

boolean find(String search, EnumSet<FindOption> options);

boolean findNext(boolean forward);

default int find(String text, String search, int from, EnumSet<FindOption> options) {
if (options.contains(FindOption.MATCH_CASE) && options.size() == 1) {
return text.indexOf(search, from);
}
String searchRegExp = search;
if (!options.contains(FindOption.REG_EXP)) {
searchRegExp = search.replaceAll("[\\$\\^\\.\\?\\[\\{]", "\\$1");
}
if (options.contains(FindOption.WHOLE_WORD)) {
searchRegExp = "\\b" + searchRegExp + "\\b";
}
if (!options.contains(FindOption.MATCH_CASE) && !search.contains("(?i)")) {
searchRegExp = "(?i)" + searchRegExp;
}
String searchText = text.substring(from);
Pattern searchPattern = Pattern.compile(searchRegExp);
Matcher searchMatcher = searchPattern.matcher(searchText);
if (searchMatcher.find()) {
return from + searchMatcher.start();
}
return -1;
}
}
1 change: 0 additions & 1 deletion Drawing/src/org/joeffice/drawing/DrawingTopComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public String getShortName() {

@Override
protected Object loadDocument(File svgFile) throws Exception {

String xmlParser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory svgFactory = new SAXSVGDocumentFactory(xmlParser);
String uri = Utilities.toURI(svgFile).toURL().toString();
Expand Down
16 changes: 8 additions & 8 deletions Presentation/src/org/joeffice/presentation/ShapeComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ private void initComponent() {
((XSLFTextShape) shape).getSheet() instanceof XSLFNotes)) {
handleTextShape((XSLFTextShape) shape);
} else {

double scale = slideComponent.getScale();
BufferedImage img = shapeToImage(shape, scale);
JLabel shapeLabel = new JLabel(new ImageIcon(img));
Expand All @@ -91,9 +90,8 @@ public static BufferedImage shapeToImage(XSLFShape shape, double scale) {
Graphics2D graphics = img.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
//graphics.translate(-shape.getAnchor().getX() * scale, -shape.getAnchor().getY() * scale);
graphics.scale(scale, scale);
Rectangle2D.Double bounds = new Rectangle2D.Double(shape.getAnchor().getX() * scale, shape.getAnchor().getY() * scale, img.getWidth(), img.getHeight());
graphics.translate(-shape.getAnchor().getX(), -shape.getAnchor().getY());
Rectangle2D.Double bounds = new Rectangle2D.Double(shape.getAnchor().getX(), shape.getAnchor().getY(), img.getWidth(), img.getHeight());
shape.draw(graphics, bounds);
graphics.dispose();
return img;
Expand Down Expand Up @@ -139,7 +137,8 @@ private void handleTextShape(XSLFTextShape textShape) {
add(textField);
if (editable) {
textField.getDocument().addDocumentListener(this);
textField.getDocument().addUndoableEditListener((UndoRedo.Manager) getSlideComponent().getSlidesComponent().getUndoRedo());
SlidesTopComponent slidesTopComponent = (SlidesTopComponent) getSlideComponent().getSlidesComponent();
textField.getDocument().addUndoableEditListener((UndoRedo.Manager) slidesTopComponent.getUndoRedo());
textField.addFocusListener(new FocusListener() {

@Override
Expand Down Expand Up @@ -256,14 +255,15 @@ public void removeUpdate(DocumentEvent de) {
public void changedUpdate(DocumentEvent de) {
try {
((XSLFTextShape) shape).setText(de.getDocument().getText(0, de.getDocument().getLength()));
getSlideComponent().getSlidesComponent().getDataObject().setModified(true);
OfficeTopComponent topComponent = (OfficeTopComponent) getSlideComponent().getSlidesComponent();
topComponent.getDataObject().setModified(true);
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}

public void registerActions(JTextPane textField) {
OfficeTopComponent topComponent = getSlideComponent().getSlidesComponent();
OfficeTopComponent topComponent = (OfficeTopComponent) getSlideComponent().getSlidesComponent();
ActionMap topComponentActions = topComponent.getActionMap();
ActionMap textFieldActions = textField.getActionMap();

Expand All @@ -276,7 +276,7 @@ public void registerActions(JTextPane textField) {
}

public void unregisterActions() {
OfficeTopComponent topComponent = getSlideComponent().getSlidesComponent();
OfficeTopComponent topComponent = (OfficeTopComponent) getSlideComponent().getSlidesComponent();
ActionMap topComponentActions = topComponent.getActionMap();

// Deactivates the cut / copy / paste buttons
Expand Down
18 changes: 11 additions & 7 deletions Presentation/src/org/joeffice/presentation/SlideComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.List;

import javax.swing.JComponent;
import javax.swing.JPanel;

import org.apache.poi.xslf.usermodel.XSLFBackground;
Expand All @@ -30,25 +32,27 @@
/**
* A component to show one slide.
*
* This class doesn't require NetBeans application framework if slidesTopComponent is null.
*
* @author Anthony Goubard - Japplis
*/
public class SlideComponent extends JPanel {

private XSLFSheet slide;

private SlidesTopComponent slidesComponent;
private JComponent slidesTopComponent;

private double scale = 1.0;

private BufferedImage backgroundImage;

public SlideComponent(XSLFSheet slide, SlidesTopComponent slidesComponent) {
this(slide, slidesComponent, new Dimension(1280, 720));
public SlideComponent(XSLFSheet slide, JComponent slidesTopComponent) {
this(slide, slidesTopComponent, new Dimension(1280, 720));
}

public SlideComponent(XSLFSheet slide, SlidesTopComponent slidesComponent, Dimension maxSize) {
public SlideComponent(XSLFSheet slide, JComponent slidesTopComponent, Dimension maxSize) {
this.slide = slide;
this.slidesComponent = slidesComponent;
this.slidesTopComponent = slidesTopComponent;

if (slide.getBackground() != null) {
Rectangle2D backgroundSize = slide.getBackground().getAnchor();
Expand Down Expand Up @@ -95,7 +99,7 @@ public XSLFSheet getSlide() {
return slide;
}

public SlidesTopComponent getSlidesComponent() {
return slidesComponent;
public JComponent getSlidesComponent() {
return slidesTopComponent;
}
}
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Joeffice modules and file extensions supported:
* Database (h2)

Joeffice uses the following libraries:
* The NetBeans Platform (12.3) https://netbeans.org/features/platform/
* The NetBeans Platform (16) https://netbeans.org/features/platform/
* Apache POI (5.0.0) https://poi.apache.org/
* H2 Database (1.4.200) https://www.h2database.com/
* Batik (included in Apache POI) https://xmlgraphics.apache.org/batik/
Expand All @@ -33,17 +33,20 @@ What are the advantages compared to Microsoft Office:
* Window docking of documents in the application
* Can be included in your company Java applications (Apache License)

TODO
### TODO
* Recent files
* Macro system (Edit -> Macro)
* Fix actions
* @ActionState
* Fails on Java 16 (NetBeans framework exceptions thrown)

How to contribute:
### How to contribute:
* There are a few FIXME in the code
* Submit merge request
* For large contributions, sign the contributor license agreement which stays that you and your company donate the code to this project.

For feature requests:
### Sponsors
* [Japplis](https://www.japplis.com) _better tools, better jobs_

### For feature requests:
* Contact [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.File;
import java.io.IOException;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

Expand All @@ -31,9 +30,9 @@
*/
public class JoefficeWorkbookFactory {

public static Workbook create(File file) throws IOException, InvalidFormatException {
public static Workbook create(File file) throws IOException {
String fileName = file.getName().toLowerCase();
if (fileName.endsWith(".csv") || fileName.endsWith(".txt")) {
if (fileName.endsWith(".csv") || fileName.endsWith(".txt") || fileName.endsWith(".tsv")) {
SmartCsvReader csvReader = new SmartCsvReader();
return csvReader.read(file);
} else {
Expand Down
Loading

0 comments on commit 60214ea

Please sign in to comment.