Changed the connect method to private.
This commit is contained in:
parent
0abca97ec2
commit
4c0d24c9d2
60
bin/mpresent
60
bin/mpresent
@ -177,41 +177,12 @@ class PresentationController:
|
|||||||
try:
|
try:
|
||||||
self.bootstrap_context.getServiceManager()
|
self.bootstrap_context.getServiceManager()
|
||||||
except (AttributeError, DisposedException):
|
except (AttributeError, DisposedException):
|
||||||
self.connect()
|
self.__connect()
|
||||||
self.open()
|
self.open()
|
||||||
presentation = self.doc.getPresentation()
|
presentation = self.doc.getPresentation()
|
||||||
if not presentation.isRunning():
|
if not presentation.isRunning():
|
||||||
presentation.start()
|
presentation.start()
|
||||||
|
|
||||||
def connect(self):
|
|
||||||
"""Connect to the running OpenOffice/LibreOffice process.
|
|
||||||
|
|
||||||
Run OpenOffice/LibreOffice in server listening mode if it is
|
|
||||||
not running yet.
|
|
||||||
"""
|
|
||||||
# Obtains the local context
|
|
||||||
local_context = uno.getComponentContext()
|
|
||||||
# Obtains the local service manager
|
|
||||||
local_service_manager = local_context.getServiceManager()
|
|
||||||
# Obtains the URL resolver
|
|
||||||
url_resolver = local_service_manager.createInstanceWithContext(
|
|
||||||
"com.sun.star.bridge.UnoUrlResolver", local_context)
|
|
||||||
# Obtains the context
|
|
||||||
url = ("uno:socket,host=localhost,port=%d;"
|
|
||||||
"urp;StarOffice.ComponentContext") % self.port
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
self.bootstrap_context = url_resolver.resolve(url)
|
|
||||||
except NoConnectException:
|
|
||||||
self.__start_oo()
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
# Obtains the service manager
|
|
||||||
self.service_manager = self.bootstrap_context.getServiceManager()
|
|
||||||
# Obtains the desktop service
|
|
||||||
self.desktop = self.service_manager.createInstanceWithContext(
|
|
||||||
"com.sun.star.frame.Desktop", self.bootstrap_context)
|
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
"""Open an office document."""
|
"""Open an office document."""
|
||||||
file_content_provider = self.service_manager.createInstance(
|
file_content_provider = self.service_manager.createInstance(
|
||||||
@ -250,6 +221,35 @@ class PresentationController:
|
|||||||
self.doc.getPresentation().getController().gotoPreviousSlide()
|
self.doc.getPresentation().getController().gotoPreviousSlide()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def __connect(self):
|
||||||
|
"""Connect to the running OpenOffice/LibreOffice process.
|
||||||
|
|
||||||
|
Run OpenOffice/LibreOffice in server listening mode if it is
|
||||||
|
not running yet.
|
||||||
|
"""
|
||||||
|
# Obtains the local context
|
||||||
|
local_context = uno.getComponentContext()
|
||||||
|
# Obtains the local service manager
|
||||||
|
local_service_manager = local_context.getServiceManager()
|
||||||
|
# Obtains the URL resolver
|
||||||
|
url_resolver = local_service_manager.createInstanceWithContext(
|
||||||
|
"com.sun.star.bridge.UnoUrlResolver", local_context)
|
||||||
|
# Obtains the context
|
||||||
|
url = ("uno:socket,host=localhost,port=%d;"
|
||||||
|
"urp;StarOffice.ComponentContext") % self.port
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
self.bootstrap_context = url_resolver.resolve(url)
|
||||||
|
except NoConnectException:
|
||||||
|
self.__start_oo()
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
# Obtains the service manager
|
||||||
|
self.service_manager = self.bootstrap_context.getServiceManager()
|
||||||
|
# Obtains the desktop service
|
||||||
|
self.desktop = self.service_manager.createInstanceWithContext(
|
||||||
|
"com.sun.star.frame.Desktop", self.bootstrap_context)
|
||||||
|
|
||||||
def __start_oo(self):
|
def __start_oo(self):
|
||||||
"""Start OpenOffice/LibreOffice in server listening mode."""
|
"""Start OpenOffice/LibreOffice in server listening mode."""
|
||||||
# For MS-Windows, which does not have fork()
|
# For MS-Windows, which does not have fork()
|
||||||
|
Loading…
Reference in New Issue
Block a user