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