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 10*38d50f7bSAndrew Rist * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*38d50f7bSAndrew Rist * 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. 19*38d50f7bSAndrew Rist * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_PRINTFUN_HXX 25cdf0e10cSrcweir #define SC_PRINTFUN_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "pagepar.hxx" 29cdf0e10cSrcweir #include "editutil.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #ifndef _PRINT_HXX //autogen 32cdf0e10cSrcweir #include <vcl/print.hxx> 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir 35cdf0e10cSrcweir class SfxPrinter; 36cdf0e10cSrcweir class SfxProgress; 37cdf0e10cSrcweir class ScDocShell; 38cdf0e10cSrcweir class ScDocument; 39cdf0e10cSrcweir class ScViewData; 40cdf0e10cSrcweir class SfxItemSet; 41cdf0e10cSrcweir class ScPageHFItem; 42cdf0e10cSrcweir class EditTextObject; 43cdf0e10cSrcweir class MultiSelection; 44cdf0e10cSrcweir class ScHeaderEditEngine; 45cdf0e10cSrcweir class ScPageBreakData; 46cdf0e10cSrcweir class ScPreviewLocationData; 47cdf0e10cSrcweir class ScPrintOptions; 48cdf0e10cSrcweir class SvxBoxItem; 49cdf0e10cSrcweir class SvxBrushItem; 50cdf0e10cSrcweir class SvxShadowItem; 51cdf0e10cSrcweir class FmFormView; 52cdf0e10cSrcweir 53cdf0e10cSrcweir #define RANGENO_NORANGE USHRT_MAX 54cdf0e10cSrcweir 55cdf0e10cSrcweir #define PRINT_HEADER_WIDTH (1.0 * TWIPS_PER_CM) 56cdf0e10cSrcweir #define PRINT_HEADER_HEIGHT (12.8 * TWIPS_PER_POINT) 57cdf0e10cSrcweir #define PRINT_HEADER_FONTHEIGHT 200 58cdf0e10cSrcweir 59cdf0e10cSrcweir 60cdf0e10cSrcweir // Einstellungen fuer Kopf-/Fusszeilen 61cdf0e10cSrcweir struct ScPrintHFParam 62cdf0e10cSrcweir { 63cdf0e10cSrcweir sal_Bool bEnable; 64cdf0e10cSrcweir sal_Bool bDynamic; 65cdf0e10cSrcweir sal_Bool bShared; 66cdf0e10cSrcweir long nHeight; // insgesamt (Hoehe+Abstand+Rahmen) 67cdf0e10cSrcweir long nManHeight; // eingestellte Groesse (Min. bei dynamisch) 68cdf0e10cSrcweir sal_uInt16 nDistance; 69cdf0e10cSrcweir sal_uInt16 nLeft; // Raender 70cdf0e10cSrcweir sal_uInt16 nRight; 71cdf0e10cSrcweir const ScPageHFItem* pLeft; 72cdf0e10cSrcweir const ScPageHFItem* pRight; 73cdf0e10cSrcweir const SvxBoxItem* pBorder; 74cdf0e10cSrcweir const SvxBrushItem* pBack; 75cdf0e10cSrcweir const SvxShadowItem* pShadow; 76cdf0e10cSrcweir }; 77cdf0e10cSrcweir 78cdf0e10cSrcweir 79cdf0e10cSrcweir // "Ersatz" fuer SV-JobSetup: 80cdf0e10cSrcweir 81cdf0e10cSrcweir class ScJobSetup 82cdf0e10cSrcweir { 83cdf0e10cSrcweir public: 84cdf0e10cSrcweir ScJobSetup( SfxPrinter* pPrinter ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir Size aUserSize; 87cdf0e10cSrcweir MapMode aUserMapMode; 88cdf0e10cSrcweir Paper ePaper; 89cdf0e10cSrcweir Orientation eOrientation; 90cdf0e10cSrcweir sal_uInt16 nPaperBin; 91cdf0e10cSrcweir }; 92cdf0e10cSrcweir 93cdf0e10cSrcweir struct ScPrintState // Variablen aus ScPrintFunc retten 94cdf0e10cSrcweir { 95cdf0e10cSrcweir SCTAB nPrintTab; 96cdf0e10cSrcweir SCCOL nStartCol; 97cdf0e10cSrcweir SCROW nStartRow; 98cdf0e10cSrcweir SCCOL nEndCol; 99cdf0e10cSrcweir SCROW nEndRow; 100cdf0e10cSrcweir sal_uInt16 nZoom; 101cdf0e10cSrcweir size_t nPagesX; 102cdf0e10cSrcweir size_t nPagesY; 103cdf0e10cSrcweir long nTabPages; 104cdf0e10cSrcweir long nTotalPages; 105cdf0e10cSrcweir long nPageStart; 106cdf0e10cSrcweir long nDocPages; 107cdf0e10cSrcweir }; 108cdf0e10cSrcweir 109cdf0e10cSrcweir class ScPageRowEntry 110cdf0e10cSrcweir { 111cdf0e10cSrcweir private: 112cdf0e10cSrcweir SCROW nStartRow; 113cdf0e10cSrcweir SCROW nEndRow; 114cdf0e10cSrcweir size_t nPagesX; 115cdf0e10cSrcweir sal_Bool* pHidden; 116cdf0e10cSrcweir //! Anzahl wirklich sichtbarer cachen??? 117cdf0e10cSrcweir 118cdf0e10cSrcweir public: 119cdf0e10cSrcweir ScPageRowEntry() { nStartRow = nEndRow = 0; nPagesX = 0; pHidden = NULL; } 120cdf0e10cSrcweir ~ScPageRowEntry() { delete[] pHidden; } 121cdf0e10cSrcweir 122cdf0e10cSrcweir ScPageRowEntry(const ScPageRowEntry& r); 123cdf0e10cSrcweir const ScPageRowEntry& operator=(const ScPageRowEntry& r); 124cdf0e10cSrcweir 125cdf0e10cSrcweir SCROW GetStartRow() const { return nStartRow; } 126cdf0e10cSrcweir SCROW GetEndRow() const { return nEndRow; } 127cdf0e10cSrcweir size_t GetPagesX() const { return nPagesX; } 128cdf0e10cSrcweir void SetStartRow(SCROW n) { nStartRow = n; } 129cdf0e10cSrcweir void SetEndRow(SCROW n) { nEndRow = n; } 130cdf0e10cSrcweir 131cdf0e10cSrcweir void SetPagesX(size_t nNew); 132cdf0e10cSrcweir void SetHidden(size_t nX); 133cdf0e10cSrcweir sal_Bool IsHidden(size_t nX) const; 134cdf0e10cSrcweir 135cdf0e10cSrcweir size_t CountVisible() const; 136cdf0e10cSrcweir }; 137cdf0e10cSrcweir 138cdf0e10cSrcweir class ScPrintFunc 139cdf0e10cSrcweir { 140cdf0e10cSrcweir private: 141cdf0e10cSrcweir ScDocShell* pDocShell; 142cdf0e10cSrcweir ScDocument* pDoc; 143cdf0e10cSrcweir SfxPrinter* pPrinter; 144cdf0e10cSrcweir OutputDevice* pDev; 145cdf0e10cSrcweir FmFormView* pDrawView; 146cdf0e10cSrcweir 147cdf0e10cSrcweir MapMode aOldPrinterMode; // MapMode vor dem Aufruf 148cdf0e10cSrcweir 149cdf0e10cSrcweir Point aSrcOffset; // Papier-1/100 mm 150cdf0e10cSrcweir Point aOffset; // mit Faktor aus Seitenformat skaliert 151cdf0e10cSrcweir sal_uInt16 nManualZoom; // Zoom in Preview (Prozent) 152cdf0e10cSrcweir sal_Bool bClearWin; // Ausgabe vorher loeschen 153cdf0e10cSrcweir sal_Bool bUseStyleColor; 154cdf0e10cSrcweir sal_Bool bIsRender; 155cdf0e10cSrcweir 156cdf0e10cSrcweir SCTAB nPrintTab; 157cdf0e10cSrcweir long nPageStart; // Offset fuer erste Seite 158cdf0e10cSrcweir long nDocPages; // Seiten im Dokument 159cdf0e10cSrcweir 160cdf0e10cSrcweir const ScRange* pUserArea; // Selektion, wenn im Dialog eingestellt 161cdf0e10cSrcweir 162cdf0e10cSrcweir const SfxItemSet* pParamSet; // eingestellte Vorlage 163cdf0e10cSrcweir sal_Bool bState; // aus State-struct erzeugt 164cdf0e10cSrcweir 165cdf0e10cSrcweir // Parameter aus Vorlage: 166cdf0e10cSrcweir sal_uInt16 nLeftMargin; 167cdf0e10cSrcweir sal_uInt16 nTopMargin; 168cdf0e10cSrcweir sal_uInt16 nRightMargin; 169cdf0e10cSrcweir sal_uInt16 nBottomMargin; 170cdf0e10cSrcweir sal_Bool bCenterHor; 171cdf0e10cSrcweir sal_Bool bCenterVer; 172cdf0e10cSrcweir sal_Bool bLandscape; 173cdf0e10cSrcweir sal_Bool bSourceRangeValid; 174cdf0e10cSrcweir 175cdf0e10cSrcweir sal_uInt16 nPageUsage; 176cdf0e10cSrcweir Size aPageSize; // Drucker-Twips 177cdf0e10cSrcweir const SvxBoxItem* pBorderItem; 178cdf0e10cSrcweir const SvxBrushItem* pBackgroundItem; 179cdf0e10cSrcweir const SvxShadowItem* pShadowItem; 180cdf0e10cSrcweir 181cdf0e10cSrcweir ScRange aLastSourceRange; 182cdf0e10cSrcweir ScPrintHFParam aHdr; 183cdf0e10cSrcweir ScPrintHFParam aFtr; 184cdf0e10cSrcweir ScPageTableParam aTableParam; 185cdf0e10cSrcweir ScPageAreaParam aAreaParam; 186cdf0e10cSrcweir 187cdf0e10cSrcweir // berechnete Werte: 188cdf0e10cSrcweir sal_uInt16 nZoom; 189cdf0e10cSrcweir sal_Bool bPrintCurrentTable; 190cdf0e10cSrcweir sal_Bool bMultiArea; 191cdf0e10cSrcweir long nTabPages; 192cdf0e10cSrcweir long nTotalPages; 193cdf0e10cSrcweir 194cdf0e10cSrcweir Rectangle aPageRect; // Dokument-Twips 195cdf0e10cSrcweir 196cdf0e10cSrcweir MapMode aLogicMode; // in DoPrint gesetzt 197cdf0e10cSrcweir MapMode aOffsetMode; 198cdf0e10cSrcweir MapMode aTwipMode; 199cdf0e10cSrcweir double nScaleX; 200cdf0e10cSrcweir double nScaleY; 201cdf0e10cSrcweir 202cdf0e10cSrcweir SCCOL nRepeatStartCol; 203cdf0e10cSrcweir SCCOL nRepeatEndCol; 204cdf0e10cSrcweir SCROW nRepeatStartRow; 205cdf0e10cSrcweir SCROW nRepeatEndRow; 206cdf0e10cSrcweir 207cdf0e10cSrcweir SCCOL nStartCol; 208cdf0e10cSrcweir SCROW nStartRow; 209cdf0e10cSrcweir SCCOL nEndCol; 210cdf0e10cSrcweir SCROW nEndRow; 211cdf0e10cSrcweir 212cdf0e10cSrcweir SCCOL* pPageEndX; // Seitenaufteilung 213cdf0e10cSrcweir SCROW* pPageEndY; 214cdf0e10cSrcweir ScPageRowEntry* pPageRows; 215cdf0e10cSrcweir size_t nPagesX; 216cdf0e10cSrcweir size_t nPagesY; 217cdf0e10cSrcweir size_t nTotalY; 218cdf0e10cSrcweir 219cdf0e10cSrcweir ScHeaderEditEngine* pEditEngine; 220cdf0e10cSrcweir SfxItemSet* pEditDefaults; 221cdf0e10cSrcweir 222cdf0e10cSrcweir ScHeaderFieldData aFieldData; 223cdf0e10cSrcweir 224cdf0e10cSrcweir List aNotePosList; // Reihenfolge der Notizen 225cdf0e10cSrcweir 226cdf0e10cSrcweir ScPageBreakData* pPageData; // zum Eintragen der Umbrueche etc. 227cdf0e10cSrcweir 228cdf0e10cSrcweir public: 229cdf0e10cSrcweir ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab, 230cdf0e10cSrcweir long nPage = 0, long nDocP = 0, 231cdf0e10cSrcweir const ScRange* pArea = NULL, 232cdf0e10cSrcweir const ScPrintOptions* pOptions = NULL, 233cdf0e10cSrcweir ScPageBreakData* pData = NULL ); 234cdf0e10cSrcweir 235cdf0e10cSrcweir // ctors for device other than printer - for preview and pdf: 236cdf0e10cSrcweir 237cdf0e10cSrcweir ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab, 238cdf0e10cSrcweir long nPage = 0, long nDocP = 0, 239cdf0e10cSrcweir const ScRange* pArea = NULL, 240cdf0e10cSrcweir const ScPrintOptions* pOptions = NULL ); 241cdf0e10cSrcweir 242cdf0e10cSrcweir ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, 243cdf0e10cSrcweir const ScPrintState& rState, 244cdf0e10cSrcweir const ScPrintOptions* pOptions ); 245cdf0e10cSrcweir 246cdf0e10cSrcweir ~ScPrintFunc(); 247cdf0e10cSrcweir 248cdf0e10cSrcweir static void DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor, 249cdf0e10cSrcweir const Rectangle& rBound, ScViewData* pViewData, sal_Bool bMetaFile ); 250cdf0e10cSrcweir 251cdf0e10cSrcweir void SetDrawView( FmFormView* pNew ); 252cdf0e10cSrcweir 253cdf0e10cSrcweir void SetOffset( const Point& rOfs ); 254cdf0e10cSrcweir void SetManualZoom( sal_uInt16 nNewZoom ); 255cdf0e10cSrcweir void SetDateTime( const Date& rDate, const Time& rTime ); 256cdf0e10cSrcweir 257cdf0e10cSrcweir void SetClearFlag( sal_Bool bFlag ); 258cdf0e10cSrcweir void SetUseStyleColor( sal_Bool bFlag ); 259cdf0e10cSrcweir void SetRenderFlag( sal_Bool bFlag ); 260cdf0e10cSrcweir 261cdf0e10cSrcweir void SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents 262cdf0e10cSrcweir 263cdf0e10cSrcweir sal_Bool UpdatePages(); 264cdf0e10cSrcweir 265cdf0e10cSrcweir void ApplyPrintSettings(); // aus DoPrint() schon gerufen 266cdf0e10cSrcweir long DoPrint( const MultiSelection& rPageRanges, 267cdf0e10cSrcweir long nStartPage, long nDisplayStart, sal_Bool bDoPrint, 268cdf0e10cSrcweir ScPreviewLocationData* pLocationData ); 269cdf0e10cSrcweir 270cdf0e10cSrcweir // Werte abfragen - sofort 271cdf0e10cSrcweir 272cdf0e10cSrcweir Size GetPageSize() const { return aPageSize; } 273cdf0e10cSrcweir Size GetDataSize() const; 274cdf0e10cSrcweir void GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr ); 275cdf0e10cSrcweir long GetFirstPageNo() const { return aTableParam.nFirstPageNo; } 276cdf0e10cSrcweir 277cdf0e10cSrcweir // letzte Werte abfragen - nach DoPrint !!! 278cdf0e10cSrcweir 279cdf0e10cSrcweir double GetScaleX() const { return nScaleX; } 280cdf0e10cSrcweir double GetScaleY() const { return nScaleY; } 281cdf0e10cSrcweir long GetTotalPages() const { return nTotalPages; } 282cdf0e10cSrcweir sal_uInt16 GetZoom() const { return nZoom; } 283cdf0e10cSrcweir 284cdf0e10cSrcweir void ResetBreaks( SCTAB nTab ); 285cdf0e10cSrcweir 286cdf0e10cSrcweir void GetPrintState( ScPrintState& rState ); 287cdf0e10cSrcweir sal_Bool GetLastSourceRange( ScRange& rRange ) const; 288cdf0e10cSrcweir sal_uInt16 GetLeftMargin() const{return nLeftMargin;} 289cdf0e10cSrcweir sal_uInt16 GetRightMargin() const{return nRightMargin;} 290cdf0e10cSrcweir sal_uInt16 GetTopMargin() const{return nTopMargin;} 291cdf0e10cSrcweir sal_uInt16 GetBottomMargin() const{return nBottomMargin;} 292cdf0e10cSrcweir void SetLeftMargin(sal_uInt16 nRulerLeftDistance){ nLeftMargin = nRulerLeftDistance; } 293cdf0e10cSrcweir void SetRightMargin(sal_uInt16 nRulerRightDistance){ nRightMargin = nRulerRightDistance; } 294cdf0e10cSrcweir void SetTopMargin(sal_uInt16 nRulerTopDistance){ nTopMargin = nRulerTopDistance; } 295cdf0e10cSrcweir void SetBottomMargin(sal_uInt16 nRulerBottomDistance){ nBottomMargin = nRulerBottomDistance; } 296cdf0e10cSrcweir ScPrintHFParam GetHeader(){return aHdr;} 297cdf0e10cSrcweir ScPrintHFParam GetFooter(){return aFtr;} 298cdf0e10cSrcweir 299cdf0e10cSrcweir private: 300cdf0e10cSrcweir void Construct( const ScPrintOptions* pOptions ); 301cdf0e10cSrcweir void InitParam( const ScPrintOptions* pOptions ); 302cdf0e10cSrcweir void CalcZoom( sal_uInt16 nRangeNo ); 303cdf0e10cSrcweir void CalcPages(); 304cdf0e10cSrcweir long CountPages(); 305cdf0e10cSrcweir long CountNotePages(); 306cdf0e10cSrcweir 307cdf0e10cSrcweir sal_Bool AdjustPrintArea( sal_Bool bNew ); 308cdf0e10cSrcweir 309cdf0e10cSrcweir Size GetDocPageSize(); 310cdf0e10cSrcweir 311cdf0e10cSrcweir long TextHeight( const EditTextObject* pObject ); 312cdf0e10cSrcweir void MakeEditEngine(); 313cdf0e10cSrcweir void UpdateHFHeight( ScPrintHFParam& rParam ); 314cdf0e10cSrcweir 315cdf0e10cSrcweir void InitModes(); 316cdf0e10cSrcweir 317cdf0e10cSrcweir sal_Bool IsLeft( long nPageNo ); 318cdf0e10cSrcweir sal_Bool IsMirror( long nPageNo ); 319cdf0e10cSrcweir void ReplaceFields( long nPageNo ); // aendert Text in pEditEngine 320cdf0e10cSrcweir void MakeTableString(); // setzt aTableStr 321cdf0e10cSrcweir 322cdf0e10cSrcweir void PrintPage( long nPageNo, 323cdf0e10cSrcweir SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 324cdf0e10cSrcweir sal_Bool bDoPrint, ScPreviewLocationData* pLocationData ); 325cdf0e10cSrcweir void PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 326cdf0e10cSrcweir long nScrX, long nScrY, 327cdf0e10cSrcweir sal_Bool bShLeft, sal_Bool bShTop, sal_Bool bShRight, sal_Bool bShBottom ); 328cdf0e10cSrcweir void LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 329cdf0e10cSrcweir long nScrX, long nScrY, sal_Bool bRepCol, sal_Bool bRepRow, 330cdf0e10cSrcweir ScPreviewLocationData& rLocationData ); 331cdf0e10cSrcweir void PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY ); 332cdf0e10cSrcweir void PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY ); 333cdf0e10cSrcweir void LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY, 334cdf0e10cSrcweir sal_Bool bRepCol, ScPreviewLocationData& rLocationData ); 335cdf0e10cSrcweir void LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY, 336cdf0e10cSrcweir sal_Bool bRepRow, ScPreviewLocationData& rLocationData ); 337cdf0e10cSrcweir void PrintHF( long nPageNo, sal_Bool bHeader, long nStartY, 338cdf0e10cSrcweir sal_Bool bDoPrint, ScPreviewLocationData* pLocationData ); 339cdf0e10cSrcweir 340cdf0e10cSrcweir long PrintNotes( long nPageNo, long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData ); 341cdf0e10cSrcweir long DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData ); 342cdf0e10cSrcweir 343cdf0e10cSrcweir void DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH, 344cdf0e10cSrcweir const SvxBoxItem* pBorderData, 345cdf0e10cSrcweir const SvxBrushItem* pBackground, 346cdf0e10cSrcweir const SvxShadowItem* pShadow ); 347cdf0e10cSrcweir 348cdf0e10cSrcweir void FillPageData(); 349cdf0e10cSrcweir }; 350cdf0e10cSrcweir 351cdf0e10cSrcweir 352cdf0e10cSrcweir 353cdf0e10cSrcweir #endif 354cdf0e10cSrcweir 355