pax_global_header 0000666 0000000 0000000 00000000064 12255017477 0014524 g ustar 00root root 0000000 0000000 52 comment=a2f9985a496ac139d416f83e92af2bcbf8b42fac
accessodf-0.1.1~b/ 0000775 0000000 0000000 00000000000 12255017477 0014015 5 ustar 00root root 0000000 0000000 accessodf-0.1.1~b/accessodf-addon/ 0000775 0000000 0000000 00000000000 12255017477 0017032 5 ustar 00root root 0000000 0000000 accessodf-0.1.1~b/accessodf-addon/pom.xml 0000664 0000000 0000000 00000010055 12255017477 0020350 0 ustar 00root root 0000000 0000000
4.0.0
be.docarch
accessodf
0.1.0-SNAPSHOT
accessodf-addon
0.1.0-SNAPSHOT
oxt
accessodf :: Addon
be.docarch
accessodf-api
org.libreoffice
juh
org.libreoffice
jurt
org.libreoffice
ridl
org.libreoffice
unoil
src/main/resources
be/docarch/accessodf/ooo/l10n
target/l10n/bundles/checks
be/docarch/accessodf/ooo/toolpanel/l10n
target/l10n/bundles/toolpanel
be.docarch
l10n-maven-plugin
checks.ods
toolpanel.ods
maven-dependency-plugin
copy-dependencies
prepare-package
copy-dependencies
target/oxt/lib
runtime
be.docarch
oxt-maven-plugin
be.docarch.accessodf.ooo.AccessODFAddOn
be.docarch.accessodf.ooo.toolpanel.ToolPanelFactory
be.docarch.accessodf.ooo.optionspage.DialogEventHandler
lib/*.jar
src/main/oxt
description.xml
META-INF/manifest.xml
src/main/oxt
description.xml
META-INF/manifest.xml
true
target/oxt
debian
maven-dependency-plugin
2.8
copy-dependencies
none
build-classpath
prepare-package
build-classpath
classpath
:
runtime
be.docarch
oxt-maven-plugin
${classpath}
accessodf-0.1.1~b/accessodf-addon/src/ 0000775 0000000 0000000 00000000000 12255017477 0017621 5 ustar 00root root 0000000 0000000 accessodf-0.1.1~b/accessodf-addon/src/main/ 0000775 0000000 0000000 00000000000 12255017477 0020545 5 ustar 00root root 0000000 0000000 accessodf-0.1.1~b/accessodf-addon/src/main/java/ 0000775 0000000 0000000 00000000000 12255017477 0021466 5 ustar 00root root 0000000 0000000 accessodf-0.1.1~b/accessodf-addon/src/main/java/be/ 0000775 0000000 0000000 00000000000 12255017477 0022054 5 ustar 00root root 0000000 0000000 accessodf-0.1.1~b/accessodf-addon/src/main/java/be/docarch/ 0000775 0000000 0000000 00000000000 12255017477 0023457 5 ustar 00root root 0000000 0000000 accessodf-0.1.1~b/accessodf-addon/src/main/java/be/docarch/accessodf/ 0000775 0000000 0000000 00000000000 12255017477 0025411 5 ustar 00root root 0000000 0000000 accessodf-0.1.1~b/accessodf-addon/src/main/java/be/docarch/accessodf/ooo/ 0000775 0000000 0000000 00000000000 12255017477 0026205 5 ustar 00root root 0000000 0000000 accessodf-0.1.1~b/accessodf-addon/src/main/java/be/docarch/accessodf/ooo/AccessODFAddOn.java 0000664 0000000 0000000 00000017634 12255017477 0031523 0 ustar 00root root 0000000 0000000 /**
* AccessODF - Accessibility checker for OpenOffice.org and LibreOffice Writer.
*
* Copyright (c) 2011 by DocArch .
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
package be.docarch.accessodf.ooo;
import java.io.File;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.logging.Handler;
import java.util.logging.FileHandler;
import java.util.logging.SimpleFormatter;
import com.sun.star.beans.XPropertySet;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.frame.XModel;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.XLayoutManager;
import com.sun.star.frame.XDesktop;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.registry.XRegistryKey;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.lib.uno.helper.Factory;
import be.docarch.accessodf.Constants;
public final class AccessODFAddOn extends WeakBase
implements com.sun.star.lang.XInitialization,
com.sun.star.frame.XDispatch,
com.sun.star.lang.XServiceInfo,
com.sun.star.frame.XDispatchProvider
{
private final XComponentContext m_xContext;
private com.sun.star.frame.XFrame m_xFrame;
private static final String m_implementationName = AccessODFAddOn.class.getName();
private static final String[] m_serviceNames = {
"com.sun.star.frame.ProtocolHandler" };
private static final Logger logger = Logger.getLogger(Constants.LOGGER_NAME);
private static final String TMP_NAME = Constants.TMP_PREFIX;
private static final File TMP_DIR = Constants.getTmpDirectory();
private Handler fh = null;
private File logFile = null;
private int counter = 0;
public AccessODFAddOn( XComponentContext context )
{
m_xContext = context;
try {
logFile = File.createTempFile(TMP_NAME, ".log", TMP_DIR);
fh = new FileHandler(logFile.getAbsolutePath());
fh.setFormatter(new SimpleFormatter());
Logger.getLogger("").addHandler(fh);
Logger.getLogger("").setLevel(Level.FINEST);
} catch (java.io.IOException ex) {
logger.log(Level.SEVERE, null, ex);
} catch (RuntimeException ex) {
logger.log(Level.SEVERE, null, ex);
}
};
public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
XSingleComponentFactory xFactory = null;
if ( sImplementationName.equals( m_implementationName ) )
xFactory = Factory.createComponentFactory(AccessODFAddOn.class, m_serviceNames);
return xFactory;
}
public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) {
return Factory.writeRegistryServiceInfo(m_implementationName,
m_serviceNames,
xRegistryKey);
}
// com.sun.star.lang.XInitialization:
public void initialize( Object[] object )
throws com.sun.star.uno.Exception
{
if ( object.length > 0 )
{
m_xFrame = (com.sun.star.frame.XFrame)UnoRuntime.queryInterface(
com.sun.star.frame.XFrame.class, object[0]);
}
}
// com.sun.star.frame.XDispatch:
public void dispatch( com.sun.star.util.URL aURL,
com.sun.star.beans.PropertyValue[] aArguments ) {
logger.info(String.valueOf(counter++));
if ( aURL.Protocol.startsWith("be.docarch.accessodf.ooo.accessodfaddon")) {
if ( aURL.Path.compareTo("TaskPanelCommand") == 0 ) {
try {
XMultiComponentFactory xMCF = (XMultiComponentFactory) UnoRuntime.queryInterface(
XMultiComponentFactory.class, m_xContext.getServiceManager());
Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext);
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop);
XComponent doc = (XComponent)xDesktop.getCurrentComponent();
XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, doc);
XFrame xFrame = xModel.getCurrentController().getFrame();
XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xFrame);
XLayoutManager xLayoutManager = (XLayoutManager) UnoRuntime.queryInterface(
XLayoutManager.class, xPropertySet.getPropertyValue("LayoutManager"));
String toolPanel = "private:resource/toolpanel/be.docarch.accessibility.ooo.toolpanel";
if (xLayoutManager.isElementVisible(toolPanel)) { // geeft altijd false
xLayoutManager.hideElement(toolPanel);
} else {
xLayoutManager.showElement(toolPanel);
}
} catch (Exception e) {
logger.log(Level.SEVERE, null, e);
}
return;
}
}
}
public void addStatusListener( com.sun.star.frame.XStatusListener xControl,
com.sun.star.util.URL aURL )
{
// add your own code here
}
public void removeStatusListener( com.sun.star.frame.XStatusListener xControl,
com.sun.star.util.URL aURL )
{
// add your own code here
}
// com.sun.star.lang.XServiceInfo:
public String getImplementationName() {
return m_implementationName;
}
public boolean supportsService( String sService ) {
int len = m_serviceNames.length;
for( int i=0; i < len; i++) {
if (sService.equals(m_serviceNames[i]))
return true;
}
return false;
}
public String[] getSupportedServiceNames() {
return m_serviceNames;
}
// com.sun.star.frame.XDispatchProvider:
public com.sun.star.frame.XDispatch queryDispatch( com.sun.star.util.URL aURL,
String sTargetFrameName,
int iSearchFlags )
{
if ( aURL.Protocol.startsWith("be.docarch.accessodf.ooo.accessodfaddon"))
{
if ( aURL.Path.compareTo("TaskPanelCommand") == 0 )
return this;
}
return null;
}
// com.sun.star.frame.XDispatchProvider:
public com.sun.star.frame.XDispatch[] queryDispatches(
com.sun.star.frame.DispatchDescriptor[] seqDescriptors )
{
int nCount = seqDescriptors.length;
com.sun.star.frame.XDispatch[] seqDispatcher =
new com.sun.star.frame.XDispatch[seqDescriptors.length];
for( int i=0; i < nCount; ++i )
{
seqDispatcher[i] = queryDispatch(seqDescriptors[i].FeatureURL,
seqDescriptors[i].FrameName,
seqDescriptors[i].SearchFlags );
}
return seqDispatcher;
}
}
accessodf-0.1.1~b/accessodf-addon/src/main/java/be/docarch/accessodf/ooo/CheckerProvider.java 0000664 0000000 0000000 00000004470 12255017477 0032134 0 ustar 00root root 0000000 0000000 /**
* AccessODF - Accessibility checker for OpenOffice.org and LibreOffice Writer.
*
* Copyright (c) 2011 by DocArch .
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
package be.docarch.accessodf.ooo;
import be.docarch.accessodf.Constants;
import be.docarch.accessodf.Checker;
import be.docarch.accessodf.Provider;
import java.util.Collection;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.imageio.spi.ServiceRegistry;
/**
*
* @author Bert Frees
*/
public class CheckerProvider implements Provider {
private static final Logger logger = Logger.getLogger(Constants.LOGGER_NAME);
private final Map checkers;
public CheckerProvider(ClassLoader classLoader,
Document document) {
checkers = new HashMap();
Checker checker;
Iterator i = ServiceRegistry.lookupProviders(Checker.class, classLoader);
while (i.hasNext()) {
checker = i.next();
checkers.put(checker.getIdentifier(), checker);
logger.info(checker.getIdentifier() + " loaded");
}
try {
Checker mainChecker = new MainChecker(document);
checkers.put(mainChecker.getIdentifier(), mainChecker);
logger.info(mainChecker.getIdentifier() + " loaded");
} catch (Exception e) {
logger.log(Level.SEVERE, null, e);
}
}
public Collection list() {
return checkers.values();
}
public Checker get(String identifier) {
return checkers.get(identifier);
}
}
accessodf-0.1.1~b/accessodf-addon/src/main/java/be/docarch/accessodf/ooo/Comment.java 0000664 0000000 0000000 00000005431 12255017477 0030455 0 ustar 00root root 0000000 0000000 /**
* AccessODF - Accessibility checker for OpenOffice.org and LibreOffice Writer.
*
* Copyright (c) 2011 by DocArch .
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
package be.docarch.accessodf.ooo;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.beans.XPropertySet;
import com.sun.star.text.XTextContent;
import com.sun.star.text.XTextCursor;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.beans.PropertyVetoException;
/**
*
* @author Bert Frees
*/
public class Comment {
XTextContent annotation = null;
XPropertySet annotationProps = null;
public Comment(XMultiServiceFactory xMSF)
throws UnknownPropertyException,
WrappedTargetException,
IllegalArgumentException,
PropertyVetoException,
com.sun.star.uno.Exception {
annotation = (XTextContent)UnoRuntime.queryInterface(
XTextContent.class, xMSF.createInstance("com.sun.star.text.textfield.Annotation"));
annotationProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, annotation);
setAuthor("Accessibility checker");
}
public void setAuthor(String author)
throws UnknownPropertyException,
PropertyVetoException,
WrappedTargetException,
IllegalArgumentException {
annotationProps.setPropertyValue("Author", author);
}
public void setContent(String content)
throws UnknownPropertyException,
PropertyVetoException,
WrappedTargetException,
IllegalArgumentException {
annotationProps.setPropertyValue("Content", content);
}
public void insertCommentAtCursor(XTextCursor cursor)
throws IllegalArgumentException{
cursor.getText().insertTextContent(cursor.getStart(), annotation, true);
}
}
accessodf-0.1.1~b/accessodf-addon/src/main/java/be/docarch/accessodf/ooo/ConfigurationAccess.java 0000664 0000000 0000000 00000005530 12255017477 0033004 0 ustar 00root root 0000000 0000000 /**
* AccessODF - Accessibility checker for OpenOffice.org and LibreOffice Writer.
*
* Copyright (c) 2011 by DocArch .
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
package be.docarch.accessodf.ooo;
import com.sun.star.beans.PropertyState;
import com.sun.star.beans.PropertyValue;
import com.sun.star.container.XNameAccess;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
/**
* Provides generic factory methods around configuration access.
* @author Christian Lins (christian.lins@sun.com)
*/
public class ConfigurationAccess
{
/**
* Creates a XNameAccess instance for read and write access to the
* configuration at the given node path.
* @param context
* @param path
* @return
*/
public static XNameAccess createUpdateAccess(XComponentContext context, String path)
{
XNameAccess access;
// Create the com.sun.star.configuration.ConfigurationUpdateAccess
// for the registry node which contains the data for our option
// pages.
XMultiServiceFactory xConfig;
try
{
xConfig = (XMultiServiceFactory) UnoRuntime.queryInterface(
XMultiServiceFactory.class,
context.getServiceManager().createInstanceWithContext(
"com.sun.star.configuration.ConfigurationProvider", context));
}
catch (com.sun.star.uno.Exception e)
{
e.printStackTrace();
return null;
}
// One argument for creating the ConfigurationUpdateAccess is the "nodepath".
// Our nodepath point to the node of which the direct subnodes represent the
// different options pages.
Object[] args = new Object[1];
args[0] = new PropertyValue("nodepath", 0, path,PropertyState.DIRECT_VALUE);
// We get the com.sun.star.container.XNameAccess from the instance of
// ConfigurationUpdateAccess and save it for later use.
try
{
access = (XNameAccess) UnoRuntime.queryInterface(
XNameAccess.class, xConfig.createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess", args));
}
catch (com.sun.star.uno.Exception e)
{
e.printStackTrace();
return null;
}
return access;
}
}
accessodf-0.1.1~b/accessodf-addon/src/main/java/be/docarch/accessodf/ooo/DaisyCheck.java 0000664 0000000 0000000 00000006464 12255017477 0031071 0 ustar 00root root 0000000 0000000 /**
* AccessODF - Accessibility checker for OpenOffice.org and LibreOffice Writer.
*
* Copyright (c) 2011 by DocArch .
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
package be.docarch.accessodf.ooo;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
import be.docarch.accessodf.Check;
/**
*
* @author Bert Frees
*/
public class DaisyCheck extends Check {
private static final String L10N_BUNDLE = "be/docarch/accessodf/ooo/l10n/checks";
public static enum ID {
E_UnsupportedImageFormat,
A_EmptyTitleField,
A_BodyMatterStartSectionNested,
A_RearMatterStartSectionNested
}
private ID identifier;
public DaisyCheck(ID identifier) {
this.identifier = identifier;
}
public String getIdentifier() {
return identifier.name();
}
public Status getStatus() {
if (identifier.name().startsWith("E_")) {
return Status.ERROR;
} else if (identifier.name().startsWith("A_")) {
return Status.ALERT;
} else {
return null;
}
}
public String getName(Locale locale) {
if (identifier == null) {
return null;
}
try {
ResourceBundle bundle = ResourceBundle.getBundle(L10N_BUNDLE, locale);
return bundle.getString("name_" + identifier.name());
} catch (MissingResourceException e) {
return identifier.name();
}
}
public String getDescription(Locale locale) {
if (identifier == null) {
return null;
}
try {
ResourceBundle bundle = ResourceBundle.getBundle(L10N_BUNDLE, locale);
return bundle.getString("description_" + identifier.name());
} catch (MissingResourceException e) {
switch (identifier) {
case A_BodyMatterStartSectionNested:
return "The section \"BodyMatterStart\" is placed inside another section. odt2daisy will not recognize it.";
case A_RearMatterStartSectionNested:
return "The section \"RearMatterStart\" is placed inside another section. odt2daisy will not recognize it.";
default:
return "";
}
}
}
public String getSuggestion(Locale locale) {
if (identifier == null) {
return null;
}
try {
ResourceBundle bundle = ResourceBundle.getBundle(L10N_BUNDLE, locale);
return bundle.getString("suggestion_" + identifier.name());
} catch (MissingResourceException e) {
return "";
}
}
}
accessodf-0.1.1~b/accessodf-addon/src/main/java/be/docarch/accessodf/ooo/Document.java 0000664 0000000 0000000 00000037473 12255017477 0030644 0 ustar 00root root 0000000 0000000 /**
* AccessODF - Accessibility checker for OpenOffice.org and LibreOffice Writer.
*
* Copyright (c) 2011 by DocArch .
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
package be.docarch.accessodf.ooo;
import java.io.File;
import java.util.logging.Logger;
import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.AnyConverter;
import com.sun.star.util.XModifiable;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XModel;
import com.sun.star.frame.XStorable;
import com.sun.star.frame.XDesktop;
import com.sun.star.document.XDocumentPropertiesSupplier;
import com.sun.star.document.XDocumentProperties;
import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.PropertyValue;
import com.sun.star.container.XEnumerationAccess;
import com.sun.star.container.XEnumeration;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer;
import com.sun.star.container.XIndexAccess;
import com.sun.star.table.XCell;
import com.sun.star.text.XTextDocument;
import com.sun.star.text.XTextContent;
import com.sun.star.text.XTextFramesSupplier;
import com.sun.star.text.XTextFrame;
import com.sun.star.text.XTextTable;
import com.sun.star.text.XTextTablesSupplier;
import com.sun.star.text.XTextGraphicObjectsSupplier;
import com.sun.star.text.XTextEmbeddedObjectsSupplier;
import com.sun.star.text.XTextViewCursor;
import com.sun.star.text.XTextViewCursorSupplier;
import com.sun.star.view.XSelectionSupplier;
import com.sun.star.style.XStyleFamiliesSupplier;
import com.sun.star.rdf.XDocumentMetadataAccess;
import com.sun.star.rdf.XRepository;
import com.sun.star.rdf.XURI;
import com.sun.star.rdf.URI;
import com.sun.star.rdf.XMetadatable;
import java.io.IOException;
import java.net.MalformedURLException;
import com.sun.star.beans.PropertyVetoException;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.IndexOutOfBoundsException;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.datatransfer.UnsupportedFlavorException;
import com.sun.star.container.ElementExistException;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.rdf.ParseException;
import com.sun.star.rdf.RepositoryException;
import be.docarch.accessodf.Constants;
/**
*
* @author Bert Frees
*/
public class Document {
private static final Logger logger = Logger.getLogger(Constants.LOGGER_NAME);
public XComponentContext xContext = null;
public XMultiServiceFactory xMSF = null;
public XMultiComponentFactory xMCF = null;
public XDocumentMetadataAccess xDMA = null;
public XRepository xRepository = null;
public XModel xModel = null;
public XComponent doc = null;
public XNameContainer paragraphStyles = null;
public XNameContainer characterStyles = null;
public XNameAccess tables = null;
public XNameAccess embeddedObjects = null;
public XNameAccess graphicObjects = null;
public XSelectionSupplier selectionSupplier = null;
public XTextViewCursor viewCursor = null;
public XDocumentProperties docProperties = null;
public XPropertySet docPropertySet = null;
public XURI metaFolderURI = null;
public XTextDocument textDocument = null;
public String metaFolder = "meta/";
private PropertyValue[] conversionProperties = null;
private XStorable storable = null;
private XModifiable xModifiable = null;
private XTextContent firstParagraph = null;
private boolean readOnly = false;
public Document(XComponentContext xContext)
throws com.sun.star.uno.Exception {
logger.entering("Document", "");
this.xContext = xContext;
xMCF = (XMultiComponentFactory) UnoRuntime.queryInterface(
XMultiComponentFactory.class, xContext.getServiceManager());
Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop);
doc = (XComponent)xDesktop.getCurrentComponent();
initDocument();
logger.exiting("Document", "");
}
public Document(String unoUrl,
XComponentContext xContext)
throws com.sun.star.uno.Exception {
logger.entering("Document", "");
this.xContext = xContext;
xMCF = (XMultiComponentFactory) UnoRuntime.queryInterface(
XMultiComponentFactory.class, xContext.getServiceManager());
Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface(
XComponentLoader.class, desktop);
PropertyValue[] loadProps = new PropertyValue[1];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "ReadOnly";
loadProps[0].Value = new Boolean(false);
doc = loader.loadComponentFromURL(unoUrl, "_blank", 0, loadProps);
initDocument();
logger.exiting("Document", "");
}
private void initDocument() throws com.sun.star.uno.Exception {
URIs.init(xContext);
textDocument = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, doc);
xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, textDocument);
xModel = (XModel) UnoRuntime.queryInterface(XModel.class, textDocument);
xDMA = (XDocumentMetadataAccess)UnoRuntime.queryInterface(XDocumentMetadataAccess.class, xModel);
xRepository = xDMA.getRDFRepository();
metaFolderURI = URI.create(xContext, xDMA.getNamespace() + metaFolder);
XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)UnoRuntime.queryInterface(
XStyleFamiliesSupplier.class, textDocument);
XNameAccess xFamilies = (XNameAccess)UnoRuntime.queryInterface (
XNameAccess.class, xSupplier.getStyleFamilies());
paragraphStyles = (XNameContainer)UnoRuntime.queryInterface(
XNameContainer.class, xFamilies.getByName("ParagraphStyles"));
characterStyles = (XNameContainer)UnoRuntime.queryInterface(
XNameContainer.class, xFamilies.getByName("CharacterStyles"));
XTextTablesSupplier tablesSupplier =
(XTextTablesSupplier)UnoRuntime.queryInterface(
XTextTablesSupplier.class, doc);
tables = tablesSupplier.getTextTables();
XTextGraphicObjectsSupplier textGraphicObjectsSupplier =
(XTextGraphicObjectsSupplier)UnoRuntime.queryInterface(
XTextGraphicObjectsSupplier.class, doc);
XTextEmbeddedObjectsSupplier textEmbeddedObjectsSupplier =
(XTextEmbeddedObjectsSupplier)UnoRuntime.queryInterface(
XTextEmbeddedObjectsSupplier.class, doc);
embeddedObjects = textEmbeddedObjectsSupplier.getEmbeddedObjects();
graphicObjects = textGraphicObjectsSupplier.getGraphicObjects();
selectionSupplier = (XSelectionSupplier)UnoRuntime.queryInterface(
XSelectionSupplier.class, xModel.getCurrentController());
XTextViewCursorSupplier xViewCursorSupplier =
(XTextViewCursorSupplier)UnoRuntime.queryInterface(
XTextViewCursorSupplier.class, xModel.getCurrentController());
viewCursor = xViewCursorSupplier.getViewCursor();
XDocumentPropertiesSupplier xDocPropSuppl = (XDocumentPropertiesSupplier) UnoRuntime.queryInterface(
XDocumentPropertiesSupplier.class, textDocument);
docProperties = xDocPropSuppl.getDocumentProperties();
docPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, doc);
Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
XDesktop xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class, desktop);
xModifiable = (XModifiable)UnoRuntime.queryInterface(XModifiable.class, xDesktop.getCurrentComponent());
conversionProperties = new PropertyValue[1];
conversionProperties[0] = new PropertyValue();
conversionProperties[0].Name = "FilterName";
conversionProperties[0].Value = "writer8";
storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xModel);
for (PropertyValue prop: xModel.getArgs()) {
if (prop.Name.equals("ReadOnly")) {
readOnly = (Boolean)AnyConverter.toBoolean(prop.Value);
break;
}
}
}
public void storeToFile(File output)
throws MalformedURLException,
com.sun.star.io.IOException {
logger.entering("Document", "storeToFile");
String outputUnoUrl = UnoUtils.createUnoFileURL(output.getAbsolutePath(), xContext);
storable.storeToURL(outputUnoUrl, conversionProperties);
logger.exiting("Document", "storeToFile");
}
public void removeAccessibilityData(String checkerID) {
try {
XURI type = URI.create(xContext, checkerID);
for (XURI graph : xDMA.getMetadataGraphsWithType(type)) {
xDMA.removeMetadataFile(graph);
}
} catch (IllegalArgumentException e) {
} catch (NoSuchElementException e) {
}
}
public void importAccessibilityData(File earlReport,
String checkerID,
String graphName)
throws IOException,
IllegalArgumentException,
UnsupportedFlavorException,
ParseException,
NoSuchElementException,
WrappedTargetException,
RepositoryException,
com.sun.star.io.IOException {
logger.entering("Document", "importAccessibilityData");
InputStream inputStream = InputStream.newInstance(earlReport);
XURI[] types = new XURI[]{ URI.create(xContext, checkerID) };
XURI graphURI = null;
try {
graphURI = xDMA.importMetadataFile((short)0, inputStream, metaFolder + graphName, metaFolderURI, types);
} catch (ElementExistException ex) {
graphURI = URI.create(xContext, metaFolderURI.getStringValue() + graphName);
xDMA.removeMetadataFile(graphURI);
try {
xDMA.importMetadataFile((short)0, inputStream, metaFolder + graphName, metaFolderURI, types);
} catch (ElementExistException e) {
}
}
logger.exiting("Document", "importAccessibilityData");
}
public void ensureMetadataReferences() throws NoSuchElementException,
WrappedTargetException,
IndexOutOfBoundsException {
XEnumerationAccess enumerationAccess = (XEnumerationAccess)UnoRuntime.queryInterface(
XEnumerationAccess.class, textDocument.getText());
XEnumeration paragraphs = enumerationAccess.createEnumeration();
while (paragraphs.hasMoreElements()) {
ensureMetadataReferences(paragraphs.nextElement());
}
XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) UnoRuntime.queryInterface(
XTextFramesSupplier.class, doc);
XIndexAccess textFrames = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class, xTextFramesSupplier.getTextFrames());
XTextFrame frame = null;
XEnumeration paragraphsInFrame = null;
for (int i=0; i