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