I'm trying to clone a Writer object, but I can't seem to get it to work.
Every time I request the XCloneable interface, my xClone object is NULL.
What am I doing wrong?

NOTE: Irrelevant code has not be included in this email

    private XComponent getDocument(String doc) throws Exception {
            PropertyValue[] loadProps = createPropertyValueArray(
                    createPropertyValue("AsTemplate",new Any(Type.BOOLEAN,
Boolean.TRUE)),
                    createPropertyValue("Hidden",new Any(Type.BOOLEAN,
Boolean.TRUE))
                    );
            XComponent xComp;
            try {
                xComp = componentImport(doc, loadProps);
            } catch (com.sun.star.uno.Exception ex) {
                throw new Exception ("Failed To load", ex);
            }

        return createCopy(xComp);
    }

    private XComponent createCopy(XComponent xComp) throws Exception {
        XComponent newComp = null;

        // xClone is always NULL
        com.sun.star.util.XCloneable xClone = (com.sun.star.util.XCloneable)
                   UnoRuntime.queryInterface(
com.sun.star.util.XCloneable.class,xComp);

        if(xClone != null) {
            newComp = (XComponent)xClone.createClone();
        }else{
            throw new Exception ("Component could not be cloned.", ex);
        }
        return newComp;
    }

I even tried adding the following to the properties list:

fileManager.createPropertyValue("FilterName",new Any(Type.STRING,
DocumentType.WRITER_OPENDOCUMENT_TEXT_TEMPLATE))

Reply via email to