Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_OUTPUT_HXX
30 : : #define SC_OUTPUT_HXX
31 : :
32 : : #include "address.hxx"
33 : : #include <tools/color.hxx>
34 : : #include <tools/fract.hxx>
35 : : #include <com/sun/star/embed/XEmbeddedObject.hpp>
36 : : #include <drawinglayer/processor2d/baseprocessor2d.hxx>
37 : :
38 : : class Rectangle;
39 : : class Font;
40 : : class OutputDevice;
41 : : class EditEngine;
42 : : class ScDocument;
43 : : class ScBaseCell;
44 : : class ScPatternAttr;
45 : : class SdrObject;
46 : : struct RowInfo;
47 : : struct ScTableInfo;
48 : : class ScTabViewShell;
49 : : class ScPageBreakData;
50 : : class FmFormView;
51 : : class ScFieldEditEngine;
52 : :
53 : : // #i74769# SdrPaintWindow predefine
54 : : class SdrPaintWindow;
55 : :
56 : : // ---------------------------------------------------------------------------
57 : :
58 : : #define SC_SCENARIO_HSPACE 60
59 : : #define SC_SCENARIO_VSPACE 50
60 : :
61 : : // ---------------------------------------------------------------------------
62 : :
63 : : enum ScOutputType { OUTTYPE_WINDOW, OUTTYPE_PRINTER };
64 : :
65 : : class ScFieldEditEngine;
66 : :
67 : : class ScOutputData
68 : : {
69 : : friend class ScDrawStringsVars;
70 : : private:
71 : 2378 : struct OutputAreaParam
72 : : {
73 : : Rectangle maAlignRect;
74 : : Rectangle maClipRect;
75 : : long mnColWidth;
76 : : bool mbLeftClip;
77 : : bool mbRightClip;
78 : : };
79 : :
80 : : class DrawEditParam
81 : : {
82 : : public:
83 : : SvxCellHorJustify meHorJust;
84 : : SvxCellVerJustify meVerJust;
85 : : SvxCellJustifyMethod meHorJustMethod;
86 : : SvxCellJustifyMethod meVerJustMethod;
87 : : SvxCellOrientation meOrient;
88 : : SCSIZE mnArrY;
89 : : SCCOL mnX;
90 : : SCROW mnY;
91 : : SCCOL mnCellX;
92 : : SCROW mnCellY;
93 : : long mnPosX;
94 : : long mnPosY;
95 : : long mnInitPosX;
96 : : bool mbBreak;
97 : : bool mbCellIsValue;
98 : : bool mbAsianVertical;
99 : : bool mbPixelToLogic;
100 : : bool mbHyphenatorSet;
101 : : bool mbRTL;
102 : : ScFieldEditEngine* mpEngine;
103 : : ScBaseCell* mpCell;
104 : : const ScPatternAttr* mpPattern;
105 : : const SfxItemSet* mpCondSet;
106 : : const ScPatternAttr* mpOldPattern;
107 : : const SfxItemSet* mpOldCondSet;
108 : : const RowInfo* mpThisRowInfo;
109 : :
110 : : explicit DrawEditParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue);
111 : :
112 : : bool readCellContent(ScDocument* pDoc, bool bShowNullValues, bool bShowFormulas, bool bSyntaxMode, bool bUseStyleColor, bool bForceAutoColor, bool& rWrapFields);
113 : : void setPatternToEngine(bool bUseStyleColor);
114 : : void calcMargins(long& rTop, long& rLeft, long& rBottom, long& rRight, double nPPTX, double nPPTY) const;
115 : : void calcPaperSize(Size& rPaperSize, const Rectangle& rAlignRect, double nPPTX, double nPPTY) const;
116 : : void getEngineSize(ScFieldEditEngine* pEngine, long& rWidth, long& rHeight) const;
117 : : bool hasLineBreak() const;
118 : : bool isHyperlinkCell() const;
119 : :
120 : : /**
121 : : * When the text is vertically oriented, the text is either rotated 90
122 : : * degrees to the right or 90 degrees to the left. Note that this is
123 : : * different from being vertically stacked.
124 : : */
125 : : bool isVerticallyOriented() const;
126 : :
127 : : /**
128 : : * Calculate offset position for vertically oriented (either
129 : : * top-bottom or bottom-top orientation) text.
130 : : *
131 : : * @param rLogicStart initial position in pixels. When the call is
132 : : * finished, this parameter will store the new
133 : : * position.
134 : : */
135 : : void calcStartPosForVertical(Point& rLogicStart, long nCellWidth, long nEngineWidth, long nTopM, OutputDevice* pRefDevice);
136 : :
137 : : void setAlignmentToEngine();
138 : : bool adjustHorAlignment(ScFieldEditEngine* pEngine);
139 : : void adjustForRTL();
140 : : void adjustForHyperlinkInPDF(Point aURLStart, OutputDevice* pDev);
141 : : };
142 : :
143 : : OutputDevice* mpDev; // Device
144 : : OutputDevice* mpRefDevice; // printer if used for preview
145 : : OutputDevice* pFmtDevice; // reference for text formatting
146 : : ScTableInfo& mrTabInfo;
147 : : RowInfo* pRowInfo; // Info block
148 : : SCSIZE nArrCount; // occupied lines in info block
149 : : ScDocument* mpDoc; // Document
150 : : SCTAB nTab; // sheet
151 : : long nScrX; // Output Startpos. (Pixel)
152 : : long nScrY;
153 : : long nScrW; // Output size (Pixel)
154 : : long nScrH;
155 : : long nMirrorW; // Visible output width for mirroring (default: nScrW)
156 : : SCCOL nX1; // Start-/End coordinates
157 : : SCROW nY1; // ( incl. hidden )
158 : : SCCOL nX2;
159 : : SCROW nY2;
160 : : SCCOL nVisX1; // Start-/End coordinates
161 : : SCROW nVisY1; // ( visable range )
162 : : SCCOL nVisX2;
163 : : SCROW nVisY2;
164 : : ScOutputType eType; // Screen/Printer ...
165 : : double mnPPTX; // Pixel per Twips
166 : : double mnPPTY;
167 : : Fraction aZoomX;
168 : : Fraction aZoomY;
169 : :
170 : : SdrObject* pEditObj; // Omit when painting
171 : :
172 : : ScTabViewShell* pViewShell; // for connect from visible plug-ins
173 : :
174 : : // #114135#
175 : : FmFormView* pDrawView; // SdrView to paint to
176 : :
177 : : sal_Bool bEditMode; // InPlace edited cell - do not output
178 : : SCCOL nEditCol;
179 : : SCROW nEditRow;
180 : :
181 : : bool bMetaFile; // Output to metafile (not pixels!)
182 : : bool bSingleGrid; // beim Gitter bChanged auswerten
183 : :
184 : : bool bPagebreakMode; // Page break preview
185 : : bool bSolidBackground; // white instead of transparant
186 : :
187 : : bool mbUseStyleColor;
188 : : bool mbForceAutoColor;
189 : :
190 : : sal_Bool mbSyntaxMode; // Syntax highlighting
191 : : Color* pValueColor;
192 : : Color* pTextColor;
193 : : Color* pFormulaColor;
194 : :
195 : : Color aGridColor;
196 : :
197 : : bool mbShowNullValues;
198 : : bool mbShowFormulas;
199 : : bool bShowSpellErrors; // Show spelling errors in EditObjects
200 : : bool bMarkClipped;
201 : :
202 : : bool bSnapPixel;
203 : :
204 : : bool bAnyRotated; // internal
205 : : bool bAnyClipped; // internal
206 : : bool bTabProtected;
207 : : sal_uInt8 nTabTextDirection; // EEHorizontalTextDirection values
208 : : bool bLayoutRTL;
209 : :
210 : : // #i74769# use SdrPaintWindow direct, remember it during BeginDrawLayers/EndDrawLayers
211 : : SdrPaintWindow* mpTargetPaintWindow;
212 : :
213 : : // private methods
214 : :
215 : : sal_Bool GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
216 : : SCCOL& rOverX, SCROW& rOverY, sal_Bool bVisRowChanged );
217 : : sal_Bool IsEmptyCellText( RowInfo* pThisRowInfo, SCCOL nX, SCROW nY );
218 : : void GetVisibleCell( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell*& rpCell );
219 : :
220 : : sal_Bool IsAvailable( SCCOL nX, SCROW nY );
221 : :
222 : : void GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY,
223 : : SCCOL nCellX, SCROW nCellY, long nNeeded,
224 : : const ScPatternAttr& rPattern,
225 : : sal_uInt16 nHorJustify, bool bCellIsValue,
226 : : bool bBreak, bool bOverwrite,
227 : : OutputAreaParam& rParam );
228 : :
229 : : void ShrinkEditEngine( EditEngine& rEngine, const Rectangle& rAlignRect,
230 : : long nLeftM, long nTopM, long nRightM, long nBottomM,
231 : : sal_Bool bWidth, sal_uInt16 nOrient, long nAttrRotate, sal_Bool bPixelToLogic,
232 : : long& rEngineWidth, long& rEngineHeight, long& rNeededPixel,
233 : : bool& rLeftClip, bool& rRightClip );
234 : :
235 : : void SetSyntaxColor( Font* pFont, ScBaseCell* pCell );
236 : : void SetEditSyntaxColor( EditEngine& rEngine, ScBaseCell* pCell );
237 : :
238 : : double GetStretch();
239 : :
240 : : void DrawRotatedFrame( const Color* pForceColor ); // pixel
241 : :
242 : : drawinglayer::processor2d::BaseProcessor2D* CreateProcessor2D( );
243 : :
244 : : void DrawEditStandard(DrawEditParam& rParam);
245 : : void DrawEditBottomTop(DrawEditParam& rParam);
246 : : void DrawEditTopBottom(DrawEditParam& rParam);
247 : : void DrawEditStacked(DrawEditParam& rParam);
248 : : void DrawEditAsianVertical(DrawEditParam& rParam);
249 : :
250 : : ScFieldEditEngine* CreateOutputEditEngine();
251 : :
252 : : public:
253 : : ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
254 : : ScTableInfo& rTabInfo, ScDocument* pNewDoc,
255 : : SCTAB nNewTab, long nNewScrX, long nNewScrY,
256 : : SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
257 : : double nPixelPerTwipsX, double nPixelPerTwipsY,
258 : : const Fraction* pZoomX = NULL,
259 : : const Fraction* pZoomY = NULL );
260 : :
261 : : ~ScOutputData();
262 : :
263 : : void SetContentDevice( OutputDevice* pContentDev );
264 : :
265 : 63 : void SetRefDevice( OutputDevice* pRDev ) { mpRefDevice = pFmtDevice = pRDev; }
266 : 70 : void SetFmtDevice( OutputDevice* pRDev ) { pFmtDevice = pRDev; }
267 : 1278 : void SetEditObject( SdrObject* pObj ) { pEditObj = pObj; }
268 : 1278 : void SetViewShell( ScTabViewShell* pSh ) { pViewShell = pSh; }
269 : :
270 : : // #114135#
271 : 67 : void SetDrawView( FmFormView* pNew ) { pDrawView = pNew; }
272 : :
273 : 1278 : void SetSolidBackground( sal_Bool bSet ) { bSolidBackground = bSet; }
274 : 1341 : void SetUseStyleColor( sal_Bool bSet ) { mbUseStyleColor = bSet; }
275 : :
276 : : void SetEditCell( SCCOL nCol, SCROW nRow );
277 : : void SetSyntaxMode( sal_Bool bNewMode );
278 : : void SetMetaFileMode( sal_Bool bNewMode );
279 : : void SetSingleGrid( sal_Bool bNewMode );
280 : : void SetGridColor( const Color& rColor );
281 : : void SetMarkClipped( sal_Bool bSet );
282 : : void SetShowNullValues ( sal_Bool bSet = sal_True );
283 : : void SetShowFormulas ( sal_Bool bSet = sal_True );
284 : : void SetShowSpellErrors( sal_Bool bSet = sal_True );
285 : : void SetMirrorWidth( long nNew );
286 : 1341 : long GetScrW() const { return nScrW; }
287 : 1341 : long GetScrH() const { return nScrH; }
288 : :
289 : : void SetSnapPixel( sal_Bool bSet = sal_True );
290 : :
291 : : void DrawGrid( sal_Bool bGrid, sal_Bool bPage );
292 : : void DrawStrings( sal_Bool bPixelToLogic = false );
293 : : void DrawDocumentBackground();
294 : : void DrawBackground();
295 : : void DrawShadow();
296 : : void DrawExtraShadow(sal_Bool bLeft, sal_Bool bTop, sal_Bool bRight, sal_Bool bBottom);
297 : : void DrawFrame();
298 : :
299 : : // with logic MapMode set!
300 : : void DrawEdit(sal_Bool bPixelToLogic);
301 : :
302 : : void FindRotated();
303 : : void DrawRotated(sal_Bool bPixelToLogic); // logical
304 : :
305 : : void DrawClear();
306 : :
307 : : // #i72502# printer only command set
308 : : Point PrePrintDrawingLayer(long nLogStX, long nLogStY );
309 : : void PostPrintDrawingLayer(const Point& rMMOffset); // #i74768# need offset for FormLayer
310 : : void PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset);
311 : :
312 : : // only screen:
313 : : void DrawingSingle(const sal_uInt16 nLayer);
314 : : void DrawSelectiveObjects(const sal_uInt16 nLayer);
315 : :
316 : : sal_Bool SetChangedClip(); // sal_False = not
317 : : PolyPolygon GetChangedArea();
318 : :
319 : : void FindChanged();
320 : : void SetPagebreakMode( ScPageBreakData* pPageData );
321 : : void DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
322 : : SCCOL nRefEndX, SCROW nRefEndY,
323 : : const Color& rColor, sal_Bool bHandle );
324 : : void DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY,
325 : : SCCOL nRefEndX, SCROW nRefEndY,
326 : : const Color& rColor, sal_uInt16 nType );
327 : : void DrawChangeTrack();
328 : : void DrawClipMarks();
329 : :
330 : : void DrawNoteMarks();
331 : : void AddPDFNotes();
332 : : };
333 : :
334 : :
335 : :
336 : : #endif
337 : :
338 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|