<commit_before># -*- coding: UTF-8 -*-
#
# Copyright (c) 2009 <NAME>, Itaapy, Pierlis, Talend.
#
# Authors: <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#
# This file is part of Lpod (see: http://lpod-project.org).
# Lpod is free software; you can redistribute it and/or modify it under
# the terms of either:
#
# a) the GNU General Public License as published by the Free Software
#    Foundation, either version 3 of the License, or (at your option)
#    any later version.
#    Lpod is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with Lpod.  If not, see <http://www.gnu.org/licenses/>.
#
# b) the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#    http://www.apache.org/licenses/LICENSE-2.0
#

# Import from lpod
from lpod.document import odf_new_document_from_type
from lpod.draw_page import odf_create_draw_page
from lpod.frame import odf_create_text_frame, odf_create_image_frame
from lpod.list import odf_create_list
from lpod.shapes import odf_create_line, odf_create_connector
from lpod.shapes import odf_create_rectangle, odf_create_ellipse
from lpod.style import odf_create_style
from lpod.smil import odf_create_anim_par, odf_create_anim_transitionFilter

PPC = 72 * 2.54



# Creation of a transition for all pages: "Fade Through black"
def get_transition(page):
    anim_page = odf_create_anim_par(presentation_node_type="timing-root")
    anim_begin = odf_create_anim_par(smil_begin="%s.begin" % page)
    transition = odf_create_anim_transitionFilter(smil_dur="2s",
                                                  smil_type="fade",
                                                  smil_subtype="fadeOverColor")
    anim_page.append_element(anim_begin)
    anim_begin.append_element(transition)
    return anim_page



# Creation of the document
document = odf_new_document_from_type('presentation')
body = document.get_body()

# Change the default graphic fill color
standard = document.get_style('graphic', u"standard")
standard.set_style_properties({'draw:fill-color': '#ffffff'})

#
# Work on pages and add textframes
#
page1 = odf_create_draw_page('page1', name=u"Page 1")
body.append_element(page1)

#
# Text Frame
#

# Set the frame color
colored = odf_create_style('graphic', name=u"colored",
                           display_name=u"Colored", parent="standard")
colored.set_style_properties({'draw:fill-color': "#ad7fa8"},
                                 area='graphic')
colored.set_style_properties(color="#ffffff", area='text')
document.insert_style(colored)

# A paragraph style with big font
big = odf_create_style('paragraph', u"big", area='paragraph', align="center")
big.set_style_properties(area='text', size="32pt")
document.insert_style(big, automatic=True)

# Set a text frame
text_frame = odf_create_text_frame([u"lpOD", u"Presentation", u"Cookbook"],
        size=('7cm', '5cm'), position=('11cm', '8cm'), style=u"colored",
        text_style=u"big")
page1.append_element(text_frame)

# Add the transition for this frame
page1.append_element(get_transition("page1"))

#
# Image Frame
#

# Start a new page
page2 = odf_create_draw_page(u"page2")
body.append_element(page2)

# Embed an image from a file name
local_uri = document.add_file(u'images/zoé.jpg')

# Add image frame
image_frame = odf_create_image_frame(local_uri, size=('60mm', '45mm'),
                                     position=('4.5cm', '7cm'))
page2.append_element(image_frame)

# Some text side by side
list = odf_create_list([u"Item 1", u"Item 2", u"Item 3"])
text_frame = odf_create_text_frame(list, size=('7cm', '2.5cm'),
                                   position=('12.5cm', '7cm'),
                                   style=u"colored")
page2.append_element(text_frame)

# Add the transition for this frame
page2.append_element(get_transition("page2"))

#
# Shapes
#

# Last page
page3 = odf_create_draw_page(u"page3")
body.append_element(page3)

# Square
square = odf_create_rectangle(shape_id=u"square", size=('8cm', '8cm'),
                              position=('17cm', '2.5cm'),
                              style=u"colored")
page3.append_element(square)

# Circle
circle = odf_create_ellipse(shape_id=u"circle", size=('8cm', '8cm'),
                            position=('2cm', '10cm'), style=u"colored")
page3.append_element(circle)

# Line
line = odf_create_line(p1=('8cm', '5cm'), p2=('20cm', '17.5cm'))
page3.append_element(line)

# Connector
connector = odf_create_connector(connected_shapes=(square, circle),
                                 glue_points=('1', '3'))

# Add the transition for this frame
page3.append_element(get_transition("page3"))

# Save
filename = 'presentation.odp'
document.save(filename, pretty=True)
print 'Document "%s" generated.' % filename<commit_msg>doc/cookbook/odp: Update the example with the transitions<commit_after># -*- coding: UTF-8 -*-
#
# Copyright (c) 2009 <NAME>, Itaapy, Pierlis, Talend.
#
# Authors: <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#
# This file is part of Lpod (see: http://lpod-project.org).
# Lpod is free software; you can redistribute it and/or modify it under
# the terms of either:
#
# a) the GNU General Public License as published by the Free Software
#    Foundation, either version 3 of the License, or (at your option)
#    any later version.
#    Lpod is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with Lpod.  If not, see <http://www.gnu.org/licenses/>.
#
# b) the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#    http://www.apache.org/licenses/LICENSE-2.0
#

# Import from lpod
from lpod.document import odf_new_document_from_type
from lpod.draw_page import odf_create_draw_page
from lpod.frame import odf_create_text_frame, odf_create_image_frame
from lpod.list import odf_create_list
from lpod.shapes import odf_create_line, odf_create_connector
from lpod.shapes import odf_create_rectangle, odf_create_ellipse
from lpod.style import odf_create_style


PPC = 72 * 2.54


# Creation of the document
document = odf_new_document_from_type('presentation')
body = document.get_body()

# Change the default graphic fill color
standard = document.get_style('graphic', u"standard")
standard.set_style_properties({'draw:fill-color': '#ffffff'})

#
# Work on pages and add textframes
#
page1 = odf_create_draw_page('page1', name=u"Page 1")
body.append_element(page1)

#
# Text Frame
#

# Set the frame color
colored = odf_create_style('graphic', name=u"colored",
                           display_name=u"Colored", parent="standard")
colored.set_style_properties({'draw:fill-color': "#ad7fa8"},
                                 area='graphic')
colored.set_style_properties(color="#ffffff", area='text')
document.insert_style(colored)

# A paragraph style with big font
big = odf_create_style('paragraph', u"big", area='paragraph', align="center")
big.set_style_properties(area='text', size="32pt")
document.insert_style(big, automatic=True)

# Set a text frame
text_frame = odf_create_text_frame([u"lpOD", u"Presentation", u"Cookbook"],
        size=('7cm', '5cm'), position=('11cm', '8cm'), style=u"colored",
        text_style=u"big")
page1.append_element(text_frame)

# Add a transition for this frame
page1.set_transition("fade", "fadeOverColor")

#
# Image Frame
#

# Start a new page
page2 = odf_create_draw_page(u"page2")
body.append_element(page2)

# Embed an image from a file name
local_uri = document.add_file(u'images/zoé.jpg')

# Add image frame
image_frame = odf_create_image_frame(local_uri, size=('60mm', '45mm'),
                                     position=('4.5cm', '7cm'))
page2.append_element(image_frame)

# Some text side by side
list = odf_create_list([u"Item 1", u"Item 2", u"Item 3"])
text_frame = odf_create_text_frame(list, size=('7cm', '2.5cm'),
                                   position=('12.5cm', '7cm'),
                                   style=u"colored")
page2.append_element(text_frame)

# Add a transition for this frame
page2.set_transition("fade", "fadeOverColor")

#
# Shapes
#

# Last page
page3 = odf_create_draw_page(u"page3")
body.append_element(page3)

# Square
square = odf_create_rectangle(shape_id=u"square", size=('8cm', '8cm'),
                              position=('17cm', '2.5cm'),
                              style=u"colored")
page3.append_element(square)

# Circle
circle = odf_create_ellipse(shape_id=u"circle", size=('8cm', '8cm'),
                            position=('2cm', '10cm'), style=u"colored")
page3.append_element(circle)

# Line
line = odf_create_line(p1=('8cm', '5cm'), p2=('20cm', '17.5cm'))
page3.append_element(line)

# Connector
connector = odf_create_connector(connected_shapes=(square, circle),
                                 glue_points=('1', '3'))

# Add a transition for this frame
page3.set_transition("fade", "fadeOverColor")

# Save
filename = 'presentation.odp'
document.save(filename, pretty=True)
print 'Document "%s" generated.' % filename
{'fraction_non_alphanumeric': 0.12034919975057161, 'fraction_numerical': 0.017459987528580335, 'mean_word_length': 3.799501246882793, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '941642', 'n_tokens_mistral': 3163, 'n_tokens_neox': 3080, 'n_words': 802}