1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: aboutdialog.cxx,v $
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>
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
)
67 TKGet( TK_MultiLine
),
68 TKGet( TK_PositionX
),
69 TKGet( TK_PositionY
),
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
);
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
)
99 TKGet( TK_Orientation
),
100 TKGet( TK_PositionX
),
101 TKGet( TK_PositionY
),
110 Any( sal_Int16( 0 ) ),
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
);
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
[] = {
131 TKGet( TK_ImageURL
),
132 TKGet( TK_PositionX
),
133 TKGet( TK_PositionY
),
134 TKGet( TK_ScaleImage
),
138 Any( sal_Int16( 1 ) ),
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
);
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
[] = {
161 TKGet( TK_PositionX
),
162 TKGet( TK_PositionY
),
163 TKGet( TK_PushButtonType
),
165 TKGet( TK_TabIndex
),
171 Any( rAboutDialog
.getString( nResID
) ),
174 Any( static_cast< sal_Int16
>( PushButtonType_OK
) ),
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
);
189 void AboutDialog::InitDialog()
191 // setting the dialog properties
192 OUString pNames
[] = {
193 rtl::OUString::createFromAscii( "BackgroundColor" ) ,
194 TKGet( TK_Closeable
),
196 TKGet( TK_Moveable
),
197 TKGet( TK_PositionX
),
198 TKGet( TK_PositionY
),
203 Any( sal_Int32( 0xffffff ) ),
205 Any( sal_Int32( ABOUT_DIALOG_HEIGHT
) ),
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 );
224 mxDialogModelPropertySet
->setPropertyValue( TKGet( TK_Width
), Any( nWidth
) );
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
),
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
);
253 // -----------------------------------------------------------------------------
255 AboutDialog::~AboutDialog()
259 // -----------------------------------------------------------------------------
261 sal_Bool
AboutDialog::execute()
263 UnoDialog::execute();
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
)