Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_PFUNCACHE_HXX
30 : : #define SC_PFUNCACHE_HXX
31 : :
32 : : #include <vector>
33 : : #include <tools/gen.hxx>
34 : : #include "rangelst.hxx"
35 : : #include "printopt.hxx"
36 : :
37 : : class ScDocShell;
38 : : class ScMarkData;
39 : :
40 : :
41 : : /** Possible types of selection for print functions */
42 : :
43 : : enum ScPrintSelectionMode
44 : : {
45 : : SC_PRINTSEL_INVALID,
46 : : SC_PRINTSEL_DOCUMENT,
47 : : SC_PRINTSEL_CURSOR,
48 : : SC_PRINTSEL_RANGE,
49 : : SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
50 : : };
51 : :
52 : :
53 : : /** Stores the selection in the ScPrintFuncCache so it is only used
54 : : for the same selection again. */
55 : :
56 [ # # ]: 0 : class ScPrintSelectionStatus
57 : : {
58 : : ScPrintSelectionMode eMode;
59 : : ScRangeList aRanges;
60 : : ScPrintOptions aOptions;
61 : :
62 : : public:
63 [ # # ]: 0 : ScPrintSelectionStatus() : eMode(SC_PRINTSEL_INVALID) {}
64 [ # # ]: 0 : ~ScPrintSelectionStatus() {}
65 : :
66 : 0 : void SetMode(ScPrintSelectionMode eNew) { eMode = eNew; }
67 : 0 : void SetRanges(const ScRangeList& rNew) { aRanges = rNew; }
68 : 0 : void SetOptions(const ScPrintOptions& rNew) { aOptions = rNew; }
69 : :
70 : 0 : sal_Bool operator==(const ScPrintSelectionStatus& rOther) const
71 [ # # ][ # # ]: 0 : { return eMode == rOther.eMode && aRanges == rOther.aRanges && aOptions == rOther.aOptions; }
[ # # ]
72 : :
73 : 0 : ScPrintSelectionMode GetMode() const { return eMode; }
74 : 0 : const ScPrintOptions& GetOptions() const { return aOptions; }
75 : : };
76 : :
77 : :
78 : : /** The range that is printed on a page (excluding repeated columns/rows),
79 : : and its position on the page, used to find hyperlink targets. */
80 : :
81 : 0 : struct ScPrintPageLocation
82 : : {
83 : : long nPage;
84 : : ScRange aCellRange;
85 : : Rectangle aRectangle; // pixels
86 : :
87 : 0 : ScPrintPageLocation() :
88 : 0 : nPage(-1) {} // default: invalid
89 : :
90 : 0 : ScPrintPageLocation( long nP, const ScRange& rRange, const Rectangle& rRect ) :
91 : 0 : nPage(nP), aCellRange(rRange), aRectangle(rRect) {}
92 : : };
93 : :
94 : :
95 : : /** Stores the data for printing that is needed from several sheets,
96 : : so it doesn't have to be calculated for rendering each page. */
97 : :
98 : : class ScPrintFuncCache
99 : : {
100 : : ScPrintSelectionStatus aSelection;
101 : : ScDocShell* pDocSh;
102 : : long nTotalPages;
103 : : std::vector<long> nPages;
104 : : std::vector<long> nFirstAttr;
105 : : std::vector<ScPrintPageLocation> aLocations;
106 : : bool bLocInitialized;
107 : :
108 : : public:
109 : : ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
110 : : const ScPrintSelectionStatus& rStatus );
111 : : ~ScPrintFuncCache();
112 : :
113 : : sal_Bool IsSameSelection( const ScPrintSelectionStatus& rStatus ) const;
114 : :
115 : : void InitLocations( const ScMarkData& rMark, OutputDevice* pDev );
116 : : bool FindLocation( const ScAddress& rCell, ScPrintPageLocation& rLocation ) const;
117 : :
118 : 0 : long GetPageCount() const { return nTotalPages; }
119 : 0 : long GetFirstAttr( SCTAB nTab ) const { return nFirstAttr[nTab]; }
120 : : SCTAB GetTabForPage( long nPage ) const;
121 : : long GetTabStart( SCTAB nTab ) const;
122 : : long GetDisplayStart( SCTAB nTab ) const;
123 : : };
124 : :
125 : : #endif
126 : :
127 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|