merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / text / txtpaint.cxx
blob0c0ed86b4f8b00e11a5b3758e91335feb39977fa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtpaint.cxx,v $
10 * $Revision: 1.11 $
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_sw.hxx"
36 #include "txtpaint.hxx"
37 #include "swrect.hxx"
38 #include "rootfrm.hxx"
40 /*************************************************************************
41 * SwSaveClip::Reset()
42 *************************************************************************/
44 void SwSaveClip::Reset()
46 // Der alte Zustand wird wieder hergestellt.
47 if( pOut && bChg )
49 if ( pOut->GetConnectMetaFile() )
50 pOut->Pop();
51 else
53 if( bOn )
54 pOut->SetClipRegion( aClip );
55 else
56 pOut->SetClipRegion();
58 bChg = sal_False;
62 /*************************************************************************
63 * SwSaveClip::_ChgClip()
64 *************************************************************************/
66 void SwSaveClip::_ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm,
67 sal_Bool bEnlargeRect )
69 SwRect aOldRect( rRect );
70 const sal_Bool bVertical = pFrm && pFrm->IsVertical();
72 if ( pFrm && pFrm->IsRightToLeft() )
73 pFrm->SwitchLTRtoRTL( (SwRect&)rRect );
75 if ( bVertical )
76 pFrm->SwitchHorizontalToVertical( (SwRect&)rRect );
78 if ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
80 (SwRect&)rRect = aOldRect;
81 return;
84 if ( !bChg )
86 if ( pOut->GetConnectMetaFile() )
87 pOut->Push();
88 else if ( bOn )
89 aClip = pOut->GetClipRegion();
92 if ( !rRect.HasArea() )
93 pOut->SetClipRegion();
94 else
96 Rectangle aRect( rRect.SVRect() );
98 // Having underscores in our line, we enlarged the repaint area
99 // (see frmform.cxx) because for some fonts it could be too small.
100 // Consequently, we have to enlarge the clipping rectangle as well.
101 if ( bEnlargeRect && ! bVertical )
102 aRect.Bottom() += 40;
104 // Wenn das ClipRect identisch ist, passiert nix.
105 if( pOut->IsClipRegion() ) // kein && wg Mac
107 if ( aRect == pOut->GetClipRegion().GetBoundRect() )
109 (SwRect&)rRect = aOldRect;
110 return;
114 if( SwRootFrm::HasSameRect( rRect ) )
115 pOut->SetClipRegion();
116 else
118 const Region aClipRegion( aRect );
119 pOut->SetClipRegion( aClipRegion );
120 #if OSL_DEBUG_LEVEL > 1
121 Rectangle aDbgRect = pOut->GetClipRegion().GetBoundRect();
122 #endif
124 #if OSL_DEBUG_LEVEL > 1
125 #ifndef PRODUCT
126 static sal_Bool bDbg = sal_False;
127 if( bDbg )
129 DbgBackColor aDbg( pOut, bDbg, COL_RED );
130 pOut->DrawRect( aRect );
132 #endif
133 #endif
135 bChg = sal_True;
137 (SwRect&)rRect = aOldRect;