Hi Christian,

I unsuccessfully try the service "com.sun.star.awt.DisplayAccess".
It seems that setPropertyValue always throws an exception :
http://lxr.go-oo.org/source/gsl/vcl/source/components/display.cxx#267

Or maybe am I doing the wrong way ?

//BEGIN

Reference< XInterface > xInterfaceDisplayAccess =
  xMultiComponentFactoryServer->createInstanceWithContext(
    OUString::createFromAscii( "com.sun.star.awt.DisplayAccess" ),
    xComponentContext );

Reference< XPropertySet > xMonProps (
  xInterfaceDisplayAccess,
  UNO_QUERY );

const OUString sPropName(
  RTL_CONSTASCII_USTRINGPARAM( "DefaultDisplay" ) );
//some monitor, 0 for primary one
sal_Int8 iDefaultDisplay = 1;
//fails here...
xMonProps->setPropertyValue(
  sPropName,
  makeAny( iDefaultDisplay ) );

//END

I also wonder where is the source file behind the dialog of slideshow settings .
I try to locate it : maybe it has answers to my questions ?

Regards,
Sharpminded

ps : Maybe this is not the right place to discuss that, please tell me
if I'm too disturbing.
/*************************************************************************
 *
 *  $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 <comphelper/processfactory.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/lang/XMultiServiceFactory.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
  Sequence < PropertyValue > ComponentPropertyValue(1); 
//  sal_Bool boStartPres = true;
//  ComponentPropertyValue[0].Name = OUString::createFromAscii( 
"StartPresentation" );
//  ComponentPropertyValue[0].Value = makeAny( boStartPres );
  sal_Bool boHidden = true;
  ComponentPropertyValue[0].Name = OUString::createFromAscii( "Hidden" );
  ComponentPropertyValue[0].Value = makeAny( boHidden );

  Reference< XComponent > xComponent =
    xComponentLoader->loadComponentFromURL(
      sAbsoluteDocUrl,
      OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ),
      0,
      ComponentPropertyValue );

  /* access to xwindow from xcomponent
  */
  //
  Reference< XModel > xModel ( xComponent, UNO_QUERY );
  Reference< XController > xController = xModel->getCurrentController();
  Reference< XFrame > xFrame = xController->getFrame();
  Reference< XWindow > xWindow = xFrame->getContainerWindow();
  xWindow->setPosSize(0,
                      0,
                      116,
                      0,
                      PosSize::POSSIZE);

/*  Reference< XMultiServiceFactory > xFactory(
    ::comphelper::getProcessServiceFactory(),
    UNO_QUERY_THROW );
  Reference< XPropertySet > xMonProps(
    xFactory->createInstance(
      OUString(
        RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess" ) ) ),
    UNO_QUERY );*/

  Reference< XInterface > xInterfaceDisplayAccess =
    xMultiComponentFactoryServer->createInstanceWithContext( 
      OUString::createFromAscii( "com.sun.star.awt.DisplayAccess" ),
      xComponentContext );

  Reference< XPropertySet > xMonProps( xInterfaceDisplayAccess,
                                       UNO_QUERY );

  const OUString sPropName( RTL_CONSTASCII_USTRINGPARAM( "DefaultDisplay" ) );
  sal_Int8 iDefaultDisplay = 1; //some monitor, 0 for primary one
//  xMonProps->setPropertyValue( sPropName, makeAny( iDefaultDisplay ) );
//  xMonProps->getPropertyValue( sPropName ) >>= iDefaultDisplay;

//    printf("'%d'\n",
//           iDefaultDisplay);

  /* start a presentation
  */
  Reference< XPresentationSupplier > xPresentationSupplier(xComponent, 
UNO_QUERY);
  Reference< XPresentation > xPresentation = 
xPresentationSupplier->getPresentation();
  xWindow->setVisible( boHidden );
  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]

Reply via email to