Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <string.h>
30 : :
31 : : #include "pagedata.hxx"
32 : :
33 : : //============================================================================
34 : :
35 : 0 : ScPrintRangeData::ScPrintRangeData()
36 : : {
37 : 0 : nPagesX = nPagesY = 0;
38 : 0 : pPageEndX = NULL;
39 : 0 : pPageEndY = NULL;
40 : 0 : bTopDown = bAutomatic = sal_True;
41 : 0 : nFirstPage = 1;
42 : 0 : }
43 : :
44 : 0 : ScPrintRangeData::~ScPrintRangeData()
45 : : {
46 [ # # ]: 0 : delete[] pPageEndX;
47 [ # # ]: 0 : delete[] pPageEndY;
48 : 0 : }
49 : :
50 : 0 : void ScPrintRangeData::SetPagesX( size_t nCount, const SCCOL* pData )
51 : : {
52 [ # # ]: 0 : delete[] pPageEndX;
53 [ # # ]: 0 : if ( nCount )
54 : : {
55 : 0 : pPageEndX = new SCCOL[nCount];
56 : 0 : memcpy( pPageEndX, pData, nCount * sizeof(SCCOL) );
57 : : }
58 : : else
59 : 0 : pPageEndX = NULL;
60 : 0 : nPagesX = nCount;
61 : 0 : }
62 : :
63 : 0 : void ScPrintRangeData::SetPagesY( size_t nCount, const SCROW* pData )
64 : : {
65 [ # # ]: 0 : delete[] pPageEndY;
66 [ # # ]: 0 : if ( nCount )
67 : : {
68 : 0 : pPageEndY = new SCROW[nCount];
69 : 0 : memcpy( pPageEndY, pData, nCount * sizeof(SCROW) );
70 : : }
71 : : else
72 : 0 : pPageEndY = NULL;
73 : 0 : nPagesY = nCount;
74 : 0 : }
75 : :
76 : : //============================================================================
77 : :
78 : 0 : ScPageBreakData::ScPageBreakData(size_t nMax)
79 : : {
80 : 0 : nUsed = 0;
81 [ # # ]: 0 : if (nMax)
82 [ # # ]: 0 : pData = new ScPrintRangeData[nMax];
83 : : else
84 : 0 : pData = NULL;
85 : 0 : nAlloc = nMax;
86 : 0 : }
87 : :
88 : 0 : ScPageBreakData::~ScPageBreakData()
89 : : {
90 [ # # ][ # # ]: 0 : delete[] pData;
91 : 0 : }
92 : :
93 : 0 : ScPrintRangeData& ScPageBreakData::GetData(size_t nPos)
94 : : {
95 : : OSL_ENSURE(nPos < nAlloc, "ScPageBreakData::GetData bumm");
96 : :
97 [ # # ]: 0 : if ( nPos >= nUsed )
98 : : {
99 : : OSL_ENSURE(nPos == nUsed, "ScPageBreakData::GetData falsche Reihenfolge");
100 : 0 : nUsed = nPos+1;
101 : : }
102 : :
103 : 0 : return pData[nPos];
104 : : }
105 : :
106 : 0 : sal_Bool ScPageBreakData::IsEqual( const ScPageBreakData& rOther ) const
107 : : {
108 [ # # ]: 0 : if ( nUsed != rOther.nUsed )
109 : 0 : return false;
110 : :
111 [ # # ]: 0 : for (sal_uInt16 i=0; i<nUsed; i++)
112 [ # # ]: 0 : if ( pData[i].GetPrintRange() != rOther.pData[i].GetPrintRange() )
113 : 0 : return false;
114 : :
115 : : //! ScPrintRangeData komplett vergleichen ??
116 : :
117 : 0 : return sal_True;
118 : : }
119 : :
120 : 0 : void ScPageBreakData::AddPages()
121 : : {
122 [ # # ]: 0 : if ( nUsed > 1 )
123 : : {
124 : 0 : long nPage = pData[0].GetFirstPage();
125 [ # # ]: 0 : for (sal_uInt16 i=0; sal::static_int_cast<size_t>(i+1)<nUsed; i++)
126 : : {
127 : 0 : nPage += ((long)pData[i].GetPagesX())*pData[i].GetPagesY();
128 : 0 : pData[i+1].SetFirstPage( nPage );
129 : : }
130 : : }
131 : 0 : }
132 : :
133 : :
134 : :
135 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|