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