Hi,
I work on an extension based on the example "DocumentLoader" from the
SDK and I need few informations to complete it.
Here are its main features :
- load a presentation document (odp ppt pps),
- start the slideshow with given position, width and height on a multi
monitors system,
- close the presentation at its end.
This extension will be called by another program with no user interaction.
Here are my problems :
1 - Loading
I can "hiddenly" load the document to avoid the display of the edition
window, but I don't know how to "un-hide" the slideshow just before
start it... As a result, I don't see anything : What a great
extension, isn't it ? ;)
2 - Starting
I can start the slideshow, but I don't know how to set its position
and size on the screen[s]. I'm just able to set the position and size
of the edition window of the presentation.
3 - Closing
I can close the presentation, but I don't know how to detect the end
of the slideshow to do that.
I tried to find answers in the IDL Reference and in the Developer's
Guide without success. Am I missing something there ?
I also read the source of OOo core (OOo_2.3.1_src_core.tar.bz2) under
"/sd/source/ui/slideshow" and I find useful functions and procedures
such as :
"ShowWindow* Slideshow::getShowWindow()"
"void Slideshow::setWindow( sd::Window* )"
"void Slideshow::resize( const Size &rSize )"
Is it possible to have access to them through UNO ?
Some help would be very appreciated !
ps sorry for my english
/*************************************************************************
*
* $RCSfile: SlideShowLoader.cxx,v $
*
* $Revision: 1.12 $
*
* last change: $Author: kz $ $Date: 2006/11/06 15:04:14 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
*
* Copyright (c) 2003 by Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Sun Microsystems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*************************************************************************/
/*****************************************************************************
*****************************************************************************
*
* Simple client application using the UnoUrlResolver service.
*
*****************************************************************************
*****************************************************************************/
#include <stdio.h>
#include <wchar.h>
#include <cppuhelper/bootstrap.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/presentation/XPresentation.hpp>
#include <com/sun/star/presentation/XPresentationSupplier.hpp>
#include <string.h>
using namespace rtl;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace com::sun::star::bridge;
using namespace com::sun::star::frame;
using namespace com::sun::star::registry;
using namespace com::sun::star::presentation;
using namespace com::sun::star::awt;
//============================================================================
int SAL_CALL main( int argc, char **argv )
{
OUString
sConnectionString(RTL_CONSTASCII_USTRINGPARAM("uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"));
if (argc < 2)
{
printf("using: SlideShowLoader <file_url> [<uno_connection_url>]\n\n"
"example: SlideShowLoader \"file:///e:/temp/test.odp\"
\"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager\"\n");
exit(1);
}
if (argc == 3)
{
sConnectionString = OUString::createFromAscii(argv[2]);
}
// creates a simple registry service instance
Reference< XSimpleRegistry > xSimpleRegistry(
::cppu::createSimpleRegistry() );
// connects the registry to a persistent data source represented by an url
xSimpleRegistry->open(
OUString( RTL_CONSTASCII_USTRINGPARAM( "SlideShowLoader.rdb" ) ),
sal_True,
sal_False );
/* bootstraps an initial component context with
service manager upon a given registry
this includes insertion of initial services :
- (registry) service manager, shared lib loader,
- simple registry, nested registry,
- implementation registration
- registry typedescription provider, typedescription manager (also
installs it into cppu core)
*/
Reference< XComponentContext > xComponentContext(
::cppu::bootstrap_InitialComponentContext( xSimpleRegistry ) );
/* gets the service manager instance to be used (or null)
this method has been added for convenience,
because the service manager is a often used object
*/
Reference< XMultiComponentFactory > xMultiComponentFactoryClient(
xComponentContext->getServiceManager() );
/* creates an instance of a component which
supports the services specified by the factory.
*/
Reference< XInterface > xInterface =
xMultiComponentFactoryClient->createInstanceWithContext(
OUString::createFromAscii( "com.sun.star.bridge.UnoUrlResolver" ),
xComponentContext );
Reference< XUnoUrlResolver > resolver( xInterface,
UNO_QUERY );
// resolves the component context from the office,
// on the uno URL given by argv[1].
try
{
xInterface = Reference< XInterface >(
resolver->resolve( sConnectionString ),
UNO_QUERY );
}
catch ( Exception& e )
{
printf("Error: cannot establish a connection using '%s':\n %s\n",
OUStringToOString(sConnectionString,
RTL_TEXTENCODING_ASCII_US).getStr(),
OUStringToOString(e.Message,
RTL_TEXTENCODING_ASCII_US).getStr());
exit(1);
}
// gets the server component context as property of the office component
factory
Reference< XPropertySet > xPropSet( xInterface,
UNO_QUERY );
xPropSet->getPropertyValue( OUString::createFromAscii("DefaultContext") ) >>=
xComponentContext;
// gets the service manager from the office
Reference< XMultiComponentFactory > xMultiComponentFactoryServer(
xComponentContext->getServiceManager() );
/* creates an instance of a component which
supports the services specified by the factory.
important : using the office component context.
*/
Reference < XComponentLoader > xComponentLoader(
xMultiComponentFactoryServer->createInstanceWithContext(
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop" ) ),
xComponentContext ),
UNO_QUERY );
/* loads a component specified by an url into
the specified new or existing frame
*/
OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;
osl_getProcessWorkingDir(&sWorkingDir.pData);
osl::FileBase::getFileURLFromSystemPath( OUString::createFromAscii(argv[1]),
sDocPathUrl);
osl::FileBase::getAbsoluteFileURL( sWorkingDir,
sDocPathUrl,
sAbsoluteDocUrl);
//properties value for the component
// sal_Bool boStartPres = true;
// sal_Bool boHidden = true;
Sequence < PropertyValue > ComponentPropertyValue(1);
// ComponentPropertyValue[0].Name = OUString::createFromAscii(
"StartPresentation" );
// ComponentPropertyValue[0].Value = makeAny(boStartPres);
// ComponentPropertyValue[1].Name = OUString::createFromAscii( "Hidden" );
// ComponentPropertyValue[1].Value = makeAny(boHidden);
Reference< XComponent > xComponent =
xComponentLoader->loadComponentFromURL(
sAbsoluteDocUrl,
OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ),
0,
ComponentPropertyValue );
/* access to xwindow from xcomponent
*/
/* doesn't work : access to edition window only
Reference< XModel > xModel ( xComponent, UNO_QUERY );
Reference< XController > xController = xModel->getCurrentController();
Reference< XFrame > xFrame = xController->getFrame();
Reference< XWindow > xWindow = xFrame->getContainerWindow();
xWindow->setPosSize(320,
256,
640,
512,
PosSize::POSSIZE);
*/
/* start a presentation
*/
Reference< XPresentationSupplier > xPresentationSupplier(xComponent,
UNO_QUERY);
Reference< XPresentation > xPresentation =
xPresentationSupplier->getPresentation();
/* access to xwindow from xpresentation
*/
/* doesn't work : bug at runtime as expected
Reference< XWindow > xWindow ( xPresentation, UNO_QUERY );
xWindow->setPosSize(320,
256,
640,
512,
PosSize::POSSIZE);
*/
/* doesn't work : bug at runtime as expected
Reference< XModel > xModel ( xPresentation, UNO_QUERY );
Reference< XController > xController = xModel->getCurrentController();
Reference< XFrame > xFrame = xController->getFrame();
Reference< XWindow > xWindow = xFrame->getContainerWindow();
xWindow->setPosSize(320,
256,
640,
512,
PosSize::POSSIZE);
*/
//!\ important : try to revert the hidden property value here
xPresentation->start();
/* detect the end of the presentation
*/
//!\ important : try to detect the end of the presentation here
/* close the document
*/
//!\ important : remove next comment // when last step complete
//xComponent->dispose();
// dispose the local service manager
Reference< XComponent >::query( xMultiComponentFactoryClient )->dispose();
return 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]