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 .
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
;
48 class ScPageBreakData
;
50 class ScFieldEditEngine
;
53 // ---------------------------------------------------------------------------
55 #define SC_SCENARIO_HSPACE 60
56 #define SC_SCENARIO_VSPACE 50
58 // ---------------------------------------------------------------------------
60 enum ScOutputType
{ OUTTYPE_WINDOW
, OUTTYPE_PRINTER
};
62 class ScFieldEditEngine
;
66 friend class ScDrawStringsVars
;
68 struct OutputAreaParam
70 Rectangle maAlignRect
;
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
;
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
137 void calcStartPosForVertical(Point
& rLogicStart
, long nCellWidth
, long nEngineWidth
, long nTopM
, OutputDevice
* pRefDevice
);
139 void setAlignmentToEngine();
140 bool adjustHorAlignment(ScFieldEditEngine
* pEngine
);
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
153 long nScrX
; // Output Startpos. (Pixel)
155 long nScrW
; // Output size (Pixel)
157 long nMirrorW
; // Visible output width for mirroring (default: nScrW)
158 SCCOL nX1
; // Start-/End coordinates
159 SCROW nY1
; // ( incl. hidden )
162 SCCOL nVisX1
; // Start-/End coordinates
163 SCROW nVisY1
; // ( visable range )
166 ScOutputType eType
; // Screen/Printer ...
167 double mnPPTX
; // Pixel per Twips
172 SdrObject
* pEditObj
; // Omit when painting
174 ScTabViewShell
* pViewShell
; // for connect from visible plug-ins
177 FmFormView
* pDrawView
; // SdrView to paint to
179 sal_Bool bEditMode
; // InPlace edited cell - do not output
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
195 Color
* pFormulaColor
;
199 bool mbShowNullValues
;
201 bool bShowSpellErrors
; // Show spelling errors in EditObjects
206 bool bAnyRotated
; // internal
207 bool bAnyClipped
; // internal
209 sal_uInt8 nTabTextDirection
; // EEHorizontalTextDirection values
212 // #i74769# use SdrPaintWindow direct, remember it during BeginDrawLayers/EndDrawLayers
213 SdrPaintWindow
* mpTargetPaintWindow
;
214 const sc::SpellCheckContext
* mpSpellCheckCxt
;
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
);
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
);
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
);
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
; }
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();
306 void DrawExtraShadow(sal_Bool bLeft
, sal_Bool bTop
, sal_Bool bRight
, sal_Bool bBottom
);
309 // with logic MapMode set!
310 void DrawEdit(sal_Bool bPixelToLogic
);
313 void DrawRotated(sal_Bool bPixelToLogic
); // logical
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
);
323 void DrawingSingle(const sal_uInt16 nLayer
);
324 void DrawSelectiveObjects(const sal_uInt16 nLayer
);
326 sal_Bool
SetChangedClip(); // sal_False = not
327 Region
GetChangedAreaRegion();
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();
348 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */