xref: /aoo42x/main/sw/source/core/text/txtpaint.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _TXTPAINT_HXX
28 #define _TXTPAINT_HXX
29 #include <vcl/outdev.hxx>
30 
31 class SwRect;				// SwSaveClip
32 #include <txtfrm.hxx>
33 
34 /*************************************************************************
35  *						class SwSaveClip
36  *************************************************************************/
37 
38 class SwSaveClip
39 {
40 	Region	 aClip;
41 	const sal_Bool	   bOn;
42 		  sal_Bool	   bChg;
43 protected:
44     OutputDevice* pOut;
45     void _ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm,
46                    sal_Bool bEnlargeRect );
47 public:
48     inline SwSaveClip( OutputDevice* pOut );
49 	inline ~SwSaveClip();
50     inline void ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm = 0,
51                          sal_Bool bEnlargeRect = sal_False)
52              { if( pOut ) _ChgClip( rRect, pFrm, bEnlargeRect ); }
53 		   void Reset();
54 	inline sal_Bool IsOn()	const { return bOn; }
55 	inline sal_Bool IsChg() const { return bChg; }
56 	inline sal_Bool IsOut() const { return 0 != pOut; }
57 	inline OutputDevice *GetOut() { return pOut; }
58 };
59 
60 inline SwSaveClip::SwSaveClip( OutputDevice* pOutDev ) :
61     bOn( pOutDev && pOutDev->IsClipRegion() ),
62     bChg( sal_False ),
63     pOut(pOutDev)
64 {}
65 
66 inline SwSaveClip::~SwSaveClip()
67 {
68 	Reset();
69 }
70 
71 #ifdef DBG_UTIL
72 
73 /*************************************************************************
74  *							class SwDbgOut
75  *************************************************************************/
76 
77 class SwDbgOut
78 {
79 protected:
80         OutputDevice* pOut;
81 public:
82         inline SwDbgOut( OutputDevice* pOutDev, const sal_Bool bOn = sal_True );
83 };
84 
85 /*************************************************************************
86  *							class DbgColor
87  *************************************************************************/
88 
89 class DbgColor
90 {
91 	Font *pFnt;
92 	Color aColor;
93 public:
94 		inline DbgColor( Font *pFont, const sal_Bool bOn = sal_True,
95 						 const ColorData eColor = COL_BLUE );
96 		inline ~DbgColor();
97 };
98 
99 /*************************************************************************
100  *							class DbgBrush
101  *************************************************************************/
102 
103 class DbgBackColor : public SwDbgOut
104 {
105 		Color 	aOldFillColor;
106 public:
107         DbgBackColor( OutputDevice* pOut, const sal_Bool bOn = sal_True,
108 				  ColorData nColor = COL_YELLOW );
109 	   ~DbgBackColor();
110 };
111 
112 /*************************************************************************
113  *							class DbgRect
114  *************************************************************************/
115 
116 class DbgRect : public SwDbgOut
117 {
118 public:
119         DbgRect( OutputDevice* pOut, const Rectangle &rRect,
120 				 const sal_Bool bOn = sal_True,
121 				 ColorData eColor = COL_LIGHTBLUE );
122 };
123 
124 /*************************************************************************
125  *						Inline-Implementierung
126  *************************************************************************/
127 
128 inline SwDbgOut::SwDbgOut( OutputDevice* pOutDev, const sal_Bool bOn )
129 			   :pOut( bOn ? pOutDev : 0 )
130 { }
131 
132 
133 inline DbgColor::DbgColor( Font *pFont, const sal_Bool bOn,
134 				 const ColorData eColor )
135 	:pFnt( bOn ? pFont : 0 )
136 {
137 	if( pFnt )
138 	{
139 		aColor = pFnt->GetColor();
140 		pFnt->SetColor( Color( eColor ) );
141 	}
142 }
143 
144 inline DbgColor::~DbgColor()
145 {
146 	if( pFnt )
147 		pFnt->SetColor( aColor );
148 }
149 
150 inline DbgBackColor::DbgBackColor( OutputDevice* pOutDev, const sal_Bool bOn,
151 						   ColorData eColor )
152 	:SwDbgOut( pOutDev, bOn )
153 {
154 	if( pOut )
155 	{
156 		aOldFillColor = pOut->GetFillColor();
157 		pOut->SetFillColor( Color(eColor) );
158 	}
159 }
160 
161 inline DbgBackColor::~DbgBackColor()
162 {
163 	if( pOut )
164 	{
165 		pOut->SetFillColor( aOldFillColor );
166 	}
167 }
168 
169 inline DbgRect::DbgRect( OutputDevice* pOutDev, const Rectangle &rRect,
170 						 const sal_Bool bOn,
171 						 ColorData eColor )
172 	: SwDbgOut( pOutDev, bOn )
173 {
174 	if( pOut )
175 	{
176 		const Color aColor( eColor );
177 		Color aLineColor = pOut->GetLineColor();
178 		pOut->SetLineColor( aColor );
179 		Color aFillColor = pOut->GetFillColor();
180 		pOut->SetFillColor( Color(COL_TRANSPARENT) );
181 		pOut->DrawRect( rRect );
182 		pOut->SetLineColor( aLineColor );
183 		pOut->SetFillColor( aFillColor );
184 	}
185 }
186 
187 #endif
188 
189 
190 
191 #endif
192