LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/dbui - dbui.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 59 1.7 %
Date: 2013-07-09 Functions: 2 11 18.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "wrtsh.hxx"
      22             : 
      23             : #include "dbui.hrc"
      24             : #include "dbui.hxx"
      25             : 
      26           0 : 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           0 :     aCancel     (this, SW_RES( PB_CANCELPRNMON  ))
      35             : {
      36           0 :     switch (eType)
      37             :     {
      38           0 :         case MONITOR_TYPE_SAVE: SetText(SW_RES(STR_SAVEMON)); break;
      39           0 :         case MONITOR_TYPE_MAIL: SetText(SW_RES(STR_EMAILMON)); break;
      40           0 :         case MONITOR_TYPE_PRINT: break;
      41             :     }
      42           0 :     FreeResource();
      43           0 : }
      44             : 
      45           0 : static void lcl_ResizeControl( Window* pWin, long nDiff )
      46             : {
      47           0 :     Size aSize( pWin->GetSizePixel() );
      48           0 :     aSize.Width() += nDiff;
      49           0 :     pWin->SetSizePixel( aSize );
      50           0 : }
      51           0 : static void lcl_RePosControl( Window* pWin, long nDiff )
      52             : {
      53           0 :     Point aPos( pWin->GetPosPixel() );
      54           0 :     aPos.X()  += nDiff;
      55           0 :     pWin->SetPosPixel( aPos );
      56           0 : }
      57             : 
      58           0 : void PrintMonitor::ResizeControls()
      59             : {
      60           0 :     Size aDlgSize( GetSizePixel() );
      61           0 :     Size aPrinterSize( aPrinter.GetSizePixel() );
      62           0 :     long nPrinterTextWidth = aPrinter.GetTextWidth( aPrinter.GetText() );
      63           0 :     if( nPrinterTextWidth > aPrinterSize.Width() )
      64             :     {
      65             :         //increase control and dialog width if printer text is too long
      66             :         //do not increase dialog width more than three times
      67           0 :         long nDiff = nPrinterTextWidth - aPrinterSize.Width();
      68           0 :         if( nDiff > 2 * aDlgSize.Width() )
      69             :         {
      70           0 :             aPrinter.SetStyle( WB_RIGHT | aPrinter.GetStyle() );
      71           0 :             nDiff = 2 * aDlgSize.Width();
      72             :         }
      73           0 :         aDlgSize.Width() += nDiff;
      74           0 :         SetSizePixel(aDlgSize);
      75           0 :         lcl_ResizeControl( &aPrinter, nDiff );
      76             : 
      77           0 :         nDiff /= 2;
      78           0 :         lcl_RePosControl( &aDocName, nDiff );
      79           0 :         lcl_RePosControl( &aPrinting, nDiff );
      80           0 :         lcl_RePosControl( &aPrintInfo, nDiff );
      81           0 :         lcl_RePosControl( &aCancel, nDiff );
      82             :     }
      83           0 : }
      84             : 
      85             : // Progress Indicator for Creation of personalized Mail Merge documents:
      86           0 : 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           0 :     m_nCurrentPosition(0)
      98             : {
      99           0 :     FreeResource();
     100             : 
     101           0 :     m_sCountingPattern = m_aCounting.GetText();
     102           0 :     m_aCounting.SetText(OUString("..."));
     103           0 : }
     104             : 
     105           0 : void CreateMonitor::UpdateCountingText()
     106             : {
     107           0 :     String sText(m_sCountingPattern);
     108           0 :     sText.SearchAndReplaceAll( m_sVariable_Total, OUString::number( m_nTotalCount ) );
     109           0 :     sText.SearchAndReplaceAll( m_sVariable_Position, OUString::number( m_nCurrentPosition ) );
     110           0 :     m_aCounting.SetText(sText);
     111           0 : }
     112             : 
     113           0 : void CreateMonitor::SetTotalCount( sal_Int32 nTotal )
     114             : {
     115           0 :     m_nTotalCount = nTotal;
     116           0 :     UpdateCountingText();
     117           0 : }
     118             : 
     119           0 : void CreateMonitor::SetCurrentPosition( sal_Int32 nCurrent )
     120             : {
     121           0 :     m_nCurrentPosition = nCurrent;
     122           0 :     UpdateCountingText();
     123           0 : }
     124             : 
     125           0 : void CreateMonitor::SetCancelHdl( const Link& rLink )
     126             : {
     127           0 :     m_aCancelButton.SetClickHdl( rLink );
     128          99 : }
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10