xref: /aoo41x/main/sw/source/core/text/txtpaint.cxx (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 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 
32 
33 #include "txtpaint.hxx"
34 #include "swrect.hxx"
35 #include "rootfrm.hxx"
36 
37 /*************************************************************************
38  *                      SwSaveClip::Reset()
39  *************************************************************************/
40 
41 void SwSaveClip::Reset()
42 {
43 	// Der alte Zustand wird wieder hergestellt.
44 	if( pOut && bChg )
45 	{
46 		if ( pOut->GetConnectMetaFile() )
47 			pOut->Pop();
48 		else
49 		{
50 			if( bOn )
51 				pOut->SetClipRegion( aClip );
52 			else
53 				pOut->SetClipRegion();
54 		}
55 		bChg = sal_False;
56 	}
57 }
58 
59 /*************************************************************************
60  *						SwSaveClip::_ChgClip()
61  *************************************************************************/
62 
63 void SwSaveClip::_ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm,
64                            sal_Bool bEnlargeRect )
65 {
66     SwRect aOldRect( rRect );
67     const sal_Bool bVertical = pFrm && pFrm->IsVertical();
68 
69     if ( pFrm && pFrm->IsRightToLeft() )
70         pFrm->SwitchLTRtoRTL( (SwRect&)rRect );
71 
72     if ( bVertical )
73         pFrm->SwitchHorizontalToVertical( (SwRect&)rRect );
74 
75     if ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
76     {
77         (SwRect&)rRect = aOldRect;
78         return;
79     }
80 
81 	if ( !bChg )
82 	{
83 		if ( pOut->GetConnectMetaFile() )
84 			pOut->Push();
85 		else if ( bOn )
86             aClip = pOut->GetClipRegion();
87 	}
88 
89 	if ( !rRect.HasArea() )
90 		pOut->SetClipRegion();
91 	else
92 	{
93         Rectangle aRect( rRect.SVRect() );
94 
95         // Having underscores in our line, we enlarged the repaint area
96         // (see frmform.cxx) because for some fonts it could be too small.
97         // Consequently, we have to enlarge the clipping rectangle as well.
98         if ( bEnlargeRect && ! bVertical )
99             aRect.Bottom() += 40;
100 
101 		// Wenn das ClipRect identisch ist, passiert nix.
102         if( pOut->IsClipRegion() ) // kein && wg Mac
103         {
104             if ( aRect == pOut->GetClipRegion().GetBoundRect() )
105             {
106                 (SwRect&)rRect = aOldRect;
107                 return;
108             }
109         }
110 
111 		if( SwRootFrm::HasSameRect( rRect ) )
112 			pOut->SetClipRegion();
113 		else
114 		{
115 			const Region aClipRegion( aRect );
116 			pOut->SetClipRegion( aClipRegion );
117 #if OSL_DEBUG_LEVEL > 1
118             Rectangle aDbgRect = pOut->GetClipRegion().GetBoundRect();
119 #endif
120 		}
121 #if OSL_DEBUG_LEVEL > 1
122 #ifdef DBG_UTIL
123 		static sal_Bool bDbg = sal_False;
124 		if( bDbg )
125 		{
126 			DbgBackColor aDbg( pOut, bDbg, COL_RED );
127 			pOut->DrawRect( aRect );
128 		}
129 #endif
130 #endif
131 	}
132 	bChg = sal_True;
133 
134     (SwRect&)rRect = aOldRect;
135 }
136 
137 
138