You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(12) |
Sep
(28) |
Oct
(40) |
Nov
(24) |
Dec
(4) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(4) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Stephen C. <cr...@us...> - 2006-01-14 15:07:28
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18901/src/com/jmonkey/office/lexi/support Modified Files: FontChooser.java LayoutUnits.java PageChooser.java ParagraphChooser.java Added Files: AttributeChooser.java Log Message: Implemented different units for layout measures; e.g. inches, points, cms, etc Index: FontChooser.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/FontChooser.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FontChooser.java 19 Dec 2005 14:12:12 -0000 1.11 --- FontChooser.java 14 Jan 2006 15:07:17 -0000 1.12 *************** *** 40,44 **** import javax.swing.JCheckBox; import javax.swing.JComboBox; - import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JList; --- 40,43 ---- *************** *** 59,63 **** * a font family, a style and a font size. */ ! public final class FontChooser extends JDialog implements ActionListener, ListSelectionListener, ItemListener { private Lexi m_app; --- 58,63 ---- * a font family, a style and a font size. */ ! public final class FontChooser extends AttributeChooser ! implements ActionListener, ListSelectionListener, ItemListener { private Lexi m_app; *************** *** 74,78 **** */ public FontChooser(JFrame owner, AttributeSet initial) { ! super(owner, "Font Chooser", true); setSize(700, 500); init(owner, initial); --- 74,78 ---- */ public FontChooser(JFrame owner, AttributeSet initial) { ! super(owner, "Font Chooser"); setSize(700, 500); init(owner, initial); Index: PageChooser.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/PageChooser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PageChooser.java 19 Dec 2005 14:12:12 -0000 1.1 --- PageChooser.java 14 Jan 2006 15:07:17 -0000 1.2 *************** *** 33,37 **** import javax.swing.JButton; - import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; --- 33,36 ---- *************** *** 47,51 **** * This class implements a Dialog for selecting page style attributes. */ ! public final class PageChooser extends JDialog implements ActionListener { private JTextField m_pageHeight, m_pageWidth; --- 46,51 ---- * This class implements a Dialog for selecting page style attributes. */ ! public final class PageChooser extends AttributeChooser ! implements ActionListener { private JTextField m_pageHeight, m_pageWidth; *************** *** 57,61 **** */ public PageChooser(JFrame owner, AttributeSet initial) { ! super(owner, "Page Chooser", true); setSize(700, 500); init(owner, initial); --- 57,61 ---- */ public PageChooser(JFrame owner, AttributeSet initial) { ! super(owner, "Page Chooser"); setSize(700, 500); init(owner, initial); *************** *** 124,152 **** public AttributeSet getAttributes() { MutableAttributeSet res = new SimpleAttributeSet(); ! if (isValidMargin(m_pageHeight)) { ! OfficeStyleConstants.setPageHeight(res, getMargin(m_pageHeight)); } ! if (isValidMargin(m_pageWidth)) { ! OfficeStyleConstants.setPageWidth(res, getMargin(m_pageWidth)); } return res; } - private boolean isValidMargin(JTextField field) { - String text = field.getText(); - if (text != null) { - try { - Integer.parseInt(text); - return true; - } - catch (NumberFormatException ex) { - } - } - return false; - } - - private int getMargin(JTextField field) { - return Integer.parseInt(field.getText()); - } - } --- 124,135 ---- public AttributeSet getAttributes() { MutableAttributeSet res = new SimpleAttributeSet(); ! if (isValidMeasure(m_pageHeight)) { ! OfficeStyleConstants.setPageHeight(res, getMeasure(m_pageHeight)); } ! if (isValidMeasure(m_pageWidth)) { ! OfficeStyleConstants.setPageWidth(res, getMeasure(m_pageWidth)); } return res; } } Index: ParagraphChooser.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/ParagraphChooser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ParagraphChooser.java 19 Dec 2005 14:12:12 -0000 1.2 --- ParagraphChooser.java 14 Jan 2006 15:07:17 -0000 1.3 *************** *** 36,40 **** import javax.swing.JButton; import javax.swing.JCheckBox; - import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; --- 36,39 ---- *************** *** 50,54 **** * This class implements a Dialog for selecting paragraph style attributes. */ ! public final class ParagraphChooser extends JDialog implements ActionListener, ItemListener { private JTextField m_leftMargin, m_rightMargin, m_topMargin, m_bottomMargin; --- 49,53 ---- * This class implements a Dialog for selecting paragraph style attributes. */ ! public final class ParagraphChooser extends AttributeChooser implements ActionListener, ItemListener { private JTextField m_leftMargin, m_rightMargin, m_topMargin, m_bottomMargin; *************** *** 62,66 **** */ public ParagraphChooser(JFrame owner, AttributeSet initial) { ! super(owner, "Paragraph Chooser", true); setSize(700, 500); init(owner, initial); --- 61,65 ---- */ public ParagraphChooser(JFrame owner, AttributeSet initial) { ! super(owner, "Paragraph Chooser"); setSize(700, 500); init(owner, initial); *************** *** 210,244 **** StyleConstants.setAlignment(res, StyleConstants.ALIGN_JUSTIFIED); } ! if (isValidMargin(m_leftMargin)) { ! StyleConstants.setLeftIndent(res, getMargin(m_leftMargin)); } ! if (isValidMargin(m_rightMargin)) { ! StyleConstants.setRightIndent(res, getMargin(m_rightMargin)); } ! if (isValidMargin(m_topMargin)) { ! StyleConstants.setSpaceAbove(res, getMargin(m_topMargin)); } ! if (isValidMargin(m_bottomMargin)) { ! StyleConstants.setSpaceBelow(res, getMargin(m_bottomMargin)); } return res; } - private boolean isValidMargin(JTextField field) { - String text = field.getText(); - if (text != null) { - try { - Integer.parseInt(text); - return true; - } - catch (NumberFormatException ex) { - } - } - return false; - } - - private int getMargin(JTextField field) { - return Integer.parseInt(field.getText()); - } - } --- 209,226 ---- StyleConstants.setAlignment(res, StyleConstants.ALIGN_JUSTIFIED); } ! if (isValidMeasure(m_leftMargin)) { ! StyleConstants.setLeftIndent(res, (float) getMeasure(m_leftMargin)); } ! if (isValidMeasure(m_rightMargin)) { ! StyleConstants.setRightIndent(res, (float) getMeasure(m_rightMargin)); } ! if (isValidMeasure(m_topMargin)) { ! StyleConstants.setSpaceAbove(res, (float) getMeasure(m_topMargin)); } ! if (isValidMeasure(m_bottomMargin)) { ! StyleConstants.setSpaceBelow(res, (float) getMeasure(m_bottomMargin)); } return res; } } --- NEW FILE: AttributeChooser.java --- /** * Copyright (C) 2005 the Lexi Project. * * This file is part of the Lexi document editor. * * Lexi is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Lexi is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Classpath; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole combination. */ package com.jmonkey.office.lexi.support; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JTextField; import com.jmonkey.office.lexi.Lexi; /** * @author Stephen Crawley */ public abstract class AttributeChooser extends JDialog { public AttributeChooser(JFrame owner, String title) { super(owner, title, true); } /** * Test if a JTextField contains a valid measure. * @param field the control to examine. * @return <code>true</code> if the text field's contents is a valid measure. */ protected boolean isValidMeasure(JTextField field) { return isValidMeasure(field.getText()); } /** * Test if a String is a valid measure. * @param text the String to examine. * @return <code>true</code> if the supplied String is a valid measure. */ protected boolean isValidMeasure(String text) { if (text != null) { String[] parts = splitMeasure(text); try { Integer.parseInt(parts[0]); return parts[1].length() == 0 || LayoutUnits.nameToUnit(parts[1]) >= 0; } catch (NumberFormatException ex) { } } return false; } protected double getMeasure(JTextField field) { return getMeasure(field.getText()); } protected double getMeasure(String text) throws NumberFormatException, IllegalArgumentException { String[] parts = splitMeasure(text); int unit = (parts[1].length() == 0) ? getDefaultUnit() : LayoutUnits.nameToUnit(parts[1]); if (unit < 0) { throw new IllegalArgumentException("unrecognized or missing unit"); } double quantity = Double.parseDouble(parts[0]); return LayoutUnits.unitsToPoints(quantity, unit); } private int getDefaultUnit() { String name = Lexi.getRegistry().getString("MAIN", "default.unit"); return LayoutUnits.nameToUnit(name); } private String[] splitMeasure(String value) { value = value.trim(); int len = value.length(); int i; for (i = 0; i < len && Character.isDigit(value.charAt(i)); i++) { /* skipping ... */ } if (i < len) { return new String[]{value.substring(0, i), value.substring(i).trim()}; } else { return new String[]{value, ""}; } } } Index: LayoutUnits.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/LayoutUnits.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LayoutUnits.java 19 Dec 2005 14:12:12 -0000 1.1 --- LayoutUnits.java 14 Jan 2006 15:07:17 -0000 1.2 *************** *** 43,48 **** private static final String[][] UNIT_NAMES = new String[][]{ ! {"point", "points"}, {"pica", "picas"}, {"inch", "inches"}, ! {"millimetre", "millimetres"}, {"centimetre", "centimetres"} }; --- 43,51 ---- private static final String[][] UNIT_NAMES = new String[][]{ ! {"point", "points", "pt"}, ! {"pica", "picas"}, ! {"inch", "inches", "in"}, ! {"millimetre", "millimetres", "mm"}, ! {"centimetre", "centimetres", "cm"} }; *************** *** 147,154 **** --- 150,185 ---- } + /** + * Convert a unit ordinal (see above) to the preferred singular name. + * @param unit a unit ordinal + * @return the corresponding unit name. + */ public static String unitName(int unit) { return unitName(unit, false); } + /** + * Convert a unit name to the corresponding ordinal. This method ignores case, + * and matches any of the names for the unit, including the abbreviation. + * @param name the unit name + * @return the corresponding unit oredinal, or <code>-1</code>. + */ + public static int nameToUnit(String name) { + for (int i = 0; i < UNIT_NAMES.length; i++) { + for (int j = 0; j < UNIT_NAMES[i].length; j++) { + if (name.equalsIgnoreCase(UNIT_NAMES[i][j])) { + return i; + } + } + } + return -1; + } + + /** + * Convert a unit ordinal (see above) to the preferred singular or plural name. + * @param unit a unit ordinal + * @param plural if <code>true</code>, the plural form of the name is required. + * @return the corresponding unit name. + */ public static String unitName(int unit, boolean plural) { try { |
From: Stephen C. <cr...@us...> - 2006-01-14 15:07:28
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18901/src/com/jmonkey/office/lexi Modified Files: FormatToolBar.java Lexi.java Log Message: Implemented different units for layout measures; e.g. inches, points, cms, etc Index: FormatToolBar.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/FormatToolBar.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FormatToolBar.java 19 Dec 2005 14:12:11 -0000 1.4 --- FormatToolBar.java 14 Jan 2006 15:07:17 -0000 1.5 *************** *** 87,91 **** if (value != null) { setMinimumSize(new Dimension(0, 16)); ! String prop = m_lexi.getRegistry().getString("COLOURS", (String) value); Color colour = Color.decode(prop); setText((String) value); --- 87,91 ---- if (value != null) { setMinimumSize(new Dimension(0, 16)); ! String prop = Lexi.getRegistry().getString("COLOURS", (String) value); Color colour = Color.decode(prop); setText((String) value); Index: Lexi.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/Lexi.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Lexi.java 19 Dec 2005 14:12:11 -0000 1.31 --- Lexi.java 14 Jan 2006 15:07:17 -0000 1.32 *************** *** 871,874 **** --- 871,875 ---- {"font.sizes.granularity", "2", "int"}, {"paper.size", "A4", "String"}, + {"default.unit", "inches", "String"}, {"mdi.outline.drag", "true", "boolean"}, {"main.look&feel", |
From: Stephen C. <cr...@us...> - 2006-01-14 15:07:28
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18901/src/com/jmonkey/office/lexi/support/editors Modified Files: OfficeDocumentEditor.java OfficeDocumentEditorKit.java OfficeStyleConstants.java Log Message: Implemented different units for layout measures; e.g. inches, points, cms, etc Index: OfficeDocumentEditorKit.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/OfficeDocumentEditorKit.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OfficeDocumentEditorKit.java 19 Dec 2005 14:12:12 -0000 1.4 --- OfficeDocumentEditorKit.java 14 Jan 2006 15:07:17 -0000 1.5 *************** *** 70,74 **** private int m_height, m_width; - private int m_topMargin, m_bottomMargin, m_leftMargin, m_rightMargin; public PageView(Element elem) { --- 70,73 ---- *************** *** 81,85 **** public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f) { - System.err.println("changeUpdate"); AttributeSet attr = getAttributes(); if (attr != null) { --- 80,83 ---- *************** *** 91,110 **** private void updateFromAttributes(AttributeSet attr) { ! float height = OfficeStyleConstants.getPageHeight(attr); ! float width = OfficeStyleConstants.getPageWidth(attr); ! float leftMargin = OfficeStyleConstants.getPageLeftMargin(attr); ! float rightMargin = OfficeStyleConstants.getPageRightMargin(attr); ! float topMargin = OfficeStyleConstants.getPageTopMargin(attr); ! float bottomMargin = OfficeStyleConstants.getPageBottomMargin(attr); m_height = (int) height; m_width = (int) width; ! m_topMargin = (int) topMargin; ! m_bottomMargin = (int) bottomMargin; ! m_leftMargin = (int) leftMargin; ! m_rightMargin = (int) rightMargin; preferenceChanged(this, true, true); m_editor.setPageSize(new Dimension(m_width, m_height)); - System.err.println("Set page size to " + m_width + ", " + m_height); } --- 89,105 ---- private void updateFromAttributes(AttributeSet attr) { ! double height = OfficeStyleConstants.getPageHeight(attr); ! double width = OfficeStyleConstants.getPageWidth(attr); ! double leftMargin = OfficeStyleConstants.getPageLeftMargin(attr); ! double rightMargin = OfficeStyleConstants.getPageRightMargin(attr); ! double topMargin = OfficeStyleConstants.getPageTopMargin(attr); ! double bottomMargin = OfficeStyleConstants.getPageBottomMargin(attr); m_height = (int) height; m_width = (int) width; ! setInsets((short) topMargin, (short) leftMargin, ! (short) bottomMargin, (short) rightMargin); preferenceChanged(this, true, true); m_editor.setPageSize(new Dimension(m_width, m_height)); } *************** *** 136,170 **** Rectangle a = (Rectangle) allocation; m_border.paintBorder(null, g, a.x, a.y, a.width, a.height); ! Rectangle childAllocation = new Rectangle( ! a.x + m_leftMargin, ! a.y + m_topMargin, ! a.width - m_leftMargin - m_rightMargin, ! a.height - m_topMargin - m_bottomMargin); m_margins.paintBorder(null, g, childAllocation.x, childAllocation.y, childAllocation.width, childAllocation.height); layout(childAllocation.width, childAllocation.height); ! super.paint(g, childAllocation); } public Shape modelToView(int pos, Shape a, Bias b) throws BadLocationException { ! Rectangle bounds = a.getBounds(); ! Rectangle childBounds = ! new Rectangle(bounds.x + m_leftMargin, ! bounds.y + m_topMargin, ! bounds.width - m_leftMargin - m_rightMargin, ! bounds.height - m_topMargin - m_bottomMargin); ! return super.modelToView(pos, childBounds, b); } public int viewToModel(float x, float y, Shape a, Bias[] bias) { ! Rectangle bounds = a.getBounds(); ! Rectangle childBounds = ! new Rectangle(bounds.x + m_leftMargin, ! bounds.y + m_topMargin, ! bounds.width - m_leftMargin - m_rightMargin, ! bounds.height - m_topMargin - m_bottomMargin); ! if (childBounds.contains((int) x, (int) y)) { ! return super.viewToModel(x, y, childBounds, bias); } else { --- 131,149 ---- Rectangle a = (Rectangle) allocation; m_border.paintBorder(null, g, a.x, a.y, a.width, a.height); ! Rectangle childAllocation = getInsideAllocation(allocation); m_margins.paintBorder(null, g, childAllocation.x, childAllocation.y, childAllocation.width, childAllocation.height); layout(childAllocation.width, childAllocation.height); ! super.paint(g, allocation); } public Shape modelToView(int pos, Shape a, Bias b) throws BadLocationException { ! return super.modelToView(pos, a, b); } public int viewToModel(float x, float y, Shape a, Bias[] bias) { ! if (a.contains((int) x, (int) y)) { ! return super.viewToModel(x, y, a, bias); } else { *************** *** 249,260 **** throws IOException, BadLocationException { ! throw new UnsupportedOperationException("read(Reader, Document, int)"); } ! public void install(JEditorPane editor) ! { super.install(editor); m_viewFactory = new OfficeViewFactory(); - System.err.println("install: this is " + this + ", editor is " + editor); m_editor = (EditorTextPane) editor; } --- 228,240 ---- throws IOException, BadLocationException { ! int ch; ! while ((ch = reader.read()) != -1) { ! doc.insertString(pos++, Character.toString((char) ch), null); ! } } ! public void install(JEditorPane editor) { super.install(editor); m_viewFactory = new OfficeViewFactory(); m_editor = (EditorTextPane) editor; } *************** *** 262,266 **** public void deinstall(JEditorPane editor) { super.deinstall(editor); - System.err.println("deinstall: this is " + this); m_editor = null; } --- 242,245 ---- Index: OfficeDocumentEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/OfficeDocumentEditor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OfficeDocumentEditor.java 19 Dec 2005 14:12:12 -0000 1.4 --- OfficeDocumentEditor.java 14 Jan 2006 15:07:17 -0000 1.5 *************** *** 102,106 **** public void setPageAttributes(AttributeSet attr, boolean replace) { - System.err.println("setPageAttributes " + attr); OfficeDocument doc = (OfficeDocument) m_editor.getStyledDocument(); doc.setPageAttributes(attr, replace); --- 102,105 ---- Index: OfficeStyleConstants.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/OfficeStyleConstants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OfficeStyleConstants.java 19 Dec 2005 14:12:12 -0000 1.1 --- OfficeStyleConstants.java 14 Jan 2006 15:07:17 -0000 1.2 *************** *** 84,158 **** } ! public static float getPageHeight(AttributeSet attrs) { ! Float v = (Float) attrs.getAttribute(PageHeight); if (v != null) { ! return v.floatValue(); } ! return (float) getPaperSize().getHeight(); } ! public static float getPageWidth(AttributeSet attrs) { ! Float v = (Float) attrs.getAttribute(PageWidth); if (v != null) { ! return v.floatValue(); } ! return (float) getPaperSize().getWidth(); } ! public static float getPageTopMargin(AttributeSet attrs) { ! Float v = (Float) attrs.getAttribute(PageTopMargin); if (v != null) { ! return v.floatValue(); } return 24; } ! public static float getPageBottomMargin(AttributeSet attrs) { ! Float v = (Float) attrs.getAttribute(PageBottomMargin); if (v != null) { ! return v.floatValue(); } return 24; } ! public static float getPageLeftMargin(AttributeSet attrs) { ! Float v = (Float) attrs.getAttribute(PageLeftMargin); if (v != null) { ! return v.floatValue(); } return 24; } ! public static float getPageRightMargin(AttributeSet attrs) { ! Float v = (Float) attrs.getAttribute(PageRightMargin); if (v != null) { ! return v.floatValue(); } return 24; } ! public static void setPageWidth(MutableAttributeSet attrs, float value) { ! attrs.addAttribute(PageWidth, new Float(value)); } ! public static void setPageHeight(MutableAttributeSet attrs, float value) { ! attrs.addAttribute(PageHeight, new Float(value)); } ! public static void setPageTopMargin(MutableAttributeSet attrs, float value) { ! attrs.addAttribute(PageTopMargin, new Float(value)); } ! public static void setPageBottomMargin(MutableAttributeSet attrs, float value) { ! attrs.addAttribute(PageBottomMargin, new Float(value)); } ! public static void setPageLeftMargin(MutableAttributeSet attrs, float value) { ! attrs.addAttribute(PageLeftMargin, new Float(value)); } ! public static void setPageRightMargin(MutableAttributeSet attrs, float value) { ! attrs.addAttribute(PageRightMargin, new Float(value)); } --- 84,158 ---- } ! public static double getPageHeight(AttributeSet attrs) { ! Double v = (Double) attrs.getAttribute(PageHeight); if (v != null) { ! return v.doubleValue(); } ! return getPaperSize().getHeight(); } ! public static double getPageWidth(AttributeSet attrs) { ! Double v = (Double) attrs.getAttribute(PageWidth); if (v != null) { ! return v.doubleValue(); } ! return getPaperSize().getWidth(); } ! public static double getPageTopMargin(AttributeSet attrs) { ! Double v = (Double) attrs.getAttribute(PageTopMargin); if (v != null) { ! return v.doubleValue(); } return 24; } ! public static double getPageBottomMargin(AttributeSet attrs) { ! Double v = (Double) attrs.getAttribute(PageBottomMargin); if (v != null) { ! return v.doubleValue(); } return 24; } ! public static double getPageLeftMargin(AttributeSet attrs) { ! Double v = (Double) attrs.getAttribute(PageLeftMargin); if (v != null) { ! return v.doubleValue(); } return 24; } ! public static double getPageRightMargin(AttributeSet attrs) { ! Double v = (Double) attrs.getAttribute(PageRightMargin); if (v != null) { ! return v.doubleValue(); } return 24; } ! public static void setPageWidth(MutableAttributeSet attrs, double value) { ! attrs.addAttribute(PageWidth, new Double(value)); } ! public static void setPageHeight(MutableAttributeSet attrs, double value) { ! attrs.addAttribute(PageHeight, new Double(value)); } ! public static void setPageTopMargin(MutableAttributeSet attrs, double value) { ! attrs.addAttribute(PageTopMargin, new Double(value)); } ! public static void setPageBottomMargin(MutableAttributeSet attrs, double value) { ! attrs.addAttribute(PageBottomMargin, new Double(value)); } ! public static void setPageLeftMargin(MutableAttributeSet attrs, double value) { ! attrs.addAttribute(PageLeftMargin, new Double(value)); } ! public static void setPageRightMargin(MutableAttributeSet attrs, double value) { ! attrs.addAttribute(PageRightMargin, new Double(value)); } *************** *** 164,168 **** String paper = Lexi.getRegistry().getString("MAIN", "paper.size"); LayoutUnits.PaperSize res = LayoutUnits.paperSize(paper); - System.err.println("paper size " + paper + " -> " + res); return res; } --- 164,167 ---- |
From: Stephen C. <cr...@us...> - 2006-01-14 15:07:28
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18901/src/com/jmonkey/office/lexi/odf Modified Files: OfficeDocument.java Log Message: Implemented different units for layout measures; e.g. inches, points, cms, etc Index: OfficeDocument.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf/OfficeDocument.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OfficeDocument.java 19 Dec 2005 14:12:12 -0000 1.3 --- OfficeDocument.java 14 Jan 2006 15:07:17 -0000 1.4 *************** *** 25,28 **** --- 25,29 ---- package com.jmonkey.office.lexi.odf; + import java.util.Enumeration; import java.util.List; *************** *** 190,194 **** } ! public void setPageAttributes(AttributeSet attr, boolean replace) { writeLock(); try { --- 191,195 ---- } ! public void setPageAttributes(AttributeSet attrs, boolean replace) { writeLock(); try { *************** *** 201,205 **** pageAttrs.removeAttributes(pageAttrs); } ! pageAttrs.addAttributes(attr); changes.end(); fireChangedUpdate(changes); --- 202,206 ---- pageAttrs.removeAttributes(pageAttrs); } ! pageAttrs.addAttributes(attrs); changes.end(); fireChangedUpdate(changes); *************** *** 211,213 **** --- 212,226 ---- } + private String showAttrs(AttributeSet attrs) { + StringBuffer sb = new StringBuffer(); + for (Enumeration en = attrs.getAttributeNames(); en.hasMoreElements(); /**/) { + Object key = en.nextElement(); + Object value = attrs.getAttribute(key); + sb.append((sb.length() == 0) ? "{" : ", "); + sb.append(key).append("=").append(value); + } + sb.append("}"); + return sb.toString(); + } + } |
From: Stephen C. <cr...@us...> - 2005-12-19 14:12:27
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16538/src/com/jmonkey/office/lexi/odf Modified Files: OfficeDocument.java Log Message: First steps in supporting page margins. Index: OfficeDocument.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf/OfficeDocument.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OfficeDocument.java 15 Nov 2005 12:59:46 -0000 1.2 --- OfficeDocument.java 19 Dec 2005 14:12:12 -0000 1.3 *************** *** 136,144 **** writeLock(); MutableAttributeSet a = new SimpleAttributeSet(); - a.addAttribute(StyleConstants.NameAttribute, ODFTag.OFFICE_BODY); - BlockElement officeBody = new BlockElement(null, a.copyAttributes()); - a.removeAttributes(a); a.addAttribute(StyleConstants.NameAttribute, ODFTag.OFFICE_TEXT); ! BlockElement officeText = new BlockElement(officeBody, a.copyAttributes()); a.removeAttributes(a); a.addAttribute(StyleConstants.NameAttribute, ODFTag.PARAGRAPH); --- 136,141 ---- writeLock(); MutableAttributeSet a = new SimpleAttributeSet(); a.addAttribute(StyleConstants.NameAttribute, ODFTag.OFFICE_TEXT); ! BlockElement officeText = new BlockElement(null, a.copyAttributes()); a.removeAttributes(a); a.addAttribute(StyleConstants.NameAttribute, ODFTag.PARAGRAPH); *************** *** 152,159 **** buff[0] = paragraph; officeText.replace(0, 0, buff); - buff[0] = officeText; - officeBody.replace(0, 0, buff); writeUnlock(); ! return officeBody; } --- 149,154 ---- buff[0] = paragraph; officeText.replace(0, 0, buff); writeUnlock(); ! return officeText; } *************** *** 174,178 **** super.insertUpdate(change, attrs); } - protected void fireChangedUpdate(DocumentEvent e) { --- 169,172 ---- *************** *** 188,196 **** } ! ! protected void fireUndoableEditUpdate(UndoableEditEvent e) { super.fireUndoableEditUpdate(e); } } --- 182,213 ---- } ! protected void fireUndoableEditUpdate(UndoableEditEvent e) { super.fireUndoableEditUpdate(e); } + public AttributeSet getPageAttributes() { + return getDefaultRootElement().getAttributes(); + } + + public void setPageAttributes(AttributeSet attr, boolean replace) { + writeLock(); + try { + DefaultDocumentEvent changes = + new DefaultDocumentEvent(0, getLength(), DocumentEvent.EventType.CHANGE); + + Element root = getDefaultRootElement(); + MutableAttributeSet pageAttrs = (MutableAttributeSet) root.getAttributes(); + if (replace) { + pageAttrs.removeAttributes(pageAttrs); + } + pageAttrs.addAttributes(attr); + changes.end(); + fireChangedUpdate(changes); + fireUndoableEditUpdate(new UndoableEditEvent(this, changes)); + } + finally { + writeUnlock(); + } + } } |
From: Stephen C. <cr...@us...> - 2005-12-19 14:12:25
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16538/src/com/jmonkey/office/lexi/support/editors Modified Files: HTMLEditor.java OfficeDocumentEditor.java OfficeDocumentEditorKit.java RTFEditor.java StyledEditor.java TEXTEditor.java Added Files: EditorTextPane.java OfficeStyleConstants.java PageAttribute.java Log Message: First steps in supporting page margins. Index: OfficeDocumentEditorKit.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/OfficeDocumentEditorKit.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OfficeDocumentEditorKit.java 20 Nov 2005 12:47:47 -0000 1.3 --- OfficeDocumentEditorKit.java 19 Dec 2005 14:12:12 -0000 1.4 *************** *** 25,28 **** --- 25,32 ---- package com.jmonkey.office.lexi.support.editors; + import java.awt.Dimension; + import java.awt.Graphics; + import java.awt.Rectangle; + import java.awt.Shape; import java.io.IOException; import java.io.InputStream; *************** *** 31,38 **** import javax.swing.Action; import javax.swing.JEditorPane; import javax.swing.text.BoxView; import javax.swing.text.BadLocationException; import javax.swing.text.Document; - import javax.swing.text.EditorKit; import javax.swing.text.Element; import javax.swing.text.LabelView; --- 35,45 ---- import javax.swing.Action; import javax.swing.JEditorPane; + import javax.swing.border.Border; + import javax.swing.border.LineBorder; + import javax.swing.event.DocumentEvent; + import javax.swing.text.AttributeSet; import javax.swing.text.BoxView; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.Element; import javax.swing.text.LabelView; *************** *** 43,46 **** --- 50,54 ---- import javax.swing.text.View; import javax.swing.text.ViewFactory; + import javax.swing.text.Position.Bias; import com.jmonkey.office.lexi.odf.ODFReader; *************** *** 48,52 **** import com.jmonkey.office.lexi.odf.OfficeDocument; - /** * @author cr...@ds... --- 56,59 ---- *************** *** 54,64 **** public class OfficeDocumentEditorKit extends StyledEditorKit { ! private JEditorPane m_editor; ! /** Shared factory for creating ODF Views. */ ! private static final ViewFactory defaultFactory = new OfficeDocumentFactory(); ! public static class OfficeDocumentFactory implements ViewFactory { /** * Creates a view from an element. --- 61,183 ---- public class OfficeDocumentEditorKit extends StyledEditorKit { + private EditorTextPane m_editor; ! private ViewFactory m_viewFactory; ! public class PageView extends BoxView { ! private Border m_border = LineBorder.createBlackLineBorder(); ! private Border m_margins = LineBorder.createGrayLineBorder(); ! ! private int m_height, m_width; ! private int m_topMargin, m_bottomMargin, m_leftMargin, m_rightMargin; ! ! public PageView(Element elem) { ! super(elem, View.Y_AXIS); ! AttributeSet attr = getAttributes(); ! if (attr != null) { ! updateFromAttributes(attr); ! } ! } ! ! public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f) { ! System.err.println("changeUpdate"); ! AttributeSet attr = getAttributes(); ! if (attr != null) { ! updateFromAttributes(attr); ! } ! super.changedUpdate(changes, a, f); ! m_editor.revalidate(); ! } ! ! private void updateFromAttributes(AttributeSet attr) { ! float height = OfficeStyleConstants.getPageHeight(attr); ! float width = OfficeStyleConstants.getPageWidth(attr); ! float leftMargin = OfficeStyleConstants.getPageLeftMargin(attr); ! float rightMargin = OfficeStyleConstants.getPageRightMargin(attr); ! float topMargin = OfficeStyleConstants.getPageTopMargin(attr); ! float bottomMargin = OfficeStyleConstants.getPageBottomMargin(attr); ! ! m_height = (int) height; ! m_width = (int) width; ! m_topMargin = (int) topMargin; ! m_bottomMargin = (int) bottomMargin; ! m_leftMargin = (int) leftMargin; ! m_rightMargin = (int) rightMargin; ! preferenceChanged(this, true, true); ! m_editor.setPageSize(new Dimension(m_width, m_height)); ! System.err.println("Set page size to " + m_width + ", " + m_height); ! } ! ! public int getResizeWeight(int axis) { ! return 1; ! } ! ! public float getMinimumSpan(int axis) { ! return (axis == X_AXIS) ? m_width : m_height; ! } ! ! public float getMaximumSpan(int axis) { ! return (axis == X_AXIS) ? m_width : m_height; ! } ! ! public float getPreferredSpan(int axis) { ! return (axis == X_AXIS) ? m_width : m_height; ! } ! ! public int getHeight() { ! return m_height; ! } ! ! public int getWidth() { ! return m_width; ! } ! ! public void paint(Graphics g, Shape allocation) { ! Rectangle a = (Rectangle) allocation; ! m_border.paintBorder(null, g, a.x, a.y, a.width, a.height); ! Rectangle childAllocation = new Rectangle( ! a.x + m_leftMargin, ! a.y + m_topMargin, ! a.width - m_leftMargin - m_rightMargin, ! a.height - m_topMargin - m_bottomMargin); ! m_margins.paintBorder(null, g, childAllocation.x, childAllocation.y, ! childAllocation.width, childAllocation.height); ! layout(childAllocation.width, childAllocation.height); ! super.paint(g, childAllocation); ! } ! ! public Shape modelToView(int pos, Shape a, Bias b) ! throws BadLocationException { ! Rectangle bounds = a.getBounds(); ! Rectangle childBounds = ! new Rectangle(bounds.x + m_leftMargin, ! bounds.y + m_topMargin, ! bounds.width - m_leftMargin - m_rightMargin, ! bounds.height - m_topMargin - m_bottomMargin); ! return super.modelToView(pos, childBounds, b); ! } ! ! public int viewToModel(float x, float y, Shape a, Bias[] bias) { ! Rectangle bounds = a.getBounds(); ! Rectangle childBounds = ! new Rectangle(bounds.x + m_leftMargin, ! bounds.y + m_topMargin, ! bounds.width - m_leftMargin - m_rightMargin, ! bounds.height - m_topMargin - m_bottomMargin); ! if (childBounds.contains((int) x, (int) y)) { ! return super.viewToModel(x, y, childBounds, bias); ! } ! else { ! return 0; ! } ! } ! ! public void setSize(float width, float height) { ! // The page size is determined by the relevant properties. ! // If the parent view tries to override this, don't oblige. ! } ! } ! public class OfficeViewFactory implements ViewFactory { /** * Creates a view from an element. *************** *** 69,80 **** public View create(Element elem) { Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute); - // System.err.println("view: o = " + o); if (o instanceof ODFTag) { int kind = ((ODFTag) o).getKind(); switch (kind) { - case ODFTag.OFFICE_BODY_KIND: case ODFTag.OFFICE_TEXT_KIND: ! // body ! return new BoxView(elem, View.Y_AXIS); case ODFTag.PARAGRAPH_KIND: case ODFTag.HEADING_KIND: --- 188,196 ---- public View create(Element elem) { Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute); if (o instanceof ODFTag) { int kind = ((ODFTag) o).getKind(); switch (kind) { case ODFTag.OFFICE_TEXT_KIND: ! return new PageView(elem); case ODFTag.PARAGRAPH_KIND: case ODFTag.HEADING_KIND: *************** *** 109,113 **** */ public ViewFactory getViewFactory() { ! return defaultFactory; } --- 225,232 ---- */ public ViewFactory getViewFactory() { ! if (m_viewFactory == null) { ! throw new IllegalStateException("no editor is installed"); ! } ! return m_viewFactory; } *************** *** 136,158 **** { super.install(editor); ! // FIXME - remove any local listeners ! m_editor = editor; ! } ! ! private Action getAction(String name) { ! EditorKit kit = m_editor.getEditorKit(); ! Action actions[] = kit.getActions(); ! for (int i = 0; i < actions.length; i++) { ! if (actions[i].getValue(Action.NAME).equals(name)) { ! System.err.println("got action: " + actions[i]); ! return actions[i]; ! } ! } ! return null; } public void deinstall(JEditorPane editor) { - // FIXME - remove any local listeners super.deinstall(editor); m_editor = null; } --- 255,266 ---- { super.install(editor); ! m_viewFactory = new OfficeViewFactory(); ! System.err.println("install: this is " + this + ", editor is " + editor); ! m_editor = (EditorTextPane) editor; } public void deinstall(JEditorPane editor) { super.deinstall(editor); + System.err.println("deinstall: this is " + this); m_editor = null; } --- NEW FILE: EditorTextPane.java --- /** * Copyright (C) 2005 the Lexi Project. * * This file is part of the Lexi document editor. * * Lexi is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Lexi is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Classpath; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole combination. */ package com.jmonkey.office.lexi.support.editors; import java.awt.Dimension; import javax.swing.JTextPane; /** * @author stephen * */ public class EditorTextPane extends JTextPane { private Dimension m_pageSize; private final boolean m_trackWidth; public EditorTextPane(boolean trackWidth) { super(); m_trackWidth = trackWidth; } public boolean getScrollableTracksViewportWidth() { return m_trackWidth; } public void setPageSize(Dimension pageSize) { m_pageSize = pageSize; } public Dimension getPreferredSize() { if (m_pageSize == null) { return super.getPreferredSize(); } else { return m_pageSize; } } } Index: HTMLEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/HTMLEditor.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** HTMLEditor.java 31 Oct 2005 14:20:44 -0000 1.11 --- HTMLEditor.java 19 Dec 2005 14:12:12 -0000 1.12 *************** *** 26,29 **** --- 26,31 ---- package com.jmonkey.office.lexi.support.editors; + import javax.swing.text.AttributeSet; + import com.jmonkey.office.lexi.support.EditorActionManager; *************** *** 47,51 **** */ public HTMLEditor(EditorActionManager eam) { ! super(eam, CONTENT_TYPE); } --- 49,53 ---- */ public HTMLEditor(EditorActionManager eam) { ! super(eam, CONTENT_TYPE, true); } *************** *** 53,55 **** --- 55,65 ---- return FILE_EXTENSIONS; } + + public AttributeSet getPageAttributes() { + return null; + } + + public void setPageAttributes(AttributeSet attr, boolean replace) { + // Do nothing + } } --- NEW FILE: PageAttribute.java --- /** * Copyright (C) 2005 the Lexi Project. * * This file is part of the Lexi document editor. * * Lexi is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Lexi is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Classpath; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole combination. */ package com.jmonkey.office.lexi.support.editors; /** * This interface is the type signature that is expected to be present * on any attribute key that contributes to the page style. * * @author cr...@ds... */ public interface PageAttribute { } Index: OfficeDocumentEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/OfficeDocumentEditor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OfficeDocumentEditor.java 20 Nov 2005 12:47:47 -0000 1.3 --- OfficeDocumentEditor.java 19 Dec 2005 14:12:12 -0000 1.4 *************** *** 33,40 **** --- 33,42 ---- import javax.swing.JEditorPane; + import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.StyledEditorKit; import com.jmonkey.office.lexi.odf.ODFDocumentFormatException; + import com.jmonkey.office.lexi.odf.OfficeDocument; import com.jmonkey.office.lexi.support.Code; import com.jmonkey.office.lexi.support.EditorActionManager; *************** *** 64,68 **** */ public OfficeDocumentEditor(EditorActionManager eam) { ! super(eam, CONTENT_TYPE); } --- 66,70 ---- */ public OfficeDocumentEditor(EditorActionManager eam) { ! super(eam, CONTENT_TYPE, false); } *************** *** 71,74 **** --- 73,81 ---- } + public AttributeSet getPageAttributes() { + OfficeDocument doc = (OfficeDocument) m_editor.getStyledDocument(); + return doc.getPageAttributes(); + } + public void read(File file) throws IOException { ZipFile zipFile = new ZipFile(file, ZipFile.OPEN_READ); *************** *** 81,85 **** in = zipFile.getInputStream(entry); StyledEditorKit kit = (StyledEditorKit) m_editor.getEditorKit(); - System.err.println("kit is " + kit); kit.read(in, m_editor.getStyledDocument(), 0); setChanged(false); --- 88,91 ---- *************** *** 95,97 **** --- 101,110 ---- } + public void setPageAttributes(AttributeSet attr, boolean replace) { + System.err.println("setPageAttributes " + attr); + OfficeDocument doc = (OfficeDocument) m_editor.getStyledDocument(); + doc.setPageAttributes(attr, replace); + // FIXME - why? + m_editor.requestFocus(); + } } Index: TEXTEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/TEXTEditor.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TEXTEditor.java 23 Nov 2005 15:15:41 -0000 1.13 --- TEXTEditor.java 19 Dec 2005 14:12:12 -0000 1.14 *************** *** 251,254 **** --- 251,258 ---- } + public AttributeSet getPageAttributes() { + return null; + } + public AttributeSet getParagraphAttributes() { return m_editor.getParagraphAttributes(); *************** *** 459,462 **** --- 463,470 ---- } + public void setPageAttributes(AttributeSet attr, boolean replace) { + // Do nothing ... + } + public final void setParagraphAttributes(AttributeSet attr, boolean replace) { // Do nothing ... Index: RTFEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/RTFEditor.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RTFEditor.java 15 Nov 2005 12:59:46 -0000 1.12 --- RTFEditor.java 19 Dec 2005 14:12:12 -0000 1.13 *************** *** 27,30 **** --- 27,31 ---- import javax.swing.Action; + import javax.swing.text.AttributeSet; import javax.swing.text.Keymap; *************** *** 49,53 **** */ public RTFEditor(EditorActionManager eam) { ! super(eam, CONTENT_TYPE); Keymap km = m_editor.getKeymap(); Action actions[] = km.getBoundActions(); --- 50,54 ---- */ public RTFEditor(EditorActionManager eam) { ! super(eam, CONTENT_TYPE, true); Keymap km = m_editor.getKeymap(); Action actions[] = km.getBoundActions(); *************** *** 61,63 **** --- 62,71 ---- } + public AttributeSet getPageAttributes() { + return null; + } + + public void setPageAttributes(AttributeSet attr, boolean replace) { + // Do nothing + } } Index: StyledEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/StyledEditor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** StyledEditor.java 23 Nov 2005 15:15:41 -0000 1.9 --- StyledEditor.java 19 Dec 2005 14:12:12 -0000 1.10 *************** *** 93,97 **** UndoableEditListener, HyperlinkListener, FocusListener, VetoableChangeListener, ChangeListener { ! private StyledEditor m_parent = null; protected EventListener(StyledEditor parent) { --- 93,97 ---- UndoableEditListener, HyperlinkListener, FocusListener, VetoableChangeListener, ChangeListener { ! private StyledEditor m_parent; protected EventListener(StyledEditor parent) { *************** *** 155,161 **** * Default Document Constructor. */ ! public StyledEditor(EditorActionManager eam, String contentType) { super(eam); ! m_editor = new JTextPane(); init(contentType); } --- 155,162 ---- * Default Document Constructor. */ ! public StyledEditor(EditorActionManager eam, String contentType, ! boolean trackWidth) { super(eam); ! m_editor = new EditorTextPane(trackWidth); init(contentType); } --- NEW FILE: OfficeStyleConstants.java --- /** * Copyright (C) 2005 the Lexi Project. * * This file is part of the Lexi document editor. * * Lexi is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Lexi is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Classpath; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole combination. */ package com.jmonkey.office.lexi.support.editors; import javax.swing.text.AttributeSet; import javax.swing.text.MutableAttributeSet; import com.jmonkey.office.lexi.Lexi; import com.jmonkey.office.lexi.support.LayoutUnits; /** * Collection of attribute keys and methods to get/set the AttributeSet * properties that are specific to OfficeDocuments. * * @author cr...@ds... */ public class OfficeStyleConstants { private String m_representation; public static final Object PageHeight = PageStyleConstants.PageHeight; public static final Object PageWidth = PageStyleConstants.PageWidth; public static final Object PageLeftMargin = PageStyleConstants.PageLeftMargin; public static final Object PageRightMargin = PageStyleConstants.PageRightMargin; public static final Object PageTopMargin = PageStyleConstants.PageTopMargin; public static final Object PageBottomMargin = PageStyleConstants.PageBottomMargin; public static class PageStyleConstants extends OfficeStyleConstants implements PageAttribute { PageStyleConstants(String representation) { super(representation); } private static final Object PageHeight = new PageStyleConstants("pageheight"); private static final Object PageWidth = new PageStyleConstants("pagewidth"); private static final Object PageLeftMargin = new PageStyleConstants("pageleftmargin"); private static final Object PageRightMargin = new PageStyleConstants("pagerightmargin"); private static final Object PageTopMargin = new PageStyleConstants("pagetopmargin"); private static final Object PageBottomMargin = new PageStyleConstants("pagebottommargin"); } OfficeStyleConstants(String representation) { m_representation = representation; } public static float getPageHeight(AttributeSet attrs) { Float v = (Float) attrs.getAttribute(PageHeight); if (v != null) { return v.floatValue(); } return (float) getPaperSize().getHeight(); } public static float getPageWidth(AttributeSet attrs) { Float v = (Float) attrs.getAttribute(PageWidth); if (v != null) { return v.floatValue(); } return (float) getPaperSize().getWidth(); } public static float getPageTopMargin(AttributeSet attrs) { Float v = (Float) attrs.getAttribute(PageTopMargin); if (v != null) { return v.floatValue(); } return 24; } public static float getPageBottomMargin(AttributeSet attrs) { Float v = (Float) attrs.getAttribute(PageBottomMargin); if (v != null) { return v.floatValue(); } return 24; } public static float getPageLeftMargin(AttributeSet attrs) { Float v = (Float) attrs.getAttribute(PageLeftMargin); if (v != null) { return v.floatValue(); } return 24; } public static float getPageRightMargin(AttributeSet attrs) { Float v = (Float) attrs.getAttribute(PageRightMargin); if (v != null) { return v.floatValue(); } return 24; } public static void setPageWidth(MutableAttributeSet attrs, float value) { attrs.addAttribute(PageWidth, new Float(value)); } public static void setPageHeight(MutableAttributeSet attrs, float value) { attrs.addAttribute(PageHeight, new Float(value)); } public static void setPageTopMargin(MutableAttributeSet attrs, float value) { attrs.addAttribute(PageTopMargin, new Float(value)); } public static void setPageBottomMargin(MutableAttributeSet attrs, float value) { attrs.addAttribute(PageBottomMargin, new Float(value)); } public static void setPageLeftMargin(MutableAttributeSet attrs, float value) { attrs.addAttribute(PageLeftMargin, new Float(value)); } public static void setPageRightMargin(MutableAttributeSet attrs, float value) { attrs.addAttribute(PageRightMargin, new Float(value)); } public String toString() { return m_representation; } private static LayoutUnits.PaperSize getPaperSize() { String paper = Lexi.getRegistry().getString("MAIN", "paper.size"); LayoutUnits.PaperSize res = LayoutUnits.paperSize(paper); System.err.println("paper size " + paper + " -> " + res); return res; } } |
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16538/src/com/jmonkey/office/lexi/support Modified Files: Editor.java EditorActionManager.java FontChooser.java ParagraphChooser.java Added Files: LayoutUnits.java PageChooser.java Log Message: First steps in supporting page margins. Index: ParagraphChooser.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/ParagraphChooser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ParagraphChooser.java 23 Nov 2005 15:15:41 -0000 1.1 --- ParagraphChooser.java 19 Dec 2005 14:12:12 -0000 1.2 *************** *** 40,44 **** import javax.swing.JLabel; import javax.swing.JPanel; - import javax.swing.JSeparator; import javax.swing.JTextField; import javax.swing.text.AttributeSet; --- 40,43 ---- *************** *** 47,51 **** import javax.swing.text.StyleConstants; - import com.jmonkey.office.lexi.Lexi; /** --- 46,49 ---- *************** *** 54,58 **** public final class ParagraphChooser extends JDialog implements ActionListener, ItemListener { - private Lexi m_app; private JTextField m_leftMargin, m_rightMargin, m_topMargin, m_bottomMargin; private JCheckBox m_leftAlign, m_rightAlign, m_centre, m_justify; --- 52,55 ---- *************** *** 89,102 **** } - public AttributeSet getParagraphProperties() { - return null; - } - /** ! * Sets us up with the panels needed to create this font chooser */ private void init(Component c, AttributeSet initial) { - m_app = (Lexi) c; - JPanel main = new JPanel(); JPanel buttonPanel = new JPanel(); --- 86,93 ---- } /** ! * Sets us up with the panels for this style chooser */ private void init(Component c, AttributeSet initial) { JPanel main = new JPanel(); JPanel buttonPanel = new JPanel(); Index: FontChooser.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/FontChooser.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FontChooser.java 23 Nov 2005 15:15:41 -0000 1.10 --- FontChooser.java 19 Dec 2005 14:12:12 -0000 1.11 *************** *** 129,133 **** optionPanel.setLayout(new GridLayout(3, 2)); ! Registry reg = m_app.getRegistry(); Enumeration fontEnum = reg.getKeys("FONTS"); Vector fonts = new Vector(); --- 129,133 ---- optionPanel.setLayout(new GridLayout(3, 2)); ! Registry reg = Lexi.getRegistry(); Enumeration fontEnum = reg.getKeys("FONTS"); Vector fonts = new Vector(); --- NEW FILE: PageChooser.java --- /** * Copyright (C) 2005 the Lexi Project. * * This file is part of the Lexi document editor. * * Lexi is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Lexi is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Classpath; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole combination. */ package com.jmonkey.office.lexi.support; import java.awt.BorderLayout; import java.awt.Component; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.text.AttributeSet; import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; import com.jmonkey.office.lexi.support.editors.OfficeStyleConstants; /** * This class implements a Dialog for selecting page style attributes. */ public final class PageChooser extends JDialog implements ActionListener { private JTextField m_pageHeight, m_pageWidth; private boolean m_outcome; /** * @param owner the owner frame for the chooser. * @param initial the initial paragraph attributes */ public PageChooser(JFrame owner, AttributeSet initial) { super(owner, "Page Chooser", true); setSize(700, 500); init(owner, initial); } /** * Handle the actions associated with the 'ok' and the 'cancel' buttons */ public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("can-button")) { m_outcome = false; dispose(); } else if (command.equals("ok-button")) { m_outcome = true; dispose(); } } public boolean getOutcome() { return m_outcome; } /** * Sets us up with the panels for this style chooser */ private void init(Component c, AttributeSet initial) { JPanel main = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel propertyPanel = new JPanel(); main.setLayout(new BorderLayout()); buttonPanel.setLayout(new FlowLayout()); propertyPanel.setLayout(new GridLayout(2, 2)); m_pageHeight = new JTextField(); m_pageWidth = new JTextField(); propertyPanel.add(m_pageHeight); propertyPanel.add(new JLabel("Page height")); propertyPanel.add(m_pageWidth); propertyPanel.add(new JLabel("Page width")); // Button Pane JButton okButton = new JButton("OK"); okButton.setActionCommand("ok-button"); okButton.addActionListener(this); JButton cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("can-button"); cancelButton.addActionListener(this); buttonPanel.add(okButton); buttonPanel.add(cancelButton); // Add Stuff to Main main.add(propertyPanel, BorderLayout.CENTER); main.add(buttonPanel, BorderLayout.SOUTH); getContentPane().add(main); pack(); // set the position of the dialog. setLocationRelativeTo(c); } public AttributeSet getAttributes() { MutableAttributeSet res = new SimpleAttributeSet(); if (isValidMargin(m_pageHeight)) { OfficeStyleConstants.setPageHeight(res, getMargin(m_pageHeight)); } if (isValidMargin(m_pageWidth)) { OfficeStyleConstants.setPageWidth(res, getMargin(m_pageWidth)); } return res; } private boolean isValidMargin(JTextField field) { String text = field.getText(); if (text != null) { try { Integer.parseInt(text); return true; } catch (NumberFormatException ex) { } } return false; } private int getMargin(JTextField field) { return Integer.parseInt(field.getText()); } } Index: EditorActionManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/EditorActionManager.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** EditorActionManager.java 23 Nov 2005 15:15:41 -0000 1.20 --- EditorActionManager.java 19 Dec 2005 14:12:12 -0000 1.21 *************** *** 90,95 **** public static final String COLOUR_CHOOSER_ACTION_PREFIX = "Colour Chooser..."; public static final String FONT_CHOOSER_ACTION_PREFIX = "Font Chooser..."; public static final String PARA_CHOOSER_ACTION_PREFIX = ! "Paragraph Chooser..."; public static final String SEARCH_ACTION_PREFIX = "Find..."; public static final String REPLACE_ACTION_PREFIX = "Find & Replace..."; --- 90,96 ---- public static final String COLOUR_CHOOSER_ACTION_PREFIX = "Colour Chooser..."; public static final String FONT_CHOOSER_ACTION_PREFIX = "Font Chooser..."; + public static final String PAGE_CHOOSER_ACTION_PREFIX = "Page Chooser..."; public static final String PARA_CHOOSER_ACTION_PREFIX = ! "Paragraph Chooser..."; public static final String SEARCH_ACTION_PREFIX = "Find..."; public static final String REPLACE_ACTION_PREFIX = "Find & Replace..."; *************** *** 144,147 **** --- 145,150 ---- m_actions.put(FILE_OPENAS_ACTION_PREFIX, new OpenAsAction(FILE_OPENAS_ACTION_PREFIX, app, agent)); + m_actions.put(PAGE_CHOOSER_ACTION_PREFIX, + new PageChooserAction(PAGE_CHOOSER_ACTION_PREFIX, app)); m_actions.put(PARA_CHOOSER_ACTION_PREFIX, new ParagraphChooserAction(PARA_CHOOSER_ACTION_PREFIX, app)); *************** *** 350,353 **** --- 353,372 ---- // ============================================================== + public final class PageChooserAction extends EditorAction { + public PageChooserAction(String nm, JFrame component) { + super(nm, component); + } + + public void doEditorAction(Editor editor, ActionEvent e) { + AttributeSet initial = editor.getPageAttributes(); + PageChooser pc = new PageChooser(m_parent, initial); + pc.setVisible(true); + + if (pc.getOutcome()) { + editor.setPageAttributes(pc.getAttributes(), false); + } + } + } + public final class ParagraphChooserAction extends EditorAction { public ParagraphChooserAction(String nm, JFrame component) { *************** *** 1034,1042 **** } public final Action getParagraphChooserAction() { return (Action) m_actions.get(PARA_CHOOSER_ACTION_PREFIX); } ! public final Action getPasteAction() { return (Action) m_actions.get(PASTE_ACTION_PREFIX); } --- 1053,1065 ---- } + public final Action getPageChooserAction() { + return (Action) m_actions.get(PAGE_CHOOSER_ACTION_PREFIX); + } + public final Action getParagraphChooserAction() { return (Action) m_actions.get(PARA_CHOOSER_ACTION_PREFIX); } ! public final Action getPasteAction() { return (Action) m_actions.get(PASTE_ACTION_PREFIX); } --- NEW FILE: LayoutUnits.java --- /** * Copyright (C) 2005 the Lexi Project. * * This file is part of the Lexi document editor. * * Lexi is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Lexi is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Classpath; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole combination. */ package com.jmonkey.office.lexi.support; import java.util.HashMap; import java.awt.geom.Dimension2D; /** * This class defines various page layout units and standard page * dimensions, along with conversion utility methods. * * @author cr...@ds... */ public class LayoutUnits { public static final int UNIT_POINTS = 0; public static final int UNIT_PICAS = 1; public static final int UNIT_INCHES = 2; public static final int UNIT_MILLIMETRES = 3; public static final int UNIT_CENTIMETRES = 4; private static final String[][] UNIT_NAMES = new String[][]{ {"point", "points"}, {"pica", "picas"}, {"inch", "inches"}, {"millimetre", "millimetres"}, {"centimetre", "centimetres"} }; private static final double[] UNIT_SCALE_FACTORS; static { // The following are based on the definition of 1 point == 1/72 inch. // This is the conventional definition for computer typesetting, though // I've also read that there are 72.27 printer's points to the inch. UNIT_SCALE_FACTORS = new double[]{ 1.0, // points 12.0, // picas 72.0, // inches 2.8452756, // millimetres 28.452756, // centimetres }; }; /** * Convert a linear measure to points. * * @param value the linear measure * @param unit the measurement unit code. * @return the value converted to points. */ public static double unitsToPoints(double value, int unit) { try { return value * UNIT_SCALE_FACTORS[unit]; } catch (ArrayIndexOutOfBoundsException ex) { throw new IllegalArgumentException("unknown unit (" + unit + ")"); } } private static final HashMap m_paperSizes = new HashMap(); static { // Standard metric paper sizes. m_paperSizes.put("a0", new PaperSize("A0", unitsToPoints(841, UNIT_MILLIMETRES), unitsToPoints(1189, UNIT_MILLIMETRES))); m_paperSizes.put("a1", new PaperSize("A1", unitsToPoints(594, UNIT_MILLIMETRES), unitsToPoints(841, UNIT_MILLIMETRES))); m_paperSizes.put("a2", new PaperSize("A2", unitsToPoints(420, UNIT_MILLIMETRES), unitsToPoints(594, UNIT_MILLIMETRES))); m_paperSizes.put("a3", new PaperSize("A3", unitsToPoints(297, UNIT_MILLIMETRES), unitsToPoints(420, UNIT_MILLIMETRES))); m_paperSizes.put("a4", new PaperSize("A4", unitsToPoints(210, UNIT_MILLIMETRES), unitsToPoints(297, UNIT_MILLIMETRES))); m_paperSizes.put("a5", new PaperSize("A5", unitsToPoints(148, UNIT_MILLIMETRES), unitsToPoints(210, UNIT_MILLIMETRES))); // FIXME - add more } public static class PaperSize extends Dimension2D { private final double m_pageHeight; private final double m_pageWidth; private final String m_name; private PaperSize(String name, double width, double height) { m_pageHeight = height; m_pageWidth = width; m_name = name; } public double getHeight() { return m_pageHeight; } public double getWidth() { return m_pageWidth; } public void setSize(double width, double height) { throw new UnsupportedOperationException("Cannot change std paper sizes"); } public String getName() { return m_name; } public String toString() { return this.getClass().toString() + "[" + m_name + ", height " + m_pageHeight + " points, width " + m_pageWidth + " points]"; } } // Not used private LayoutUnits() { super(); } public static String unitName(int unit) { return unitName(unit, false); } public static String unitName(int unit, boolean plural) { try { return UNIT_NAMES[unit][plural ? 1 : 0]; } catch (ArrayIndexOutOfBoundsException ex) { throw new IllegalArgumentException("unknown unit (" + unit + ")"); } } public static double pointsToUnits(double value, int unit) { try { return value / UNIT_SCALE_FACTORS[unit]; } catch (ArrayIndexOutOfBoundsException ex) { throw new IllegalArgumentException("unknown unit (" + unit + ")"); } } public static PaperSize paperSize(String name) { return (PaperSize) m_paperSizes.get(name.toLowerCase()); } } Index: Editor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/Editor.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Editor.java 23 Nov 2005 15:15:41 -0000 1.18 --- Editor.java 19 Dec 2005 14:12:12 -0000 1.19 *************** *** 198,201 **** --- 198,203 ---- public abstract MutableAttributeSet getInputAttributes(); + public abstract AttributeSet getPageAttributes(); + public abstract AttributeSet getParagraphAttributes(); *************** *** 332,340 **** boolean replace); /** * Applies the given attributes to paragraphs. If * there is a selection, the attributes are applied * to the paragraphs that intersect the selection. ! * if there is no selection, the attributes are applied * to the paragraph at the current caret position. * --- 334,344 ---- boolean replace); + public abstract void setPageAttributes(AttributeSet attr, boolean replace); + /** * Applies the given attributes to paragraphs. If * there is a selection, the attributes are applied * to the paragraphs that intersect the selection. ! * If there is no selection, the attributes are applied * to the paragraph at the current caret position. * |
From: Stephen C. <cr...@us...> - 2005-12-19 14:12:21
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16538/src/com/jmonkey/office/lexi Modified Files: DocumentManager.java FormatToolBar.java Lexi.java OptionsPanel.java Log Message: First steps in supporting page margins. Index: DocumentManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/DocumentManager.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** DocumentManager.java 20 Nov 2005 12:47:46 -0000 1.14 --- DocumentManager.java 19 Dec 2005 14:12:11 -0000 1.15 *************** *** 70,74 **** super(); m_parent = parent; ! m_registry = parent.getRegistry(); m_newDocumentTitle = m_registry.getString("MAIN", "new.document.title"); m_currentDir = m_registry.getString("USER", "default.documents.directory"); --- 70,74 ---- super(); m_parent = parent; ! m_registry = Lexi.getRegistry(); m_newDocumentTitle = m_registry.getString("MAIN", "new.document.title"); m_currentDir = m_registry.getString("USER", "default.documents.directory"); Index: OptionsPanel.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/OptionsPanel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OptionsPanel.java 15 Oct 2005 06:09:56 -0000 1.1 --- OptionsPanel.java 19 Dec 2005 14:12:11 -0000 1.2 *************** *** 98,102 **** String path = pathChoice.getAbsolutePath(); m_field.setText(path); ! Registry reg = getMain().getRegistry(); reg.setProperty("USER", m_key, path); } --- 98,102 ---- String path = pathChoice.getAbsolutePath(); m_field.setText(path); ! Registry reg = Lexi.getRegistry(); reg.setProperty("USER", m_key, path); } *************** *** 111,115 **** super(); m_app = app; ! m_reg = app.getRegistry(); m_gridBag = new GridBagLayout(); --- 111,115 ---- super(); m_app = app; ! m_reg = Lexi.getRegistry(); m_gridBag = new GridBagLayout(); Index: FormatToolBar.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/FormatToolBar.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FormatToolBar.java 20 Nov 2005 12:47:46 -0000 1.3 --- FormatToolBar.java 19 Dec 2005 14:12:11 -0000 1.4 *************** *** 222,226 **** m_colours.setRenderer(new ColourActionCellRenderer()); ! Registry reg = lexi.getRegistry(); Enumeration colourEnum = reg.getKeys("COLOURS"); EditorActionManager eam = lexi.getEditorActionManager(); --- 222,226 ---- m_colours.setRenderer(new ColourActionCellRenderer()); ! Registry reg = Lexi.getRegistry(); Enumeration colourEnum = reg.getKeys("COLOURS"); EditorActionManager eam = lexi.getEditorActionManager(); *************** *** 343,347 **** */ private final int[] getFontSizes() { ! Registry reg = m_lexi.getRegistry(); int begin = reg.getInteger("MAIN", "font.sizes.minimum"); int end = reg.getInteger("MAIN", "font.sizes.maximum"); --- 343,347 ---- */ private final int[] getFontSizes() { ! Registry reg = Lexi.getRegistry(); int begin = reg.getInteger("MAIN", "font.sizes.minimum"); int end = reg.getInteger("MAIN", "font.sizes.maximum"); Index: Lexi.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/Lexi.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Lexi.java 23 Nov 2005 15:15:41 -0000 1.30 --- Lexi.java 19 Dec 2005 14:12:11 -0000 1.31 *************** *** 93,96 **** --- 93,99 ---- private static int s_documentCount = 0; + private static Registry s_mainRegistry = null; + + private EditorActionManager m_editorActionManager = null; *************** *** 134,140 **** // ==================================================== - // Use the Registry to store the previously opened files - private Registry m_mainRegistry = null; - // The apps menu bar. private JMenuBar m_menuBar = null; --- 137,140 ---- *************** *** 598,601 **** --- 598,602 ---- formatMenu.add(eam.getFontChooserAction()); formatMenu.add(eam.getParagraphChooserAction()); + formatMenu.add(eam.getPageChooserAction()); // WINDOW MENU ========================= *************** *** 829,834 **** * Gets the current Registry for Main */ ! public final Registry getRegistry() { ! if (m_mainRegistry == null) { try { Registry reg = Registry.loadForClass(Lexi.class, LEXI_REGISTRY_VERSION); --- 830,835 ---- * Gets the current Registry for Main */ ! public static Registry getRegistry() { ! if (s_mainRegistry == null) { try { Registry reg = Registry.loadForClass(Lexi.class, LEXI_REGISTRY_VERSION); *************** *** 869,872 **** --- 870,874 ---- {"font.sizes.maximum", "150", "int"}, {"font.sizes.granularity", "2", "int"}, + {"paper.size", "A4", "String"}, {"mdi.outline.drag", "true", "boolean"}, {"main.look&feel", *************** *** 876,880 **** }); } ! // Default Options group if (reg.sizeOf("OPTION") == 0) { --- 878,882 ---- }); } ! // Default Options group if (reg.sizeOf("OPTION") == 0) { *************** *** 937,941 **** } ! m_mainRegistry = reg; } catch (java.io.IOException ioe0) { --- 939,943 ---- } ! s_mainRegistry = reg; } catch (java.io.IOException ioe0) { *************** *** 943,947 **** } } ! return m_mainRegistry; } --- 945,949 ---- } } ! return s_mainRegistry; } |
From: Stephen C. <cr...@us...> - 2005-11-23 15:15:52
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31500/src/com/jmonkey/office/lexi Modified Files: Lexi.java Log Message: Added a rudimentary paragraph format dialog that currently sets alignment and margins (in points). Index: Lexi.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/Lexi.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Lexi.java 18 Nov 2005 14:59:56 -0000 1.29 --- Lexi.java 23 Nov 2005 15:15:41 -0000 1.30 *************** *** 597,600 **** --- 597,601 ---- formatMenu.add(eam.getColourChooserAction()); formatMenu.add(eam.getFontChooserAction()); + formatMenu.add(eam.getParagraphChooserAction()); // WINDOW MENU ========================= |
From: Stephen C. <cr...@us...> - 2005-11-23 15:15:50
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31500/src/com/jmonkey/office/lexi/support Modified Files: Editor.java EditorActionManager.java FontChooser.java Added Files: ParagraphChooser.java Log Message: Added a rudimentary paragraph format dialog that currently sets alignment and margins (in points). Index: FontChooser.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/FontChooser.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FontChooser.java 15 Oct 2005 06:09:57 -0000 1.9 --- FontChooser.java 23 Nov 2005 15:15:41 -0000 1.10 *************** *** 70,83 **** /** ! * Display the FontChooser and return the slected font. ! * ! * @param owner the owner frame for the chooser. ! * @param title the title text for the chooser ! * @param modal if <code>true</code> the chooser is a modal dialog. ! * @return java.awt.Font The selected font, or null. */ ! public FontChooser(JFrame owner, String title, boolean modal, ! AttributeSet initial) { ! super(owner, title, modal); setSize(700, 500); init(owner, initial); --- 70,78 ---- /** ! * @param owner this Dialog's parent window. ! * @param initial the initial font attributes */ ! public FontChooser(JFrame owner, AttributeSet initial) { ! super(owner, "Font Chooser", true); setSize(700, 500); init(owner, initial); Index: EditorActionManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/EditorActionManager.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** EditorActionManager.java 21 Nov 2005 13:46:05 -0000 1.19 --- EditorActionManager.java 23 Nov 2005 15:15:41 -0000 1.20 *************** *** 90,93 **** --- 90,95 ---- public static final String COLOUR_CHOOSER_ACTION_PREFIX = "Colour Chooser..."; public static final String FONT_CHOOSER_ACTION_PREFIX = "Font Chooser..."; + public static final String PARA_CHOOSER_ACTION_PREFIX = + "Paragraph Chooser..."; public static final String SEARCH_ACTION_PREFIX = "Find..."; public static final String REPLACE_ACTION_PREFIX = "Find & Replace..."; *************** *** 100,111 **** public static final String FILE_SAVECOPY_ACTION_PREFIX = "Save Copy..."; - // public static final String FONT_FAMILY_ACTION_PREFIX = - // "format-font-family@"; - // public static final String FONT_SIZE_ACTION_PREFIX = "format-font-size@"; - // public static final String FONT_COLOUR_ACTION_PREFIX = - // "format-font-colour@"; - - // StyleConstants.ALIGN_RIGHT; - // ========= PRIVATE MEMBERS =================== --- 102,105 ---- *************** *** 150,153 **** --- 144,149 ---- m_actions.put(FILE_OPENAS_ACTION_PREFIX, new OpenAsAction(FILE_OPENAS_ACTION_PREFIX, app, agent)); + m_actions.put(PARA_CHOOSER_ACTION_PREFIX, + new ParagraphChooserAction(PARA_CHOOSER_ACTION_PREFIX, app)); m_actions.put(PASTE_ACTION_PREFIX, new PasteAction()); m_actions.put(REDO_ACTION_PREFIX, new RedoAction()); *************** *** 260,267 **** protected void doEditorAction(Editor editor, ActionEvent e) { AttributeSet initial = editor.getCharacterAttributes(); ! FontChooser fc = new FontChooser(m_parent, "Font Chooser", true, initial); fc.setVisible(true); if (fc.getOutcome()) { String family = fc.getFontFamily(); int size = fc.getFontSize(); --- 256,264 ---- protected void doEditorAction(Editor editor, ActionEvent e) { AttributeSet initial = editor.getCharacterAttributes(); ! FontChooser fc = new FontChooser(m_parent, initial); fc.setVisible(true); if (fc.getOutcome()) { + // FIXME - ugly String family = fc.getFontFamily(); int size = fc.getFontSize(); *************** *** 353,356 **** --- 350,369 ---- // ============================================================== + public final class ParagraphChooserAction extends EditorAction { + public ParagraphChooserAction(String nm, JFrame component) { + super(nm, component); + } + + public void doEditorAction(Editor editor, ActionEvent e) { + AttributeSet initial = editor.getParagraphAttributes(); + ParagraphChooser pc = new ParagraphChooser(m_parent, initial); + pc.setVisible(true); + + if (pc.getOutcome()) { + editor.setParagraphAttributes(pc.getAttributes(), false); + } + } + } + public final class ColourChooserAction extends EditorAction { public ColourChooserAction(String nm, JFrame component) { *************** *** 1021,1025 **** } ! public final Action getPasteAction() { return (Action) m_actions.get(PASTE_ACTION_PREFIX); } --- 1034,1042 ---- } ! public final Action getParagraphChooserAction() { ! return (Action) m_actions.get(PARA_CHOOSER_ACTION_PREFIX); ! } ! ! public final Action getPasteAction() { return (Action) m_actions.get(PASTE_ACTION_PREFIX); } Index: Editor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/Editor.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Editor.java 21 Nov 2005 13:46:05 -0000 1.17 --- Editor.java 23 Nov 2005 15:15:41 -0000 1.18 *************** *** 26,30 **** package com.jmonkey.office.lexi.support; - //import com.jmonkey.core.util.Code; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; --- 26,29 ---- *************** *** 198,201 **** --- 197,202 ---- public abstract MutableAttributeSet getInputAttributes(); + + public abstract AttributeSet getParagraphAttributes(); /** --- NEW FILE: ParagraphChooser.java --- /** * Copyright (C) 2005 the Lexi Project. * * This file is part of the Lexi document editor. * * Lexi is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Lexi is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Classpath; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole combination. */ package com.jmonkey.office.lexi.support; import java.awt.BorderLayout; import java.awt.Component; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JTextField; import javax.swing.text.AttributeSet; import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; import com.jmonkey.office.lexi.Lexi; /** * This class implements a Dialog for selecting paragraph style attributes. */ public final class ParagraphChooser extends JDialog implements ActionListener, ItemListener { private Lexi m_app; private JTextField m_leftMargin, m_rightMargin, m_topMargin, m_bottomMargin; private JCheckBox m_leftAlign, m_rightAlign, m_centre, m_justify; private boolean m_outcome; /** * @param owner the owner frame for the chooser. * @param initial the initial paragraph attributes */ public ParagraphChooser(JFrame owner, AttributeSet initial) { super(owner, "Paragraph Chooser", true); setSize(700, 500); init(owner, initial); } /** * Handle the actions associated with the 'ok' and the 'cancel' buttons */ public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("can-button")) { m_outcome = false; dispose(); } else if (command.equals("ok-button")) { m_outcome = true; dispose(); } } public boolean getOutcome() { return m_outcome; } public AttributeSet getParagraphProperties() { return null; } /** * Sets us up with the panels needed to create this font chooser */ private void init(Component c, AttributeSet initial) { m_app = (Lexi) c; JPanel main = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel propertyPanel = new JPanel(); main.setLayout(new BorderLayout()); buttonPanel.setLayout(new FlowLayout()); propertyPanel.setLayout(new GridLayout(4, 3)); m_leftAlign = new JCheckBox("Left align", false); m_leftAlign.addItemListener(this); m_rightAlign = new JCheckBox("Right align", false); m_rightAlign.addItemListener(this); m_centre = new JCheckBox("Center", false); m_centre.addItemListener(this); m_justify = new JCheckBox("Justify", false); m_justify.addItemListener(this); m_leftMargin = new JTextField(); m_rightMargin = new JTextField(); m_topMargin = new JTextField(); m_bottomMargin = new JTextField(); // Select the initial alignment switch (StyleConstants.getAlignment(initial)) { case StyleConstants.ALIGN_LEFT: m_leftAlign.setSelected(true); break; case StyleConstants.ALIGN_RIGHT: m_rightAlign.setSelected(true); break; case StyleConstants.ALIGN_CENTER: m_centre.setSelected(true); break; case StyleConstants.ALIGN_JUSTIFIED: m_justify.setSelected(true); break; } propertyPanel.add(m_leftMargin); propertyPanel.add(new JLabel("Left margin")); propertyPanel.add(m_leftAlign); propertyPanel.add(m_rightMargin); propertyPanel.add(new JLabel("Right margin")); propertyPanel.add(m_rightAlign); propertyPanel.add(m_topMargin); propertyPanel.add(new JLabel("Top margin")); propertyPanel.add(m_centre); propertyPanel.add(m_bottomMargin); propertyPanel.add(new JLabel("Bottom margin")); propertyPanel.add(m_justify); // Button Pane JButton okButton = new JButton("OK"); okButton.setActionCommand("ok-button"); okButton.addActionListener(this); JButton cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("can-button"); cancelButton.addActionListener(this); buttonPanel.add(okButton); buttonPanel.add(cancelButton); // Add Stuff to Main main.add(propertyPanel, BorderLayout.CENTER); main.add(buttonPanel, BorderLayout.SOUTH); getContentPane().add(main); pack(); // set the position of the dialog. setLocationRelativeTo(c); } /** * Handles the checkbox changes */ public void itemStateChanged(ItemEvent iEv) { if (iEv.getStateChange() == ItemEvent.SELECTED) { // Toggle off all other checkboxes. if (iEv.getItem() == m_leftAlign) { m_rightAlign.setSelected(false); m_centre.setSelected(false); m_justify.setSelected(false); } else if (iEv.getItem() == m_rightAlign) { m_leftAlign.setSelected(false); m_centre.setSelected(false); m_justify.setSelected(false); } else if (iEv.getItem() == m_centre) { m_leftAlign.setSelected(false); m_rightAlign.setSelected(false); m_justify.setSelected(false); } else if (iEv.getItem() == m_justify) { m_leftAlign.setSelected(false); m_centre.setSelected(false); m_rightAlign.setSelected(false); } } else if (iEv.getStateChange() == ItemEvent.DESELECTED && !m_leftAlign.isSelected() && !m_rightAlign.isSelected() && !m_centre.isSelected() && !m_justify.isSelected()) { // If all checkboxes are clear, tick the 'left align' checkbox. m_leftAlign.setSelected(true); } } public AttributeSet getAttributes() { MutableAttributeSet res = new SimpleAttributeSet(); if (m_leftAlign.isSelected()) { StyleConstants.setAlignment(res, StyleConstants.ALIGN_LEFT); } else if (m_rightAlign.isSelected()) { StyleConstants.setAlignment(res, StyleConstants.ALIGN_RIGHT); } else if (m_centre.isSelected()) { StyleConstants.setAlignment(res, StyleConstants.ALIGN_CENTER); } else if (m_justify.isSelected()) { StyleConstants.setAlignment(res, StyleConstants.ALIGN_JUSTIFIED); } if (isValidMargin(m_leftMargin)) { StyleConstants.setLeftIndent(res, getMargin(m_leftMargin)); } if (isValidMargin(m_rightMargin)) { StyleConstants.setRightIndent(res, getMargin(m_rightMargin)); } if (isValidMargin(m_topMargin)) { StyleConstants.setSpaceAbove(res, getMargin(m_topMargin)); } if (isValidMargin(m_bottomMargin)) { StyleConstants.setSpaceBelow(res, getMargin(m_bottomMargin)); } return res; } private boolean isValidMargin(JTextField field) { String text = field.getText(); if (text != null) { try { Integer.parseInt(text); return true; } catch (NumberFormatException ex) { } } return false; } private int getMargin(JTextField field) { return Integer.parseInt(field.getText()); } } |
From: Stephen C. <cr...@us...> - 2005-11-23 15:15:50
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31500/src/com/jmonkey/office/lexi/support/editors Modified Files: StyledEditor.java TEXTEditor.java Log Message: Added a rudimentary paragraph format dialog that currently sets alignment and margins (in points). Index: StyledEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/StyledEditor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** StyledEditor.java 21 Nov 2005 13:43:46 -0000 1.8 --- StyledEditor.java 23 Nov 2005 15:15:41 -0000 1.9 *************** *** 229,232 **** --- 229,236 ---- return m_editor.getInputAttributes(); } + + public AttributeSet getParagraphAttributes() { + return m_editor.getParagraphAttributes(); + } public JEditorPane getTextComponent() { Index: TEXTEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/TEXTEditor.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TEXTEditor.java 20 Nov 2005 12:47:47 -0000 1.12 --- TEXTEditor.java 23 Nov 2005 15:15:41 -0000 1.13 *************** *** 250,253 **** --- 250,257 ---- return m_editor.getInputAttributes(); } + + public AttributeSet getParagraphAttributes() { + return m_editor.getParagraphAttributes(); + } public JEditorPane getTextComponent() { |
From: Stephen C. <cr...@us...> - 2005-11-21 13:46:59
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25242/src/com/jmonkey/office/lexi/support Modified Files: Editor.java EditorActionManager.java Log Message: Tidy imports Index: Editor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/Editor.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Editor.java 20 Nov 2005 12:47:47 -0000 1.16 --- Editor.java 21 Nov 2005 13:46:05 -0000 1.17 *************** *** 39,47 **** import javax.swing.JPopupMenu; import javax.swing.text.AttributeSet; - import javax.swing.text.Document; import javax.swing.text.Element; import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; - import javax.swing.text.StyledDocument; import javax.swing.undo.UndoManager; --- 39,45 ---- Index: EditorActionManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/EditorActionManager.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** EditorActionManager.java 20 Nov 2005 12:47:47 -0000 1.18 --- EditorActionManager.java 21 Nov 2005 13:46:05 -0000 1.19 *************** *** 46,50 **** import javax.swing.text.AbstractDocument; import javax.swing.text.AttributeSet; - import javax.swing.text.Document; import javax.swing.text.Element; import javax.swing.text.JTextComponent; --- 46,49 ---- |
From: Stephen C. <cr...@us...> - 2005-11-21 13:43:57
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24448/src/com/jmonkey/office/lexi/support/editors Modified Files: StyledEditor.java Log Message: Fixed race condition which caused occasional NPEs when launching the font chooser. Index: StyledEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/StyledEditor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** StyledEditor.java 20 Nov 2005 12:47:47 -0000 1.7 --- StyledEditor.java 21 Nov 2005 13:43:46 -0000 1.8 *************** *** 200,224 **** } else { ! return EditorActionManager.getActiveEditor().getInputAttributes(); } } - /** - * Applies the given attributes to paragraphs. If - * there is a selection, the attributes are applied - * to the paragraphs that intersect the selection. - * if there is no selection, the attributes are applied - * to the paragraph at the current caret position. - * - * @param attr the attributes - * @param replace if true, replace the existing attributes first - */ - public final void setParagraphAttributes(AttributeSet attr, boolean replace) { - int p0 = m_editor.getSelectionStart(); - int p1 = m_editor.getSelectionEnd(); - StyledDocument doc = (StyledDocument) m_editor.getDocument(); - doc.setParagraphAttributes(p0, p1 - p0, attr, replace); - // FIXME -- why??? - m_editor.requestFocus(); - } /** --- 200,206 ---- } else { ! return getInputAttributes(); } } /** *************** *** 479,490 **** } - public final void setCharacterAttributes(AttributeSet attr, boolean replace) { ! JEditorPane pane = getTextComponent(); ! int p0 = pane.getSelectionStart(); ! int p1 = pane.getSelectionEnd(); if (p0 != p1) { ! StyledDocument doc = (StyledDocument) pane.getDocument(); doc.setCharacterAttributes(p0, p1 - p0, attr, replace); } --- 461,470 ---- } public final void setCharacterAttributes(AttributeSet attr, boolean replace) { ! int p0 = m_editor.getSelectionStart(); ! int p1 = m_editor.getSelectionEnd(); if (p0 != p1) { ! StyledDocument doc = (StyledDocument) m_editor.getDocument(); doc.setCharacterAttributes(p0, p1 - p0, attr, replace); } *************** *** 496,500 **** inputAttributes.addAttributes(attr); } ! pane.requestFocus(); } --- 476,481 ---- inputAttributes.addAttributes(attr); } ! // FIXME - why? ! m_editor.requestFocus(); } *************** *** 507,510 **** --- 488,510 ---- } + /** + * Applies the given attributes to paragraphs. If + * there is a selection, the attributes are applied + * to the paragraphs that intersect the selection. + * If there is no selection, the attributes are applied + * to the paragraph at the current caret position. + * + * @param attr the attributes + * @param replace if true, replace the existing attributes first + */ + public final void setParagraphAttributes(AttributeSet attr, boolean replace) { + int p0 = m_editor.getSelectionStart(); + int p1 = m_editor.getSelectionEnd(); + StyledDocument doc = (StyledDocument) m_editor.getDocument(); + doc.setParagraphAttributes(p0, p1 - p0, attr, replace); + // FIXME -- why??? + m_editor.requestFocus(); + } + public final void setSelectionColor(Color colour) { m_editor.setSelectionColor(colour); |
From: Stephen C. <cr...@us...> - 2005-11-20 12:48:01
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12747/src/com/jmonkey/office/lexi/support Modified Files: Editor.java EditorActionManager.java Log Message: Code reorganization and pruning of lame imports Index: Editor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/Editor.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Editor.java 18 Nov 2005 14:59:56 -0000 1.15 --- Editor.java 20 Nov 2005 12:47:47 -0000 1.16 *************** *** 185,188 **** --- 185,190 ---- return new TEXTEditor(eam); } + + public abstract AttributeSet getCharacterAttributes(); public final File getFile() { *************** *** 328,352 **** * if true, then replace the existing attributes first */ ! public final void setCharacterAttributes(AttributeSet attr, boolean replace) ! { ! JEditorPane pane = getTextComponent(); ! int p0 = pane.getSelectionStart(); ! int p1 = pane.getSelectionEnd(); ! if (p0 != p1) { ! Document doc = pane.getDocument(); ! if (doc instanceof StyledDocument) { ! ((StyledDocument) doc).setCharacterAttributes(p0, p1 - p0, attr, ! replace); ! } ! } ! else { ! MutableAttributeSet inputAttributes = getInputAttributes(); ! if (replace) { ! inputAttributes.removeAttributes(inputAttributes); ! } ! inputAttributes.addAttributes(attr); ! } ! pane.requestFocus(); ! } public final void setFile(File file) { --- 330,349 ---- * if true, then replace the existing attributes first */ ! public abstract void setCharacterAttributes(AttributeSet attr, ! boolean replace); ! ! /** ! * Applies the given attributes to paragraphs. If ! * there is a selection, the attributes are applied ! * to the paragraphs that intersect the selection. ! * if there is no selection, the attributes are applied ! * to the paragraph at the current caret position. ! * ! * @param editor the editor ! * @param attr the attributes ! * @param replace if true, replace the existing attributes first ! */ ! public abstract void setParagraphAttributes(AttributeSet attr, ! boolean replace); public final void setFile(File file) { Index: EditorActionManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/EditorActionManager.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** EditorActionManager.java 18 Nov 2005 14:59:56 -0000 1.17 --- EditorActionManager.java 20 Nov 2005 12:47:47 -0000 1.18 *************** *** 260,264 **** protected void doEditorAction(Editor editor, ActionEvent e) { ! AttributeSet initial = getCharacterAttributes(editor.getTextComponent()); FontChooser fc = new FontChooser(m_parent, "Font Chooser", true, initial); fc.setVisible(true); --- 260,264 ---- protected void doEditorAction(Editor editor, ActionEvent e) { ! AttributeSet initial = editor.getCharacterAttributes(); FontChooser fc = new FontChooser(m_parent, "Font Chooser", true, initial); fc.setVisible(true); *************** *** 439,443 **** MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setAlignment(attr, a); ! setParagraphAttributes(editor.getTextComponent(), attr, false); } } --- 439,443 ---- MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setAlignment(attr, a); ! editor.setParagraphAttributes(attr, false); } } *************** *** 1087,1135 **** return (EditorActionManager.s_editor != null); } - - protected final AttributeSet getCharacterAttributes(JEditorPane editor) { - int p0 = editor.getSelectionStart(); - int p1 = editor.getSelectionEnd(); - if (p0 != p1) { - StyledDocument doc = (StyledDocument) editor.getDocument(); - return doc.getCharacterElement(p0).getAttributes(); - } - else { - return EditorActionManager.getActiveEditor().getInputAttributes(); - } - } - - /** - * Applies the given attributes to paragraphs. If - * there is a selection, the attributes are applied - * to the paragraphs that intersect the selection. - * if there is no selection, the attributes are applied - * to the paragraph at the current caret position. - * - * @param editor the editor - * @param attr the attributes - * @param replace if true, replace the existing attributes first - */ - protected final void setParagraphAttributes(JEditorPane editor, - AttributeSet attr, boolean replace) { - int p0 = editor.getSelectionStart(); - int p1 = editor.getSelectionEnd(); - Editor active = EditorActionManager.getActiveEditor(); - Document doc = active.getTextComponent().getDocument(); - if (doc instanceof StyledDocument) { - ((StyledDocument) doc).setParagraphAttributes(p0, p1 - p0, attr, replace); - } - editor.requestFocus(); - } - - /** - * Returns a running thread wrapping the runnable object. - * @param r java.lang.Runnable - * @return java.lang.Thread - */ - public static final Runnable threads(Runnable r) { - Thread t = new Thread(r); - t.start(); - return t; - } } --- 1087,1089 ---- |
From: Stephen C. <cr...@us...> - 2005-11-20 12:48:01
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12747/src/com/jmonkey/office/lexi/support/editors Modified Files: OfficeDocumentEditor.java OfficeDocumentEditorKit.java StyledEditor.java TEXTEditor.java Log Message: Code reorganization and pruning of lame imports Index: StyledEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/StyledEditor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** StyledEditor.java 15 Nov 2005 12:59:46 -0000 1.6 --- StyledEditor.java 20 Nov 2005 12:47:47 -0000 1.7 *************** *** 57,60 **** --- 57,61 ---- import javax.swing.event.UndoableEditEvent; import javax.swing.event.UndoableEditListener; + import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.Document; *************** *** 190,194 **** } } ! /** * Returns the content type as a MIME string. --- 191,225 ---- } } ! ! public final AttributeSet getCharacterAttributes() { ! int p0 = m_editor.getSelectionStart(); ! int p1 = m_editor.getSelectionEnd(); ! if (p0 != p1) { ! StyledDocument doc = (StyledDocument) m_editor.getDocument(); ! return doc.getCharacterElement(p0).getAttributes(); ! } ! else { ! return EditorActionManager.getActiveEditor().getInputAttributes(); ! } ! } ! /** ! * Applies the given attributes to paragraphs. If ! * there is a selection, the attributes are applied ! * to the paragraphs that intersect the selection. ! * if there is no selection, the attributes are applied ! * to the paragraph at the current caret position. ! * ! * @param attr the attributes ! * @param replace if true, replace the existing attributes first ! */ ! public final void setParagraphAttributes(AttributeSet attr, boolean replace) { ! int p0 = m_editor.getSelectionStart(); ! int p1 = m_editor.getSelectionEnd(); ! StyledDocument doc = (StyledDocument) m_editor.getDocument(); ! doc.setParagraphAttributes(p0, p1 - p0, attr, replace); ! // FIXME -- why??? ! m_editor.requestFocus(); ! } ! /** * Returns the content type as a MIME string. *************** *** 448,451 **** --- 479,502 ---- } + + public final void setCharacterAttributes(AttributeSet attr, boolean replace) + { + JEditorPane pane = getTextComponent(); + int p0 = pane.getSelectionStart(); + int p1 = pane.getSelectionEnd(); + if (p0 != p1) { + StyledDocument doc = (StyledDocument) pane.getDocument(); + doc.setCharacterAttributes(p0, p1 - p0, attr, replace); + } + else { + MutableAttributeSet inputAttributes = getInputAttributes(); + if (replace) { + inputAttributes.removeAttributes(inputAttributes); + } + inputAttributes.addAttributes(attr); + } + pane.requestFocus(); + } + public void setCurrentParagraph(Element paragraph) { m_currentParagraph = paragraph; Index: OfficeDocumentEditorKit.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/OfficeDocumentEditorKit.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OfficeDocumentEditorKit.java 15 Nov 2005 12:59:46 -0000 1.2 --- OfficeDocumentEditorKit.java 20 Nov 2005 12:47:47 -0000 1.3 *************** *** 25,29 **** package com.jmonkey.office.lexi.support.editors; - import java.awt.event.ActionEvent; import java.io.IOException; import java.io.InputStream; --- 25,28 ---- *************** *** 34,38 **** import javax.swing.text.BoxView; import javax.swing.text.BadLocationException; - import javax.swing.text.DefaultEditorKit; import javax.swing.text.Document; import javax.swing.text.EditorKit; --- 33,36 ---- Index: TEXTEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/TEXTEditor.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TEXTEditor.java 30 Oct 2005 15:53:26 -0000 1.11 --- TEXTEditor.java 20 Nov 2005 12:47:47 -0000 1.12 *************** *** 58,61 **** --- 58,62 ---- import javax.swing.event.UndoableEditEvent; import javax.swing.event.UndoableEditListener; + import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.Document; *************** *** 63,66 **** --- 64,68 ---- import javax.swing.text.Element; import javax.swing.text.MutableAttributeSet; + import javax.swing.text.StyledDocument; import javax.swing.text.Utilities; *************** *** 195,198 **** --- 197,227 ---- } + public final AttributeSet getCharacterAttributes() { + return getInputAttributes(); + } + + /** + * Applies the given attributes to paragraphs. If + * there is a selection, the attributes are applied + * to the paragraphs that intersect the selection. + * if there is no selection, the attributes are applied + * to the paragraph at the current caret position. + * + * @param editor the editor + * @param attr the attributes + * @param replace if true, replace the existing attributes first + */ + protected final void setParagraphAttributes(JEditorPane editor, + AttributeSet attr, boolean replace) { + int p0 = editor.getSelectionStart(); + int p1 = editor.getSelectionEnd(); + Editor active = EditorActionManager.getActiveEditor(); + Document doc = active.getTextComponent().getDocument(); + if (doc instanceof StyledDocument) { + ((StyledDocument) doc).setParagraphAttributes(p0, p1 - p0, attr, replace); + } + editor.requestFocus(); + } + public final String getContentType() { return m_editor.getContentType(); *************** *** 413,416 **** --- 442,450 ---- } + + public void setCharacterAttributes(AttributeSet attr, boolean replace) { + // Do nothing ... + } + public void setCurrentParagraph(Element paragraph) { m_currentParagraph = paragraph; *************** *** 421,424 **** --- 455,462 ---- } + public final void setParagraphAttributes(AttributeSet attr, boolean replace) { + // Do nothing ... + } + public final void setSelectionColor(Color colour) { m_editor.setSelectionColor(colour); Index: OfficeDocumentEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/OfficeDocumentEditor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OfficeDocumentEditor.java 15 Nov 2005 12:59:46 -0000 1.2 --- OfficeDocumentEditor.java 20 Nov 2005 12:47:47 -0000 1.3 *************** *** 33,40 **** import javax.swing.JEditorPane; - import javax.swing.KeyStroke; - import javax.swing.Action; - import javax.swing.text.EditorKit; - import javax.swing.text.Keymap; import javax.swing.text.BadLocationException; import javax.swing.text.StyledEditorKit; --- 33,36 ---- |
From: Stephen C. <cr...@us...> - 2005-11-20 12:48:01
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12747/src/com/jmonkey/office/lexi/odf Modified Files: XMLHandler.java Log Message: Code reorganization and pruning of lame imports Index: XMLHandler.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf/XMLHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLHandler.java 12 Nov 2005 13:56:38 -0000 1.1 --- XMLHandler.java 20 Nov 2005 12:47:46 -0000 1.2 *************** *** 25,30 **** package com.jmonkey.office.lexi.odf; - import java.util.ArrayList; - import org.xml.sax.helpers.DefaultHandler; --- 25,28 ---- *************** *** 33,37 **** */ public class XMLHandler extends DefaultHandler { - private ArrayList m_stack = new ArrayList(); abstract class ElementHandler { --- 31,34 ---- |
From: Stephen C. <cr...@us...> - 2005-11-20 12:48:01
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12747/src/com/jmonkey/office/lexi Modified Files: DocumentManager.java FormatToolBar.java Log Message: Code reorganization and pruning of lame imports Index: DocumentManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/DocumentManager.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** DocumentManager.java 18 Nov 2005 14:59:56 -0000 1.13 --- DocumentManager.java 20 Nov 2005 12:47:46 -0000 1.14 *************** *** 28,32 **** import java.awt.Component; import java.awt.Dimension; - import java.awt.Font; import java.awt.event.ActionEvent; import java.io.File; --- 28,31 ---- *************** *** 46,50 **** import javax.swing.text.StyleConstants; - import com.jmonkey.export.Format; import com.jmonkey.export.Registry; import com.jmonkey.export.Runtime; --- 45,48 ---- Index: FormatToolBar.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/FormatToolBar.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FormatToolBar.java 17 Nov 2005 13:59:39 -0000 1.2 --- FormatToolBar.java 20 Nov 2005 12:47:46 -0000 1.3 *************** *** 36,40 **** import java.util.Enumeration; - import javax.swing.Action; import javax.swing.Icon; import javax.swing.JButton; --- 36,39 ---- |
From: Stephen C. <cr...@us...> - 2005-11-18 15:00:07
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23712/src/com/jmonkey/office/lexi Modified Files: DocumentManager.java Lexi.java MediaTypesPanel.java Log Message: Initialize a new document to well-defined font family / size / colour. Index: DocumentManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/DocumentManager.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DocumentManager.java 3 Nov 2005 12:17:46 -0000 1.12 --- DocumentManager.java 18 Nov 2005 14:59:56 -0000 1.13 *************** *** 25,30 **** --- 25,32 ---- package com.jmonkey.office.lexi; + import java.awt.Color; import java.awt.Component; import java.awt.Dimension; + import java.awt.Font; import java.awt.event.ActionEvent; import java.io.File; *************** *** 41,45 **** --- 43,50 ---- import javax.swing.JOptionPane; import javax.swing.filechooser.FileFilter; + import javax.swing.text.MutableAttributeSet; + import javax.swing.text.StyleConstants; + import com.jmonkey.export.Format; import com.jmonkey.export.Registry; import com.jmonkey.export.Runtime; *************** *** 77,81 **** Code.debug("editorNew"); NewDialog dialog = new NewDialog(m_parent, ! m_registry.getString("MAIN", "default.content.type")); String contentType = dialog.getChosenContentType(); if (contentType != null) { --- 82,86 ---- Code.debug("editorNew"); NewDialog dialog = new NewDialog(m_parent, ! m_registry.getString("DOCUMENTS", "default.content.type")); String contentType = dialog.getChosenContentType(); if (contentType != null) { *************** *** 382,389 **** m_currentDoc.activate(); m_parent.updateOpenWindowsMenu(); ! if (file != null) { ! if (file.exists() && file.isFile()) { ! editorOpen(file); ! } } doc.setVisible(true); --- 387,409 ---- m_currentDoc.activate(); m_parent.updateOpenWindowsMenu(); ! if (file != null && file.exists() && file.isFile()) { ! editorOpen(file); ! } ! else { ! // Set the document's initial font family, size and text color ! String colourName = m_registry.getString("DOCUMENTS", "default.colour"); ! String hex = m_registry.getString("COLOURS", colourName); ! Color colour = Color.decode(hex); ! String fontFamily = ! m_registry.getString("DOCUMENTS", "default.font.family"); ! int fontSize = ! m_registry.getInteger("DOCUMENTS", "default.font.size"); ! Editor editor = doc.getEditor(); ! MutableAttributeSet attrs = editor.getSimpleAttributeSet(); ! StyleConstants.setForeground(attrs, colour); ! StyleConstants.setFontFamily(attrs, fontFamily); ! StyleConstants.setFontSize(attrs, fontSize); ! editor.setCharacterAttributes(attrs, false); ! m_parent.getFormatToolBar().updateControls(editor, attrs); } doc.setVisible(true); *************** *** 397,401 **** return createDocumentFrame(file, m_newDocumentTitle + m_parent.getDocumentNumber(), ! m_registry.getString("MAIN", "default.content.type")); } --- 417,421 ---- return createDocumentFrame(file, m_newDocumentTitle + m_parent.getDocumentNumber(), ! m_registry.getString("DOCUMENTS", "default.content.type")); } *************** *** 415,419 **** null, m_newDocumentTitle + (m_parent.getDocumentNumber() + 1), ! m_registry.getString("MAIN", "default.content.type")); } --- 435,439 ---- null, m_newDocumentTitle + (m_parent.getDocumentNumber() + 1), ! m_registry.getString("DOCUMENTS", "default.content.type")); } Index: Lexi.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/Lexi.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Lexi.java 16 Nov 2005 15:27:54 -0000 1.28 --- Lexi.java 18 Nov 2005 14:59:56 -0000 1.29 *************** *** 873,877 **** "String"}, {"new.document.title", "New Document", "String"}, - {"default.content.type", Editor.VALID_CONTENT_TYPES[2], "String"} }); } --- 873,876 ---- *************** *** 910,914 **** } ! // Default Colours if (reg.sizeOf("COLOURS") == 0) { reg.initGroup("COLOURS", new String[][]{ --- 909,913 ---- } ! // Default Colours group if (reg.sizeOf("COLOURS") == 0) { reg.initGroup("COLOURS", new String[][]{ *************** *** 928,931 **** --- 927,939 ---- } + // Default Document group + if (reg.sizeOf("DOCUMENTS") == 0) { + reg.initGroup("DOCUMENTS", new String[][]{ + {"default.content.type", Editor.VALID_CONTENT_TYPES[2]}, + {"default.font.family", "Courier"}, + {"default.font.size", "12", "int"}, + {"default.colour", "Black"}}); + } + m_mainRegistry = reg; } Index: MediaTypesPanel.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/MediaTypesPanel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MediaTypesPanel.java 15 Oct 2005 06:09:56 -0000 1.1 --- MediaTypesPanel.java 18 Nov 2005 14:59:56 -0000 1.2 *************** *** 29,33 **** protected MediaTypesPanel(Lexi app) { super(app); ! addPropertyRow("Default Content Type", "MAIN", "default.content.type"); addFillAtBottom(); } --- 29,33 ---- protected MediaTypesPanel(Lexi app) { super(app); ! addPropertyRow("Default Content Type", "DOCUMENTS", "default.content.type"); addFillAtBottom(); } |
From: Stephen C. <cr...@us...> - 2005-11-18 15:00:04
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23712/src/com/jmonkey/office/lexi/support Modified Files: Editor.java EditorActionManager.java Log Message: Initialize a new document to well-defined font family / size / colour. Index: Editor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/Editor.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Editor.java 12 Nov 2005 13:56:38 -0000 1.14 --- Editor.java 18 Nov 2005 14:59:56 -0000 1.15 *************** *** 39,45 **** --- 39,47 ---- import javax.swing.JPopupMenu; import javax.swing.text.AttributeSet; + import javax.swing.text.Document; import javax.swing.text.Element; import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; + import javax.swing.text.StyledDocument; import javax.swing.undo.UndoManager; *************** *** 316,319 **** --- 318,353 ---- public abstract void setCurrentRun(Element run); + /** + * Applies the given attributes to character content. If there is a selection, + * the attributes are applied to the selection range. If there is no + * selection, the attributes are applied to the input attribute set which + * defines the attributes for any new text that gets inserted. + * + * @param attr the attributes + * @param replace + * if true, then replace the existing attributes first + */ + public final void setCharacterAttributes(AttributeSet attr, boolean replace) + { + JEditorPane pane = getTextComponent(); + int p0 = pane.getSelectionStart(); + int p1 = pane.getSelectionEnd(); + if (p0 != p1) { + Document doc = pane.getDocument(); + if (doc instanceof StyledDocument) { + ((StyledDocument) doc).setCharacterAttributes(p0, p1 - p0, attr, + replace); + } + } + else { + MutableAttributeSet inputAttributes = getInputAttributes(); + if (replace) { + inputAttributes.removeAttributes(inputAttributes); + } + inputAttributes.addAttributes(attr); + } + pane.requestFocus(); + } + public final void setFile(File file) { m_file = file; Index: EditorActionManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/EditorActionManager.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** EditorActionManager.java 17 Nov 2005 13:59:39 -0000 1.16 --- EditorActionManager.java 18 Nov 2005 14:59:56 -0000 1.17 *************** *** 276,280 **** StyleConstants.setItalic(attr, isItalic); StyleConstants.setBold(attr, isBold); ! setCharacterAttributes(editor.getTextComponent(), attr, false); } else { --- 276,280 ---- StyleConstants.setItalic(attr, isItalic); StyleConstants.setBold(attr, isBold); ! editor.setCharacterAttributes(attr, false); } else { *************** *** 306,310 **** MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setFontFamily(attr, family); ! setCharacterAttributes(editor.getTextComponent(), attr, false); } else { --- 306,310 ---- MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setFontFamily(attr, family); ! editor.setCharacterAttributes(attr, false); } else { *************** *** 341,345 **** MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setFontSize(attr, size); ! setCharacterAttributes(editor.getTextComponent(), attr, false); } else { --- 341,345 ---- MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setFontSize(attr, size); ! editor.setCharacterAttributes(attr, false); } else { *************** *** 372,376 **** MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setForeground(attr, fg); ! setCharacterAttributes(editor.getTextComponent(), attr, false); } else { --- 372,376 ---- MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setForeground(attr, fg); ! editor.setCharacterAttributes(attr, false); } else { *************** *** 403,407 **** MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setForeground(attr, fg); ! setCharacterAttributes(editor.getTextComponent(), attr, false); } else { --- 403,407 ---- MutableAttributeSet attr = editor.getSimpleAttributeSet(); StyleConstants.setForeground(attr, fg); ! editor.setCharacterAttributes(attr, false); } else { *************** *** 452,456 **** boolean bold = !StyleConstants.isBold(attr); StyleConstants.setBold(attr, bold); ! setCharacterAttributes(editor.getTextComponent(), attr, false); } } --- 452,456 ---- boolean bold = !StyleConstants.isBold(attr); StyleConstants.setBold(attr, bold); ! editor.setCharacterAttributes(attr, false); } } *************** *** 465,469 **** boolean italic = !StyleConstants.isItalic(attr); StyleConstants.setItalic(attr, italic); ! setCharacterAttributes(editor.getTextComponent(), attr, false); } } --- 465,469 ---- boolean italic = !StyleConstants.isItalic(attr); StyleConstants.setItalic(attr, italic); ! editor.setCharacterAttributes(attr, false); } } *************** *** 478,482 **** boolean underline = !StyleConstants.isUnderline(attr); StyleConstants.setUnderline(attr, underline); ! setCharacterAttributes(editor.getTextComponent(), attr, false); } } --- 478,482 ---- boolean underline = !StyleConstants.isUnderline(attr); StyleConstants.setUnderline(attr, underline); ! editor.setCharacterAttributes(attr, false); } } *************** *** 491,495 **** boolean bold = !StyleConstants.isStrikeThrough(attr); StyleConstants.setStrikeThrough(attr, bold); ! setCharacterAttributes(editor.getTextComponent(), attr, false); } } --- 491,495 ---- boolean bold = !StyleConstants.isStrikeThrough(attr); StyleConstants.setStrikeThrough(attr, bold); ! editor.setCharacterAttributes(attr, false); } } *************** *** 1087,1123 **** return (EditorActionManager.s_editor != null); } - - /** - * Applies the given attributes to character content. If there is a selection, - * the attributes are applied to the selection range. If there is no - * selection, the attributes are applied to the input attribute set which - * defines the attributes for any new text that gets inserted. - * - * @param editor the editor - * @param attr the attributes - * @param replace - * if true, then replace the existing attributes first - */ - protected final void setCharacterAttributes(JEditorPane editor, - AttributeSet attr, boolean replace) { - int p0 = editor.getSelectionStart(); - int p1 = editor.getSelectionEnd(); - Editor active = EditorActionManager.getActiveEditor(); - if (p0 != p1) { - Document doc = active.getTextComponent().getDocument(); - if (doc instanceof StyledDocument) { - ((StyledDocument) doc).setCharacterAttributes(p0, p1 - p0, attr, - replace); - } - } - else { - MutableAttributeSet inputAttributes = active.getInputAttributes(); - if (replace) { - inputAttributes.removeAttributes(inputAttributes); - } - inputAttributes.addAttributes(attr); - } - editor.requestFocus(); - } protected final AttributeSet getCharacterAttributes(JEditorPane editor) { --- 1087,1090 ---- |
From: Stephen C. <cr...@us...> - 2005-11-17 13:59:49
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6718/src/com/jmonkey/office/lexi/support Modified Files: EditorActionManager.java Log Message: Implemented colour tracking too. Index: EditorActionManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/EditorActionManager.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EditorActionManager.java 16 Nov 2005 15:27:55 -0000 1.15 --- EditorActionManager.java 17 Nov 2005 13:59:39 -0000 1.16 *************** *** 382,386 **** public final class ForegroundAction extends EditorAction { protected Color m_fg = null; - protected String m_name = null; --- 382,385 ---- *************** *** 410,413 **** --- 409,420 ---- } } + + public Color getColour() { + return m_fg; + } + + public String getName() { + return m_name; + } } |
From: Stephen C. <cr...@us...> - 2005-11-17 13:59:49
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6718/src/com/jmonkey/office/lexi Modified Files: FormatToolBar.java Log Message: Implemented colour tracking too. Index: FormatToolBar.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/FormatToolBar.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FormatToolBar.java 16 Nov 2005 15:27:54 -0000 1.1 --- FormatToolBar.java 17 Nov 2005 13:59:39 -0000 1.2 *************** *** 54,57 **** --- 54,58 ---- import com.jmonkey.office.lexi.support.EditorActionManager.FontFamilyAction; import com.jmonkey.office.lexi.support.EditorActionManager.FontSizeAction; + import com.jmonkey.office.lexi.support.EditorActionManager.ForegroundAction; /** *************** *** 73,77 **** private JButton m_strikeThrough; - /** --- 74,77 ---- *************** *** 160,168 **** setMinimumSize(new Dimension(0, 16)); Font thisFont = new Font((String) value, Font.PLAIN, 12); - Code.debug("Font PostScript Name: " + thisFont.getPSName()); setFont(thisFont); setText((String) value); - - // setIcon((ImageIcon)a.getValue(Action.SMALL_ICON)); if (isSelected) { setBackground(list.getSelectionBackground()); --- 160,165 ---- *************** *** 195,199 **** setText((String) value); setMinimumSize(new Dimension(0, 16)); - // setIcon((ImageIcon)a.getValue(Action.SMALL_ICON)); if (isSelected) { setBackground(list.getSelectionBackground()); --- 192,195 ---- *************** *** 233,239 **** String colourKey = (String) colourEnum.nextElement(); try { ! m_colours.addItem(eam.getColourAction( ! colourKey, ! Color.decode(reg.getString("COLOURS", colourKey)))); } catch (NumberFormatException nfe0) { --- 229,234 ---- String colourKey = (String) colourEnum.nextElement(); try { ! Color colour = Color.decode(reg.getString("COLOURS", colourKey)); ! m_colours.addItem(eam.getColourAction(colourKey, colour)); } catch (NumberFormatException nfe0) { *************** *** 247,251 **** m_fonts.setEditable(false); m_fonts.setRenderer(new FontActionCellRenderer()); - Enumeration fontEnum = reg.getKeys("FONTS"); while (fontEnum.hasMoreElements()) { --- 242,245 ---- *************** *** 257,261 **** Code.debug("Create font sizes dropdown."); - m_fontSizes = new ActionComboBox(); m_fontSizes.setMinimumSize(new Dimension(0, 16)); --- 251,254 ---- *************** *** 302,307 **** */ public void updateControls(Editor editor, AttributeSet attrs) { - System.err.println("called FormatToolBar.updateControls: " + attrs); - Object val = attrs.getAttribute(StyleConstants.FontSize); int fontSize = (val == null) ? editor.getFont().getSize() : --- 295,298 ---- *************** *** 328,342 **** } ! // val = attrs.getAttribute(StyleConstants.Foreground); ! // String colour = (val == null) ? editor.defaultForeground(editor) : ! // (String) val; ! // count = m_colours.getItemCount(); ! // for (int i = 0; i < count; i++) { ! // ColourAction item = (ColourAction) m_colours.getItemAt(i); ! // if (item.getColour().equals(colour)) { ! // m_colours.setSelectedIndex(i); ! // break; ! // } ! // } } --- 319,332 ---- } ! val = attrs.getAttribute(StyleConstants.Foreground); ! Color colour = (val == null) ? editor.getForeground() : (Color) val; ! count = m_colours.getItemCount(); ! for (int i = 0; i < count; i++) { ! ForegroundAction item = (ForegroundAction) m_colours.getItemAt(i); ! if (item.getColour().equals(colour)) { ! m_colours.setSelectedIndex(i); ! break; ! } ! } } |
From: Stephen C. <cr...@us...> - 2005-11-16 15:28:04
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3413/src/com/jmonkey/office/lexi Modified Files: Lexi.java Added Files: FormatToolBar.java Log Message: Preliminary implementation of font family/size tracking. As the cursor moves to characters with different character attributes, the editor's font family and size controls track the corresponding attributes. (Doesn't yet cope with the fact that the default font family is a logical font ... and is not known to the font family control.) --- NEW FILE: FormatToolBar.java --- /** * Copyright (C) 2005 the Lexi Project. * * This file is part of the Lexi document editor. * * Lexi is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Lexi is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Classpath; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole combination. */ package com.jmonkey.office.lexi; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.Graphics; import java.awt.Image; import java.io.Serializable; import java.util.Enumeration; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JToolBar; import javax.swing.ListCellRenderer; import javax.swing.text.AttributeSet; import javax.swing.text.StyleConstants; import com.jmonkey.export.Registry; import com.jmonkey.office.lexi.support.ActionComboBox; import com.jmonkey.office.lexi.support.ActionToolBar; import com.jmonkey.office.lexi.support.Code; import com.jmonkey.office.lexi.support.Editor; import com.jmonkey.office.lexi.support.EditorActionManager; import com.jmonkey.office.lexi.support.EditorActionManager.FontFamilyAction; import com.jmonkey.office.lexi.support.EditorActionManager.FontSizeAction; /** * */ public class FormatToolBar extends ActionToolBar { private Lexi m_lexi; private ActionComboBox m_fonts; private ActionComboBox m_fontSizes; private ActionComboBox m_colours; private JButton m_alignLeft; private JButton m_alignCenter; private JButton m_alignRight; private JButton m_justify; private JButton m_bold; private JButton m_italic; private JButton m_underline; private JButton m_strikeThrough; /** * Coloured list item Renderer. */ protected class ColourActionCellRenderer extends JLabel implements ListCellRenderer { public ColourActionCellRenderer() { setOpaque(true); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value != null) { setMinimumSize(new Dimension(0, 16)); String prop = m_lexi.getRegistry().getString("COLOURS", (String) value); Color colour = Color.decode(prop); setText((String) value); setIcon(new ColourIcon(colour)); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; } else { return new JLabel("VALUE IS NULL"); } } /** * Icon Renderer */ protected final class ColourIcon implements Icon, Serializable { private transient Color m_colour = null; private transient Image m_image = null; protected ColourIcon(Color colour) { super(); m_colour = colour; } public void paintIcon(Component c, Graphics g, int x, int y) { if (m_image == null) { m_image = c.createImage(getIconWidth(), getIconHeight()); Graphics imageG = m_image.getGraphics(); paintImage(c, imageG, m_colour); } g.drawImage(m_image, x, y, null); } private void paintImage(Component c, Graphics g, Color colour) { g.setColor(colour); g.fillRect(0, 0, getIconWidth(), getIconHeight()); g.setColor(Color.black); g.drawRect(0, 0, getIconWidth() - 1, getIconHeight() - 1); } public int getIconWidth() { return 16; } public int getIconHeight() { return 16; } } } /** * Font list item Renderer. */ protected class FontActionCellRenderer extends JLabel implements ListCellRenderer { public FontActionCellRenderer() { setOpaque(true); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value != null) { setMinimumSize(new Dimension(0, 16)); Font thisFont = new Font((String) value, Font.PLAIN, 12); Code.debug("Font PostScript Name: " + thisFont.getPSName()); setFont(thisFont); setText((String) value); // setIcon((ImageIcon)a.getValue(Action.SMALL_ICON)); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; } else { return new JLabel("VALUE IS NULL"); } } } /** * Font size list item Renderer. */ protected class FSActionCellRenderer extends JLabel implements ListCellRenderer { public FSActionCellRenderer() { setOpaque(true); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value != null) { setText((String) value); setMinimumSize(new Dimension(0, 16)); // setIcon((ImageIcon)a.getValue(Action.SMALL_ICON)); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; } else { return new JLabel("VALUE IS NULL"); } } } FormatToolBar(Lexi lexi) { super(); m_lexi = lexi; setLayout(new FlowLayout(FlowLayout.LEFT)); // This causes a fatal exception when not in windows L&F // _FORMAT_TOOL_BAR.putClientProperty("JToolBar.isRollover", "" + true); Code.debug("Create font colour dropdown."); m_colours = new ActionComboBox(); m_colours.setMinimumSize(new Dimension(0, 16)); m_colours.setEditable(false); m_colours.setRenderer(new ColourActionCellRenderer()); Registry reg = lexi.getRegistry(); Enumeration colourEnum = reg.getKeys("COLOURS"); EditorActionManager eam = lexi.getEditorActionManager(); while (colourEnum.hasMoreElements()) { String colourKey = (String) colourEnum.nextElement(); try { m_colours.addItem(eam.getColourAction( colourKey, Color.decode(reg.getString("COLOURS", colourKey)))); } catch (NumberFormatException nfe0) { // ignore } } Code.debug("Create font faces dropdown."); m_fonts = new ActionComboBox(); m_fonts.setMinimumSize(new Dimension(0, 16)); m_fonts.setEditable(false); m_fonts.setRenderer(new FontActionCellRenderer()); Enumeration fontEnum = reg.getKeys("FONTS"); while (fontEnum.hasMoreElements()) { String fontKey = (String) fontEnum.nextElement(); if (reg.getBoolean("FONTS", fontKey)) { m_fonts.addItem(eam.getFontFaceAction(fontKey)); } } Code.debug("Create font sizes dropdown."); m_fontSizes = new ActionComboBox(); m_fontSizes.setMinimumSize(new Dimension(0, 16)); m_fontSizes.setEditable(false); m_fontSizes.setRenderer(new FSActionCellRenderer()); int[] fontSizes = getFontSizes(); for (int i = 0; i < fontSizes.length; i++) { m_fontSizes.addItem(eam.getFontSizeAction(fontSizes[i])); } add(m_colours); add(m_fonts); add(m_fontSizes); addSeparator(); m_alignLeft = add(eam.getAlignLeftAction(), "align_left16.gif"); m_alignCenter = add(eam.getAlignCenterAction(), "align_center16.gif"); m_alignRight = add(eam.getAlignRightAction(), "align_right16.gif"); m_justify = add(eam.getAlignJustifyAction(), "align_justify16.gif"); addSeparator(); m_bold = add(eam.getBoldAction(), "bold_action16.gif"); m_italic = add(eam.getItalicAction(), "italic_action16.gif"); m_underline = add(eam.getUnderlineAction(), "underline_action16.gif"); m_strikeThrough = add(eam.getStrikeThroughAction(), "strikethrough_action16.gif"); // FIXME - Orientation Not working properly. String pos = reg.getString("USER", "position.format.toolbar"); if (pos.equalsIgnoreCase(BorderLayout.WEST) || pos.equalsIgnoreCase(BorderLayout.EAST)) { setOrientation(JToolBar.VERTICAL); } else if (pos.equalsIgnoreCase(BorderLayout.NORTH) || pos.equalsIgnoreCase(BorderLayout.SOUTH)) { setOrientation(JToolBar.HORIZONTAL); } setVisible(reg.getBoolean("USER", "show.format.toolbar")); } /** * Update the toolbar's controls to match the supplied attributes. * @param attrs the set of attributes we want to be reflected in * our controls. */ public void updateControls(Editor editor, AttributeSet attrs) { System.err.println("called FormatToolBar.updateControls: " + attrs); Object val = attrs.getAttribute(StyleConstants.FontSize); int fontSize = (val == null) ? editor.getFont().getSize() : ((Integer) val).intValue(); int count = m_fontSizes.getItemCount(); for (int i = 0; i < count; i++) { FontSizeAction item = (FontSizeAction) m_fontSizes.getItemAt(i); if (item.getSize() == fontSize) { m_fontSizes.setSelectedIndex(i); break; } } val = attrs.getAttribute(StyleConstants.FontFamily); String family = (val == null) ? editor.getFont().getFamily() : (String) val; count = m_fonts.getItemCount(); for (int i = 0; i < count; i++) { FontFamilyAction item = (FontFamilyAction) m_fonts.getItemAt(i); if (item.getFamily().equals(family)) { m_fonts.setSelectedIndex(i); break; } } // val = attrs.getAttribute(StyleConstants.Foreground); // String colour = (val == null) ? editor.defaultForeground(editor) : // (String) val; // count = m_colours.getItemCount(); // for (int i = 0; i < count; i++) { // ColourAction item = (ColourAction) m_colours.getItemAt(i); // if (item.getColour().equals(colour)) { // m_colours.setSelectedIndex(i); // break; // } // } } /** * Creates a range of Font sizes from the begin number to the end * number, with the specified granularity. * <P> * i.e. A granularity of two, will increase the range by 2. So, the number of * actions produced will be ((end - begin) / 2) or begin, begin + 2, begin + * 4, begin + 6 [up to] end. * * @param begin start of the range. * @param end end of the range. * @param granularity range granularity (divide by). */ private final int[] getFontSizes() { Registry reg = m_lexi.getRegistry(); int begin = reg.getInteger("MAIN", "font.sizes.minimum"); int end = reg.getInteger("MAIN", "font.sizes.maximum"); int granularity = reg.getInteger("MAIN", "font.sizes.granularity"); if (begin > end) { throw new IllegalArgumentException( "Invalid font size range; minimum font size > maximum font size."); } if (((end - begin) <= granularity)) { throw new IllegalArgumentException( "The granularity >= (maximum font size - minimum font size)."); } if (((end - begin) % granularity) > 0) { throw new IllegalArgumentException( "(Maximum font size - minimum font size) not divisible by granularity."); } int[] sizes = new int[((end - begin) / granularity) + 1]; for (int i = 0; i < sizes.length; i++) { sizes[i] = begin + granularity * i; } return sizes; } } Index: Lexi.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/Lexi.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Lexi.java 30 Oct 2005 15:55:47 -0000 1.27 --- Lexi.java 16 Nov 2005 15:27:54 -0000 1.28 *************** *** 28,36 **** import java.awt.BorderLayout; import java.awt.Color; - import java.awt.Component; import java.awt.Dimension; - import java.awt.FlowLayout; - import java.awt.Font; - import java.awt.Graphics; import java.awt.GraphicsEnvironment; import java.awt.Image; --- 28,32 ---- *************** *** 44,48 **** import java.io.File; import java.io.IOException; - import java.io.Serializable; import java.util.Enumeration; import java.util.ResourceBundle; --- 40,43 ---- *************** *** 52,61 **** import javax.swing.BorderFactory; import javax.swing.ButtonGroup; - import javax.swing.Icon; import javax.swing.JCheckBoxMenuItem; import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.JLabel; - import javax.swing.JList; import javax.swing.JMenu; import javax.swing.JMenuBar; --- 47,54 ---- *************** *** 64,68 **** import javax.swing.JPanel; import javax.swing.JToolBar; - import javax.swing.ListCellRenderer; import javax.swing.Scrollable; import javax.swing.SwingConstants; --- 57,60 ---- *************** *** 75,79 **** import com.jmonkey.export.RegistryFormatException; import com.jmonkey.office.help.OfficeHelp; - import com.jmonkey.office.lexi.support.ActionComboBox; import com.jmonkey.office.lexi.support.ActionToolBar; import com.jmonkey.office.lexi.support.Code; --- 67,70 ---- *************** *** 99,103 **** private static JLabel s_statusLabel = null; private static JToolBar s_toolBar = null; ! private static JToolBar s_formatToolBar = null; private static int s_documentCount = 0; --- 90,94 ---- private static JLabel s_statusLabel = null; private static JToolBar s_toolBar = null; ! private static FormatToolBar s_formatToolBar = null; private static int s_documentCount = 0; *************** *** 317,456 **** } ! /** ! * Coloured list item Renderer. ! */ ! protected class ColourActionCellRenderer extends JLabel implements ! ListCellRenderer { ! public ColourActionCellRenderer() { ! setOpaque(true); ! } ! ! public Component getListCellRendererComponent(JList list, Object value, ! int index, boolean isSelected, boolean cellHasFocus) { ! if (value != null) { ! setMinimumSize(new Dimension(0, 16)); ! String prop = getRegistry().getString("COLOURS", (String) value); ! Color colour = Color.decode(prop); ! setText((String) value); ! setIcon(new ColourIcon(colour)); ! if (isSelected) { ! setBackground(list.getSelectionBackground()); ! setForeground(list.getSelectionForeground()); ! } ! else { ! setBackground(list.getBackground()); ! setForeground(list.getForeground()); ! } ! return this; ! ! } ! else { ! return new JLabel("VALUE IS NULL"); ! } ! } ! ! /** ! * Icon Renderer ! */ ! protected final class ColourIcon implements Icon, Serializable { ! private transient Color m_colour = null; ! private transient Image m_image = null; ! ! protected ColourIcon(Color colour) { ! super(); ! m_colour = colour; ! } ! ! public void paintIcon(Component c, Graphics g, int x, int y) { ! if (m_image == null) { ! m_image = c.createImage(getIconWidth(), getIconHeight()); ! Graphics imageG = m_image.getGraphics(); ! paintImage(c, imageG, m_colour); ! } ! g.drawImage(m_image, x, y, null); ! } ! ! private void paintImage(Component c, Graphics g, Color colour) { ! g.setColor(colour); ! g.fillRect(0, 0, getIconWidth(), getIconHeight()); ! g.setColor(Color.black); ! g.drawRect(0, 0, getIconWidth() - 1, getIconHeight() - 1); ! } ! ! public int getIconWidth() { ! return 16; ! } ! ! public int getIconHeight() { ! return 16; ! } ! } ! } ! ! /** ! * Font list item Renderer. ! */ ! protected class FontActionCellRenderer extends JLabel implements ! ListCellRenderer { ! public FontActionCellRenderer() { ! setOpaque(true); ! } ! ! public Component getListCellRendererComponent(JList list, Object value, ! int index, boolean isSelected, boolean cellHasFocus) { ! if (value != null) { ! setMinimumSize(new Dimension(0, 16)); ! Font thisFont = new Font((String) value, Font.PLAIN, 12); ! Code.debug("Font PostScript Name: " + thisFont.getPSName()); ! setFont(thisFont); ! setText((String) value); ! ! // setIcon((ImageIcon)a.getValue(Action.SMALL_ICON)); ! if (isSelected) { ! setBackground(list.getSelectionBackground()); ! setForeground(list.getSelectionForeground()); ! } ! else { ! setBackground(list.getBackground()); ! setForeground(list.getForeground()); ! } ! return this; ! } ! else { ! return new JLabel("VALUE IS NULL"); ! } ! } ! } ! ! /** ! * Font size list item Renderer. ! */ ! protected class FSActionCellRenderer extends JLabel implements ! ListCellRenderer { ! public FSActionCellRenderer() { ! setOpaque(true); ! } ! ! public Component getListCellRendererComponent(JList list, Object value, ! int index, boolean isSelected, boolean cellHasFocus) { ! if (value != null) { ! setText((String) value); ! setMinimumSize(new Dimension(0, 16)); ! // setIcon((ImageIcon)a.getValue(Action.SMALL_ICON)); ! if (isSelected) { ! setBackground(list.getSelectionBackground()); ! setForeground(list.getSelectionForeground()); ! } ! else { ! setBackground(list.getBackground()); ! setForeground(list.getForeground()); ! } ! return this; ! } ! else { ! return new JLabel("VALUE IS NULL"); ! } ! } ! } // PropertySheetDialog --- 308,312 ---- } ! // PropertySheetDialog *************** *** 913,997 **** } ! protected final JToolBar getFormatToolBar() { if (s_formatToolBar == null) { ! s_formatToolBar = new ActionToolBar(); ! s_formatToolBar.setLayout(new FlowLayout(FlowLayout.LEFT)); ! ! // This causes a fatal exception when not in windows L&F ! // _FORMAT_TOOL_BAR.putClientProperty("JToolBar.isRollover", "" + true); ! ! Code.debug("Create font colour dropdown."); ! ActionComboBox colours = new ActionComboBox(); ! colours.setMinimumSize(new Dimension(0, 16)); ! colours.setEditable(false); ! colours.setRenderer(new ColourActionCellRenderer()); ! ! Registry reg = getRegistry(); ! Enumeration colourEnum = reg.getKeys("COLOURS"); ! EditorActionManager eam = getEditorActionManager(); ! while (colourEnum.hasMoreElements()) { ! String colourKey = (String) colourEnum.nextElement(); ! try { ! colours.addItem(eam.getColourAction( ! colourKey, ! Color.decode(reg.getString("COLOURS", colourKey)))); ! } ! catch (NumberFormatException nfe0) { ! // ignore ! } ! } ! ! Code.debug("Create font faces dropdown."); ! ActionComboBox fonts = new ActionComboBox(); ! fonts.setMinimumSize(new Dimension(0, 16)); ! fonts.setEditable(false); ! fonts.setRenderer(new FontActionCellRenderer()); ! ! Enumeration fontEnum = reg.getKeys("FONTS"); ! while (fontEnum.hasMoreElements()) { ! String fontKey = (String) fontEnum.nextElement(); ! if (reg.getBoolean("FONTS", fontKey)) { ! fonts.addItem(eam.getFontFaceAction(fontKey)); ! } ! } ! ! Code.debug("Create font sizes dropdown."); ! ! ActionComboBox fsizes = new ActionComboBox(); ! fsizes.setMinimumSize(new Dimension(0, 16)); ! fsizes.setEditable(false); ! fsizes.setRenderer(new FSActionCellRenderer()); ! int[] fontSizes = getFontSizes(); ! for (int i = 0; i < fontSizes.length; i++) { ! fsizes.addItem(eam.getFontSizeAction(fontSizes[i])); ! } ! ActionToolBar ftb = (ActionToolBar) s_formatToolBar; ! ftb.add(colours); ! ftb.add(fonts); ! ftb.add(fsizes); ! ftb.addSeparator(); ! ftb.add(eam.getAlignLeftAction(), "align_left16.gif"); ! ftb.add(eam.getAlignCenterAction(), "align_center16.gif"); ! ftb.add(eam.getAlignRightAction(), "align_right16.gif"); ! ftb.add(eam.getAlignJustifyAction(), "align_justify16.gif"); ! ftb.addSeparator(); ! ftb.add(eam.getBoldAction(), "bold_action16.gif"); ! ftb.add(eam.getItalicAction(), "italic_action16.gif"); ! ftb.add(eam.getUnderlineAction(), "underline_action16.gif"); ! ftb.add(eam.getStrikeThroughAction(), "strikethrough_action16.gif"); ! ! // FIXME - Orientation Not working properly. ! String pos = reg.getString("USER", "position.format.toolbar"); ! if (pos.equalsIgnoreCase(BorderLayout.WEST) || ! pos.equalsIgnoreCase(BorderLayout.EAST)) { ! ftb.setOrientation(JToolBar.VERTICAL); ! } ! else if (pos.equalsIgnoreCase(BorderLayout.NORTH) || ! pos.equalsIgnoreCase(BorderLayout.SOUTH)) { ! ftb.setOrientation(JToolBar.HORIZONTAL); ! } ! ftb.setVisible(reg.getBoolean("USER", "show.format.toolbar")); } - return s_formatToolBar; } --- 769,776 ---- } ! public final FormatToolBar getFormatToolBar() { if (s_formatToolBar == null) { ! s_formatToolBar = new FormatToolBar(this); } return s_formatToolBar; } |
From: Stephen C. <cr...@us...> - 2005-11-16 15:28:03
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3413/src/com/jmonkey/office/lexi/support Modified Files: ActionToolBar.java EditorActionManager.java Log Message: Preliminary implementation of font family/size tracking. As the cursor moves to characters with different character attributes, the editor's font family and size controls track the corresponding attributes. (Doesn't yet cope with the fact that the default font family is a logical font ... and is not known to the font family control.) Index: EditorActionManager.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/EditorActionManager.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** EditorActionManager.java 30 Oct 2005 15:55:47 -0000 1.14 --- EditorActionManager.java 16 Nov 2005 15:27:55 -0000 1.15 *************** *** 53,56 **** --- 53,58 ---- import javax.swing.text.StyledDocument; + import com.jmonkey.office.lexi.Lexi; + public class EditorActionManager extends ActionManager { *************** *** 109,113 **** // ========= PRIVATE MEMBERS =================== ! private final CaretListener m_attributeTracker = new AttributeTracker(); private static Editor s_editor = null; --- 111,115 ---- // ========= PRIVATE MEMBERS =================== ! private final CaretListener m_attributeTracker; private static Editor s_editor = null; *************** *** 119,122 **** --- 121,126 ---- */ public EditorActionManager(JFrame app, FileActionListener agent) { + m_attributeTracker = new AttributeTracker(app); + // Populate the action map with the static actions. m_actions.put(ALIGN_CENTER_ACTION_PREFIX, *************** *** 175,180 **** */ private final class AttributeTracker implements CaretListener, Serializable { ! protected AttributeTracker() { super(); } --- 179,187 ---- */ private final class AttributeTracker implements CaretListener, Serializable { ! private JFrame m_app; ! ! protected AttributeTracker(JFrame app) { super(); + m_app = app; } *************** *** 193,197 **** if (run != ed.getCurrentRun()) { ed.setCurrentRun(run); ! createInputAttributes(ed.getCurrentRun(), ed.getInputAttributes()); } } --- 200,206 ---- if (run != ed.getCurrentRun()) { ed.setCurrentRun(run); ! MutableAttributeSet attrs = ed.getInputAttributes(); ! createInputAttributes(ed.getCurrentRun(), attrs); ! ((Lexi) m_app).getFormatToolBar().updateControls(ed, attrs); } } *************** *** 245,249 **** // ==================================================== ! private final class FontChooserAction extends EditorAction { public FontChooserAction(String nm, JFrame component) { super(nm, component); --- 254,258 ---- // ==================================================== ! public final class FontChooserAction extends EditorAction { public FontChooserAction(String nm, JFrame component) { super(nm, component); *************** *** 277,281 **** // ==================================================== ! private final class FontFamilyAction extends EditorAction { private String m_family; --- 286,290 ---- // ==================================================== ! public final class FontFamilyAction extends EditorAction { private String m_family; *************** *** 303,310 **** } } } // End FontFamilyAction class // =================================================== ! private final class FontSizeAction extends EditorAction { private int m_size; --- 312,324 ---- } } + + public String getFamily() { + return m_family; + } + } // End FontFamilyAction class // =================================================== ! public final class FontSizeAction extends EditorAction { private int m_size; *************** *** 333,340 **** } } } // End FontSizeAction // ============================================================== ! private final class ColourChooserAction extends EditorAction { public ColourChooserAction(String nm, JFrame component) { super(nm, component); --- 347,358 ---- } } + + public int getSize() { + return m_size; + } } // End FontSizeAction // ============================================================== ! public final class ColourChooserAction extends EditorAction { public ColourChooserAction(String nm, JFrame component) { super(nm, component); *************** *** 362,366 **** } ! private final class ForegroundAction extends EditorAction { protected Color m_fg = null; --- 380,384 ---- } ! public final class ForegroundAction extends EditorAction { protected Color m_fg = null; *************** *** 394,398 **** } ! private final class AlignmentAction extends EditorAction { private int m_alignment; --- 412,416 ---- } ! public final class AlignmentAction extends EditorAction { private int m_alignment; *************** *** 418,422 **** } ! private final class BoldAction extends EditorAction { public BoldAction() { super(BOLD_ACTION_PREFIX); --- 436,440 ---- } ! public final class BoldAction extends EditorAction { public BoldAction() { super(BOLD_ACTION_PREFIX); *************** *** 431,435 **** } ! private final class ItalicAction extends EditorAction { public ItalicAction() { super(ITALIC_ACTION_PREFIX); --- 449,453 ---- } ! public final class ItalicAction extends EditorAction { public ItalicAction() { super(ITALIC_ACTION_PREFIX); *************** *** 444,448 **** } ! private final class UnderlineAction extends EditorAction { public UnderlineAction() { super(UNDERLINE_ACTION_PREFIX); --- 462,466 ---- } ! public final class UnderlineAction extends EditorAction { public UnderlineAction() { super(UNDERLINE_ACTION_PREFIX); *************** *** 457,461 **** } ! private final class StrikeThroughAction extends EditorAction { public StrikeThroughAction() { super(STRIKETHROUGH_ACTION_PREFIX); --- 475,479 ---- } ! public final class StrikeThroughAction extends EditorAction { public StrikeThroughAction() { super(STRIKETHROUGH_ACTION_PREFIX); *************** *** 470,474 **** } ! private final class CutAction extends EditorAction { public CutAction() { super(CUT_ACTION_PREFIX); --- 488,492 ---- } ! public final class CutAction extends EditorAction { public CutAction() { super(CUT_ACTION_PREFIX); *************** *** 480,484 **** } ! private final class CopyAction extends EditorAction { public CopyAction() { super(COPY_ACTION_PREFIX); --- 498,502 ---- } ! public final class CopyAction extends EditorAction { public CopyAction() { super(COPY_ACTION_PREFIX); *************** *** 490,494 **** } ! private final class PasteAction extends EditorAction { public PasteAction() { super(PASTE_ACTION_PREFIX); --- 508,512 ---- } ! public final class PasteAction extends EditorAction { public PasteAction() { super(PASTE_ACTION_PREFIX); *************** *** 500,504 **** } ! private final class BeepAction extends EditorAction { public BeepAction() { super(BEEP_ACTION_PREFIX); --- 518,522 ---- } ! public final class BeepAction extends EditorAction { public BeepAction() { super(BEEP_ACTION_PREFIX); *************** *** 510,514 **** } ! private final class SelectAllAction extends EditorAction { protected SelectAllAction() { super(SELECTALL_ACTION_PREFIX); --- 528,532 ---- } ! public final class SelectAllAction extends EditorAction { protected SelectAllAction() { super(SELECTALL_ACTION_PREFIX); *************** *** 522,526 **** } ! private final class SelectNoneAction extends EditorAction { protected SelectNoneAction() { super(SELECTNONE_ACTION_PREFIX); --- 540,544 ---- } ! public final class SelectNoneAction extends EditorAction { protected SelectNoneAction() { super(SELECTNONE_ACTION_PREFIX); *************** *** 538,542 **** } ! protected final class UndoAction extends EditorAction { protected UndoAction() { super(UNDO_ACTION_PREFIX); --- 556,560 ---- } ! public final class UndoAction extends EditorAction { protected UndoAction() { super(UNDO_ACTION_PREFIX); *************** *** 550,554 **** } ! private final class RedoAction extends EditorAction { protected RedoAction() { super(REDO_ACTION_PREFIX); --- 568,572 ---- } ! public final class RedoAction extends EditorAction { protected RedoAction() { super(REDO_ACTION_PREFIX); *************** *** 562,566 **** } ! private final class SearchAction extends EditorAction { public SearchAction(String nm, JFrame component) { super(nm); --- 580,584 ---- } ! public final class SearchAction extends EditorAction { public SearchAction(String nm, JFrame component) { super(nm); *************** *** 572,576 **** } ! private final class ReplaceAction extends EditorAction { public ReplaceAction(String nm, JFrame component) { --- 590,594 ---- } ! public final class ReplaceAction extends EditorAction { public ReplaceAction(String nm, JFrame component) { *************** *** 583,587 **** } ! private final class NewAction extends EditorAction { private FileActionListener m_listener; --- 601,605 ---- } ! public final class NewAction extends EditorAction { private FileActionListener m_listener; *************** *** 596,600 **** } ! private final class OpenAction extends EditorAction { private FileActionListener m_listener; --- 614,618 ---- } ! public final class OpenAction extends EditorAction { private FileActionListener m_listener; *************** *** 609,613 **** } ! private final class OpenAsAction extends EditorAction { private FileActionListener m_listener; --- 627,631 ---- } ! public final class OpenAsAction extends EditorAction { private FileActionListener m_listener; *************** *** 622,626 **** } ! private final class RevertAction extends EditorAction { private FileActionListener m_listener; --- 640,644 ---- } ! public final class RevertAction extends EditorAction { private FileActionListener m_listener; *************** *** 635,639 **** } ! private final class SaveAction extends EditorAction { private FileActionListener m_listener; --- 653,657 ---- } ! public final class SaveAction extends EditorAction { private FileActionListener m_listener; *************** *** 648,652 **** } ! private final class SaveAsAction extends EditorAction { private FileActionListener m_listener = null; --- 666,670 ---- } ! public final class SaveAsAction extends EditorAction { private FileActionListener m_listener = null; *************** *** 661,665 **** } ! private final class SaveCopyAction extends EditorAction { private FileActionListener m_listener; --- 679,683 ---- } ! public final class SaveCopyAction extends EditorAction { private FileActionListener m_listener; Index: ActionToolBar.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/ActionToolBar.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ActionToolBar.java 30 Oct 2005 15:55:47 -0000 1.7 --- ActionToolBar.java 16 Nov 2005 15:27:55 -0000 1.8 *************** *** 39,43 **** import com.jmonkey.office.lexi.support.images.Loader; ! public final class ActionToolBar extends JToolBar { /* registry of listeners created for Action-JButton * linkage. This is needed so that references can --- 39,43 ---- import com.jmonkey.office.lexi.support.images.Loader; ! public class ActionToolBar extends JToolBar { /* registry of listeners created for Action-JButton * linkage. This is needed so that references can |
From: Stephen C. <cr...@us...> - 2005-11-15 12:59:54
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30520/src/com/jmonkey/office/lexi/support/editors Modified Files: OfficeDocumentEditor.java OfficeDocumentEditorKit.java RTFEditor.java StyledEditor.java Log Message: Another tiny increment ... Index: StyledEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/StyledEditor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** StyledEditor.java 12 Nov 2005 13:56:38 -0000 1.5 --- StyledEditor.java 15 Nov 2005 12:59:46 -0000 1.6 *************** *** 284,288 **** m_editor.getCaret().setBlinkRate(300); Document doc = m_editor.getDocument(); - System.err.println("Document in StyledEditor is " + doc); // Event Listeners --- 284,287 ---- Index: OfficeDocumentEditorKit.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/OfficeDocumentEditorKit.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OfficeDocumentEditorKit.java 12 Nov 2005 13:56:38 -0000 1.1 --- OfficeDocumentEditorKit.java 15 Nov 2005 12:59:46 -0000 1.2 *************** *** 25,28 **** --- 25,29 ---- package com.jmonkey.office.lexi.support.editors; + import java.awt.event.ActionEvent; import java.io.IOException; import java.io.InputStream; *************** *** 31,42 **** import javax.swing.Action; import javax.swing.JEditorPane; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.Element; import javax.swing.text.LabelView; import javax.swing.text.MutableAttributeSet; import javax.swing.text.StyleConstants; import javax.swing.text.StyledEditorKit; - import javax.swing.text.TextAction; import javax.swing.text.View; import javax.swing.text.ViewFactory; --- 32,46 ---- import javax.swing.Action; import javax.swing.JEditorPane; + import javax.swing.text.BoxView; import javax.swing.text.BadLocationException; + import javax.swing.text.DefaultEditorKit; import javax.swing.text.Document; + import javax.swing.text.EditorKit; import javax.swing.text.Element; import javax.swing.text.LabelView; import javax.swing.text.MutableAttributeSet; + import javax.swing.text.ParagraphView; import javax.swing.text.StyleConstants; import javax.swing.text.StyledEditorKit; import javax.swing.text.View; import javax.swing.text.ViewFactory; *************** *** 50,61 **** * @author cr...@ds... */ ! public class OfficeDocumentEditorKit extends StyledEditorKit { ! private JEditorPane m_theEditor; /** Shared factory for creating ODF Views. */ private static final ViewFactory defaultFactory = new OfficeDocumentFactory(); - public static class OfficeDocumentFactory implements ViewFactory { /** --- 54,65 ---- * @author cr...@ds... */ ! public class OfficeDocumentEditorKit extends StyledEditorKit ! { ! private JEditorPane m_editor; /** Shared factory for creating ODF Views. */ private static final ViewFactory defaultFactory = new OfficeDocumentFactory(); public static class OfficeDocumentFactory implements ViewFactory { /** *************** *** 67,78 **** public View create(Element elem) { Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute); if (o instanceof ODFTag) { int kind = ((ODFTag) o).getKind(); switch (kind) { case ODFTag.PARAGRAPH_KIND: case ODFTag.HEADING_KIND: // paragraph ! return new javax.swing.text.html.ParagraphView(elem); ! } } // default to text display --- 71,89 ---- public View create(Element elem) { Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute); + // System.err.println("view: o = " + o); if (o instanceof ODFTag) { int kind = ((ODFTag) o).getKind(); switch (kind) { + case ODFTag.OFFICE_BODY_KIND: + case ODFTag.OFFICE_TEXT_KIND: + // body + return new BoxView(elem, View.Y_AXIS); case ODFTag.PARAGRAPH_KIND: case ODFTag.HEADING_KIND: // paragraph ! return new ParagraphView(elem); ! case ODFTag.CONTENT_KIND: ! return new LabelView(elem); ! } } // default to text display *************** *** 126,138 **** public void install(JEditorPane editor) { - // FIXME - add local listeners super.install(editor); ! m_theEditor = editor; } public void deinstall(JEditorPane editor) { ! // FIXME - remove local listeners super.deinstall(editor); ! m_theEditor = null; } --- 137,161 ---- public void install(JEditorPane editor) { super.install(editor); ! // FIXME - remove any local listeners ! m_editor = editor; ! } ! ! private Action getAction(String name) { ! EditorKit kit = m_editor.getEditorKit(); ! Action actions[] = kit.getActions(); ! for (int i = 0; i < actions.length; i++) { ! if (actions[i].getValue(Action.NAME).equals(name)) { ! System.err.println("got action: " + actions[i]); ! return actions[i]; ! } ! } ! return null; } public void deinstall(JEditorPane editor) { ! // FIXME - remove any local listeners super.deinstall(editor); ! m_editor = null; } Index: OfficeDocumentEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/OfficeDocumentEditor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OfficeDocumentEditor.java 12 Nov 2005 13:56:38 -0000 1.1 --- OfficeDocumentEditor.java 15 Nov 2005 12:59:46 -0000 1.2 *************** *** 33,36 **** --- 33,40 ---- import javax.swing.JEditorPane; + import javax.swing.KeyStroke; + import javax.swing.Action; + import javax.swing.text.EditorKit; + import javax.swing.text.Keymap; import javax.swing.text.BadLocationException; import javax.swing.text.StyledEditorKit; Index: RTFEditor.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/support/editors/RTFEditor.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** RTFEditor.java 31 Oct 2005 14:20:44 -0000 1.11 --- RTFEditor.java 15 Nov 2005 12:59:46 -0000 1.12 *************** *** 26,29 **** --- 26,32 ---- package com.jmonkey.office.lexi.support.editors; + import javax.swing.Action; + import javax.swing.text.Keymap; + import com.jmonkey.office.lexi.support.EditorActionManager; *************** *** 47,50 **** --- 50,58 ---- public RTFEditor(EditorActionManager eam) { super(eam, CONTENT_TYPE); + Keymap km = m_editor.getKeymap(); + Action actions[] = km.getBoundActions(); + for (int i = 0; i < actions.length; i++) { + System.err.println("action[" + i + "] is " + actions[i]); + } } |
From: Stephen C. <cr...@us...> - 2005-11-15 12:59:54
|
Update of /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30520/src/com/jmonkey/office/lexi/odf Modified Files: ODFContentHandler.java ODFTag.java OfficeDocument.java Log Message: Another tiny increment ... Index: ODFTag.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf/ODFTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ODFTag.java 12 Nov 2005 13:56:38 -0000 1.1 --- ODFTag.java 15 Nov 2005 12:59:46 -0000 1.2 *************** *** 46,52 **** // Unspecified text. ! public static final int TEXT_KIND = 5; public static final ODFTag CONTENT = ! new ODFTag("", TEXT_KIND); private final int m_kind; --- 46,52 ---- // Unspecified text. ! public static final int CONTENT_KIND = 5; public static final ODFTag CONTENT = ! new ODFTag("**content**", CONTENT_KIND); private final int m_kind; *************** *** 67,70 **** --- 67,74 ---- return m_name; } + + public String toString() { + return getName(); + } } Index: ODFContentHandler.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf/ODFContentHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ODFContentHandler.java 12 Nov 2005 13:56:38 -0000 1.1 --- ODFContentHandler.java 15 Nov 2005 12:59:46 -0000 1.2 *************** *** 25,30 **** package com.jmonkey.office.lexi.odf; - import java.util.HashMap; - import org.xml.sax.Attributes; import org.xml.sax.SAXException; --- 25,28 ---- Index: OfficeDocument.java =================================================================== RCS file: /cvsroot/lexi/lexi/src/com/jmonkey/office/lexi/odf/OfficeDocument.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OfficeDocument.java 12 Nov 2005 13:56:38 -0000 1.1 --- OfficeDocument.java 15 Nov 2005 12:59:46 -0000 1.2 *************** *** 27,30 **** --- 27,32 ---- import java.util.List; + import javax.swing.event.DocumentEvent; + import javax.swing.event.UndoableEditEvent; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; *************** *** 116,125 **** } ! protected Element createLeafElement(Element parent, AttributeSet a, int p0, int p1) { ! return new RunElement(parent, a, p0, p1); } protected Element createBranchElement(Element parent, AttributeSet a) { ! return new BlockElement(parent, a); } --- 118,130 ---- } ! protected Element createLeafElement(Element parent, AttributeSet a, ! int p0, int p1) { ! // System.err.println("OfficeDocument.createLeafElement"); ! return new RunElement(parent, a, p0, p1); } protected Element createBranchElement(Element parent, AttributeSet a) { ! // System.err.println("OfficeDocument.createBranchElement"); ! return new BlockElement(parent, a); } *************** *** 156,162 **** public void insertString(int offs, String str, AttributeSet attrs) throws BadLocationException { ! System.err.println("called insertString(" + offs + ", " + ! str + ", " + attrs + ")"); super.insertString(offs, str, attrs); } --- 161,168 ---- public void insertString(int offs, String str, AttributeSet attrs) throws BadLocationException { ! // System.err.println("called insertString(" + offs + ", " + ! // str + ", " + attrs + ")"); super.insertString(offs, str, attrs); + // this.dump(System.err); } *************** *** 168,170 **** --- 174,196 ---- super.insertUpdate(change, attrs); } + + + protected void fireChangedUpdate(DocumentEvent e) { + super.fireChangedUpdate(e); + } + + protected void fireInsertUpdate(DocumentEvent e) { + super.fireInsertUpdate(e); + } + + protected void fireRemoveUpdate(DocumentEvent e) { + super.fireRemoveUpdate(e); + } + + + protected void fireUndoableEditUpdate(UndoableEditEvent e) { + super.fireUndoableEditUpdate(e); + } + + } |