Re: [dev] Please help: saving document as DOC format, then opening, losing position properties for TextGraphicObject

2010-01-03 Thread tora - Takamichi Akiyama

Hi,

Chris Fleischmann wrote:

Hi basically I am using the OpenOffice SDK (3.1.1) to create a new Writer
document. I add images with the following code, passing in the XText (which
in this case is an XText from a XTextFrame).



XTextCursor xTextCursor = xFrameText.createTextCursor();

...

xFrameText.insertTextContent(xTextCursor, xNewTextContent, false);


What I tried is:
XTextDocument xTextDocument = (XTextDocument) 
UnoRuntime.queryInterface(XTextDocument.class, oDoc);
XText xText = xTextDocument.getText();
XTextCursor xTextCursor = xText.createTextCursor();
...
xText.insertTextContent(xTextCursor, xTextContent, false);

Details:
 
http://tora-japan.com/wiki/Insert_an_image_file_into_OpenOffice.org_Writer_document_and_save_it_as_a_Microsoft_Office_97-2003_file

Tora

-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Please help: saving document as DOC format, then opening, losing position properties for TextGraphicObject

2010-01-02 Thread tora - Takamichi Akiyama

I am not sure, but, hopefully, this could be a hint.

After manually inserting a graphic image into an empty Writer document,
the following code fragment of OpenOffice.org Basic reports that

HoriOrientRelation = 7
VertOrientPosition = 7

Sub Main
oObject = ThisComponent.getDrawPage().getByIndex(0)
print AnchorType =   oObject.AnchorType
print Height =   oObject.Height
print Width =oObject.Width
print HoriOrient =   oObject.HoriOrient
print HoriOrientPosition =   oObject.HoriOrientPosition
print HoriOrientRelation =   oObject.HoriOrientRelation
print VertOrient =   oObject.VertOrient
print VertOrientPosition =   oObject.VertOrientPosition
print VertOrientRelation =   oObject.VertOrientRelation
End Sub

They seem to be described at
http://api.openoffice.org/docs/common/ref/com/sun/star/text/RelOrientation.html


An export filter for Microsoft Word 97-2003 (not for 2007, though) has some 
relevant code.
http://svn.services.openoffice.org/ooo/tags/OpenOffice_3_1_1/sw/source/filter/ww8/wrtw8esh.cxx

bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient _iorHoriOri, ...
{
...
// convert horizontal position, if needed
{
enum HoriConv { NO_CONV, CONV2PG, CONV2COL, CONV2CHAR };
HoriConv eHoriConv( NO_CONV );
...
case text::RelOrientation::PAGE_FRAME:
case text::RelOrientation::PAGE_PRINT_AREA:
{
if ( bConvDueToOrientation || bFollowTextFlow )
eHoriConv = CONV2PG;
}
...
case text::RelOrientation::FRAME:
{
if ( bConvDueToOrientation )
eHoriConv = CONV2COL;
}
...

Tora


Chris Fleischmann wrote:

OpenOffice 3.1.1. Java SDK, MAC OS X 10.6.2, MS Word 2007/2008.

Firstly I am happily able to position my TextGraphicObject's where I need
them, ie., I use the following code to position the TextGrahicObject in
OpenOffice with a particular width and height:



xProps.setPropertyValue(HoriOrient, new 
Short(HoriOrientation.NONE));
xProps.setPropertyValue(HoriOrientPosition, new Integer(pos_x));



However when I open up the document in MS Word, the image, has been
left-aligned (lots its X position) and lots its Y position?

Is there a way to make sure the position is maintained in both OOo and MS
Word?

Thanks in advance,

Chris


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Please help: saving document as DOC format, then opening, losing position properties for TextGraphicObject

2010-01-02 Thread Chris Fleischmann

Thanks for responding, I have since tried playing around with the orientation
settings, but alas, its still not keeping the x/y position from the
paragraph anchor when I open it up in Word ... See the picture properties
here for one of my images in openoffice 3.1.1:

http://old.nabble.com/file/p26992864/Screen%2Bshot%2B2010-01-02%2Bat%2B11.46.15%2BPM.png
 

Unfortunately, it still moves to the TOP of the paragraph anchor, and also
moves to the leftmost position possible.

So given the paragraph anchor, the image moves to the top left position of
the anchor.

Thanks in advance for any other tips.


tora - Takamichi Akiyama wrote:
 
 I am not sure, but, hopefully, this could be a hint.
 
 After manually inserting a graphic image into an empty Writer document,
 the following code fragment of OpenOffice.org Basic reports that
 
   HoriOrientRelation = 7
   VertOrientPosition = 7
 
 Sub Main
   oObject = ThisComponent.getDrawPage().getByIndex(0)
   print AnchorType =   oObject.AnchorType
   print Height =   oObject.Height
   print Width =oObject.Width
   print HoriOrient =   oObject.HoriOrient
   print HoriOrientPosition =   oObject.HoriOrientPosition
   print HoriOrientRelation =   oObject.HoriOrientRelation
   print VertOrient =   oObject.VertOrient
   print VertOrientPosition =   oObject.VertOrientPosition
   print VertOrientRelation =   oObject.VertOrientRelation
 End Sub
 
 They seem to be described at
 http://api.openoffice.org/docs/common/ref/com/sun/star/text/RelOrientation.html
 
 
 An export filter for Microsoft Word 97-2003 (not for 2007, though) has
 some relevant code.
 http://svn.services.openoffice.org/ooo/tags/OpenOffice_3_1_1/sw/source/filter/ww8/wrtw8esh.cxx
 
 bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient _iorHoriOri, ...
 {
 ...
  // convert horizontal position, if needed
  {
  enum HoriConv { NO_CONV, CONV2PG, CONV2COL, CONV2CHAR };
  HoriConv eHoriConv( NO_CONV );
 ...
  case text::RelOrientation::PAGE_FRAME:
  case text::RelOrientation::PAGE_PRINT_AREA:
  {
  if ( bConvDueToOrientation || bFollowTextFlow )
  eHoriConv = CONV2PG;
  }
 ...
  case text::RelOrientation::FRAME:
  {
  if ( bConvDueToOrientation )
  eHoriConv = CONV2COL;
  }
 ...
 
 Tora
 
 
 Chris Fleischmann wrote:
 OpenOffice 3.1.1. Java SDK, MAC OS X 10.6.2, MS Word 2007/2008.
 
 Firstly I am happily able to position my TextGraphicObject's where I need
 them, ie., I use the following code to position the TextGrahicObject in
 OpenOffice with a particular width and height:
 
 xProps.setPropertyValue(HoriOrient, new
 Short(HoriOrientation.NONE));
 xProps.setPropertyValue(HoriOrientPosition, new
 Integer(pos_x));
 
 However when I open up the document in MS Word, the image, has been
 left-aligned (lots its X position) and lots its Y position?
 
 Is there a way to make sure the position is maintained in both OOo and MS
 Word?
 
 Thanks in advance,
 
 Chris
 
 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional commands, e-mail: dev-h...@openoffice.org
 
 
 

-- 
View this message in context: 
http://old.nabble.com/Please-help%3A-saving-document-as-DOC-format%2C-then-opening%2C-losing-position-properties-for-TextGraphicObject-tp26989671p26992864.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Please help: saving document as DOC format, then opening, losing position properties for TextGraphicObject

2010-01-02 Thread tora - Takamichi Akiyama

Are you using vertical writing? If so, there is a bug which
misinterprets the position of graphic object during importing
from and exporting into Microsoft Word 97-2003.

 http://qa.openoffice.org/issues/show_bug.cgi?id=86769
 
http://www.openoffice.org/nonav/issues/showattachment.cgi/61766/i86769_wordarts_01_doc_snapshots.png

How are you trying to achieve your needs?  Like this?
 1. Prepare OpenOffice.org 3.1.1 on MacOS X 10.6.2.
 2. Start your Java program to create an empty Writer document or
to open an existing Writer document and then
to import a graphic image file.
 3. How do you save the Writer document as a Word file?
by hand or by the Java program?
 4. What file type or FilterName do you use for saving the document?
Microsoft Word 97/2000/XP   writer_MS_Word_97
Microsoft Word 2003 XML writer_MS_Word_2003_XML
Microsoft Word 2007 XML writer_MS_Word_2007
 5. Anything else that you have noticed...

There might be several possibilities, I guess:
 (a) Something in your Java program.
 (b) Bugs in OpenOffice.org 3.1.1.
 (c) Bugs in Microsoft Office running on Macintosh.

What will happen with your environment?
 1. Manually create an empty Writer document.
 2. Manually import a graphic image.
 3. Move it and alter its attributes.
 4. Save it as Word 97/2000/XP and/or Word 2003 XML.
 5. Open it with your Word 2007/2008.

Tora

Chris Fleischmann wrote:

Thanks for responding, I have since tried playing around with the orientation
settings, but alas, its still not keeping the x/y position from the
paragraph anchor when I open it up in Word ... See the picture properties
here for one of my images in openoffice 3.1.1:

http://old.nabble.com/file/p26992864/Screen%2Bshot%2B2010-01-02%2Bat%2B11.46.15%2BPM.png 


Unfortunately, it still moves to the TOP of the paragraph anchor, and also
moves to the leftmost position possible.

So given the paragraph anchor, the image moves to the top left position of
the anchor.

Thanks in advance for any other tips.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Please help: saving document as DOC format, then opening, losing position properties for TextGraphicObject

2010-01-02 Thread tora - Takamichi Akiyama

Hi,
What I have just noticed with writer_MS_Word_2003_XML is ...

Steps
 1. Manually create an empty Writer document.
 2. Manually import a graphic image.
 3. Move it and alter its attributes.
 4. Save it as Word 2003 XML.
 5. Open it with my favorite text editor.

The inside of the XML file
w:pict
 w:binData w:name=wordml://graphics1...(encoded image 
data).../w:binData
 v:shape id=_x0_0_0_0 
style=position:absolute;z-index:0;left:0pt;top:0pt;width:0pt;
  v:imagedata src=wordml://graphics1 o:title=graphics1/
 /v:shape
/w:pict

It says ... left:0pt;top:0pt; ...

Tora


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Please help: saving document as DOC format, then opening, losing position properties for TextGraphicObject

2010-01-02 Thread vito smolej
What about putting the graphics into a container - a text box for
instance -, which is able to listen to your prayers (g)?

Regards

Vito

-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Please help: saving document as DOC format, then opening, losing position properties for TextGraphicObject

2010-01-02 Thread Chris Fleischmann

Hello...

I have since tried the following code, which aims to do just that... It add
the picture to a frame, The frame is either anchored to a paragraph or
frame...Thats is, I have a parent frame which is anchored to a particular
page, with PAGE anchoring... Inside that frame is the NEW frame that now
holds the image.

This all works in OpenOffice... The document works perfectly. In MS Word...
I don't see the images or new frames at all.

See code here:

protected XTextFrame getTextFrame(XText xText,
int width,
int height,
int x,
int y,
TextContentAnchorType anchorType,
short horiOrient,
short vertOrient) throws Exception {
Object textFrame =
xWriterFactory_dest.createInstance(com.sun.star.text.TextFrame);

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

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

BorderLine aBorderLine = new BorderLine();
aBorderLine.OuterLineWidth = 1;
aBorderLine.Color = new Integer(0x00);

xShapeProps.setPropertyValue(TopBorder, aBorderLine);
xShapeProps.setPropertyValue(BottomBorder, aBorderLine);
xShapeProps.setPropertyValue(LeftBorder, aBorderLine);
xShapeProps.setPropertyValue(RightBorder, aBorderLine);

xShapeProps.setPropertyValue(AnchorType, anchorType);

// Setting the vertical and horizontal position
xShapeProps.setPropertyValue(FrameIsAutomaticHeight, new
Boolean(false));
xShapeProps.setPropertyValue(SizeType, new Short((short)1));

xShapeProps.setPropertyValue(HoriOrient, new Short(horiOrient));
xShapeProps.setPropertyValue(VertOrient, new Short(vertOrient));

xShapeProps.setPropertyValue(FrameWidthAbsolute, new
Integer(width));
xShapeProps.setPropertyValue(FrameHeightAbsolute, new
Integer(height));

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

// Setting the vertical and horizontal position
if (horiOrient == HoriOrientation.NONE) {
xShapeProps.setPropertyValue(HoriOrientPosition, new
Integer(x));
}

if (vertOrient == VertOrientation.NONE) {
xShapeProps.setPropertyValue(VertOrientPosition, new
Integer(y));
}

xShapeProps.setPropertyValue(TextWrap, WrapTextMode.NONE);

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

return xTextFrame;
}


And the addImage method has since been changed too:


/**
 * Use this method to add a JPG to the textframe.
 *
 * @param strImgFileName The image to add.
 * @param width The width of the image.
 * @param height The height of the image.
 * @param centreImage Centre the image.
 * @param x The position on the frame from the left margin (of the
frame).
 * @param y The position on the frame from the top margin (of the
frame).
 *
 * @throws Exception
 */
private void addJPGImage(XTextFrame xTextFrame,
String strImgFileName,
int width,
int height,
boolean centreImage,
int x,
int y)
throws Exception {
// allocate an xText object in case it's required.
XText xText = xTextDocument_dest.getText();

// Test whether we need to assign a different text frame.
if (xTextFrame != null) {
xFrameText = (XText) UnoRuntime.queryInterface(XText.class,
xTextFrame);
}

XTextFrame tmp_xTextFrame = null;

if (centreImage == true) {
int anchor = -1;

if (xTextFrame != null) {
anchor = TextContentAnchorType.AT_FRAME_value;
} else {
anchor = TextContentAnchorType.AT_PARAGRAPH_value;
}

tmp_xTextFrame = getTextFrame(xFrameText.getText(),
width,
height,
x,
y,
TextContentAnchorType.fromInt(anchor),
HoriOrientation.CENTER,
VertOrientation.TOP);
} else {
int pos_x = -1;
int pos_y = -1;

short horiOrient = HoriOrientation.NONE;
short vertOrient = VertOrientation.NONE;

int anchor = -1;

if (xTextFrame != null) {
anchor = TextContentAnchorType.AT_FRAME_value;
} else {
anchor = TextContentAnchorType.AT_PARAGRAPH_value;
}

// The X orientation, is moved 10mm to the right... move it
back.
if (x == (-1)) {
horiOrient = HoriOrientation.NONE;
pos_x = 0;
 

[dev] Please help: saving document as DOC format, then opening, losing position properties for TextGraphicObject

2010-01-01 Thread Chris Fleischmann

Hello All,

OpenOffice 3.1.1. Java SDK, MAC OS X 10.6.2, MS Word 2007/2008.

Firstly I am happily able to position my TextGraphicObject's where I need
them, ie., I use the following code to position the TextGrahicObject in
OpenOffice with a particular width and height:

Object newImage =
xWriterFactory_dest.createInstance(com.sun.star.text.TextGraphicObject);

XTextContent xNewTextContent = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class, newImage);

XTextCursor xTextCursor = xFrameText.createTextCursor();

xTextCursor.gotoEnd(false);

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

// 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(strImgFileName.getBytes(), 0, strImgFileName.length());

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

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

xBitmapContainer.insertByName(internalName, strImgFileName);

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

xProps.setPropertyValue(AnchorType,
TextContentAnchorType.AT_PARAGRAPH);

xProps.setPropertyValue(Width, width);
xProps.setPropertyValue(Height, height);

if (centreImage == true) {
int pos_x = (frame_size.Width / 2) - (width / 2);

// update frame width with the new dimensions.
xProps.setPropertyValue(HoriOrient, new
Short(HoriOrientation.NONE));
xProps.setPropertyValue(HoriOrientPosition, new
Integer(pos_x));
} else {
int pos_x = 1000;
int pos_y = 1000;

xProps.setPropertyValue(HoriOrient, new
Short(HoriOrientation.NONE));
xProps.setPropertyValue(HoriOrientPosition, new
Integer(pos_x));

xProps.setPropertyValue(VertOrient, new
Short(HoriOrientation.NONE));
xProps.setPropertyValue(VertOrientPosition, new
Integer(pos_y));
}

xtext.insertTextContent(xTextCursor, xNewTextContent, false);

// remove unnecessary object reference
xBitmapContainer.removeByName(internalName);

However when I open up the document in MS Word, the image, has been
left-aligned (lots its X position) and lots its Y position?

Is there a way to make sure the position is maintained in both OOo and MS
Word?

Thanks in advance,

Chris


-- 
View this message in context: 
http://old.nabble.com/Please-help%3A-saving-document-as-DOC-format%2C-then-opening%2C-losing-position-properties-for-TextGraphicObject-tp26989671p26989671.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org