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