1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include <tools/gen.hxx>
24 #include <rangelst.hxx>
25 #include <printopt.hxx>
31 /** Possible types of selection for print functions */
33 enum class ScPrintSelectionMode
39 RangeExclusivelyOleAndDrawObjects
42 /** Stores the selection in the ScPrintFuncCache so it is only used
43 for the same selection again. */
45 class ScPrintSelectionStatus
47 ScPrintSelectionMode eMode
;
49 ScPrintOptions aOptions
;
52 ScPrintSelectionStatus() : eMode(ScPrintSelectionMode::Invalid
) {}
54 void SetMode(ScPrintSelectionMode eNew
) { eMode
= eNew
; }
55 void SetRanges(const ScRangeList
& rNew
) { aRanges
= rNew
; }
56 void SetOptions(const ScPrintOptions
& rNew
) { aOptions
= rNew
; }
58 bool operator==(const ScPrintSelectionStatus
& rOther
) const
59 { return eMode
== rOther
.eMode
&& aRanges
== rOther
.aRanges
&& aOptions
== rOther
.aOptions
; }
61 ScPrintSelectionMode
GetMode() const { return eMode
; }
62 const ScPrintOptions
& GetOptions() const { return aOptions
; }
65 /** The range that is printed on a page (excluding repeated columns/rows),
66 and its position on the page, used to find hyperlink targets. */
68 struct ScPrintPageLocation
72 tools::Rectangle aRectangle
; // pixels
74 ScPrintPageLocation() :
75 nPage(-1) {} // default: invalid
77 ScPrintPageLocation( tools::Long nP
, const ScRange
& rRange
, const tools::Rectangle
& rRect
) :
78 nPage(nP
), aCellRange(rRange
), aRectangle(rRect
) {}
81 /** Stores the data for printing that is needed from several sheets,
82 so it doesn't have to be calculated for rendering each page. */
84 class ScPrintFuncCache
86 ScPrintSelectionStatus aSelection
;
88 tools::Long nTotalPages
;
89 std::vector
<tools::Long
> nPages
;
90 std::vector
<tools::Long
> nFirstAttr
;
91 std::vector
<ScPrintPageLocation
> aLocations
;
95 ScPrintFuncCache(ScDocShell
* pD
, const ScMarkData
& rMark
, ScPrintSelectionStatus aStatus
,
96 Size aPageSize
= {}, bool bLandscape
= false, bool bUse
= false);
99 bool IsSameSelection( const ScPrintSelectionStatus
& rStatus
) const;
101 void InitLocations( const ScMarkData
& rMark
, OutputDevice
* pDev
);
102 bool FindLocation( const ScAddress
& rCell
, ScPrintPageLocation
& rLocation
) const;
104 tools::Long
GetPageCount() const { return nTotalPages
; }
105 tools::Long
GetFirstAttr( SCTAB nTab
) const { return nFirstAttr
[nTab
]; }
106 SCTAB
GetTabForPage( tools::Long nPage
) const;
107 tools::Long
GetTabStart( SCTAB nTab
) const;
108 tools::Long
GetDisplayStart( SCTAB nTab
) const;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */