LCOV - code coverage report
Current view: top level - reportdesign/source/ui/dlg - PageNumber.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 55 1.8 %
Date: 2015-06-13 12:38:46 Functions: 2 7 28.6 %
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             : #include "PageNumber.hxx"
      20             : #include <com/sun/star/beans/XPropertySet.hpp>
      21             : #include <tools/debug.hxx>
      22             : #include "RptResId.hrc"
      23             : #include "rptui_slotid.hrc"
      24             : #include "ModuleHelper.hxx"
      25             : #include "RptDef.hxx"
      26             : #include "helpids.hrc"
      27             : #include <vcl/msgbox.hxx>
      28             : #include <vcl/settings.hxx>
      29             : 
      30             : #include "UITools.hxx"
      31             : #include "uistrings.hrc"
      32             : #include "ReportController.hxx"
      33             : #include <com/sun/star/report/XFixedText.hpp>
      34             : #include <algorithm>
      35             : 
      36             : namespace rptui
      37             : {
      38             : using namespace ::com::sun::star;
      39             : using namespace ::comphelper;
      40             : 
      41             : 
      42             : // class OPageNumberDialog
      43             : 
      44           0 : OPageNumberDialog::OPageNumberDialog( vcl::Window* _pParent
      45             :                                            ,const uno::Reference< report::XReportDefinition >& _xHoldAlive
      46             :                                            ,OReportController* _pController)
      47             :     : ModalDialog( _pParent, "PageNumberDialog" , "modules/dbreport/ui/pagenumberdialog.ui" )
      48             :     ,m_pController(_pController)
      49           0 :     ,m_xHoldAlive(_xHoldAlive)
      50             : {
      51           0 :     get(m_pPageN,"pagen");
      52           0 :     get(m_pPageNofM,"pagenofm");
      53           0 :     get(m_pTopPage,"toppage");
      54           0 :     get(m_pBottomPage,"bottompage");
      55           0 :     get(m_pAlignmentLst,"alignment");
      56           0 :     get(m_pShowNumberOnFirstPage,"shownumberonfirstpage");
      57             : 
      58             : 
      59           0 :     m_pShowNumberOnFirstPage->Hide();
      60             : 
      61           0 : }
      62             : 
      63             : 
      64           0 : OPageNumberDialog::~OPageNumberDialog()
      65             : {
      66           0 :     disposeOnce();
      67           0 : }
      68             : 
      69           0 : void OPageNumberDialog::dispose()
      70             : {
      71           0 :     m_pPageN.clear();
      72           0 :     m_pPageNofM.clear();
      73           0 :     m_pTopPage.clear();
      74           0 :     m_pBottomPage.clear();
      75           0 :     m_pAlignmentLst.clear();
      76           0 :     m_pShowNumberOnFirstPage.clear();
      77           0 :     ModalDialog::dispose();
      78           0 : }
      79             : 
      80           0 : short OPageNumberDialog::Execute()
      81             : {
      82           0 :     short nRet = ModalDialog::Execute();
      83           0 :     if ( nRet == RET_OK )
      84             :     {
      85             :         try
      86             :         {
      87           0 :             sal_Int32 nControlMaxSize = 3000;
      88           0 :             sal_Int32 nPosX = 0;
      89           0 :             sal_Int32 nPos2X = 0;
      90           0 :             awt::Size aRptSize = getStyleProperty<awt::Size>(m_xHoldAlive,PROPERTY_PAPERSIZE);
      91           0 :             switch ( m_pAlignmentLst->GetSelectEntryPos() )
      92             :             {
      93             :                 case 0: // left
      94           0 :                     nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
      95           0 :                     break;
      96             :                 case 1: // middle
      97           0 :                     nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN) + (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN) - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize) / 2;
      98           0 :                     break;
      99             :                 case 2: // right
     100           0 :                     nPosX = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
     101           0 :                     break;
     102             :                 case 3: // inner
     103             :                 case 4: // outer
     104           0 :                     nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
     105           0 :                     nPos2X = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
     106           0 :                     break;
     107             :                 default:
     108           0 :                     break;
     109             :             }
     110           0 :             if ( m_pAlignmentLst->GetSelectEntryPos() > 2 )
     111           0 :                 nPosX = nPos2X;
     112             : 
     113           0 :             sal_Int32 nLength = 0;
     114           0 :             uno::Sequence<beans::PropertyValue> aValues( 3 );
     115           0 :             aValues[nLength].Name = PROPERTY_POSITION;
     116           0 :             aValues[nLength++].Value <<= awt::Point(nPosX,0);
     117             : 
     118           0 :             aValues[nLength].Name = PROPERTY_PAGEHEADERON;
     119           0 :             aValues[nLength++].Value <<= m_pTopPage->IsChecked();
     120             : 
     121           0 :             aValues[nLength].Name = PROPERTY_STATE;
     122           0 :             aValues[nLength++].Value <<= m_pPageNofM->IsChecked();
     123             : 
     124           0 :             m_pController->executeChecked(SID_INSERT_FLD_PGNUMBER,aValues);
     125             :         }
     126           0 :         catch(uno::Exception&)
     127             :         {
     128           0 :             nRet = RET_NO;
     129             :         }
     130             :     }
     131           0 :     return nRet;
     132             : }
     133             : 
     134           3 : } // rptui
     135             : 
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11