Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / output.hxx
blob03952a8f791136e309b6e85ecb314cf88e19906d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SC_OUTPUT_HXX
21 #define SC_OUTPUT_HXX
23 #include "address.hxx"
24 #include "cellvalue.hxx"
25 #include <tools/color.hxx>
26 #include <tools/fract.hxx>
27 #include <com/sun/star/embed/XEmbeddedObject.hpp>
28 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
30 namespace sc {
31 struct SpellCheckContext;
34 namespace editeng {
35 struct MisspellRanges;
38 class Rectangle;
39 class Font;
40 class OutputDevice;
41 class EditEngine;
42 class ScDocument;
43 class ScPatternAttr;
44 class SdrObject;
45 struct RowInfo;
46 struct ScTableInfo;
47 class ScTabViewShell;
48 class ScPageBreakData;
49 class FmFormView;
50 class ScFieldEditEngine;
51 class SdrPaintWindow;
53 // ---------------------------------------------------------------------------
55 #define SC_SCENARIO_HSPACE 60
56 #define SC_SCENARIO_VSPACE 50
58 // ---------------------------------------------------------------------------
60 enum ScOutputType { OUTTYPE_WINDOW, OUTTYPE_PRINTER };
62 class ScFieldEditEngine;
64 class ScOutputData
66 friend class ScDrawStringsVars;
67 private:
68 struct OutputAreaParam
70 Rectangle maAlignRect;
71 Rectangle maClipRect;
72 long mnColWidth;
73 bool mbLeftClip;
74 bool mbRightClip;
77 class DrawEditParam
79 public:
80 SvxCellHorJustify meHorJustAttr; ///< alignment attribute
81 SvxCellHorJustify meHorJustContext; ///< context depending on attribute, content and direction
82 SvxCellHorJustify meHorJustResult; ///< result for EditEngine
83 SvxCellVerJustify meVerJust;
84 SvxCellJustifyMethod meHorJustMethod;
85 SvxCellJustifyMethod meVerJustMethod;
86 SvxCellOrientation meOrient;
87 SCSIZE mnArrY;
88 SCCOL mnX;
89 SCROW mnY;
90 SCCOL mnCellX;
91 SCROW mnCellY;
92 SCTAB mnTab;
93 long mnPosX;
94 long mnPosY;
95 long mnInitPosX;
96 bool mbBreak:1;
97 bool mbCellIsValue:1;
98 bool mbAsianVertical:1;
99 bool mbPixelToLogic:1;
100 bool mbHyphenatorSet:1;
101 ScFieldEditEngine* mpEngine;
102 ScRefCellValue maCell;
103 const ScPatternAttr* mpPattern;
104 const SfxItemSet* mpCondSet;
105 const SfxItemSet* mpPreviewFontSet;
106 const ScPatternAttr* mpOldPattern;
107 const SfxItemSet* mpOldCondSet;
108 const SfxItemSet* mpOldPreviewFontSet;
109 const RowInfo* mpThisRowInfo;
110 const std::vector<editeng::MisspellRanges>* mpMisspellRanges;
112 explicit DrawEditParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue);
114 bool readCellContent(ScDocument* pDoc, bool bShowNullValues, bool bShowFormulas, bool bSyntaxMode, bool bUseStyleColor, bool bForceAutoColor, bool& rWrapFields);
115 void setPatternToEngine(bool bUseStyleColor);
116 void calcMargins(long& rTop, long& rLeft, long& rBottom, long& rRight, double nPPTX, double nPPTY) const;
117 void calcPaperSize(Size& rPaperSize, const Rectangle& rAlignRect, double nPPTX, double nPPTY) const;
118 void getEngineSize(ScFieldEditEngine* pEngine, long& rWidth, long& rHeight) const;
119 bool hasLineBreak() const;
120 bool isHyperlinkCell() const;
123 * When the text is vertically oriented, the text is either rotated 90
124 * degrees to the right or 90 degrees to the left. Note that this is
125 * different from being vertically stacked.
127 bool isVerticallyOriented() const;
130 * Calculate offset position for vertically oriented (either
131 * top-bottom or bottom-top orientation) text.
133 * @param rLogicStart initial position in pixels. When the call is
134 * finished, this parameter will store the new
135 * position.
137 void calcStartPosForVertical(Point& rLogicStart, long nCellWidth, long nEngineWidth, long nTopM, OutputDevice* pRefDevice);
139 void setAlignmentToEngine();
140 bool adjustHorAlignment(ScFieldEditEngine* pEngine);
141 void adjustForRTL();
142 void adjustForHyperlinkInPDF(Point aURLStart, OutputDevice* pDev);
145 OutputDevice* mpDev; // Device
146 OutputDevice* mpRefDevice; // printer if used for preview
147 OutputDevice* pFmtDevice; // reference for text formatting
148 ScTableInfo& mrTabInfo;
149 RowInfo* pRowInfo; // Info block
150 SCSIZE nArrCount; // occupied lines in info block
151 ScDocument* mpDoc; // Document
152 SCTAB nTab; // sheet
153 long nScrX; // Output Startpos. (Pixel)
154 long nScrY;
155 long nScrW; // Output size (Pixel)
156 long nScrH;
157 long nMirrorW; // Visible output width for mirroring (default: nScrW)
158 SCCOL nX1; // Start-/End coordinates
159 SCROW nY1; // ( incl. hidden )
160 SCCOL nX2;
161 SCROW nY2;
162 SCCOL nVisX1; // Start-/End coordinates
163 SCROW nVisY1; // ( visable range )
164 SCCOL nVisX2;
165 SCROW nVisY2;
166 ScOutputType eType; // Screen/Printer ...
167 double mnPPTX; // Pixel per Twips
168 double mnPPTY;
169 Fraction aZoomX;
170 Fraction aZoomY;
172 SdrObject* pEditObj; // Omit when painting
174 ScTabViewShell* pViewShell; // for connect from visible plug-ins
176 // #114135#
177 FmFormView* pDrawView; // SdrView to paint to
179 sal_Bool bEditMode; // InPlace edited cell - do not output
180 SCCOL nEditCol;
181 SCROW nEditRow;
183 bool bMetaFile; // Output to metafile (not pixels!)
184 bool bSingleGrid; // beim Gitter bChanged auswerten
186 bool bPagebreakMode; // Page break preview
187 bool bSolidBackground; // white instead of transparant
189 bool mbUseStyleColor;
190 bool mbForceAutoColor;
192 sal_Bool mbSyntaxMode; // Syntax highlighting
193 Color* pValueColor;
194 Color* pTextColor;
195 Color* pFormulaColor;
197 Color aGridColor;
199 bool mbShowNullValues;
200 bool mbShowFormulas;
201 bool bShowSpellErrors; // Show spelling errors in EditObjects
202 bool bMarkClipped;
204 bool bSnapPixel;
206 bool bAnyRotated; // internal
207 bool bAnyClipped; // internal
208 bool bTabProtected;
209 sal_uInt8 nTabTextDirection; // EEHorizontalTextDirection values
210 bool bLayoutRTL;
212 // #i74769# use SdrPaintWindow direct, remember it during BeginDrawLayers/EndDrawLayers
213 SdrPaintWindow* mpTargetPaintWindow;
214 const sc::SpellCheckContext* mpSpellCheckCxt;
216 // private methods
218 sal_Bool GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
219 SCCOL& rOverX, SCROW& rOverY, sal_Bool bVisRowChanged );
220 bool IsEmptyCellText( RowInfo* pThisRowInfo, SCCOL nX, SCROW nY );
221 void GetVisibleCell( SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue& rCell );
223 bool IsAvailable( SCCOL nX, SCROW nY );
225 void GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY,
226 SCCOL nCellX, SCROW nCellY, long nNeeded,
227 const ScPatternAttr& rPattern,
228 sal_uInt16 nHorJustify, bool bCellIsValue,
229 bool bBreak, bool bOverwrite,
230 OutputAreaParam& rParam );
232 void ShrinkEditEngine( EditEngine& rEngine, const Rectangle& rAlignRect,
233 long nLeftM, long nTopM, long nRightM, long nBottomM,
234 sal_Bool bWidth, sal_uInt16 nOrient, long nAttrRotate, sal_Bool bPixelToLogic,
235 long& rEngineWidth, long& rEngineHeight, long& rNeededPixel,
236 bool& rLeftClip, bool& rRightClip );
238 void SetSyntaxColor( Font* pFont, const ScRefCellValue& rCell );
239 void SetEditSyntaxColor( EditEngine& rEngine, ScRefCellValue& rCell );
241 double GetStretch();
243 void DrawRotatedFrame( const Color* pForceColor ); // pixel
245 drawinglayer::processor2d::BaseProcessor2D* CreateProcessor2D( );
247 void DrawEditStandard(DrawEditParam& rParam);
248 void DrawEditBottomTop(DrawEditParam& rParam);
249 void DrawEditTopBottom(DrawEditParam& rParam);
250 void DrawEditStacked(DrawEditParam& rParam);
251 void DrawEditAsianVertical(DrawEditParam& rParam);
253 ScFieldEditEngine* CreateOutputEditEngine();
255 void ShowClipMarks( DrawEditParam& rParam, long nEngineHeight, const Size& aCellSize,
256 bool bMerged, OutputAreaParam& aAreaParam );
258 bool Clip( DrawEditParam& rParam, const Size& aCellSize, OutputAreaParam& aAreaParam,
259 long nEngineHeight, bool bWrapFields);
261 public:
262 ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
263 ScTableInfo& rTabInfo, ScDocument* pNewDoc,
264 SCTAB nNewTab, long nNewScrX, long nNewScrY,
265 SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
266 double nPixelPerTwipsX, double nPixelPerTwipsY,
267 const Fraction* pZoomX = NULL,
268 const Fraction* pZoomY = NULL );
270 ~ScOutputData();
272 void SetSpellCheckContext( const sc::SpellCheckContext* pCxt );
273 void SetContentDevice( OutputDevice* pContentDev );
275 void SetRefDevice( OutputDevice* pRDev ) { mpRefDevice = pFmtDevice = pRDev; }
276 void SetFmtDevice( OutputDevice* pRDev ) { pFmtDevice = pRDev; }
277 void SetEditObject( SdrObject* pObj ) { pEditObj = pObj; }
278 void SetViewShell( ScTabViewShell* pSh ) { pViewShell = pSh; }
280 // #114135#
281 void SetDrawView( FmFormView* pNew ) { pDrawView = pNew; }
283 void SetSolidBackground( sal_Bool bSet ) { bSolidBackground = bSet; }
284 void SetUseStyleColor( sal_Bool bSet ) { mbUseStyleColor = bSet; }
286 void SetEditCell( SCCOL nCol, SCROW nRow );
287 void SetSyntaxMode( sal_Bool bNewMode );
288 void SetMetaFileMode( sal_Bool bNewMode );
289 void SetSingleGrid( sal_Bool bNewMode );
290 void SetGridColor( const Color& rColor );
291 void SetMarkClipped( sal_Bool bSet );
292 void SetShowNullValues ( sal_Bool bSet = sal_True );
293 void SetShowFormulas ( sal_Bool bSet = sal_True );
294 void SetShowSpellErrors( sal_Bool bSet = sal_True );
295 void SetMirrorWidth( long nNew );
296 long GetScrW() const { return nScrW; }
297 long GetScrH() const { return nScrH; }
299 void SetSnapPixel( sal_Bool bSet = sal_True );
301 void DrawGrid( sal_Bool bGrid, sal_Bool bPage );
302 void DrawStrings( sal_Bool bPixelToLogic = false );
303 void DrawDocumentBackground();
304 void DrawBackground();
305 void DrawShadow();
306 void DrawExtraShadow(sal_Bool bLeft, sal_Bool bTop, sal_Bool bRight, sal_Bool bBottom);
307 void DrawFrame();
309 // with logic MapMode set!
310 void DrawEdit(sal_Bool bPixelToLogic);
312 void FindRotated();
313 void DrawRotated(sal_Bool bPixelToLogic); // logical
315 void DrawClear();
317 // #i72502# printer only command set
318 Point PrePrintDrawingLayer(long nLogStX, long nLogStY );
319 void PostPrintDrawingLayer(const Point& rMMOffset); // #i74768# need offset for FormLayer
320 void PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset);
322 // only screen:
323 void DrawingSingle(const sal_uInt16 nLayer);
324 void DrawSelectiveObjects(const sal_uInt16 nLayer);
326 sal_Bool SetChangedClip(); // sal_False = not
327 Region GetChangedAreaRegion();
329 void FindChanged();
330 void SetPagebreakMode( ScPageBreakData* pPageData );
331 void DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
332 SCCOL nRefEndX, SCROW nRefEndY,
333 const Color& rColor, sal_Bool bHandle );
334 void DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY,
335 SCCOL nRefEndX, SCROW nRefEndY,
336 const Color& rColor, sal_uInt16 nType );
337 void DrawChangeTrack();
338 void DrawClipMarks();
340 void DrawNoteMarks();
341 void AddPDFNotes();
346 #endif
348 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */