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 "prnsave.hxx"
21 : #include "global.hxx"
22 : #include "address.hxx"
23 :
24 : // STATIC DATA
25 :
26 : // Daten pro Tabelle
27 :
28 388 : ScPrintSaverTab::ScPrintSaverTab() :
29 : mpRepeatCol(NULL),
30 : mpRepeatRow(NULL),
31 388 : mbEntireSheet(false)
32 : {
33 388 : }
34 :
35 776 : ScPrintSaverTab::~ScPrintSaverTab()
36 : {
37 388 : delete mpRepeatCol;
38 388 : delete mpRepeatRow;
39 388 : }
40 :
41 388 : void ScPrintSaverTab::SetAreas( const ScRangeVec& rRanges, bool bEntireSheet )
42 : {
43 388 : maPrintRanges = rRanges;
44 388 : mbEntireSheet = bEntireSheet;
45 388 : }
46 :
47 388 : void ScPrintSaverTab::SetRepeat( const ScRange* pCol, const ScRange* pRow )
48 : {
49 388 : delete mpRepeatCol;
50 388 : mpRepeatCol = pCol ? new ScRange(*pCol) : NULL;
51 388 : delete mpRepeatRow;
52 388 : mpRepeatRow = pRow ? new ScRange(*pRow) : NULL;
53 388 : }
54 :
55 220 : inline bool PtrEqual( const ScRange* p1, const ScRange* p2 )
56 : {
57 220 : return ( !p1 && !p2 ) || ( p1 && p2 && *p1 == *p2 );
58 : }
59 :
60 110 : bool ScPrintSaverTab::operator==( const ScPrintSaverTab& rCmp ) const
61 : {
62 : return
63 220 : PtrEqual( mpRepeatCol, rCmp.mpRepeatCol ) &&
64 220 : PtrEqual( mpRepeatRow, rCmp.mpRepeatRow ) &&
65 330 : (mbEntireSheet == rCmp.mbEntireSheet) &&
66 220 : (maPrintRanges == rCmp.maPrintRanges);
67 : }
68 :
69 : // Daten fuer das ganze Dokument
70 :
71 260 : ScPrintRangeSaver::ScPrintRangeSaver( SCTAB nCount ) :
72 260 : nTabCount( nCount )
73 : {
74 260 : if (nCount > 0)
75 260 : pData = new ScPrintSaverTab[nCount];
76 : else
77 0 : pData = NULL;
78 260 : }
79 :
80 260 : ScPrintRangeSaver::~ScPrintRangeSaver()
81 : {
82 260 : delete[] pData;
83 260 : }
84 :
85 388 : ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB nTab)
86 : {
87 : OSL_ENSURE(nTab<nTabCount,"ScPrintRangeSaver Tab too big");
88 388 : return pData[nTab];
89 : }
90 :
91 8 : const ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB nTab) const
92 : {
93 : OSL_ENSURE(nTab<nTabCount,"ScPrintRangeSaver Tab too big");
94 8 : return pData[nTab];
95 : }
96 :
97 122 : bool ScPrintRangeSaver::operator==( const ScPrintRangeSaver& rCmp ) const
98 : {
99 122 : bool bEqual = ( nTabCount == rCmp.nTabCount );
100 122 : if (bEqual)
101 192 : for (SCTAB i=0; i<nTabCount; i++)
102 110 : if (!(pData[i]==rCmp.pData[i]))
103 : {
104 0 : bEqual = false;
105 0 : break;
106 : }
107 122 : return bEqual;
108 228 : }
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|