diff options
author | Malte Timmermann <mt@openoffice.org> | 2001-01-24 13:34:09 +0000 |
---|---|---|
committer | Malte Timmermann <mt@openoffice.org> | 2001-01-24 13:34:09 +0000 |
commit | f5ed39242515779abd8c437e7cea03dd5e3470a8 (patch) | |
tree | af1cb6e0bcec24917ce55923cbe48a0d7be1b0c5 /toolkit/workben | |
parent | ece88d80ccdbd3bf523b4c705410d826f35e1d2b (diff) |
unodialog
Diffstat (limited to 'toolkit/workben')
-rw-r--r-- | toolkit/workben/makefile.mk | 91 | ||||
-rw-r--r-- | toolkit/workben/unodialog.cxx | 255 |
2 files changed, 272 insertions, 74 deletions
diff --git a/toolkit/workben/makefile.mk b/toolkit/workben/makefile.mk index ac0844979640..0d6106d29be0 100644 --- a/toolkit/workben/makefile.mk +++ b/toolkit/workben/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.1.1.1 $ +# $Revision: 1.2 $ # -# last change: $Author: hr $ $Date: 2000-09-18 17:02:10 $ +# last change: $Author: mt $ $Date: 2001-01-24 14:33:50 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -63,8 +63,10 @@ PRJ=.. PRJNAME=toolkit -TARGET=controls +TARGET=unodialog LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE + # --- Settings ----------------------------------------------------- @@ -74,32 +76,22 @@ LIBTARGET=NO # --- Files -------------------------------------------------------- -CXXFILES= controls.cxx \ - smartvcl.cxx +CXXFILES= unodialog.cxx -OBJFILES= $(OBJ)$/controls.obj \ - $(OBJ)$/smartvcl.obj +OBJFILES= $(OBJ)$/unodialog.obj -APP2TARGET= controls -APP2OBJS= $(OBJ)$/controls.obj +APP2TARGET= unodialog +APP2OBJS= $(OBJ)$/unodialog.obj APP2STDLIBS=$(TOOLSLIB) \ $(SOTLIB) \ $(SVTOOLLIB) \ - $(USRLIB) \ - $(ONELIB) \ - $(SVLIB) -APP2DEF= $(MISC)$/controls.def - -APP3TARGET= smartvcl -APP3OBJS= $(OBJ)$/smartvcl.obj -APP3STDLIBS=$(TOOLSLIB) \ - $(SOTLIB) \ - $(SVTOOLLIB) \ - $(USRLIB) \ - $(ONELIB) \ - $(SVLIB) -APP3DEF= $(MISC)$/smartvcl.def + $(COMPHELPERLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VCLLIB) \ + $(SALLIB) +APP2DEF= $(MISC)$/unodialog.def # --- Targets ------------------------------------------------------ @@ -112,8 +104,8 @@ APP3DEF= $(MISC)$/smartvcl.def .IF "$(GUI)" == "WIN" -$(MISC)$/controls.def: makefile - echo NAME controls >$@ +$(MISC)$/unodialog.def: makefile.mk + echo NAME unodialog >$@ echo DESCRIPTION 'StarView - Testprogramm' >>$@ echo EXETYPE WINDOWS >>$@ echo STUB 'winSTUB.EXE' >>$@ @@ -123,53 +115,4 @@ $(MISC)$/controls.def: makefile echo HEAPSIZE 8192 >>$@ echo STACKSIZE 32768 >>$@ -$(MISC)$/smartvcl.def: makefile - echo NAME smartvcl >$@ - echo DESCRIPTION 'StarView - Testprogramm' >>$@ - echo EXETYPE WINDOWS >>$@ - echo STUB 'winSTUB.EXE' >>$@ - echo PROTMODE >>$@ - echo CODE PRELOAD MOVEABLE DISCARDABLE >>$@ - echo DATA PRELOAD MOVEABLE MULTIPLE >>$@ - echo HEAPSIZE 8192 >>$@ - echo STACKSIZE 32768 >>$@ - -.ENDIF - -# ------------------------------------------------------------------ -# OS2 -# ------------------------------------------------------------------ - -.IF "$(GUI)" == "OS2" - -$(MISC)$/controls.def: makefile - echo NAME controls WINDOWAPI >$@ - echo DESCRIPTION 'StarView - Testprogramm' >>$@ -.IF "$(COM)" != "BLC" - echo STUB 'os2STUB.EXE' >>$@ -.ENDIF -.IF "$(COM)"!="MTW" - echo EXETYPE OS2 >>$@ -.ENDIF - echo PROTMODE >>$@ - echo CODE LOADONCALL >>$@ - echo DATA PRELOAD MULTIPLE >>$@ - echo HEAPSIZE 16384 >>$@ - echo STACKSIZE 32768 >>$@ - -$(MISC)$/smartvcl.def: makefile - echo NAME smartvcl WINDOWAPI >$@ - echo DESCRIPTION 'StarView - Testprogramm' >>$@ -.IF "$(COM)" != "BLC" - echo STUB 'os2STUB.EXE' >>$@ -.ENDIF -.IF "$(COM)"!="MTW" - echo EXETYPE OS2 >>$@ -.ENDIF - echo PROTMODE >>$@ - echo CODE LOADONCALL >>$@ - echo DATA PRELOAD MULTIPLE >>$@ - echo HEAPSIZE 16384 >>$@ - echo STACKSIZE 32768 >>$@ - .ENDIF diff --git a/toolkit/workben/unodialog.cxx b/toolkit/workben/unodialog.cxx new file mode 100644 index 000000000000..26a0a97eb17c --- /dev/null +++ b/toolkit/workben/unodialog.cxx @@ -0,0 +1,255 @@ +/************************************************************************* + * + * $RCSfile: unodialog.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mt $ $Date: 2001-01-24 14:34:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#define NOOLDSV + + +#ifndef _COM_SUN_STAR_AWT_XTOOLKIT_HPP_ +#include <com/sun/star/awt/XToolkit.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROLMODEL_HPP_ +#include <com/sun/star/awt/XControlModel.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_ +#include <com/sun/star/awt/XControlContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROL_HPP_ +#include <com/sun/star/awt/XControl.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XDIALOG_HPP_ +#include <com/sun/star/awt/XDialog.hpp> +#endif + + +#include <tools/debug.hxx> +#include <vcl/svapp.hxx> +#include <svtools/unoiface.hxx> // InitExtToolkit + +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif + +#include <cppuhelper/servicefactory.hxx> +#include <cppuhelper/servicefactory.hxx> +#include <comphelper/regpathhelper.hxx> + +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/registry/XSimpleRegistry.hpp> + + +using namespace ::com::sun::star; +using namespace ::com::sun::star::connection; +using namespace ::vos; +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::registry; +using namespace ::com::sun::star::lang; + + + +::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > createApplicationServiceManager() +{ + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xReturn = ::cppu::createServiceFactory(); + + try + { + + if ( xReturn.is() ) + { + Reference< XInitialization > xInit ( xReturn, UNO_QUERY ) ; + if ( xInit.is() ) + { + ::rtl::OUString localRegistry = ::comphelper::getPathToUserRegistry(); + ::rtl::OUString systemRegistry = ::comphelper::getPathToSystemRegistry(); + + Reference< XSimpleRegistry > xLocalRegistry ( xReturn->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.registry.SimpleRegistry") ) ), UNO_QUERY ); + Reference< XSimpleRegistry > xSystemRegistry ( xReturn->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.SimpleRegistry") ) ), UNO_QUERY ); + if ( xLocalRegistry.is() && (localRegistry.getLength() > 0) ) + { + try + { + xLocalRegistry->open( localRegistry, sal_False, sal_True); + } + catch ( InvalidRegistryException& ) + { + } + + if ( !xLocalRegistry->isValid() ) + xLocalRegistry->open(localRegistry, sal_True, sal_True); + } + + if ( xSystemRegistry.is() && (systemRegistry.getLength() > 0) ) + xSystemRegistry->open( systemRegistry, sal_True, sal_False); + + if ( (xLocalRegistry.is() && xLocalRegistry->isValid()) && + (xSystemRegistry.is() && xSystemRegistry->isValid()) ) + { + Sequence< Any > seqAnys(2); + seqAnys[0] <<= xLocalRegistry ; + seqAnys[1] <<= xSystemRegistry ; + + Reference < XSimpleRegistry > xReg( + xReturn->createInstanceWithArguments( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.NestedRegistry")), seqAnys ), UNO_QUERY ); + + seqAnys = Sequence< Any >( 1 ); + seqAnys[0] <<= xReg; + if ( xReg.is() ) + xInit->initialize( seqAnys ); + } + } + else + { + xReturn = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(); + } + } + } + + catch( ::com::sun::star::uno::Exception& ) + { + } + + return xReturn ; +} + + +// ----------------------------------------------------------------------- + +class MyApp : public Application +{ +public: + void Main(); +}; + +MyApp aMyApp; + +// ----------------------------------------------------------------------- + +void MyApp::Main() +{ + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF = createApplicationServiceManager(); + ::comphelper::setProcessServiceFactory( xMSF ); + InitExtVclToolkit(); + Application::RegisterUnoServices(); + + uno::Reference< awt::XToolkit> xToolkit( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.ExtToolkit" ) ) ), uno::UNO_QUERY ); + + // Create a DialogModel + uno::Reference< container::XNameContainer > xC( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), uno::UNO_QUERY ); + uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY ); + + // Create a ButtonModel + uno::Reference< awt::XControlModel > xCtrl1( xModFact->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xPSet( xCtrl1, uno::UNO_QUERY ); + uno::Any aValue; + aValue <<= (sal_Int32) 10; + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ), aValue ); + aValue <<= (sal_Int32) 10; + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ), aValue ); + aValue <<= (sal_Int32) 100; + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Width" ) ), aValue ); + aValue <<= (sal_Int32) 20; + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue ); + aValue <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Test!" ) ); + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Label" ) ), aValue ); + uno::Any aAny; + aAny <<= xCtrl1; + xC->insertByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control1" ) ), aAny ); + + // Create a EditModel + uno::Reference< awt::XControlModel > xCtrl2( xModFact->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ), uno::UNO_QUERY ); + xPSet = uno::Reference< beans::XPropertySet >( xCtrl2, uno::UNO_QUERY ); + aValue <<= (sal_Int32) 10; + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ), aValue ); + aValue <<= (sal_Int32) 50; + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ), aValue ); + aValue <<= (sal_Int32) 100; + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Width" ) ), aValue ); + aValue <<= (sal_Int32) 20; + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue ); + aValue <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Text..." ) ); + xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Text" ) ), aValue ); + aAny <<= xCtrl2; + xC->insertByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control2" ) ), aAny ); + + + uno::Reference< beans::XPropertySet > xDlgPSet( xC, uno::UNO_QUERY ); + aValue <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Test-Dialog" ) ); + xDlgPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aValue ); + + // Create a Dialog + uno::Reference< awt::XControl > xDlg( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialog" ) ) ), uno::UNO_QUERY ); + uno::Reference< awt::XControlModel > xDlgMod( xC, uno::UNO_QUERY ); + xDlg->setModel( xDlgMod ); + xDlg->createPeer( xToolkit, NULL ); + + uno::Reference< awt::XDialog > xD( xDlg, uno::UNO_QUERY ); + xD->execute(); + +} |