/src/libreoffice/sc/source/ui/inc/output.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <address.hxx> |
23 | | #include <cellvalue.hxx> |
24 | | #include <spellcheckcontext.hxx> |
25 | | #include <tools/color.hxx> |
26 | | #include <tools/fract.hxx> |
27 | | #include <tools/gen.hxx> |
28 | | #include <editeng/svxenum.hxx> |
29 | | #include <vcl/outdev.hxx> |
30 | | #include <vcl/pdfwriter.hxx> |
31 | | #include <tools/degree.hxx> |
32 | | #include <o3tl/deleter.hxx> |
33 | | #include <optional> |
34 | | |
35 | | struct ScCellInfo; |
36 | | |
37 | | namespace sc { |
38 | | class SpellCheckContext; |
39 | | } |
40 | | |
41 | | namespace editeng { |
42 | | struct MisspellRanges; |
43 | | } |
44 | | namespace drawinglayer::processor2d { class BaseProcessor2D; } |
45 | | |
46 | | namespace vcl { class Font; } |
47 | | class EditEngine; |
48 | | class ScDocument; |
49 | | class ScPatternAttr; |
50 | | struct RowInfo; |
51 | | struct ScTableInfo; |
52 | | class ScTabViewShell; |
53 | | class ScPageBreakData; |
54 | | class FmFormView; |
55 | | class ScFieldEditEngine; |
56 | | class SdrPaintWindow; |
57 | | class ScDrawStringsVars; |
58 | | |
59 | 0 | #define SC_SCENARIO_HSPACE 60 |
60 | 0 | #define SC_SCENARIO_VSPACE 50 |
61 | | |
62 | | enum ScOutputType { OUTTYPE_WINDOW, OUTTYPE_PRINTER }; |
63 | | |
64 | | class ClearableClipRegion; |
65 | | typedef std::unique_ptr<ClearableClipRegion, o3tl::default_delete<ClearableClipRegion>> ClearableClipRegionPtr; |
66 | | |
67 | | typedef std::map<SCROW, sal_Int32> TableRowIdMap; |
68 | | typedef std::map<std::pair<SCROW, SCCOL>, sal_Int32> TableDataIdMap; |
69 | | struct ScEnhancedPDFState |
70 | | { |
71 | | sal_Int32 m_WorksheetId = -1; |
72 | | TableRowIdMap m_TableRowMap; |
73 | | TableDataIdMap m_TableDataMap; |
74 | 0 | ScEnhancedPDFState(){}; |
75 | | }; |
76 | | |
77 | | /// Describes reference mark to be drawn, position & size in TWIPs |
78 | | struct ReferenceMark { |
79 | | tools::Long nX; |
80 | | tools::Long nY; |
81 | | tools::Long nWidth; |
82 | | tools::Long nHeight; |
83 | | tools::Long nTab; |
84 | | Color aColor; |
85 | | |
86 | | ReferenceMark() |
87 | 0 | : nX( 0 ) |
88 | 0 | , nY( 0 ) |
89 | 0 | , nWidth( 0 ) |
90 | 0 | , nHeight( 0 ) |
91 | 0 | , nTab( 0 ) |
92 | 0 | , aColor( COL_AUTO ) {} |
93 | | |
94 | | ReferenceMark( tools::Long aX, |
95 | | tools::Long aY, |
96 | | tools::Long aWidth, |
97 | | tools::Long aHeight, |
98 | | tools::Long aTab, |
99 | | const Color& rColor ) |
100 | 0 | : nX( aX ) |
101 | 0 | , nY( aY ) |
102 | 0 | , nWidth( aWidth ) |
103 | 0 | , nHeight( aHeight ) |
104 | 0 | , nTab( aTab ) |
105 | 0 | , aColor( rColor ) {} |
106 | | |
107 | 0 | bool Is() const { return ( nWidth > 0 && nHeight > 0 ); } |
108 | | }; |
109 | | |
110 | | class ScOutputData |
111 | | { |
112 | | friend class ScDrawStringsVars; |
113 | | friend class ScGridWindow; |
114 | | private: |
115 | | struct OutputAreaParam |
116 | | { |
117 | | tools::Rectangle maAlignRect; |
118 | | tools::Rectangle maClipRect; |
119 | | tools::Long mnColWidth; |
120 | | tools::Long mnLeftClipLength; /// length of the string getting cut off on the left. |
121 | | tools::Long mnRightClipLength; /// length of the string getting cut off on the right. |
122 | | bool mbLeftClip; |
123 | | bool mbRightClip; |
124 | | }; |
125 | | |
126 | | class DrawEditParam |
127 | | { |
128 | | public: |
129 | | SvxCellHorJustify meHorJustAttr; ///< alignment attribute |
130 | | SvxCellHorJustify meHorJustContext; ///< context depending on attribute, content and direction |
131 | | SvxCellHorJustify meHorJustResult; ///< result for EditEngine |
132 | | SvxCellVerJustify meVerJust; |
133 | | SvxCellJustifyMethod meHorJustMethod; |
134 | | SvxCellJustifyMethod meVerJustMethod; |
135 | | SvxCellOrientation meOrient; |
136 | | SCSIZE mnArrY; |
137 | | SCCOL mnX; |
138 | | SCCOL mnCellX; |
139 | | SCROW mnCellY; |
140 | | tools::Long mnPosX; |
141 | | tools::Long mnPosY; |
142 | | tools::Long mnInitPosX; |
143 | | bool mbBreak:1; |
144 | | bool mbCellIsValue:1; |
145 | | bool mbAsianVertical:1; |
146 | | bool mbPixelToLogic:1; |
147 | | bool mbHyphenatorSet:1; |
148 | | ScFieldEditEngine* mpEngine; |
149 | | ScRefCellValue maCell; |
150 | | const ScPatternAttr* mpPattern; |
151 | | const SfxItemSet* mpCondSet; |
152 | | const SfxItemSet* mpPreviewFontSet; |
153 | | const ScPatternAttr* mpOldPattern; |
154 | | const SfxItemSet* mpOldCondSet; |
155 | | const SfxItemSet* mpOldPreviewFontSet; |
156 | | RowInfo* mpThisRowInfo; |
157 | | sc::MisspellRangeResult maMisspellRanges; |
158 | | |
159 | | explicit DrawEditParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue); |
160 | | |
161 | | bool readCellContent(const ScDocument* pDoc, bool bShowNullValues, bool bShowFormulas, bool bSyntaxMode, bool bUseStyleColor, bool bForceAutoColor, bool& rWrapFields); |
162 | | void setPatternToEngine(bool bUseStyleColor); |
163 | | void calcMargins(tools::Long& rTop, tools::Long& rLeft, tools::Long& rBottom, tools::Long& rRight, double nPPTX, double nPPTY) const; |
164 | | void calcPaperSize(Size& rPaperSize, const tools::Rectangle& rAlignRect, double nPPTX, double nPPTY) const; |
165 | | void getEngineSize(ScFieldEditEngine* pEngine, tools::Long& rWidth, tools::Long& rHeight) const; |
166 | | bool hasLineBreak() const; |
167 | | bool isHyperlinkCell() const; |
168 | | |
169 | | /** |
170 | | * When the text is vertically oriented, the text is either rotated 90 |
171 | | * degrees to the right or 90 degrees to the left. Note that this is |
172 | | * different from being vertically stacked. |
173 | | */ |
174 | | bool isVerticallyOriented() const; |
175 | | |
176 | | /** |
177 | | * Calculate offset position for vertically oriented (either |
178 | | * top-bottom or bottom-top orientation) text. |
179 | | * |
180 | | * @param rLogicStart initial position in pixels. When the call is |
181 | | * finished, this parameter will store the new |
182 | | * position. |
183 | | */ |
184 | | void calcStartPosForVertical(Point& rLogicStart, tools::Long nCellWidth, tools::Long nEngineWidth, tools::Long nTopM, const OutputDevice* pRefDevice); |
185 | | |
186 | | void setAlignmentToEngine(); |
187 | | bool adjustHorAlignment(ScFieldEditEngine* pEngine); |
188 | | void adjustForHyperlinkInPDF(Point aURLStart, const OutputDevice* pDev); |
189 | | }; |
190 | | |
191 | | VclPtr<OutputDevice> mpOriginalTargetDevice; // 'unpatched' TargetDevice |
192 | | VclPtr<OutputDevice> mpDev; // Device |
193 | | VclPtr<OutputDevice> mpRefDevice; // printer if used for preview |
194 | | VclPtr<OutputDevice> pFmtDevice; // reference for text formatting |
195 | | ScTableInfo& mrTabInfo; |
196 | | RowInfo* mpRowInfo; // Info block |
197 | | SCSIZE mnArrCount; // occupied lines in info block |
198 | | ScDocument* mpDoc; // Document |
199 | | SCTAB mnTab; // sheet |
200 | | tools::Long mnScrX; // Output Startpos. (Pixel) |
201 | | tools::Long mnScrY; |
202 | | tools::Long mnScrW; // Output size (Pixel) |
203 | | tools::Long mnScrH; |
204 | | tools::Long mnMirrorW; // Visible output width for mirroring (default: nScrW) |
205 | | SCCOL mnX1; // Start-/End coordinates |
206 | | SCROW mnY1; // ( incl. hidden ) |
207 | | SCCOL mnX2; |
208 | | SCROW mnY2; |
209 | | SCCOL mnVisX1; // Start-/End coordinates |
210 | | SCROW mnVisY1; // ( visible range ) |
211 | | SCCOL mnVisX2; |
212 | | SCROW mnVisY2; |
213 | | ScOutputType meType; // Screen/Printer ... |
214 | | double mnPPTX; // Pixel per Twips |
215 | | double mnPPTY; |
216 | | Fraction maZoomX; |
217 | | Fraction maZoomY; |
218 | | |
219 | | ScTabViewShell* mpViewShell; // for connect from visible plug-ins |
220 | | |
221 | | FmFormView* mpDrawView; // SdrView to paint to |
222 | | |
223 | | bool mbEditMode; // InPlace edited cell - do not output |
224 | | SCCOL mnEditCol; |
225 | | SCROW mnEditRow; |
226 | | |
227 | | bool mbMetaFile; // Output to metafile (not pixels!) |
228 | | |
229 | | bool mbPagebreakMode; // Page break preview |
230 | | bool mbSolidBackground; // white instead of transparent |
231 | | |
232 | | bool mbUseStyleColor; |
233 | | bool mbForceAutoColor; |
234 | | |
235 | | bool mbSyntaxMode; // Syntax highlighting |
236 | | std::optional<Color> mxValueColor; |
237 | | std::optional<Color> mxTextColor; |
238 | | std::optional<Color> mxFormulaColor; |
239 | | |
240 | | Color maGridColor; |
241 | | |
242 | | bool mbShowNullValues; |
243 | | bool mbShowFormulas; |
244 | | bool mbShowSpellErrors; // Show spelling errors in EditObjects |
245 | | bool mbMarkClipped; |
246 | | |
247 | | bool mbSnapPixel; |
248 | | |
249 | | bool mbAnyClipped; // internal |
250 | | bool mbVertical; |
251 | | bool mbTabProtected; |
252 | | bool mbLayoutRTL; |
253 | | |
254 | | // #i74769# use SdrPaintWindow direct, remember it during BeginDrawLayers/EndDrawLayers |
255 | | SdrPaintWindow* mpTargetPaintWindow; |
256 | | const sc::SpellCheckContext* mpSpellCheckCxt; |
257 | | std::unique_ptr<ScFieldEditEngine> mxOutputEditEngine; |
258 | | |
259 | | // private methods |
260 | | |
261 | | bool GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY, |
262 | | SCCOL& rOverX, SCROW& rOverY, bool bVisRowChanged ); |
263 | | bool IsEmptyCellText( const RowInfo* pThisRowInfo, SCCOL nX, SCROW nY ); |
264 | | void GetVisibleCell( SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue& rCell ); |
265 | | |
266 | | bool IsAvailable( SCCOL nX, SCROW nY ); |
267 | | |
268 | | void GetOutputArea( SCCOL nX, SCSIZE nArrY, tools::Long nPosX, tools::Long nPosY, |
269 | | SCCOL nCellX, SCROW nCellY, tools::Long nNeeded, |
270 | | const ScPatternAttr& rPattern, |
271 | | sal_uInt16 nHorJustify, bool bCellIsValue, |
272 | | bool bBreak, bool bOverwrite, |
273 | | OutputAreaParam& rParam ); |
274 | | |
275 | | void ShrinkEditEngine( EditEngine& rEngine, const tools::Rectangle& rAlignRect, |
276 | | tools::Long nLeftM, tools::Long nTopM, tools::Long nRightM, tools::Long nBottomM, |
277 | | bool bWidth, SvxCellOrientation nOrient, Degree100 nAttrRotate, bool bPixelToLogic, |
278 | | tools::Long& rEngineWidth, tools::Long& rEngineHeight, tools::Long& rNeededPixel, |
279 | | bool& rLeftClip, bool& rRightClip ); |
280 | | |
281 | | void SetSyntaxColor( vcl::Font* pFont, const ScRefCellValue& rCell ); |
282 | | void SetEditSyntaxColor( EditEngine& rEngine, const ScRefCellValue& rCell ); |
283 | | |
284 | | double GetStretch() const; |
285 | | |
286 | | void DrawRotatedFrame(vcl::RenderContext& rRenderContext); // pixel |
287 | | |
288 | | std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> CreateProcessor2D( ); |
289 | | |
290 | | void DrawEditStandard(DrawEditParam& rParam); |
291 | | void DrawEditBottomTop(DrawEditParam& rParam); |
292 | | void DrawEditTopBottom(DrawEditParam& rParam); |
293 | | void DrawEditStacked(DrawEditParam& rParam); |
294 | | void DrawEditAsianVertical(DrawEditParam& rParam); |
295 | | |
296 | | void InitOutputEditEngine(); |
297 | | |
298 | | void SetClipMarks( OutputAreaParam &aAreaParam, ScCellInfo* pClipMarkCell, |
299 | | SvxCellHorJustify eOutHorJust, tools::Long nLayoutSign ); |
300 | | |
301 | | void ShowClipMarks( DrawEditParam& rParam, tools::Long nEngineWidth, const Size& aCellSize, |
302 | | bool bMerged, OutputAreaParam& aAreaParam, bool bTop ); |
303 | | |
304 | | ClearableClipRegionPtr Clip(DrawEditParam& rParam, const Size& aCellSize, OutputAreaParam& aAreaParam, |
305 | | tools::Long nEngineWidth, bool bWrapFields, bool bTop); |
306 | | |
307 | | bool AdjustAreaParamClipRect(OutputAreaParam& rAreaParam); |
308 | | tools::Long SetEngineTextAndGetWidth( DrawEditParam& rParam, const OUString& rSetString, |
309 | | tools::Long& rNeededPixel, tools::Long nAddWidthPixels ); |
310 | | |
311 | | // Check for and set cell rotations at OutputData to have it available |
312 | | // in the svx tooling to render the borders. Moved to private section |
313 | | // and the single call to end of constructor to be sure this always happens |
314 | | void SetCellRotations(); |
315 | | |
316 | | /// inner loop of LayoutStrings |
317 | | void LayoutStringsImpl(bool bPixelToLogic, RowInfo* pThisRowInfo, SCCOL nX, SCROW nY, SCSIZE nArrY, |
318 | | std::optional<SCCOL>& oFirstNonEmptyCellX, |
319 | | std::optional<SCCOL>& oLastEmptyCellX, |
320 | | SCCOL nLastContentCol, |
321 | | std::vector<std::unique_ptr<ScPatternAttr> >& aAltPatterns, |
322 | | const ScPatternAttr*& pOldPattern, |
323 | | const SfxItemSet*& pOldCondSet, |
324 | | SvtScriptType& nOldScript, |
325 | | ScDrawStringsVars& aVars, |
326 | | bool& bProgress, tools::Long nPosX, tools::Long nPosY, bool bTaggedPDF, |
327 | | bool& bReopenRowTag, vcl::PDFExtOutDevData* pPDF, |
328 | | tools::Long nLayoutSign, |
329 | | KernArray& aDX); |
330 | | |
331 | | public: |
332 | | |
333 | | /** |
334 | | * @param nNewScrX: X-Offset in the output device for the table |
335 | | * @param nNewScrY: Y-Offset in the output device for the table |
336 | | * |
337 | | */ |
338 | | ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType, |
339 | | ScTableInfo& rTabInfo, ScDocument* pNewDoc, |
340 | | SCTAB nNewTab, tools::Long nNewScrX, tools::Long nNewScrY, |
341 | | SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2, |
342 | | double nPixelPerTwipsX, double nPixelPerTwipsY, |
343 | | const Fraction* pZoomX = nullptr, |
344 | | const Fraction* pZoomY = nullptr ); |
345 | | |
346 | | ~ScOutputData(); |
347 | | |
348 | | void SetSpellCheckContext( const sc::SpellCheckContext* pCxt ); |
349 | | void SetContentDevice( OutputDevice* pContentDev ); |
350 | | |
351 | | void SetRefDevice( OutputDevice* pRDev ); |
352 | | void SetFmtDevice( OutputDevice* pRDev ); |
353 | 0 | void SetViewShell( ScTabViewShell* pSh ) { mpViewShell = pSh; } |
354 | | |
355 | 0 | void SetDrawView( FmFormView* pNew ) { mpDrawView = pNew; } |
356 | | |
357 | 0 | void SetSolidBackground( bool bSet ) { mbSolidBackground = bSet; } |
358 | | void SetUseStyleColor( bool bSet ); |
359 | | |
360 | | void SetEditCell( SCCOL nCol, SCROW nRow ); |
361 | | void SetSyntaxMode( bool bNewMode ); |
362 | | void SetMetaFileMode( bool bNewMode ); |
363 | | void SetGridColor( const Color& rColor ); |
364 | | void SetMarkClipped( bool bSet ); |
365 | | void SetShowNullValues ( bool bSet ); |
366 | | void SetShowFormulas ( bool bSet ); |
367 | | void SetShowSpellErrors( bool bSet ); |
368 | | void SetMirrorWidth( tools::Long nNew ); |
369 | 0 | tools::Long GetScrW() const { return mnScrW; } |
370 | 0 | tools::Long GetScrH() const { return mnScrH; } |
371 | | |
372 | | void SetSnapPixel(); |
373 | | |
374 | | bool ReopenPDFStructureElement(vcl::pdf::StructElement aType, SCROW nRow = -1, |
375 | | SCCOL nCol = -1); |
376 | | |
377 | | void DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool bPage, bool bMergeCover = false); |
378 | | void DrawStrings( bool bPixelToLogic = false ); |
379 | | |
380 | | /// Draw all strings |
381 | | void LayoutStrings(bool bPixelToLogic); |
382 | | |
383 | | void DrawDocumentBackground(); |
384 | | void DrawBackground(vcl::RenderContext& rRenderContext); |
385 | | void DrawShadow(); |
386 | | void DrawExtraShadow(bool bLeft, bool bTop, bool bRight, bool bBottom); |
387 | | void DrawFrame(vcl::RenderContext& rRenderContext); |
388 | | |
389 | | // with logic MapMode set! |
390 | | void DrawEdit(bool bPixelToLogic); |
391 | | void DrawRotated(bool bPixelToLogic); // logical |
392 | | |
393 | | void DrawClear(); |
394 | | |
395 | | // #i72502# printer only command set |
396 | | Point PrePrintDrawingLayer(tools::Long nLogStX, tools::Long nLogStY ); |
397 | | void PostPrintDrawingLayer(const Point& rMMOffset); // #i74768# need offset for FormLayer |
398 | | void PrintDrawingLayer(SdrLayerID nLayer, const Point& rMMOffset); |
399 | | |
400 | | // only screen: |
401 | | void DrawSelectiveObjects(SdrLayerID nLayer); |
402 | | |
403 | | bool SetChangedClip(); // sal_False = not |
404 | | vcl::Region GetChangedAreaRegion(); |
405 | | |
406 | | void FindChanged(); |
407 | | void SetPagebreakMode( ScPageBreakData* pPageData ); |
408 | | /// Draws reference mark and returns its properties |
409 | | void DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY, |
410 | | SCCOL nRefEndX, SCROW nRefEndY, |
411 | | const Color& rColor, bool bHandle ); |
412 | | ReferenceMark FillReferenceMark( SCCOL nRefStartX, SCROW nRefStartY, |
413 | | SCCOL nRefEndX, SCROW nRefEndY, |
414 | | const Color& rColor ); |
415 | | void DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY, |
416 | | SCCOL nRefEndX, SCROW nRefEndY, |
417 | | const Color& rColor, sal_uInt16 nType ); |
418 | | void DrawChangeTrack(); |
419 | | void DrawClipMarks(); |
420 | | |
421 | | void DrawNoteMarks(vcl::RenderContext& rRenderContext); |
422 | | void DrawFormulaMarks(vcl::RenderContext& rRenderContext); |
423 | | void AddPDFNotes(); |
424 | | void DrawSparklines(vcl::RenderContext& rRenderContext); |
425 | | }; |
426 | | |
427 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |