1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sc.hxx" 26 27 28 #include <string.h> 29 #include <tools/debug.hxx> 30 31 32 #include "pagedata.hxx" 33 34 //============================================================================ 35 36 ScPrintRangeData::ScPrintRangeData() 37 { 38 nPagesX = nPagesY = 0; 39 pPageEndX = NULL; 40 pPageEndY = NULL; 41 bTopDown = bAutomatic = sal_True; 42 nFirstPage = 1; 43 } 44 45 ScPrintRangeData::~ScPrintRangeData() 46 { 47 delete[] pPageEndX; 48 delete[] pPageEndY; 49 } 50 51 void ScPrintRangeData::SetPagesX( size_t nCount, const SCCOL* pData ) 52 { 53 delete[] pPageEndX; 54 if ( nCount ) 55 { 56 pPageEndX = new SCCOL[nCount]; 57 memcpy( pPageEndX, pData, nCount * sizeof(SCCOL) ); 58 } 59 else 60 pPageEndX = NULL; 61 nPagesX = nCount; 62 } 63 64 void ScPrintRangeData::SetPagesY( size_t nCount, const SCROW* pData ) 65 { 66 delete[] pPageEndY; 67 if ( nCount ) 68 { 69 pPageEndY = new SCROW[nCount]; 70 memcpy( pPageEndY, pData, nCount * sizeof(SCROW) ); 71 } 72 else 73 pPageEndY = NULL; 74 nPagesY = nCount; 75 } 76 77 //============================================================================ 78 79 ScPageBreakData::ScPageBreakData(size_t nMax) 80 { 81 nUsed = 0; 82 if (nMax) 83 pData = new ScPrintRangeData[nMax]; 84 else 85 pData = NULL; 86 nAlloc = nMax; 87 } 88 89 ScPageBreakData::~ScPageBreakData() 90 { 91 delete[] pData; 92 } 93 94 ScPrintRangeData& ScPageBreakData::GetData(size_t nPos) 95 { 96 DBG_ASSERT(nPos < nAlloc, "ScPageBreakData::GetData bumm"); 97 98 if ( nPos >= nUsed ) 99 { 100 DBG_ASSERT(nPos == nUsed, "ScPageBreakData::GetData falsche Reihenfolge"); 101 nUsed = nPos+1; 102 } 103 104 return pData[nPos]; 105 } 106 107 sal_Bool ScPageBreakData::IsEqual( const ScPageBreakData& rOther ) const 108 { 109 if ( nUsed != rOther.nUsed ) 110 return sal_False; 111 112 for (sal_uInt16 i=0; i<nUsed; i++) 113 if ( pData[i].GetPrintRange() != rOther.pData[i].GetPrintRange() ) 114 return sal_False; 115 116 //! ScPrintRangeData komplett vergleichen ?? 117 118 return sal_True; 119 } 120 121 void ScPageBreakData::AddPages() 122 { 123 if ( nUsed > 1 ) 124 { 125 long nPage = pData[0].GetFirstPage(); 126 for (sal_uInt16 i=0; sal::static_int_cast<size_t>(i+1)<nUsed; i++) 127 { 128 nPage += ((long)pData[i].GetPagesX())*pData[i].GetPagesY(); 129 pData[i+1].SetFirstPage( nPage ); 130 } 131 } 132 } 133 134 135 136