def create_segmented_circle(slide, num_segments, width_percentage, size_outer=100, use_arrow_shape=False): # aussenKurve = bezier.bezierKreisNRM(2,100,[100,100]) # innenKurve = bezier.bezierKreisNRM(2,75,[100,100]) size_inner = size_outer * (1 - width_percentage / 100.) aussenKurve = bezier.kreisSegmente(num_segments, size_outer, [200, 200]) innenKurve = bezier.kreisSegmente(num_segments, size_inner, [200, 200]) # shapeCount = slide.shapes.count def addNodesForCurves(ffb, kurven): for k in kurven: ffb.AddNodes(1, 1, k[1][0], k[1][1], k[2][0], k[2][1], k[3][0], k[3][1]) for i in range(0, len(aussenKurve)): # Außen- und Innenkurve jeweils als Liste von Bezierkurven aK = aussenKurve[i] iK = innenKurve[i] iK.reverse() for k in iK: k.reverse() # Hinweg auf Außenkurve ffb = slide.Shapes.BuildFreeform(1, aK[0][0][0], aK[0][0][1]) addNodesForCurves(ffb, aK) # Uebergang zur Innenkurve # mit kleiner Spitze A = aK[-1][3] B = iK[0][0] M = [A[0] + (B[0] - A[0]) / 2, A[1] + (B[1] - A[1]) / 2.] h = [B[1] - A[1], A[0] - B[0]] if use_arrow_shape: ffb.AddNodes(0, 0, M[0] + h[0] / 3., M[1] + h[1] / 3.) ffb.AddNodes(0, 0, B[0], B[1]) # Rueckweg auf Innenkurve addNodesForCurves(ffb, iK) # Uebergang zur Außenkurve # mit kleiner Spitze (Mittelpunkt M, Orthogale h) A = iK[-1][3] B = aK[0][0] M = [A[0] + (B[0] - A[0]) / 2, A[1] + (B[1] - A[1]) / 2.] h = [B[1] - A[1], A[0] - B[0]] if use_arrow_shape: ffb.AddNodes(0, 0, M[0] - h[0] / 3., M[1] - h[1] / 3.) ffb.AddNodes(0, 0, B[0], B[1]) shp = ffb.ConvertToShape() # einen Shape-Punkt bewegen --> textframe wird auf shape zentriert shp.nodes.setposition(1, aK[0][0][0] + 1, aK[0][0][1]) shp.nodes.setposition(1, aK[0][0][0], aK[0][0][1]) #slide.Shapes.Range(array('l', [i + shapeCount for i in range(0,len(aussenKurve))])).Group.select # slide.Shapes.Range(Array[int]([i+shapeCount+1 for i in range(0,len(aussenKurve))])).group().select() pplib.last_n_shapes_on_slide(slide, num_segments).group().select()
def slide_paste(cls, application, data_type=PASTE_DATATYPE_PNG, content_only=False): if not cls.has_clipboard_data(): return data = cls.get_clipboard_data(application) cur_slide = application.ActiveWindow.View.Slide # cur_shapes = cur_slide.Shapes.Count pasted_shapes = 0 for slide_id in data["slide_ids"]: if type(slide_id) == tuple: shape_id = slide_id[1] slide_id = slide_id[0] else: shape_id = None try: try: #Copy cls.find_and_copy_object(application, slide_id, data["slide_path"], content_only, shape_id) except: #bkt.helpers.exception_as_message() bkt.helpers.message("Fehler! Referenz nicht gefunden.") continue #Paste application.ActiveWindow.Selection.SlideRange[ 1].Shapes.PasteSpecial(Datatype=data_type) pasted_shapes += 1 #Save tags shape = application.ActiveWindow.Selection.ShapeRange(1) with ThumbnailerTags(shape.Tags) as tags: tags.set_thumbnail(slide_id, data["slide_path"], data_type, content_only, shape_id) shape.Tags.Add(bkt.contextdialogs.BKT_CONTEXTDIALOG_TAGKEY, BKT_THUMBNAIL) except: #bkt.helpers.exception_as_message() bkt.helpers.message( "Fehler! Thumbnail konnte nicht im gewählten Format eingefügt werden." ) logging.error(traceback.format_exc()) # select pasted shapes if pasted_shapes > 0: # cur_slide.Shapes.Range(Array[int](range(cur_shapes+1, cur_slide.Shapes.Count+1))).Select() pplib.last_n_shapes_on_slide(cur_slide, pasted_shapes).Select() #Restore clipboard cls.set_clipboard_data(**data)
def create_process(cls, slide, num_steps=3, first_pentagon=True, spacing=5): ref_left, ref_top, ref_width, ref_height = pplib.slide_content_size( slide.parent) width = (ref_width + spacing) / num_steps - spacing height = 50 top = ref_top left = ref_left if first_pentagon: slide.shapes.addshape(pplib.MsoAutoShapeType['msoShapePentagon'], left, top, width, height) else: slide.shapes.addshape(pplib.MsoAutoShapeType['msoShapeChevron'], left, top, width, height) for i in range(num_steps - 1): left += width + spacing slide.shapes.addshape(pplib.MsoAutoShapeType['msoShapeChevron'], left, top, width, height) shapes = pplib.last_n_shapes_on_slide(slide, num_steps) shapes.Adjustments[1] = 0.28346 #0.5cm shapes.Textframe2.TextRange.ParagraphFormat.Bullet.Type = 0 shapes.Textframe2.TextRange.ParagraphFormat.LeftIndent = 0 shapes.Textframe2.TextRange.ParagraphFormat.FirstLineIndent = 0 shapes.Textframe2.VerticalAnchor = 3 #middle grp = shapes.group() cls._add_tags(grp) grp.select()
def create(cls, slide): logging.debug("create ampel 3") # from System import Array # slide=cls.context.app.activewindow.selection.sliderange[1] # shapeCount = slide.shapes.count shapes = [ slide.shapes.addshape(1, 100, 100, 30, 80), #rect slide.shapes.addshape(9, 105, 105, 20, 20), #red slide.shapes.addshape(9, 105, 130, 20, 20), #yellow slide.shapes.addshape(9, 105, 155, 20, 20) #green ] for shape in shapes: shape.fill.ForeColor.RGB = 14277081 shape.line.weight = 0.75 shape.line.ForeColor.RGB = 0 # gruppieren # grp = slide.Shapes.Range(Array[int](range(shapeCount+1, shapeCount+5))).group() grp = pplib.last_n_shapes_on_slide(slide, 4).group() grp.select() grp.LockAspectRatio = -1 #msoTrue grp.Tags.Add(bkt.contextdialogs.BKT_CONTEXTDIALOG_TAGKEY, cls.BKT_DIALOG_AMPEL) cls.set_color(grp)
def _create_stateshape_scale(cls, slide, shape_type, total): shapecount = slide.Shapes.Count for i in range(total+1): cls._create_single_scale(slide, shape_type, i, total) slide.Shapes.Range(shapecount+1).visible = -1 #make first visible # grp = slide.Shapes.Range(Array[int](range(shapecount+1, shapecount+1+total+1))).group() grp = pplib.last_n_shapes_on_slide(slide, total+1).group() grp.Tags.Add(bkt.contextdialogs.BKT_CONTEXTDIALOG_TAGKEY, StateShape.BKT_DIALOG_TAG) grp.select()
def create_headered_chevron(cls, slide): ''' creates a headered pentagon on the given slide ''' # shapeCount = slide.shapes.count # shapes erstellen pentagon = slide.shapes.addshape( pplib.MsoAutoShapeType['msoShapeChevron'], 100, 100, 400, 200) header = slide.shapes.addshape( pplib.MsoAutoShapeType['msoShapeRectangle'], 100, 100, 400, 30) pentagon.TextFrame.TextRange.Text = "Content" header.TextFrame.TextRange.Text = "Header" pentagon.Fill.ForeColor.ObjectThemeColor = pplib.MsoThemeColorIndex[ 'msoThemeColorBackground1'] header.Fill.ForeColor.ObjectThemeColor = pplib.MsoThemeColorIndex[ 'msoThemeColorText1'] #header.Fill.ForeColor.ObjectThemeColor = pplib.MsoThemeColorIndex['msoThemeColorBackground2'] pentagon.TextFrame.TextRange.Font.Color.ObjectThemeColor = pplib.MsoThemeColorIndex[ 'msoThemeColorText1'] header.TextFrame.TextRange.Font.Color.ObjectThemeColor = pplib.MsoThemeColorIndex[ 'msoThemeColorBackground1'] #header.TextFrame.TextRange.Font.Color.ObjectThemeColor = pplib.MsoThemeColorIndex['msoThemeColorText2'] pentagon.Line.ForeColor.ObjectThemeColor = pplib.MsoThemeColorIndex[ 'msoThemeColorText1'] header.Line.ForeColor.ObjectThemeColor = pplib.MsoThemeColorIndex[ 'msoThemeColorText1'] pentagon.Adjustments.item[1] = 0.2 # margin top pentagon.textFrame.MarginTop = 36 #margin left header.textFrame.MarginLeft = 16 # align top/left pentagon.TextFrame.VerticalAnchor = 1 # Top pentagon.TextFrame.TextRange.ParagraphFormat.Alignment = 1 # Left header.TextFrame.TextRange.ParagraphFormat.Alignment = 1 # Left # gruppieren/selektieren # grp = slide.Shapes.Range(Array[int]([shapeCount+1, shapeCount+2])).group() grp = pplib.last_n_shapes_on_slide(slide, 2).group() grp.select() #cls.update_pentagon_group(grp) cls.update_header(pentagon, header)
def _create_single_scale(cls, slide, shape_type=1, state=0, total=3, visible=0): # shapecount = slide.Shapes.Count left = 90 for i in range(total): left += cls.size + cls.spacing s = slide.Shapes.AddShape( shape_type, left, 100, cls.size, cls.size ) s.Line.Weight = 0.75 s.Line.ForeColor.RGB = cls.color_line if i < state: s.Fill.ForeColor.RGB = cls.color_filled else: s.Fill.ForeColor.RGB = cls.color_empty # grp = slide.Shapes.Range(Array[int](range(shapecount+1, shapecount+1+total))).group() grp = pplib.last_n_shapes_on_slide(slide, total).group() grp.Visible = visible return grp