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