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 : #include "scitems.hxx"
21 : #include <svx/algitem.hxx>
22 : #include <editeng/boxitem.hxx>
23 : #include <editeng/brushitem.hxx>
24 : #include <editeng/contouritem.hxx>
25 : #include <editeng/colritem.hxx>
26 : #include <editeng/crossedoutitem.hxx>
27 : #include <editeng/fontitem.hxx>
28 : #include <editeng/postitem.hxx>
29 : #include <editeng/shdditem.hxx>
30 : #include <editeng/udlnitem.hxx>
31 : #include <editeng/wghtitem.hxx>
32 : #include <vcl/svapp.hxx>
33 : #include <svl/zforlist.hxx>
34 : #include <vcl/msgbox.hxx>
35 : #include <vcl/settings.hxx>
36 : #include <vcl/builderfactory.hxx>
37 : #include <sfx2/viewfrm.hxx>
38 : #include <comphelper/processfactory.hxx>
39 :
40 : #include "sc.hrc"
41 : #include "scmod.hxx"
42 : #include "attrib.hxx"
43 : #include "zforauto.hxx"
44 : #include "global.hxx"
45 : #include "globstr.hrc"
46 : #include "autoform.hxx"
47 : #include "miscdlgs.hrc"
48 : #include "autofmt.hxx"
49 : #include "scresid.hxx"
50 : #include "document.hxx"
51 : #include "docsh.hxx"
52 : #include "tabvwsh.hxx"
53 :
54 : #define FRAME_OFFSET 4
55 :
56 : // ScAutoFmtPreview
57 :
58 0 : ScAutoFmtPreview::ScAutoFmtPreview(vcl::Window* pParent)
59 : : Window(pParent)
60 : , pCurData(NULL)
61 : , aVD(*this)
62 : , bFitWidth(false)
63 : , mbRTL(false)
64 : , aStrJan(ScResId(STR_JAN))
65 : , aStrFeb(ScResId(STR_FEB))
66 : , aStrMar(ScResId(STR_MAR))
67 : , aStrNorth(ScResId(STR_NORTH))
68 : , aStrMid(ScResId(STR_MID))
69 : , aStrSouth(ScResId(STR_SOUTH))
70 : , aStrSum(ScResId(STR_SUM))
71 0 : , pNumFmt(new SvNumberFormatter(::comphelper::getProcessComponentContext(), ScGlobal::eLnge))
72 : {
73 0 : Init();
74 0 : }
75 :
76 0 : VCL_BUILDER_FACTORY(ScAutoFmtPreview)
77 :
78 0 : void ScAutoFmtPreview::Resize()
79 : {
80 0 : aPrvSize = Size(GetSizePixel().Width() - 6, GetSizePixel().Height() - 30);
81 0 : mnLabelColWidth = (aPrvSize.Width() - 4) / 4 - 12;
82 0 : mnDataColWidth1 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 3;
83 0 : mnDataColWidth2 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 4;
84 0 : mnRowHeight = (aPrvSize.Height() - 4) / 5;
85 0 : NotifyChange(pCurData);
86 0 : }
87 :
88 0 : ScAutoFmtPreview::~ScAutoFmtPreview()
89 : {
90 0 : disposeOnce();
91 0 : }
92 :
93 0 : void ScAutoFmtPreview::dispose()
94 : {
95 0 : delete pNumFmt;
96 0 : vcl::Window::dispose();
97 0 : }
98 :
99 0 : static void lcl_SetFontProperties(
100 : vcl::Font& rFont,
101 : const SvxFontItem& rFontItem,
102 : const SvxWeightItem& rWeightItem,
103 : const SvxPostureItem& rPostureItem )
104 : {
105 0 : rFont.SetFamily ( rFontItem.GetFamily() );
106 0 : rFont.SetName ( rFontItem.GetFamilyName() );
107 0 : rFont.SetStyleName ( rFontItem.GetStyleName() );
108 0 : rFont.SetCharSet ( rFontItem.GetCharSet() );
109 0 : rFont.SetPitch ( rFontItem.GetPitch() );
110 0 : rFont.SetWeight ( (FontWeight)rWeightItem.GetValue() );
111 0 : rFont.SetItalic ( (FontItalic)rPostureItem.GetValue() );
112 0 : }
113 :
114 0 : void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont )
115 : {
116 0 : if ( pCurData )
117 : {
118 0 : rFont = rCJKFont = rCTLFont = GetFont();
119 0 : Size aFontSize( rFont.GetSize().Width(), 10 * GetDPIScaleFactor() );
120 :
121 0 : const SvxFontItem* pFontItem = static_cast<const SvxFontItem*> (pCurData->GetItem( nIndex, ATTR_FONT ));
122 0 : const SvxWeightItem* pWeightItem = static_cast<const SvxWeightItem*> (pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT ));
123 0 : const SvxPostureItem* pPostureItem = static_cast<const SvxPostureItem*> (pCurData->GetItem( nIndex, ATTR_FONT_POSTURE ));
124 0 : const SvxFontItem* pCJKFontItem = static_cast<const SvxFontItem*> (pCurData->GetItem( nIndex, ATTR_CJK_FONT ));
125 0 : const SvxWeightItem* pCJKWeightItem = static_cast<const SvxWeightItem*> (pCurData->GetItem( nIndex, ATTR_CJK_FONT_WEIGHT ));
126 0 : const SvxPostureItem* pCJKPostureItem = static_cast<const SvxPostureItem*> (pCurData->GetItem( nIndex, ATTR_CJK_FONT_POSTURE ));
127 0 : const SvxFontItem* pCTLFontItem = static_cast<const SvxFontItem*> (pCurData->GetItem( nIndex, ATTR_CTL_FONT ));
128 0 : const SvxWeightItem* pCTLWeightItem = static_cast<const SvxWeightItem*> (pCurData->GetItem( nIndex, ATTR_CTL_FONT_WEIGHT ));
129 0 : const SvxPostureItem* pCTLPostureItem = static_cast<const SvxPostureItem*> (pCurData->GetItem( nIndex, ATTR_CTL_FONT_POSTURE ));
130 0 : const SvxUnderlineItem* pUnderlineItem = static_cast<const SvxUnderlineItem*> (pCurData->GetItem( nIndex, ATTR_FONT_UNDERLINE ));
131 0 : const SvxOverlineItem* pOverlineItem = static_cast<const SvxOverlineItem*> (pCurData->GetItem( nIndex, ATTR_FONT_OVERLINE ));
132 0 : const SvxCrossedOutItem* pCrossedOutItem = static_cast<const SvxCrossedOutItem*>(pCurData->GetItem( nIndex, ATTR_FONT_CROSSEDOUT ));
133 0 : const SvxContourItem* pContourItem = static_cast<const SvxContourItem*> (pCurData->GetItem( nIndex, ATTR_FONT_CONTOUR ));
134 0 : const SvxShadowedItem* pShadowedItem = static_cast<const SvxShadowedItem*> (pCurData->GetItem( nIndex, ATTR_FONT_SHADOWED ));
135 0 : const SvxColorItem* pColorItem = static_cast<const SvxColorItem*> (pCurData->GetItem( nIndex, ATTR_FONT_COLOR ));
136 :
137 0 : lcl_SetFontProperties( rFont, *pFontItem, *pWeightItem, *pPostureItem );
138 0 : lcl_SetFontProperties( rCJKFont, *pCJKFontItem, *pCJKWeightItem, *pCJKPostureItem );
139 0 : lcl_SetFontProperties( rCTLFont, *pCTLFontItem, *pCTLWeightItem, *pCTLPostureItem );
140 :
141 0 : Color aColor( pColorItem->GetValue() );
142 0 : if( aColor.GetColor() == COL_TRANSPARENT )
143 0 : aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
144 :
145 : #define SETONALLFONTS( MethodName, Value ) \
146 : rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value );
147 :
148 0 : SETONALLFONTS( SetUnderline, (FontUnderline)pUnderlineItem->GetValue() )
149 0 : SETONALLFONTS( SetOverline, (FontUnderline)pOverlineItem->GetValue() )
150 0 : SETONALLFONTS( SetStrikeout, (FontStrikeout)pCrossedOutItem->GetValue() )
151 0 : SETONALLFONTS( SetOutline, pContourItem->GetValue() )
152 0 : SETONALLFONTS( SetShadow, pShadowedItem->GetValue() )
153 0 : SETONALLFONTS( SetColor, aColor )
154 0 : SETONALLFONTS( SetSize, aFontSize )
155 0 : SETONALLFONTS( SetTransparent, true )
156 :
157 : #undef SETONALLFONTS
158 : }
159 0 : }
160 :
161 0 : sal_uInt16 ScAutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
162 : {
163 : static const sal_uInt16 pnFmtMap[] =
164 : {
165 : 0, 1, 2, 1, 3,
166 : 4, 5, 6, 5, 7,
167 : 8, 9, 10, 9, 11,
168 : 4, 5, 6, 5, 7,
169 : 12, 13, 14, 13, 15
170 : };
171 0 : return pnFmtMap[ maArray.GetCellIndex( nCol, nRow, mbRTL ) ];
172 : }
173 :
174 0 : const SvxBoxItem& ScAutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
175 : {
176 : OSL_ENSURE( pCurData, "ScAutoFmtPreview::GetBoxItem - no format data found" );
177 0 : return *static_cast< const SvxBoxItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BORDER ) );
178 : }
179 :
180 0 : const SvxLineItem& ScAutoFmtPreview::GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const
181 : {
182 : OSL_ENSURE( pCurData, "ScAutoFmtPreview::GetDiagItem - no format data found" );
183 0 : return *static_cast< const SvxLineItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), bTLBR ? ATTR_BORDER_TLBR : ATTR_BORDER_BLTR ) );
184 : }
185 :
186 0 : void ScAutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow)
187 : {
188 0 : if (!pCurData)
189 : {
190 0 : return;
191 : }
192 :
193 : // Emit the cell text
194 :
195 0 : OUString cellString;
196 0 : bool bNumFormat = pCurData->GetIncludeValueFormat();
197 : sal_uLong nNum;
198 : double nVal;
199 0 : Color* pDummy = NULL;
200 0 : sal_uInt16 nIndex = static_cast<sal_uInt16>(maArray.GetCellIndex(nCol, nRow, mbRTL));
201 :
202 0 : switch (nIndex)
203 : {
204 0 : case 1: cellString = aStrJan; break;
205 0 : case 2: cellString = aStrFeb; break;
206 0 : case 3: cellString = aStrMar; break;
207 0 : case 5: cellString = aStrNorth; break;
208 0 : case 10: cellString = aStrMid; break;
209 0 : case 15: cellString = aStrSouth; break;
210 : case 4:
211 0 : case 20: cellString = aStrSum; break;
212 :
213 : case 6:
214 : case 8:
215 : case 16:
216 0 : case 18: nVal = nIndex;
217 0 : nNum = 5;
218 0 : goto mknum;
219 : case 17:
220 0 : case 7: nVal = nIndex;
221 0 : nNum = 6;
222 0 : goto mknum;
223 : case 11:
224 : case 12:
225 0 : case 13: nVal = nIndex;
226 0 : nNum = 12 == nIndex ? 10 : 9;
227 0 : goto mknum;
228 :
229 0 : case 9: nVal = 21; nNum = 7; goto mknum;
230 0 : case 14: nVal = 36; nNum = 11; goto mknum;
231 0 : case 19: nVal = 51; nNum = 7; goto mknum;
232 0 : case 21: nVal = 33; nNum = 13; goto mknum;
233 0 : case 22: nVal = 36; nNum = 14; goto mknum;
234 0 : case 23: nVal = 39; nNum = 13; goto mknum;
235 0 : case 24: nVal = 108; nNum = 15;
236 : mknum:
237 0 : if (bNumFormat)
238 : {
239 0 : ScNumFormatAbbrev& rNumFormat = (ScNumFormatAbbrev&) pCurData->GetNumFormat(sal_uInt16(nNum));
240 0 : nNum = rNumFormat.GetFormatIndex(*pNumFmt);
241 : }
242 : else
243 0 : nNum = 0;
244 0 : pNumFmt->GetOutputString(nVal, nNum, cellString, &pDummy);
245 0 : break;
246 : }
247 :
248 0 : if (!cellString.isEmpty())
249 : {
250 :
251 0 : Size aStrSize;
252 0 : sal_uInt16 nFmtIndex = GetFormatIndex( nCol, nRow );
253 0 : Rectangle cellRect = maArray.GetCellRect( nCol, nRow );
254 0 : Point aPos = cellRect.TopLeft();
255 0 : sal_uInt16 nRightX = 0;
256 0 : bool bJustify = pCurData->GetIncludeJustify();
257 0 : SvxHorJustifyItem aHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY );
258 : SvxCellHorJustify eJustification;
259 :
260 0 : SvtScriptedTextHelper aScriptedText(rRenderContext);
261 :
262 : // Justification:
263 :
264 : eJustification = mbRTL ? SVX_HOR_JUSTIFY_RIGHT : bJustify ?
265 0 : (SvxCellHorJustify) (static_cast<const SvxHorJustifyItem*>(pCurData->GetItem(nFmtIndex, ATTR_HOR_JUSTIFY))->GetValue()) :
266 0 : SVX_HOR_JUSTIFY_STANDARD;
267 :
268 0 : if (pCurData->GetIncludeFont())
269 : {
270 0 : vcl::Font aFont, aCJKFont, aCTLFont;
271 0 : Size theMaxStrSize;
272 :
273 0 : MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont );
274 :
275 0 : theMaxStrSize = cellRect.GetSize();
276 0 : theMaxStrSize.Width() -= FRAME_OFFSET;
277 0 : theMaxStrSize.Height() -= FRAME_OFFSET;
278 :
279 0 : aScriptedText.SetFonts( &aFont, &aCJKFont, &aCTLFont );
280 0 : aScriptedText.SetText(cellString, xBreakIter);
281 0 : aStrSize = aScriptedText.GetTextSize();
282 :
283 0 : if (theMaxStrSize.Height() < aStrSize.Height())
284 : {
285 : // if the string does not fit in the row using this font,
286 : // the default font is used
287 0 : aScriptedText.SetDefaultFont();
288 0 : aStrSize = aScriptedText.GetTextSize();
289 : }
290 0 : while((theMaxStrSize.Width() <= aStrSize.Width()) && (cellString.getLength() > 1))
291 : {
292 0 : if( eJustification == SVX_HOR_JUSTIFY_RIGHT )
293 0 : cellString = cellString.copy(1);
294 : else
295 0 : cellString = cellString.copy(0, cellString.getLength() - 1 );
296 :
297 0 : aScriptedText.SetText( cellString, xBreakIter );
298 0 : aStrSize = aScriptedText.GetTextSize();
299 0 : }
300 : }
301 : else
302 : {
303 0 : aScriptedText.SetDefaultFont();
304 0 : aScriptedText.SetText( cellString, xBreakIter );
305 0 : aStrSize = aScriptedText.GetTextSize();
306 : }
307 :
308 0 : nRightX = sal_uInt16(cellRect.GetWidth() - aStrSize.Width() - FRAME_OFFSET);
309 :
310 : // vertical (always center):
311 :
312 0 : aPos.Y() += (mnRowHeight - (sal_uInt16)aStrSize.Height()) / 2;
313 :
314 : // horizontal
315 :
316 0 : if (eJustification != SVX_HOR_JUSTIFY_STANDARD)
317 : {
318 0 : sal_uInt16 nHorPos = sal_uInt16((cellRect.GetWidth()-aStrSize.Width()) / 2);
319 :
320 0 : switch (eJustification)
321 : {
322 : case SVX_HOR_JUSTIFY_LEFT:
323 0 : aPos.X() += FRAME_OFFSET;
324 0 : break;
325 : case SVX_HOR_JUSTIFY_RIGHT:
326 0 : aPos.X() += nRightX;
327 0 : break;
328 : case SVX_HOR_JUSTIFY_BLOCK:
329 : case SVX_HOR_JUSTIFY_REPEAT:
330 : case SVX_HOR_JUSTIFY_CENTER:
331 0 : aPos.X() += nHorPos;
332 0 : break;
333 : // coverity[dead_error_line] - following conditions exist to avoid compiler warning
334 : case SVX_HOR_JUSTIFY_STANDARD:
335 : default:
336 : // Standard is not handled here
337 0 : break;
338 : }
339 : }
340 : else
341 : {
342 :
343 : // Standard justification
344 :
345 0 : if (nCol == 0 || nRow == 0)
346 : {
347 : // Text label to the left or sum left adjusted
348 0 : aPos.X() += FRAME_OFFSET;
349 : }
350 : else
351 : {
352 : // Numbers/Dates right adjusted
353 0 : aPos.X() += nRightX;
354 : }
355 : }
356 0 : aScriptedText.DrawText(aPos);
357 0 : }
358 : }
359 :
360 : #undef FRAME_OFFSET
361 :
362 0 : void ScAutoFmtPreview::DrawStrings(vcl::RenderContext& rRenderContext)
363 : {
364 0 : for(size_t nRow = 0; nRow < 5; ++nRow)
365 0 : for(size_t nCol = 0; nCol < 5; ++nCol)
366 0 : DrawString(rRenderContext, nCol, nRow);
367 0 : }
368 :
369 0 : void ScAutoFmtPreview::DrawBackground(vcl::RenderContext& rRenderContext)
370 : {
371 0 : if (pCurData)
372 : {
373 0 : for(size_t nRow = 0; nRow < 5; ++nRow)
374 : {
375 0 : for(size_t nCol = 0; nCol < 5; ++nCol)
376 : {
377 : const SvxBrushItem* pItem = static_cast< const SvxBrushItem* >(
378 0 : pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BACKGROUND ) );
379 :
380 0 : rRenderContext.Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
381 0 : rRenderContext.SetLineColor();
382 0 : rRenderContext.SetFillColor( pItem->GetColor() );
383 0 : rRenderContext.DrawRect( maArray.GetCellRect( nCol, nRow ) );
384 0 : rRenderContext.Pop();
385 : }
386 : }
387 : }
388 0 : }
389 :
390 0 : void ScAutoFmtPreview::PaintCells(vcl::RenderContext& rRenderContext)
391 : {
392 0 : if (pCurData)
393 : {
394 : // 1) background
395 0 : if (pCurData->GetIncludeBackground())
396 0 : DrawBackground(rRenderContext);
397 :
398 : // 2) values
399 0 : DrawStrings(rRenderContext);
400 :
401 : // 3) border
402 0 : if (pCurData->GetIncludeFrame())
403 0 : maArray.DrawArray(rRenderContext);
404 : }
405 0 : }
406 :
407 0 : void ScAutoFmtPreview::Init()
408 : {
409 0 : SetBorderStyle( WindowBorderStyle::MONO );
410 0 : maArray.Initialize( 5, 5 );
411 0 : maArray.SetUseDiagDoubleClipping( false );
412 0 : CalcCellArray( false );
413 0 : CalcLineMap();
414 0 : }
415 :
416 0 : void ScAutoFmtPreview::DetectRTL(ScViewData *pViewData)
417 : {
418 0 : SCTAB nCurrentTab = pViewData->GetTabNo();
419 0 : ScDocument* pDoc = pViewData->GetDocument();
420 0 : mbRTL = pDoc->IsLayoutRTL(nCurrentTab);
421 0 : xBreakIter = pDoc->GetBreakIterator();
422 0 : }
423 :
424 0 : void ScAutoFmtPreview::CalcCellArray( bool bFitWidthP )
425 : {
426 0 : maArray.SetXOffset( 2 );
427 0 : maArray.SetAllColWidths( bFitWidthP ? mnDataColWidth2 : mnDataColWidth1 );
428 0 : maArray.SetColWidth( 0, mnLabelColWidth );
429 0 : maArray.SetColWidth( 4, mnLabelColWidth );
430 :
431 0 : maArray.SetYOffset( 2 );
432 0 : maArray.SetAllRowHeights( mnRowHeight );
433 :
434 0 : aPrvSize.Width() = maArray.GetWidth() + 4;
435 0 : aPrvSize.Height() = maArray.GetHeight() + 4;
436 0 : }
437 :
438 0 : inline void lclSetStyleFromBorder( svx::frame::Style& rStyle, const ::editeng::SvxBorderLine* pBorder )
439 : {
440 0 : rStyle.Set( pBorder, 1.0 / TWIPS_PER_POINT, 5 );
441 0 : }
442 :
443 0 : void ScAutoFmtPreview::CalcLineMap()
444 : {
445 0 : if ( pCurData )
446 : {
447 0 : for( size_t nRow = 0; nRow < 5; ++nRow )
448 : {
449 0 : for( size_t nCol = 0; nCol < 5; ++nCol )
450 : {
451 0 : svx::frame::Style aStyle;
452 :
453 0 : const SvxBoxItem& rItem = GetBoxItem( nCol, nRow );
454 0 : lclSetStyleFromBorder( aStyle, rItem.GetLeft() );
455 0 : maArray.SetCellStyleLeft( nCol, nRow, aStyle );
456 0 : lclSetStyleFromBorder( aStyle, rItem.GetRight() );
457 0 : maArray.SetCellStyleRight( nCol, nRow, aStyle );
458 0 : lclSetStyleFromBorder( aStyle, rItem.GetTop() );
459 0 : maArray.SetCellStyleTop( nCol, nRow, aStyle );
460 0 : lclSetStyleFromBorder( aStyle, rItem.GetBottom() );
461 0 : maArray.SetCellStyleBottom( nCol, nRow, aStyle );
462 :
463 0 : lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, true ).GetLine() );
464 0 : maArray.SetCellStyleTLBR( nCol, nRow, aStyle );
465 0 : lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, false ).GetLine() );
466 0 : maArray.SetCellStyleBLTR( nCol, nRow, aStyle );
467 : }
468 : }
469 : }
470 0 : }
471 :
472 0 : void ScAutoFmtPreview::NotifyChange( ScAutoFormatData* pNewData )
473 : {
474 0 : if (pNewData)
475 : {
476 0 : pCurData = pNewData;
477 0 : bFitWidth = pNewData->GetIncludeWidthHeight();
478 : }
479 :
480 0 : CalcCellArray( bFitWidth );
481 0 : CalcLineMap();
482 :
483 0 : Invalidate(Rectangle(Point(0,0), GetSizePixel()));
484 0 : }
485 :
486 0 : void ScAutoFmtPreview::DoPaint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
487 : {
488 0 : DrawModeFlags nOldDrawMode = aVD->GetDrawMode();
489 :
490 0 : Size aWndSize(GetSizePixel());
491 0 : vcl::Font aFont(aVD->GetFont());
492 0 : Color aBackCol(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor());
493 0 : Point aTmpPoint;
494 0 : Rectangle aRect(aTmpPoint, aWndSize);
495 :
496 0 : aFont.SetTransparent( true );
497 0 : aVD->SetFont(aFont);
498 0 : aVD->SetLineColor();
499 0 : aVD->SetFillColor(aBackCol);
500 0 : aVD->SetOutputSize(aWndSize);
501 0 : aVD->DrawRect(aRect);
502 :
503 0 : PaintCells(*aVD.get());
504 :
505 0 : rRenderContext.SetLineColor();
506 0 : rRenderContext.SetFillColor(aBackCol);
507 0 : rRenderContext.DrawRect(aRect);
508 :
509 0 : Point aPos((aWndSize.Width() - aPrvSize.Width()) / 2, (aWndSize.Height() - aPrvSize.Height()) / 2);
510 0 : if (AllSettings::GetLayoutRTL())
511 0 : aPos.X() = -aPos.X();
512 0 : rRenderContext.DrawOutDev(aPos, aWndSize, Point(), aWndSize, *aVD.get());
513 0 : aVD->SetDrawMode(nOldDrawMode);
514 0 : }
515 :
516 0 : void ScAutoFmtPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
517 : {
518 0 : DoPaint(rRenderContext, rRect);
519 156 : }
520 :
521 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|