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 0 : ScPrintRangeData::ScPrintRangeData()
25 : {
26 0 : nPagesX = nPagesY = 0;
27 0 : pPageEndX = NULL;
28 0 : pPageEndY = NULL;
29 0 : bTopDown = bAutomatic = true;
30 0 : nFirstPage = 1;
31 0 : }
32 :
33 0 : ScPrintRangeData::~ScPrintRangeData()
34 : {
35 0 : delete[] pPageEndX;
36 0 : delete[] pPageEndY;
37 0 : }
38 :
39 0 : void ScPrintRangeData::SetPagesX( size_t nCount, const SCCOL* pData )
40 : {
41 0 : delete[] pPageEndX;
42 0 : if ( nCount )
43 : {
44 0 : pPageEndX = new SCCOL[nCount];
45 0 : memcpy( pPageEndX, pData, nCount * sizeof(SCCOL) );
46 : }
47 : else
48 0 : pPageEndX = NULL;
49 0 : nPagesX = nCount;
50 0 : }
51 :
52 0 : void ScPrintRangeData::SetPagesY( size_t nCount, const SCROW* pData )
53 : {
54 0 : delete[] pPageEndY;
55 0 : if ( nCount )
56 : {
57 0 : pPageEndY = new SCROW[nCount];
58 0 : memcpy( pPageEndY, pData, nCount * sizeof(SCROW) );
59 : }
60 : else
61 0 : pPageEndY = NULL;
62 0 : nPagesY = nCount;
63 0 : }
64 :
65 0 : ScPageBreakData::ScPageBreakData(size_t nMax)
66 : {
67 0 : nUsed = 0;
68 0 : if (nMax)
69 0 : pData = new ScPrintRangeData[nMax];
70 : else
71 0 : pData = NULL;
72 0 : nAlloc = nMax;
73 0 : }
74 :
75 0 : ScPageBreakData::~ScPageBreakData()
76 : {
77 0 : delete[] pData;
78 0 : }
79 :
80 0 : ScPrintRangeData& ScPageBreakData::GetData(size_t nPos)
81 : {
82 : OSL_ENSURE(nPos < nAlloc, "ScPageBreakData::GetData bumm");
83 :
84 0 : if ( nPos >= nUsed )
85 : {
86 : OSL_ENSURE(nPos == nUsed, "ScPageBreakData::GetData falsche Reihenfolge");
87 0 : nUsed = nPos+1;
88 : }
89 :
90 0 : 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 0 : }
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|