LibreOffice Module sc (master)  1
prnsave.cxx
Go to the documentation of this file.
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 <address.hxx>
22 
23 #include <osl/diagnose.h>
24 
25 // Data per table
26 
28  mbEntireSheet(false)
29 {
30 }
31 
33 {
34  mpRepeatCol.reset();
35  mpRepeatRow.reset();
36 }
37 
38 void ScPrintSaverTab::SetAreas( const ScRangeVec& rRanges, bool bEntireSheet )
39 {
40  maPrintRanges = rRanges;
41  mbEntireSheet = bEntireSheet;
42 }
43 
44 void ScPrintSaverTab::SetRepeat( const ScRange* pCol, const ScRange* pRow )
45 {
46  mpRepeatCol.reset(pCol ? new ScRange(*pCol) : nullptr);
47  mpRepeatRow.reset(pRow ? new ScRange(*pRow) : nullptr);
48 }
49 
50 static bool PtrEqual( const ScRange* p1, const ScRange* p2 )
51 {
52  return ( !p1 && !p2 ) || ( p1 && p2 && *p1 == *p2 );
53 }
54 
56 {
57  return
58  PtrEqual( mpRepeatCol.get(), rCmp.mpRepeatCol.get() ) &&
59  PtrEqual( mpRepeatRow.get(), rCmp.mpRepeatRow.get() ) &&
60  (mbEntireSheet == rCmp.mbEntireSheet) &&
61  (maPrintRanges == rCmp.maPrintRanges);
62 }
63 
64 // Data for the whole document
65 
67  nTabCount( nCount )
68 {
69  if (nCount > 0)
70  pData.reset( new ScPrintSaverTab[nCount] );
71 }
72 
74 {
75 }
76 
78 {
79  OSL_ENSURE(nTab<nTabCount,"ScPrintRangeSaver Tab too big");
80  return pData[nTab];
81 }
82 
84 {
85  OSL_ENSURE(nTab<nTabCount,"ScPrintRangeSaver Tab too big");
86  return pData[nTab];
87 }
88 
90 {
91  bool bEqual = ( nTabCount == rCmp.nTabCount );
92  if (bEqual)
93  for (SCTAB i=0; i<nTabCount; i++)
94  if (!(pData[i]==rCmp.pData[i]))
95  {
96  bEqual = false;
97  break;
98  }
99  return bEqual;
100 }
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const ScPrintSaverTab &rCmp) const
Definition: prnsave.cxx:55
std::unique_ptr< ScRange > mpRepeatRow
single
Definition: prnsave.hxx:32
ScPrintRangeSaver(SCTAB nCount)
Definition: prnsave.cxx:66
bool operator==(const ScPrintRangeSaver &rCmp) const
Definition: prnsave.cxx:89
ScPrintSaverTab & GetTabData(SCTAB nTab)
Definition: prnsave.cxx:77
ScRangeVec maPrintRanges
Array.
Definition: prnsave.hxx:30
std::unique_ptr< ScPrintSaverTab[]> pData
Definition: prnsave.hxx:53
void SetRepeat(const ScRange *pCol, const ScRange *pRow)
Definition: prnsave.cxx:44
int i
std::unique_ptr< ScRange > mpRepeatCol
single
Definition: prnsave.hxx:31
static bool PtrEqual(const ScRange *p1, const ScRange *p2)
Definition: prnsave.cxx:50
::std::vector< ScRange > ScRangeVec
Definition: prnsave.hxx:28
sal_Int16 SCTAB
Definition: types.hxx:22
void SetAreas(const ScRangeVec &rRanges, bool bEntireSheet)
Definition: prnsave.cxx:38
bool mbEntireSheet
Definition: prnsave.hxx:33