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