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

Generated by: LCOV version 1.10