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