当前位置: 首页>>代码示例>>Java>>正文


Java XStorable类代码示例

本文整理汇总了Java中com.sun.star.frame.XStorable的典型用法代码示例。如果您正苦于以下问题:Java XStorable类的具体用法?Java XStorable怎么用?Java XStorable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XStorable类属于com.sun.star.frame包,在下文中一共展示了XStorable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadAndExport

import com.sun.star.frame.XStorable; //导入依赖的package包/类
/**
 * Load and export.
 * @param inputStream
 *            the input stream
 * @param importOptions
 *            the import options
 * @param outputStream
 *            the output stream
 * @param exportOptions
 *            the export options
 * @throws Exception
 *             the exception
 */
@SuppressWarnings("unchecked")
private void loadAndExport(InputStream inputStream, Map/* <String,Object> */importOptions,
		OutputStream outputStream, Map/* <String,Object> */exportOptions) throws Exception {
	XComponentLoader desktop = openOfficeConnection.getDesktopObject();

	Map/* <String,Object> */loadProperties = new HashMap();
	loadProperties.putAll(getDefaultLoadProperties());
	loadProperties.putAll(importOptions);
	// doesn't work using InputStreamToXInputStreamAdapter; probably because
	// it's not XSeekable
	// property("InputStream", new
	// InputStreamToXInputStreamAdapter(inputStream))
	loadProperties.put("InputStream", new ByteArrayToXInputStreamAdapter(IOUtils.toByteArray(inputStream))); //$NON-NLS-1$

	XComponent document = desktop.loadComponentFromURL(
			"private:stream", "_blank", 0, toPropertyValues(loadProperties)); //$NON-NLS-1$ //$NON-NLS-2$
	if (document == null) {
		throw new OPException(Messages.getString("ooconverter.StreamOpenOfficeDocumentConverter.6")); //$NON-NLS-1$
	}

	refreshDocument(document);

	Map/* <String,Object> */storeProperties = new HashMap();
	storeProperties.putAll(exportOptions);
	storeProperties.put("OutputStream", new OutputStreamToXOutputStreamAdapter(outputStream)); //$NON-NLS-1$

	try {
		XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, document);
		storable.storeToURL("private:stream", toPropertyValues(storeProperties)); //$NON-NLS-1$
	} finally {
		document.dispose();
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:47,代码来源:StreamOpenOfficeDocumentConverter.java

示例2: saveTo

import com.sun.star.frame.XStorable; //导入依赖的package包/类
public File saveTo(File location) {
    try {
        location = location.getAbsoluteFile();
        String targetUrl = "file://" + location.toString();

        XStorable xStorable = UnoRuntime.queryInterface(XStorable.class, doc);
        PropertyValue[] docArgs = new PropertyValue[1];
        docArgs[0] = new PropertyValue();
        docArgs[0].Name = "Overwrite";
        docArgs[0].Value = Boolean.TRUE;
        xStorable.storeAsURL(targetUrl, docArgs);

        return location;
    } catch (IOException e) {
        throw new LibreOfficeException(e);
    }
}
 
开发者ID:kamax-io,项目名称:libreoffice4j,代码行数:18,代码来源:SpreadsheetDocument.java

示例3: storeDocument

import com.sun.star.frame.XStorable; //导入依赖的package包/类
private void storeDocument(XComponent document, File outputFile) throws OfficeException {
	Map<String, ?> storeProperties = getStoreProperties(outputFile, document);
	if (storeProperties == null) {
		throw new OfficeException("unsupported conversion");
	}
	try {
		PropertyValue[] storeProps = new PropertyValue[1];
		storeProps[0] = new PropertyValue();
		storeProps[0].Name = "FilterName";
		storeProps[0].Value = "writer_pdf_Export";
		cast(XStorable.class, document).storeToURL(toUrl(outputFile), storeProps);
	} catch (ErrorCodeIOException errorCodeIOException) {
		throw new OfficeException("could not store document: " + outputFile.getName() + "; errorCode: "
				+ errorCodeIOException.ErrCode, errorCodeIOException);
	} catch (IOException ioException) {
		throw new OfficeException("could not store document: " + outputFile.getName(), ioException);
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:19,代码来源:AbstractConversionTask.java

示例4: exportDocument

import com.sun.star.frame.XStorable; //导入依赖的package包/类
/**
 * Exports document on the basis of the submitted filter and URL.
 * 
 * @param document document to be exported
 * @param URL URL to be used
 * @param filter OpenOffice.org filter to be used
 * @param properties properties properties for OpenOffice.org
 * 
 * @throws IOException if any error occurs
 */
public static void exportDocument(IDocument document, String URL, IFilter filter, PropertyValue[] properties) 
throws IOException {
  if(properties == null) {
    properties = new PropertyValue[0];
  }
  PropertyValue[] newProperties = new PropertyValue[properties.length + 1];
  for(int i=0; i<properties.length; i++) {
    newProperties[i] = properties[i];
  }
      
  newProperties[properties.length] = new PropertyValue(); 
  newProperties[properties.length].Name = "FilterName"; 
  newProperties[properties.length].Value = filter.getFilterDefinition(document);
  
  XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, document.getXComponent());
  try {
    xStorable.storeToURL(URL, newProperties);
  }
  catch(com.sun.star.io.IOException ioException) {
    throw new IOException(ioException.getMessage());
  }    
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:33,代码来源:DocumentExporter.java

示例5: storeDocument

import com.sun.star.frame.XStorable; //导入依赖的package包/类
/**
 * Stores document to the submitted URL.
 * 
 * @param document document to be stored
 * @param URL URL to be used
 * @param properties properties for OpenOffice.org
 * 
 * @throws IOException if any error occurs
 */
public static void storeDocument(IDocument document, String URL, PropertyValue[] properties) 
  throws IOException {
  if(URL == null) {
    URL = "";
  }
  if(properties == null && URL.length() == 0) {
    properties = new PropertyValue[0];
  }
  XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, document.getXComponent());
  try {
    if(URL.length() != 0) {
      xStorable.storeToURL(URL, properties);
    }
    else {
      xStorable.store();
    }
  }
  catch(com.sun.star.io.IOException ioException) {
    throw new IOException(ioException.getMessage());
  }    
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:31,代码来源:DocumentWriter.java

示例6: storeDocument

import com.sun.star.frame.XStorable; //导入依赖的package包/类
/**
 * Store document.
 * @param document
 *            the document
 * @param outputUrl
 *            the output url
 * @param storeProperties
 *            the store properties
 */
@SuppressWarnings("unchecked")
private void storeDocument(XComponent document, String outputUrl, Map storeProperties)
		throws com.sun.star.io.IOException {
	try {
		XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, document);
		storable.storeToURL(outputUrl, toPropertyValues(storeProperties));
	} finally {
		XCloseable closeable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, document);
		if (closeable != null) {
			try {
				closeable.close(true);
			} catch (CloseVetoException closeVetoException) {
				if (Converter.DEBUG_MODE) {
					closeVetoException.printStackTrace();
				}
			}
		} else {
			document.dispose();
		}
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:31,代码来源:OpenOfficeDocumentConverter.java

示例7: storeDocument

import com.sun.star.frame.XStorable; //导入依赖的package包/类
private void storeDocument(XComponent document, File outputFile) throws OfficeException {
    Map<String,?> storeProperties = getStoreProperties(outputFile, document);
    if (storeProperties == null) {
        throw new OfficeException("unsupported conversion");
    }
    try {
        cast(XStorable.class, document).storeToURL(toUrl(outputFile), toUnoProperties(storeProperties));
    } catch (ErrorCodeIOException errorCodeIOException) {
        throw new OfficeException("could not store document: " + outputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
    } catch (IOException ioException) {
        throw new OfficeException("could not store document: " + outputFile.getName(), ioException);
    }
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:14,代码来源:AbstractConversionTask.java

示例8: getPersistenceService

import com.sun.star.frame.XStorable; //导入依赖的package包/类
/**
 * Returns persistence service.
 * 
 * @return persistence service
 * 
 * @author Andreas Bröker
 */
public IPersistenceService getPersistenceService() {
	if (persistenceService == null) {
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(
				XStorable.class, xComponent);
		persistenceService = new PersistenceService(this, xStorable);
	}
	return persistenceService;
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:16,代码来源:AbstractDocument.java

示例9: saveXComponent

import com.sun.star.frame.XStorable; //导入依赖的package包/类
public void saveXComponent(XComponent xComponent, XOutputStream xOutputStream, String filterName) throws IOException {
    PropertyValue[] props = new PropertyValue[2];
    props[0] = new PropertyValue();
    props[1] = new PropertyValue();
    props[0].Name = "OutputStream";
    props[0].Value = xOutputStream;
    props[1].Name = "FilterName";
    props[1].Value = filterName;
    XStorable xStorable = as(XStorable.class, xComponent);
    xStorable.storeToURL("private:stream", props);
}
 
开发者ID:cuba-platform,项目名称:yarg,代码行数:12,代码来源:OfficeResourceProvider.java

示例10: convertOODocToFile

import com.sun.star.frame.XStorable; //导入依赖的package包/类
public static void convertOODocToFile(XMultiComponentFactory xmulticomponentfactory, String fileInPath, String fileOutPath, String outputMimeType) throws FileNotFoundException, IOException, MalformedURLException, Exception {
    // Converting the document to the favoured type
    // Query for the XPropertySet interface.
    XPropertySet xpropertysetMultiComponentFactory = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory);

    // Get the default context from the office server.
    Object objectDefaultContext = xpropertysetMultiComponentFactory.getPropertyValue("DefaultContext");

    // Query for the interface XComponentContext.
    XComponentContext xcomponentcontext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, objectDefaultContext);

    /* A desktop environment contains tasks with one or more
       frames in which components can be loaded. Desktop is the
       environment for components which can instanciate within
       frames. */

    Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext);
    //XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj);
    XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj);


    // Preparing properties for loading the document
    PropertyValue propertyvalue[] = new PropertyValue[ 2 ];
    // Setting the flag for hidding the open document
    propertyvalue[ 0 ] = new PropertyValue();
    propertyvalue[ 0 ].Name = "Hidden";
    propertyvalue[ 0 ].Value = Boolean.valueOf(false);

    propertyvalue[ 1 ] = new PropertyValue();
    propertyvalue[ 1 ].Name = "UpdateDocMode";
    propertyvalue[ 1 ].Value = "1";

    // Loading the wanted document
    String stringUrl = convertToUrl(fileInPath, xcomponentcontext);
    Debug.logInfo("stringUrl:" + stringUrl, module);
    Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(stringUrl, "_blank", 0, propertyvalue);

    // Getting an object that will offer a simple way to store a document to a URL.
    XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore);

    // Preparing properties for converting the document
    propertyvalue = new PropertyValue[ 3 ];
    // Setting the flag for overwriting
    propertyvalue[ 0 ] = new PropertyValue();
    propertyvalue[ 0 ].Name = "Overwrite";
    propertyvalue[ 0 ].Value = Boolean.valueOf(true);
    // Setting the filter name
    // Preparing properties for converting the document
    String filterName = getFilterNameFromMimeType(outputMimeType);

    propertyvalue[ 1 ] = new PropertyValue();
    propertyvalue[ 1 ].Name = "FilterName";
    propertyvalue[ 1 ].Value = filterName;

    propertyvalue[2] = new PropertyValue();
    propertyvalue[2].Name = "CompressionMode";
    propertyvalue[2].Value = "1";

    // Storing and converting the document
    //File newFile = new File(stringConvertedFile);
    //newFile.createNewFile();

    String stringConvertedFile = convertToUrl(fileOutPath, xcomponentcontext);
    Debug.logInfo("stringConvertedFile: "+stringConvertedFile, module);
    xstorable.storeToURL(stringConvertedFile, propertyvalue);

    // Getting the method dispose() for closing the document
    XComponent xcomponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xstorable);

    // Closing the converted document
    xcomponent.dispose();
    return;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:74,代码来源:OpenOfficeWorker.java

示例11: convertOODocByteStreamToByteStream

import com.sun.star.frame.XStorable; //导入依赖的package包/类
public static OpenOfficeByteArrayOutputStream convertOODocByteStreamToByteStream(XMultiComponentFactory xmulticomponentfactory,
        OpenOfficeByteArrayInputStream is, String inputMimeType, String outputMimeType) throws Exception {

    // Query for the XPropertySet interface.
    XPropertySet xpropertysetMultiComponentFactory = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory);

    // Get the default context from the office server.
    Object objectDefaultContext = xpropertysetMultiComponentFactory.getPropertyValue("DefaultContext");

    // Query for the interface XComponentContext.
    XComponentContext xcomponentcontext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, objectDefaultContext);

    /* A desktop environment contains tasks with one or more
       frames in which components can be loaded. Desktop is the
       environment for components which can instanciate within
       frames. */

    Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext);
    //XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj);
    XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj);

    // Preparing properties for loading the document
    PropertyValue propertyvalue[] = new PropertyValue[2];
    // Setting the flag for hidding the open document
    propertyvalue[0] = new PropertyValue();
    propertyvalue[0].Name = "Hidden";
    propertyvalue[0].Value = Boolean.TRUE;
    //
    propertyvalue[1] = new PropertyValue();
    propertyvalue[1].Name = "InputStream";
    propertyvalue[1].Value = is;

    // Loading the wanted document
    Object objectDocumentToStore = xcomponentloader.loadComponentFromURL("private:stream", "_blank", 0, propertyvalue);
    if (objectDocumentToStore == null) {
        Debug.logError("Could not get objectDocumentToStore object from xcomponentloader.loadComponentFromURL", module);
    }

    // Getting an object that will offer a simple way to store a document to a URL.
    XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore);
    if (xstorable == null) {
        Debug.logError("Could not get XStorable object from UnoRuntime.queryInterface", module);
    }

    // Preparing properties for converting the document
    String filterName = getFilterNameFromMimeType(outputMimeType);
    propertyvalue = new PropertyValue[4];

    propertyvalue[0] = new PropertyValue();
    propertyvalue[0].Name = "OutputStream";
    OpenOfficeByteArrayOutputStream os = new OpenOfficeByteArrayOutputStream();
    propertyvalue[0].Value = os;
    // Setting the filter name
    propertyvalue[1] = new PropertyValue();
    propertyvalue[1].Name = "FilterName";
    propertyvalue[1].Value = filterName;
    // Setting the flag for overwriting
    propertyvalue[3] = new PropertyValue();
    propertyvalue[3].Name = "Overwrite";
    propertyvalue[3].Value = Boolean.TRUE;
    // For PDFs
    propertyvalue[2] = new PropertyValue();
    propertyvalue[2].Name = "CompressionMode";
    propertyvalue[2].Value = "1";

    xstorable.storeToURL("private:stream", propertyvalue);
    //xstorable.storeToURL("file:///home/byersa/testdoc1_file.pdf", propertyvalue);

    // Getting the method dispose() for closing the document
    XComponent xcomponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xstorable);

    // Closing the converted document
    xcomponent.dispose();

    return os;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:77,代码来源:OpenOfficeWorker.java

示例12: saveOutputFile

import com.sun.star.frame.XStorable; //导入依赖的package包/类
/**
 * Speichert doc unter dem in outFile angegebenen Dateipfad und schließt dann doc.
 * 
 * @author Matthias Benkmann (D-III-ITD-D101)
 * 
 *         TESTED
 */
private static void saveOutputFile(File outFile, XTextDocument doc)
{
  try
  {
    String unparsedUrl = outFile.toURI().toURL().toString();

    XStorable store = UNO.XStorable(doc);
    PropertyValue[] options;

    /*
     * For more options see:
     * 
     * http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export
     */
    if (unparsedUrl.endsWith(".pdf"))
    {
      options = new PropertyValue[1];

      options[0] = new PropertyValue();
      options[0].Name = "FilterName";
      options[0].Value = "writer_pdf_Export";
    }
    else if (unparsedUrl.endsWith(".doc"))
    {
      options = new PropertyValue[1];

      options[0] = new PropertyValue();
      options[0].Name = "FilterName";
      options[0].Value = "MS Word 97";
    }
    else
    {
      if (!unparsedUrl.endsWith(".odt")) unparsedUrl = unparsedUrl + ".odt";

      options = new PropertyValue[0];
    }

    com.sun.star.util.URL url = UNO.getParsedUNOUrl(unparsedUrl);

    /*
     * storeTOurl() has to be used instead of storeASurl() for PDF export
     */
    store.storeToURL(url.Complete, options);
  }
  catch (Exception x)
  {
    Logger.error(x);
  }
}
 
开发者ID:WollMux,项目名称:WollMux,代码行数:57,代码来源:MailMergeNew.java

示例13: convert

import com.sun.star.frame.XStorable; //导入依赖的package包/类
public void convert(OOoInputStream input, OOoOutputStream output,
		String filterName, Map<String, Object> filterParameters)
		throws Exception {
	XMultiComponentFactory xMultiComponentFactory = xComponentContext
			.getServiceManager();
	Object desktopService = xMultiComponentFactory
			.createInstanceWithContext("com.sun.star.frame.Desktop",
					xComponentContext);
	XComponentLoader xComponentLoader = UnoRuntime.queryInterface(
			XComponentLoader.class, desktopService);

	PropertyValue[] conversionProperties = new PropertyValue[3];
	conversionProperties[0] = new PropertyValue();
	conversionProperties[1] = new PropertyValue();
	conversionProperties[2] = new PropertyValue();

	conversionProperties[0].Name = "InputStream";
	conversionProperties[0].Value = input;
	conversionProperties[1].Name = "Hidden";
	conversionProperties[1].Value = Boolean.TRUE;

	XComponent document = xComponentLoader.loadComponentFromURL(
			"private:stream", "_blank", 0, conversionProperties);

	List<PropertyValue> filterData = new ArrayList<PropertyValue>();
	for (Map.Entry<String, Object> entry : filterParameters.entrySet()) {
		PropertyValue propertyValue = new PropertyValue();
		propertyValue.Name = entry.getKey();
		propertyValue.Value = entry.getValue();
		filterData.add(propertyValue);
	}

	conversionProperties[0].Name = "OutputStream";
	conversionProperties[0].Value = output;
	conversionProperties[1].Name = "FilterName";
	conversionProperties[1].Value = filterName;
	conversionProperties[2].Name = "FilterData";
	conversionProperties[2].Value = filterData
			.toArray(new PropertyValue[1]);

	XStorable xstorable = UnoRuntime.queryInterface(XStorable.class,
			document);
	xstorable.storeToURL("private:stream", conversionProperties);

	XCloseable xclosable = UnoRuntime.queryInterface(XCloseable.class,
			document);
	xclosable.close(true);
}
 
开发者ID:Altrusoft,项目名称:docserv,代码行数:49,代码来源:OOoStreamConverter.java

示例14: PersistenceService

import com.sun.star.frame.XStorable; //导入依赖的package包/类
/**
 * Constructs new PersistenceService.
 * 
 * @param document document to be used
 * @param xStorable OpenOffice.org XStorable interface to be used
 * 
 * @throws IllegalArgumentException if the submitted document or the OpenOffice.org XStorable interface 
 * is not valid
 * 
 * @author Andreas Bröker
 */
public PersistenceService(IDocument document, XStorable xStorable)
    throws IllegalArgumentException {
  if (document == null)
    throw new IllegalArgumentException(Messages.getString("PersistenceService.exception_document_invalid")); //$NON-NLS-1$
  this.document = document;

  if (xStorable == null)
    throw new IllegalArgumentException(Messages.getString("PersistenceService.exception_xstorable_interface_invalid")); //$NON-NLS-1$
  this.xStorable = xStorable;
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:22,代码来源:PersistenceService.java

示例15: setSource

import com.sun.star.frame.XStorable; //导入依赖的package包/类
/**
 * Legt doc als die Datei fest mit der die externe Andwendung gestartet werden
 * soll. Die Datei wird immer zuerst in eine temporäre Datei exportiert bevor die
 * externe Anwendung aufgerufen wird. In welchem Format gespeichert wird, bestimmt
 * die FILTER-Angabe in der Definition der externen Anwendung. Ob die Datei als
 * Pfad oder als file: URL an die externe Anwendung übergeben wird bestimmt die
 * DOWNLOAD-Angabe. Als Dateierweiterung für die temporäre Datei wird das dem
 * Konstruktor übergebenene ext verwendet. Werden mehrere setSource() Funktionen
 * aufgerufen, so gewinnt die letzte.
 * 
 * @throws ConfigurationErrorException
 *           falls die FILTER-Angabe in der Definition der externen Anwendung
 *           fehlt.
 * 
 * @see #setSource(URL)
 * 
 * TESTED
 */
public void setSource(XStorable doc) throws ConfigurationErrorException
{
  if (filter == null)
    throw new ConfigurationErrorException(L.m(
      "FILTER-Angabe fehlt bei Anwendung für \"%1\"", ext));
  this.doc = doc;
  this.url = null;
}
 
开发者ID:WollMux,项目名称:WollMux,代码行数:27,代码来源:OpenExt.java


注:本文中的com.sun.star.frame.XStorable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。