fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / svx / source / dialog / paraprev.cxx
bloba8e2b56ce0bbe3b735c93ba65560ee81e1b09f5c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <sfx2/dialoghelper.hxx>
21 #include <svx/paraprev.hxx>
22 #include <vcl/builderfactory.hxx>
23 #include <vcl/settings.hxx>
25 SvxParaPrevWindow::SvxParaPrevWindow( vcl::Window* pParent, WinBits nBits) :
26 Window( pParent, nBits),
27 nLeftMargin ( 0 ),
28 nRightMargin ( 0 ),
29 nFirstLineOfst ( 0 ),
30 nUpper ( 0 ),
31 nLower ( 0 ),
32 eAdjust ( SVX_ADJUST_LEFT ),
33 eLastLine ( SVX_ADJUST_LEFT ),
34 eLine ( SVX_PREV_LINESPACE_1 ),
35 nLineVal ( 0 )
38 // Count in Twips by default
39 SetMapMode(MapMode(MAP_TWIP));
41 aSize = Size(11905, 16837);
43 SetBorderStyle(WindowBorderStyle::MONO);
46 VCL_BUILDER_FACTORY_ARGS(SvxParaPrevWindow, WB_BORDER)
48 Size SvxParaPrevWindow::GetOptimalSize() const
50 return getParagraphPreviewOptimalSize(this);
53 void SvxParaPrevWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
55 DrawParagraph(rRenderContext, true);
58 #define DEF_MARGIN 120
60 void SvxParaPrevWindow::DrawParagraph(vcl::RenderContext& rRenderContext, bool bAll)
62 Size aWinSize(GetOutputSizePixel());
63 aWinSize = rRenderContext.PixelToLogic(aWinSize);
64 Size aTmp(1, 1);
65 aTmp = PixelToLogic(aTmp);
66 aWinSize.Width() -= aTmp.Width() /2;
67 aWinSize.Height() -= aTmp.Height() /2;
69 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
70 const Color& rWinColor = rStyleSettings.GetWindowColor();
71 Color aGrayColor(COL_LIGHTGRAY);
73 rRenderContext.SetFillColor(Color(rWinColor));
74 if (bAll)
75 rRenderContext.DrawRect(Rectangle(Point(), aWinSize));
77 rRenderContext.SetLineColor();
79 long nH = aWinSize.Height() / 19;
80 Size aLineSiz(aWinSize.Width() - DEF_MARGIN, nH);
81 Size aSiz = aLineSiz;
82 Point aPnt;
83 aPnt.X() = DEF_MARGIN / 2;
84 rRenderContext.SetFillColor(aGrayColor);
86 for (sal_uInt16 i = 0; i < 9; ++i)
88 if (i == 3)
90 rRenderContext.SetFillColor(Color(COL_GRAY));
91 long nTop = nUpper * aLineSiz.Height() / aSize.Height();
92 aPnt.Y() += nTop * 2;
95 if (i == 6 )
96 rRenderContext.SetFillColor(aGrayColor);
98 if (3 <= i && 6 > i)
100 long nLeft = nLeftMargin * aLineSiz.Width() / aSize.Width();
101 long nFirst = nFirstLineOfst * aLineSiz.Width() / aSize.Width();
102 long nTmp = nLeft + nFirst;
104 if (i == 3)
106 aPnt.X() += nTmp;
107 aSiz.Width() -= nTmp;
109 else
111 aPnt.X() += nLeft;
112 aSiz.Width() -= nLeft;
114 long nRight = nRightMargin * aLineSiz.Width() / aSize.Width();
115 aSiz.Width() -= nRight;
118 if (4 == i || 5 == i || 6 == i)
120 switch (eLine)
122 case SVX_PREV_LINESPACE_1:
123 break;
124 case SVX_PREV_LINESPACE_15:
125 aPnt.Y() += nH / 2;
126 break;
127 case SVX_PREV_LINESPACE_2:
128 aPnt.Y() += nH;
129 break;
130 case SVX_PREV_LINESPACE_PROP:
131 case SVX_PREV_LINESPACE_MIN:
132 case SVX_PREV_LINESPACE_DURCH:
133 break;
137 aPnt.Y() += nH;
139 if (3 <= i && 5 >= i)
141 long nLW = long();
142 switch (i)
144 case 3:
145 nLW = aLineSiz.Width() * 8 / 10;
146 break;
147 case 4:
148 nLW = aLineSiz.Width() * 9 / 10;
149 break;
150 case 5:
151 nLW = aLineSiz.Width() / 2;
152 break;
155 if (nLW > aSiz.Width())
156 nLW = aSiz.Width();
158 switch (eAdjust)
160 case SVX_ADJUST_LEFT:
161 break;
162 case SVX_ADJUST_RIGHT:
163 aPnt.X() += ( aSiz.Width() - nLW );
164 break;
165 case SVX_ADJUST_CENTER:
166 aPnt.X() += ( aSiz.Width() - nLW ) / 2;
167 break;
168 default: ; //prevent warning
170 if (SVX_ADJUST_BLOCK == eAdjust)
172 if(5 == i)
174 switch( eLastLine )
176 case SVX_ADJUST_LEFT:
177 break;
178 case SVX_ADJUST_RIGHT:
179 aPnt.X() += ( aSiz.Width() - nLW );
180 break;
181 case SVX_ADJUST_CENTER:
182 aPnt.X() += ( aSiz.Width() - nLW ) / 2;
183 break;
184 case SVX_ADJUST_BLOCK:
185 nLW = aSiz.Width();
186 break;
187 default: ; //prevent warning
190 else
191 nLW = aSiz.Width();
193 aSiz.Width() = nLW;
196 Rectangle aRect(aPnt, aSiz);
198 if (Lines[i] != aRect || bAll)
200 if (!bAll)
202 Color aFillCol = rRenderContext.GetFillColor();
203 rRenderContext.SetFillColor(rWinColor);
204 rRenderContext.DrawRect(Lines[i]);
205 rRenderContext.SetFillColor(aFillCol);
207 rRenderContext.DrawRect( aRect );
208 Lines[i] = aRect;
211 if (5 == i)
213 long nBottom = nLower * aLineSiz.Height() / aSize.Height();
214 aPnt.Y() += nBottom * 2;
217 aPnt.Y() += nH;
218 // Reset, recalculate for each line
219 aPnt.X() = DEF_MARGIN / 2;
220 aSiz = aLineSiz;
224 #undef DEF_MARGIN
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */