diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt index cad6aed..0767bb6 100644 --- a/source/distro/changelog.txt +++ b/source/distro/changelog.txt @@ -1,7 +1,11 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2 + ---------- version 1.1.7 ---------- +[w2x] The option use_dublin_core no longer has effect on EPUB export (instead identifier, author, date and title are always + exported, and other properties are exported if they exist and are non-empty) + [w2x] Added opf:file-as attribute to EPUB metadata (creators and contributors) [w2x] EPUB meta data can now be edited directly from the export dialog diff --git a/source/distro/doc/user-manual.odt b/source/distro/doc/user-manual.odt index 84e3772..64ca00d 100644 Binary files a/source/distro/doc/user-manual.odt and b/source/distro/doc/user-manual.odt differ diff --git a/source/java/org/openoffice/da/comp/w2lcommon/helper/DialogAccess.java b/source/java/org/openoffice/da/comp/w2lcommon/helper/DialogAccess.java index 0cf0019..dfcae5a 100644 --- a/source/java/org/openoffice/da/comp/w2lcommon/helper/DialogAccess.java +++ b/source/java/org/openoffice/da/comp/w2lcommon/helper/DialogAccess.java @@ -16,11 +16,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * - * Copyright: 2002-2009 by Henrik Just + * Copyright: 2002-2011 by Henrik Just * * All Rights Reserved. * - * Version 1.2 (2009-11-08) + * Version 1.2 (2011-03-03) * */ @@ -275,6 +275,27 @@ public class DialogAccess { // Will fail if the control does not exist or is not a formatted field } } + + public int getDateFieldValue(String sControlName) { + XPropertySet xPropertySet = getControlProperties(sControlName); + try { + return ((Integer) xPropertySet.getPropertyValue("Date")).intValue(); + } + catch (Exception e) { + // Will fail if the control does not exist or is not a date field + return 0; + } + } + + public void setDateFieldValue(String sControlName, int nValue) { + XPropertySet xPropertySet = getControlProperties(sControlName); + try { + xPropertySet.setPropertyValue("Date", nValue); + } + catch (Exception e) { + // Will fail if the control does not exist or is not a date field + } + } public int getNumericFieldValue(String sControlName) { XPropertySet xPropertySet = getControlProperties(sControlName); diff --git a/source/java/org/openoffice/da/comp/w2lcommon/helper/DialogBase.java b/source/java/org/openoffice/da/comp/w2lcommon/helper/DialogBase.java index 2f1268a..8dacc93 100644 --- a/source/java/org/openoffice/da/comp/w2lcommon/helper/DialogBase.java +++ b/source/java/org/openoffice/da/comp/w2lcommon/helper/DialogBase.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2011-02-23) + * Version 1.2 (2011-02-25) * */ @@ -391,7 +391,7 @@ public abstract class DialogBase implements // Will fail if the control does not exist or is not a text field } } - + protected String getFormattedFieldText(String sControlName) { XPropertySet xPropertySet = getControlProperties(sControlName); try { diff --git a/source/java/org/openoffice/da/comp/writer2xhtml/EpubMetadataDialog.java b/source/java/org/openoffice/da/comp/writer2xhtml/EpubMetadataDialog.java index c544690..7c74c3e 100644 --- a/source/java/org/openoffice/da/comp/writer2xhtml/EpubMetadataDialog.java +++ b/source/java/org/openoffice/da/comp/writer2xhtml/EpubMetadataDialog.java @@ -20,15 +20,19 @@ * * All Rights Reserved. * - * Version 1.2 (2011-02-24) + * Version 1.2 (2011-03-05) * */ package org.openoffice.da.comp.writer2xhtml; +import java.text.DecimalFormat; +import java.text.NumberFormat; import java.util.HashMap; import java.util.HashSet; import java.util.Vector; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.openoffice.da.comp.w2lcommon.helper.DialogBase; import org.openoffice.da.comp.w2lcommon.helper.SimpleDialog; @@ -56,6 +60,9 @@ import com.sun.star.uno.AnyConverter; import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; +import com.sun.star.util.DateTime; + +// TODO: Create the UNO helper class DocumentPropertiesAccess /** This class provides a UNO component which implements a custom metadata editor UI for the EPUB export */ @@ -67,6 +74,12 @@ public class EpubMetadataDialog extends DialogBase { String sRole = ""; } + // Date data + private class DateInfo { + int nDate = 0; + String sEvent = ""; + } + // All the user defined properties we handle private static final String IDENTIFIER="Identifier"; private static final String CREATOR="Creator"; @@ -98,6 +111,13 @@ public class EpubMetadataDialog extends DialogBase { // Author and date bookkeeping private Vector authors = new Vector(); + private Vector dates = new Vector(); + + // Number formatter + private NumberFormat formatter = new DecimalFormat("00"); + + // Pattern matcher for dates + Pattern datePattern = Pattern.compile("(\\d{4})-(\\d{2})-(\\d{2})"); public EpubMetadataDialog(XComponentContext xContext) { super(xContext); @@ -151,13 +171,19 @@ public class EpubMetadataDialog extends DialogBase { else if (sMethod.equals("DateDeleteClick")) { return dateDeleteClick(); } + else if (sMethod.equals("DateUpClick")) { + return dateUpClick(); + } + else if (sMethod.equals("DateDownClick")) { + return dateDownClick(); + } return false; } @Override public String[] getSupportedMethodNames() { String[] sNames = { "UseCustomIdentifierChange", "AuthorAddClick", "AuthorModifyClick", "AuthorDeleteClick", "AuthorUpClick", "AuthorDownClick", - "DataAddClick", "DateModifyClick", "DateDeleteClick"}; + "DataAddClick", "DateModifyClick", "DateDeleteClick", "DateUpClick", "DateDownClick"}; return sNames; } @@ -247,17 +273,74 @@ public class EpubMetadataDialog extends DialogBase { } private boolean dateAddClick() { - System.out.println("DateAddClick"); + SimpleDialog dialog = new SimpleDialog(xContext,"W2XDialogs2.DateDialog"); + if (dialog.getDialog()!=null) { + dialog.getControls().setDateFieldValue("Date", datetime2int(xDocumentProperties.getModificationDate())); + if (dialog.getDialog().execute()==ExecutableDialogResults.OK) { + DateInfo date = new DateInfo(); + date.nDate = dialog.getControls().getDateFieldValue("Date"); + date.sEvent = dialog.getControls().getTextFieldText("Event").trim(); + dates.add(date); + updateDateList((short) (dates.size()-1)); + } + dialog.getDialog().endExecute(); + } return true; } private boolean dateModifyClick() { - System.out.println("DateModifyClick"); + short nIndex = getListBoxSelectedItem("Dates"); + DateInfo date = dates.get(nIndex); + SimpleDialog dialog = new SimpleDialog(xContext,"W2XDialogs2.DateDialog"); + if (dialog.getDialog()!=null) { + dialog.getControls().setDateFieldValue("Date", date.nDate); + dialog.getControls().setTextFieldText("Event", date.sEvent); + if (dialog.getDialog().execute()==ExecutableDialogResults.OK) { + date.nDate = dialog.getControls().getDateFieldValue("Date"); + date.sEvent = dialog.getControls().getTextFieldText("Event").trim(); + updateDateList(nIndex); + } + dialog.getDialog().endExecute(); + } return true; } private boolean dateDeleteClick() { - System.out.println("DateDeleteClick"); + if (dates.size()>0) { + SimpleDialog dialog = new SimpleDialog(xContext,"W2XDialogs2.DeleteDialog"); + if (dialog.getDialog()!=null) { + short nIndex = getListBoxSelectedItem("Dates"); + String sLabel = dialog.getControls().getLabelText("DeleteLabel"); + sLabel = sLabel.replaceAll("%s", formatDate(dates.get(nIndex).nDate)); + dialog.getControls().setLabelText("DeleteLabel", sLabel); + if (dialog.getDialog().execute()==ExecutableDialogResults.OK) { + dates.remove(nIndex); + updateDateList(nIndex0) { + DateInfo date = dates.get(nIndex); + dates.set(nIndex, dates.get(nIndex-1)); + dates.set(nIndex-1, date); + updateDateList((short) (nIndex-1)); + } + return true; + } + + private boolean dateDownClick() { + short nIndex = getListBoxSelectedItem("Dates"); + if (nIndex+10); useCustomIdentifierChange(); if (sIdentifiers.length>0) { // Use the first if we have several... - setTextFieldText("Identifier",getValue(sIdentifiers[0])); + setTextFieldText("Identifier",getStringValue(sIdentifiers[0])); setTextFieldText("IdentifierType",getSuffix(sIdentifiers[0])); } @@ -296,7 +379,7 @@ public class EpubMetadataDialog extends DialogBase { String[] sCreators = getProperties(CREATOR,false); for (String sCreator : sCreators) { AuthorInfo creator = new AuthorInfo(); - creator.sName = getValue(sCreator); + creator.sName = getStringValue(sCreator); creator.sRole = getSuffix(sCreator); creator.isCreator = true; authors.add(creator); @@ -304,7 +387,7 @@ public class EpubMetadataDialog extends DialogBase { String[] sContributors = getProperties(CONTRIBUTOR,false); for (String sContributor : sContributors) { AuthorInfo contributor = new AuthorInfo(); - contributor.sName = getValue(sContributor); + contributor.sName = getStringValue(sContributor); contributor.sRole = getSuffix(sContributor); contributor.isCreator = false; authors.add(contributor); @@ -312,7 +395,19 @@ public class EpubMetadataDialog extends DialogBase { updateAuthorList((short) 0); // Get the dates and set the list box - // TODO + String[] sDates = getProperties(DATE,false); + for (String sDate : sDates) { + DateInfo date = new DateInfo(); + DateTime dt = getDateValue(sDate); + if (dt!=null) { // We accept either a date + date.nDate = datetime2int(dt); + } + else { // Or a string in the form yyyy-mm-dd + date.nDate = parseDate(getStringValue(sDate)); + } + date.sEvent = getSuffix(sDate); + dates.add(date); + } updateDateList((short) 0); // Get the standard properties and set the text fields @@ -363,7 +458,7 @@ public class EpubMetadataDialog extends DialogBase { } int i=0; for (AuthorInfo author : authors) { - String sName = (author.isCreator ? CREATOR : CONTRIBUTOR)+(++i); + String sName = (author.isCreator ? CREATOR : CONTRIBUTOR)+formatter.format(++i); if (author.sRole.length()>0) { sName+="."+author.sRole; } @@ -372,7 +467,21 @@ public class EpubMetadataDialog extends DialogBase { } // Set the dates from the list box - // TODO + String[] sDates = getProperties(DATE,false); + for (String sDate : sDates) { // remove old dates + removeProperty(sDate); + } + i=0; + for (DateInfo date : dates) { + String sName = DATE+formatter.format(++i); + if (date.sEvent.length()>0) { + sName+="."+date.sEvent; + } + addProperty(sName); + setValue(sName,formatDate(date.nDate)); + // Doesn't work (why not?) + //setValue(sName,int2datetime(date.nDate)); + } // Set the standard properties from the text fields xDocumentProperties.setTitle(getTextFieldText("Title")); @@ -435,9 +544,9 @@ public class EpubMetadataDialog extends DialogBase { } // Set the value of a user property (failing silently if the property does not exist) - private void setValue(String sName, String sValue) { + private void setValue(String sName, Object value) { try { - xUserPropertySet.setPropertyValue(sName, sValue); + xUserPropertySet.setPropertyValue(sName, value); } catch (UnknownPropertyException e) { } catch (PropertyVetoException e) { } catch (IllegalArgumentException e) { @@ -445,18 +554,11 @@ public class EpubMetadataDialog extends DialogBase { } } - // Get the value of a user property (returning null if the property does not exist) - private String getValue(String sName) { - Object value; - try { - value = xUserPropertySet.getPropertyValue(sName); - } catch (UnknownPropertyException e) { - return null; - } catch (WrappedTargetException e) { - return null; - } - - if (AnyConverter.isString(value)) { + // Get the string value of a user property (returning null if the property does not exist) + private String getStringValue(String sName) { + Object value = getValue(sName); + + if (value!=null && AnyConverter.isString(value)) { try { return AnyConverter.toString(value); } catch (IllegalArgumentException e) { @@ -466,19 +568,48 @@ public class EpubMetadataDialog extends DialogBase { return null; } + private DateTime getDateValue(String sName) { + Object value = getValue(sName); + + if (value!=null && value instanceof DateTime) { + return (DateTime) value; + } + return null; + } + + // Get the value of a user property (returning null if the property does not exist) + private Object getValue(String sName) { + try { + return xUserPropertySet.getPropertyValue(sName); + } catch (UnknownPropertyException e) { + return null; + } catch (WrappedTargetException e) { + return null; + } + } + private void updateAuthorList(short nItem) { int nCount = authors.size(); - String[] sAuthors = new String[nCount]; - for (int i=0; i0) { + String[] sAuthors = new String[nCount]; + for (int i=0; i0 ? ", "+author.sRole : "") +")"; + } + setListBoxStringItemList("Authors", sAuthors); + setListBoxSelectedItem("Authors",nItem); + setControlEnabled("Authors", true); + } + else { // Display the fall-back author + String[] sAuthors = new String[1]; + sAuthors[0] = xDocumentProperties.getAuthor()+" (default creator)"; + setListBoxStringItemList("Authors", sAuthors); + setControlEnabled("Authors", false); } - setListBoxStringItemList("Authors", sAuthors); - setListBoxSelectedItem("Authors",nItem); setControlEnabled("ModifyAuthorButton",nCount>0); setControlEnabled("DeleteAuthorButton",nCount>0); setControlEnabled("AuthorUpButton",nCount>1); @@ -486,15 +617,36 @@ public class EpubMetadataDialog extends DialogBase { } private void updateDateList(short nItem) { - setControlEnabled("AddDateButton",false); - setControlEnabled("ModifyDateButton",false); - setControlEnabled("DeleteDateButton",false); + int nCount = dates.size(); + if (nCount>0) { + String[] sDates = new String[nCount]; + for (int i=0; i0) { + sDates[i]+=" (" + date.sEvent + ")"; + } + } + setListBoxStringItemList("Dates", sDates); + setListBoxSelectedItem("Dates",nItem); + setControlEnabled("Dates", true); + } + else { // Display the fall-back date + String[] sDates = new String[1]; + sDates[0] = formatDate(datetime2int(xDocumentProperties.getModificationDate()))+" (default date)"; + setListBoxStringItemList("Dates", sDates); + setControlEnabled("Dates", false); + } + setControlEnabled("ModifyDateButton",nCount>0); + setControlEnabled("DeleteDateButton",nCount>0); + setControlEnabled("DateUpButton",nCount>1); + setControlEnabled("DateDownButton",nCount>1); } private void readSimpleProperty(String sName) { String[] sNames = getProperties(sName,true); if (sNames.length>0) { - String sValue = getValue(sNames[0]); + String sValue = getStringValue(sNames[0]); if (sValue!=null) { setTextFieldText(sName, sValue); } @@ -513,5 +665,44 @@ public class EpubMetadataDialog extends DialogBase { } } + // Date fields uses integers for dates (format yyyymmdd) + // Document properties uses com.sun.star.util.DateTime + // Also dates should be formatted as yyyy-mm-dd as strings + // Thus we need a few conversion methods + + // Format a integer date as yyyy-mm-dd + private String formatDate(int nDate) { + String sDate = Integer.toString(nDate); + if (sDate.length()==8) { + return sDate.substring(0,4)+"-"+sDate.substring(4, 6)+"-"+sDate.substring(6); + } + else { + return "???"; + } + } + + // Parse a string as a date in the format yyyy-mm-dd (returning 0 on failure) + private int parseDate(String sDate) { + Matcher matcher = datePattern.matcher(sDate); + if (matcher.matches()) { + return Misc.getPosInteger(matcher.group(1)+matcher.group(2)+matcher.group(3),0); + } + return 0; + } + + // Convert an integer to com.sun.star.util.DateTime + /*private DateTime int2datetime(int nDate) { + DateTime date = new DateTime(); + date.Year = (short) (nDate/10000); + date.Month = (short) ((nDate%10000)/100); + date.Day = (short) (nDate%100); + System.out.println(date.Year+"-"+date.Month+"-"+date.Day); + return date; + }*/ + + // Convert a com.sun.star.util.DateTime to integer + private int datetime2int(DateTime date) { + return 10000*date.Year+100*date.Month+date.Day; + } } diff --git a/source/java/org/openoffice/da/comp/writer2xhtml/EpubOptionsDialog.java b/source/java/org/openoffice/da/comp/writer2xhtml/EpubOptionsDialog.java index 457583e..d112825 100644 --- a/source/java/org/openoffice/da/comp/writer2xhtml/EpubOptionsDialog.java +++ b/source/java/org/openoffice/da/comp/writer2xhtml/EpubOptionsDialog.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2011-02-23) + * Version 1.2 (2011-03-04) * */ @@ -96,7 +96,6 @@ public class EpubOptionsDialog extends OptionsDialogBase { // Special content loadCheckBoxOption(xProps, "DisplayHiddenText"); loadCheckBoxOption(xProps, "Notes"); - loadCheckBoxOption(xProps, "UseDublinCore"); // Document division loadCheckBoxOption(xProps, "Split"); @@ -143,7 +142,6 @@ public class EpubOptionsDialog extends OptionsDialogBase { // Special content saveCheckBoxOption(xProps, helper, "DisplayHiddenText", "display_hidden_text"); saveCheckBoxOption(xProps, helper, "Notes", "notes"); - saveCheckBoxOption(xProps, helper, "UseDublinCore", "use_dublin_core"); // Document division boolean bSplit = saveCheckBoxOption(xProps, "Split"); @@ -241,7 +239,6 @@ public class EpubOptionsDialog extends OptionsDialogBase { setControlEnabled("DefaultFontNameLabel",!isLocked("default_font_name") && bUseDefaultFont); setControlEnabled("DefaultFontName",!isLocked("default_font_name") && bUseDefaultFont); - setControlEnabled("DisplayHiddenText",!isLocked("display_hidden_text")); setControlEnabled("ConvertToPx",!isLocked("convert_to_px")); setControlEnabled("OriginalImageSize",!isLocked("original_image_size")); @@ -251,8 +248,8 @@ public class EpubOptionsDialog extends OptionsDialogBase { setControlEnabled("IgnoreDoubleSpaces",!isLocked("ignore_double_spaces")); // Special content + setControlEnabled("DisplayHiddenText",!isLocked("display_hidden_text")); setControlEnabled("Notes",!isLocked("notes")); - setControlEnabled("UseDublinCore",!isLocked("use_dublin_core")); // Document division boolean bSplit = getCheckBoxStateAsBoolean("Split"); diff --git a/source/java/writer2latex/api/ConverterFactory.java b/source/java/writer2latex/api/ConverterFactory.java index 48bc6b0..c745e05 100644 --- a/source/java/writer2latex/api/ConverterFactory.java +++ b/source/java/writer2latex/api/ConverterFactory.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2011-02-24) + * Version 1.2 (2011-03-05) * */ @@ -33,7 +33,7 @@ public class ConverterFactory { // Version information private static final String VERSION = "1.1.7"; - private static final String DATE = "2011-02-24"; + private static final String DATE = "2011-03-05"; /** Return the Writer2LaTeX version in the form * (major version).(minor version).(patch level)
diff --git a/source/java/writer2latex/epub/EPUBWriter.java b/source/java/writer2latex/epub/EPUBWriter.java index 1d6bfa2..217f98a 100644 --- a/source/java/writer2latex/epub/EPUBWriter.java +++ b/source/java/writer2latex/epub/EPUBWriter.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * version 1.2 (2011-02-23) + * version 1.2 (2011-03-04) * */ @@ -89,7 +89,7 @@ public class EPUBWriter implements OutputFile { zos.closeEntry(); // Then manifest - OPFWriter manifest = new OPFWriter(xhtmlResult, config.xhtmlUseDublinCore()); + OPFWriter manifest = new OPFWriter(xhtmlResult); ZipEntry manifestEntry = new ZipEntry("OEBPS/book.opf"); zos.putNextEntry(manifestEntry); writeZipEntry(manifest,zos); diff --git a/source/java/writer2latex/epub/OPFWriter.java b/source/java/writer2latex/epub/OPFWriter.java index 9209dec..2018004 100644 --- a/source/java/writer2latex/epub/OPFWriter.java +++ b/source/java/writer2latex/epub/OPFWriter.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * version 1.2 (2011-02-24) + * version 1.2 (2011-03-04) * */ @@ -51,7 +51,7 @@ import writer2latex.xmerge.NewDOMDocument; public class OPFWriter extends NewDOMDocument { private String sUID=null; - public OPFWriter(ConverterResult cr, boolean bUseDublinCore) { + public OPFWriter(ConverterResult cr) { super("book", "opf"); // create DOM @@ -79,25 +79,23 @@ public class OPFWriter extends NewDOMDocument { metadata.setAttribute("xmlns:opf", "http://www.idpf.org/2007/opf"); pack.appendChild(metadata); + // Title and language (required) appendElement(contentDOM, metadata, "dc:title", cr.getMetaData().getTitle()); appendElement(contentDOM, metadata, "dc:language", cr.getMetaData().getLanguage()); - // Additional meta data - if (bUseDublinCore) { - // Subject and keywords in ODF both map to Dublin core subjects - if (cr.getMetaData().getSubject().length()>0) { - appendElement(contentDOM, metadata, "dc:subject", cr.getMetaData().getSubject()); - } - if (cr.getMetaData().getKeywords().length()>0) { - String[] sKeywords = cr.getMetaData().getKeywords().split(","); - for (String sKeyword : sKeywords) { - appendElement(contentDOM, metadata, "dc:subject", sKeyword.trim()); - } - } - if (cr.getMetaData().getDescription().length()>0) { - appendElement(contentDOM, metadata, "dc:description", cr.getMetaData().getDescription()); + // Subject and keywords in ODF both map to Dublin core subjects + if (cr.getMetaData().getSubject().length()>0) { + appendElement(contentDOM, metadata, "dc:subject", cr.getMetaData().getSubject()); + } + if (cr.getMetaData().getKeywords().length()>0) { + String[] sKeywords = cr.getMetaData().getKeywords().split(","); + for (String sKeyword : sKeywords) { + appendElement(contentDOM, metadata, "dc:subject", sKeyword.trim()); } } + if (cr.getMetaData().getDescription().length()>0) { + appendElement(contentDOM, metadata, "dc:description", cr.getMetaData().getDescription()); + } // User defined meta data // The identifier, creator, contributor and date has an optional attribute and there may be multiple instances of @@ -108,88 +106,86 @@ public class OPFWriter extends NewDOMDocument { boolean bHasIdentifier = false; boolean bHasCreator = false; boolean bHasDate = false; - if (bUseDublinCore) { - // First rearrange the user-defined meta data - Map userDefinedMetaData = cr.getMetaData().getUserDefinedMetaData(); - Map dc = new HashMap(); - for (String sKey : userDefinedMetaData.keySet()) { - if (sKey.length()>0) { - String[] sValue = new String[2]; - sValue[0] = userDefinedMetaData.get(sKey); - String sNewKey; - int nDot = sKey.indexOf("."); - if (nDot>0) { - sNewKey = sKey.substring(0, nDot).toLowerCase(); - sValue[1] = sKey.substring(nDot+1); - } - else { - sNewKey = sKey.toLowerCase(); - sValue[1] = null; - } - dc.put(sNewKey, sValue); + // First rearrange the user-defined meta data + Map userDefinedMetaData = cr.getMetaData().getUserDefinedMetaData(); + Map dc = new HashMap(); + for (String sKey : userDefinedMetaData.keySet()) { + if (sKey.length()>0) { + String[] sValue = new String[2]; + sValue[0] = userDefinedMetaData.get(sKey); + String sNewKey; + int nDot = sKey.indexOf("."); + if (nDot>0) { + sNewKey = sKey.substring(0, nDot).toLowerCase(); + sValue[1] = sKey.substring(nDot+1); + } + else { + sNewKey = sKey.toLowerCase(); + sValue[1] = null; + } + dc.put(sNewKey, sValue); + } + } + // Then export it + String[] sKeys = Misc.sortStringSet(dc.keySet()); + for (String sKey : sKeys) { + String sValue = dc.get(sKey)[0]; + String sAttributeValue = dc.get(sKey)[1]; + if (sKey.startsWith("identifier")) { + Element identifier = appendElement(contentDOM, metadata, "dc:identifier", sValue); + if (!bHasIdentifier) { // The first identifier is the unique ID + identifier.setAttribute("id", "BookId"); + sUID = sValue; + } + if (sAttributeValue!=null) { + identifier.setAttribute("opf:scheme", sAttributeValue); + } + bHasIdentifier = true; + } + else if (sKey.startsWith("creator")) { + Element creator = appendElement(contentDOM, metadata, "dc:creator", sValue); + creator.setAttribute("opf:file-as", fileAs(sValue)); + if (sAttributeValue!=null) { + creator.setAttribute("opf:role", sAttributeValue); + } + bHasCreator = true; + } + else if (sKey.startsWith("contributor")) { + Element contributor = appendElement(contentDOM, metadata, "dc:contributor", sValue); + contributor.setAttribute("opf:file-as", fileAs(sValue)); + if (sAttributeValue!=null) { + contributor.setAttribute("opf:role", sAttributeValue); } } - // Then export it - String[] sKeys = Misc.sortStringSet(dc.keySet()); - for (String sKey : sKeys) { - String sValue = dc.get(sKey)[0]; - String sAttributeValue = dc.get(sKey)[1]; - if (sKey.startsWith("identifier")) { - Element identifier = appendElement(contentDOM, metadata, "dc:identifier", sValue); - if (!bHasIdentifier) { // The first identifier is the unique ID - identifier.setAttribute("id", "BookId"); - sUID = sValue; - } - if (sAttributeValue!=null) { - identifier.setAttribute("opf:scheme", sAttributeValue); - } - bHasIdentifier = true; + else if (sKey.startsWith("date")) { + Element date = appendElement(contentDOM, metadata, "dc:date", sValue); + if (sAttributeValue!=null) { + date.setAttribute("opf:event", sAttributeValue); } - else if (sKey.startsWith("creator")) { - Element creator = appendElement(contentDOM, metadata, "dc:creator", sValue); - creator.setAttribute("opf:file-as", fileAs(sValue)); - if (sAttributeValue!=null) { - creator.setAttribute("opf:role", sAttributeValue); - } - bHasCreator = true; + bHasDate = true; + } + // Remaining properties must be unique and has not attributes, hence + else if (sAttributeValue==null) { + if ("publisher".equals(sKey)) { + appendElement(contentDOM, metadata, "dc:publisher", sValue); } - else if (sKey.startsWith("contributor")) { - Element contributor = appendElement(contentDOM, metadata, "dc:contributor", sValue); - contributor.setAttribute("opf:file-as", fileAs(sValue)); - if (sAttributeValue!=null) { - contributor.setAttribute("opf:role", sAttributeValue); - } + else if ("type".equals(sKey)) { + appendElement(contentDOM, metadata, "dc:type", sValue); } - else if (sKey.startsWith("date")) { - Element date = appendElement(contentDOM, metadata, "dc:date", sValue); - if (sAttributeValue!=null) { - date.setAttribute("opf:event", sAttributeValue); - } - bHasDate = true; + else if ("format".equals(sKey)) { + appendElement(contentDOM, metadata, "dc:format", sValue); } - // Remaining properties must be unique and has not attributes, hence - else if (sAttributeValue==null) { - if ("publisher".equals(sKey)) { - appendElement(contentDOM, metadata, "dc:publisher", sValue); - } - else if ("type".equals(sKey)) { - appendElement(contentDOM, metadata, "dc:type", sValue); - } - else if ("format".equals(sKey)) { - appendElement(contentDOM, metadata, "dc:format", sValue); - } - else if ("source".equals(sKey)) { - appendElement(contentDOM, metadata, "dc:source", sValue); - } - else if ("relation".equals(sKey)) { - appendElement(contentDOM, metadata, "dc:relation", sValue); - } - else if ("coverage".equals(sKey)) { - appendElement(contentDOM, metadata, "dc:coverage", sValue); - } - else if ("rights".equals(sKey)) { - appendElement(contentDOM, metadata, "dc:rights", sValue); - } + else if ("source".equals(sKey)) { + appendElement(contentDOM, metadata, "dc:source", sValue); + } + else if ("relation".equals(sKey)) { + appendElement(contentDOM, metadata, "dc:relation", sValue); + } + else if ("coverage".equals(sKey)) { + appendElement(contentDOM, metadata, "dc:coverage", sValue); + } + else if ("rights".equals(sKey)) { + appendElement(contentDOM, metadata, "dc:rights", sValue); } } } @@ -202,15 +198,14 @@ public class OPFWriter extends NewDOMDocument { identifier.setAttribute("id", "BookId"); identifier.setAttribute("opf:scheme", "UUID"); } - if (bUseDublinCore) { - if (!bHasCreator && cr.getMetaData().getCreator().length()>0) { - appendElement(contentDOM, metadata, "dc:creator", cr.getMetaData().getCreator()); - } - if (!bHasDate && cr.getMetaData().getDate().length()>0) { - // TODO: Support meta:creation-date? - appendElement(contentDOM, metadata, "dc:date", cr.getMetaData().getDate()); - } - } + if (!bHasCreator && cr.getMetaData().getCreator().length()>0) { + appendElement(contentDOM, metadata, "dc:creator", cr.getMetaData().getCreator()) + .setAttribute("opf:file-as", fileAs(cr.getMetaData().getCreator())); + } + if (!bHasDate && cr.getMetaData().getDate().length()>0) { + // TODO: Support meta:creation-date? + appendElement(contentDOM, metadata, "dc:date", cr.getMetaData().getDate()); + } // Manifest must contain references to all the files in the XHTML converter result // Spine should contain references to all the master documents within the converter result diff --git a/source/oxt/writer2xhtml/W2XDialogs2/EpubMetadata.xdl b/source/oxt/writer2xhtml/W2XDialogs2/EpubMetadata.xdl index 10042fb..06b562e 100644 --- a/source/oxt/writer2xhtml/W2XDialogs2/EpubMetadata.xdl +++ b/source/oxt/writer2xhtml/W2XDialogs2/EpubMetadata.xdl @@ -19,58 +19,64 @@ - + - + - + - + - + - - - - + + + + - + - + - + - + - + - + - + - + - + - - - - - + + + + + - + - + - + + + + + + + \ No newline at end of file diff --git a/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl b/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl index 890deae..7351a51 100755 --- a/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl +++ b/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl @@ -21,7 +21,6 @@ - @@ -90,7 +89,7 @@ - + diff --git a/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/epub_metadata.xhp b/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/epub_metadata.xhp index 21ee9cc..597b3b8 100644 --- a/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/epub_metadata.xhp +++ b/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/epub_metadata.xhp @@ -13,14 +13,15 @@
Choose File - Export - EPUB, Click Edit in the dialog
+ The EPUB standard specifies a large number of document properties. Not all of these are supported by the OpenDocument standard. Writer2xhtml supports the additional properties using user defined document properties. This dialog provides a convenient interface to edit all EPUB document properties, but you can also access all properties using the standard interface in %PRODUCTNAME Writer, that is File - Properties. - Properties that are not required can be left blank. In this case they will not be included in the EPUB document (except the - title which is always included). + Writer2xhtml will always include the identifier, author(s), date(s) and the title. + Other fields are optional and can be left blank. In this case they will not be included in the EPUB document. Custom identifier @@ -45,9 +46,11 @@ An author can be either a creator, that is a primary author of the publication, or a contributor, that is a party whose contribution to the publication is secondary to the creator(s). Furthermore an author may have a special role, e.g. illustrator. Both properties are specified when you add - a new authort to the list. + a new author to the list. Note that some EPUB readers may only present the first creator, hence - the order may be important + you should make sure that the primary creator is at the top of the list. + If you do not add any authors, Writer2xhtml will display and use a default value + for the author. Add... Click this to add new author to the list. @@ -68,6 +71,10 @@ Dates An EPUB document can specify one or more dates relating to the publication. Each date can be associated with a special event such as creation, publication or modification. + Note that some EPUB readers may only present the first date, hence + you should make sure that the primary date is at the top of the list. + If you do not add any dates, Writer2xhtml will display and use a default value + for the date (date of last modification). Add... Click this to add new date to the list. @@ -78,9 +85,16 @@ Delete... Click this to delete the currently selected date from the list. + Up + Click this to move the currently selected date up one position in the list. + + Down + Click this to move the currently selected date down one position in the list. + + Title - The title of the document. This will always be included in the EPUB document, - even if you have not selected Export optional document properties. + The title of the document. This will always be included in the EPUB + document. Subject The subject of the document