def HighlightAll(doc):
    """
    Apply syntax highlighting to all TextShapes in the document which have the "code"
    graphic style applied to them
    """
    styles = doc.StyleFamilies.getByName(u"graphics")
    code = styles.getByName(u"code")
    pages = doc.DrawPages
    count = pages.getCount()
    for idx in xrange(count):
        page = pages.getByIndex(idx)
        count = page.getCount()
        for item_idx in xrange(count):
            item = page.getByIndex(item_idx)
            if 'com.sun.star.drawing.TextShape' in item.SupportedServiceNames:
                style = item.Style
                if style==code:
                    ColourTextBox(item)

    Apply syntax highlighting to all TextShapes in the document which have the "code"
    graphic style applied to them
    
recipes/Python/576796_PythSyntax_Highlighting_OpenOffice/recipe-576796.py