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