xref: /aoo41x/main/sc/source/core/tool/prnsave.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 // INCLUDE ---------------------------------------------------------------
34 
35 #include <tools/debug.hxx>
36 
37 #include "prnsave.hxx"
38 #include "global.hxx"
39 #include "address.hxx"
40 
41 // STATIC DATA -----------------------------------------------------------
42 
43 //------------------------------------------------------------------
44 
45 //
46 //		Daten pro Tabelle
47 //
48 
49 ScPrintSaverTab::ScPrintSaverTab() :
50     mpRepeatCol(NULL),
51     mpRepeatRow(NULL),
52     mbEntireSheet(sal_False)
53 {
54 }
55 
56 ScPrintSaverTab::~ScPrintSaverTab()
57 {
58     delete mpRepeatCol;
59     delete mpRepeatRow;
60 }
61 
62 void ScPrintSaverTab::SetAreas( const ScRangeVec& rRanges, sal_Bool bEntireSheet )
63 {
64     maPrintRanges = rRanges;
65     mbEntireSheet = bEntireSheet;
66 }
67 
68 void ScPrintSaverTab::SetRepeat( const ScRange* pCol, const ScRange* pRow )
69 {
70     delete mpRepeatCol;
71     mpRepeatCol = pCol ? new ScRange(*pCol) : NULL;
72     delete mpRepeatRow;
73     mpRepeatRow = pRow ? new ScRange(*pRow) : NULL;
74 }
75 
76 inline sal_Bool PtrEqual( const ScRange* p1, const ScRange* p2 )
77 {
78 	return ( !p1 && !p2 ) || ( p1 && p2 && *p1 == *p2 );
79 }
80 
81 sal_Bool ScPrintSaverTab::operator==( const ScPrintSaverTab& rCmp ) const
82 {
83     return
84         PtrEqual( mpRepeatCol, rCmp.mpRepeatCol ) &&
85         PtrEqual( mpRepeatRow, rCmp.mpRepeatRow ) &&
86         (mbEntireSheet == rCmp.mbEntireSheet) &&
87         (maPrintRanges == rCmp.maPrintRanges);
88 }
89 
90 //
91 //		Daten fuer das ganze Dokument
92 //
93 
94 ScPrintRangeSaver::ScPrintRangeSaver( SCTAB nCount ) :
95 	nTabCount( nCount )
96 {
97 	if (nCount > 0)
98 		pData = new ScPrintSaverTab[nCount];
99 	else
100 		pData = NULL;
101 }
102 
103 ScPrintRangeSaver::~ScPrintRangeSaver()
104 {
105 	delete[] pData;
106 }
107 
108 ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB nTab)
109 {
110 	DBG_ASSERT(nTab<nTabCount,"ScPrintRangeSaver Tab zu gross");
111 	return pData[nTab];
112 }
113 
114 const ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB nTab) const
115 {
116 	DBG_ASSERT(nTab<nTabCount,"ScPrintRangeSaver Tab zu gross");
117 	return pData[nTab];
118 }
119 
120 sal_Bool ScPrintRangeSaver::operator==( const ScPrintRangeSaver& rCmp ) const
121 {
122 	sal_Bool bEqual = ( nTabCount == rCmp.nTabCount );
123 	if (bEqual)
124 		for (SCTAB i=0; i<nTabCount; i++)
125 			if (!(pData[i]==rCmp.pData[i]))
126 			{
127 				bEqual = sal_False;
128 				break;
129 			}
130 	return bEqual;
131 }
132 
133 
134 
135 
136