fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / docshell / pagedata.cxx
blob883bd09d1357aee6e49e54e34980563bd42b32d3
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 .
20 #include <string.h>
22 #include "pagedata.hxx"
24 #include <osl/diagnose.h>
26 ScPrintRangeData::ScPrintRangeData()
28 nPagesX = nPagesY = 0;
29 pPageEndX = NULL;
30 pPageEndY = NULL;
31 bTopDown = bAutomatic = true;
32 nFirstPage = 1;
35 ScPrintRangeData::~ScPrintRangeData()
37 delete[] pPageEndX;
38 delete[] pPageEndY;
41 void ScPrintRangeData::SetPagesX( size_t nCount, const SCCOL* pData )
43 delete[] pPageEndX;
44 if ( nCount )
46 pPageEndX = new SCCOL[nCount];
47 memcpy( pPageEndX, pData, nCount * sizeof(SCCOL) );
49 else
50 pPageEndX = NULL;
51 nPagesX = nCount;
54 void ScPrintRangeData::SetPagesY( size_t nCount, const SCROW* pData )
56 delete[] pPageEndY;
57 if ( nCount )
59 pPageEndY = new SCROW[nCount];
60 memcpy( pPageEndY, pData, nCount * sizeof(SCROW) );
62 else
63 pPageEndY = NULL;
64 nPagesY = nCount;
67 ScPageBreakData::ScPageBreakData(size_t nMax)
69 nUsed = 0;
70 if (nMax)
71 pData = new ScPrintRangeData[nMax];
72 else
73 pData = NULL;
74 nAlloc = nMax;
77 ScPageBreakData::~ScPageBreakData()
79 delete[] pData;
82 ScPrintRangeData& ScPageBreakData::GetData(size_t nPos)
84 OSL_ENSURE(nPos < nAlloc, "ScPageBreakData::GetData bumm");
86 if ( nPos >= nUsed )
88 OSL_ENSURE(nPos == nUsed, "ScPageBreakData::GetData falsche Reihenfolge");
89 nUsed = nPos+1;
92 return pData[nPos];
95 bool ScPageBreakData::operator==( const ScPageBreakData& rOther ) const
97 if ( nUsed != rOther.nUsed )
98 return false;
100 for (sal_uInt16 i=0; i<nUsed; i++)
101 if ( pData[i].GetPrintRange() != rOther.pData[i].GetPrintRange() )
102 return false;
104 //! ScPrintRangeData komplett vergleichen ??
106 return true;
109 void ScPageBreakData::AddPages()
111 if ( nUsed > 1 )
113 long nPage = pData[0].GetFirstPage();
114 for (sal_uInt16 i=0; sal::static_int_cast<size_t>(i+1)<nUsed; i++)
116 nPage += ((long)pData[i].GetPagesX())*pData[i].GetPagesY();
117 pData[i+1].SetFirstPage( nPage );
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */