Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / inc / prnsave.hxx
blob9d10b430d4c650daa7ca9ea0a41fce90d63815bc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include "address.hxx"
23 #include <optional>
24 #include <memory>
25 #include <vector>
27 namespace tools { class JsonWriter; }
29 class ScPrintSaverTab
31 typedef ::std::vector< ScRange > ScRangeVec;
33 ScRangeVec maPrintRanges; ///< Array
34 std::optional<ScRange> moRepeatCol; ///< single
35 std::optional<ScRange> moRepeatRow; ///< single
36 bool mbEntireSheet;
38 public:
39 ScPrintSaverTab();
40 ~ScPrintSaverTab();
42 void SetAreas( ScRangeVec&& rRanges, bool bEntireSheet );
43 void SetRepeat( std::optional<ScRange> oCol, std::optional<ScRange> oRow );
45 const ScRangeVec& GetPrintRanges() const { return maPrintRanges; }
46 bool IsEntireSheet() const { return mbEntireSheet; }
47 const std::optional<ScRange>& GetRepeatCol() const { return moRepeatCol; }
48 const std::optional<ScRange>& GetRepeatRow() const { return moRepeatRow; }
50 bool operator==( const ScPrintSaverTab& rCmp ) const;
53 class ScPrintRangeSaver
55 SCTAB nTabCount;
56 std::unique_ptr<ScPrintSaverTab[]> pData;
58 public:
59 ScPrintRangeSaver( SCTAB nCount );
60 ~ScPrintRangeSaver();
62 SCTAB GetTabCount() const { return nTabCount; }
63 ScPrintSaverTab& GetTabData(SCTAB nTab);
64 const ScPrintSaverTab& GetTabData(SCTAB nTab) const;
65 void GetPrintRangesInfo(tools::JsonWriter& rPrintRanges) const;
67 bool operator==( const ScPrintRangeSaver& rCmp ) const;
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */