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 : #include <osl/diagnose.h>
25 :
26 1 : ScPrintRangeData::ScPrintRangeData()
27 : {
28 1 : nPagesX = nPagesY = 0;
29 1 : pPageEndX = NULL;
30 1 : pPageEndY = NULL;
31 1 : bTopDown = bAutomatic = 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 1 : ScPageBreakData::ScPageBreakData(size_t nMax)
68 : {
69 1 : nUsed = 0;
70 1 : if (nMax)
71 1 : pData = new ScPrintRangeData[nMax];
72 : else
73 0 : pData = NULL;
74 1 : nAlloc = nMax;
75 1 : }
76 :
77 1 : ScPageBreakData::~ScPageBreakData()
78 : {
79 1 : delete[] pData;
80 1 : }
81 :
82 1 : ScPrintRangeData& ScPageBreakData::GetData(size_t nPos)
83 : {
84 : OSL_ENSURE(nPos < nAlloc, "ScPageBreakData::GetData bumm");
85 :
86 1 : if ( nPos >= nUsed )
87 : {
88 : OSL_ENSURE(nPos == nUsed, "ScPageBreakData::GetData falsche Reihenfolge");
89 1 : nUsed = nPos+1;
90 : }
91 :
92 1 : return pData[nPos];
93 : }
94 :
95 0 : bool ScPageBreakData::operator==( const ScPageBreakData& rOther ) const
96 : {
97 0 : if ( nUsed != rOther.nUsed )
98 0 : return false;
99 :
100 0 : for (size_t i=0; i<nUsed; i++)
101 0 : if ( pData[i].GetPrintRange() != rOther.pData[i].GetPrintRange() )
102 0 : return false;
103 :
104 : //! ScPrintRangeData komplett vergleichen ??
105 :
106 0 : return true;
107 : }
108 :
109 0 : void ScPageBreakData::AddPages()
110 : {
111 0 : if ( nUsed > 1 )
112 : {
113 0 : long nPage = pData[0].GetFirstPage();
114 0 : for (size_t i=0; i+1<nUsed; i++)
115 : {
116 0 : nPage += ((long)pData[i].GetPagesX())*pData[i].GetPagesY();
117 0 : pData[i+1].SetFirstPage( nPage );
118 : }
119 : }
120 156 : }
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|