Make CopyEffectsTo an extension method and reorder its parameters.
diff --git a/PowerPointLaTeX/PowerPointLaTeX/LaTeXTool.cs b/PowerPointLaTeX/PowerPointLaTeX/LaTeXTool.cs
index 32d985c..08a2491 100644
--- a/PowerPointLaTeX/PowerPointLaTeX/LaTeXTool.cs
+++ b/PowerPointLaTeX/PowerPointLaTeX/LaTeXTool.cs
@@ -185,7 +185,7 @@
return picture;
}
- private int GetSafeEffectParagraph( Effect effect ) {
+ private static int GetSafeEffectParagraph( Effect effect ) {
try {
return effect.Paragraph;
}
@@ -206,37 +206,13 @@
|| effect.EffectInformation.BuildByLevelEffect == MsoAnimateByLevel.msoAnimateLevelNone)
select effect;
- CopyEffectsTo( picture, true, sequence, effects );
+ picture.AddEffects(effects, true, sequence);
}
catch {
Debug.Fail( "CopyInlineEffects failed!" );
}
}
- private static void CopyEffectsTo(Shape target, bool setToWithPrevious, Sequence sequence, IEnumerable<Effect> effects)
- {
- foreach (Effect effect in effects)
- {
- int index = effect.Index + 1;
- Effect formulaEffect = sequence.Clone(effect, index);
- try
- {
- formulaEffect = sequence.ConvertToBuildLevel(formulaEffect, MsoAnimateByLevel.msoAnimateLevelNone);
- }
- catch { }
- //formulaEffect = sequence.ConvertToTextUnitEffect(formulaEffect, MsoAnimTextUnitEffect.msoAnimTextUnitEffectMixed);
- if (setToWithPrevious)
- formulaEffect.Timing.TriggerType = MsoAnimTriggerType.msoAnimTriggerWithPrevious;
- try
- {
- formulaEffect.Paragraph = 0;
- }
- catch { }
- formulaEffect.Shape = target;
- // Effect formulaEffect = sequence.AddEffect(picture, effect.EffectType, MsoAnimateByLevel.msoAnimateLevelNone, MsoAnimTriggerType.msoAnimTriggerWithPrevious, index);
- }
- }
-
private static void FillTextRange(TextRange range, char character, float minWidth)
{
range.Text = character.ToString() + ( (char) 160 ).ToString(); // ;
@@ -406,26 +382,6 @@
shape.LaTeXTags().Type.value = codeCount > 0 ? EquationType.HasCompiledInlines : EquationType.None;
}
- public void CompileShape(Slide slide, Shape shape)
- {
- // we don't need to compile already compiled shapes (its also sensible to avoid destroying escape sequences or overwrite entries, etc.)
- // don't try to compile equations (or their sources) either
- EquationType type = shape.LaTeXTags().Type;
- if (type == EquationType.HasCompiledInlines || type == EquationType.Equation)
- {
- return;
- }
-
- if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
- {
- TextFrame textFrame = shape.TextFrame;
- if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
- {
- CompileInlineTextRange(slide, shape, textFrame.TextRange);
- }
- }
- }
-
private void DecompileTextRange(Slide slide, Shape shape, TextRange range)
{
// make sure this is always valid, otherwise the code will do stupid things
@@ -474,6 +430,26 @@
shape.LaTeXTags().Type.value = EquationType.HasInlines;
}
+ public void CompileShape(Slide slide, Shape shape)
+ {
+ // we don't need to compile already compiled shapes (its also sensible to avoid destroying escape sequences or overwrite entries, etc)
+ // don't try to compile equations (or their sources) either
+ EquationType type = shape.LaTeXTags().Type;
+ if (type == EquationType.HasCompiledInlines || type == EquationType.Equation)
+ {
+ return;
+ }
+
+ if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
+ {
+ TextFrame textFrame = shape.TextFrame;
+ if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
+ {
+ CompileInlineTextRange(slide, shape, textFrame.TextRange);
+ }
+ }
+ }
+
public void DecompileShape(Slide slide, Shape shape)
{
// we don't need to decompile already shapes that aren't compiled
@@ -533,8 +509,6 @@
shape.LaTeXTags().Clear();
}
-
-
public void CompileSlide(Slide slide)
{
ShapeWalker.WalkSlide(slide, CompileShape);
@@ -641,7 +615,7 @@
where effect.Shape == equation
select effect;
- CopyEffectsTo(newEquation, false, sequence, effects);
+ newEquation.AddEffects(effects, false, sequence);
// delete the old equation
equation.Delete();
diff --git a/PowerPointLaTeX/PowerPointLaTeX/ShapeExtensions.cs b/PowerPointLaTeX/PowerPointLaTeX/ShapeExtensions.cs
index 476dc97..da291de 100644
--- a/PowerPointLaTeX/PowerPointLaTeX/ShapeExtensions.cs
+++ b/PowerPointLaTeX/PowerPointLaTeX/ShapeExtensions.cs
@@ -52,5 +52,28 @@
return linkShape;
}
+ internal static void AddEffects(this Shape target, IEnumerable<Effect> effects, bool setToWithPrevious, Sequence sequence)
+ {
+ foreach (Effect effect in effects)
+ {
+ int index = effect.Index + 1;
+ Effect formulaEffect = sequence.Clone(effect, index);
+ try
+ {
+ formulaEffect = sequence.ConvertToBuildLevel(formulaEffect, MsoAnimateByLevel.msoAnimateLevelNone);
+ }
+ catch { }
+ //formulaEffect = sequence.ConvertToTextUnitEffect(formulaEffect, MsoAnimTextUnitEffect.msoAnimTextUnitEffectMixed);
+ if (setToWithPrevious)
+ formulaEffect.Timing.TriggerType = MsoAnimTriggerType.msoAnimTriggerWithPrevious;
+ try
+ {
+ formulaEffect.Paragraph = 0;
+ }
+ catch { }
+ formulaEffect.Shape = target;
+ // Effect formulaEffect = sequence.AddEffect(picture, effect.EffectType, MsoAnimateByLevel.msoAnimateLevelNone, MsoAnimTriggerType.msoAnimTriggerWithPrevious, index);
+ }
+ }
}
}