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