xref: /aoo4110/main/sc/source/core/tool/prnsave.cxx (revision b1cdbd2c)
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 
29 // INCLUDE ---------------------------------------------------------------
30 
31 #include <tools/debug.hxx>
32 
33 #include "prnsave.hxx"
34 #include "global.hxx"
35 #include "address.hxx"
36 
37 // STATIC DATA -----------------------------------------------------------
38 
39 //------------------------------------------------------------------
40 
41 //
42 //		Daten pro Tabelle
43 //
44 
ScPrintSaverTab()45 ScPrintSaverTab::ScPrintSaverTab() :
46     mpRepeatCol(NULL),
47     mpRepeatRow(NULL),
48     mbEntireSheet(sal_False)
49 {
50 }
51 
~ScPrintSaverTab()52 ScPrintSaverTab::~ScPrintSaverTab()
53 {
54     delete mpRepeatCol;
55     delete mpRepeatRow;
56 }
57 
SetAreas(const ScRangeVec & rRanges,sal_Bool bEntireSheet)58 void ScPrintSaverTab::SetAreas( const ScRangeVec& rRanges, sal_Bool bEntireSheet )
59 {
60     maPrintRanges = rRanges;
61     mbEntireSheet = bEntireSheet;
62 }
63 
SetRepeat(const ScRange * pCol,const ScRange * pRow)64 void ScPrintSaverTab::SetRepeat( const ScRange* pCol, const ScRange* pRow )
65 {
66     delete mpRepeatCol;
67     mpRepeatCol = pCol ? new ScRange(*pCol) : NULL;
68     delete mpRepeatRow;
69     mpRepeatRow = pRow ? new ScRange(*pRow) : NULL;
70 }
71 
PtrEqual(const ScRange * p1,const ScRange * p2)72 inline sal_Bool PtrEqual( const ScRange* p1, const ScRange* p2 )
73 {
74 	return ( !p1 && !p2 ) || ( p1 && p2 && *p1 == *p2 );
75 }
76 
operator ==(const ScPrintSaverTab & rCmp) const77 sal_Bool ScPrintSaverTab::operator==( const ScPrintSaverTab& rCmp ) const
78 {
79     return
80         PtrEqual( mpRepeatCol, rCmp.mpRepeatCol ) &&
81         PtrEqual( mpRepeatRow, rCmp.mpRepeatRow ) &&
82         (mbEntireSheet == rCmp.mbEntireSheet) &&
83         (maPrintRanges == rCmp.maPrintRanges);
84 }
85 
86 //
87 //		Daten fuer das ganze Dokument
88 //
89 
ScPrintRangeSaver(SCTAB nCount)90 ScPrintRangeSaver::ScPrintRangeSaver( SCTAB nCount ) :
91 	nTabCount( nCount )
92 {
93 	if (nCount > 0)
94 		pData = new ScPrintSaverTab[nCount];
95 	else
96 		pData = NULL;
97 }
98 
~ScPrintRangeSaver()99 ScPrintRangeSaver::~ScPrintRangeSaver()
100 {
101 	delete[] pData;
102 }
103 
GetTabData(SCTAB nTab)104 ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB nTab)
105 {
106 	DBG_ASSERT(nTab<nTabCount,"ScPrintRangeSaver Tab zu gross");
107 	return pData[nTab];
108 }
109 
GetTabData(SCTAB nTab) const110 const ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB nTab) const
111 {
112 	DBG_ASSERT(nTab<nTabCount,"ScPrintRangeSaver Tab zu gross");
113 	return pData[nTab];
114 }
115 
operator ==(const ScPrintRangeSaver & rCmp) const116 sal_Bool ScPrintRangeSaver::operator==( const ScPrintRangeSaver& rCmp ) const
117 {
118 	sal_Bool bEqual = ( nTabCount == rCmp.nTabCount );
119 	if (bEqual)
120 		for (SCTAB i=0; i<nTabCount; i++)
121 			if (!(pData[i]==rCmp.pData[i]))
122 			{
123 				bEqual = sal_False;
124 				break;
125 			}
126 	return bEqual;
127 }
128 
129 
130 
131 
132