Skip to content

Commit

Permalink
Addresses #10, Copy page number area to a new text area in the sa… (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
hylkevds authored Feb 8, 2020
1 parent d54d5da commit 345d5c3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/ExpandAnimations.bas
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ function expandDocument(doc as Object, oStatusBar as Object)
' go through pages in reverse order
for i = numSlides-1 to 0 step -1
slide = doc.drawPages(i)
if slide.IsPageNumberVisible then
fixateSlideNumber(doc, slide, i+1, numSlides)
end if
' If the slide name is pageXXn it is an autogenerated name
' It is impossible to name a slide "Slide XX", but "Slide: XX" works
if Left(slide.Name, 4) = "page" then
slide.Name = "Slide: " & CStr(i+1)
end if
oStatusBar.setValue(numSlides-i)
if hasAnimation(slide) then
n = countAnimationSteps(slide)
Expand All @@ -157,7 +165,27 @@ function expandDocument(doc as Object, oStatusBar as Object)

' saving the expanded version
doc.store()
end function

function fixateSlideNumber(doc as Object, slide as Object, slideNr as Integer, slideCount as Integer)
master = slide.MasterPage
shapeCount = master.getCount()
for shapeNr = 0 to shapeCount-1
shape = master.getByIndex(shapeNr)
shapeType = shape.getShapeType()
if shapeType = "com.sun.star.presentation.SlideNumberShape" then
copy = doc.createInstance("com.sun.star.drawing.TextShape")
'Call Tools.WritedbgInfo(shape)
slide.IsPageNumberVisible = False
slide.add(copy)
copy.setString(CStr(slideNr) & " / " & CStr(slideCount))
copy.Style = shape.Style
copy.Text.Style = shape.Text.Style
copy.Position = shape.Position
copy.Size = shape.Size
copy.TextVerticalAdjust = shape.TextVerticalAdjust

This comment has been minimized.

Copy link
@zzjjzzgggg

zzjjzzgggg Jun 19, 2020

Contributor

This copy object doesn't preserve the font size and alignment of shape.

  1. Font size of copy is different from the font size of shape.
  2. If text in shape is right aligned, the text in copy is still left aligned.

I have been reading the libreoffice API document for quite a while, it seems that TextShape doesn't have a property controlling its alignment.

This comment has been minimized.

Copy link
@zzjjzzgggg

This comment has been minimized.

Copy link
@zzjjzzgggg

zzjjzzgggg Jun 19, 2020

Contributor

It seems that we need to add the following two lines after line 186. Now everything seems to be correct.

copy.Text.CharHeight = shape.Text.CharHeight
copy.TextHorizontalAdjust = 2

The second line means align right. It is strange that shape.TextHorizontalAdjust is left aligned.

This comment has been minimized.

Copy link
@monperrus

monperrus via email Jun 19, 2020

Owner
end if
next
end function

function somethingWrong( slide as Object )
Expand Down

0 comments on commit 345d5c3

Please sign in to comment.