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