Ask Your Question
0

getDrawPage fails in Impress document

asked 2019-08-29 06:16:52 +0200

Jshbtmn gravatar image

updated 2019-08-29 06:20:14 +0200

Ratslinger gravatar image

Hi all,

I'm not a programmer, I'm a pro A/V tech who works primarily on Broadway style musicals. I'm trying to write a macro that will find my current cursor position and attach a small blue circle, labelled with a number that relates to a fader on my sound console. I'm having trouble getting the document to find the current drawpage, but only not in text documents. I need this to work in Impress, as scripts generally come to me in PDF form. It's currently set for a hard position (aposition), once I can get the current page figured out, I'll take a crack at relating it to cursor position. Thanks in advance!

`Sub InsertProcessShape

Dim oDoc As Object

 Dim oDrawPage As Object

Dim oShape As Object

 Dim shapeGeometry(0) as new com.sun.star.beans.PropertyValue

Dim oSize As new com.sun.star.awt.Size

   oSize.width = 1200
   oSize.height = 1200

   oDoc = Stardesktop.getCurrentComponent()
   MsgBox oDoc.getImplementationName()

   oDrawPage = oDoc.getDrawPage()
   oShape = oDoc.createInstance("com.sun.star.drawing.EllipseShape")
   shapeGeometry(0).Name = "Type"
   shapeGeometry(0).Value = "Circle"
   oDrawPage.add(oShape)
   oShape.Size = oSize
   oShape.FillStyle = com.sun.star.drawing.FillStyle.NONE
   oShape.LineWidth = 170
   oShape.LineColor = 220

   Dim aPosition As New com.sun.star.awt.Point

  aPosition.X = 8000
  aPosition.Y = 8000

   oShape.setposition(aPosition)

   oShape.Text.String = "1"
   oShape.Text.CharHeight = 20
   oShape.Text.CharFontName = "Alef"

End Sub`
edit retag flag offensive close merge delete

Comments

Code set to preformatted text (on toolbar) for clarity.

Ratslinger gravatar imageRatslinger ( 2019-08-29 06:21:17 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-08-29 06:53:37 +0200

Ratslinger gravatar image

updated 2019-08-29 07:27:25 +0200

Hello,

Know very little about Impress. Do know that access to Draw page is different during the slide show and when editing.

From your code you appear to be in edit mode.

Edit (old code deleted):

Sorry, went back to notes. Easier method to get access to current Draw Page:

oDoc = Stardesktop.getCurrentComponent()
oCurrentController = oDoc.getCurrentController()
oDrawPage = oCurrentController.CurrentPage

Edit #2:

With your code & above change, produced this:

image description

edit flag offensive delete link more

Comments

Please note: Have had various problems on Ubuntu 18.04 using LO v6.3.0.4.

Various times have lost all editing capabilities with Impress slides. Presentation still worked. Had this happen when exploring with MRI & with running various macros (this one and others). No rhyme or reason thus far. Could be problem in this version.

Advise to always make a backup copy before running any macro.

Ratslinger gravatar imageRatslinger ( 2019-08-29 07:36:26 +0200 )edit

Appears to function, thanks so much. Backing up now.

Jshbtmn gravatar imageJshbtmn ( 2019-08-29 16:57:49 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-08-29 06:16:52 +0200

Seen: 19 times

Last updated: Aug 29