Top > OOoBasic > Impress > Animation

アニメーション Edit

アニメーション。

アニメーションの設定 Edit

Sub SetAnimation_1
 oDoc = ThisComponent
 oCollection = oDoc.getCurrentSelection()
 oShape = oCollection.getByIndex(0)

 oShape.Effect = com.sun.star.presentation.AnimationEffect.APPEAR
 oShape.Speed = com.sun.star.presentation.AnimationSpeed.FAST
End Sub

アニメーションの設定例2 Edit

  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
Sub CreateTextAnimation_1
  INTERVAL = 0.15
  sText = "ABCDE"
  
  oDoc = ThisComponent
  oDrawPage = oDoc.getCurrentController().getCurrentPage()
  
  aPos = CreateUnoStruct("com.sun.star.awt.Point")
  aSize = CreateUnoStruct("com.sun.star.awt.Size")
  aPos.X = 2500
  aPos.Y = 11000
  aSize.Width = 10000
  aSize.Height = 1000
  
  ' current page animations timing-root
  oAnimNode = oDrawPage.getAnimationNode()
  If NOT oAnimNode.hasElements() Then Exit Sub
  oPageAnimNodeEnume = oAnimNode.createEnumeration()
  ' main-sequence
  oPageSeqTimeCont = oPageAnimNodeEnume.nextElement()
  oPageSeqTimeCont.Duration = None
  
  ' first level par
  oParallelTimeCont = CreateUnoService( _
      "com.sun.star.animations.ParallelTimeContainer")
  oParallelTimeCont.Begin = CreateEvent(None, 0, None, com.sun.star.animations.EventTrigger.ON_NEXT)
  oParallelTimeCont.Restart = 0
  
  oPageSeqTimeCont.appendChild(oParallelTimeCont)
  
  nTotal = 0.001
  nLast = Len(sText) -1
  For i = 0 To nLast step 1
    sPartStr = Mid(sText, 1, i+1)
    oShape = CreateTextControl(oDoc, aPos, aSize)
    oDrawPage.add(oShape)
    oShape.setString(sPartStr)
  
    If NOT (i = 0) Then
      oChildPTC = CreateSimplePTC(nTotal - INTERVAL)
      oParallelTimeCont.appendChild(oChildPTC)
  
      oSubPTC = CreatePTC(0.0, 2, 1, "ooo-entrance-appear")
      oChildPTC.appendChild(oSubPTC)
  
      oAnimSet = CreateAppearAnimationSet(0.0001, 0.001, oShape, True)
      oSubPTC.appendChild(oAnimSet)
    End If
    If NOT (i = nLast) Then
      If (i = 0) Then
        oChildPTC = CreateSimplePTC(0.001)
      Else
        oChildPTC = CreateSimplePTC(nTotal - INTERVAL)
      End If
      oParallelTimeCont.appendChild(oChildPTC)
 
      If i = 0 Then
        oSubPTC = CreatePTC(0.0, 1, 2, "ooo-exit-disappear")
      Else
        oSubPTC = CreatePTC(INTERVAL, 3, 2, "ooo-exit-disappear")
     End If
    oChildPTC.appendChild(oSubPTC)
  
    oAnimSet = CreateAppearAnimationSet(0.0001, 0.001, oShape, False)
    oSubPTC.appendChild(oAnimSet)
    End If
    nTotal = nTotal + INTERVAL + 0.002
  Next
End Sub
 
 
Function CreateAppearAnimationSet(nBegin, nDuration, oSource, bVisible) As Object
  oAnimSet = CreateUnoService( _
      "com.sun.star.animations.AnimateSet")
  oAnimSet.AttributeName = "Visibility"
  oAnimSet.Additive = com.sun.star.animations.AnimationAdditiveMode.REPLACE
  oAnimSet.Begin = nBegin
  oAnimSet.Duration = nDuration
  oAnimSet.Fill = com.sun.star.animations.AnimationFill.HOLD
  oAnimSet.Restart = 0
  oAnimSet.Target = oSource
  oAnimSet.To = bVisible
  CreateAppearAnimationSet = oAnimSet
End Function
 
 
Function CreatePTC( nBegin, nNodeType, nPresetClass, vPresetId ) As Object
  oSubPTC = CreateUnoService( _
      "com.sun.star.animations.ParallelTimeContainer")
  oSubPTC.Begin = nBegin
  oSubPTC.Restart = 0
  oSubPTC.Fill = com.sun.star.animations.AnimationFill.HOLD
  oSubPTC.UserData = CreateUserData_1(nNodeType, nPresetClass, vPresetId)
  CreatePTC = oSubPTC
End Function
 
 
Function CreateSimplePTC(nBegin) As Object
  oChildPTC = CreateUnoService( _
      "com.sun.star.animations.ParallelTimeContainer")
  oChildPTC.Begin = nBegin
  oChildPTC.Restart = 0
  CreateSimplePTC = oChildPTC
End Function
 
' nNodeType: start type 1: OnClick, 2: With previous, 3: After previous
' nPresetClass: type of effect: 
Function CreateUserData_1( nNodeType, nPresetClass, vPresetId ) As Object
  Dim aUserData(2) As New com.sun.star.beans.NamedValue
  aUserData(0) = CreateNamedValue("node-type", nNodeType)
  aUserData(1) = CreateNamedValue("preset-class", nPresetClass)
  aUserData(2) = CreateNamedValue("preset-id", vPresetId)
  CreateUserData_1 = aUserData
End Function
 
 
Function CreateNamedValue( sName As String, vValue As Variant ) _
    As com.sun.star.beans.NamedValue
  aValue = CreateUnoStruct("com.sun.star.beans.NamedValue")
  aValue.Name = sName
  aValue.Value = vValue
  CreateNamedValue = aValue
End Function
 
 
Function CreateEvent(vOffset, usRepeat, vSource, nTrigger) _
    As com.sun.star.animation.Event
  aEv = CreateUnoStruct("com.sun.star.animations.Event")
  aEv.Offset = vOffset
  aEv.Repeat = usRepeat
  aEv.Source = vSource
  aEv.Trigger = nTrigger
  CreateEvent = aEv
End Function
 
 
Function CreateTextControl( oDoc As Object, aPos, aSize ) As Object
  oShape = oDoc.createInstance("com.sun.star.drawing.TextShape")
  oShape.setPosition(aPos)
  oShape.setSize(aSize)
  CreateTextControl = oShape
End Function

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes