/src/libreoffice/sc/source/ui/docshell/pagedata.cxx
Line | Count | Source |
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 <algorithm> |
21 | | #include <string.h> |
22 | | |
23 | | #include <pagedata.hxx> |
24 | | |
25 | | #include <osl/diagnose.h> |
26 | | |
27 | | ScPrintRangeData::ScPrintRangeData() |
28 | 0 | { |
29 | 0 | bTopDown = bAutomatic = true; |
30 | 0 | nFirstPage = 1; |
31 | 0 | } |
32 | | |
33 | | ScPrintRangeData::~ScPrintRangeData() |
34 | 0 | { |
35 | 0 | } |
36 | | |
37 | | void ScPrintRangeData::SetPagesX( size_t nCount, const SCCOL* pData ) |
38 | 0 | { |
39 | 0 | mvPageEndX.resize( nCount ); |
40 | 0 | std::copy_n( pData, nCount, mvPageEndX.data() ); |
41 | 0 | } |
42 | | |
43 | | void ScPrintRangeData::SetPagesY( size_t nCount, const SCROW* pData ) |
44 | 0 | { |
45 | 0 | mvPageEndY.resize(nCount); |
46 | 0 | std::copy_n( pData, nCount, mvPageEndY.data() ); |
47 | 0 | } |
48 | | |
49 | | ScPageBreakData::ScPageBreakData(size_t nMax) |
50 | 0 | { |
51 | 0 | nUsed = 0; |
52 | 0 | if (nMax) |
53 | 0 | pData.reset( new ScPrintRangeData[nMax] ); |
54 | 0 | nAlloc = nMax; |
55 | 0 | } |
56 | | |
57 | | ScPageBreakData::~ScPageBreakData() |
58 | 0 | { |
59 | 0 | } |
60 | | |
61 | | ScPrintRangeData& ScPageBreakData::GetData(size_t nPos) |
62 | 0 | { |
63 | 0 | OSL_ENSURE(nPos < nAlloc, "ScPageBreakData::GetData bumm"); |
64 | |
|
65 | 0 | if ( nPos >= nUsed ) |
66 | 0 | { |
67 | 0 | OSL_ENSURE(nPos == nUsed, "ScPageBreakData::GetData wrong order"); |
68 | 0 | nUsed = nPos+1; |
69 | 0 | } |
70 | |
|
71 | 0 | return pData[nPos]; |
72 | 0 | } |
73 | | |
74 | | bool ScPageBreakData::operator==( const ScPageBreakData& rOther ) const |
75 | 0 | { |
76 | 0 | if ( nUsed != rOther.nUsed ) |
77 | 0 | return false; |
78 | | |
79 | 0 | for (size_t i=0; i<nUsed; i++) |
80 | 0 | if ( pData[i].GetPrintRange() != rOther.pData[i].GetPrintRange() ) |
81 | 0 | return false; |
82 | | |
83 | | //! compare ScPrintRangeData completely ?? |
84 | | |
85 | 0 | return true; |
86 | 0 | } |
87 | | |
88 | | void ScPageBreakData::AddPages() |
89 | 0 | { |
90 | 0 | if ( nUsed > 1 ) |
91 | 0 | { |
92 | 0 | tools::Long nPage = pData[0].GetFirstPage(); |
93 | 0 | for (size_t i=0; i+1<nUsed; i++) |
94 | 0 | { |
95 | 0 | nPage += static_cast<tools::Long>(pData[i].GetPagesX())*pData[i].GetPagesY(); |
96 | 0 | pData[i+1].SetFirstPage( nPage ); |
97 | 0 | } |
98 | 0 | } |
99 | 0 | } |
100 | | |
101 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |