1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 // INCLUDE --------------------------------------------------------------- 28 29 30 #include <tools/list.hxx> 31 #include "wrtsh.hxx" 32 33 34 #include "dbui.hrc" 35 #include "dbui.hxx" 36 37 /*--------------------------------------------------------------------- 38 Beschreibung: 39 ---------------------------------------------------------------------*/ 40 41 PrintMonitor::PrintMonitor( Window *pParent, PrintMonitorType eType ) 42 : ModelessDialog( pParent, SW_RES(DLG_PRINTMONITOR) ), 43 aDocName (this, SW_RES( FT_DOCNAME )), 44 aPrinting (this, SW_RES( 45 eType == MONITOR_TYPE_MAIL ? 46 FT_SENDING : eType == MONITOR_TYPE_SAVE ? FT_SAVING : FT_PRINTING )), 47 aPrinter (this, SW_RES( FT_PRINTER )), 48 aPrintInfo (this, SW_RES( FT_PRINTINFO )), 49 aCancel (this, SW_RES( PB_CANCELPRNMON )) 50 { 51 switch (eType) 52 { 53 case MONITOR_TYPE_SAVE: SetText(SW_RES(STR_SAVEMON)); break; 54 case MONITOR_TYPE_MAIL: SetText(SW_RES(STR_EMAILMON)); break; 55 case MONITOR_TYPE_PRINT: break; 56 } 57 FreeResource(); 58 } 59 /*--------------------------------------------------------------------- 60 61 ---------------------------------------------------------------------*/ 62 void lcl_ResizeControl( Window* pWin, long nDiff ) 63 { 64 Size aSize( pWin->GetSizePixel() ); 65 aSize.Width() += nDiff; 66 pWin->SetSizePixel( aSize ); 67 } 68 void lcl_RePosControl( Window* pWin, long nDiff ) 69 { 70 Point aPos( pWin->GetPosPixel() ); 71 aPos.X() += nDiff; 72 pWin->SetPosPixel( aPos ); 73 } 74 75 void PrintMonitor::ResizeControls() 76 { 77 Size aDlgSize( GetSizePixel() ); 78 Size aPrinterSize( aPrinter.GetSizePixel() ); 79 long nPrinterTextWidth = aPrinter.GetTextWidth( aPrinter.GetText() ); 80 if( nPrinterTextWidth > aPrinterSize.Width() ) 81 { 82 //increase control and dialog width if printer text is too long 83 //do not increase dialog width more than three times 84 long nDiff = nPrinterTextWidth - aPrinterSize.Width(); 85 if( nDiff > 2 * aDlgSize.Width() ) 86 { 87 aPrinter.SetStyle( WB_RIGHT | aPrinter.GetStyle() ); 88 nDiff = 2 * aDlgSize.Width(); 89 } 90 aDlgSize.Width() += nDiff; 91 SetSizePixel(aDlgSize); 92 lcl_ResizeControl( &aPrinter, nDiff ); 93 94 nDiff /= 2; 95 lcl_RePosControl( &aDocName, nDiff ); 96 lcl_RePosControl( &aPrinting, nDiff ); 97 lcl_RePosControl( &aPrintInfo, nDiff ); 98 lcl_RePosControl( &aCancel, nDiff ); 99 } 100 } 101 /*--------------------------------------------------------------------- 102 Progress Indicator for Creation of personalized Mail Merge documents: 103 ---------------------------------------------------------------------*/ 104 105 CreateMonitor::CreateMonitor( Window *pParent ) 106 : ModelessDialog( pParent, SW_RES(DLG_MM_CREATIONMONITOR) ), 107 m_aStatus (this, SW_RES( FT_STATUS )), 108 m_aProgress (this, SW_RES( FT_PROGRESS )), 109 m_aCreateDocuments (this, SW_RES( FT_CREATEDOCUMENTS )), 110 m_aCounting (this, SW_RES( FT_COUNTING )), 111 m_aCancelButton (this, SW_RES( PB_CANCELPRNMON )), 112 m_sCountingPattern(), 113 m_sVariable_Total( String::CreateFromAscii("%Y") ), 114 m_sVariable_Position( String::CreateFromAscii("%X") ), 115 m_nTotalCount(0), 116 m_nCurrentPosition(0) 117 { 118 FreeResource(); 119 120 m_sCountingPattern = m_aCounting.GetText(); 121 m_aCounting.SetText(String::CreateFromAscii("...")); 122 } 123 124 void CreateMonitor::UpdateCountingText() 125 { 126 String sText(m_sCountingPattern); 127 sText.SearchAndReplaceAll( m_sVariable_Total, String::CreateFromInt32( m_nTotalCount ) ); 128 sText.SearchAndReplaceAll( m_sVariable_Position, String::CreateFromInt32( m_nCurrentPosition ) ); 129 m_aCounting.SetText(sText); 130 } 131 132 void CreateMonitor::SetTotalCount( sal_Int32 nTotal ) 133 { 134 m_nTotalCount = nTotal; 135 UpdateCountingText(); 136 } 137 138 void CreateMonitor::SetCurrentPosition( sal_Int32 nCurrent ) 139 { 140 m_nCurrentPosition = nCurrent; 141 UpdateCountingText(); 142 } 143 144 void CreateMonitor::SetCancelHdl( const Link& rLink ) 145 { 146 m_aCancelButton.SetClickHdl( rLink ); 147 } 148