Line data Source code
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 : #ifndef INCLUDED_SC_SOURCE_UI_INC_OUTPUT_HXX
21 : #define INCLUDED_SC_SOURCE_UI_INC_OUTPUT_HXX
22 :
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>
29 :
30 : namespace sc {
31 : struct SpellCheckContext;
32 : }
33 :
34 : namespace editeng {
35 : struct MisspellRanges;
36 : }
37 :
38 : class Rectangle;
39 : namespace vcl { 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;
52 :
53 : #define SC_SCENARIO_HSPACE 60
54 : #define SC_SCENARIO_VSPACE 50
55 :
56 : enum ScOutputType { OUTTYPE_WINDOW, OUTTYPE_PRINTER };
57 :
58 : class ScFieldEditEngine;
59 :
60 : class ScOutputData
61 : {
62 : friend class ScDrawStringsVars;
63 : friend class ScGridWindow;
64 : private:
65 4070 : struct OutputAreaParam
66 : {
67 : Rectangle maAlignRect;
68 : Rectangle maClipRect;
69 : long mnColWidth;
70 : long mnLeftClipLength; /// length of the string getting cut off on the left.
71 : long mnRightClipLength; /// length of the string getting cut off on the right.
72 : bool mbLeftClip;
73 : bool mbRightClip;
74 : };
75 :
76 1079 : class DrawEditParam
77 : {
78 : public:
79 : SvxCellHorJustify meHorJustAttr; ///< alignment attribute
80 : SvxCellHorJustify meHorJustContext; ///< context depending on attribute, content and direction
81 : SvxCellHorJustify meHorJustResult; ///< result for EditEngine
82 : SvxCellVerJustify meVerJust;
83 : SvxCellJustifyMethod meHorJustMethod;
84 : SvxCellJustifyMethod meVerJustMethod;
85 : SvxCellOrientation meOrient;
86 : SCSIZE mnArrY;
87 : SCCOL mnX;
88 : SCROW mnY;
89 : SCCOL mnCellX;
90 : SCROW mnCellY;
91 : SCTAB mnTab;
92 : long mnPosX;
93 : long mnPosY;
94 : long mnInitPosX;
95 : bool mbBreak:1;
96 : bool mbCellIsValue:1;
97 : bool mbAsianVertical:1;
98 : bool mbPixelToLogic:1;
99 : bool mbHyphenatorSet:1;
100 : ScFieldEditEngine* mpEngine;
101 : ScRefCellValue maCell;
102 : const ScPatternAttr* mpPattern;
103 : const SfxItemSet* mpCondSet;
104 : const SfxItemSet* mpPreviewFontSet;
105 : const ScPatternAttr* mpOldPattern;
106 : const SfxItemSet* mpOldCondSet;
107 : const SfxItemSet* mpOldPreviewFontSet;
108 : const RowInfo* mpThisRowInfo;
109 : const std::vector<editeng::MisspellRanges>* mpMisspellRanges;
110 :
111 : explicit DrawEditParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue);
112 :
113 : bool readCellContent(ScDocument* pDoc, bool bShowNullValues, bool bShowFormulas, bool bSyntaxMode, bool bUseStyleColor, bool bForceAutoColor, bool& rWrapFields);
114 : void setPatternToEngine(bool bUseStyleColor);
115 : void calcMargins(long& rTop, long& rLeft, long& rBottom, long& rRight, double nPPTX, double nPPTY) const;
116 : void calcPaperSize(Size& rPaperSize, const Rectangle& rAlignRect, double nPPTX, double nPPTY) const;
117 : void getEngineSize(ScFieldEditEngine* pEngine, long& rWidth, long& rHeight) const;
118 : bool hasLineBreak() const;
119 : bool isHyperlinkCell() const;
120 :
121 : /**
122 : * When the text is vertically oriented, the text is either rotated 90
123 : * degrees to the right or 90 degrees to the left. Note that this is
124 : * different from being vertically stacked.
125 : */
126 : bool isVerticallyOriented() const;
127 :
128 : /**
129 : * Calculate offset position for vertically oriented (either
130 : * top-bottom or bottom-top orientation) text.
131 : *
132 : * @param rLogicStart initial position in pixels. When the call is
133 : * finished, this parameter will store the new
134 : * position.
135 : */
136 : void calcStartPosForVertical(Point& rLogicStart, long nCellWidth, long nEngineWidth, long nTopM, OutputDevice* pRefDevice);
137 :
138 : void setAlignmentToEngine();
139 : bool adjustHorAlignment(ScFieldEditEngine* pEngine);
140 : void adjustForRTL();
141 : void adjustForHyperlinkInPDF(Point aURLStart, OutputDevice* pDev);
142 : };
143 :
144 : VclPtr<OutputDevice> mpDev; // Device
145 : VclPtr<OutputDevice> mpRefDevice; // printer if used for preview
146 : VclPtr<OutputDevice> pFmtDevice; // reference for text formatting
147 : ScTableInfo& mrTabInfo;
148 : RowInfo* pRowInfo; // Info block
149 : SCSIZE nArrCount; // occupied lines in info block
150 : ScDocument* mpDoc; // Document
151 : SCTAB nTab; // sheet
152 : long nScrX; // Output Startpos. (Pixel)
153 : long nScrY;
154 : long nScrW; // Output size (Pixel)
155 : long nScrH;
156 : long nMirrorW; // Visible output width for mirroring (default: nScrW)
157 : SCCOL nX1; // Start-/End coordinates
158 : SCROW nY1; // ( incl. hidden )
159 : SCCOL nX2;
160 : SCROW nY2;
161 : SCCOL nVisX1; // Start-/End coordinates
162 : SCROW nVisY1; // ( visible range )
163 : SCCOL nVisX2;
164 : SCROW nVisY2;
165 : ScOutputType eType; // Screen/Printer ...
166 : double mnPPTX; // Pixel per Twips
167 : double mnPPTY;
168 : Fraction aZoomX;
169 : Fraction aZoomY;
170 :
171 : SdrObject* pEditObj; // Omit when painting
172 :
173 : ScTabViewShell* pViewShell; // for connect from visible plug-ins
174 :
175 : // #114135#
176 : FmFormView* pDrawView; // SdrView to paint to
177 :
178 : bool bEditMode; // InPlace edited cell - do not output
179 : SCCOL nEditCol;
180 : SCROW nEditRow;
181 :
182 : bool bMetaFile; // Output to metafile (not pixels!)
183 : bool bSingleGrid; // beim Gitter bChanged auswerten
184 :
185 : bool bPagebreakMode; // Page break preview
186 : bool bSolidBackground; // white instead of transparant
187 :
188 : bool mbUseStyleColor;
189 : bool mbForceAutoColor;
190 :
191 : bool mbSyntaxMode; // Syntax highlighting
192 : Color* pValueColor;
193 : Color* pTextColor;
194 : Color* pFormulaColor;
195 :
196 : Color aGridColor;
197 :
198 : bool mbShowNullValues;
199 : bool mbShowFormulas;
200 : bool bShowSpellErrors; // Show spelling errors in EditObjects
201 : bool bMarkClipped;
202 :
203 : bool bSnapPixel;
204 :
205 : bool bAnyRotated; // internal
206 : bool bAnyClipped; // internal
207 : bool bTabProtected;
208 : sal_uInt8 nTabTextDirection; // EEHorizontalTextDirection values
209 : bool bLayoutRTL;
210 :
211 : // #i74769# use SdrPaintWindow direct, remember it during BeginDrawLayers/EndDrawLayers
212 : SdrPaintWindow* mpTargetPaintWindow;
213 : const sc::SpellCheckContext* mpSpellCheckCxt;
214 :
215 : // private methods
216 :
217 : bool GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
218 : SCCOL& rOverX, SCROW& rOverY, bool bVisRowChanged );
219 : bool IsEmptyCellText( RowInfo* pThisRowInfo, SCCOL nX, SCROW nY );
220 : void GetVisibleCell( SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue& rCell );
221 :
222 : bool IsAvailable( SCCOL nX, SCROW nY );
223 :
224 : void GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY,
225 : SCCOL nCellX, SCROW nCellY, long nNeeded,
226 : const ScPatternAttr& rPattern,
227 : sal_uInt16 nHorJustify, bool bCellIsValue,
228 : bool bBreak, bool bOverwrite,
229 : OutputAreaParam& rParam );
230 :
231 : void ShrinkEditEngine( EditEngine& rEngine, const Rectangle& rAlignRect,
232 : long nLeftM, long nTopM, long nRightM, long nBottomM,
233 : bool bWidth, sal_uInt16 nOrient, long nAttrRotate, bool bPixelToLogic,
234 : long& rEngineWidth, long& rEngineHeight, long& rNeededPixel,
235 : bool& rLeftClip, bool& rRightClip );
236 :
237 : void SetSyntaxColor( vcl::Font* pFont, const ScRefCellValue& rCell );
238 : void SetEditSyntaxColor( EditEngine& rEngine, ScRefCellValue& rCell );
239 :
240 : double GetStretch();
241 :
242 : void DrawRotatedFrame( const Color* pForceColor ); // pixel
243 :
244 : drawinglayer::processor2d::BaseProcessor2D* CreateProcessor2D( );
245 :
246 : void DrawEditStandard(DrawEditParam& rParam);
247 : void DrawEditBottomTop(DrawEditParam& rParam);
248 : void DrawEditTopBottom(DrawEditParam& rParam);
249 : void DrawEditStacked(DrawEditParam& rParam);
250 : void DrawEditAsianVertical(DrawEditParam& rParam);
251 :
252 : ScFieldEditEngine* CreateOutputEditEngine();
253 :
254 : void ShowClipMarks( DrawEditParam& rParam, long nEngineHeight, const Size& aCellSize,
255 : bool bMerged, OutputAreaParam& aAreaParam );
256 :
257 : bool Clip( DrawEditParam& rParam, const Size& aCellSize, OutputAreaParam& aAreaParam,
258 : long nEngineHeight, bool bWrapFields);
259 :
260 : public:
261 : ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
262 : ScTableInfo& rTabInfo, ScDocument* pNewDoc,
263 : SCTAB nNewTab, long nNewScrX, long nNewScrY,
264 : SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
265 : double nPixelPerTwipsX, double nPixelPerTwipsY,
266 : const Fraction* pZoomX = NULL,
267 : const Fraction* pZoomY = NULL );
268 :
269 : ~ScOutputData();
270 :
271 : void SetSpellCheckContext( const sc::SpellCheckContext* pCxt );
272 : void SetContentDevice( OutputDevice* pContentDev );
273 :
274 22 : void SetRefDevice( OutputDevice* pRDev ) { mpRefDevice = pFmtDevice = pRDev; }
275 27 : void SetFmtDevice( OutputDevice* pRDev ) { pFmtDevice = pRDev; }
276 2964 : void SetEditObject( SdrObject* pObj ) { pEditObj = pObj; }
277 2964 : void SetViewShell( ScTabViewShell* pSh ) { pViewShell = pSh; }
278 :
279 : // #114135#
280 27 : void SetDrawView( FmFormView* pNew ) { pDrawView = pNew; }
281 :
282 2964 : void SetSolidBackground( bool bSet ) { bSolidBackground = bSet; }
283 2986 : void SetUseStyleColor( bool bSet ) { mbUseStyleColor = bSet; }
284 :
285 : void SetEditCell( SCCOL nCol, SCROW nRow );
286 : void SetSyntaxMode( bool bNewMode );
287 : void SetMetaFileMode( bool bNewMode );
288 : void SetSingleGrid( bool bNewMode );
289 : void SetGridColor( const Color& rColor );
290 : void SetMarkClipped( bool bSet );
291 : void SetShowNullValues ( bool bSet = true );
292 : void SetShowFormulas ( bool bSet = true );
293 : void SetShowSpellErrors( bool bSet = true );
294 : void SetMirrorWidth( long nNew );
295 2991 : long GetScrW() const { return nScrW; }
296 2994 : long GetScrH() const { return nScrH; }
297 :
298 : void SetSnapPixel( bool bSet = true );
299 :
300 : void DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool bPage);
301 : void DrawStrings( bool bPixelToLogic = false );
302 :
303 : /// Draw all strings, or provide Rectangle where the text (defined by rAddress) would be drawn.
304 : Rectangle LayoutStrings(bool bPixelToLogic = false, bool bPaint = true, const ScAddress &rAddress = ScAddress());
305 :
306 : void DrawDocumentBackground();
307 : void DrawBackground();
308 : void DrawShadow();
309 : void DrawExtraShadow(bool bLeft, bool bTop, bool bRight, bool bBottom);
310 : void DrawFrame();
311 :
312 : // with logic MapMode set!
313 : void DrawEdit(bool bPixelToLogic);
314 :
315 : void FindRotated();
316 : void DrawRotated(bool bPixelToLogic); // logical
317 :
318 : void DrawClear();
319 :
320 : // #i72502# printer only command set
321 : Point PrePrintDrawingLayer(long nLogStX, long nLogStY );
322 : void PostPrintDrawingLayer(const Point& rMMOffset); // #i74768# need offset for FormLayer
323 : void PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset);
324 :
325 : // only screen:
326 : void DrawingSingle(const sal_uInt16 nLayer);
327 : void DrawSelectiveObjects(const sal_uInt16 nLayer);
328 :
329 : bool SetChangedClip(); // sal_False = not
330 : vcl::Region GetChangedAreaRegion();
331 :
332 : void FindChanged();
333 : void SetPagebreakMode( ScPageBreakData* pPageData );
334 : void DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
335 : SCCOL nRefEndX, SCROW nRefEndY,
336 : const Color& rColor, bool bHandle );
337 : void DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY,
338 : SCCOL nRefEndX, SCROW nRefEndY,
339 : const Color& rColor, sal_uInt16 nType );
340 : void DrawChangeTrack();
341 : void DrawClipMarks();
342 :
343 : void DrawNoteMarks();
344 : void AddPDFNotes();
345 : };
346 :
347 : #endif
348 :
349 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|