1c142477cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3c142477cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4c142477cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5c142477cSAndrew Rist * distributed with this work for additional information 6c142477cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7c142477cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8c142477cSAndrew Rist * "License"); you may not use this file except in compliance 9c142477cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11c142477cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13c142477cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14c142477cSAndrew Rist * software distributed under the License is distributed on an 15c142477cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16c142477cSAndrew Rist * KIND, either express or implied. See the License for the 17c142477cSAndrew Rist * specific language governing permissions and limitations 18c142477cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20c142477cSAndrew Rist *************************************************************/ 21c142477cSAndrew Rist 22c142477cSAndrew 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" 29*597a4c59SAriel Constenla-Haile #include "minimizer.hrc" 30*597a4c59SAriel Constenla-Haile #include "helpid.hrc" 31*597a4c59SAriel Constenla-Haile 32cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> 33*597a4c59SAriel Constenla-Haile #include <com/sun/star/awt/XUnitConversion.hpp> 34cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp> 35cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp> 36*597a4c59SAriel Constenla-Haile #include <com/sun/star/graphic/GraphicType.hpp> 37cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 38cdf0e10cSrcweir #include "com/sun/star/util/URL.hpp" 39cdf0e10cSrcweir #include "com/sun/star/util/XURLTransformer.hpp" 40*597a4c59SAriel Constenla-Haile #include <com/sun/star/util/MeasureUnit.hpp> 41*597a4c59SAriel Constenla-Haile #include <com/sun/star/awt/PosSize.hpp> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #define DIALOG_WIDTH 240 44cdf0e10cSrcweir #define DIALOG_HEIGHT 80 45cdf0e10cSrcweir #define PAGE_POS_X 35 46cdf0e10cSrcweir #define PAGE_WIDTH ( DIALOG_WIDTH - PAGE_POS_X ) - 6 47cdf0e10cSrcweir 48cdf0e10cSrcweir 49cdf0e10cSrcweir // --------------------- 50cdf0e10cSrcweir // - INFORMATIONDIALOG - 51cdf0e10cSrcweir // --------------------- 52cdf0e10cSrcweir 53cdf0e10cSrcweir using namespace ::com::sun::star; 54cdf0e10cSrcweir using namespace ::com::sun::star::io; 55cdf0e10cSrcweir using namespace ::com::sun::star::ui; 56cdf0e10cSrcweir using namespace ::com::sun::star::awt; 57cdf0e10cSrcweir using namespace ::com::sun::star::uno; 58cdf0e10cSrcweir using namespace ::com::sun::star::util; 59cdf0e10cSrcweir using namespace ::com::sun::star::lang; 60cdf0e10cSrcweir using namespace ::com::sun::star::frame; 61cdf0e10cSrcweir using namespace ::com::sun::star::beans; 62cdf0e10cSrcweir using namespace ::com::sun::star::script; 63cdf0e10cSrcweir using namespace ::com::sun::star::container; 64cdf0e10cSrcweir 65*597a4c59SAriel Constenla-Haile using ::rtl::OUString; 66cdf0e10cSrcweir 67cdf0e10cSrcweir // ----------------------------------------------------------------------------- 68cdf0e10cSrcweir 69*597a4c59SAriel Constenla-Haile Reference< XFixedText > InformationDialog::InsertFixedText( 70*597a4c59SAriel Constenla-Haile const rtl::OUString& rControlName, 71*597a4c59SAriel Constenla-Haile const OUString& rLabel, 72*597a4c59SAriel Constenla-Haile sal_Int32 nXPos, 73*597a4c59SAriel Constenla-Haile sal_Int32 nYPos, 74*597a4c59SAriel Constenla-Haile sal_Int32 nWidth, 75*597a4c59SAriel Constenla-Haile sal_Int32 nHeight, 76*597a4c59SAriel Constenla-Haile sal_Bool bMultiLine, 77*597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir OUString pNames[] = { 80cdf0e10cSrcweir TKGet( TK_Height ), 81cdf0e10cSrcweir TKGet( TK_Label ), 82cdf0e10cSrcweir TKGet( TK_MultiLine ), 83cdf0e10cSrcweir TKGet( TK_PositionX ), 84cdf0e10cSrcweir TKGet( TK_PositionY ), 85cdf0e10cSrcweir TKGet( TK_Step ), 86cdf0e10cSrcweir TKGet( TK_TabIndex ), 87cdf0e10cSrcweir TKGet( TK_Width ) }; 88cdf0e10cSrcweir 89cdf0e10cSrcweir Any pValues[] = { 90cdf0e10cSrcweir Any( nHeight ), 91cdf0e10cSrcweir Any( rLabel ), 92cdf0e10cSrcweir Any( bMultiLine ), 93cdf0e10cSrcweir Any( nXPos ), 94cdf0e10cSrcweir Any( nYPos ), 95cdf0e10cSrcweir Any( (sal_Int16)0 ), 96cdf0e10cSrcweir Any( nTabIndex ), 97cdf0e10cSrcweir Any( nWidth ) }; 98cdf0e10cSrcweir 99cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount ); 102cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount ); 103cdf0e10cSrcweir 104*597a4c59SAriel Constenla-Haile return insertFixedText( rControlName, aNames, aValues ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107*597a4c59SAriel Constenla-Haile Reference< XControl > InformationDialog::InsertImage( 108e381ffeaSAriel Constenla-Haile const OUString& rControlName, 109e381ffeaSAriel Constenla-Haile const OUString& rURL, 110e381ffeaSAriel Constenla-Haile sal_Int32 nPosX, 111e381ffeaSAriel Constenla-Haile sal_Int32 nPosY, 112e381ffeaSAriel Constenla-Haile sal_Int32 nWidth, 113e381ffeaSAriel Constenla-Haile sal_Int32 nHeight, 114e381ffeaSAriel Constenla-Haile sal_Bool bScale ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir OUString pNames[] = { 117cdf0e10cSrcweir TKGet( TK_Border ), 118cdf0e10cSrcweir TKGet( TK_Height ), 119cdf0e10cSrcweir TKGet( TK_ImageURL ), 120cdf0e10cSrcweir TKGet( TK_PositionX ), 121cdf0e10cSrcweir TKGet( TK_PositionY ), 122cdf0e10cSrcweir TKGet( TK_ScaleImage ), 123cdf0e10cSrcweir TKGet( TK_Width ) }; 124cdf0e10cSrcweir 125cdf0e10cSrcweir Any pValues[] = { 126cdf0e10cSrcweir Any( sal_Int16( 0 ) ), 127cdf0e10cSrcweir Any( nHeight ), 128cdf0e10cSrcweir Any( rURL ), 129cdf0e10cSrcweir Any( nPosX ), 130cdf0e10cSrcweir Any( nPosY ), 131e381ffeaSAriel Constenla-Haile Any( bScale ), 132cdf0e10cSrcweir Any( nWidth ) }; 133cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount ); 136cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount ); 137cdf0e10cSrcweir 138*597a4c59SAriel Constenla-Haile return insertImage( rControlName, aNames, aValues ); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141*597a4c59SAriel Constenla-Haile Reference< XCheckBox > InformationDialog::InsertCheckBox( 142*597a4c59SAriel Constenla-Haile const OUString& rControlName, 143*597a4c59SAriel Constenla-Haile const OUString& rLabel, 144*597a4c59SAriel Constenla-Haile const OUString& rHelpURL, 145*597a4c59SAriel Constenla-Haile sal_Int32 nXPos, 146*597a4c59SAriel Constenla-Haile sal_Int32 nYPos, 147*597a4c59SAriel Constenla-Haile sal_Int32 nWidth, 148*597a4c59SAriel Constenla-Haile sal_Int32 nHeight, 149*597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir OUString pNames[] = { 152cdf0e10cSrcweir TKGet( TK_Enabled ), 153cdf0e10cSrcweir TKGet( TK_Height ), 154*597a4c59SAriel Constenla-Haile TKGet( TK_HelpURL ), 155cdf0e10cSrcweir TKGet( TK_Label ), 156cdf0e10cSrcweir TKGet( TK_PositionX ), 157cdf0e10cSrcweir TKGet( TK_PositionY ), 158cdf0e10cSrcweir TKGet( TK_Step ), 159cdf0e10cSrcweir TKGet( TK_TabIndex ), 160cdf0e10cSrcweir TKGet( TK_Width ) }; 161cdf0e10cSrcweir 162cdf0e10cSrcweir Any pValues[] = { 163cdf0e10cSrcweir Any( sal_True ), 164cdf0e10cSrcweir Any( nHeight ), 165*597a4c59SAriel Constenla-Haile Any( rHelpURL ), 166cdf0e10cSrcweir Any( rLabel ), 167cdf0e10cSrcweir Any( nXPos ), 168cdf0e10cSrcweir Any( nYPos ), 169cdf0e10cSrcweir Any( (sal_Int16)0 ), 170cdf0e10cSrcweir Any( nTabIndex ), 171cdf0e10cSrcweir Any( nWidth ) }; 172cdf0e10cSrcweir 173cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount ); 176cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount ); 177cdf0e10cSrcweir 178*597a4c59SAriel Constenla-Haile return insertCheckBox( rControlName, aNames, aValues ); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181*597a4c59SAriel Constenla-Haile Reference< XButton > InformationDialog::InsertButton( 182*597a4c59SAriel Constenla-Haile const OUString& rControlName, 183*597a4c59SAriel Constenla-Haile sal_Int32 nXPos, 184*597a4c59SAriel Constenla-Haile sal_Int32 nYPos, 185*597a4c59SAriel Constenla-Haile sal_Int32 nWidth, 186*597a4c59SAriel Constenla-Haile sal_Int32 nHeight, 187*597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex, 188*597a4c59SAriel Constenla-Haile sal_Int32 nResID ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir OUString pNames[] = { 191cdf0e10cSrcweir TKGet( TK_Enabled ), 192cdf0e10cSrcweir TKGet( TK_Height ), 193cdf0e10cSrcweir TKGet( TK_Label ), 194cdf0e10cSrcweir TKGet( TK_PositionX ), 195cdf0e10cSrcweir TKGet( TK_PositionY ), 196cdf0e10cSrcweir TKGet( TK_PushButtonType ), 197cdf0e10cSrcweir TKGet( TK_Step ), 198cdf0e10cSrcweir TKGet( TK_TabIndex ), 199cdf0e10cSrcweir TKGet( TK_Width ) }; 200cdf0e10cSrcweir 201cdf0e10cSrcweir Any pValues[] = { 202cdf0e10cSrcweir Any( sal_True ), 203cdf0e10cSrcweir Any( nHeight ), 204*597a4c59SAriel Constenla-Haile Any( getString( nResID ) ), 205cdf0e10cSrcweir Any( nXPos ), 206cdf0e10cSrcweir Any( nYPos ), 207cdf0e10cSrcweir Any( static_cast< sal_Int16 >( PushButtonType_OK ) ), 208cdf0e10cSrcweir Any( (sal_Int16)0 ), 209cdf0e10cSrcweir Any( nTabIndex ), 210cdf0e10cSrcweir Any( nWidth ) }; 211cdf0e10cSrcweir 212cdf0e10cSrcweir 213cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); 214cdf0e10cSrcweir 215cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount ); 216cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount ); 217cdf0e10cSrcweir 218*597a4c59SAriel Constenla-Haile return insertButton( rControlName, Reference< XActionListener >(), aNames, aValues ); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir 222cdf0e10cSrcweir static OUString ImpValueOfInMB( const sal_Int64& rVal ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir double fVal( static_cast<double>( rVal ) ); 225cdf0e10cSrcweir fVal /= ( 1 << 20 ); 226cdf0e10cSrcweir fVal += 0.05; 227cdf0e10cSrcweir rtl::OUStringBuffer aVal( OUString::valueOf( fVal ) ); 228cdf0e10cSrcweir sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) ); 229cdf0e10cSrcweir if ( nX > 0 ) 230cdf0e10cSrcweir aVal.setLength( nX + 2 ); 231cdf0e10cSrcweir return aVal.makeStringAndClear(); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir void InformationDialog::InitDialog() 235cdf0e10cSrcweir { 236cdf0e10cSrcweir sal_Int32 nDialogHeight = DIALOG_HEIGHT; 237cdf0e10cSrcweir if ( !maSaveAsURL.getLength() ) 238cdf0e10cSrcweir nDialogHeight -= 22; 239cdf0e10cSrcweir 240cdf0e10cSrcweir // setting the dialog properties 241cdf0e10cSrcweir OUString pNames[] = { 242cdf0e10cSrcweir TKGet( TK_Closeable ), 243cdf0e10cSrcweir TKGet( TK_Height ), 244*597a4c59SAriel Constenla-Haile TKGet( TK_HelpURL ), 245cdf0e10cSrcweir TKGet( TK_Moveable ), 246cdf0e10cSrcweir TKGet( TK_PositionX ), 247cdf0e10cSrcweir TKGet( TK_PositionY ), 248cdf0e10cSrcweir TKGet( TK_Title ), 249cdf0e10cSrcweir TKGet( TK_Width ) }; 250cdf0e10cSrcweir 251cdf0e10cSrcweir Any pValues[] = { 252cdf0e10cSrcweir Any( sal_True ), 253cdf0e10cSrcweir Any( nDialogHeight ), 254*597a4c59SAriel Constenla-Haile Any( HID( HID_SDEXT_MINIMIZER_INFOBOX_DLG ) ), 255cdf0e10cSrcweir Any( sal_True ), 256cdf0e10cSrcweir Any( sal_Int32( 245 ) ), 257cdf0e10cSrcweir Any( sal_Int32( 115 ) ), 258*597a4c59SAriel Constenla-Haile Any( getString( STR_INFO_DIALOG ) ), 259cdf0e10cSrcweir Any( sal_Int32( DIALOG_WIDTH ) ) }; 260cdf0e10cSrcweir 261cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); 262cdf0e10cSrcweir 263cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount ); 264cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount ); 265cdf0e10cSrcweir 266cdf0e10cSrcweir mxDialogModelMultiPropertySet->setPropertyValues( aNames, aValues ); 267cdf0e10cSrcweir 268cdf0e10cSrcweir sal_Int64 nSource = mnSourceSize; 269cdf0e10cSrcweir sal_Int64 nDest = mnDestSize; 270cdf0e10cSrcweir 271*597a4c59SAriel Constenla-Haile sal_Int32 nInfoStrResId( STR_INFO_1 ); 272cdf0e10cSrcweir if ( mnSourceSize ) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir if ( mnDestSize ) 275*597a4c59SAriel Constenla-Haile nInfoStrResId = STR_INFO_1; 276cdf0e10cSrcweir else 277cdf0e10cSrcweir { 278*597a4c59SAriel Constenla-Haile nInfoStrResId = STR_INFO_2; 279cdf0e10cSrcweir nDest = mnApproxSize; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir } 282cdf0e10cSrcweir else if ( mnDestSize ) 283*597a4c59SAriel Constenla-Haile nInfoStrResId = STR_INFO_3; 284cdf0e10cSrcweir else 285cdf0e10cSrcweir { 286*597a4c59SAriel Constenla-Haile nInfoStrResId = STR_INFO_4; 287cdf0e10cSrcweir nDest = mnApproxSize; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir rtl::OUString aTitle; 291cdf0e10cSrcweir if ( maSaveAsURL.getLength() ) 292cdf0e10cSrcweir { 293*597a4c59SAriel Constenla-Haile Reference< XURLTransformer > xURLTransformer( mxContext->getServiceManager()->createInstanceWithContext( 294*597a4c59SAriel Constenla-Haile OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ), mxContext ), UNO_QUERY ); 295cdf0e10cSrcweir if ( xURLTransformer.is() ) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir util::URL aURL, aPresentationURL; 298cdf0e10cSrcweir aURL.Complete = maSaveAsURL; 299cdf0e10cSrcweir xURLTransformer->parseSmart( aURL, rtl::OUString() ); 300cdf0e10cSrcweir 301cdf0e10cSrcweir const OUString sFileProtocol( RTL_CONSTASCII_USTRINGPARAM( "file:///" ) ); 302cdf0e10cSrcweir aPresentationURL.Complete = sFileProtocol.concat( aURL.Name ); 303cdf0e10cSrcweir aTitle = xURLTransformer->getPresentation( aPresentationURL, sal_False ); 304cdf0e10cSrcweir 305cdf0e10cSrcweir if ( aTitle.match( sFileProtocol, 0 ) ) 306cdf0e10cSrcweir aTitle = aTitle.replaceAt( 0, sFileProtocol.getLength(), rtl::OUString() ); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310*597a4c59SAriel Constenla-Haile OUString aInfoString( getString( nInfoStrResId ) ); 311cdf0e10cSrcweir const OUString aOldSizePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%OLDFILESIZE" ) ); 312cdf0e10cSrcweir const OUString aNewSizePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%NEWFILESIZE" ) ); 313cdf0e10cSrcweir const OUString aTitlePlaceholder( aTitle.getLength() ? OUString::createFromAscii( "%TITLE" ) : OUString::createFromAscii( "'%TITLE'" ) ); 314cdf0e10cSrcweir 315cdf0e10cSrcweir sal_Int32 i = aInfoString.indexOf( aOldSizePlaceholder, 0 ); 316cdf0e10cSrcweir if ( i >= 0 ) 317cdf0e10cSrcweir aInfoString = aInfoString.replaceAt( i, aOldSizePlaceholder.getLength(), ImpValueOfInMB( nSource ) ); 318cdf0e10cSrcweir 319cdf0e10cSrcweir sal_Int32 j = aInfoString.indexOf( aNewSizePlaceholder, 0 ); 320cdf0e10cSrcweir if ( j >= 0 ) 321cdf0e10cSrcweir aInfoString = aInfoString.replaceAt( j, aNewSizePlaceholder.getLength(), ImpValueOfInMB( nDest ) ); 322cdf0e10cSrcweir 323cdf0e10cSrcweir sal_Int32 k = aInfoString.indexOf( aTitlePlaceholder, 0 ); 324cdf0e10cSrcweir if ( k >= 0 ) 325cdf0e10cSrcweir aInfoString = aInfoString.replaceAt( k, aTitlePlaceholder.getLength(), aTitle ); 326cdf0e10cSrcweir 327*597a4c59SAriel Constenla-Haile 328*597a4c59SAriel Constenla-Haile Reference< XControl > xImageCtrl = InsertImage( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "aboutimage" ) ), 329e381ffeaSAriel Constenla-Haile rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:standardimage/query" ) ), 330*597a4c59SAriel Constenla-Haile 3, 3, 25, 25, sal_False ); 331*597a4c59SAriel Constenla-Haile Reference< XControl > xFixedText( InsertFixedText( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "fixedtext" ) ), aInfoString, PAGE_POS_X, 6, PAGE_WIDTH, 24, sal_True, 0 ), UNO_QUERY); 332*597a4c59SAriel Constenla-Haile 333cdf0e10cSrcweir if ( maSaveAsURL.getLength() ) 334*597a4c59SAriel Constenla-Haile mxCheckBox = InsertCheckBox( TKGet( TK_OpenNewDocument ), 335*597a4c59SAriel Constenla-Haile getString( STR_AUTOMATICALLY_OPEN ), 336*597a4c59SAriel Constenla-Haile HID( HID_SDEXT_MINIMIZER_INFOBOX_CB_OPENNEW ), 337*597a4c59SAriel Constenla-Haile PAGE_POS_X, 42, 338*597a4c59SAriel Constenla-Haile PAGE_WIDTH, 8, 1 ); 339*597a4c59SAriel Constenla-Haile Reference< XControl> xButtonCtrl( InsertButton( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "button" ) ), DIALOG_WIDTH / 2 - 15, nDialogHeight - 20, 30, 14, 2, STR_OK ), UNO_QUERY ); 340cdf0e10cSrcweir 341cdf0e10cSrcweir sal_Bool bOpenNewDocument = mrbOpenNewDocument; 342cdf0e10cSrcweir setControlProperty( TKGet( TK_OpenNewDocument ), TKGet( TK_State ), Any( (sal_Int16)bOpenNewDocument ) ); 343*597a4c59SAriel Constenla-Haile 344*597a4c59SAriel Constenla-Haile sal_Int32 nX, nY, nDlgWidth; 345*597a4c59SAriel Constenla-Haile Size aSize3( 3, 3 ); 346*597a4c59SAriel Constenla-Haile Reference< XUnitConversion > xUnitConverter( mxDialogWindow, UNO_QUERY_THROW ); 347*597a4c59SAriel Constenla-Haile aSize3 = xUnitConverter->convertSizeToPixel( aSize3, util::MeasureUnit::APPFONT ); 348*597a4c59SAriel Constenla-Haile nX = nY = aSize3.Width; 349*597a4c59SAriel Constenla-Haile 350*597a4c59SAriel Constenla-Haile Reference< XPropertySet > xImageProps (xImageCtrl->getModel(), UNO_QUERY_THROW ); 351*597a4c59SAriel Constenla-Haile Reference< graphic::XGraphic > xGraphic( 352*597a4c59SAriel Constenla-Haile xImageProps->getPropertyValue( 353*597a4c59SAriel Constenla-Haile OUString( RTL_CONSTASCII_USTRINGPARAM( "Graphic") ) ), UNO_QUERY_THROW ); 354*597a4c59SAriel Constenla-Haile if ( xGraphic.is() && xGraphic->getType() != graphic::GraphicType::EMPTY ) 355*597a4c59SAriel Constenla-Haile { 356*597a4c59SAriel Constenla-Haile Size aSizePixel; 357*597a4c59SAriel Constenla-Haile Rectangle aPosSizePixel; 358*597a4c59SAriel Constenla-Haile Reference< XPropertySet > xGraphicProps( xGraphic, UNO_QUERY_THROW ); 359*597a4c59SAriel Constenla-Haile xGraphicProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SizePixel"))) >>= aSizePixel; 360*597a4c59SAriel Constenla-Haile Reference< XWindow > xImage (xImageCtrl->getPeer(), UNO_QUERY_THROW ); 361*597a4c59SAriel Constenla-Haile 362*597a4c59SAriel Constenla-Haile xImage->setPosSize( nX, nY, 363*597a4c59SAriel Constenla-Haile aSizePixel.Width, 364*597a4c59SAriel Constenla-Haile aSizePixel.Height, 365*597a4c59SAriel Constenla-Haile awt::PosSize::POSSIZE ); 366*597a4c59SAriel Constenla-Haile 367*597a4c59SAriel Constenla-Haile nX += aSizePixel.Width + aSize3.Width; 368*597a4c59SAriel Constenla-Haile 369*597a4c59SAriel Constenla-Haile Reference< XWindow > xLabel ( xFixedText->getPeer(), UNO_QUERY_THROW ); 370*597a4c59SAriel Constenla-Haile aPosSizePixel = xLabel->getPosSize(); 371*597a4c59SAriel Constenla-Haile xLabel->setPosSize( nX, nY, 372*597a4c59SAriel Constenla-Haile aPosSizePixel.Width, 373*597a4c59SAriel Constenla-Haile aPosSizePixel.Height, 374*597a4c59SAriel Constenla-Haile awt::PosSize::POSSIZE ); 375*597a4c59SAriel Constenla-Haile 376*597a4c59SAriel Constenla-Haile nDlgWidth = nX + aPosSizePixel.Width + aSize3.Width; 377*597a4c59SAriel Constenla-Haile nY += aPosSizePixel.Height + aSize3.Height; 378*597a4c59SAriel Constenla-Haile 379*597a4c59SAriel Constenla-Haile if ( mxCheckBox.is() ) 380*597a4c59SAriel Constenla-Haile { 381*597a4c59SAriel Constenla-Haile Reference< XControl > xCheckBoxCtrl( mxCheckBox, UNO_QUERY_THROW ); 382*597a4c59SAriel Constenla-Haile Reference< XWindow > xCheckBox( xCheckBoxCtrl->getPeer(), UNO_QUERY_THROW ); 383*597a4c59SAriel Constenla-Haile Rectangle aCBSize = xCheckBox->getPosSize(); 384*597a4c59SAriel Constenla-Haile xCheckBox->setPosSize( nX, nY, 385*597a4c59SAriel Constenla-Haile aPosSizePixel.Width, 386*597a4c59SAriel Constenla-Haile aCBSize.Height , 387*597a4c59SAriel Constenla-Haile awt::PosSize::POSSIZE); 388*597a4c59SAriel Constenla-Haile nY += aCBSize.Height + aSize3.Height; 389*597a4c59SAriel Constenla-Haile } 390*597a4c59SAriel Constenla-Haile 391*597a4c59SAriel Constenla-Haile nY += aSize3.Height; 392*597a4c59SAriel Constenla-Haile Reference< XWindow > xButton ( xButtonCtrl->getPeer(), UNO_QUERY_THROW ); 393*597a4c59SAriel Constenla-Haile aPosSizePixel = xButton->getPosSize(); 394*597a4c59SAriel Constenla-Haile xButton->setPosSize( nDlgWidth / 2 - aPosSizePixel.Width / 2, 395*597a4c59SAriel Constenla-Haile nY , 396*597a4c59SAriel Constenla-Haile aPosSizePixel.Width, 397*597a4c59SAriel Constenla-Haile aPosSizePixel.Height, 398*597a4c59SAriel Constenla-Haile awt::PosSize::POSSIZE ); 399*597a4c59SAriel Constenla-Haile nY += aPosSizePixel.Height + aSize3.Height; 400*597a4c59SAriel Constenla-Haile mxDialogWindow->setPosSize( 0, 0, nDlgWidth, nY, awt::PosSize::SIZE ); 401*597a4c59SAriel Constenla-Haile } 402*597a4c59SAriel Constenla-Haile 403*597a4c59SAriel Constenla-Haile centerDialog(); 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir // ----------------------------------------------------------------------------- 407cdf0e10cSrcweir 408*597a4c59SAriel Constenla-Haile InformationDialog::InformationDialog( 409*597a4c59SAriel Constenla-Haile const Reference< XComponentContext > &rxContext, 410*597a4c59SAriel Constenla-Haile const Reference< XWindowPeer>& rxParent, 411*597a4c59SAriel Constenla-Haile const rtl::OUString& rSaveAsURL, 412*597a4c59SAriel Constenla-Haile sal_Bool& rbOpenNewDocument, 413*597a4c59SAriel Constenla-Haile const sal_Int64& rSourceSize, 414*597a4c59SAriel Constenla-Haile const sal_Int64& rDestSize, 415*597a4c59SAriel Constenla-Haile const sal_Int64& rApproxSize ) 416*597a4c59SAriel Constenla-Haile : UnoDialog( rxContext, rxParent ), 417*597a4c59SAriel Constenla-Haile ConfigurationAccess( rxContext, NULL ), 418*597a4c59SAriel Constenla-Haile mxContext( rxContext ), 419cdf0e10cSrcweir mnSourceSize( rSourceSize ), 420cdf0e10cSrcweir mnDestSize( rDestSize ), 421cdf0e10cSrcweir mnApproxSize( rApproxSize ), 422cdf0e10cSrcweir mrbOpenNewDocument( rbOpenNewDocument ), 423cdf0e10cSrcweir maSaveAsURL( rSaveAsURL ) 424cdf0e10cSrcweir { 425*597a4c59SAriel Constenla-Haile OSL_TRACE( "InformationDialog::InformationDialog" ); 426*597a4c59SAriel Constenla-Haile createWindowPeer(); 427cdf0e10cSrcweir 428cdf0e10cSrcweir InitDialog(); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir // ----------------------------------------------------------------------------- 432cdf0e10cSrcweir 433cdf0e10cSrcweir InformationDialog::~InformationDialog() 434cdf0e10cSrcweir { 435*597a4c59SAriel Constenla-Haile OSL_TRACE( "InformationDialog::~InformationDialog" ); 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir // ----------------------------------------------------------------------------- 439cdf0e10cSrcweir 440cdf0e10cSrcweir sal_Bool InformationDialog::execute() 441cdf0e10cSrcweir { 442*597a4c59SAriel Constenla-Haile OSL_TRACE( "InformationDialog::execute" ); 443cdf0e10cSrcweir UnoDialog::execute(); 444cdf0e10cSrcweir 445*597a4c59SAriel Constenla-Haile if ( maSaveAsURL.getLength() && mxCheckBox.is() ) 446cdf0e10cSrcweir { 447*597a4c59SAriel Constenla-Haile sal_Bool bOpenNewDocument = static_cast< sal_Bool >( mxCheckBox->getState() ); 448cdf0e10cSrcweir mrbOpenNewDocument = bOpenNewDocument; 449cdf0e10cSrcweir } 450*597a4c59SAriel Constenla-Haile 451*597a4c59SAriel Constenla-Haile endExecute( sal_True ); 452cdf0e10cSrcweir return mbStatus; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455