xref: /AOO41X/main/sdext/source/minimizer/informationdialog.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir  /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sdext.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "informationdialog.hxx"
32*cdf0e10cSrcweir #include "optimizationstats.hxx"
33*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
36*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
37*cdf0e10cSrcweir #include "com/sun/star/util/URL.hpp"
38*cdf0e10cSrcweir #include "com/sun/star/util/XURLTransformer.hpp"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #define DIALOG_WIDTH	240
41*cdf0e10cSrcweir #define DIALOG_HEIGHT	80
42*cdf0e10cSrcweir #define PAGE_POS_X		35
43*cdf0e10cSrcweir #define PAGE_WIDTH		( DIALOG_WIDTH - PAGE_POS_X ) - 6
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir // ---------------------
47*cdf0e10cSrcweir // - INFORMATIONDIALOG -
48*cdf0e10cSrcweir // ---------------------
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using namespace ::rtl;
51*cdf0e10cSrcweir using namespace ::com::sun::star;
52*cdf0e10cSrcweir using namespace ::com::sun::star::io;
53*cdf0e10cSrcweir using namespace ::com::sun::star::ui;
54*cdf0e10cSrcweir using namespace ::com::sun::star::awt;
55*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
56*cdf0e10cSrcweir using namespace ::com::sun::star::util;
57*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
58*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
59*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
60*cdf0e10cSrcweir using namespace ::com::sun::star::script;
61*cdf0e10cSrcweir using namespace ::com::sun::star::container;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir // -----------------------------------------------------------------------------
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir rtl::OUString InsertFixedText( InformationDialog& rInformationDialog, const rtl::OUString& rControlName, const OUString& rLabel,
68*cdf0e10cSrcweir 								sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Int16 nTabIndex )
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir 	OUString pNames[] = {
71*cdf0e10cSrcweir 		TKGet( TK_Height ),
72*cdf0e10cSrcweir 		TKGet( TK_Label ),
73*cdf0e10cSrcweir 		TKGet( TK_MultiLine ),
74*cdf0e10cSrcweir 		TKGet( TK_PositionX ),
75*cdf0e10cSrcweir 		TKGet( TK_PositionY ),
76*cdf0e10cSrcweir 		TKGet( TK_Step ),
77*cdf0e10cSrcweir 		TKGet( TK_TabIndex ),
78*cdf0e10cSrcweir 		TKGet( TK_Width ) };
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 	Any	pValues[] = {
81*cdf0e10cSrcweir 		Any( nHeight ),
82*cdf0e10cSrcweir 		Any( rLabel ),
83*cdf0e10cSrcweir 		Any( bMultiLine ),
84*cdf0e10cSrcweir 		Any( nXPos ),
85*cdf0e10cSrcweir 		Any( nYPos ),
86*cdf0e10cSrcweir 		Any( (sal_Int16)0 ),
87*cdf0e10cSrcweir 		Any( nTabIndex ),
88*cdf0e10cSrcweir 		Any( nWidth ) };
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	Sequence< rtl::OUString >	aNames( pNames, nCount );
93*cdf0e10cSrcweir 	Sequence< Any >				aValues( pValues, nCount );
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	rInformationDialog.insertFixedText( rControlName, aNames, aValues );
96*cdf0e10cSrcweir 	return rControlName;
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir rtl::OUString InsertImage( InformationDialog& rInformationDialog, const OUString& rControlName, const OUString& rURL,
100*cdf0e10cSrcweir 						sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight )
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir 	OUString pNames[] = {
103*cdf0e10cSrcweir 		TKGet( TK_Border ),
104*cdf0e10cSrcweir 		TKGet( TK_Height ),
105*cdf0e10cSrcweir 		TKGet( TK_ImageURL ),
106*cdf0e10cSrcweir 		TKGet( TK_PositionX ),
107*cdf0e10cSrcweir 		TKGet( TK_PositionY ),
108*cdf0e10cSrcweir 		TKGet( TK_ScaleImage ),
109*cdf0e10cSrcweir 		TKGet( TK_Width ) };
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	Any	pValues[] = {
112*cdf0e10cSrcweir 		Any( sal_Int16( 0 ) ),
113*cdf0e10cSrcweir 		Any( nHeight ),
114*cdf0e10cSrcweir 		Any( rURL ),
115*cdf0e10cSrcweir 		Any( nPosX ),
116*cdf0e10cSrcweir 		Any( nPosY ),
117*cdf0e10cSrcweir 		Any( sal_True ),
118*cdf0e10cSrcweir 		Any( nWidth ) };
119*cdf0e10cSrcweir 	sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	Sequence< rtl::OUString >	aNames( pNames, nCount );
122*cdf0e10cSrcweir 	Sequence< Any >				aValues( pValues, nCount );
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	rInformationDialog.insertImage( rControlName, aNames, aValues );
125*cdf0e10cSrcweir 	return rControlName;
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir rtl::OUString InsertCheckBox( InformationDialog& rInformationDialog, const OUString& rControlName,
129*cdf0e10cSrcweir 	const Reference< XItemListener > xItemListener, const OUString& rLabel,
130*cdf0e10cSrcweir 		sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir 	OUString pNames[] = {
133*cdf0e10cSrcweir 		TKGet( TK_Enabled ),
134*cdf0e10cSrcweir 		TKGet( TK_Height ),
135*cdf0e10cSrcweir 		TKGet( TK_Label ),
136*cdf0e10cSrcweir 		TKGet( TK_PositionX ),
137*cdf0e10cSrcweir 		TKGet( TK_PositionY ),
138*cdf0e10cSrcweir 		TKGet( TK_Step ),
139*cdf0e10cSrcweir 		TKGet( TK_TabIndex ),
140*cdf0e10cSrcweir 		TKGet( TK_Width ) };
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	Any	pValues[] = {
143*cdf0e10cSrcweir 		Any( sal_True ),
144*cdf0e10cSrcweir 		Any( nHeight ),
145*cdf0e10cSrcweir 		Any( rLabel ),
146*cdf0e10cSrcweir 		Any( nXPos ),
147*cdf0e10cSrcweir 		Any( nYPos ),
148*cdf0e10cSrcweir 		Any( (sal_Int16)0 ),
149*cdf0e10cSrcweir 		Any( nTabIndex ),
150*cdf0e10cSrcweir 		Any( nWidth ) };
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 	sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	Sequence< rtl::OUString >	aNames( pNames, nCount );
155*cdf0e10cSrcweir 	Sequence< Any >				aValues( pValues, nCount );
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 	Reference< XCheckBox > xCheckBox( rInformationDialog.insertCheckBox( rControlName, aNames, aValues ) );
158*cdf0e10cSrcweir 	if ( xItemListener.is() )
159*cdf0e10cSrcweir 		xCheckBox->addItemListener( xItemListener );
160*cdf0e10cSrcweir 	return rControlName;
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir rtl::OUString InsertButton( InformationDialog& rInformationDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener,
164*cdf0e10cSrcweir 	sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, PPPOptimizerTokenEnum nResID )
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir 	OUString pNames[] = {
167*cdf0e10cSrcweir 		TKGet( TK_Enabled ),
168*cdf0e10cSrcweir 		TKGet( TK_Height ),
169*cdf0e10cSrcweir 		TKGet( TK_Label ),
170*cdf0e10cSrcweir 		TKGet( TK_PositionX ),
171*cdf0e10cSrcweir 		TKGet( TK_PositionY ),
172*cdf0e10cSrcweir 		TKGet( TK_PushButtonType ),
173*cdf0e10cSrcweir 		TKGet( TK_Step ),
174*cdf0e10cSrcweir 		TKGet( TK_TabIndex ),
175*cdf0e10cSrcweir 		TKGet( TK_Width ) };
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 	Any	pValues[] = {
178*cdf0e10cSrcweir 		Any( sal_True ),
179*cdf0e10cSrcweir 		Any( nHeight ),
180*cdf0e10cSrcweir 		Any( rInformationDialog.getString( nResID ) ),
181*cdf0e10cSrcweir 		Any( nXPos ),
182*cdf0e10cSrcweir 		Any( nYPos ),
183*cdf0e10cSrcweir 		Any( static_cast< sal_Int16 >( PushButtonType_OK ) ),
184*cdf0e10cSrcweir 		Any( (sal_Int16)0 ),
185*cdf0e10cSrcweir 		Any( nTabIndex ),
186*cdf0e10cSrcweir 		Any( nWidth ) };
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	Sequence< rtl::OUString >	aNames( pNames, nCount );
192*cdf0e10cSrcweir 	Sequence< Any >				aValues( pValues, nCount );
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 	rInformationDialog.insertButton( rControlName, xActionListener, aNames, aValues );
195*cdf0e10cSrcweir 	return rControlName;
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir static OUString ImpValueOfInMB( const sal_Int64& rVal )
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir 	double fVal( static_cast<double>( rVal ) );
202*cdf0e10cSrcweir 	fVal /= ( 1 << 20 );
203*cdf0e10cSrcweir 	fVal += 0.05;
204*cdf0e10cSrcweir 	rtl::OUStringBuffer aVal( OUString::valueOf( fVal ) );
205*cdf0e10cSrcweir 	sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) );
206*cdf0e10cSrcweir 	if ( nX > 0 )
207*cdf0e10cSrcweir 		aVal.setLength( nX + 2 );
208*cdf0e10cSrcweir 	return aVal.makeStringAndClear();
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir OUString InformationDialog::ImpGetStandardImage( const OUString& sPrivateURL )
212*cdf0e10cSrcweir {
213*cdf0e10cSrcweir 	rtl::OUString sURL;
214*cdf0e10cSrcweir 	try
215*cdf0e10cSrcweir 	{
216*cdf0e10cSrcweir 		mxTempFile = Reference< XStream >( mxMSF->getServiceManager()->createInstanceWithContext( OUString::createFromAscii( "com.sun.star.io.TempFile" ), mxMSF ), UNO_QUERY_THROW );
217*cdf0e10cSrcweir 		Reference< XPropertySet > xPropSet( mxTempFile, UNO_QUERY );
218*cdf0e10cSrcweir 		Reference< XOutputStream > xOutputStream( mxTempFile->getOutputStream() );
219*cdf0e10cSrcweir 		if ( xOutputStream.is() && xPropSet.is() )
220*cdf0e10cSrcweir 		{
221*cdf0e10cSrcweir 			Reference< graphic::XGraphicProvider > xGraphicProvider( mxMSF->getServiceManager()->createInstanceWithContext(
222*cdf0e10cSrcweir 						OUString::createFromAscii( "com.sun.star.graphic.GraphicProvider" ), mxMSF ), UNO_QUERY_THROW );
223*cdf0e10cSrcweir 			Sequence< PropertyValue > aArgs( 1 );
224*cdf0e10cSrcweir 			aArgs[ 0 ].Name = OUString::createFromAscii( "URL" );
225*cdf0e10cSrcweir 			aArgs[ 0 ].Value <<= sPrivateURL;
226*cdf0e10cSrcweir 			Reference< graphic::XGraphic > xGraphic( xGraphicProvider->queryGraphic( aArgs ) );
227*cdf0e10cSrcweir 			if ( xGraphic.is() )
228*cdf0e10cSrcweir 			{
229*cdf0e10cSrcweir 				OUString aDestMimeType( RTL_CONSTASCII_USTRINGPARAM( "image/png" ) );
230*cdf0e10cSrcweir 				Sequence< PropertyValue > aArgs2( 2 );
231*cdf0e10cSrcweir 				aArgs2[ 0 ].Name = TKGet( TK_MimeType );				// the GraphicProvider is using "MimeType", the GraphicExporter "MediaType"...
232*cdf0e10cSrcweir 				aArgs2[ 0 ].Value <<= aDestMimeType;
233*cdf0e10cSrcweir 				aArgs2[ 1 ].Name = TKGet( TK_OutputStream );
234*cdf0e10cSrcweir 				aArgs2[ 1 ].Value <<= xOutputStream;
235*cdf0e10cSrcweir 				xGraphicProvider->storeGraphic( xGraphic, aArgs2 );
236*cdf0e10cSrcweir 			}
237*cdf0e10cSrcweir 			xPropSet->getPropertyValue( OUString::createFromAscii( "Uri" ) ) >>= sURL;
238*cdf0e10cSrcweir 		}
239*cdf0e10cSrcweir 	}
240*cdf0e10cSrcweir 	catch( Exception& )
241*cdf0e10cSrcweir 	{
242*cdf0e10cSrcweir 	}
243*cdf0e10cSrcweir 	return sURL;
244*cdf0e10cSrcweir }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir void InformationDialog::InitDialog()
247*cdf0e10cSrcweir {
248*cdf0e10cSrcweir 	sal_Int32 nDialogHeight = DIALOG_HEIGHT;
249*cdf0e10cSrcweir 	if ( !maSaveAsURL.getLength() )
250*cdf0e10cSrcweir 		nDialogHeight -= 22;
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir    // setting the dialog properties
253*cdf0e10cSrcweir 	OUString pNames[] = {
254*cdf0e10cSrcweir 		TKGet( TK_Closeable ),
255*cdf0e10cSrcweir 		TKGet( TK_Height ),
256*cdf0e10cSrcweir 		TKGet( TK_Moveable ),
257*cdf0e10cSrcweir 		TKGet( TK_PositionX ),
258*cdf0e10cSrcweir 		TKGet( TK_PositionY ),
259*cdf0e10cSrcweir 		TKGet( TK_Title ),
260*cdf0e10cSrcweir 		TKGet( TK_Width ) };
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 	Any	pValues[] = {
263*cdf0e10cSrcweir 		Any( sal_True ),
264*cdf0e10cSrcweir 		Any( nDialogHeight ),
265*cdf0e10cSrcweir 		Any( sal_True ),
266*cdf0e10cSrcweir 		Any( sal_Int32( 245 ) ),
267*cdf0e10cSrcweir 		Any( sal_Int32( 115 ) ),
268*cdf0e10cSrcweir 		Any( getString( STR_SUN_OPTIMIZATION_WIZARD2 ) ),
269*cdf0e10cSrcweir 		Any( sal_Int32( DIALOG_WIDTH ) ) };
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 	sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 	Sequence< rtl::OUString >	aNames( pNames, nCount );
274*cdf0e10cSrcweir 	Sequence< Any >				aValues( pValues, nCount );
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 	mxDialogModelMultiPropertySet->setPropertyValues( aNames, aValues );
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir 	sal_Int64 nSource = mnSourceSize;
279*cdf0e10cSrcweir 	sal_Int64 nDest   = mnDestSize;
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 	PPPOptimizerTokenEnum eInfoString( STR_INFO_1 );
282*cdf0e10cSrcweir 	if ( mnSourceSize )
283*cdf0e10cSrcweir 	{
284*cdf0e10cSrcweir 		if ( mnDestSize )
285*cdf0e10cSrcweir 			eInfoString = STR_INFO_1;
286*cdf0e10cSrcweir 		else
287*cdf0e10cSrcweir 		{
288*cdf0e10cSrcweir 			eInfoString = STR_INFO_2;
289*cdf0e10cSrcweir 			nDest = mnApproxSize;
290*cdf0e10cSrcweir 		}
291*cdf0e10cSrcweir 	}
292*cdf0e10cSrcweir 	else if ( mnDestSize )
293*cdf0e10cSrcweir 		eInfoString = STR_INFO_3;
294*cdf0e10cSrcweir 	else
295*cdf0e10cSrcweir 	{
296*cdf0e10cSrcweir 		eInfoString = STR_INFO_4;
297*cdf0e10cSrcweir 		nDest = mnApproxSize;
298*cdf0e10cSrcweir 	}
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 	rtl::OUString aTitle;
301*cdf0e10cSrcweir 	if ( maSaveAsURL.getLength() )
302*cdf0e10cSrcweir 	{
303*cdf0e10cSrcweir 		Reference< XURLTransformer > xURLTransformer( mxMSF->getServiceManager()->createInstanceWithContext(
304*cdf0e10cSrcweir 				OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ), mxMSF ), UNO_QUERY );
305*cdf0e10cSrcweir 		if ( xURLTransformer.is() )
306*cdf0e10cSrcweir 		{
307*cdf0e10cSrcweir 			util::URL aURL, aPresentationURL;
308*cdf0e10cSrcweir 			aURL.Complete = maSaveAsURL;
309*cdf0e10cSrcweir 			xURLTransformer->parseSmart( aURL, rtl::OUString() );
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir 			const OUString sFileProtocol( RTL_CONSTASCII_USTRINGPARAM( "file:///" ) );
312*cdf0e10cSrcweir 			aPresentationURL.Complete = sFileProtocol.concat( aURL.Name );
313*cdf0e10cSrcweir 			aTitle = xURLTransformer->getPresentation( aPresentationURL, sal_False );
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 			if ( aTitle.match( sFileProtocol, 0 ) )
316*cdf0e10cSrcweir 				aTitle = aTitle.replaceAt( 0, sFileProtocol.getLength(), rtl::OUString() );
317*cdf0e10cSrcweir 		}
318*cdf0e10cSrcweir 	}
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 	OUString aInfoString( getString( eInfoString ) );
321*cdf0e10cSrcweir 	const OUString aOldSizePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%OLDFILESIZE" ) );
322*cdf0e10cSrcweir 	const OUString aNewSizePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%NEWFILESIZE" ) );
323*cdf0e10cSrcweir 	const OUString aTitlePlaceholder( aTitle.getLength() ? OUString::createFromAscii( "%TITLE" ) : OUString::createFromAscii( "'%TITLE'" ) );
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 	sal_Int32 i = aInfoString.indexOf( aOldSizePlaceholder, 0 );
326*cdf0e10cSrcweir 	if ( i >= 0 )
327*cdf0e10cSrcweir 		aInfoString = aInfoString.replaceAt( i, aOldSizePlaceholder.getLength(), ImpValueOfInMB( nSource ) );
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	sal_Int32 j = aInfoString.indexOf( aNewSizePlaceholder, 0 );
330*cdf0e10cSrcweir 	if ( j >= 0 )
331*cdf0e10cSrcweir 		aInfoString = aInfoString.replaceAt( j, aNewSizePlaceholder.getLength(), ImpValueOfInMB( nDest ) );
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir 	sal_Int32 k = aInfoString.indexOf( aTitlePlaceholder, 0 );
334*cdf0e10cSrcweir 	if ( k >= 0 )
335*cdf0e10cSrcweir 		aInfoString = aInfoString.replaceAt( k, aTitlePlaceholder.getLength(), aTitle );
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::awt::XItemListener > xItemListener;
338*cdf0e10cSrcweir 	InsertImage( *this, rtl::OUString( rtl::OUString::createFromAscii( "aboutimage" ) ), ImpGetStandardImage( rtl::OUString::createFromAscii( "private:standardimage/query" ) ), 5, 5, 25, 25 );
339*cdf0e10cSrcweir 	InsertFixedText( *this, rtl::OUString( rtl::OUString::createFromAscii( "fixedtext" ) ), aInfoString, PAGE_POS_X, 6, PAGE_WIDTH, 24, sal_True, 0 );
340*cdf0e10cSrcweir 	if ( maSaveAsURL.getLength() )
341*cdf0e10cSrcweir 		InsertCheckBox(  *this, TKGet( TK_OpenNewDocument ), xItemListener, getString( STR_AUTOMATICALLY_OPEN ), PAGE_POS_X, 42, PAGE_WIDTH, 8, 1 );
342*cdf0e10cSrcweir 	InsertButton( *this, rtl::OUString( rtl::OUString::createFromAscii( "button" ) ), mxActionListener, DIALOG_WIDTH / 2 - 25, nDialogHeight - 20, 50, 14, 2, STR_OK );
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 	sal_Bool bOpenNewDocument = mrbOpenNewDocument;
345*cdf0e10cSrcweir 	setControlProperty( TKGet( TK_OpenNewDocument ), TKGet( TK_State ), Any( (sal_Int16)bOpenNewDocument ) );
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir // -----------------------------------------------------------------------------
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir InformationDialog::InformationDialog( const Reference< XComponentContext > &rxMSF, Reference< XFrame >& rxFrame, const rtl::OUString& rSaveAsURL, sal_Bool& rbOpenNewDocument, const sal_Int64& rSourceSize, const sal_Int64& rDestSize, const sal_Int64& rApproxSize ) :
351*cdf0e10cSrcweir 	UnoDialog( rxMSF, rxFrame ),
352*cdf0e10cSrcweir 	ConfigurationAccess( rxMSF, NULL ),
353*cdf0e10cSrcweir 	mxMSF( rxMSF ),
354*cdf0e10cSrcweir 	mxFrame( rxFrame ),
355*cdf0e10cSrcweir 	mxActionListener( new OKActionListener( *this ) ),
356*cdf0e10cSrcweir 	mnSourceSize( rSourceSize ),
357*cdf0e10cSrcweir 	mnDestSize( rDestSize ),
358*cdf0e10cSrcweir 	mnApproxSize( rApproxSize ),
359*cdf0e10cSrcweir 	mrbOpenNewDocument( rbOpenNewDocument ),
360*cdf0e10cSrcweir 	maSaveAsURL( rSaveAsURL )
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir 	Reference< XFrame > xFrame( mxController->getFrame() );
363*cdf0e10cSrcweir 	Reference< XWindow > xContainerWindow( xFrame->getContainerWindow() );
364*cdf0e10cSrcweir 	Reference< XWindowPeer > xWindowPeer( xContainerWindow, UNO_QUERY_THROW );
365*cdf0e10cSrcweir 	createWindowPeer( xWindowPeer );
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 	InitDialog();
368*cdf0e10cSrcweir }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir // -----------------------------------------------------------------------------
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir InformationDialog::~InformationDialog()
373*cdf0e10cSrcweir {
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir // -----------------------------------------------------------------------------
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir sal_Bool InformationDialog::execute()
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir 	UnoDialog::execute();
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 	if ( maSaveAsURL.getLength() )
383*cdf0e10cSrcweir 	{
384*cdf0e10cSrcweir 		sal_Int16 nInt16 = 0;
385*cdf0e10cSrcweir 		Any aAny( getControlProperty( TKGet( TK_OpenNewDocument ), TKGet( TK_State ) ) );
386*cdf0e10cSrcweir 		if ( aAny >>= nInt16 )
387*cdf0e10cSrcweir 		{
388*cdf0e10cSrcweir 			sal_Bool bOpenNewDocument = static_cast< sal_Bool >( nInt16 );
389*cdf0e10cSrcweir 			mrbOpenNewDocument = bOpenNewDocument;
390*cdf0e10cSrcweir 		}
391*cdf0e10cSrcweir 	}
392*cdf0e10cSrcweir 	return mbStatus;
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir // -----------------------------------------------------------------------------
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir void OKActionListener::actionPerformed( const ActionEvent& rEvent )
398*cdf0e10cSrcweir 	throw ( com::sun::star::uno::RuntimeException )
399*cdf0e10cSrcweir {
400*cdf0e10cSrcweir 	if ( rEvent.ActionCommand == rtl::OUString( rtl::OUString::createFromAscii( "button" ) ) )
401*cdf0e10cSrcweir 	{
402*cdf0e10cSrcweir 		mrInformationDialog.endExecute( sal_True );
403*cdf0e10cSrcweir 	}
404*cdf0e10cSrcweir }
405*cdf0e10cSrcweir void OKActionListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
406*cdf0e10cSrcweir 	throw ( com::sun::star::uno::RuntimeException )
407*cdf0e10cSrcweir {
408*cdf0e10cSrcweir }
409