xref: /aoo41x/main/sw/source/core/text/txtpaint.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _TXTPAINT_HXX
24 #define _TXTPAINT_HXX
25 #include <vcl/outdev.hxx>
26 
27 class SwRect;				// SwSaveClip
28 #include <txtfrm.hxx>
29 
30 /*************************************************************************
31  *						class SwSaveClip
32  *************************************************************************/
33 
34 class SwSaveClip
35 {
36 	Region	 aClip;
37 	const sal_Bool	   bOn;
38 		  sal_Bool	   bChg;
39 protected:
40     OutputDevice* pOut;
41     void _ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm,
42                    sal_Bool bEnlargeRect );
43 public:
44     inline SwSaveClip( OutputDevice* pOut );
45 	inline ~SwSaveClip();
ChgClip(const SwRect & rRect,const SwTxtFrm * pFrm=0,sal_Bool bEnlargeRect=sal_False)46     inline void ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm = 0,
47                          sal_Bool bEnlargeRect = sal_False)
48              { if( pOut ) _ChgClip( rRect, pFrm, bEnlargeRect ); }
49 		   void Reset();
IsOn() const50 	inline sal_Bool IsOn()	const { return bOn; }
IsChg() const51 	inline sal_Bool IsChg() const { return bChg; }
IsOut() const52 	inline sal_Bool IsOut() const { return 0 != pOut; }
GetOut()53 	inline OutputDevice *GetOut() { return pOut; }
54 };
55 
SwSaveClip(OutputDevice * pOutDev)56 inline SwSaveClip::SwSaveClip( OutputDevice* pOutDev ) :
57     bOn( pOutDev && pOutDev->IsClipRegion() ),
58     bChg( sal_False ),
59     pOut(pOutDev)
60 {}
61 
~SwSaveClip()62 inline SwSaveClip::~SwSaveClip()
63 {
64 	Reset();
65 }
66 
67 #ifdef DBG_UTIL
68 
69 /*************************************************************************
70  *							class SwDbgOut
71  *************************************************************************/
72 
73 class SwDbgOut
74 {
75 protected:
76         OutputDevice* pOut;
77 public:
78         inline SwDbgOut( OutputDevice* pOutDev, const sal_Bool bOn = sal_True );
79 };
80 
81 /*************************************************************************
82  *							class DbgColor
83  *************************************************************************/
84 
85 class DbgColor
86 {
87 	Font *pFnt;
88 	Color aColor;
89 public:
90 		inline DbgColor( Font *pFont, const sal_Bool bOn = sal_True,
91 						 const ColorData eColor = COL_BLUE );
92 		inline ~DbgColor();
93 };
94 
95 /*************************************************************************
96  *							class DbgBrush
97  *************************************************************************/
98 
99 class DbgBackColor : public SwDbgOut
100 {
101 		Color 	aOldFillColor;
102 public:
103         DbgBackColor( OutputDevice* pOut, const sal_Bool bOn = sal_True,
104 				  ColorData nColor = COL_YELLOW );
105 	   ~DbgBackColor();
106 };
107 
108 /*************************************************************************
109  *							class DbgRect
110  *************************************************************************/
111 
112 class DbgRect : public SwDbgOut
113 {
114 public:
115         DbgRect( OutputDevice* pOut, const Rectangle &rRect,
116 				 const sal_Bool bOn = sal_True,
117 				 ColorData eColor = COL_LIGHTBLUE );
118 };
119 
120 /*************************************************************************
121  *						Inline-Implementierung
122  *************************************************************************/
123 
SwDbgOut(OutputDevice * pOutDev,const sal_Bool bOn)124 inline SwDbgOut::SwDbgOut( OutputDevice* pOutDev, const sal_Bool bOn )
125 			   :pOut( bOn ? pOutDev : 0 )
126 { }
127 
128 
DbgColor(Font * pFont,const sal_Bool bOn,const ColorData eColor)129 inline DbgColor::DbgColor( Font *pFont, const sal_Bool bOn,
130 				 const ColorData eColor )
131 	:pFnt( bOn ? pFont : 0 )
132 {
133 	if( pFnt )
134 	{
135 		aColor = pFnt->GetColor();
136 		pFnt->SetColor( Color( eColor ) );
137 	}
138 }
139 
~DbgColor()140 inline DbgColor::~DbgColor()
141 {
142 	if( pFnt )
143 		pFnt->SetColor( aColor );
144 }
145 
DbgBackColor(OutputDevice * pOutDev,const sal_Bool bOn,ColorData eColor)146 inline DbgBackColor::DbgBackColor( OutputDevice* pOutDev, const sal_Bool bOn,
147 						   ColorData eColor )
148 	:SwDbgOut( pOutDev, bOn )
149 {
150 	if( pOut )
151 	{
152 		aOldFillColor = pOut->GetFillColor();
153 		pOut->SetFillColor( Color(eColor) );
154 	}
155 }
156 
~DbgBackColor()157 inline DbgBackColor::~DbgBackColor()
158 {
159 	if( pOut )
160 	{
161 		pOut->SetFillColor( aOldFillColor );
162 	}
163 }
164 
DbgRect(OutputDevice * pOutDev,const Rectangle & rRect,const sal_Bool bOn,ColorData eColor)165 inline DbgRect::DbgRect( OutputDevice* pOutDev, const Rectangle &rRect,
166 						 const sal_Bool bOn,
167 						 ColorData eColor )
168 	: SwDbgOut( pOutDev, bOn )
169 {
170 	if( pOut )
171 	{
172 		const Color aColor( eColor );
173 		Color aLineColor = pOut->GetLineColor();
174 		pOut->SetLineColor( aColor );
175 		Color aFillColor = pOut->GetFillColor();
176 		pOut->SetFillColor( Color(COL_TRANSPARENT) );
177 		pOut->DrawRect( rRect );
178 		pOut->SetLineColor( aLineColor );
179 		pOut->SetFillColor( aFillColor );
180 	}
181 }
182 
183 #endif
184 
185 
186 
187 #endif
188