|
View:
New views
13 Messages
—
Rating Filter:
Alert me
|
|
|
I have five text frames on the one page, can I move each frame to a new page?Hello folks, I have TextFrames, that are created like so (at the beginning of the process):
private XText getTextFrame(XText xText, int x, int y) { try { Object textFrame = xWriterFactory.createInstance("com.sun.star.text.TextFrame"); XTextContent xTextContentFrame = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, textFrame); XPropertySet xShapeProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, textFrame); xShapeProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PARAGRAPH); // Setting the vertical and horizontal position xShapeProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE)); xShapeProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE)); xShapeProps.setPropertyValue("VertOrientPosition", new Integer(x)); xShapeProps.setPropertyValue("HoriOrientPosition", new Integer(y)); // Set the width and height of the shape. xShapeProps.setPropertyValue("FrameWidthAbsolute", new Integer(frame_size.Width)); xShapeProps.setPropertyValue("FrameHeightAbsolute", new Integer(frame_size.Height)); xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new Boolean(false)); xShapeProps.setPropertyValue("SizeType", new Short((short)1)); xShapeProps.setPropertyValue("LeftBorderDistance", new Integer(200)); xShapeProps.setPropertyValue("RightBorderDistance", new Integer(200)); xShapeProps.setPropertyValue("TopBorderDistance", new Integer(200)); xShapeProps.setPropertyValue("BottomBorderDistance", new Integer(200)); xText.insertTextContent(xText.getEnd(), xTextContentFrame, false); XText xFrameText = (XText) UnoRuntime.queryInterface(XText.class, textFrame); return xFrameText; } catch (java.lang.Exception e) { e.printStackTrace(); } return null; } This method seems to work, it creates the textframe with a specific size, at a specific x/y location. I am now attempting to iterate over the "said" textframes like so: XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, xWriterComponent_dest); XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); String[] textframes = xNamedFrames.getElementNames(); for (int i = 0; i < textframes.length; i++) { XTextFrame textframe = null; try { textframe = (XTextFrame)xNamedFrames.getByName(textframes[i]); XTextContent xFrameContent = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, textframe); XPropertySet xShapeProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, textframe); Which seems to work, ie., i can iterate over the above "said" frames.... I have tried doing: xShapeProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PARAGRAPH); // Setting the vertical and horizontal position xShapeProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE)); xShapeProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE)); xShapeProps.setPropertyValue("VertOrientPosition", new Integer(1000 + (i * 1000))); xShapeProps.setPropertyValue("HoriOrientPosition", new Integer(1000)); so as to move the frames slowly but sure down the page.... That doesn't seem to work? Secondly, is there a way to create a new page between each cycle so that I can move the textframe to the new page with the same, x/y origin? Thanks in advance for any help you can shed on the issue, Chris |
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?I have gotten so far as;
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(); XTextCursor xTextCursor = xText.createTextCursor(); for (int i = 0; i < xIndexAccess.getCount(); i++) { try { Any xImageAny = (Any) xIndexAccess.getByIndex(i); Object textFrame = xImageAny.getObject(); XTextContent xFrameContent = (XTextContent)textFrame; XPropertySet xShapeProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, textFrame); xShapeProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE); // Setting the vertical and horizontal position int height = (i * page_size.Height) + 1000; xShapeProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE)); xShapeProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE)); xShapeProps.setPropertyValue("HoriOrientPosition", new Integer(1000)); xShapeProps.setPropertyValue("VertOrientPosition", new Integer(height)); // Set the width and height of the shape. xShapeProps.setPropertyValue("FrameWidthAbsolute", new Integer(frame_size.Width)); xShapeProps.setPropertyValue("FrameHeightAbsolute", new Integer(frame_size.Height)); xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new Boolean(false)); xShapeProps.setPropertyValue("SizeType", new Short((short)1)); xShapeProps.setPropertyValue("LeftBorderDistance", new Integer(200)); xShapeProps.setPropertyValue("RightBorderDistance", new Integer(200)); xShapeProps.setPropertyValue("TopBorderDistance", new Integer(200)); xShapeProps.setPropertyValue("BottomBorderDistance", new Integer(200)); // Insert a paragraph break into the document (not the frame) xText.insertControlCharacter (xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false); XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); xCursorProps.setPropertyValue("BreakType", com.sun.star.style.BreakType.PAGE_AFTER); xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false); xTextCursor.gotoEnd(false); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } } Which allows me to grab the existing textfram. I then attempt to change the verticial position based on the page size, and once moved add a new page to the document and updating the height value for the next frame's translation... This doesn't seem to work, ie., the textframe(s) do not move to the next page, they don't translate, the seem to move down the page by increments of 1000? Shouldn't the Anchor, AT_PAGE move to the "second", "third" or etc. etc. page, rather than stick to page 1? thanks for any help you may be able to shed.
|
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?Chris Fleischmann wrote:
> I have gotten so far as; > > 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(); > > XTextCursor xTextCursor = xText.createTextCursor(); > > for (int i = 0; i < xIndexAccess.getCount(); i++) { > try { > Any xImageAny = (Any) xIndexAccess.getByIndex(i); > Object textFrame = xImageAny.getObject(); > > XTextContent xFrameContent = (XTextContent)textFrame; > > XPropertySet xShapeProps = (XPropertySet) > UnoRuntime.queryInterface(XPropertySet.class, textFrame); > > xShapeProps.setPropertyValue("AnchorType", > TextContentAnchorType.AT_PAGE); > > // Setting the vertical and horizontal position > int height = (i * page_size.Height) + 1000; > > xShapeProps.setPropertyValue("VertOrient", new > Short(VertOrientation.NONE)); > xShapeProps.setPropertyValue("HoriOrient", new > Short(HoriOrientation.NONE)); > xShapeProps.setPropertyValue("HoriOrientPosition", new > Integer(1000)); > xShapeProps.setPropertyValue("VertOrientPosition", new > Integer(height)); > > // Set the width and height of the shape. > xShapeProps.setPropertyValue("FrameWidthAbsolute", new > Integer(frame_size.Width)); > xShapeProps.setPropertyValue("FrameHeightAbsolute", new > Integer(frame_size.Height)); > xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new > Boolean(false)); > xShapeProps.setPropertyValue("SizeType", new > Short((short)1)); > > xShapeProps.setPropertyValue("LeftBorderDistance", new > Integer(200)); > xShapeProps.setPropertyValue("RightBorderDistance", new > Integer(200)); > xShapeProps.setPropertyValue("TopBorderDistance", new > Integer(200)); > xShapeProps.setPropertyValue("BottomBorderDistance", new > Integer(200)); > > // Insert a paragraph break into the document (not the > frame) > xText.insertControlCharacter (xTextCursor, > ControlCharacter.PARAGRAPH_BREAK, false); > > XPropertySet xCursorProps = > (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); > > xCursorProps.setPropertyValue("BreakType", > com.sun.star.style.BreakType.PAGE_AFTER); > > xText.insertControlCharacter(xTextCursor, > ControlCharacter.PARAGRAPH_BREAK, false); > > xTextCursor.gotoEnd(false); > } catch (Exception e) { > System.out.println(e.getMessage()); > > e.printStackTrace(); > } > } > } > > > Which allows me to grab the existing textfram. I then attempt to change the > verticial position based on the page size, and once moved add a new page to > the document and updating the height value for the next frame's > translation... > > This doesn't seem to work, ie., the textframe(s) do not move to the next > page, they don't translate, the seem to move down the page by increments of > 1000? Shouldn't the Anchor, AT_PAGE move to the "second", "third" or etc. > etc. page, rather than stick to page 1? > AT_PAGE is the only option, but the vertical position is calqulated from the begining off the document, so for every Page you have to ad the hight off every page . And i think a viewCursor gives you information about the pagenr wher the frame is located. Hope it helps Fernand > thanks for any help you may be able to shed. > > > > Chris Fleischmann wrote: > >> Hello folks, I have TextFrames, that are created like so (at the beginning >> of the process): >> >> private XText getTextFrame(XText xText, int x, int y) { >> try { >> Object textFrame = >> xWriterFactory.createInstance("com.sun.star.text.TextFrame"); >> >> XTextContent xTextContentFrame = (XTextContent) >> UnoRuntime.queryInterface(XTextContent.class, textFrame); >> >> XPropertySet xShapeProps = (XPropertySet) >> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >> >> xShapeProps.setPropertyValue("AnchorType", >> TextContentAnchorType.AT_PARAGRAPH); >> >> // Setting the vertical and horizontal position >> xShapeProps.setPropertyValue("VertOrient", new >> Short(VertOrientation.NONE)); >> xShapeProps.setPropertyValue("HoriOrient", new >> Short(HoriOrientation.NONE)); >> xShapeProps.setPropertyValue("VertOrientPosition", new >> Integer(x)); >> xShapeProps.setPropertyValue("HoriOrientPosition", new >> Integer(y)); >> >> // Set the width and height of the shape. >> xShapeProps.setPropertyValue("FrameWidthAbsolute", new >> Integer(frame_size.Width)); >> xShapeProps.setPropertyValue("FrameHeightAbsolute", new >> Integer(frame_size.Height)); >> xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new >> Boolean(false)); >> xShapeProps.setPropertyValue("SizeType", new Short((short)1)); >> >> xShapeProps.setPropertyValue("LeftBorderDistance", new >> Integer(200)); >> xShapeProps.setPropertyValue("RightBorderDistance", new >> Integer(200)); >> xShapeProps.setPropertyValue("TopBorderDistance", new >> Integer(200)); >> xShapeProps.setPropertyValue("BottomBorderDistance", new >> Integer(200)); >> >> xText.insertTextContent(xText.getEnd(), xTextContentFrame, >> false); >> >> XText xFrameText = (XText) >> UnoRuntime.queryInterface(XText.class, textFrame); >> >> return xFrameText; >> } catch (java.lang.Exception e) { >> e.printStackTrace(); >> } >> >> return null; >> } >> >> This method seems to work, it creates the textframe with a specific size, >> at a specific x/y location. >> >> I am now attempting to iterate over the "said" textframes like so: >> >> XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) >> UnoRuntime.queryInterface(XTextFramesSupplier.class, >> xWriterComponent_dest); >> >> XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); >> >> String[] textframes = xNamedFrames.getElementNames(); >> >> for (int i = 0; i < textframes.length; i++) { >> XTextFrame textframe = null; >> >> try { >> textframe = >> (XTextFrame)xNamedFrames.getByName(textframes[i]); >> >> XTextContent xFrameContent = (XTextContent) >> UnoRuntime.queryInterface(XTextContent.class, textframe); >> >> XPropertySet xShapeProps = (XPropertySet) >> UnoRuntime.queryInterface(XPropertySet.class, textframe); >> >> Which seems to work, ie., i can iterate over the above "said" frames.... I >> have tried doing: >> >> xShapeProps.setPropertyValue("AnchorType", >> TextContentAnchorType.AT_PARAGRAPH); >> >> // Setting the vertical and horizontal position >> xShapeProps.setPropertyValue("VertOrient", new >> Short(VertOrientation.NONE)); >> xShapeProps.setPropertyValue("HoriOrient", new >> Short(HoriOrientation.NONE)); >> xShapeProps.setPropertyValue("VertOrientPosition", new >> Integer(1000 + (i * 1000))); >> xShapeProps.setPropertyValue("HoriOrientPosition", new >> Integer(1000)); >> >> so as to move the frames slowly but sure down the page.... >> >> That doesn't seem to work? >> >> Secondly, is there a way to create a new page between each cycle so that I >> can move the textframe to the new page with the same, x/y origin? >> >> Thanks in advance for any help you can shed on the issue, >> >> Chris >> >> >> > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?Hi, Yes, I am trying to calculate the height like so,
(i * page_size.Height) + 1000 The page_size.Height was calculated previously, ie., 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; I have also tried the following: private void moveTextFrames() { XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, xWriterComponent_dest); XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xNamedFrames); XTextContent xFrameContent[] = new XTextContent[xIndexAccess.getCount()]; XPropertySet xShapeProps[] = new XPropertySet[xIndexAccess.getCount()]; XText xText = xTextDocument_dest.getText(); XTextCursor xTextCursor = xText.createTextCursor(); for (int i = 0; i < xIndexAccess.getCount(); i++) { try { Any xImageAny = (Any) xIndexAccess.getByIndex(i); Object textFrame = xImageAny.getObject(); xFrameContent[i] = (XTextContent)textFrame; xShapeProps[i] = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, textFrame); xShapeProps[i].setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE); // Setting the vertical and horizontal position long height = (i * page_size.Height) + 1000; xShapeProps[i].setPropertyValue("VertOrientPosition", height); // Insert a paragraph break into the document (not the frame) xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false); XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); xCursorProps.setPropertyValue("BreakType", com.sun.star.style.BreakType.PAGE_AFTER); xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } } Which doesn't seem to work either, see attached. test.odt Is there a problem specifying a "long" for the vertical position, rather than an "Integer", ie., the value when you get to page 3 or 4 is over 32768 pixels high. Any thoughts, do I have to move the view cursor or something or somehow to get the anchor on to the next page.. I notice when I try it manually, i need to "cut" the text frame, move to the next page and paste the frame, I then notice that the anchor is moved to the right page.. At present, it seems all of the textframes remain on page1 in top/left corner. I can happily move the textframes using the above technique around the first page, but not on to the next page.... Your help is greatly appreciated. Chris
|
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?Chris ,
Long is needed because integer is to small and there are different properties who has to been set properly. Please find the basic code i uses to place Frames without any problem iPagenr = oViewCursor.page iHCpos = oViewCursor.getPosition().X iVCpos = oViewCursor.getPosition().Y - (30700 * (iPagenr -1)) ' Vieuwcursor rekend steeds van begin van document oFrame.SetPropertyValue("AnchorPageNo", iPagenr) oFrame.AnchorType = lAnchor oFrame.PositionProtected = False oFrame.SizeProtected = false oFrame.ContentProtected = false oFrame.HoriOrient = NONE oFrame.VertOrient = NONE oFrame.VertOrientRelation = PAGE_PRINT_AREA oFrame.HoriOrientRelation = PAGE_PRINT_AREA oText.insertTextContent(oCursor(), oFrame, false) hope i helps Fernand > Hi, Yes, I am trying to calculate the height like so, > > (i * page_size.Height) + 1000 > > The page_size.Height was calculated previously, ie., > > 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; > > > I have also tried the following: > > private void moveTextFrames() { > XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) > UnoRuntime.queryInterface(XTextFramesSupplier.class, > xWriterComponent_dest); > > XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); > > XIndexAccess xIndexAccess = (XIndexAccess) > UnoRuntime.queryInterface( > XIndexAccess.class, xNamedFrames); > > XTextContent xFrameContent[] = new > XTextContent[xIndexAccess.getCount()]; > XPropertySet xShapeProps[] = new > XPropertySet[xIndexAccess.getCount()]; > > XText xText = xTextDocument_dest.getText(); > > XTextCursor xTextCursor = xText.createTextCursor(); > > for (int i = 0; i < xIndexAccess.getCount(); i++) { > try { > Any xImageAny = (Any) xIndexAccess.getByIndex(i); > Object textFrame = xImageAny.getObject(); > > xFrameContent[i] = (XTextContent)textFrame; > > xShapeProps[i] = (XPropertySet) > UnoRuntime.queryInterface(XPropertySet.class, textFrame); > > xShapeProps[i].setPropertyValue("AnchorType", > TextContentAnchorType.AT_PAGE); > > // Setting the vertical and horizontal position > long height = (i * page_size.Height) + 1000; > > //xShapeProps.setPropertyValue("VertOrient", new > Short(VertOrientation.NONE)); > //xShapeProps.setPropertyValue("HoriOrient", new > Short(HoriOrientation.NONE)); > //xShapeProps.setPropertyValue("HoriOrientPosition", new > Integer(1000)); > xShapeProps[i].setPropertyValue("VertOrientPosition", > height); > > // Set the width and height of the shape. > //xShapeProps.setPropertyValue("FrameWidthAbsolute", new > Integer(frame_size.Width)); > //xShapeProps.setPropertyValue("FrameHeightAbsolute", new > Integer(frame_size.Height)); > //xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new > Boolean(false)); > //xShapeProps.setPropertyValue("SizeType", new > Short((short)1)); > > //xShapeProps.setPropertyValue("LeftBorderDistance", new > Integer(200)); > //xShapeProps.setPropertyValue("RightBorderDistance", new > Integer(200)); > //xShapeProps.setPropertyValue("TopBorderDistance", new > Integer(200)); > //xShapeProps.setPropertyValue("BottomBorderDistance", new > Integer(200)); > > // Insert a paragraph break into the document (not the > frame) > xText.insertControlCharacter(xTextCursor, > ControlCharacter.PARAGRAPH_BREAK, false); > > XPropertySet xCursorProps = > (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); > > xCursorProps.setPropertyValue("BreakType", > com.sun.star.style.BreakType.PAGE_AFTER); > > xText.insertControlCharacter(xTextCursor, > ControlCharacter.PARAGRAPH_BREAK, false); > > } catch (Exception e) { > System.out.println(e.getMessage()); > > e.printStackTrace(); > } > } > } > > Which doesn't seem to work either, see attached. > > Is there a problem specifying a "long" for the vertical position, rather > than an "Integer", ie., the value when you get to page 3 or 4 is over 32768 > pixels high. > > Any thoughts, do I have to move the view cursor or something or somehow to > get the anchor on to the next page.. I notice when I try it manually, i need > to "cut" the text frame, move to the next page and paste the frame, I then > notice that the anchor is moved to the right page.. > > At present, it seems all of the textframes remain on page1 in top/left > corner. > > I can happily move the textframes using the above technique around the first > page, but not on to the next page.... > > Your help is greatly appreciated. > > Chris > > > > > > > > Fernand Vanrie wrote: > >> Chris Fleischmann wrote: >> >>> I have gotten so far as; >>> >>> 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(); >>> >>> XTextCursor xTextCursor = xText.createTextCursor(); >>> >>> for (int i = 0; i < xIndexAccess.getCount(); i++) { >>> try { >>> Any xImageAny = (Any) xIndexAccess.getByIndex(i); >>> Object textFrame = xImageAny.getObject(); >>> >>> XTextContent xFrameContent = (XTextContent)textFrame; >>> >>> XPropertySet xShapeProps = (XPropertySet) >>> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >>> >>> xShapeProps.setPropertyValue("AnchorType", >>> TextContentAnchorType.AT_PAGE); >>> >>> // Setting the vertical and horizontal position >>> int height = (i * page_size.Height) + 1000; >>> >>> xShapeProps.setPropertyValue("VertOrient", new >>> Short(VertOrientation.NONE)); >>> xShapeProps.setPropertyValue("HoriOrient", new >>> Short(HoriOrientation.NONE)); >>> xShapeProps.setPropertyValue("HoriOrientPosition", new >>> Integer(1000)); >>> xShapeProps.setPropertyValue("VertOrientPosition", new >>> Integer(height)); >>> >>> // Set the width and height of the shape. >>> xShapeProps.setPropertyValue("FrameWidthAbsolute", new >>> Integer(frame_size.Width)); >>> xShapeProps.setPropertyValue("FrameHeightAbsolute", new >>> Integer(frame_size.Height)); >>> xShapeProps.setPropertyValue("FrameIsAutomaticHeight", >>> new >>> Boolean(false)); >>> xShapeProps.setPropertyValue("SizeType", new >>> Short((short)1)); >>> >>> xShapeProps.setPropertyValue("LeftBorderDistance", new >>> Integer(200)); >>> xShapeProps.setPropertyValue("RightBorderDistance", new >>> Integer(200)); >>> xShapeProps.setPropertyValue("TopBorderDistance", new >>> Integer(200)); >>> xShapeProps.setPropertyValue("BottomBorderDistance", new >>> Integer(200)); >>> >>> // Insert a paragraph break into the document (not the >>> frame) >>> xText.insertControlCharacter (xTextCursor, >>> ControlCharacter.PARAGRAPH_BREAK, false); >>> >>> XPropertySet xCursorProps = >>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); >>> >>> xCursorProps.setPropertyValue("BreakType", >>> com.sun.star.style.BreakType.PAGE_AFTER); >>> >>> xText.insertControlCharacter(xTextCursor, >>> ControlCharacter.PARAGRAPH_BREAK, false); >>> >>> xTextCursor.gotoEnd(false); >>> } catch (Exception e) { >>> System.out.println(e.getMessage()); >>> >>> e.printStackTrace(); >>> } >>> } >>> } >>> >>> >>> Which allows me to grab the existing textfram. I then attempt to change >>> the >>> verticial position based on the page size, and once moved add a new page >>> to >>> the document and updating the height value for the next frame's >>> translation... >>> >>> This doesn't seem to work, ie., the textframe(s) do not move to the next >>> page, they don't translate, the seem to move down the page by increments >>> of >>> 1000? Shouldn't the Anchor, AT_PAGE move to the "second", "third" or etc. >>> etc. page, rather than stick to page 1? >>> >>> >> Chris, >> >> AT_PAGE is the only option, but the vertical position is calqulated from >> the begining off the document, so for every Page you have to ad the >> hight off every page . >> And i think a viewCursor gives you information about the pagenr wher >> the frame is located. >> >> Hope it helps >> >> Fernand >> >>> thanks for any help you may be able to shed. >>> >>> >>> >>> Chris Fleischmann wrote: >>> >>> >>>> Hello folks, I have TextFrames, that are created like so (at the >>>> beginning >>>> of the process): >>>> >>>> private XText getTextFrame(XText xText, int x, int y) { >>>> try { >>>> Object textFrame = >>>> xWriterFactory.createInstance("com.sun.star.text.TextFrame"); >>>> >>>> XTextContent xTextContentFrame = (XTextContent) >>>> UnoRuntime.queryInterface(XTextContent.class, textFrame); >>>> >>>> XPropertySet xShapeProps = (XPropertySet) >>>> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >>>> >>>> xShapeProps.setPropertyValue("AnchorType", >>>> TextContentAnchorType.AT_PARAGRAPH); >>>> >>>> // Setting the vertical and horizontal position >>>> xShapeProps.setPropertyValue("VertOrient", new >>>> Short(VertOrientation.NONE)); >>>> xShapeProps.setPropertyValue("HoriOrient", new >>>> Short(HoriOrientation.NONE)); >>>> xShapeProps.setPropertyValue("VertOrientPosition", new >>>> Integer(x)); >>>> xShapeProps.setPropertyValue("HoriOrientPosition", new >>>> Integer(y)); >>>> >>>> // Set the width and height of the shape. >>>> xShapeProps.setPropertyValue("FrameWidthAbsolute", new >>>> Integer(frame_size.Width)); >>>> xShapeProps.setPropertyValue("FrameHeightAbsolute", new >>>> Integer(frame_size.Height)); >>>> xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new >>>> Boolean(false)); >>>> xShapeProps.setPropertyValue("SizeType", new >>>> Short((short)1)); >>>> >>>> xShapeProps.setPropertyValue("LeftBorderDistance", new >>>> Integer(200)); >>>> xShapeProps.setPropertyValue("RightBorderDistance", new >>>> Integer(200)); >>>> xShapeProps.setPropertyValue("TopBorderDistance", new >>>> Integer(200)); >>>> xShapeProps.setPropertyValue("BottomBorderDistance", new >>>> Integer(200)); >>>> >>>> xText.insertTextContent(xText.getEnd(), xTextContentFrame, >>>> false); >>>> >>>> XText xFrameText = (XText) >>>> UnoRuntime.queryInterface(XText.class, textFrame); >>>> >>>> return xFrameText; >>>> } catch (java.lang.Exception e) { >>>> e.printStackTrace(); >>>> } >>>> >>>> return null; >>>> } >>>> >>>> This method seems to work, it creates the textframe with a specific >>>> size, >>>> at a specific x/y location. >>>> >>>> I am now attempting to iterate over the "said" textframes like so: >>>> >>>> XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) >>>> UnoRuntime.queryInterface(XTextFramesSupplier.class, >>>> xWriterComponent_dest); >>>> >>>> XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); >>>> >>>> String[] textframes = xNamedFrames.getElementNames(); >>>> >>>> for (int i = 0; i < textframes.length; i++) { >>>> XTextFrame textframe = null; >>>> >>>> try { >>>> textframe = >>>> (XTextFrame)xNamedFrames.getByName(textframes[i]); >>>> >>>> XTextContent xFrameContent = (XTextContent) >>>> UnoRuntime.queryInterface(XTextContent.class, textframe); >>>> >>>> XPropertySet xShapeProps = (XPropertySet) >>>> UnoRuntime.queryInterface(XPropertySet.class, textframe); >>>> >>>> Which seems to work, ie., i can iterate over the above "said" frames.... >>>> I >>>> have tried doing: >>>> >>>> xShapeProps.setPropertyValue("AnchorType", >>>> TextContentAnchorType.AT_PARAGRAPH); >>>> >>>> // Setting the vertical and horizontal position >>>> xShapeProps.setPropertyValue("VertOrient", new >>>> Short(VertOrientation.NONE)); >>>> xShapeProps.setPropertyValue("HoriOrient", new >>>> Short(HoriOrientation.NONE)); >>>> xShapeProps.setPropertyValue("VertOrientPosition", new >>>> Integer(1000 + (i * 1000))); >>>> xShapeProps.setPropertyValue("HoriOrientPosition", new >>>> Integer(1000)); >>>> >>>> so as to move the frames slowly but sure down the page.... >>>> >>>> That doesn't seem to work? >>>> >>>> Secondly, is there a way to create a new page between each cycle so that >>>> I >>>> can move the textframe to the new page with the same, x/y origin? >>>> >>>> Thanks in advance for any help you can shed on the issue, >>>> >>>> Chris >>>> >>>> >>>> >>>> >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@... >> For additional commands, e-mail: dev-help@... >> >> >> >> > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?Thanks for the tips... my method is now;
private void moveTextFrames() { XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, xWriterComponent_dest); XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xNamedFrames); XTextContent xFrameContent[] = new XTextContent[xIndexAccess.getCount()]; XPropertySet xShapeProps[] = new XPropertySet[xIndexAccess.getCount()]; 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_sourceDoc = xViewCursorSupplier_targetDoc.getViewCursor(); /* XPageCursor xPageCursor = (XPageCursor) UnoRuntime.queryInterface( XPageCursor.class, xTextViewCursor_sourceDoc); */ for (int i = 0; i < xIndexAccess.getCount(); i++) { try { Any xImageAny = (Any) xIndexAccess.getByIndex(i); Object textFrame = xImageAny.getObject(); xFrameContent[i] = (XTextContent)textFrame; xShapeProps[i] = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, textFrame); // Setting the vertical and horizontal position long height = (i * page_size.Height) + 1000; System.out.println("height: " + height); // Setting the vertical and horizontal position xShapeProps[i].setPropertyValue("AnchorPageNo", new Short((short)(i + 1))); xShapeProps[i].setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE); xShapeProps[i].setPropertyValue("VertOrient", new Short(VertOrientation.NONE)); xShapeProps[i].setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE)); xShapeProps[i].setPropertyValue("VertOrientPosition", new Long(height)); xShapeProps[i].setPropertyValue("HoriOrientPosition", new Integer(1000)); xShapeProps[i].setPropertyValue("HoriOrientRelation", (short)50); xShapeProps[i].setPropertyValue("VertOrientRelation", (short)50); // Set the width and height of the shape. xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new Integer(frame_size.Width)); xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new Integer(frame_size.Height)); xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight", new Boolean(false)); xShapeProps[i].setPropertyValue("SizeType", new Short((short)1)); xShapeProps[i].setPropertyValue("LeftBorderDistance", new Integer(200)); xShapeProps[i].setPropertyValue("RightBorderDistance", new Integer(200)); xShapeProps[i].setPropertyValue("TopBorderDistance", new Integer(200)); xShapeProps[i].setPropertyValue("BottomBorderDistance", new Integer(200)); // Insert a paragraph break into the document (not the frame) xText.insertControlCharacter(xTextViewCursor_sourceDoc, ControlCharacter.PARAGRAPH_BREAK, false); XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextViewCursor_sourceDoc); xCursorProps.setPropertyValue("BreakType", com.sun.star.style.BreakType.PAGE_AFTER); xText.insertControlCharacter(xTextViewCursor_sourceDoc, ControlCharacter.PARAGRAPH_BREAK, false); // xTextCursor.collapseToEnd(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } } With your code, are you coming from the "bottom" of your document and working your way up? I also don't believe I need; PositionProtected = False SizeProtected = false ContentProtected = false But still it doesn't work... :( See attachment, text.odt I als notice that there seems to be issues with the longs, ints, shorts etc... as also captured here: http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16089 Any other thoughts? Thanks in advance
|
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?Chris ,
Before you start placing Frames, you must been sure you have already created the right number of pages. anyhow: i placed some code in your documents "standard basic libray module1" this code placed a 1000x1000 frame at the cusor position,you moves your cursor to the right position, or you gives fixed coordinates to replace the cursor position and translates to java :-) Fernand > Thanks for the tips... my method is now; > > private void moveTextFrames() { > XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) > UnoRuntime.queryInterface(XTextFramesSupplier.class, > xWriterComponent_dest); > > XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); > > XIndexAccess xIndexAccess = (XIndexAccess) > UnoRuntime.queryInterface( > XIndexAccess.class, xNamedFrames); > > XTextContent xFrameContent[] = new > XTextContent[xIndexAccess.getCount()]; > XPropertySet xShapeProps[] = new > XPropertySet[xIndexAccess.getCount()]; > > 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_sourceDoc = > xViewCursorSupplier_targetDoc.getViewCursor(); > > /* > XPageCursor xPageCursor = > (XPageCursor) UnoRuntime.queryInterface( > XPageCursor.class, > xTextViewCursor_sourceDoc); > */ > > for (int i = 0; i < xIndexAccess.getCount(); i++) { > try { > Any xImageAny = (Any) xIndexAccess.getByIndex(i); > Object textFrame = xImageAny.getObject(); > > xFrameContent[i] = (XTextContent)textFrame; > > xShapeProps[i] = (XPropertySet) > UnoRuntime.queryInterface(XPropertySet.class, textFrame); > > // Setting the vertical and horizontal position > long height = (i * page_size.Height) + 1000; > > System.out.println("height: " + height); > > // Setting the vertical and horizontal position > > xShapeProps[i].setPropertyValue("AnchorPageNo", new > Short((short)(i + 1))); > > xShapeProps[i].setPropertyValue("AnchorType", > TextContentAnchorType.AT_PAGE); > > xShapeProps[i].setPropertyValue("VertOrient", new > Short(VertOrientation.NONE)); > xShapeProps[i].setPropertyValue("HoriOrient", new > Short(HoriOrientation.NONE)); > xShapeProps[i].setPropertyValue("VertOrientPosition", new > Long(height)); > xShapeProps[i].setPropertyValue("HoriOrientPosition", new > Integer(1000)); > > xShapeProps[i].setPropertyValue("HoriOrientRelation", > (short)50); > xShapeProps[i].setPropertyValue("VertOrientRelation", > (short)50); > > // Set the width and height of the shape. > xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new > Integer(frame_size.Width)); > xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new > Integer(frame_size.Height)); > > xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight", > new Boolean(false)); > xShapeProps[i].setPropertyValue("SizeType", new > Short((short)1)); > > xShapeProps[i].setPropertyValue("LeftBorderDistance", new > Integer(200)); > xShapeProps[i].setPropertyValue("RightBorderDistance", new > Integer(200)); > xShapeProps[i].setPropertyValue("TopBorderDistance", new > Integer(200)); > xShapeProps[i].setPropertyValue("BottomBorderDistance", new > Integer(200)); > > // Insert a paragraph break into the document (not the > frame) > xText.insertControlCharacter(xTextViewCursor_sourceDoc, > ControlCharacter.PARAGRAPH_BREAK, false); > > XPropertySet xCursorProps = > (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, > xTextViewCursor_sourceDoc); > > xCursorProps.setPropertyValue("BreakType", > com.sun.star.style.BreakType.PAGE_AFTER); > > xText.insertControlCharacter(xTextViewCursor_sourceDoc, > ControlCharacter.PARAGRAPH_BREAK, false); > // xTextCursor.collapseToEnd(); > > } catch (Exception e) { > System.out.println(e.getMessage()); > > e.printStackTrace(); > } > } > } > > > With your code, are you coming from the "bottom" of your document and > working your way up? > > I also don't believe I need; > > PositionProtected = False > SizeProtected = false > ContentProtected = false > > But still it doesn't work... :( > > See attachment, http://www.nabble.com/file/p24164747/text.odt text.odt > > I als notice that there seems to be issues with the longs, ints, shorts > etc... as also captured here: > http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16089 > > Any other thoughts? > > Thanks in advance > > > Fernand Vanrie wrote: > >> Chris , >> >> Long is needed because integer is to small and there are different >> properties who has to been set properly. >> >> Please find the basic code i uses to place Frames without any problem >> >> iPagenr = oViewCursor.page >> iHCpos = oViewCursor.getPosition().X >> iVCpos = oViewCursor.getPosition().Y - (30700 * (iPagenr -1)) ' >> Vieuwcursor rekend steeds van begin van document >> >> oFrame.SetPropertyValue("AnchorPageNo", iPagenr) >> oFrame.AnchorType = lAnchor >> oFrame.PositionProtected = False >> oFrame.SizeProtected = false >> oFrame.ContentProtected = false >> oFrame.HoriOrient = NONE >> oFrame.VertOrient = NONE >> oFrame.VertOrientRelation = PAGE_PRINT_AREA >> oFrame.HoriOrientRelation = PAGE_PRINT_AREA >> >> oText.insertTextContent(oCursor(), oFrame, false) >> >> hope i helps >> >> Fernand >> >>> Hi, Yes, I am trying to calculate the height like so, >>> >>> (i * page_size.Height) + 1000 >>> >>> The page_size.Height was calculated previously, ie., >>> >>> 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; >>> >>> >>> I have also tried the following: >>> >>> private void moveTextFrames() { >>> XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) >>> UnoRuntime.queryInterface(XTextFramesSupplier.class, >>> xWriterComponent_dest); >>> >>> XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); >>> >>> XIndexAccess xIndexAccess = (XIndexAccess) >>> UnoRuntime.queryInterface( >>> XIndexAccess.class, xNamedFrames); >>> >>> XTextContent xFrameContent[] = new >>> XTextContent[xIndexAccess.getCount()]; >>> XPropertySet xShapeProps[] = new >>> XPropertySet[xIndexAccess.getCount()]; >>> >>> XText xText = xTextDocument_dest.getText(); >>> >>> XTextCursor xTextCursor = xText.createTextCursor(); >>> >>> for (int i = 0; i < xIndexAccess.getCount(); i++) { >>> try { >>> Any xImageAny = (Any) xIndexAccess.getByIndex(i); >>> Object textFrame = xImageAny.getObject(); >>> >>> xFrameContent[i] = (XTextContent)textFrame; >>> >>> xShapeProps[i] = (XPropertySet) >>> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >>> >>> xShapeProps[i].setPropertyValue("AnchorType", >>> TextContentAnchorType.AT_PAGE); >>> >>> // Setting the vertical and horizontal position >>> long height = (i * page_size.Height) + 1000; >>> >>> //xShapeProps.setPropertyValue("VertOrient", new >>> Short(VertOrientation.NONE)); >>> //xShapeProps.setPropertyValue("HoriOrient", new >>> Short(HoriOrientation.NONE)); >>> //xShapeProps.setPropertyValue("HoriOrientPosition", new >>> Integer(1000)); >>> xShapeProps[i].setPropertyValue("VertOrientPosition", >>> height); >>> >>> // Set the width and height of the shape. >>> //xShapeProps.setPropertyValue("FrameWidthAbsolute", new >>> Integer(frame_size.Width)); >>> //xShapeProps.setPropertyValue("FrameHeightAbsolute", new >>> Integer(frame_size.Height)); >>> //xShapeProps.setPropertyValue("FrameIsAutomaticHeight", >>> new >>> Boolean(false)); >>> //xShapeProps.setPropertyValue("SizeType", new >>> Short((short)1)); >>> >>> //xShapeProps.setPropertyValue("LeftBorderDistance", new >>> Integer(200)); >>> //xShapeProps.setPropertyValue("RightBorderDistance", new >>> Integer(200)); >>> //xShapeProps.setPropertyValue("TopBorderDistance", new >>> Integer(200)); >>> //xShapeProps.setPropertyValue("BottomBorderDistance", >>> new >>> Integer(200)); >>> >>> // Insert a paragraph break into the document (not the >>> frame) >>> xText.insertControlCharacter(xTextCursor, >>> ControlCharacter.PARAGRAPH_BREAK, false); >>> >>> XPropertySet xCursorProps = >>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); >>> >>> xCursorProps.setPropertyValue("BreakType", >>> com.sun.star.style.BreakType.PAGE_AFTER); >>> >>> xText.insertControlCharacter(xTextCursor, >>> ControlCharacter.PARAGRAPH_BREAK, false); >>> >>> } catch (Exception e) { >>> System.out.println(e.getMessage()); >>> >>> e.printStackTrace(); >>> } >>> } >>> } >>> >>> Which doesn't seem to work either, see attached. >>> >>> Is there a problem specifying a "long" for the vertical position, rather >>> than an "Integer", ie., the value when you get to page 3 or 4 is over >>> 32768 >>> pixels high. >>> >>> Any thoughts, do I have to move the view cursor or something or somehow >>> to >>> get the anchor on to the next page.. I notice when I try it manually, i >>> need >>> to "cut" the text frame, move to the next page and paste the frame, I >>> then >>> notice that the anchor is moved to the right page.. >>> >>> At present, it seems all of the textframes remain on page1 in top/left >>> corner. >>> >>> I can happily move the textframes using the above technique around the >>> first >>> page, but not on to the next page.... >>> >>> Your help is greatly appreciated. >>> >>> Chris >>> >>> >>> >>> >>> >>> >>> >>> Fernand Vanrie wrote: >>> >>> >>>> Chris Fleischmann wrote: >>>> >>>> >>>>> I have gotten so far as; >>>>> >>>>> 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(); >>>>> >>>>> XTextCursor xTextCursor = xText.createTextCursor(); >>>>> >>>>> for (int i = 0; i < xIndexAccess.getCount(); i++) { >>>>> try { >>>>> Any xImageAny = (Any) xIndexAccess.getByIndex(i); >>>>> Object textFrame = xImageAny.getObject(); >>>>> >>>>> XTextContent xFrameContent = (XTextContent)textFrame; >>>>> >>>>> XPropertySet xShapeProps = (XPropertySet) >>>>> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >>>>> >>>>> xShapeProps.setPropertyValue("AnchorType", >>>>> TextContentAnchorType.AT_PAGE); >>>>> >>>>> // Setting the vertical and horizontal position >>>>> int height = (i * page_size.Height) + 1000; >>>>> >>>>> xShapeProps.setPropertyValue("VertOrient", new >>>>> Short(VertOrientation.NONE)); >>>>> xShapeProps.setPropertyValue("HoriOrient", new >>>>> Short(HoriOrientation.NONE)); >>>>> xShapeProps.setPropertyValue("HoriOrientPosition", new >>>>> Integer(1000)); >>>>> xShapeProps.setPropertyValue("VertOrientPosition", new >>>>> Integer(height)); >>>>> >>>>> // Set the width and height of the shape. >>>>> xShapeProps.setPropertyValue("FrameWidthAbsolute", new >>>>> Integer(frame_size.Width)); >>>>> xShapeProps.setPropertyValue("FrameHeightAbsolute", new >>>>> Integer(frame_size.Height)); >>>>> xShapeProps.setPropertyValue("FrameIsAutomaticHeight", >>>>> new >>>>> Boolean(false)); >>>>> xShapeProps.setPropertyValue("SizeType", new >>>>> Short((short)1)); >>>>> >>>>> xShapeProps.setPropertyValue("LeftBorderDistance", new >>>>> Integer(200)); >>>>> xShapeProps.setPropertyValue("RightBorderDistance", new >>>>> Integer(200)); >>>>> xShapeProps.setPropertyValue("TopBorderDistance", new >>>>> Integer(200)); >>>>> xShapeProps.setPropertyValue("BottomBorderDistance", >>>>> new >>>>> Integer(200)); >>>>> >>>>> // Insert a paragraph break into the document (not the >>>>> frame) >>>>> xText.insertControlCharacter (xTextCursor, >>>>> ControlCharacter.PARAGRAPH_BREAK, false); >>>>> >>>>> XPropertySet xCursorProps = >>>>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, >>>>> xTextCursor); >>>>> >>>>> xCursorProps.setPropertyValue("BreakType", >>>>> com.sun.star.style.BreakType.PAGE_AFTER); >>>>> >>>>> xText.insertControlCharacter(xTextCursor, >>>>> ControlCharacter.PARAGRAPH_BREAK, false); >>>>> >>>>> xTextCursor.gotoEnd(false); >>>>> } catch (Exception e) { >>>>> System.out.println(e.getMessage()); >>>>> >>>>> e.printStackTrace(); >>>>> } >>>>> } >>>>> } >>>>> >>>>> >>>>> Which allows me to grab the existing textfram. I then attempt to change >>>>> the >>>>> verticial position based on the page size, and once moved add a new >>>>> page >>>>> to >>>>> the document and updating the height value for the next frame's >>>>> translation... >>>>> >>>>> This doesn't seem to work, ie., the textframe(s) do not move to the >>>>> next >>>>> page, they don't translate, the seem to move down the page by >>>>> increments >>>>> of >>>>> 1000? Shouldn't the Anchor, AT_PAGE move to the "second", "third" or >>>>> etc. >>>>> etc. page, rather than stick to page 1? >>>>> >>>>> >>>>> >>>> Chris, >>>> >>>> AT_PAGE is the only option, but the vertical position is calqulated from >>>> the begining off the document, so for every Page you have to ad the >>>> hight off every page . >>>> And i think a viewCursor gives you information about the pagenr wher >>>> the frame is located. >>>> >>>> Hope it helps >>>> >>>> Fernand >>>> >>>> >>>>> thanks for any help you may be able to shed. >>>>> >>>>> >>>>> >>>>> Chris Fleischmann wrote: >>>>> >>>>> >>>>> >>>>>> Hello folks, I have TextFrames, that are created like so (at the >>>>>> beginning >>>>>> of the process): >>>>>> >>>>>> private XText getTextFrame(XText xText, int x, int y) { >>>>>> try { >>>>>> Object textFrame = >>>>>> xWriterFactory.createInstance("com.sun.star.text.TextFrame"); >>>>>> >>>>>> XTextContent xTextContentFrame = (XTextContent) >>>>>> UnoRuntime.queryInterface(XTextContent.class, textFrame); >>>>>> >>>>>> XPropertySet xShapeProps = (XPropertySet) >>>>>> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >>>>>> >>>>>> xShapeProps.setPropertyValue("AnchorType", >>>>>> TextContentAnchorType.AT_PARAGRAPH); >>>>>> >>>>>> // Setting the vertical and horizontal position >>>>>> xShapeProps.setPropertyValue("VertOrient", new >>>>>> Short(VertOrientation.NONE)); >>>>>> xShapeProps.setPropertyValue("HoriOrient", new >>>>>> Short(HoriOrientation.NONE)); >>>>>> xShapeProps.setPropertyValue("VertOrientPosition", new >>>>>> Integer(x)); >>>>>> xShapeProps.setPropertyValue("HoriOrientPosition", new >>>>>> Integer(y)); >>>>>> >>>>>> // Set the width and height of the shape. >>>>>> xShapeProps.setPropertyValue("FrameWidthAbsolute", new >>>>>> Integer(frame_size.Width)); >>>>>> xShapeProps.setPropertyValue("FrameHeightAbsolute", new >>>>>> Integer(frame_size.Height)); >>>>>> xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new >>>>>> Boolean(false)); >>>>>> xShapeProps.setPropertyValue("SizeType", new >>>>>> Short((short)1)); >>>>>> >>>>>> xShapeProps.setPropertyValue("LeftBorderDistance", new >>>>>> Integer(200)); >>>>>> xShapeProps.setPropertyValue("RightBorderDistance", new >>>>>> Integer(200)); >>>>>> xShapeProps.setPropertyValue("TopBorderDistance", new >>>>>> Integer(200)); >>>>>> xShapeProps.setPropertyValue("BottomBorderDistance", new >>>>>> Integer(200)); >>>>>> >>>>>> xText.insertTextContent(xText.getEnd(), xTextContentFrame, >>>>>> false); >>>>>> >>>>>> XText xFrameText = (XText) >>>>>> UnoRuntime.queryInterface(XText.class, textFrame); >>>>>> >>>>>> return xFrameText; >>>>>> } catch (java.lang.Exception e) { >>>>>> e.printStackTrace(); >>>>>> } >>>>>> >>>>>> return null; >>>>>> } >>>>>> >>>>>> This method seems to work, it creates the textframe with a specific >>>>>> size, >>>>>> at a specific x/y location. >>>>>> >>>>>> I am now attempting to iterate over the "said" textframes like so: >>>>>> >>>>>> XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) >>>>>> UnoRuntime.queryInterface(XTextFramesSupplier.class, >>>>>> xWriterComponent_dest); >>>>>> >>>>>> XNameAccess xNamedFrames = >>>>>> xTextFramesSupplier.getTextFrames(); >>>>>> >>>>>> String[] textframes = xNamedFrames.getElementNames(); >>>>>> >>>>>> for (int i = 0; i < textframes.length; i++) { >>>>>> XTextFrame textframe = null; >>>>>> >>>>>> try { >>>>>> textframe = >>>>>> (XTextFrame)xNamedFrames.getByName(textframes[i]); >>>>>> >>>>>> XTextContent xFrameContent = (XTextContent) >>>>>> UnoRuntime.queryInterface(XTextContent.class, textframe); >>>>>> >>>>>> XPropertySet xShapeProps = (XPropertySet) >>>>>> UnoRuntime.queryInterface(XPropertySet.class, textframe); >>>>>> >>>>>> Which seems to work, ie., i can iterate over the above "said" >>>>>> frames.... >>>>>> I >>>>>> have tried doing: >>>>>> >>>>>> xShapeProps.setPropertyValue("AnchorType", >>>>>> TextContentAnchorType.AT_PARAGRAPH); >>>>>> >>>>>> // Setting the vertical and horizontal position >>>>>> xShapeProps.setPropertyValue("VertOrient", new >>>>>> Short(VertOrientation.NONE)); >>>>>> xShapeProps.setPropertyValue("HoriOrient", new >>>>>> Short(HoriOrientation.NONE)); >>>>>> xShapeProps.setPropertyValue("VertOrientPosition", new >>>>>> Integer(1000 + (i * 1000))); >>>>>> xShapeProps.setPropertyValue("HoriOrientPosition", new >>>>>> Integer(1000)); >>>>>> >>>>>> so as to move the frames slowly but sure down the page.... >>>>>> >>>>>> That doesn't seem to work? >>>>>> >>>>>> Secondly, is there a way to create a new page between each cycle so >>>>>> that >>>>>> I >>>>>> can move the textframe to the new page with the same, x/y origin? >>>>>> >>>>>> Thanks in advance for any help you can shed on the issue, >>>>>> >>>>>> Chris >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: dev-unsubscribe@... >>>> For additional commands, e-mail: dev-help@... >>>> >>>> >>>> >>>> >>>> >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@... >> For additional commands, e-mail: dev-help@... >> >> >> >> > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?I'm sorry but your last comment lost me...
Here is my Java method to create the necessary pages and to move the textframes (well trying to): private void moveTextFrames() { XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, xWriterComponent_dest); XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xNamedFrames); XTextContent xFrameContent[] = new XTextContent[xIndexAccess.getCount()]; XPropertySet xShapeProps[] = new XPropertySet[xIndexAccess.getCount()]; 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); xPageCursor.jumpToFirstPage(); xPageCursor.jumpToEndOfPage(); for (int i = 0; i < xIndexAccess.getCount(); 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(); } } xPageCursor.jumpToFirstPage(); for (int i = 0; i < xIndexAccess.getCount(); i++) { try { Any xImageAny = (Any) xIndexAccess.getByIndex(i); Object textFrame = xImageAny.getObject(); xFrameContent[i] = (XTextContent)textFrame; xShapeProps[i] = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, textFrame); int height = xTextViewCursor_targetDoc.getPosition().Y; xShapeProps[i].setPropertyValue("AnchorPageNo", new Short((short)(i + 1))); System.out.println("AnchorPageNo: " + xShapeProps[i].getPropertyValue("AnchorPageNo")); xShapeProps[i].setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE); System.out.println("AnchorType: " + xShapeProps[i].getPropertyValue("AnchorType")); xShapeProps[i].setPropertyValue("VertOrient", new Short(VertOrientation.NONE)); System.out.println("VertOrient: " + xShapeProps[i].getPropertyValue("VertOrient")); xShapeProps[i].setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE)); System.out.println("HoriOrient: " + xShapeProps[i].getPropertyValue("HoriOrient")); xShapeProps[i].setPropertyValue("VertOrientPosition", new Integer(height)); System.out.println("VertOrientPosition: " + xShapeProps[i].getPropertyValue("VertOrientPosition")); xShapeProps[i].setPropertyValue("HoriOrientPosition", new Integer(1000)); System.out.println("HoriOrientPosition: " + xShapeProps[i].getPropertyValue("HoriOrientPosition")); xShapeProps[i].setPropertyValue("HoriOrientRelation", new Short(RelOrientation.PAGE_PRINT_AREA)); System.out.println("HoriOrientRelation: " + xShapeProps[i].getPropertyValue("HoriOrientRelation")); xShapeProps[i].setPropertyValue("VertOrientRelation", new Short(RelOrientation.PAGE_PRINT_AREA)); System.out.println("VertOrientRelation: " + xShapeProps[i].getPropertyValue("VertOrientRelation")); // Set the width and height of the shape. xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new Integer(frame_size.Width)); xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new Integer(frame_size.Height)); xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight", new Boolean(false)); xShapeProps[i].setPropertyValue("SizeType", new Short((short)1)); xShapeProps[i].setPropertyValue("LeftBorderDistance", new Integer(200)); xShapeProps[i].setPropertyValue("RightBorderDistance", new Integer(200)); xShapeProps[i].setPropertyValue("TopBorderDistance", new Integer(200)); xShapeProps[i].setPropertyValue("BottomBorderDistance", new Integer(200)); xPageCursor.jumpToNextPage(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } } The pages are created without any issues... The output as per my println statements shows correct page and heights assuming the first page top, left is 0/0. Basically, what I can do is move the text frame without any issues using the VertOrientPosition and HoriOrientPosition as long as the boundaries for the textframe don't go out of the first page... Meaning I can get the textframes to move around on page 1 no problem... but trying to anchor them on to subsequent pages at the same x/y coordinate on the page isn't working. Again, see attached odt. test.odt
|
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?Here is the output I capture from the println statements:
height: 0 AnchorPageNo: 1 AnchorType: com.sun.star.text.TextContentAnchorType@39060b VertOrient: 0 HoriOrient: 0 VertOrientPosition: 0 HoriOrientPosition: 1000 HoriOrientRelation: 8 VertOrientRelation: 8 height: 21500 AnchorPageNo: 2 AnchorType: com.sun.star.text.TextContentAnchorType@39060b VertOrient: 0 HoriOrient: 0 VertOrientPosition: 21500 HoriOrientPosition: 1000 HoriOrientRelation: 8 VertOrientRelation: 8 height: 43000 AnchorPageNo: 3 AnchorType: com.sun.star.text.TextContentAnchorType@39060b VertOrient: 0 HoriOrient: 0 VertOrientPosition: 43000 HoriOrientPosition: 1000 HoriOrientRelation: 8 VertOrientRelation: 8
|
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?Hello Chris,
On Monday 22 June 2009, 09:46, Chris Fleischmann wrote: > Hello folks, I have TextFrames, that are created like so (at the beginning > of the process): ... > This method seems to work, it creates the textframe with a specific size, > at a specific x/y location. > > I am now attempting to iterate over the "said" textframes like so: ... > Secondly, is there a way to create a new page between each cycle so that I > can move the textframe to the new page with the same, x/y origin? you can "move" each text frame to a new page by inserting a page break at the frame's anchor (IIRC the frame will have an anchor as long as it is not anchored at the page). See the Java code attached. Regards -- Ariel Constenla-Haile La Plata, Argentina [TextFramePageBreak.java] /* * TextFramePageBreak.java * */ package org.openoffice.sdk; import com.sun.star.awt.Size; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.uno.XComponentContext; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.container.XIndexAccess; import com.sun.star.container.XNameAccess; import com.sun.star.drawing.XShape; import com.sun.star.frame.FrameSearchFlag; import com.sun.star.frame.XComponentLoader; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.style.BreakType; import com.sun.star.text.ControlCharacter; import com.sun.star.text.SizeType; import com.sun.star.text.TextContentAnchorType; 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.XTextRange; import com.sun.star.uno.UnoRuntime; /** * * @author ariel */ public class TextFramePageBreak { private static final int FRAMES_COUNT = 5; XComponentContext m_xContext; /** Creates a new instance of TextFramePageBreak */ public TextFramePageBreak(XComponentContext xContext) { m_xContext = xContext; } /** * @param args the command line arguments */ public static void main(String[] args) { int nRet = 0; try { // get the remote office component context XComponentContext xContext = Bootstrap.bootstrap(); if (xContext == null) { System.err.println("ERROR: Could not bootstrap default Office."); nRet = -1; } TextFramePageBreak demo = new TextFramePageBreak(xContext); demo.firstInsertThenAccess(); } catch (java.lang.Exception e) { e.printStackTrace(); } finally { System.exit(nRet); } } protected void firstInsertThenAccess(){ try { XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface( XTextDocument.class, newDocComponent(m_xContext, "swriter")); // this simulates a situation where we want to access already inserted // objects in order to set a page break after them insertTextFrames(xTextDocument); accessTextFrames(xTextDocument); } catch (Exception e) { e.printStackTrace(); } } private void insertTextFrames(XTextDocument xTextDocument){ try { XMultiServiceFactory xDocFactory = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, xTextDocument); XText xText = xTextDocument.getText(); XTextCursor xTextCursor = xText.createTextCursorByRange(xText.getStart()); // first insert the text frames for (int i = 0; i < FRAMES_COUNT; i++) { insertTextFrame(xDocFactory, xTextCursor); insertParaBreak(xTextCursor); } } catch (Exception e) { e.printStackTrace(); } } private void accessTextFrames(XTextDocument xTextDocument){ try { // access them and insert a page break XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, xTextDocument); XNameAccess xNamedTextFrames = xTextFramesSupplier.getTextFrames(); XIndexAccess xIndexedTextFrames = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xNamedTextFrames); for (int i = 0; i < xIndexedTextFrames.getCount(); i++) { XTextFrame xTextFrame = (XTextFrame) UnoRuntime.queryInterface( XTextFrame.class, xIndexedTextFrames.getByIndex(i)); XTextRange xAnchor = xTextFrame.getAnchor(); // IIRC when anchored at the page, there is no anchor (sic.) // (and of course, the text content CAN NOT be a text table) if ( xAnchor != null ){ try { XPropertySet xAnchorProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xAnchor); xAnchorProps.setPropertyValue("PageDescName", "Default"); // this also works, but results in an extra page //xAnchorProps.setPropertyValue("BreakType", BreakType.PAGE_AFTER); } catch (Exception e) { } } } } catch (Exception e) { e.printStackTrace(); } } //========================================================================= //========================================================================= private void insertText(XTextRange xTextRange, String sStr) { xTextRange.getText().insertString(xTextRange, sStr, false); } private void insertParaBreak(XTextRange xTextRange) { try { xTextRange.getText().insertControlCharacter( xTextRange, ControlCharacter.PARAGRAPH_BREAK, false); } catch (Exception ex) { ex.printStackTrace(); } } private void insertTextContent(XTextRange xTextRange, XTextContent xContent) { try { xTextRange.getText().insertTextContent(xTextRange, xContent, false); } catch (Exception ex) { ex.printStackTrace(); } } private void insertTextFrame(XMultiServiceFactory xDocFactory, XTextRange xTextRange) { try { XTextFrame xTextFrame = createTextFrame(xDocFactory, 12000, 4000, TextContentAnchorType.AT_PARAGRAPH, SizeType.MIN); insertTextContent(xTextRange, xTextFrame); XText xFrameText = xTextFrame.getText(); insertText(xFrameText.getEnd(), "Some text inside the frame."); } catch (Exception ex) { ex.printStackTrace(); } } private XTextFrame createTextFrame( XMultiServiceFactory xDocFactory, int nWidth, int nHeight, TextContentAnchorType aAnchorType, short nSizeType){ XTextFrame xTextFrame = null; try { xTextFrame = (XTextFrame) UnoRuntime.queryInterface( XTextFrame.class, xDocFactory.createInstance( "com.sun.star.text.TextFrame")); XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xTextFrame); xShape.setSize(new Size(nWidth, nHeight)); XPropertySet xFrameProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xTextFrame); xFrameProps.setPropertyValue("AnchorType", aAnchorType); xFrameProps.setPropertyValue("SizeType", new Short(nSizeType)); } catch (Exception ex){ ex.printStackTrace(); } finally { return xTextFrame; } } private XComponent newDocComponent(XComponentContext xContext, String sDocType){ XComponent xComponent = null; try { XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, xContext.getServiceManager().createInstanceWithContext( "com.sun.star.frame.Desktop", xContext)); xComponent = xComponentLoader.loadComponentFromURL( "private:factory/" + sDocType, "_blank", FrameSearchFlag.ALL, new PropertyValue[0]); } catch (Exception e) { e.printStackTrace(); } finally { return xComponent; } } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: I have five text frames on the one page, can I move each frame to a new page?Chris Fleischmann wrote:
> Here is the output I capture from the println statements: > > height: 0 > = invisible frame > AnchorPageNo: 1 > AnchorType: com.sun.star.text.TextContentAnchorType@39060b > VertOrient: 0 > HoriOrient: 0 > VertOrientPosition: 0 > HoriOrientPosition: 1000 > HoriOrientRelation: 8 > VertOrientRelation: 8 > height: 21500 > AnchorPageNo: 2 > AnchorType: com.sun.star.text.TextContentAnchorType@39060b > VertOrient: 0 > > HoriOrient: 0 > VertOrientPosition: 21500 > HoriOrientPosition: 1000 > HoriOrientRelation: 8 > supposed to be "PAGE_PRINT_AREA" > VertOrientRelation: 8 > > height: 43000 > = frame with height off 43 cm , can not been placed > AnchorPageNo: 3 > AnchorType: com.sun.star.text.TextContentAnchorType@39060b > VertOrient: 0 > HoriOrient: 0 > VertOrientPosition: 43000 > HoriOrientPosition: 1000 > HoriOrientRelation: 8 > VertOrientRelation: 8 > > > > Chris Fleischmann wrote: > >> I'm sorry but your last comment lost me... >> >> Here is my Java method to create the necessary pages and to move the >> textframes (well trying to): >> >> private void moveTextFrames() { >> XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) >> UnoRuntime.queryInterface(XTextFramesSupplier.class, >> xWriterComponent_dest); >> >> XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); >> >> XIndexAccess xIndexAccess = (XIndexAccess) >> UnoRuntime.queryInterface( >> XIndexAccess.class, xNamedFrames); >> >> XTextContent xFrameContent[] = new >> XTextContent[xIndexAccess.getCount()]; >> XPropertySet xShapeProps[] = new >> XPropertySet[xIndexAccess.getCount()]; >> >> 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); >> >> xPageCursor.jumpToFirstPage(); >> xPageCursor.jumpToEndOfPage(); >> >> for (int i = 0; i < xIndexAccess.getCount(); 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(); >> } >> } >> >> xPageCursor.jumpToFirstPage(); >> >> for (int i = 0; i < xIndexAccess.getCount(); i++) { >> try { >> Any xImageAny = (Any) xIndexAccess.getByIndex(i); >> Object textFrame = xImageAny.getObject(); >> >> xFrameContent[i] = (XTextContent)textFrame; >> >> xShapeProps[i] = (XPropertySet) >> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >> >> int height = xTextViewCursor_targetDoc.getPosition().Y; >> >> xShapeProps[i].setPropertyValue("AnchorPageNo", new >> Short((short)(i + 1))); >> >> System.out.println("AnchorPageNo: " + >> xShapeProps[i].getPropertyValue("AnchorPageNo")); >> >> xShapeProps[i].setPropertyValue("AnchorType", >> TextContentAnchorType.AT_PAGE); >> >> System.out.println("AnchorType: " + >> xShapeProps[i].getPropertyValue("AnchorType")); >> >> xShapeProps[i].setPropertyValue("VertOrient", new >> Short(VertOrientation.NONE)); >> >> System.out.println("VertOrient: " + >> xShapeProps[i].getPropertyValue("VertOrient")); >> >> xShapeProps[i].setPropertyValue("HoriOrient", new >> Short(HoriOrientation.NONE)); >> >> System.out.println("HoriOrient: " + >> xShapeProps[i].getPropertyValue("HoriOrient")); >> >> xShapeProps[i].setPropertyValue("VertOrientPosition", new >> Integer(height)); >> >> System.out.println("VertOrientPosition: " + >> xShapeProps[i].getPropertyValue("VertOrientPosition")); >> >> xShapeProps[i].setPropertyValue("HoriOrientPosition", new >> Integer(1000)); >> >> System.out.println("HoriOrientPosition: " + >> xShapeProps[i].getPropertyValue("HoriOrientPosition")); >> >> xShapeProps[i].setPropertyValue("HoriOrientRelation", new >> Short(RelOrientation.PAGE_PRINT_AREA)); >> >> System.out.println("HoriOrientRelation: " + >> xShapeProps[i].getPropertyValue("HoriOrientRelation")); >> >> xShapeProps[i].setPropertyValue("VertOrientRelation", new >> Short(RelOrientation.PAGE_PRINT_AREA)); >> >> System.out.println("VertOrientRelation: " + >> xShapeProps[i].getPropertyValue("VertOrientRelation")); >> >> // Set the width and height of the shape. >> xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new >> Integer(frame_size.Width)); >> xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new >> Integer(frame_size.Height)); >> >> xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight", >> new Boolean(false)); >> xShapeProps[i].setPropertyValue("SizeType", new >> Short((short)1)); >> >> xShapeProps[i].setPropertyValue("LeftBorderDistance", new >> Integer(200)); >> xShapeProps[i].setPropertyValue("RightBorderDistance", new >> Integer(200)); >> xShapeProps[i].setPropertyValue("TopBorderDistance", new >> Integer(200)); >> xShapeProps[i].setPropertyValue("BottomBorderDistance", >> new Integer(200)); >> >> xPageCursor.jumpToNextPage(); >> >> } catch (Exception e) { >> System.out.println(e.getMessage()); >> >> e.printStackTrace(); >> } >> } >> } >> >> The pages are created without any issues... The output as per my println >> statements shows correct page and heights assuming the first page top, >> left is 0/0. >> >> Basically, what I can do is move the text frame without any issues using >> the VertOrientPosition and HoriOrientPosition as long as the boundaries >> for the textframe don't go out of the first page... Meaning I can get the >> textframes to move around on page 1 no problem... but trying to anchor >> them on to subsequent pages at the same x/y coordinate on the page isn't >> working. >> >> Again, see attached odt. http://www.nabble.com/file/p24177299/test.odt >> test.odt >> >> >> Fernand Vanrie wrote: >> >>> Chris , >>> >>> Before you start placing Frames, you must been sure you have already >>> created the right number of pages. >>> >>> anyhow: i placed some code in your documents "standard basic libray >>> module1" >>> this code placed a 1000x1000 frame at the cusor position,you moves your >>> cursor to the right position, or you gives fixed coordinates to >>> replace the cursor position and translates to java :-) >>> Fernand >>> >>> >>>> Thanks for the tips... my method is now; >>>> >>>> private void moveTextFrames() { >>>> XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) >>>> UnoRuntime.queryInterface(XTextFramesSupplier.class, >>>> xWriterComponent_dest); >>>> >>>> XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames(); >>>> >>>> XIndexAccess xIndexAccess = (XIndexAccess) >>>> UnoRuntime.queryInterface( >>>> XIndexAccess.class, xNamedFrames); >>>> >>>> XTextContent xFrameContent[] = new >>>> XTextContent[xIndexAccess.getCount()]; >>>> XPropertySet xShapeProps[] = new >>>> XPropertySet[xIndexAccess.getCount()]; >>>> >>>> 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_sourceDoc = >>>> xViewCursorSupplier_targetDoc.getViewCursor(); >>>> >>>> /* >>>> XPageCursor xPageCursor = >>>> (XPageCursor) UnoRuntime.queryInterface( >>>> XPageCursor.class, >>>> xTextViewCursor_sourceDoc); >>>> */ >>>> >>>> for (int i = 0; i < xIndexAccess.getCount(); i++) { >>>> try { >>>> Any xImageAny = (Any) xIndexAccess.getByIndex(i); >>>> Object textFrame = xImageAny.getObject(); >>>> >>>> xFrameContent[i] = (XTextContent)textFrame; >>>> >>>> xShapeProps[i] = (XPropertySet) >>>> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >>>> >>>> // Setting the vertical and horizontal position >>>> long height = (i * page_size.Height) + 1000; >>>> >>>> System.out.println("height: " + height); >>>> >>>> // Setting the vertical and horizontal position >>>> >>>> xShapeProps[i].setPropertyValue("AnchorPageNo", new >>>> Short((short)(i + 1))); >>>> >>>> xShapeProps[i].setPropertyValue("AnchorType", >>>> TextContentAnchorType.AT_PAGE); >>>> >>>> xShapeProps[i].setPropertyValue("VertOrient", new >>>> Short(VertOrientation.NONE)); >>>> xShapeProps[i].setPropertyValue("HoriOrient", new >>>> Short(HoriOrientation.NONE)); >>>> xShapeProps[i].setPropertyValue("VertOrientPosition", >>>> new >>>> Long(height)); >>>> xShapeProps[i].setPropertyValue("HoriOrientPosition", >>>> new >>>> Integer(1000)); >>>> >>>> xShapeProps[i].setPropertyValue("HoriOrientRelation", >>>> (short)50); >>>> xShapeProps[i].setPropertyValue("VertOrientRelation", >>>> (short)50); >>>> >>>> // Set the width and height of the shape. >>>> xShapeProps[i].setPropertyValue("FrameWidthAbsolute", >>>> new >>>> Integer(frame_size.Width)); >>>> xShapeProps[i].setPropertyValue("FrameHeightAbsolute", >>>> new >>>> Integer(frame_size.Height)); >>>> >>>> >>>> xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight", >>>> new Boolean(false)); >>>> xShapeProps[i].setPropertyValue("SizeType", new >>>> Short((short)1)); >>>> >>>> xShapeProps[i].setPropertyValue("LeftBorderDistance", >>>> new >>>> Integer(200)); >>>> xShapeProps[i].setPropertyValue("RightBorderDistance", >>>> new >>>> Integer(200)); >>>> xShapeProps[i].setPropertyValue("TopBorderDistance", new >>>> Integer(200)); >>>> xShapeProps[i].setPropertyValue("BottomBorderDistance", >>>> new >>>> Integer(200)); >>>> >>>> // Insert a paragraph break into the document (not the >>>> frame) >>>> xText.insertControlCharacter(xTextViewCursor_sourceDoc, >>>> ControlCharacter.PARAGRAPH_BREAK, false); >>>> >>>> XPropertySet xCursorProps = >>>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, >>>> xTextViewCursor_sourceDoc); >>>> >>>> xCursorProps.setPropertyValue("BreakType", >>>> com.sun.star.style.BreakType.PAGE_AFTER); >>>> >>>> xText.insertControlCharacter(xTextViewCursor_sourceDoc, >>>> ControlCharacter.PARAGRAPH_BREAK, false); >>>> // xTextCursor.collapseToEnd(); >>>> >>>> } catch (Exception e) { >>>> System.out.println(e.getMessage()); >>>> >>>> e.printStackTrace(); >>>> } >>>> } >>>> } >>>> >>>> >>>> With your code, are you coming from the "bottom" of your document and >>>> working your way up? >>>> >>>> I also don't believe I need; >>>> >>>> PositionProtected = False >>>> SizeProtected = false >>>> ContentProtected = false >>>> >>>> But still it doesn't work... :( >>>> >>>> See attachment, http://www.nabble.com/file/p24164747/text.odt text.odt >>>> >>>> I als notice that there seems to be issues with the longs, ints, shorts >>>> etc... as also captured here: >>>> http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16089 >>>> >>>> Any other thoughts? >>>> >>>> Thanks in advance >>>> >>>> >>>> Fernand Vanrie wrote: >>>> >>>> >>>>> Chris , >>>>> >>>>> Long is needed because integer is to small and there are different >>>>> properties who has to been set properly. >>>>> >>>>> Please find the basic code i uses to place Frames without any problem >>>>> >>>>> iPagenr = oViewCursor.page >>>>> iHCpos = oViewCursor.getPosition().X >>>>> iVCpos = oViewCursor.getPosition().Y - (30700 * (iPagenr -1)) ' >>>>> Vieuwcursor rekend steeds van begin van document >>>>> >>>>> oFrame.SetPropertyValue("AnchorPageNo", iPagenr) >>>>> oFrame.AnchorType = lAnchor >>>>> oFrame.PositionProtected = False >>>>> oFrame.SizeProtected = false >>>>> oFrame.ContentProtected = false >>>>> oFrame.HoriOrient = NONE >>>>> oFrame.VertOrient = NONE >>>>> oFrame.VertOrientRelation = PAGE_PRINT_AREA >>>>> oFrame.HoriOrientRelation = PAGE_PRINT_AREA >>>>> >>>>> oText.insertTextContent(oCursor(), oFrame, false) >>>>> >>>>> hope i helps >>>>> >>>>> Fernand >>>>> >>>>> >>>>>> Hi, Yes, I am trying to calculate the height like so, >>>>>> >>>>>> (i * page_size.Height) + 1000 >>>>>> >>>>>> The page_size.Height was calculated previously, ie., >>>>>> >>>>>> 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; >>>>>> >>>>>> >>>>>> I have also tried the following: >>>>>> >>>>>> private void moveTextFrames() { >>>>>> XTextFramesSupplier xTextFramesSupplier = >>>>>> (XTextFramesSupplier) >>>>>> UnoRuntime.queryInterface(XTextFramesSupplier.class, >>>>>> xWriterComponent_dest); >>>>>> >>>>>> XNameAccess xNamedFrames = >>>>>> xTextFramesSupplier.getTextFrames(); >>>>>> >>>>>> XIndexAccess xIndexAccess = (XIndexAccess) >>>>>> UnoRuntime.queryInterface( >>>>>> XIndexAccess.class, xNamedFrames); >>>>>> >>>>>> XTextContent xFrameContent[] = new >>>>>> XTextContent[xIndexAccess.getCount()]; >>>>>> XPropertySet xShapeProps[] = new >>>>>> XPropertySet[xIndexAccess.getCount()]; >>>>>> >>>>>> XText xText = xTextDocument_dest.getText(); >>>>>> >>>>>> XTextCursor xTextCursor = xText.createTextCursor(); >>>>>> >>>>>> for (int i = 0; i < xIndexAccess.getCount(); i++) { >>>>>> try { >>>>>> Any xImageAny = (Any) xIndexAccess.getByIndex(i); >>>>>> Object textFrame = xImageAny.getObject(); >>>>>> >>>>>> xFrameContent[i] = (XTextContent)textFrame; >>>>>> >>>>>> xShapeProps[i] = (XPropertySet) >>>>>> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >>>>>> >>>>>> xShapeProps[i].setPropertyValue("AnchorType", >>>>>> TextContentAnchorType.AT_PAGE); >>>>>> >>>>>> // Setting the vertical and horizontal position >>>>>> long height = (i * page_size.Height) + 1000; >>>>>> >>>>>> //xShapeProps.setPropertyValue("VertOrient", new >>>>>> Short(VertOrientation.NONE)); >>>>>> //xShapeProps.setPropertyValue("HoriOrient", new >>>>>> Short(HoriOrientation.NONE)); >>>>>> //xShapeProps.setPropertyValue("HoriOrientPosition", >>>>>> new >>>>>> Integer(1000)); >>>>>> xShapeProps[i].setPropertyValue("VertOrientPosition", >>>>>> height); >>>>>> >>>>>> // Set the width and height of the shape. >>>>>> //xShapeProps.setPropertyValue("FrameWidthAbsolute", >>>>>> new >>>>>> Integer(frame_size.Width)); >>>>>> //xShapeProps.setPropertyValue("FrameHeightAbsolute", >>>>>> new >>>>>> Integer(frame_size.Height)); >>>>>> >>>>>> //xShapeProps.setPropertyValue("FrameIsAutomaticHeight", >>>>>> new >>>>>> Boolean(false)); >>>>>> //xShapeProps.setPropertyValue("SizeType", new >>>>>> Short((short)1)); >>>>>> >>>>>> //xShapeProps.setPropertyValue("LeftBorderDistance", >>>>>> new >>>>>> Integer(200)); >>>>>> //xShapeProps.setPropertyValue("RightBorderDistance", >>>>>> new >>>>>> Integer(200)); >>>>>> //xShapeProps.setPropertyValue("TopBorderDistance", >>>>>> new >>>>>> Integer(200)); >>>>>> //xShapeProps.setPropertyValue("BottomBorderDistance", >>>>>> new >>>>>> Integer(200)); >>>>>> >>>>>> // Insert a paragraph break into the document (not the >>>>>> frame) >>>>>> xText.insertControlCharacter(xTextCursor, >>>>>> ControlCharacter.PARAGRAPH_BREAK, false); >>>>>> >>>>>> XPropertySet xCursorProps = >>>>>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, >>>>>> xTextCursor); >>>>>> >>>>>> xCursorProps.setPropertyValue("BreakType", >>>>>> com.sun.star.style.BreakType.PAGE_AFTER); >>>>>> >>>>>> xText.insertControlCharacter(xTextCursor, >>>>>> ControlCharacter.PARAGRAPH_BREAK, false); >>>>>> >>>>>> } catch (Exception e) { >>>>>> System.out.println(e.getMessage()); >>>>>> >>>>>> e.printStackTrace(); >>>>>> } >>>>>> } >>>>>> } >>>>>> >>>>>> Which doesn't seem to work either, see attached. >>>>>> >>>>>> Is there a problem specifying a "long" for the vertical position, >>>>>> rather >>>>>> than an "Integer", ie., the value when you get to page 3 or 4 is over >>>>>> 32768 >>>>>> pixels high. >>>>>> >>>>>> Any thoughts, do I have to move the view cursor or something or >>>>>> somehow >>>>>> to >>>>>> get the anchor on to the next page.. I notice when I try it manually, >>>>>> i >>>>>> need >>>>>> to "cut" the text frame, move to the next page and paste the frame, I >>>>>> then >>>>>> notice that the anchor is moved to the right page.. >>>>>> >>>>>> At present, it seems all of the textframes remain on page1 in top/left >>>>>> corner. >>>>>> >>>>>> I can happily move the textframes using the above technique around the >>>>>> first >>>>>> page, but not on to the next page.... >>>>>> >>>>>> Your help is greatly appreciated. >>>>>> >>>>>> Chris >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> Fernand Vanrie wrote: >>>>>> >>>>>> >>>>>> >>>>>>> Chris Fleischmann wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>>> I have gotten so far as; >>>>>>>> >>>>>>>> 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(); >>>>>>>> >>>>>>>> XTextCursor xTextCursor = xText.createTextCursor(); >>>>>>>> >>>>>>>> for (int i = 0; i < xIndexAccess.getCount(); i++) { >>>>>>>> try { >>>>>>>> Any xImageAny = (Any) xIndexAccess.getByIndex(i); >>>>>>>> Object textFrame = xImageAny.getObject(); >>>>>>>> >>>>>>>> XTextContent xFrameContent = >>>>>>>> (XTextContent)textFrame; >>>>>>>> >>>>>>>> XPropertySet xShapeProps = (XPropertySet) >>>>>>>> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >>>>>>>> >>>>>>>> xShapeProps.setPropertyValue("AnchorType", >>>>>>>> TextContentAnchorType.AT_PAGE); >>>>>>>> >>>>>>>> // Setting the vertical and horizontal position >>>>>>>> int height = (i * page_size.Height) + 1000; >>>>>>>> >>>>>>>> xShapeProps.setPropertyValue("VertOrient", new >>>>>>>> Short(VertOrientation.NONE)); >>>>>>>> xShapeProps.setPropertyValue("HoriOrient", new >>>>>>>> Short(HoriOrientation.NONE)); >>>>>>>> xShapeProps.setPropertyValue("HoriOrientPosition", >>>>>>>> new >>>>>>>> Integer(1000)); >>>>>>>> xShapeProps.setPropertyValue("VertOrientPosition", >>>>>>>> new >>>>>>>> Integer(height)); >>>>>>>> >>>>>>>> // Set the width and height of the shape. >>>>>>>> xShapeProps.setPropertyValue("FrameWidthAbsolute", >>>>>>>> new >>>>>>>> Integer(frame_size.Width)); >>>>>>>> xShapeProps.setPropertyValue("FrameHeightAbsolute", >>>>>>>> new >>>>>>>> Integer(frame_size.Height)); >>>>>>>> >>>>>>>> xShapeProps.setPropertyValue("FrameIsAutomaticHeight", >>>>>>>> new >>>>>>>> Boolean(false)); >>>>>>>> xShapeProps.setPropertyValue("SizeType", new >>>>>>>> Short((short)1)); >>>>>>>> >>>>>>>> xShapeProps.setPropertyValue("LeftBorderDistance", >>>>>>>> new >>>>>>>> Integer(200)); >>>>>>>> xShapeProps.setPropertyValue("RightBorderDistance", >>>>>>>> new >>>>>>>> Integer(200)); >>>>>>>> xShapeProps.setPropertyValue("TopBorderDistance", >>>>>>>> new >>>>>>>> Integer(200)); >>>>>>>> xShapeProps.setPropertyValue("BottomBorderDistance", >>>>>>>> new >>>>>>>> Integer(200)); >>>>>>>> >>>>>>>> // Insert a paragraph break into the document (not >>>>>>>> the >>>>>>>> frame) >>>>>>>> xText.insertControlCharacter (xTextCursor, >>>>>>>> ControlCharacter.PARAGRAPH_BREAK, false); >>>>>>>> >>>>>>>> XPropertySet xCursorProps = >>>>>>>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, >>>>>>>> xTextCursor); >>>>>>>> >>>>>>>> xCursorProps.setPropertyValue("BreakType", >>>>>>>> com.sun.star.style.BreakType.PAGE_AFTER); >>>>>>>> >>>>>>>> xText.insertControlCharacter(xTextCursor, >>>>>>>> ControlCharacter.PARAGRAPH_BREAK, false); >>>>>>>> >>>>>>>> xTextCursor.gotoEnd(false); >>>>>>>> } catch (Exception e) { >>>>>>>> System.out.println(e.getMessage()); >>>>>>>> >>>>>>>> e.printStackTrace(); >>>>>>>> } >>>>>>>> } >>>>>>>> } >>>>>>>> >>>>>>>> >>>>>>>> Which allows me to grab the existing textfram. I then attempt to >>>>>>>> change >>>>>>>> the >>>>>>>> verticial position based on the page size, and once moved add a new >>>>>>>> page >>>>>>>> to >>>>>>>> the document and updating the height value for the next frame's >>>>>>>> translation... >>>>>>>> >>>>>>>> This doesn't seem to work, ie., the textframe(s) do not move to the >>>>>>>> next >>>>>>>> page, they don't translate, the seem to move down the page by >>>>>>>> increments >>>>>>>> of >>>>>>>> 1000? Shouldn't the Anchor, AT_PAGE move to the "second", "third" or >>>>>>>> etc. >>>>>>>> etc. page, rather than stick to page 1? >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> Chris, >>>>>>> >>>>>>> AT_PAGE is the only option, but the vertical position is calqulated >>>>>>> from >>>>>>> the begining off the document, so for every Page you have to ad the >>>>>>> hight off every page . >>>>>>> And i think a viewCursor gives you information about the pagenr wher >>>>>>> the frame is located. >>>>>>> >>>>>>> Hope it helps >>>>>>> >>>>>>> Fernand >>>>>>> >>>>>>> >>>>>>> >>>>>>>> thanks for any help you may be able to shed. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Chris Fleischmann wrote: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> Hello folks, I have TextFrames, that are created like so (at the >>>>>>>>> beginning >>>>>>>>> of the process): >>>>>>>>> >>>>>>>>> private XText getTextFrame(XText xText, int x, int y) { >>>>>>>>> try { >>>>>>>>> Object textFrame = >>>>>>>>> xWriterFactory.createInstance("com.sun.star.text.TextFrame"); >>>>>>>>> >>>>>>>>> XTextContent xTextContentFrame = (XTextContent) >>>>>>>>> UnoRuntime.queryInterface(XTextContent.class, textFrame); >>>>>>>>> >>>>>>>>> XPropertySet xShapeProps = (XPropertySet) >>>>>>>>> UnoRuntime.queryInterface(XPropertySet.class, textFrame); >>>>>>>>> >>>>>>>>> xShapeProps.setPropertyValue("AnchorType", >>>>>>>>> TextContentAnchorType.AT_PARAGRAPH); >>>>>>>>> >>>>>>>>> // Setting the vertical and horizontal position >>>>>>>>> xShapeProps.setPropertyValue("VertOrient", new >>>>>>>>> Short(VertOrientation.NONE)); >>>>>>>>> xShapeProps.setPropertyValue("HoriOrient", new >>>>>>>>> Short(HoriOrientation.NONE)); >>>>>>>>> xShapeProps.setPropertyValue("VertOrientPosition", new >>>>>>>>> Integer(x)); >>>>>>>>> xShapeProps.setPropertyValue("HoriOrientPosition", new >>>>>>>>> Integer(y)); >>>>>>>>> >>>>>>>>> // Set the width and height of the shape. >>>>>>>>> xShapeProps.setPropertyValue("FrameWidthAbsolute", new >>>>>>>>> Integer(frame_size.Width)); >>>>>>>>> xShapeProps.setPropertyValue("FrameHeightAbsolute", new >>>>>>>>> Integer(frame_size.Height)); >>>>>>>>> xShapeProps.setPropertyValue("FrameIsAutomaticHeight", >>>>>>>>> new >>>>>>>>> Boolean(false)); >>>>>>>>> xShapeProps.setPropertyValue("SizeType", new >>>>>>>>> Short((short)1)); >>>>>>>>> >>>>>>>>> xShapeProps.setPropertyValue("LeftBorderDistance", new >>>>>>>>> Integer(200)); >>>>>>>>> xShapeProps.setPropertyValue("RightBorderDistance", new >>>>>>>>> Integer(200)); >>>>>>>>> xShapeProps.setPropertyValue("TopBorderDistance", new >>>>>>>>> Integer(200)); >>>>>>>>> xShapeProps.setPropertyValue("BottomBorderDistance", >>>>>>>>> new >>>>>>>>> Integer(200)); >>>>>>>>> >>>>>>>>> xText.insertTextContent(xText.getEnd(), >>>>>>>>> xTextContentFrame, >>>>>>>>> false); >>>>>>>>> >>>>>>>>> XText xFrameText = (XText) >>>>>>>>> UnoRuntime.queryInterface(XText.class, textFrame); >>>>>>>>> >>>>>>>>> return xFrameText; >>>>>>>>> } catch (java.lang.Exception e) { >>>>>>>>> e.printStackTrace(); >>>>>>>>> } >>>>>>>>> >>>>>>>>> return null; >>>>>>>>> } >>>>>>>>> >>>>>>>>> This method seems to work, it creates the textframe with a specific >>>>>>>>> size, >>>>>>>>> at a specific x/y location. >>>>>>>>> >>>>>>>>> I am now attempting to iterate over the "said" textframes like so: >>>>>>>>> >>>>>>>>> XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier) >>>>>>>>> >>>>>>>>> UnoRuntime.queryInterface(XTextFramesSupplier.class, >>>>>>>>> xWriterComponent_dest); >>>>>>>>> >>>>>>>>> XNameAccess xNamedFrames = >>>>>>>>> xTextFramesSupplier.getTextFrames(); >>>>>>>>> >>>>>>>>> String[] textframes = xNamedFrames.getElementNames(); >>>>>>>>> >>>>>>>>> for (int i = 0; i < textframes.length; i++) { >>>>>>>>> XTextFrame textframe = null; >>>>>>>>> >>>>>>>>> try { >>>>>>>>> textframe = >>>>>>>>> (XTextFrame)xNamedFrames.getByName(textframes[i]); >>>>>>>>> >>>>>>>>> XTextContent xFrameContent = (XTextContent) >>>>>>>>> UnoRuntime.queryInterface(XTextContent.class, textframe); >>>>>>>>> >>>>>>>>> XPropertySet xShapeProps = (XPropertySet) >>>>>>>>> UnoRuntime.queryInterface(XPropertySet.class, textframe); >>>>>>>>> >>>>>>>>> Which seems to work, ie., i can iterate over the above "said" >>>>>>>>> frames.... >>>>>>>>> I >>>>>>>>> have tried doing: >>>>>>>>> >>>>>>>>> xShapeProps.setPropertyValue("AnchorType", >>>>>>>>> TextContentAnchorType.AT_PARAGRAPH); >>>>>>>>> >>>>>>>>> // Setting the vertical and horizontal position >>>>>>>>> xShapeProps.setPropertyValue("VertOrient", new >>>>>>>>> Short(VertOrientation.NONE)); >>>>>>>>> xShapeProps.setPropertyValue("HoriOrient", new >>>>>>>>> Short(HoriOrientation.NONE)); >>>>>>>>> xShapeProps.setPropertyValue("VertOrientPosition", >>>>>>>>> new >>>>>>>>> Integer(1000 + (i * 1000))); >>>>>>>>> xShapeProps.setPropertyValue("HoriOrientPosition", >>>>>>>>> new >>>>>>>>> Integer(1000)); >>>>>>>>> >>>>>>>>> so as to move the frames slowly but sure down the page.... >>>>>>>>> >>>>>>>>> That doesn't seem to work? >>>>>>>>> >>>>>>>>> Secondly, is there a way to create a new page between each cycle so >>>>>>>>> that >>>>>>>>> I >>>>>>>>> can move the textframe to the new page with the same, x/y origin? >>>>>>>>> >>>>>>>>> Thanks in advance for any help you can shed on the issue, >>>>>>>>> >>>>>>>>> Chris >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>>> To unsubscribe, e-mail: dev-unsubscribe@... >>>>>>> For additional commands, e-mail: dev-help@... >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: dev-unsubscribe@... >>>>> For additional commands, e-mail: dev-help@... >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscribe@... >>> For additional commands, e-mail: dev-help@... >>> >>> >>> >>> >> > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
SOLVED Re: I have five text frames on the one page, can I move each frame to a new page?Thank you for all of your help Fernand, I ended up solving it with the following code/method:
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); XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument_dest); // get the NameAccess interface from the Style family collection XNameAccess xNameAccess = xSupplier.getStyleFamilies(); try { 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")); // retrieve the page size page_size = (Size) xPropertySet.getPropertyValue("Size"); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } xPageCursor.jumpToFirstPage(); xPageCursor.jumpToEndOfPage(); for (int i = 1; i < xIndexAccess.getCount(); 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(); } } xPageCursor.jumpToFirstPage(); for (int i = 0; i < xIndexAccess.getCount(); i++) { try { Any xImageAny = (Any) xIndexAccess.getByIndex(i); Object textFrame = xImageAny.getObject(); XTextFrame xTextFrame = (XTextFrame)textFrame; XPropertySet xShapeProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame); xShapeProps.setPropertyValue("AnchorPageNo", 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(200)); xShapeProps.setPropertyValue("RightBorderDistance", new Integer(200)); xShapeProps.setPropertyValue("TopBorderDistance", new Integer(200)); xShapeProps.setPropertyValue("BottomBorderDistance", new Integer(200)); xPageCursor.jumpToNextPage(); xPageCursor.jumpToStartOfPage(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
|
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |