1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: paraprev.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
36 #include <svx/paraprev.hxx>
38 // STATIC DATA -----------------------------------------------------------
40 #define FOUR_POINTS 80
42 // class SvxParaPrevWindow -----------------------------------------------
44 SvxParaPrevWindow::SvxParaPrevWindow( Window
* pParent
, const ResId
& rId
) :
46 Window( pParent
, rId
),
53 eAdjust ( SVX_ADJUST_LEFT
),
54 eLastLine ( SVX_ADJUST_LEFT
),
55 eLine ( SVX_PREV_LINESPACE_1
),
59 // defaultmaessing in Twips rechnen
60 SetMapMode( MapMode( MAP_TWIP
) );
61 aWinSize
= GetOutputSizePixel();
62 aWinSize
= PixelToLogic( aWinSize
);
64 aTmp
= PixelToLogic(aTmp
);
65 aWinSize
.Width() -= aTmp
.Width() /2;
66 aWinSize
.Height() -= aTmp
.Height() /2;
68 aSize
= Size( 11905, 16837 );
70 SetBorderStyle( WINDOW_BORDER_MONO
);
73 // -----------------------------------------------------------------------
75 void SvxParaPrevWindow::Paint( const Rectangle
& )
77 DrawParagraph( TRUE
);
80 // -----------------------------------------------------------------------
82 #define DEF_MARGIN 120
84 void SvxParaPrevWindow::DrawParagraph( BOOL bAll
)
86 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
87 const Color
& rWinColor
= rStyleSettings
.GetWindowColor();
88 Color
aGrayColor(COL_LIGHTGRAY
);
90 SetFillColor( Color( rWinColor
) );
92 DrawRect( Rectangle( Point(), aWinSize
) );
96 long nH
= aWinSize
.Height() / 19;
97 Size
aLineSiz( aWinSize
.Width() - DEF_MARGIN
, nH
),
100 aPnt
.X() = DEF_MARGIN
/ 2;
101 SetFillColor( aGrayColor
);
103 for ( USHORT i
= 0; i
< 9; ++i
)
107 SetFillColor( Color( COL_GRAY
) );
108 long nTop
= nUpper
* aLineSiz
.Height() / aSize
.Height();
109 aPnt
.Y() += nTop
* 2;
113 SetFillColor( aGrayColor
);
115 if ( 3 <= i
&& 6 > i
)
117 long nLeft
= nLeftMargin
* aLineSiz
.Width() / aSize
.Width();
118 long nFirst
= nFirstLineOfst
* aLineSiz
.Width() / aSize
.Width();
119 long nTmp
= nLeft
+ nFirst
;
124 aSiz
.Width() -= nTmp
;
129 aSiz
.Width() -= nLeft
;
131 long nRight
= nRightMargin
* aLineSiz
.Width() / aSize
.Width();
132 aSiz
.Width() -= nRight
;
135 if ( 4 == i
|| 5 == i
|| 6 == i
)
139 case SVX_PREV_LINESPACE_1
: break;
140 case SVX_PREV_LINESPACE_15
: aPnt
.Y() += nH
/ 2; break;
141 case SVX_PREV_LINESPACE_2
: aPnt
.Y() += nH
; break;
143 case SVX_PREV_LINESPACE_PROP
:
144 case SVX_PREV_LINESPACE_MIN
:
145 case SVX_PREV_LINESPACE_DURCH
: break;
151 if ( (3 <= i
) && (5 >= i
) )
157 case 3: nLW
= aLineSiz
.Width() * 8 / 10; break;
158 case 4: nLW
= aLineSiz
.Width() * 9 / 10; break;
159 case 5: nLW
= aLineSiz
.Width() / 2; break;
162 if ( nLW
> aSiz
.Width() )
167 case SVX_ADJUST_LEFT
:
169 case SVX_ADJUST_RIGHT
:
170 aPnt
.X() += ( aSiz
.Width() - nLW
);
172 case SVX_ADJUST_CENTER
:
173 aPnt
.X() += ( aSiz
.Width() - nLW
) / 2;
175 default: ; //prevent warning
177 if( SVX_ADJUST_BLOCK
== eAdjust
)
183 case SVX_ADJUST_LEFT
:
185 case SVX_ADJUST_RIGHT
:
186 aPnt
.X() += ( aSiz
.Width() - nLW
);
188 case SVX_ADJUST_CENTER
:
189 aPnt
.X() += ( aSiz
.Width() - nLW
) / 2;
191 case SVX_ADJUST_BLOCK
:
194 default: ; //prevent warning
203 Rectangle
aRect( aPnt
, aSiz
);
205 if ( Lines
[i
] != aRect
|| bAll
)
209 Color aFillCol
= GetFillColor();
210 SetFillColor( rWinColor
);
211 DrawRect( Lines
[i
] );
212 SetFillColor( aFillCol
);
220 long nBottom
= nLower
* aLineSiz
.Height() / aSize
.Height();
221 aPnt
.Y() += nBottom
* 2;
225 // wieder zuruecksetzen, fuer jede Linie neu berechnen
226 aPnt
.X() = DEF_MARGIN
/ 2;
233 // -----------------------------------------------------------------------
235 void SvxParaPrevWindow::OutputSizeChanged()
237 aWinSize
= GetOutputSizePixel();
238 aWinSize
= PixelToLogic( aWinSize
);