update credits
[LibreOffice.git] / sw / source / ui / dbui / dbui.cxx
blob17c18dabc925ebb7da23b2830bc6dce9c44b2ba4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "wrtsh.hxx"
23 #include "dbui.hrc"
24 #include "dbui.hxx"
26 PrintMonitor::PrintMonitor( Window *pParent, PrintMonitorType eType )
27 : ModelessDialog( pParent, SW_RES(DLG_PRINTMONITOR) ),
28 aDocName (this, SW_RES( FT_DOCNAME )),
29 aPrinting (this, SW_RES(
30 eType == MONITOR_TYPE_MAIL ?
31 FT_SENDING : eType == MONITOR_TYPE_SAVE ? FT_SAVING : FT_PRINTING )),
32 aPrinter (this, SW_RES( FT_PRINTER )),
33 aPrintInfo (this, SW_RES( FT_PRINTINFO )),
34 aCancel (this, SW_RES( PB_CANCELPRNMON ))
36 switch (eType)
38 case MONITOR_TYPE_SAVE: SetText(SW_RES(STR_SAVEMON)); break;
39 case MONITOR_TYPE_MAIL: SetText(SW_RES(STR_EMAILMON)); break;
40 case MONITOR_TYPE_PRINT: break;
42 FreeResource();
45 static void lcl_ResizeControl( Window* pWin, long nDiff )
47 Size aSize( pWin->GetSizePixel() );
48 aSize.Width() += nDiff;
49 pWin->SetSizePixel( aSize );
51 static void lcl_RePosControl( Window* pWin, long nDiff )
53 Point aPos( pWin->GetPosPixel() );
54 aPos.X() += nDiff;
55 pWin->SetPosPixel( aPos );
58 void PrintMonitor::ResizeControls()
60 Size aDlgSize( GetSizePixel() );
61 Size aPrinterSize( aPrinter.GetSizePixel() );
62 long nPrinterTextWidth = aPrinter.GetTextWidth( aPrinter.GetText() );
63 if( nPrinterTextWidth > aPrinterSize.Width() )
65 //increase control and dialog width if printer text is too long
66 //do not increase dialog width more than three times
67 long nDiff = nPrinterTextWidth - aPrinterSize.Width();
68 if( nDiff > 2 * aDlgSize.Width() )
70 aPrinter.SetStyle( WB_RIGHT | aPrinter.GetStyle() );
71 nDiff = 2 * aDlgSize.Width();
73 aDlgSize.Width() += nDiff;
74 SetSizePixel(aDlgSize);
75 lcl_ResizeControl( &aPrinter, nDiff );
77 nDiff /= 2;
78 lcl_RePosControl( &aDocName, nDiff );
79 lcl_RePosControl( &aPrinting, nDiff );
80 lcl_RePosControl( &aPrintInfo, nDiff );
81 lcl_RePosControl( &aCancel, nDiff );
85 // Progress Indicator for Creation of personalized Mail Merge documents:
86 CreateMonitor::CreateMonitor( Window *pParent )
87 : ModelessDialog( pParent, SW_RES(DLG_MM_CREATIONMONITOR) ),
88 m_aStatus (this, SW_RES( FT_STATUS )),
89 m_aProgress (this, SW_RES( FT_PROGRESS )),
90 m_aCreateDocuments (this, SW_RES( FT_CREATEDOCUMENTS )),
91 m_aCounting (this, SW_RES( FT_COUNTING )),
92 m_aCancelButton (this, SW_RES( PB_CANCELPRNMON )),
93 m_sCountingPattern(),
94 m_sVariable_Total( OUString("%Y") ),
95 m_sVariable_Position( OUString("%X") ),
96 m_nTotalCount(0),
97 m_nCurrentPosition(0)
99 FreeResource();
101 m_sCountingPattern = m_aCounting.GetText();
102 m_aCounting.SetText(OUString("..."));
105 void CreateMonitor::UpdateCountingText()
107 String sText(m_sCountingPattern);
108 sText.SearchAndReplaceAll( m_sVariable_Total, OUString::number( m_nTotalCount ) );
109 sText.SearchAndReplaceAll( m_sVariable_Position, OUString::number( m_nCurrentPosition ) );
110 m_aCounting.SetText(sText);
113 void CreateMonitor::SetTotalCount( sal_Int32 nTotal )
115 m_nTotalCount = nTotal;
116 UpdateCountingText();
119 void CreateMonitor::SetCurrentPosition( sal_Int32 nCurrent )
121 m_nCurrentPosition = nCurrent;
122 UpdateCountingText();
125 void CreateMonitor::SetCancelHdl( const Link& rLink )
127 m_aCancelButton.SetClickHdl( rLink );
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */