1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SC_SOURCE_UI_INC_OUTPUT_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_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>
31 struct SpellCheckContext
;
35 struct MisspellRanges
;
39 namespace vcl
{ class Font
; }
48 class ScPageBreakData
;
50 class ScFieldEditEngine
;
53 #define SC_SCENARIO_HSPACE 60
54 #define SC_SCENARIO_VSPACE 50
56 enum ScOutputType
{ OUTTYPE_WINDOW
, OUTTYPE_PRINTER
};
58 class ScFieldEditEngine
;
62 friend class ScDrawStringsVars
;
63 friend class ScGridWindow
;
65 struct OutputAreaParam
67 Rectangle maAlignRect
;
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.
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
;
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
;
111 explicit DrawEditParam(const ScPatternAttr
* pPattern
, const SfxItemSet
* pCondSet
, bool bCellIsValue
);
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;
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.
126 bool isVerticallyOriented() const;
129 * Calculate offset position for vertically oriented (either
130 * top-bottom or bottom-top orientation) text.
132 * @param rLogicStart initial position in pixels. When the call is
133 * finished, this parameter will store the new
136 void calcStartPosForVertical(Point
& rLogicStart
, long nCellWidth
, long nEngineWidth
, long nTopM
, OutputDevice
* pRefDevice
);
138 void setAlignmentToEngine();
139 bool adjustHorAlignment(ScFieldEditEngine
* pEngine
);
141 void adjustForHyperlinkInPDF(Point aURLStart
, OutputDevice
* pDev
);
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
152 long nScrX
; // Output Startpos. (Pixel)
154 long nScrW
; // Output size (Pixel)
156 long nMirrorW
; // Visible output width for mirroring (default: nScrW)
157 SCCOL nX1
; // Start-/End coordinates
158 SCROW nY1
; // ( incl. hidden )
161 SCCOL nVisX1
; // Start-/End coordinates
162 SCROW nVisY1
; // ( visible range )
165 ScOutputType eType
; // Screen/Printer ...
166 double mnPPTX
; // Pixel per Twips
171 SdrObject
* pEditObj
; // Omit when painting
173 ScTabViewShell
* pViewShell
; // for connect from visible plug-ins
175 FmFormView
* pDrawView
; // SdrView to paint to
177 bool bEditMode
; // InPlace edited cell - do not output
181 bool bMetaFile
; // Output to metafile (not pixels!)
182 bool bSingleGrid
; // beim Gitter bChanged auswerten
184 bool bPagebreakMode
; // Page break preview
185 bool bSolidBackground
; // white instead of transparant
187 bool mbUseStyleColor
;
188 bool mbForceAutoColor
;
190 bool mbSyntaxMode
; // Syntax highlighting
193 Color
* pFormulaColor
;
197 bool mbShowNullValues
;
199 bool bShowSpellErrors
; // Show spelling errors in EditObjects
204 bool bAnyRotated
; // internal
205 bool bAnyClipped
; // internal
207 sal_uInt8 nTabTextDirection
; // EEHorizontalTextDirection values
210 // #i74769# use SdrPaintWindow direct, remember it during BeginDrawLayers/EndDrawLayers
211 SdrPaintWindow
* mpTargetPaintWindow
;
212 const sc::SpellCheckContext
* mpSpellCheckCxt
;
216 bool GetMergeOrigin( SCCOL nX
, SCROW nY
, SCSIZE nArrY
,
217 SCCOL
& rOverX
, SCROW
& rOverY
, bool bVisRowChanged
);
218 bool IsEmptyCellText( RowInfo
* pThisRowInfo
, SCCOL nX
, SCROW nY
);
219 void GetVisibleCell( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, ScRefCellValue
& rCell
);
221 bool IsAvailable( SCCOL nX
, SCROW nY
);
223 void GetOutputArea( SCCOL nX
, SCSIZE nArrY
, long nPosX
, long nPosY
,
224 SCCOL nCellX
, SCROW nCellY
, long nNeeded
,
225 const ScPatternAttr
& rPattern
,
226 sal_uInt16 nHorJustify
, bool bCellIsValue
,
227 bool bBreak
, bool bOverwrite
,
228 OutputAreaParam
& rParam
);
230 void ShrinkEditEngine( EditEngine
& rEngine
, const Rectangle
& rAlignRect
,
231 long nLeftM
, long nTopM
, long nRightM
, long nBottomM
,
232 bool bWidth
, sal_uInt16 nOrient
, long nAttrRotate
, bool bPixelToLogic
,
233 long& rEngineWidth
, long& rEngineHeight
, long& rNeededPixel
,
234 bool& rLeftClip
, bool& rRightClip
);
236 void SetSyntaxColor( vcl::Font
* pFont
, const ScRefCellValue
& rCell
);
237 void SetEditSyntaxColor( EditEngine
& rEngine
, ScRefCellValue
& rCell
);
241 void DrawRotatedFrame(vcl::RenderContext
& rRenderContext
, const Color
* pForceColor
); // pixel
243 drawinglayer::processor2d::BaseProcessor2D
* CreateProcessor2D( );
245 void DrawEditStandard(DrawEditParam
& rParam
);
246 void DrawEditBottomTop(DrawEditParam
& rParam
);
247 void DrawEditTopBottom(DrawEditParam
& rParam
);
248 void DrawEditStacked(DrawEditParam
& rParam
);
249 void DrawEditAsianVertical(DrawEditParam
& rParam
);
251 ScFieldEditEngine
* CreateOutputEditEngine();
253 void ShowClipMarks( DrawEditParam
& rParam
, long nEngineHeight
, const Size
& aCellSize
,
254 bool bMerged
, OutputAreaParam
& aAreaParam
);
256 bool Clip( DrawEditParam
& rParam
, const Size
& aCellSize
, OutputAreaParam
& aAreaParam
,
257 long nEngineHeight
, bool bWrapFields
);
260 ScOutputData( OutputDevice
* pNewDev
, ScOutputType eNewType
,
261 ScTableInfo
& rTabInfo
, ScDocument
* pNewDoc
,
262 SCTAB nNewTab
, long nNewScrX
, long nNewScrY
,
263 SCCOL nNewX1
, SCROW nNewY1
, SCCOL nNewX2
, SCROW nNewY2
,
264 double nPixelPerTwipsX
, double nPixelPerTwipsY
,
265 const Fraction
* pZoomX
= nullptr,
266 const Fraction
* pZoomY
= nullptr );
270 void SetSpellCheckContext( const sc::SpellCheckContext
* pCxt
);
271 void SetContentDevice( OutputDevice
* pContentDev
);
273 void SetRefDevice( OutputDevice
* pRDev
) { mpRefDevice
= pFmtDevice
= pRDev
; }
274 void SetFmtDevice( OutputDevice
* pRDev
) { pFmtDevice
= pRDev
; }
275 void SetEditObject( SdrObject
* pObj
) { pEditObj
= pObj
; }
276 void SetViewShell( ScTabViewShell
* pSh
) { pViewShell
= pSh
; }
278 void SetDrawView( FmFormView
* pNew
) { pDrawView
= pNew
; }
280 void SetSolidBackground( bool bSet
) { bSolidBackground
= bSet
; }
281 void SetUseStyleColor( bool bSet
) { mbUseStyleColor
= bSet
; }
283 void SetEditCell( SCCOL nCol
, SCROW nRow
);
284 void SetSyntaxMode( bool bNewMode
);
285 void SetMetaFileMode( bool bNewMode
);
286 void SetSingleGrid( bool bNewMode
);
287 void SetGridColor( const Color
& rColor
);
288 void SetMarkClipped( bool bSet
);
289 void SetShowNullValues ( bool bSet
= true );
290 void SetShowFormulas ( bool bSet
= true );
291 void SetShowSpellErrors( bool bSet
= true );
292 void SetMirrorWidth( long nNew
);
293 long GetScrW() const { return nScrW
; }
294 long GetScrH() const { return nScrH
; }
298 void DrawGrid(vcl::RenderContext
& rRenderContext
, bool bGrid
, bool bPage
);
299 void DrawStrings( bool bPixelToLogic
= false );
301 /// Draw all strings, or provide Rectangle where the text (defined by rAddress) would be drawn.
302 Rectangle
LayoutStrings(bool bPixelToLogic
= false, bool bPaint
= true, const ScAddress
&rAddress
= ScAddress());
304 void DrawDocumentBackground();
305 void DrawBackground(vcl::RenderContext
& rRenderContext
);
307 void DrawExtraShadow(bool bLeft
, bool bTop
, bool bRight
, bool bBottom
);
308 void DrawFrame(vcl::RenderContext
& rRenderContext
);
310 // with logic MapMode set!
311 void DrawEdit(bool bPixelToLogic
);
314 void DrawRotated(bool bPixelToLogic
); // logical
318 // #i72502# printer only command set
319 Point
PrePrintDrawingLayer(long nLogStX
, long nLogStY
);
320 void PostPrintDrawingLayer(const Point
& rMMOffset
); // #i74768# need offset for FormLayer
321 void PrintDrawingLayer(const sal_uInt16 nLayer
, const Point
& rMMOffset
);
324 void DrawingSingle(const sal_uInt16 nLayer
);
325 void DrawSelectiveObjects(const sal_uInt16 nLayer
);
327 bool SetChangedClip(); // sal_False = not
328 vcl::Region
GetChangedAreaRegion();
331 void SetPagebreakMode( ScPageBreakData
* pPageData
);
332 void DrawRefMark( SCCOL nRefStartX
, SCROW nRefStartY
,
333 SCCOL nRefEndX
, SCROW nRefEndY
,
334 const Color
& rColor
, bool bHandle
);
335 void DrawOneChange( SCCOL nRefStartX
, SCROW nRefStartY
,
336 SCCOL nRefEndX
, SCROW nRefEndY
,
337 const Color
& rColor
, sal_uInt16 nType
);
338 void DrawChangeTrack();
339 void DrawClipMarks();
341 void DrawNoteMarks(vcl::RenderContext
& rRenderContext
);
347 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */