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