Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / docshell / pagedata.cxx
blob946b3e6c48c934d9305db51245a6d7e39420d417
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 //============================================================================
26 ScPrintRangeData::ScPrintRangeData()
28 nPagesX = nPagesY = 0;
29 pPageEndX = NULL;
30 pPageEndY = NULL;
31 bTopDown = bAutomatic = sal_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 //============================================================================
69 ScPageBreakData::ScPageBreakData(size_t nMax)
71 nUsed = 0;
72 if (nMax)
73 pData = new ScPrintRangeData[nMax];
74 else
75 pData = NULL;
76 nAlloc = nMax;
79 ScPageBreakData::~ScPageBreakData()
81 delete[] pData;
84 ScPrintRangeData& ScPageBreakData::GetData(size_t nPos)
86 OSL_ENSURE(nPos < nAlloc, "ScPageBreakData::GetData bumm");
88 if ( nPos >= nUsed )
90 OSL_ENSURE(nPos == nUsed, "ScPageBreakData::GetData falsche Reihenfolge");
91 nUsed = nPos+1;
94 return pData[nPos];
97 sal_Bool ScPageBreakData::IsEqual( const ScPageBreakData& rOther ) const
99 if ( nUsed != rOther.nUsed )
100 return false;
102 for (sal_uInt16 i=0; i<nUsed; i++)
103 if ( pData[i].GetPrintRange() != rOther.pData[i].GetPrintRange() )
104 return false;
106 //! ScPrintRangeData komplett vergleichen ??
108 return sal_True;
111 void ScPageBreakData::AddPages()
113 if ( nUsed > 1 )
115 long nPage = pData[0].GetFirstPage();
116 for (sal_uInt16 i=0; sal::static_int_cast<size_t>(i+1)<nUsed; i++)
118 nPage += ((long)pData[i].GetPagesX())*pData[i].GetPagesY();
119 pData[i+1].SetFirstPage( nPage );
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */