2017-03-29 8 views
0

マクロに関しては、Impress(マクロの記録なし、Pythonスクリプティングなし、Basicのみなど)、およびごく少数のサンプルでほとんど機能していません。選択にフェードイン効果を作成するにはどうすればいいですか?

「手動で」テキストアニメーションを作成する方法のサンプルはありません。私は1つを見つけたhere(6歳)と多くの情報があります。

これまで私は、(1)既にそこにあるテキストアニメーション「fadein」をスキャンしていました。(2)他のテキストアニメーションをすべてスキャンし、それらを削除して、「fadein 「アニメーション:私は効果のクローンを作成する場合

sub MyFunction 
    ' -------------------------------------------------------------------- 
    ' (1) scan for a text animation "fadein" that is already there 
    effectNodeFadeIn = Null 
    doc = ThisComponent 
    numSlides = doc.getDrawPages().getCount() 
    slide = doc.drawPages(numSlides-1) 

    mainSequence = getMainSequence(slide)  
    clickNodes = mainSequence.createEnumeration() 
    while clickNodes.hasMoreElements() and IsNull(effectNodeFadeIn) 
     clickNode = clickNodes.nextElement() 

     groupNodes = clickNode.createEnumeration() 
     while groupNodes.hasMoreElements() and IsNull(effectNodeFadeIn) 
      groupNode = groupNodes.nextElement() 

      effectNodes = groupNode.createEnumeration() 
      while effectNodes.hasMoreElements() and IsNull(effectNodeFadeIn) 
       effectNode = effectNodes.nextElement() 
       ' ICIC 

       if effectNode.ImplementationName = "animcore::ParallelTimeContainer" then 
        if hasUserDataKey(effectNode, "preset-id") then 
         v = getUserDataValue(effectNode, "preset-id") 
         if v = "ooo-entrance-fade-in" then ' ooo-entrance-appear 
          effectNodeFadeIn = effectNode 
         end if 
        end if 
       end if 
       ' useless loop just in case I need it: 
       animNodes = effectNode.createEnumeration() 
       while animNodes.hasMoreElements() 
        animNode = animNodes.nextElement() 
       wend 
      wend 
     wend 
    wend 
    ' -------------------------------------------------------------------- 
    ' (2) scan for all other text animations, 
    ' and then remove them an replace them by a clone of the "fadein" animation 
    if not IsNull(effectNodeFadeIn) then 

     clickNodes = mainSequence.createEnumeration() 
     while clickNodes.hasMoreElements() 
      clickNode = clickNodes.nextElement() 

      groupNodes = clickNode.createEnumeration() 
      while groupNodes.hasMoreElements() 
       groupNode = groupNodes.nextElement() 

       effectNodes = groupNode.createEnumeration() 
       while effectNodes.hasMoreElements() 
        effectNode = effectNodes.nextElement() 
        ' ICIC 

        if effectNode.ImplementationName = "animcore::ParallelTimeContainer" then 
         if hasUserDataKey(effectNode, "preset-id") then 
          v = getUserDataValue(effectNode, "preset-id") 
          if v <> "ooo-entrance-fade-in" then ' ooo-entrance-appear 
           groupNode.removeChild(effectNode) 
           n = effectNodeFadeIn.createClone() 
           groupNode.appendChild(n) 

           ' useless loop just in case I need it: 
           animNodes = effectNode.createEnumeration() 
           while animNodes.hasMoreElements() 
            animNode = animNodes.nextElement() 
           wend 
          end if 
         end if 

        end if 
       wend 
      wend 
     wend 
    end if 
end sub 

function hasUserDataKey(node as Object, key as String) as Boolean 
    for each data in node.UserData 
     if data.Name = "node-type" then 
      hasUserDataKey = True 
      exit function 
     end if 
    next data 
    hasUserDataKey = False 
end function 

function getUserDataValue(node as Object, key as String) as Variant 
    for each data in node.UserData 
     if data.Name = key then 
      getUserDataValue = data.Value 
      exit function 
     end if 
    next data 
end function 

が、それはまだだ 『リンク』のオリジナルテキストにして、親が削除され、置き換えられている 『フェードイン』のテキスト。どのようにこれを修正するための任意のアイデア?

+0

ここで 'hasUserDataKey()'と 'getUserDataValue()'の定義は何ですか? –

+0

不足している2つの機能で質問が更新されました。 –

答えて

0

それはあなたが形状の内のテキストを選択しているように聞こえるので、次のように基本的なコードを使用します。

Sub AddAnimation 
    xTextCursor = ThisComponent.CurrentController.Selection(0) 
    xText = xTextCursor.getText() 
    xText.TextEffect = com.sun.star.presentation.AnimationEffect.FADE_FROM_BOTTOM 
End Sub 

やPythonで

:私には完全には明らかではない理由から

import uno 
from com.sun.star.presentation.AnimationEffect import FADE_FROM_BOTTOM 

def add_animation(): 
    oDoc = XSCRIPTCONTEXT.getDocument() 
    xTextCursor = oDoc.CurrentController.Selection.getByIndex(0) 
    xText = xTextCursor.getText() 
    xText.TextEffect = FADE_FROM_BOTTOM 

、結果はフェードインではなくワイプされます。

文書はhttps://wiki.openoffice.org/wiki/Documentation/DevGuide/Drawings/Animations_and_Interactionsです。そのページのShapeHelperクラスはShapeHelper.javaで定義されています。

+0

そして、私は良い定数を検索しようとしますが、それは良いスタートですが、 "1秒"に変更する必要があります。 –

+0

私は2つの大きなループで質問を修正しましたが、これはほとんど機能しています。 –

+0

私はまだ作業用のソースコードを探しています...コードがほとんど動いているところを見つけました。印象的です:テキストの作成、エフェクトの作成、すべてはOKですが、時間は無視されます...マクロを起動しますそれは、期間が無視されることを除いてすべてを生成しますが、テキスト要素の "期間"を手動でクリックし、それを手動で変更すると、それは動作します(それは、削除され、 。)私はとても近く、とてもイライラしています... http://hermione.s41.xrea.com/pukiwiki/pukiwiki.php?OOoBasic%2FImpress%2FAnimation –

関連する問題