Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / pfuncache.hxx
blobeeba9c238097a6c0ec33c992aadfc22e1e2cfda0
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 #ifndef SC_PFUNCACHE_HXX
21 #define SC_PFUNCACHE_HXX
23 #include <vector>
24 #include <tools/gen.hxx>
25 #include "rangelst.hxx"
26 #include "printopt.hxx"
28 class ScDocShell;
29 class ScMarkData;
32 /** Possible types of selection for print functions */
34 enum ScPrintSelectionMode
36 SC_PRINTSEL_INVALID,
37 SC_PRINTSEL_DOCUMENT,
38 SC_PRINTSEL_CURSOR,
39 SC_PRINTSEL_RANGE,
40 SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
44 /** Stores the selection in the ScPrintFuncCache so it is only used
45 for the same selection again. */
47 class ScPrintSelectionStatus
49 ScPrintSelectionMode eMode;
50 ScRangeList aRanges;
51 ScPrintOptions aOptions;
53 public:
54 ScPrintSelectionStatus() : eMode(SC_PRINTSEL_INVALID) {}
55 ~ScPrintSelectionStatus() {}
57 void SetMode(ScPrintSelectionMode eNew) { eMode = eNew; }
58 void SetRanges(const ScRangeList& rNew) { aRanges = rNew; }
59 void SetOptions(const ScPrintOptions& rNew) { aOptions = rNew; }
61 sal_Bool operator==(const ScPrintSelectionStatus& rOther) const
62 { return eMode == rOther.eMode && aRanges == rOther.aRanges && aOptions == rOther.aOptions; }
64 ScPrintSelectionMode GetMode() const { return eMode; }
65 const ScPrintOptions& GetOptions() const { return aOptions; }
69 /** The range that is printed on a page (excluding repeated columns/rows),
70 and its position on the page, used to find hyperlink targets. */
72 struct ScPrintPageLocation
74 long nPage;
75 ScRange aCellRange;
76 Rectangle aRectangle; // pixels
78 ScPrintPageLocation() :
79 nPage(-1) {} // default: invalid
81 ScPrintPageLocation( long nP, const ScRange& rRange, const Rectangle& rRect ) :
82 nPage(nP), aCellRange(rRange), aRectangle(rRect) {}
86 /** Stores the data for printing that is needed from several sheets,
87 so it doesn't have to be calculated for rendering each page. */
89 class ScPrintFuncCache
91 ScPrintSelectionStatus aSelection;
92 ScDocShell* pDocSh;
93 long nTotalPages;
94 std::vector<long> nPages;
95 std::vector<long> nFirstAttr;
96 std::vector<ScPrintPageLocation> aLocations;
97 bool bLocInitialized;
99 public:
100 ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
101 const ScPrintSelectionStatus& rStatus );
102 ~ScPrintFuncCache();
104 sal_Bool IsSameSelection( const ScPrintSelectionStatus& rStatus ) const;
106 void InitLocations( const ScMarkData& rMark, OutputDevice* pDev );
107 bool FindLocation( const ScAddress& rCell, ScPrintPageLocation& rLocation ) const;
109 long GetPageCount() const { return nTotalPages; }
110 long GetFirstAttr( SCTAB nTab ) const { return nFirstAttr[nTab]; }
111 SCTAB GetTabForPage( long nPage ) const;
112 long GetTabStart( SCTAB nTab ) const;
113 long GetDisplayStart( SCTAB nTab ) const;
116 #endif
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */