読者です 読者をやめる 読者になる 読者になる

OooBasicで遊んだ

OpenOfficeのマクロであるOooBasicを使ってImpress(PowerPoint相当)でソフトシャドウを作ってみた。
2.4〜3.1で動作することを確認しています。


ぜひコピーして使ってよりよく改造してください。
(できればそれも公開してください)

変ゼミ資料をすこし改造してUp

OooBasic
View more documents from inajob.


参考になるか知らないけどソース

Sub shapes_rect_corner
 On Error Resume Next
 
  oDoc = ThisComponent
  oController = oDoc.getCurrentController()
  oDrawPage = oController.currentPage 'oDoc.getDrawPages().getByIndex(1)
  oSelection = oController.getSelection().getByIndex(0)
  dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
  ' ==constants==
  margin = 1000
  offset = 100
  ' ============
  dispatcher.executeDispatch(oController.Frame, ".uno:Copy", "", 0, Array())
  dispatcher.executeDispatch(oController.Frame, ".uno:Paste", "", 0, Array()) 
  orgObj  = oDrawPage.getByIndex(oDrawPage.count - 1)     
  oRectShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape")
  
  aPoint = CreateUnoStruct("com.sun.star.awt.Point")
  aSize = CreateUnoStruct("com.sun.star.awt.Size")
  aPoint.X = oSelection.Position.X - margin/2
  aPoint.Y = oSelection.Position.Y - margin/2
  aSize.Width = oSelection.Size.Width + margin
  aSize.Height = oSelection.Size.Height + margin
  
  oRectShape.setPosition(aPoint)
  oRectShape.setSize(aSize)
  oRectShape.CornerRadius = 0
  oRectShape.fillColor = 16777215 'FFFFFF
  oRectShape.lineStyle = 0
  
  oDrawPage.add(oRectShape)
  
  oController.select(oSelection)
  if Not IsNull(oSelection.fillColor) then
  	oSelection.fillColor = 0 ' BLACK
  end if
  
  dispatcher.executeDispatch(oController.Frame, ".uno:BringToFront", "", 0, Array())

  oShapes = createUnoService("com.sun.star.drawing.ShapeCollection")
  oShapes.add(oRectShape)
  oShapes.add(oSelection)
  og = oDrawPage.group( oShapes )
  
  oController.select(og)
  dispatcher.executeDispatch(oController.Frame, ".uno:ConvertIntoBitmap", "", 0, Array())
  obj  = oDrawPage.getByIndex(oDrawPage.count - 1) ' reselect
    
  aPoint = CreateUnoStruct("com.sun.star.awt.Point")
  aPoint.X = obj.Position.X + offset
  aPoint.Y = obj.Position.Y + offset
  obj.setPosition(aPoint)
  
  oController.select(obj)
  For i = 1 To 20
    	dispatcher.executeDispatch(oController.Frame, ".uno:GraphicFilterSmooth", "", 0, Array())
  Next i
  
    oController.select(orgObj)
  dispatcher.executeDispatch(oController.Frame, ".uno:BringToFront", "", 0, Array())
  
End Sub

参考URL一覧(slideshareではクリックできないので写し)