To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=103356
                 Issue #|103356
                 Summary|Saving to MS Word not work when you have an embedded b
                        |ackground image for a TextFrame anchoring an embedded 
                        |TextGraphicObject image.
               Component|Word processor
                 Version|OOO310m11
                Platform|Macintosh
                     URL|
              OS/Version|All
                  Status|UNCONFIRMED
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P2
            Subcomponent|save-export
             Assigned to|writerneedsconfirm
             Reported by|cfleisch





------- Additional comments from [email protected] Mon Jul  6 13:08:18 
+0000 2009 -------
Hello Folks, I am using OpenOffice 3.1.0 M11 on an Intel based Mac. I have 4 gig
of RAM and 45GB of spare HDD.

What I have found is that if you specify an embedded background image for a
textframe and then add a TextGraphicObject to it, anchored to a paragraph within
the textframe (again as an embedded graphic object). Saving to Microsoft Word
(97/2000/XP) fails with the error:

"There is not enough memory or disk space to display or print the picture"

If I choose to not embed the graphic image for the textGraphicObject, the Save
As option works. It's only when the TextFrame has an embedded background image
along with embedding an object in the textframe.

Below is some sample code demonstrating this issue.:


package org.openoffice.sdk.example.text;

import com.sun.star.awt.FontWeight;
import com.sun.star.awt.Size;
import com.sun.star.beans.Property;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.XPropertySetInfo;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer;
import com.sun.star.datatransfer.XTransferable;
import com.sun.star.datatransfer.XTransferableSupplier;
import com.sun.star.drawing.XShape;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XController;
import com.sun.star.frame.XStorable;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.style.GraphicLocation;
import com.sun.star.style.XStyleFamiliesSupplier;
import com.sun.star.table.BorderLine;
import com.sun.star.text.ControlCharacter;
import com.sun.star.text.HoriOrientation;
import com.sun.star.text.TextContentAnchorType;
import com.sun.star.text.VertOrientation;
import com.sun.star.text.XPageCursor;
import com.sun.star.text.XParagraphCursor;
import com.sun.star.text.XText;
import com.sun.star.text.XTextContent;
import com.sun.star.text.XTextCursor;
import com.sun.star.text.XTextDocument;
import com.sun.star.text.XTextFrame;
import com.sun.star.text.XTextFramesSupplier;
import com.sun.star.text.XTextGraphicObjectsSupplier;
import com.sun.star.text.XTextViewCursor;
import com.sun.star.text.XTextViewCursorSupplier;
import com.sun.star.text.XWordCursor;
import com.sun.star.uno.Any;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.XCloseable;
import java.math.BigInteger;
import java.security.MessageDigest;
import ooo.connector.BootstrapSocketConnector;

public class TextDocumentStructure5 {
    private XTextDocument xTextDocument_src;
    private XTextDocument xTextDocument_dest;
    private XMultiServiceFactory xWriterFactory_src;
    private XMultiServiceFactory xWriterFactory_dest;
    private XComponent xWriterComponent_src;
    private XComponent xWriterComponent_dest;
    private Size page_size;
    private Size frame_size;

    public static void main(String args[]) {
        TextDocumentStructure5 tds = new TextDocumentStructure5();

        tds.copyContents();

        tds.moveTextFrames();

        // tds.saveFile();

        System.exit(1);
    }

    public TextDocumentStructure5() {
        String oooExeFolder = "/Applications/OpenOffice.org.app/Contents/MacOS";

        try {
            // get the remote office component context
            XComponentContext xRemoteContext =
BootstrapSocketConnector.bootstrap(oooExeFolder);
            //XComponentContext xRemoteContext = Bootstrap.bootstrap();

            if (xRemoteContext == null) {
                System.err.println("ERROR: Could not bootstrap default 
Office.");
            }

            XMultiComponentFactory xRemoteServiceManager =
                    xRemoteContext.getServiceManager();

            Object desktop =
                    xRemoteServiceManager.createInstanceWithContext(
                    "com.sun.star.frame.Desktop", xRemoteContext);

            XComponentLoader xComponentLoader =
                    (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class, desktop);

            /*
            XStringSubstitution xStringSubstitution = (XStringSubstitution)
             UnoRuntime.queryInterface(
                 XStringSubstitution.class,
                 xRemoteServiceManager.createInstanceWithContext(
                     "com.sun.star.util.PathSubstitution", xRemoteContext));

            String tempDir =
xStringSubstitution.getSubstituteVariableValue("$(temp)");
            */

            PropertyValue[] loadProps = new PropertyValue[0];

            xWriterComponent_src =
                    
xComponentLoader.loadComponentFromURL("private:factory/swriter",
                    "_blank", 0, loadProps);

            xWriterComponent_dest =
                    
xComponentLoader.loadComponentFromURL("private:factory/swriter",
                    "_blank", 0, loadProps);

            xTextDocument_src =
                    (XTextDocument) 
UnoRuntime.queryInterface(XTextDocument.class,
                    xWriterComponent_src);

            xTextDocument_dest =
                    (XTextDocument) 
UnoRuntime.queryInterface(XTextDocument.class,
                    xWriterComponent_dest);

            // get internal service factory of the document
            xWriterFactory_src = (XMultiServiceFactory) 
UnoRuntime.queryInterface(
                    XMultiServiceFactory.class, xWriterComponent_src);

            xWriterFactory_dest = (XMultiServiceFactory) 
UnoRuntime.queryInterface(
                    XMultiServiceFactory.class, xWriterComponent_dest);

            XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier) 
                    UnoRuntime.queryInterface(XStyleFamiliesSupplier.class,
xTextDocument_dest);

            // get the NameAccess interface from the Style family collection
            XNameAccess xNameAccess = xSupplier.getStyleFamilies();

            XNameContainer xPageStyleCollection = (XNameContainer)
                    UnoRuntime.queryInterface(XNameContainer.class,
xNameAccess.getByName(
                    "PageStyles"));

            // create a PropertySet to set the properties for the new Pagestyle
            XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,
                    xPageStyleCollection.getByName("Default"));

            // Flip the size
            page_size = (Size) xPropertySet.getPropertyValue("Size");

            int height = page_size.Height;
            page_size.Height = page_size.Width;
            page_size.Width = height;

            xPropertySet.setPropertyValue("Size", page_size);

            // Switch the orientation
            xPropertySet.setPropertyValue("IsLandscape", new Boolean(true));
            xPropertySet.setPropertyValue("LeftMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("RightMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("TopMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("BottomMargin", new Short((short) 0));

            xSupplier = (XStyleFamiliesSupplier)
                    UnoRuntime.queryInterface(XStyleFamiliesSupplier.class,
xTextDocument_src);

            // get the NameAccess interface from the Style family collection
            xNameAccess = xSupplier.getStyleFamilies();

            xPageStyleCollection = (XNameContainer)
                    UnoRuntime.queryInterface(XNameContainer.class,
xNameAccess.getByName(
                    "PageStyles"));

            // create a PropertySet to set the properties for the new Pagestyle
            xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,
                    xPageStyleCollection.getByName("Default"));

            xPropertySet.setPropertyValue("LeftMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("RightMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("TopMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("BottomMargin", new Short((short) 0));

            frame_size = new Size();

            frame_size.Height = page_size.Height - 2000;
            frame_size.Width = (page_size.Width / 2) - 2000;

            // create some example data
            XText xText = xTextDocument_src.getText();
            
            createExampleData(xText);

            XTextCursor xTextCursor = xText.createTextCursor();
            xTextCursor.gotoEnd(false);

            xText.insertControlCharacter(xTextCursor,
com.sun.star.text.ControlCharacter.APPEND_PARAGRAPH, false);

            loadJpgImage(xText,
"file:///Users/chrisf/Pictures/sakura1600_2.jpg", 4000, 4000);

            xText.insertControlCharacter(xTextCursor,
com.sun.star.text.ControlCharacter.APPEND_PARAGRAPH, false);
            
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }

    private void moveTextFrames() {
        XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier)
                UnoRuntime.queryInterface(XTextFramesSupplier.class,
xWriterComponent_dest);

        XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames();

        XIndexAccess xIndexAccess = (XIndexAccess)
                UnoRuntime.queryInterface(
                XIndexAccess.class, xNamedFrames);

        XText xText = xTextDocument_dest.getText();

        XController xController_targetDoc =
xTextDocument_dest.getCurrentController();

        // the cursor for the source document
        XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
                (XTextViewCursorSupplier)
                UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
                xController_targetDoc);

        //selecting the whole source document
        XTextViewCursor xTextViewCursor_targetDoc =
                xViewCursorSupplier_targetDoc.getViewCursor();

        XPageCursor xPageCursor =
                (XPageCursor) UnoRuntime.queryInterface(
                XPageCursor.class,
                xTextViewCursor_targetDoc);

        try {
            XNameContainer xBitmapContainer = (XNameContainer)
UnoRuntime.queryInterface(
                    XNameContainer.class, xWriterFactory_dest.createInstance(
                    "com.sun.star.drawing.BitmapTable"));

            XTextGraphicObjectsSupplier os =
                (XTextGraphicObjectsSupplier) UnoRuntime.queryInterface(
                        XTextGraphicObjectsSupplier.class, xTextDocument_dest);

            XNameAccess as = os.getGraphicObjects();

            if ((as != null) && (as.hasElements())) {
                String names[] = as.getElementNames();

                for (int i = 0; i < names.length; i++) {
                    Object o = (Object) as.getByName(names[i]);

                    XTextContent xTCGraphicObject = (XTextContent)
                            UnoRuntime.queryInterface(XTextContent.class, o);

                    XPropertySet xProps = (XPropertySet)
                            UnoRuntime.queryInterface(XPropertySet.class,
xTCGraphicObject);

                    String url = (String)xProps.getPropertyValue("GraphicURL");
                    Integer width = (Integer)xProps.getPropertyValue("Width");
                    Integer height = (Integer)xProps.getPropertyValue("Height");

                    // helper-stuff to let OOo create an internal name of the
graphic
                    // that can be used later (internal name consists of various
checksums)
                    MessageDigest md = MessageDigest.getInstance("MD5");
                    md.update(url.getBytes(), 0, url.length());

                    String internalName = new BigInteger(1,
md.digest()).toString(16);

                    xBitmapContainer.insertByName(internalName, url);

                    String internalURL =
(String)(xBitmapContainer.getByName(internalName));

                   
xTextViewCursor_targetDoc.gotoRange(xTCGraphicObject.getAnchor(), false);

                    XTextContent xNewTextContent = (XTextContent)
UnoRuntime.queryInterface(
                            XTextContent.class, 
xWriterFactory_dest.createInstance(
                            "com.sun.star.text.TextGraphicObject"));

                    xProps = (XPropertySet)
                            UnoRuntime.queryInterface(XPropertySet.class,
xNewTextContent);

                    // Not working with the Save AS option to MS Word.
                    //xProps.setPropertyValue("GraphicURL", internalURL); // <--
THIS DOESN"T WORK!
                    xProps.setPropertyValue("GraphicURL", url); // <-- THIS
WORKS, ie., a LINKED IMAGE!
                    xProps.setPropertyValue("Width", new Integer((int)(width)));
                    xProps.setPropertyValue("Height", new 
Integer((int)(height)));
                    
                    xProps.setPropertyValue("AnchorType",
TextContentAnchorType.AT_PARAGRAPH);

                    xTextViewCursor_targetDoc.getText().insertTextContent(
                            xTextViewCursor_targetDoc, xNewTextContent, false);

                    xText.removeTextContent(xTCGraphicObject);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        xText = xTextDocument_dest.getText();

        float frame_count = xIndexAccess.getCount();
        frame_count = frame_count / 2; // 2 frames per page.

        while (frame_count % 2 != 0) {
            frame_count++;
        }

        xPageCursor.jumpToFirstPage();
        xPageCursor.jumpToEndOfPage();

        for (int i = 1; i < frame_count; i++) {
            try {
                xPageCursor.jumpToLastPage();
                xPageCursor.jumpToEndOfPage();

                // Insert a paragraph break into the document (not the frame)
                xText.insertControlCharacter(xTextViewCursor_targetDoc,
ControlCharacter.PARAGRAPH_BREAK, false);

                XPropertySet xCursorProps =
(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
xTextViewCursor_targetDoc);

                xCursorProps.setPropertyValue("BreakType",
com.sun.star.style.BreakType.PAGE_AFTER);

                xText.insertControlCharacter(xTextViewCursor_targetDoc,
ControlCharacter.PARAGRAPH_BREAK, false);
            } catch (Exception e) {
                System.out.println(e.getMessage());

                e.printStackTrace();
            }
        }

        XTextFrame xTextFrame;//[] = new XTextFrame[xIndexAccess.getCount()];
        XPropertySet xShapeProps;//[] = new 
XPropertySet[xIndexAccess.getCount()];
        Object textFrame;//[] = new Object[xIndexAccess.getCount()];
        Any xImageAny;//[] = new Any[xIndexAccess.getCount()];

        xPageCursor.jumpToFirstPage();

        for (int i = 0; i < xIndexAccess.getCount(); i+= 2) {
            try {
                xImageAny = (Any) xIndexAccess.getByIndex(i);
                textFrame = xImageAny.getObject();

                xTextFrame = (XTextFrame)textFrame;

                XText xFrameText = (XText)
UnoRuntime.queryInterface(XText.class, textFrame);

                xShapeProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTextFrame);

                xShapeProps.setPropertyValue("AnchorPageNo", new
Short(xPageCursor.getPage()));
                xShapeProps.setPropertyValue("AnchorType",
TextContentAnchorType.AT_PAGE);

                xShapeProps.setPropertyValue("HoriOrient", new
Short(HoriOrientation.NONE));
                xShapeProps.setPropertyValue("VertOrient", new
Short(VertOrientation.NONE));

                // Setting the vertical and horizontal position
                xShapeProps.setPropertyValue("HoriOrientPosition", new
Integer(1000));
                xShapeProps.setPropertyValue("VertOrientPosition", new
Integer(1000));

                xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new
Boolean(false));

                xShapeProps.setPropertyValue("LeftBorderDistance", new
Integer(300));
                xShapeProps.setPropertyValue("RightBorderDistance", new
Integer(300));
                xShapeProps.setPropertyValue("TopBorderDistance", new 
Integer(300));
                xShapeProps.setPropertyValue("BottomBorderDistance", new
Integer(300));

                if ((i + 1) < xIndexAccess.getCount()) {
                    int x = i + 1;

                    xImageAny = (Any) xIndexAccess.getByIndex(x);
                    textFrame = xImageAny.getObject();

                    xTextFrame = (XTextFrame)textFrame;

                    xFrameText = (XText) UnoRuntime.queryInterface(XText.class,
textFrame);

                    xShapeProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTextFrame);

                    xShapeProps.setPropertyValue("AnchorPageNo", new
Short(xPageCursor.getPage()));
                    xShapeProps.setPropertyValue("AnchorType",
TextContentAnchorType.AT_PAGE);

                    xShapeProps.setPropertyValue("HoriOrient", new
Short(HoriOrientation.NONE));
                    xShapeProps.setPropertyValue("VertOrient", new
Short(VertOrientation.NONE));

                    // Setting the vertical and horizontal position
                    xShapeProps.setPropertyValue("HoriOrientPosition", new
Integer((page_size.Width / 2) + 1000));
                    xShapeProps.setPropertyValue("VertOrientPosition", new
Integer(1000));

                    xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new
Boolean(false));

                    xShapeProps.setPropertyValue("LeftBorderDistance", new
Integer(300));
                    xShapeProps.setPropertyValue("RightBorderDistance", new
Integer(300));
                    xShapeProps.setPropertyValue("TopBorderDistance", new
Integer(300));
                    xShapeProps.setPropertyValue("BottomBorderDistance", new
Integer(300));
                }

                xPageCursor.jumpToNextPage();
                xPageCursor.jumpToStartOfPage();
            } catch (Exception e) { 
                System.out.println(e.getMessage());
                
                e.printStackTrace();
            }
        }
    }

    private XText getTextFrame(XText xText) {
        try {
            Object textFrame =
xWriterFactory_dest.createInstance("com.sun.star.text.TextFrame");

            XTextFrame xTextFrame = (XTextFrame)
UnoRuntime.queryInterface(XTextFrame.class, textFrame);

            XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class,
xTextFrame);
            
            xShape.setSize(new Size(frame_size.Width, frame_size.Height));

            XPropertySet xShapeProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTextFrame);

            BorderLine aBorderLine = new BorderLine();
            aBorderLine.OuterLineWidth = 1;
            aBorderLine.Color = new Integer(0xFFFFFF);
            
            xShapeProps.setPropertyValue("TopBorder", aBorderLine);
            xShapeProps.setPropertyValue("BottomBorder", aBorderLine);
            xShapeProps.setPropertyValue("LeftBorder", aBorderLine);
            xShapeProps.setPropertyValue("RightBorder", aBorderLine);

            xShapeProps.setPropertyValue("AnchorType",
TextContentAnchorType.AT_PAGE);

            // Setting the vertical and horizontal position
            xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new
Boolean(false));

            xShapeProps.setPropertyValue("VertOrient", new
Short(VertOrientation.NONE));
            xShapeProps.setPropertyValue("HoriOrient", new
Short(HoriOrientation.NONE));

            xShapeProps.setPropertyValue("VertOrientPosition", new 
Integer(1000));
            xShapeProps.setPropertyValue("HoriOrientPosition", new 
Integer(1000));

            xShapeProps.setPropertyValue("LeftBorderDistance", new Integer(0));
            xShapeProps.setPropertyValue("RightBorderDistance", new Integer(0));
            xShapeProps.setPropertyValue("TopBorderDistance", new Integer(0));
            xShapeProps.setPropertyValue("BottomBorderDistance", new 
Integer(0));

            XNameContainer xBitmapContainer = (XNameContainer)
UnoRuntime.queryInterface(
                    XNameContainer.class, xWriterFactory_dest.createInstance(
                    "com.sun.star.drawing.BitmapTable"));

            String backgroundImageURL =
"file:///Users/chrisf/NetBeansProjects/WebApplication2/web/Shared/images/border6.jpg";

            // helper-stuff to let OOo create an internal name of the graphic
            // that can be used later (internal name consists of various 
checksums)
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(backgroundImageURL.getBytes(), 0,
backgroundImageURL.length());

            String internalName = new BigInteger(1, md.digest()).toString(16);

            xBitmapContainer.insertByName(internalName, backgroundImageURL);

            String internalURL = 
(String)(xBitmapContainer.getByName(internalName));

            xShapeProps.setPropertyValue("BackGraphicURL", internalURL);
            xShapeProps.setPropertyValue("BackGraphicLocation",
GraphicLocation.AREA);

            XPropertySetInfo xPropertySetInfo = 
xShapeProps.getPropertySetInfo();

            Property property[] = xPropertySetInfo.getProperties();

            for (int i = 0; i < property.length; i++) {
                try {
                    System.out.println(property[i].Name + ": " +
                            xShapeProps.getPropertyValue(property[i].Name));
                } catch (Exception e) { }
            }

            xText.insertTextContent(xText.getEnd(), xTextFrame, false);

            xBitmapContainer.removeByName(internalName);

            XText xFrameText = (XText) UnoRuntime.queryInterface(XText.class,
textFrame);

            return xFrameText;
        } catch (java.lang.Exception e) {
            e.printStackTrace();
        }

        return null;
    }

    private void copyContents() {
        try {
            //the controllers
            XController xController_sourceDoc =
xTextDocument_src.getCurrentController();
            XController xController_targetDoc =
xTextDocument_dest.getCurrentController();

            // the cursor for the source document
            XTextViewCursorSupplier xViewCursorSupplier_sourceDoc =
                    (XTextViewCursorSupplier)
                    UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
                    xController_sourceDoc);

            //selecting the whole source document
            XTextViewCursor xTextViewCursor_sourceDoc =
                    xViewCursorSupplier_sourceDoc.getViewCursor();

            XPageCursor xPageCursor =
                    (XPageCursor) UnoRuntime.queryInterface(
                    XPageCursor.class,
                    xTextViewCursor_sourceDoc);

            XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)
                    UnoRuntime.queryInterface(XStyleFamiliesSupplier.class,
xTextDocument_dest);

            // get the NameAccess interface from the Style family collection
            XNameAccess xNameAccess = xSupplier.getStyleFamilies();

            XNameContainer xPageStyleCollection = (XNameContainer)
                    UnoRuntime.queryInterface(XNameContainer.class,
xNameAccess.getByName(
                    "ParagraphStyles"));

            // create a PropertySet to set the properties for the new Pagestyle
            XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,
                    xPageStyleCollection.getByName("Default"));

            Float charHeight = 
(Float)xPropertySet.getPropertyValue("CharHeight");
            //Integer paraTopMargin =
(Integer)xPropertySet.getPropertyValue("ParaTopMargin");
            //Integer paraBottomMargin =
(Integer)xPropertySet.getPropertyValue("ParaBottomMargin");

            int page_height = page_size.Width;
            int frame_height = frame_size.Height;
            
            float ratio_y = ((float)frame_height - 2000) / (float)page_height;

            // Switch the orientation
            short charHeight2 = (short)(charHeight.floatValue() * ratio_y);
            
            xPropertySet.setPropertyValue("CharHeight", new Short(charHeight2));

            // select the current page of document with the cursor
            xPageCursor.jumpToLastPage();
            xPageCursor.jumpToEndOfPage();

            int currentPage = xPageCursor.getPage();

            //getting the data supplier of our source doc
            XTransferableSupplier xTransferableSupplier_sourceDoc;
            XTransferableSupplier xTransferableSupplier_targetDoc;
            XTextViewCursorSupplier xViewCursorSupplier_targetDoc;
            XTextViewCursor xTextViewCursor_targetDoc;
            XTransferable xTransferable;

            do {
                while (xPageCursor.getPage() == currentPage) {
                    if (!xTextViewCursor_sourceDoc.goLeft((short)1, true)) {
                        break;
                    }
                }
                
                //getting the data supplier of our source doc
                xTransferableSupplier_sourceDoc =
                        (XTransferableSupplier) UnoRuntime.queryInterface(
                        XTransferableSupplier.class,
                        xController_sourceDoc);

                //saving the selected contents
                xTransferable =
                        xTransferableSupplier_sourceDoc.getTransferable();

                // Create the TextFrame
                XText xText = xTextDocument_dest.getText();
                xText = getTextFrame(xText);

                //getting the data supplier of our target doc
                 xTransferableSupplier_targetDoc =
                        (XTransferableSupplier) UnoRuntime.queryInterface(
                        XTransferableSupplier.class,
                        xController_targetDoc);

                //the cursor for the target document
                xViewCursorSupplier_targetDoc =
                        (XTextViewCursorSupplier)
                        UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
                        xController_targetDoc);

                //going to the end of the source document
                xTextViewCursor_targetDoc =
                        xViewCursorSupplier_targetDoc.getViewCursor();

                xTextViewCursor_targetDoc.gotoRange(xText.getEnd(), false);

                // inserting the source document there
                
xTransferableSupplier_targetDoc.insertTransferable(xTransferable);

                // RESET cursor and page.
                xTextViewCursor_sourceDoc.goRight((short)1, false);

                xPageCursor.jumpToPreviousPage();
                xPageCursor.jumpToEndOfPage();
            } while (--currentPage > 0);

        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }

    private void saveFile() {
        try {
            XStorable xStorable =
            (XStorable)UnoRuntime.queryInterface(XStorable.class,
xTextDocument_dest);

            PropertyValue[] storeProps = new PropertyValue[1];
            storeProps[0] = new PropertyValue();
            //storeProps[0].Name = "FilterName";
            //storeProps[0].Value = "MS Word 97";

            xStorable.storeAsURL("file:///Users/chrisf/Documents/test.odt",
storeProps);

            XCloseable xcloseable = (XCloseable) UnoRuntime.queryInterface(
                    XCloseable.class, xTextDocument_dest);

            xcloseable.close(false);

            xcloseable = (XCloseable) UnoRuntime.queryInterface(
                    XCloseable.class, xTextDocument_src);

            xcloseable.close(false);

        } catch (java.lang.Exception e) {
            e.printStackTrace();
        }
    }

    protected void createExampleData(com.sun.star.text.XText xText) {
        try {
            for (int i = 0; i < 6; i++) {
                for (int j = 0; j < 1000; j++) {
                    xText.insertString(xText.getEnd(), String.valueOf(j) + " ",
false);
                }
                
                xText.insertControlCharacter(xText.getEnd(),
ControlCharacter.PARAGRAPH_BREAK, false);
            }

            XWordCursor xWordCursor =
                    (XWordCursor) UnoRuntime.queryInterface(
                    XWordCursor.class, xText.getStart());

            xWordCursor.gotoNextWord(false);
            xWordCursor.gotoNextWord(false);
            xWordCursor.gotoEndOfWord(true);

            XPropertySet xPropertySet =
                    (XPropertySet) UnoRuntime.queryInterface(
                    XPropertySet.class, xWordCursor);

            xPropertySet.setPropertyValue("CharWeight",  new
Float(FontWeight.BOLD));
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }

    protected void loadJpgImage(XText xText, String strImgFileName, int width,
int height) {
        try {
            Object newImage =
xWriterFactory_src.createInstance("com.sun.star.text.TextGraphicObject" );
            XTextContent xNewTextContent = ( XTextContent )
UnoRuntime.queryInterface(XTextContent.class, newImage);

            XTextCursor xTextCursor = xText.createTextCursor();

            xTextCursor.gotoEnd(false);

            xText.insertTextContent( xTextCursor, xNewTextContent, false);

            XPropertySet xProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, newImage);

            int page_height = page_size.Width;
            int page_width = page_size.Height;

            int frame_height = frame_size.Height;
            int frame_width = frame_size.Width;

            float ratio_x = ((float)frame_height) / (float)page_height;
            float ratio_y = ((float)frame_width) / (float)page_width;

            float ratio = 1;

            if (ratio_x < ratio_y) {
                ratio = ratio_x;
            } else {
                ratio = ratio_y;
            }

            xProps.setPropertyValue("GraphicURL", strImgFileName);
            xProps.setPropertyValue("AnchorType",
TextContentAnchorType.AT_PARAGRAPH);
            xProps.setPropertyValue("Width", new Integer((int)(width * ratio)));
            xProps.setPropertyValue("Height", new Integer((int)(height * 
ratio)));
        } catch (Exception e) {
            e.printStackTrace();

            System.out.println("Failed to insert Graphic");
        }
    }
}

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to