LCOV - code coverage report
Current view: top level - sc/source/ui/docshell - pagedata.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 39 55 70.9 %
Date: 2014-11-03 Functions: 9 11 81.8 %
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             : #include <string.h>
      21             : 
      22             : #include "pagedata.hxx"
      23             : 
      24           2 : ScPrintRangeData::ScPrintRangeData()
      25             : {
      26           2 :     nPagesX = nPagesY = 0;
      27           2 :     pPageEndX = NULL;
      28           2 :     pPageEndY = NULL;
      29           2 :     bTopDown = bAutomatic = true;
      30           2 :     nFirstPage = 1;
      31           2 : }
      32             : 
      33           2 : ScPrintRangeData::~ScPrintRangeData()
      34             : {
      35           2 :     delete[] pPageEndX;
      36           2 :     delete[] pPageEndY;
      37           2 : }
      38             : 
      39           2 : void ScPrintRangeData::SetPagesX( size_t nCount, const SCCOL* pData )
      40             : {
      41           2 :     delete[] pPageEndX;
      42           2 :     if ( nCount )
      43             :     {
      44           2 :         pPageEndX = new SCCOL[nCount];
      45           2 :         memcpy( pPageEndX, pData, nCount * sizeof(SCCOL) );
      46             :     }
      47             :     else
      48           0 :         pPageEndX = NULL;
      49           2 :     nPagesX = nCount;
      50           2 : }
      51             : 
      52           2 : void ScPrintRangeData::SetPagesY( size_t nCount, const SCROW* pData )
      53             : {
      54           2 :     delete[] pPageEndY;
      55           2 :     if ( nCount )
      56             :     {
      57           2 :         pPageEndY = new SCROW[nCount];
      58           2 :         memcpy( pPageEndY, pData, nCount * sizeof(SCROW) );
      59             :     }
      60             :     else
      61           0 :         pPageEndY = NULL;
      62           2 :     nPagesY = nCount;
      63           2 : }
      64             : 
      65           2 : ScPageBreakData::ScPageBreakData(size_t nMax)
      66             : {
      67           2 :     nUsed = 0;
      68           2 :     if (nMax)
      69           2 :         pData = new ScPrintRangeData[nMax];
      70             :     else
      71           0 :         pData = NULL;
      72           2 :     nAlloc = nMax;
      73           2 : }
      74             : 
      75           2 : ScPageBreakData::~ScPageBreakData()
      76             : {
      77           2 :     delete[] pData;
      78           2 : }
      79             : 
      80           2 : ScPrintRangeData& ScPageBreakData::GetData(size_t nPos)
      81             : {
      82             :     OSL_ENSURE(nPos < nAlloc, "ScPageBreakData::GetData bumm");
      83             : 
      84           2 :     if ( nPos >= nUsed )
      85             :     {
      86             :         OSL_ENSURE(nPos == nUsed, "ScPageBreakData::GetData falsche Reihenfolge");
      87           2 :         nUsed = nPos+1;
      88             :     }
      89             : 
      90           2 :     return pData[nPos];
      91             : }
      92             : 
      93           0 : bool ScPageBreakData::operator==( const ScPageBreakData& rOther ) const
      94             : {
      95           0 :     if ( nUsed != rOther.nUsed )
      96           0 :         return false;
      97             : 
      98           0 :     for (sal_uInt16 i=0; i<nUsed; i++)
      99           0 :         if ( pData[i].GetPrintRange() != rOther.pData[i].GetPrintRange() )
     100           0 :             return false;
     101             : 
     102             :     //! ScPrintRangeData komplett vergleichen ??
     103             : 
     104           0 :     return true;
     105             : }
     106             : 
     107           0 : void ScPageBreakData::AddPages()
     108             : {
     109           0 :     if ( nUsed > 1 )
     110             :     {
     111           0 :         long nPage = pData[0].GetFirstPage();
     112           0 :         for (sal_uInt16 i=0; sal::static_int_cast<size_t>(i+1)<nUsed; i++)
     113             :         {
     114           0 :             nPage += ((long)pData[i].GetPagesX())*pData[i].GetPagesY();
     115           0 :             pData[i+1].SetFirstPage( nPage );
     116             :         }
     117             :     }
     118         228 : }
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10