} // private void ActOnShape

        private static void ActOnSelectedText(ActOnPPTText act, Config conf)
        {
            logger.ConditionalDebug("ActOnSelectedText");
            ProgressNotifier.thePN.Start();
            if (ColorizationPPT.thisAddIn.Application.Presentations.Count > 0)
            {
                ColorizationPPT.thisAddIn.Application.StartNewUndoEntry();
                var sel = ColorizationPPT.thisAddIn.Application.ActiveWindow.Selection;
                if (sel.Type == PpSelectionType.ppSelectionText)
                {
                    act(new PPTText(ColorizationPPT.thisAddIn.Application.ActiveWindow.Selection.TextRange), conf);
                }
                else if (sel.Type == PpSelectionType.ppSelectionShapes)
                {
                    // bool textFound = false;
                    foreach (Shape sh in sel.ShapeRange)
                    {
                        ActOnShape(sh, act, sel.ShapeRange.Count, conf);
                    } // foreach
                }     // else no text selected
                else if (sel.Type == PpSelectionType.ppSelectionSlides)
                {
                    foreach (Slide s in sel.SlideRange)
                    {
                        foreach (Shape sh in s.Shapes)
                        {
                            ActOnShape(sh, act, s.Shapes.Count, conf);
                        }
                    }
                }
            }
            ProgressNotifier.thePN.Completed();
            logger.ConditionalDebug("EXIT ActOnSelectedText");
        } // void ColorizeSelectedPhons()
예제 #2
0
        } // private void ActOnShape

        private static void ActOnSelectedText(ActOnPPTText act, Config conf)
        {
            logger.ConditionalDebug("ActOnSelectedText");
            try
            {
                ProgressNotifier.thePN.Start();
                if (ColorizationPPT.thisAddIn.Application.Presentations.Count > 0)
                {
                    ColorizationPPT.thisAddIn.Application.StartNewUndoEntry();
                    var sel = ColorizationPPT.thisAddIn.Application.ActiveWindow.Selection;
                    if (sel.Type == PpSelectionType.ppSelectionText)
                    {
                        ShapeRange shapeR = sel.ShapeRange;
                        Debug.Assert(shapeR.Count == 1);
                        Shape      s      = shapeR[1];
                        SlideRange slideR = sel.SlideRange;
                        Debug.Assert(slideR.Count == 1);
                        act(new PPTText(ColorizationPPT.thisAddIn.Application.ActiveWindow.Selection.TextRange,
                                        slideR[1], s.HasTable == Microsoft.Office.Core.MsoTriState.msoTrue, s.Left, s.Top), conf);
                    }
                    else if (sel.Type == PpSelectionType.ppSelectionShapes)
                    {
                        // bool textFound = false;
                        foreach (Shape sh in sel.ShapeRange)
                        {
                            ActOnShape(sh, act, sel.ShapeRange.Count, conf);
                        } // foreach
                    }     // else no text selected
                    else if (sel.Type == PpSelectionType.ppSelectionSlides)
                    {
                        foreach (Slide s in sel.SlideRange)
                        {
                            foreach (Shape sh in s.Shapes)
                            {
                                ActOnShape(sh, act, s.Shapes.Count, conf);
                            }
                        }
                    }
                }
                ProgressNotifier.thePN.Completed();
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("Ouups. Une vilaine erreur s'est produite. Désolé. N'hésitez pas à nous ");
                sb.AppendLine("envoyer une description de votre problème à [email protected].");
                sb.AppendLine(e.Message);
                sb.AppendLine(e.StackTrace);
                logger.Error(sb.ToString());
                MessageBox.Show(sb.ToString(), ConfigBase.ColorizationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            logger.ConditionalDebug("EXIT ActOnSelectedText");
        } // void ColorizeSelectedPhons()
예제 #3
0
 private static void ActOnShape(Shape sh, ActOnPPTText act, int nrObjSelected, Config conf,
                                bool withinTable = false, float posX = 0.0f, float posY = 0.0f)
 {
     logger.ConditionalDebug("ActOnShape");
     Debug.Assert(sh != null);
     if (sh.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
     {
         if (sh.TextFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
         {
             Slide slide    = null;
             Shape theShape = sh;
             while (theShape != null && slide == null)
             {
                 if (theShape.Parent != null && theShape.Parent is Slide)
                 {
                     slide = sh.Parent;
                 }
                 else
                 {
                     theShape = theShape.Parent;
                 }
             }
             act(new PPTText(sh.TextFrame.TextRange, slide, withinTable, posX, posY), conf);
         }
     }
     else if (sh.Type == Microsoft.Office.Core.MsoShapeType.msoGroup)
     {
         foreach (Shape descSh in sh.GroupItems)
         {
             ActOnShape(descSh, act, nrObjSelected, conf, withinTable, posX, posY);
         }
     }
     if (sh.HasTable == Microsoft.Office.Core.MsoTriState.msoTrue)
     {
         foreach (Row r in sh.Table.Rows)
         {
             foreach (Cell c in r.Cells)
             {
                 if ((nrObjSelected > 1) || (c.Selected))
                 {
                     ActOnShape(c.Shape, act, nrObjSelected, conf, true, sh.Left, sh.Top);
                 }
             }
         }
     }
     // il y a visiblement un problème avec la sélection de tableaux. Les cellules ne sont pas sélectionnées
     // si plusieurs objets sont sélectionnés dont le tableau...
     // rendons donc le comportement dépendant du nombre d'objets dans la sélection... Y a-t-il un piège?
     // Powerpoint lui-même n'utilise pas ce truc. Hypothèse il s'agit d'un bug de Powerpoint dans la version
     // que j'utilise. Le comportement pourrait donc changer. Avec un peu de chance, le code devrait continuer
     // à se comporter correctement.
 } // private void ActOnShape