Coding standards

This commit is contained in:
Jonathan Corwin 2010-07-11 21:53:53 +01:00
parent fe5b3e6771
commit bff74507d7
3 changed files with 470 additions and 469 deletions

View File

@ -174,7 +174,7 @@ def resize_image(image, width, height):
""" """
preview = QtGui.QImage(image) preview = QtGui.QImage(image)
if not preview.isNull(): if not preview.isNull():
if(preview.width() == width and preview.height == height): if preview.width() == width and preview.height == height:
return preview return preview
preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation) QtCore.Qt.SmoothTransformation)

View File

@ -1,468 +1,468 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
############################################################################### ###############################################################################
# OpenLP - Open Source Lyrics Projection # # OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman # # Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # # Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # # Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
# Thompson, Jon Tibble, Carsten Tinggaard # # Thompson, Jon Tibble, Carsten Tinggaard #
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it # # This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free # # under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. # # Software Foundation; version 2 of the License. #
# # # #
# This program is distributed in the hope that it will be useful, but WITHOUT # # This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. # # more details. #
# # # #
# You should have received a copy of the GNU General Public License along # # You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
# OOo API documentation: # OOo API documentation:
# http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html # http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/Getting_Information_about_UNO_Objects#Inspecting_interfaces_during_debugging # http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/Getting_Information_about_UNO_Objects#Inspecting_interfaces_during_debugging
# http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html # http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html
# http://www.oooforum.org/forum/viewtopic.phtml?t=5252 # http://www.oooforum.org/forum/viewtopic.phtml?t=5252
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations # http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations
# http://mail.python.org/pipermail/python-win32/2008-January/006676.html # http://mail.python.org/pipermail/python-win32/2008-January/006676.html
# http://www.linuxjournal.com/content/starting-stopping-and-connecting-openoffice-python # http://www.linuxjournal.com/content/starting-stopping-and-connecting-openoffice-python
# http://nxsy.org/comparing-documents-with-openoffice-and-python # http://nxsy.org/comparing-documents-with-openoffice-and-python
import logging import logging
import os import os
import time import time
from openlp.core.lib import resize_image from openlp.core.lib import resize_image
if os.name == u'nt': if os.name == u'nt':
from win32com.client import Dispatch from win32com.client import Dispatch
import pywintypes import pywintypes
else: else:
try: try:
import uno import uno
from com.sun.star.beans import PropertyValue from com.sun.star.beans import PropertyValue
uno_available = True uno_available = True
except ImportError: except ImportError:
uno_available = False uno_available = False
from PyQt4 import QtCore from PyQt4 import QtCore
from presentationcontroller import PresentationController, PresentationDocument from presentationcontroller import PresentationController, PresentationDocument
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ImpressController(PresentationController): class ImpressController(PresentationController):
""" """
Class to control interactions with Impress presentations. Class to control interactions with Impress presentations.
It creates the runtime environment, loads and closes the presentation as It creates the runtime environment, loads and closes the presentation as
well as triggering the correct activities based on the users input well as triggering the correct activities based on the users input
""" """
log.info(u'ImpressController loaded') log.info(u'ImpressController loaded')
def __init__(self, plugin): def __init__(self, plugin):
""" """
Initialise the class Initialise the class
""" """
log.debug(u'Initialising') log.debug(u'Initialising')
PresentationController.__init__(self, plugin, u'Impress') PresentationController.__init__(self, plugin, u'Impress')
self.supports = [u'.odp'] self.supports = [u'.odp']
self.alsosupports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx'] self.alsosupports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx']
self.process = None self.process = None
self.desktop = None self.desktop = None
self.manager = None self.manager = None
def check_available(self): def check_available(self):
""" """
Impress is able to run on this machine Impress is able to run on this machine
""" """
log.debug(u'check_available') log.debug(u'check_available')
if os.name == u'nt': if os.name == u'nt':
return self.get_com_servicemanager() is not None return self.get_com_servicemanager() is not None
else: else:
return uno_available return uno_available
def start_process(self): def start_process(self):
""" """
Loads a running version of OpenOffice in the background. Loads a running version of OpenOffice in the background.
It is not displayed to the user but is available to the UNO interface It is not displayed to the user but is available to the UNO interface
when required. when required.
""" """
log.debug(u'start process Openoffice') log.debug(u'start process Openoffice')
if os.name == u'nt': if os.name == u'nt':
self.manager = self.get_com_servicemanager() self.manager = self.get_com_servicemanager()
self.manager._FlagAsMethod(u'Bridge_GetStruct') self.manager._FlagAsMethod(u'Bridge_GetStruct')
self.manager._FlagAsMethod(u'Bridge_GetValueObject') self.manager._FlagAsMethod(u'Bridge_GetValueObject')
else: else:
# -headless # -headless
cmd = u'openoffice.org -nologo -norestore -minimized -invisible -nofirststartwizard -accept="socket,host=localhost,port=2002;urp;"' cmd = u'openoffice.org -nologo -norestore -minimized -invisible -nofirststartwizard -accept="socket,host=localhost,port=2002;urp;"'
self.process = QtCore.QProcess() self.process = QtCore.QProcess()
self.process.startDetached(cmd) self.process.startDetached(cmd)
self.process.waitForStarted() self.process.waitForStarted()
def get_uno_desktop(self): def get_uno_desktop(self):
""" """
On non-Windows platforms, use Uno. Get the OpenOffice desktop On non-Windows platforms, use Uno. Get the OpenOffice desktop
which will be used to manage impress which will be used to manage impress
""" """
log.debug(u'get UNO Desktop Openoffice') log.debug(u'get UNO Desktop Openoffice')
ctx = None ctx = None
loop = 0 loop = 0
log.debug(u'get UNO Desktop Openoffice - getComponentContext') log.debug(u'get UNO Desktop Openoffice - getComponentContext')
context = uno.getComponentContext() context = uno.getComponentContext()
log.debug(u'get UNO Desktop Openoffice - createInstaneWithContext - ' log.debug(u'get UNO Desktop Openoffice - createInstaneWithContext - '
u'UnoUrlResolver') u'UnoUrlResolver')
resolver = context.ServiceManager.createInstanceWithContext( resolver = context.ServiceManager.createInstanceWithContext(
u'com.sun.star.bridge.UnoUrlResolver', context) u'com.sun.star.bridge.UnoUrlResolver', context)
while ctx is None and loop < 3: while ctx is None and loop < 3:
try: try:
log.debug(u'get UNO Desktop Openoffice - resolve') log.debug(u'get UNO Desktop Openoffice - resolve')
ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;' ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;'
u'urp;StarOffice.ComponentContext') u'urp;StarOffice.ComponentContext')
except: except:
log.exception(u'Unable to find running instance ') log.exception(u'Unable to find running instance ')
self.start_process() self.start_process()
loop += 1 loop += 1
try: try:
self.manager = ctx.ServiceManager self.manager = ctx.ServiceManager
log.debug(u'get UNO Desktop Openoffice - createInstanceWithContext' log.debug(u'get UNO Desktop Openoffice - createInstanceWithContext'
u' - Desktop') u' - Desktop')
desktop = self.manager.createInstanceWithContext( desktop = self.manager.createInstanceWithContext(
"com.sun.star.frame.Desktop", ctx ) "com.sun.star.frame.Desktop", ctx )
return desktop return desktop
except: except:
log.exception(u'Failed to get UNO desktop') log.exception(u'Failed to get UNO desktop')
return None return None
def get_com_desktop(self): def get_com_desktop(self):
""" """
On Windows platforms, use COM. Return the desktop object which On Windows platforms, use COM. Return the desktop object which
will be used to manage Impress will be used to manage Impress
""" """
log.debug(u'get COM Desktop OpenOffice') log.debug(u'get COM Desktop OpenOffice')
if not self.manager: if not self.manager:
return None return None
return self.manager.createInstance(u'com.sun.star.frame.Desktop') return self.manager.createInstance(u'com.sun.star.frame.Desktop')
def get_com_servicemanager(self): def get_com_servicemanager(self):
""" """
Return the OOo service manager for windows Return the OOo service manager for windows
""" """
log.debug(u'get_com_servicemanager openoffice') log.debug(u'get_com_servicemanager openoffice')
try: try:
return Dispatch(u'com.sun.star.ServiceManager') return Dispatch(u'com.sun.star.ServiceManager')
except pywintypes.com_error: except pywintypes.com_error:
log.exception(u'Failed to get COM service manager') log.exception(u'Failed to get COM service manager')
return None return None
def kill(self): def kill(self):
""" """
Called at system exit to clean up any running presentations Called at system exit to clean up any running presentations
""" """
log.debug(u'Kill OpenOffice') log.debug(u'Kill OpenOffice')
while self.docs: while self.docs:
self.docs[0].close_presentation() self.docs[0].close_presentation()
if os.name != u'nt': if os.name != u'nt':
desktop = self.get_uno_desktop() desktop = self.get_uno_desktop()
else: else:
desktop = self.get_com_desktop() desktop = self.get_com_desktop()
#Sometimes we get a failure and desktop is None #Sometimes we get a failure and desktop is None
if not desktop: if not desktop:
log.exception(u'Failed to terminate OpenOffice') log.exception(u'Failed to terminate OpenOffice')
return return
docs = desktop.getComponents() docs = desktop.getComponents()
if docs.hasElements(): if docs.hasElements():
log.debug(u'OpenOffice not terminated') log.debug(u'OpenOffice not terminated')
else: else:
try: try:
desktop.terminate() desktop.terminate()
log.debug(u'OpenOffice killed') log.debug(u'OpenOffice killed')
except: except:
log.exception(u'Failed to terminate OpenOffice') log.exception(u'Failed to terminate OpenOffice')
def add_doc(self, name): def add_doc(self, name):
""" """
Called when a new Impress document is opened Called when a new Impress document is opened
""" """
log.debug(u'Add Doc OpenOffice') log.debug(u'Add Doc OpenOffice')
doc = ImpressDocument(self, name) doc = ImpressDocument(self, name)
self.docs.append(doc) self.docs.append(doc)
return doc return doc
class ImpressDocument(PresentationDocument): class ImpressDocument(PresentationDocument):
""" """
Class which holds information and controls a single presentation Class which holds information and controls a single presentation
""" """
def __init__(self, controller, presentation): def __init__(self, controller, presentation):
""" """
Constructor, store information about the file and initialise Constructor, store information about the file and initialise
""" """
log.debug(u'Init Presentation OpenOffice') log.debug(u'Init Presentation OpenOffice')
PresentationDocument.__init__(self, controller, presentation) PresentationDocument.__init__(self, controller, presentation)
self.document = None self.document = None
self.presentation = None self.presentation = None
self.control = None self.control = None
def load_presentation(self): def load_presentation(self):
""" """
Called when a presentation is added to the SlideController. Called when a presentation is added to the SlideController.
It builds the environment, starts communcations with the background It builds the environment, starts communcations with the background
OpenOffice task started earlier. If OpenOffice is not present is is OpenOffice task started earlier. If OpenOffice is not present is is
started. Once the environment is available the presentation is loaded started. Once the environment is available the presentation is loaded
and started. and started.
``presentation`` ``presentation``
The file name of the presentatios to the run. The file name of the presentatios to the run.
""" """
log.debug(u'Load Presentation OpenOffice') log.debug(u'Load Presentation OpenOffice')
#print "s.dsk1 ", self.desktop #print "s.dsk1 ", self.desktop
if os.name == u'nt': if os.name == u'nt':
desktop = self.controller.get_com_desktop() desktop = self.controller.get_com_desktop()
if desktop is None: if desktop is None:
self.controller.start_process() self.controller.start_process()
desktop = self.controller.get_com_desktop() desktop = self.controller.get_com_desktop()
url = u'file:///' + self.filepath.replace(u'\\', u'/').replace( url = u'file:///' + self.filepath.replace(u'\\', u'/').replace(
u':', u'|').replace(u' ', u'%20') u':', u'|').replace(u' ', u'%20')
else: else:
desktop = self.controller.get_uno_desktop() desktop = self.controller.get_uno_desktop()
url = uno.systemPathToFileUrl(self.filepath) url = uno.systemPathToFileUrl(self.filepath)
if desktop is None: if desktop is None:
return False return False
self.desktop = desktop self.desktop = desktop
properties = [] properties = []
properties.append(self.create_property(u'Minimized', True)) properties.append(self.create_property(u'Minimized', True))
properties = tuple(properties) properties = tuple(properties)
try: try:
self.document = desktop.loadComponentFromURL(url, u'_blank', self.document = desktop.loadComponentFromURL(url, u'_blank',
0, properties) 0, properties)
except: except:
log.exception(u'Failed to load presentation') log.exception(u'Failed to load presentation')
return False return False
self.presentation = self.document.getPresentation() self.presentation = self.document.getPresentation()
self.presentation.Display = \ self.presentation.Display = \
self.controller.plugin.renderManager.screens.current_display + 1 self.controller.plugin.renderManager.screens.current_display + 1
self.control = None self.control = None
self.create_thumbnails() self.create_thumbnails()
return True return True
def create_thumbnails(self): def create_thumbnails(self):
""" """
Create thumbnail images for presentation Create thumbnail images for presentation
""" """
log.debug(u'create thumbnails OpenOffice') log.debug(u'create thumbnails OpenOffice')
if self.check_thumbnails(): if self.check_thumbnails():
return return
if os.name == u'nt': if os.name == u'nt':
thumbdirurl = u'file:///' + self.get_temp_folder().replace( thumbdirurl = u'file:///' + self.get_temp_folder().replace(
u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20') u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
else: else:
thumbdirurl = uno.systemPathToFileUrl(self.get_temp_folder()) thumbdirurl = uno.systemPathToFileUrl(self.get_temp_folder())
props = [] props = []
props.append(self.create_property(u'FilterName', u'impress_png_Export')) props.append(self.create_property(u'FilterName', u'impress_png_Export'))
props = tuple(props) props = tuple(props)
doc = self.document doc = self.document
pages = doc.getDrawPages() pages = doc.getDrawPages()
if not os.path.isdir(self.get_temp_folder()): if not os.path.isdir(self.get_temp_folder()):
os.makedirs(self.get_temp_folder()) os.makedirs(self.get_temp_folder())
for idx in range(pages.getCount()): for idx in range(pages.getCount()):
page = pages.getByIndex(idx) page = pages.getByIndex(idx)
doc.getCurrentController().setCurrentPage(page) doc.getCurrentController().setCurrentPage(page)
urlpath = u'%s/%s.png' % (thumbdirurl, unicode(idx + 1)) urlpath = u'%s/%s.png' % (thumbdirurl, unicode(idx + 1))
path = os.path.join(self.get_temp_folder(), path = os.path.join(self.get_temp_folder(),
unicode(idx + 1) + u'.png') unicode(idx + 1) + u'.png')
try: try:
doc.storeToURL(urlpath, props) doc.storeToURL(urlpath, props)
self.convert_thumbnail(path, idx + 1) self.convert_thumbnail(path, idx + 1)
if os.path.exists(path): if os.path.exists(path):
os.remove(path) os.remove(path)
except: except:
log.exception(u'%s - Unable to store openoffice preview' % path) log.exception(u'%s - Unable to store openoffice preview' % path)
def create_property(self, name, value): def create_property(self, name, value):
""" """
Create an OOo style property object which are passed into some Create an OOo style property object which are passed into some
Uno methods Uno methods
""" """
log.debug(u'create property OpenOffice') log.debug(u'create property OpenOffice')
if os.name == u'nt': if os.name == u'nt':
prop = self.controller.manager.\ prop = self.controller.manager.\
Bridge_GetStruct(u'com.sun.star.beans.PropertyValue') Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
else: else:
prop = PropertyValue() prop = PropertyValue()
prop.Name = name prop.Name = name
prop.Value = value prop.Value = value
return prop return prop
def close_presentation(self): def close_presentation(self):
""" """
Close presentation and clean up objects Close presentation and clean up objects
Triggered by new object being added to SlideController or OpenLP Triggered by new object being added to SlideController or OpenLP
being shutdown being shutdown
""" """
log.debug(u'close Presentation OpenOffice') log.debug(u'close Presentation OpenOffice')
if self.document: if self.document:
if self.presentation: if self.presentation:
try: try:
self.presentation.end() self.presentation.end()
self.presentation = None self.presentation = None
self.document.dispose() self.document.dispose()
except: except:
#We tried! #We tried!
pass pass
self.document = None self.document = None
self.controller.remove_doc(self) self.controller.remove_doc(self)
def is_loaded(self): def is_loaded(self):
""" """
Returns true if a presentation is loaded Returns true if a presentation is loaded
""" """
log.debug(u'is loaded OpenOffice') log.debug(u'is loaded OpenOffice')
#print "is_loaded " #print "is_loaded "
if self.presentation is None or self.document is None: if self.presentation is None or self.document is None:
#print "no present or document" #print "no present or document"
return False return False
try: try:
if self.document.getPresentation() is None: if self.document.getPresentation() is None:
#print "no getPresentation" #print "no getPresentation"
return False return False
except: except:
return False return False
return True return True
def is_active(self): def is_active(self):
""" """
Returns true if a presentation is active and running Returns true if a presentation is active and running
""" """
log.debug(u'is active OpenOffice') log.debug(u'is active OpenOffice')
#print "is_active " #print "is_active "
if not self.is_loaded(): if not self.is_loaded():
#print "False " #print "False "
return False return False
#print "self.con ", self.control #print "self.con ", self.control
if self.control is None: if self.control is None:
return False return False
return True return True
def unblank_screen(self): def unblank_screen(self):
""" """
Unblanks the screen Unblanks the screen
""" """
log.debug(u'unblank screen OpenOffice') log.debug(u'unblank screen OpenOffice')
return self.control.resume() return self.control.resume()
def blank_screen(self): def blank_screen(self):
""" """
Blanks the screen Blanks the screen
""" """
log.debug(u'blank screen OpenOffice') log.debug(u'blank screen OpenOffice')
self.control.blankScreen(0) self.control.blankScreen(0)
def is_blank(self): def is_blank(self):
""" """
Returns true if screen is blank Returns true if screen is blank
""" """
log.debug(u'is blank OpenOffice') log.debug(u'is blank OpenOffice')
if self.control: if self.control:
return self.control.isPaused() return self.control.isPaused()
else: else:
return False return False
def stop_presentation(self): def stop_presentation(self):
""" """
Stop the presentation, remove from screen Stop the presentation, remove from screen
""" """
log.debug(u'stop presentation OpenOffice') log.debug(u'stop presentation OpenOffice')
# deactivate should hide the screen according to docs, but doesn't # deactivate should hide the screen according to docs, but doesn't
#self.control.deactivate() #self.control.deactivate()
self.presentation.end() self.presentation.end()
self.control = None self.control = None
def start_presentation(self): def start_presentation(self):
""" """
Start the presentation from the beginning Start the presentation from the beginning
""" """
log.debug(u'start presentation OpenOffice') log.debug(u'start presentation OpenOffice')
if self.control is None or not self.control.isRunning(): if self.control is None or not self.control.isRunning():
self.presentation.start() self.presentation.start()
# start() returns before the getCurrentComponent is ready. # start() returns before the getCurrentComponent is ready.
# Try for 5 seconds # Try for 5 seconds
i = 1 i = 1
while self.desktop.getCurrentComponent() is None and i < 50: while self.desktop.getCurrentComponent() is None and i < 50:
time.sleep(0.1) time.sleep(0.1)
i = i + 1 i = i + 1
self.control = \ self.control = \
self.desktop.getCurrentComponent().Presentation.getController() self.desktop.getCurrentComponent().Presentation.getController()
else: else:
self.control.activate() self.control.activate()
self.goto_slide(1) self.goto_slide(1)
def get_slide_number(self): def get_slide_number(self):
""" """
Return the current slide number on the screen, from 1 Return the current slide number on the screen, from 1
""" """
return self.control.getCurrentSlideIndex() + 1 return self.control.getCurrentSlideIndex() + 1
def get_slide_count(self): def get_slide_count(self):
""" """
Return the total number of slides Return the total number of slides
""" """
return self.document.getDrawPages().getCount() return self.document.getDrawPages().getCount()
def goto_slide(self, slideno): def goto_slide(self, slideno):
""" """
Go to a specific slide (from 1) Go to a specific slide (from 1)
""" """
self.control.gotoSlideIndex(slideno-1) self.control.gotoSlideIndex(slideno-1)
def next_step(self): def next_step(self):
""" """
Triggers the next effect of slide on the running presentation Triggers the next effect of slide on the running presentation
""" """
self.control.gotoNextEffect() self.control.gotoNextEffect()
def previous_step(self): def previous_step(self):
""" """
Triggers the previous slide on the running presentation Triggers the previous slide on the running presentation
""" """
self.control.gotoPreviousSlide() self.control.gotoPreviousSlide()
def get_slide_text(self, slide_no): def get_slide_text(self, slide_no):
""" """
Returns the text on the slide Returns the text on the slide
``slide_no`` ``slide_no``
The slide the text is required for, starting at 1 The slide the text is required for, starting at 1
""" """
doc = self.document doc = self.document
pages = doc.getDrawPages() pages = doc.getDrawPages()
text = '' text = ''
page = pages.getByIndex(slide_no - 1) page = pages.getByIndex(slide_no - 1)
for idx in range(page.getCount()): for idx in range(page.getCount()):
shape = page.getByIndex(idx) shape = page.getByIndex(idx)
if shape.supportsService("com.sun.star.drawing.Text"): if shape.supportsService("com.sun.star.drawing.Text"):
text += shape.getString() + '\n' text += shape.getString() + '\n'
return text return text
def get_slide_notes(self, slide_no): def get_slide_notes(self, slide_no):
""" """
Returns the text on the slide Returns the text on the slide
``slide_no`` ``slide_no``
The slide the notes are required for, starting at 1 The slide the notes are required for, starting at 1
""" """
doc = self.document doc = self.document
pages = doc.getDrawPages() pages = doc.getDrawPages()
text = '' text = ''
page = pages.getByIndex(slide_no - 1) page = pages.getByIndex(slide_no - 1)
notes = page.getNotesPage() notes = page.getNotesPage()
for idx in range(notes.getCount()): for idx in range(notes.getCount()):
shape = notes.getByIndex(idx) shape = notes.getByIndex(idx)
if shape.supportsService("com.sun.star.drawing.Text"): if shape.supportsService("com.sun.star.drawing.Text"):
text += shape.getString() + '\n' text += shape.getString() + '\n'
return text return text

View File

@ -138,3 +138,4 @@ class PresentationPlugin(Plugin):
'programs. The choice of available presentation programs is ' 'programs. The choice of available presentation programs is '
'available to the user in a drop down box.') 'available to the user in a drop down box.')
return about_text return about_text