1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pfuncache.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_PFUNCACHE_HXX
32 #define SC_PFUNCACHE_HXX
35 #include <tools/gen.hxx>
36 #include "rangelst.hxx"
42 /** Possible types of selection for print functions */
44 enum ScPrintSelectionMode
50 SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
54 /** Stores the selection in the ScPrintFuncCache so it is only used
55 for the same selection again. */
57 class ScPrintSelectionStatus
59 ScPrintSelectionMode eMode
;
63 ScPrintSelectionStatus() : eMode(SC_PRINTSEL_INVALID
) {}
64 ~ScPrintSelectionStatus() {}
66 void SetMode(ScPrintSelectionMode eNew
) { eMode
= eNew
; }
67 void SetRanges(const ScRangeList
& rNew
) { aRanges
= rNew
; }
69 BOOL
operator==(const ScPrintSelectionStatus
& rOther
) const
70 { return eMode
== rOther
.eMode
&& aRanges
== rOther
.aRanges
; }
72 ScPrintSelectionMode
GetMode() const { return eMode
; }
76 /** The range that is printed on a page (excluding repeated columns/rows),
77 and its position on the page, used to find hyperlink targets. */
79 struct ScPrintPageLocation
83 Rectangle aRectangle
; // pixels
85 ScPrintPageLocation() :
86 nPage(-1) {} // default: invalid
88 ScPrintPageLocation( long nP
, const ScRange
& rRange
, const Rectangle
& rRect
) :
89 nPage(nP
), aCellRange(rRange
), aRectangle(rRect
) {}
93 /** Stores the data for printing that is needed from several sheets,
94 so it doesn't have to be calculated for rendering each page. */
96 class ScPrintFuncCache
98 ScPrintSelectionStatus aSelection
;
101 long nPages
[MAXTABCOUNT
];
102 long nFirstAttr
[MAXTABCOUNT
];
103 std::vector
<ScPrintPageLocation
> aLocations
;
104 bool bLocInitialized
;
107 ScPrintFuncCache( ScDocShell
* pD
, const ScMarkData
& rMark
,
108 const ScPrintSelectionStatus
& rStatus
);
111 BOOL
IsSameSelection( const ScPrintSelectionStatus
& rStatus
) const;
113 void InitLocations( const ScMarkData
& rMark
, OutputDevice
* pDev
);
114 bool FindLocation( const ScAddress
& rCell
, ScPrintPageLocation
& rLocation
) const;
116 long GetPageCount() const { return nTotalPages
; }
117 long GetFirstAttr( SCTAB nTab
) const { return nFirstAttr
[nTab
]; }
118 SCTAB
GetTabForPage( long nPage
) const;
119 long GetTabStart( SCTAB nTab
) const;
120 long GetDisplayStart( SCTAB nTab
) const;