update dev300-m58
[ooovba.git] / sdext / source / minimizer / aboutdialog.cxx
blob6d9142dbb8c8b6259d53b24e98b2db0b97094226
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: aboutdialog.cxx,v $
11 * $Revision: 1.8 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "aboutdialog.hxx"
36 #include "optimizationstats.hxx"
37 #include "fileopendialog.hxx"
38 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
40 // ---------------
41 // - ABOUTDIALOG -
42 // ---------------
44 using namespace ::rtl;
45 using namespace ::com::sun::star::ui;
46 using namespace ::com::sun::star::awt;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::util;
49 using namespace ::com::sun::star::lang;
50 using namespace ::com::sun::star::frame;
51 using namespace ::com::sun::star::beans;
52 using namespace ::com::sun::star::script;
53 using namespace ::com::sun::star::container;
55 #define ABOUT_DIALOG_WIDTH 200
56 #define ABOUT_DIALOG_HEIGHT 155
58 // -----------------------------------------------------------------------------
61 rtl::OUString InsertFixedText( AboutDialog& rAboutDialog, const rtl::OUString& rControlName, const OUString& rLabel,
62 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Int16 nTabIndex )
64 OUString pNames[] = {
65 TKGet( TK_Height ),
66 TKGet( TK_Label ),
67 TKGet( TK_MultiLine ),
68 TKGet( TK_PositionX ),
69 TKGet( TK_PositionY ),
70 TKGet( TK_Step ),
71 TKGet( TK_TabIndex ),
72 TKGet( TK_Width ) };
74 Any pValues[] = {
75 Any( nHeight ),
76 Any( rLabel ),
77 Any( bMultiLine ),
78 Any( nXPos ),
79 Any( nYPos ),
80 Any( (sal_Int16)0 ),
81 Any( nTabIndex ),
82 Any( nWidth ) };
84 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
86 Sequence< rtl::OUString > aNames( pNames, nCount );
87 Sequence< Any > aValues( pValues, nCount );
89 rAboutDialog.insertFixedText( rControlName, aNames, aValues );
90 return rControlName;
93 #if 0
94 rtl::OUString InsertSeparator( AboutDialog& rAboutDialog, const OUString& rControlName, sal_Int32 nOrientation,
95 sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight )
97 OUString pNames[] = {
98 TKGet( TK_Height ),
99 TKGet( TK_Orientation ),
100 TKGet( TK_PositionX ),
101 TKGet( TK_PositionY ),
102 TKGet( TK_Step ),
103 TKGet( TK_Width ) };
105 Any pValues[] = {
106 Any( nHeight ),
107 Any( nOrientation ),
108 Any( nPosX ),
109 Any( nPosY ),
110 Any( sal_Int16( 0 ) ),
111 Any( nWidth ) };
113 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
115 Sequence< rtl::OUString > aNames( pNames, nCount );
116 Sequence< Any > aValues( pValues, nCount );
118 rAboutDialog.insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" ) ),
119 rControlName, aNames, aValues );
120 return rControlName;
123 #endif
125 rtl::OUString InsertImage( AboutDialog& rAboutDialog, const OUString& rControlName, const OUString& rURL,
126 sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight )
128 OUString pNames[] = {
129 TKGet( TK_Border ),
130 TKGet( TK_Height ),
131 TKGet( TK_ImageURL ),
132 TKGet( TK_PositionX ),
133 TKGet( TK_PositionY ),
134 TKGet( TK_ScaleImage ),
135 TKGet( TK_Width ) };
137 Any pValues[] = {
138 Any( sal_Int16( 1 ) ),
139 Any( nHeight ),
140 Any( rURL ),
141 Any( nPosX ),
142 Any( nPosY ),
143 Any( sal_False ),
144 Any( nWidth ) };
145 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
147 Sequence< rtl::OUString > aNames( pNames, nCount );
148 Sequence< Any > aValues( pValues, nCount );
150 rAboutDialog.insertImage( rControlName, aNames, aValues );
151 return rControlName;
154 rtl::OUString InsertButton( AboutDialog& rAboutDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener,
155 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, PPPOptimizerTokenEnum nResID )
157 OUString pNames[] = {
158 TKGet( TK_Enabled ),
159 TKGet( TK_Height ),
160 TKGet( TK_Label ),
161 TKGet( TK_PositionX ),
162 TKGet( TK_PositionY ),
163 TKGet( TK_PushButtonType ),
164 TKGet( TK_Step ),
165 TKGet( TK_TabIndex ),
166 TKGet( TK_Width ) };
168 Any pValues[] = {
169 Any( sal_True ),
170 Any( nHeight ),
171 Any( rAboutDialog.getString( nResID ) ),
172 Any( nXPos ),
173 Any( nYPos ),
174 Any( static_cast< sal_Int16 >( PushButtonType_OK ) ),
175 Any( (sal_Int16)0 ),
176 Any( nTabIndex ),
177 Any( nWidth ) };
180 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
182 Sequence< rtl::OUString > aNames( pNames, nCount );
183 Sequence< Any > aValues( pValues, nCount );
185 rAboutDialog.insertButton( rControlName, xActionListener, aNames, aValues );
186 return rControlName;
189 void AboutDialog::InitDialog()
191 // setting the dialog properties
192 OUString pNames[] = {
193 rtl::OUString::createFromAscii( "BackgroundColor" ) ,
194 TKGet( TK_Closeable ),
195 TKGet( TK_Height ),
196 TKGet( TK_Moveable ),
197 TKGet( TK_PositionX ),
198 TKGet( TK_PositionY ),
199 TKGet( TK_Title ),
200 TKGet( TK_Width ) };
202 Any pValues[] = {
203 Any( sal_Int32( 0xffffff ) ),
204 Any( sal_True ),
205 Any( sal_Int32( ABOUT_DIALOG_HEIGHT ) ),
206 Any( sal_True ),
207 Any( sal_Int32( 113 ) ),
208 Any( sal_Int32( 42 ) ),
209 Any( getString( STR_ABOUT_VERSION2 ) ),
210 Any( sal_Int32( ABOUT_DIALOG_WIDTH ) ) };
212 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
214 Sequence< rtl::OUString > aNames( pNames, nCount );
215 Sequence< Any > aValues( pValues, nCount );
217 rtl::OUString sBitmapPath( getPath( TK_BitmapPath ) );
218 rtl::OUString sBitmap( rtl::OUString::createFromAscii( "/aboutlogo.png" ) );
219 rtl::OUString sURL( sBitmapPath += sBitmap );
221 mxDialogModelMultiPropertySet->setPropertyValues( aNames, aValues );
222 sal_Int32 nWidth = getMapsFromPixels( 387 );
223 if ( nWidth )
224 mxDialogModelPropertySet->setPropertyValue( TKGet( TK_Width ), Any( nWidth ) );
225 else
226 nWidth = ABOUT_DIALOG_WIDTH;
228 // int nHeight = (int) getMapsFromPixels( 95 );
230 InsertImage( *this, rtl::OUString( rtl::OUString::createFromAscii( "aboutimage" ) ), sURL, 0, 0, nWidth, 60 );
231 InsertFixedText( *this, rtl::OUString( rtl::OUString::createFromAscii( "fixedtext" ) ), getString( STR_ABOUT_PRN ), 9, 66, nWidth - 18, 50, sal_True, 0 );
232 // InsertSeparator( *this, rtl::OUString( rtl::OUString::createFromAscii( "separator" ) ), 0, 0, ABOUT_DIALOG_HEIGHT - 25, nWidth, 8 );
233 InsertButton( *this, rtl::OUString( rtl::OUString::createFromAscii( "button" ) ), mxActionListener, ( nWidth / 2 ) - 25, 120, 50, 14, 1, STR_OK );
236 // -----------------------------------------------------------------------------
238 AboutDialog::AboutDialog( const Reference< XComponentContext > &rxMSF, Reference< XFrame >& rxFrame ) :
239 UnoDialog( rxMSF, rxFrame ),
240 ConfigurationAccess( rxMSF, NULL ),
241 mxMSF( rxMSF ),
242 mxFrame( rxFrame ),
243 mxActionListener( new AboutActionListener( *this ) )
245 Reference< XFrame > xFrame( mxController->getFrame() );
246 Reference< XWindow > xContainerWindow( xFrame->getContainerWindow() );
247 Reference< XWindowPeer > xWindowPeer( xContainerWindow, UNO_QUERY_THROW );
248 createWindowPeer( xWindowPeer );
250 InitDialog();
253 // -----------------------------------------------------------------------------
255 AboutDialog::~AboutDialog()
259 // -----------------------------------------------------------------------------
261 sal_Bool AboutDialog::execute()
263 UnoDialog::execute();
264 return mbStatus;
267 // -----------------------------------------------------------------------------
269 void AboutActionListener::actionPerformed( const ActionEvent& rEvent )
270 throw ( com::sun::star::uno::RuntimeException )
272 if ( rEvent.ActionCommand == rtl::OUString( rtl::OUString::createFromAscii( "button" ) ) )
274 mrAboutDialog.endExecute( sal_True );
277 void AboutActionListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
278 throw ( com::sun::star::uno::RuntimeException )