1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 // INCLUDE --------------------------------------------------------------- 32 33 34 #include <tools/list.hxx> 35 #include "wrtsh.hxx" 36 37 38 #include "dbui.hrc" 39 #include "dbui.hxx" 40 41 /*--------------------------------------------------------------------- 42 Beschreibung: 43 ---------------------------------------------------------------------*/ 44 45 PrintMonitor::PrintMonitor( Window *pParent, PrintMonitorType eType ) 46 : ModelessDialog( pParent, SW_RES(DLG_PRINTMONITOR) ), 47 aDocName (this, SW_RES( FT_DOCNAME )), 48 aPrinting (this, SW_RES( 49 eType == MONITOR_TYPE_MAIL ? 50 FT_SENDING : eType == MONITOR_TYPE_SAVE ? FT_SAVING : FT_PRINTING )), 51 aPrinter (this, SW_RES( FT_PRINTER )), 52 aPrintInfo (this, SW_RES( FT_PRINTINFO )), 53 aCancel (this, SW_RES( PB_CANCELPRNMON )) 54 { 55 switch (eType) 56 { 57 case MONITOR_TYPE_SAVE: SetText(SW_RES(STR_SAVEMON)); break; 58 case MONITOR_TYPE_MAIL: SetText(SW_RES(STR_EMAILMON)); break; 59 case MONITOR_TYPE_PRINT: break; 60 } 61 FreeResource(); 62 } 63 /*--------------------------------------------------------------------- 64 65 ---------------------------------------------------------------------*/ 66 void lcl_ResizeControl( Window* pWin, long nDiff ) 67 { 68 Size aSize( pWin->GetSizePixel() ); 69 aSize.Width() += nDiff; 70 pWin->SetSizePixel( aSize ); 71 } 72 void lcl_RePosControl( Window* pWin, long nDiff ) 73 { 74 Point aPos( pWin->GetPosPixel() ); 75 aPos.X() += nDiff; 76 pWin->SetPosPixel( aPos ); 77 } 78 79 void PrintMonitor::ResizeControls() 80 { 81 Size aDlgSize( GetSizePixel() ); 82 Size aPrinterSize( aPrinter.GetSizePixel() ); 83 long nPrinterTextWidth = aPrinter.GetTextWidth( aPrinter.GetText() ); 84 if( nPrinterTextWidth > aPrinterSize.Width() ) 85 { 86 //increase control and dialog width if printer text is too long 87 //do not increase dialog width more than three times 88 long nDiff = nPrinterTextWidth - aPrinterSize.Width(); 89 if( nDiff > 2 * aDlgSize.Width() ) 90 { 91 aPrinter.SetStyle( WB_RIGHT | aPrinter.GetStyle() ); 92 nDiff = 2 * aDlgSize.Width(); 93 } 94 aDlgSize.Width() += nDiff; 95 SetSizePixel(aDlgSize); 96 lcl_ResizeControl( &aPrinter, nDiff ); 97 98 nDiff /= 2; 99 lcl_RePosControl( &aDocName, nDiff ); 100 lcl_RePosControl( &aPrinting, nDiff ); 101 lcl_RePosControl( &aPrintInfo, nDiff ); 102 lcl_RePosControl( &aCancel, nDiff ); 103 } 104 } 105 /*--------------------------------------------------------------------- 106 Progress Indicator for Creation of personalized Mail Merge documents: 107 ---------------------------------------------------------------------*/ 108 109 CreateMonitor::CreateMonitor( Window *pParent ) 110 : ModelessDialog( pParent, SW_RES(DLG_MM_CREATIONMONITOR) ), 111 m_aStatus (this, SW_RES( FT_STATUS )), 112 m_aProgress (this, SW_RES( FT_PROGRESS )), 113 m_aCreateDocuments (this, SW_RES( FT_CREATEDOCUMENTS )), 114 m_aCounting (this, SW_RES( FT_COUNTING )), 115 m_aCancelButton (this, SW_RES( PB_CANCELPRNMON )), 116 m_sCountingPattern(), 117 m_sVariable_Total( String::CreateFromAscii("%Y") ), 118 m_sVariable_Position( String::CreateFromAscii("%X") ), 119 m_nTotalCount(0), 120 m_nCurrentPosition(0) 121 { 122 FreeResource(); 123 124 m_sCountingPattern = m_aCounting.GetText(); 125 m_aCounting.SetText(String::CreateFromAscii("...")); 126 } 127 128 void CreateMonitor::UpdateCountingText() 129 { 130 String sText(m_sCountingPattern); 131 sText.SearchAndReplaceAll( m_sVariable_Total, String::CreateFromInt32( m_nTotalCount ) ); 132 sText.SearchAndReplaceAll( m_sVariable_Position, String::CreateFromInt32( m_nCurrentPosition ) ); 133 m_aCounting.SetText(sText); 134 } 135 136 void CreateMonitor::SetTotalCount( sal_Int32 nTotal ) 137 { 138 m_nTotalCount = nTotal; 139 UpdateCountingText(); 140 } 141 142 void CreateMonitor::SetCurrentPosition( sal_Int32 nCurrent ) 143 { 144 m_nCurrentPosition = nCurrent; 145 UpdateCountingText(); 146 } 147 148 void CreateMonitor::SetCancelHdl( const Link& rLink ) 149 { 150 m_aCancelButton.SetClickHdl( rLink ); 151 } 152