I'm very seldom using this, so I have no idea what to do?
Code: Select all
REM  *****  BASIC  *****
Sub Main
End Sub
Sub fitGraphics()
   Dim oDoc As Object
   Dim oSheet As Object
   Dim aCell As Object
   Dim g as Object
   Dim c As Integer
   Dim s As new com.sun.star.awt.Size
   Dim gp As new com.sun.star.awt.Point     
   Dim ap As new com.sun.star.awt.Point     
   Dim p As new com.sun.star.awt.Point     
   Dim xAdjust As Long
   Dim yAdjust As Long
   Dim rowHeight As Long
   Dim colWidth As Long
   
   oDoc = ThisComponent
   
   oSheet = oDoc.CurrentController.ActiveSheet
   
   c = oSheet.DrawPage.count
   
   Do While c >= 1
         g = oSheet.DrawPage(c - 1)
         if InStr(g.ShapeType,"GraphicObjectShape") > 0 then
            s = g.getSize()
            gp = g.getPosition()
            aCell = g.anchor
            rowHeight = oSheet.Rows(aCell.CellAddress.Row).Height
            colWidth = oSheet.Columns(g.anchor.CellAddress.Column).Width
            
            if rowHeight < s.Height then
               oSheet.Rows(aCell.CellAddress.Row).Height = s.Height
               yAdjust = 0
         else
            yAdjust = (rowHeight - s.Height) \ 2
         endif
         if colWidth < s.Width then
               oSheet.Columns(aCell.CellAddress.Column).Width = s.Width
               xAdjust = 0
         else
            xAdjust = (colWidth - s.Width) \ 2
         endif      
            ap = aCell.Position()
            gp = g.getPosition()
            if (rowHeight < s.Height) or colWidth < s.Width then
               g.setSize(s)
               g.setPosition(ap)
            else
               p.X = ap.X + xAdjust
               p.Y = ap.Y + yAdjust
               g.setPosition(p)
            endif
         endif
         c = c - 1
   Loop
   
End Sub
sub test
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:OriginalSize", "", 0, Array())
end sub
sub test2
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(7) as new com.sun.star.beans.PropertyValue
args1(0).Name = "BorderOuter.LeftBorder"
args1(0).Value = Array(0,0,0,0)
args1(1).Name = "BorderOuter.LeftDistance"
args1(1).Value = 0
args1(2).Name = "BorderOuter.RightBorder"
args1(2).Value = Array(0,0,0,0)
args1(3).Name = "BorderOuter.RightDistance"
args1(3).Value = 0
args1(4).Name = "BorderOuter.TopBorder"
args1(4).Value = Array(0,0,0,0)
args1(5).Name = "BorderOuter.TopDistance"
args1(5).Value = 0
args1(6).Name = "BorderOuter.BottomBorder"
args1(6).Value = Array(0,0,2,0)
args1(7).Name = "BorderOuter.BottomDistance"
args1(7).Value = 0
dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertRows", "", 0, Array())
end sub
sub days7
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertRows", "", 0, Array())
rem ----------------------------------------------------------------------
dim args2(7) as new com.sun.star.beans.PropertyValue
args2(0).Name = "BorderOuter.LeftBorder"
args2(0).Value = Array(0,0,0,0)
args2(1).Name = "BorderOuter.LeftDistance"
args2(1).Value = 0
args2(2).Name = "BorderOuter.RightBorder"
args2(2).Value = Array(0,0,0,0)
args2(3).Name = "BorderOuter.RightDistance"
args2(3).Value = 0
args2(4).Name = "BorderOuter.TopBorder"
args2(4).Value = Array(0,0,0,0)
args2(5).Name = "BorderOuter.TopDistance"
args2(5).Value = 0
args2(6).Name = "BorderOuter.BottomBorder"
args2(6).Value = Array(0,0,0,0)
args2(7).Name = "BorderOuter.BottomDistance"
args2(7).Value = 0
dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(4) as new com.sun.star.beans.PropertyValue
args3(0).Name = "BorderInner.Horizontal"
args3(0).Value = Array(0,0,0,0)
args3(1).Name = "BorderInner.Vertical"
args3(1).Value = Array(0,0,0,0)
args3(2).Name = "BorderInner.Flags"
args3(2).Value = 2
args3(3).Name = "BorderInner.ValidFlags"
args3(3).Value = 125
args3(4).Name = "BorderInner.DefaultDistance"
args3(4).Value = 0
dispatcher.executeDispatch(document, ".uno:BorderInner", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "RowHeight"
args4(0).Value = 0
dispatcher.executeDispatch(document, ".uno:RowHeight", "", 0, args4())
end sub