xref: /aoo4110/main/sc/source/ui/inc/pfuncache.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_PFUNCACHE_HXX
25 #define SC_PFUNCACHE_HXX
26 
27 #include <vector>
28 #include <tools/gen.hxx>
29 #include "rangelst.hxx"
30 #include "printopt.hxx"
31 
32 class ScDocShell;
33 class ScMarkData;
34 
35 
36 /** Possible types of selection for print functions */
37 
38 enum ScPrintSelectionMode
39 {
40 	SC_PRINTSEL_INVALID,
41 	SC_PRINTSEL_DOCUMENT,
42 	SC_PRINTSEL_CURSOR,
43 	SC_PRINTSEL_RANGE,
44     SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
45 };
46 
47 
48 /** Stores the selection in the ScPrintFuncCache so it is only used
49 	for the same selection again. */
50 
51 class ScPrintSelectionStatus
52 {
53 	ScPrintSelectionMode	eMode;
54 	ScRangeList				aRanges;
55     ScPrintOptions          aOptions;
56 
57 public:
ScPrintSelectionStatus()58 			ScPrintSelectionStatus() : eMode(SC_PRINTSEL_INVALID) {}
~ScPrintSelectionStatus()59 			~ScPrintSelectionStatus() {}
60 
SetMode(ScPrintSelectionMode eNew)61 	void	SetMode(ScPrintSelectionMode eNew)	{ eMode = eNew; }
SetRanges(const ScRangeList & rNew)62 	void	SetRanges(const ScRangeList& rNew)	{ aRanges = rNew; }
SetOptions(const ScPrintOptions & rNew)63     void    SetOptions(const ScPrintOptions& rNew) { aOptions = rNew; }
64 
operator ==(const ScPrintSelectionStatus & rOther) const65 	sal_Bool	operator==(const ScPrintSelectionStatus& rOther) const
66             { return eMode == rOther.eMode && aRanges == rOther.aRanges && aOptions == rOther.aOptions; }
67 
GetMode() const68     ScPrintSelectionMode GetMode() const { return eMode; }
GetOptions() const69     const ScPrintOptions& GetOptions() const { return aOptions; }
70 };
71 
72 
73 /** The range that is printed on a page (excluding repeated columns/rows),
74     and its position on the page, used to find hyperlink targets. */
75 
76 struct ScPrintPageLocation
77 {
78     long        nPage;
79     ScRange     aCellRange;
80     Rectangle   aRectangle;     // pixels
81 
ScPrintPageLocationScPrintPageLocation82     ScPrintPageLocation() :
83         nPage(-1) {}            // default: invalid
84 
ScPrintPageLocationScPrintPageLocation85     ScPrintPageLocation( long nP, const ScRange& rRange, const Rectangle& rRect ) :
86         nPage(nP), aCellRange(rRange), aRectangle(rRect) {}
87 };
88 
89 
90 /** Stores the data for printing that is needed from several sheets,
91 	so it doesn't have to be calculated for rendering each page. */
92 
93 class ScPrintFuncCache
94 {
95 	ScPrintSelectionStatus	aSelection;
96 	ScDocShell*				pDocSh;
97 	long					nTotalPages;
98 	long					nPages[MAXTABCOUNT];
99 	long					nFirstAttr[MAXTABCOUNT];
100 	std::vector<ScPrintPageLocation> aLocations;
101 	bool                    bLocInitialized;
102 
103 public:
104 			ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
105 								const ScPrintSelectionStatus& rStatus );
106 			~ScPrintFuncCache();
107 
108 	sal_Bool	IsSameSelection( const ScPrintSelectionStatus& rStatus ) const;
109 
110     void    InitLocations( const ScMarkData& rMark, OutputDevice* pDev );
111     bool    FindLocation( const ScAddress& rCell, ScPrintPageLocation& rLocation ) const;
112 
GetPageCount() const113 	long	GetPageCount() const				{ return nTotalPages; }
GetFirstAttr(SCTAB nTab) const114 	long	GetFirstAttr( SCTAB nTab ) const	{ return nFirstAttr[nTab]; }
115 	SCTAB	GetTabForPage( long nPage ) const;
116 	long	GetTabStart( SCTAB nTab ) const;
117 	long	GetDisplayStart( SCTAB nTab ) const;
118 };
119 
120 #endif
121 
122