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