1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtpaint.cxx,v $
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"
38 #include "rootfrm.hxx"
40 /*************************************************************************
42 *************************************************************************/
44 void SwSaveClip::Reset()
46 // Der alte Zustand wird wieder hergestellt.
49 if ( pOut
->GetConnectMetaFile() )
54 pOut
->SetClipRegion( aClip
);
56 pOut
->SetClipRegion();
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
);
76 pFrm
->SwitchHorizontalToVertical( (SwRect
&)rRect
);
78 if ( !pOut
|| (!rRect
.HasArea() && !pOut
->IsClipRegion()) )
80 (SwRect
&)rRect
= aOldRect
;
86 if ( pOut
->GetConnectMetaFile() )
89 aClip
= pOut
->GetClipRegion();
92 if ( !rRect
.HasArea() )
93 pOut
->SetClipRegion();
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
;
114 if( SwRootFrm::HasSameRect( rRect
) )
115 pOut
->SetClipRegion();
118 const Region
aClipRegion( aRect
);
119 pOut
->SetClipRegion( aClipRegion
);
120 #if OSL_DEBUG_LEVEL > 1
121 Rectangle aDbgRect
= pOut
->GetClipRegion().GetBoundRect();
124 #if OSL_DEBUG_LEVEL > 1
126 static sal_Bool bDbg
= sal_False
;
129 DbgBackColor
aDbg( pOut
, bDbg
, COL_RED
);
130 pOut
->DrawRect( aRect
);
137 (SwRect
&)rRect
= aOldRect
;