xref: /AOO41X/main/sw/source/core/text/txtpaint.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "txtpaint.hxx"
30cdf0e10cSrcweir #include "swrect.hxx"
31cdf0e10cSrcweir #include "rootfrm.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /*************************************************************************
34cdf0e10cSrcweir  *                      SwSaveClip::Reset()
35cdf0e10cSrcweir  *************************************************************************/
36cdf0e10cSrcweir 
Reset()37cdf0e10cSrcweir void SwSaveClip::Reset()
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	// Der alte Zustand wird wieder hergestellt.
40cdf0e10cSrcweir 	if( pOut && bChg )
41cdf0e10cSrcweir 	{
42cdf0e10cSrcweir 		if ( pOut->GetConnectMetaFile() )
43cdf0e10cSrcweir 			pOut->Pop();
44cdf0e10cSrcweir 		else
45cdf0e10cSrcweir 		{
46cdf0e10cSrcweir 			if( bOn )
47cdf0e10cSrcweir 				pOut->SetClipRegion( aClip );
48cdf0e10cSrcweir 			else
49cdf0e10cSrcweir 				pOut->SetClipRegion();
50cdf0e10cSrcweir 		}
51cdf0e10cSrcweir 		bChg = sal_False;
52cdf0e10cSrcweir 	}
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir /*************************************************************************
56cdf0e10cSrcweir  *						SwSaveClip::_ChgClip()
57cdf0e10cSrcweir  *************************************************************************/
58cdf0e10cSrcweir 
_ChgClip(const SwRect & rRect,const SwTxtFrm * pFrm,sal_Bool bEnlargeRect)59cdf0e10cSrcweir void SwSaveClip::_ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm,
60cdf0e10cSrcweir                            sal_Bool bEnlargeRect )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     SwRect aOldRect( rRect );
63cdf0e10cSrcweir     const sal_Bool bVertical = pFrm && pFrm->IsVertical();
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     if ( pFrm && pFrm->IsRightToLeft() )
66cdf0e10cSrcweir         pFrm->SwitchLTRtoRTL( (SwRect&)rRect );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     if ( bVertical )
69cdf0e10cSrcweir         pFrm->SwitchHorizontalToVertical( (SwRect&)rRect );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     if ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
72cdf0e10cSrcweir     {
73cdf0e10cSrcweir         (SwRect&)rRect = aOldRect;
74cdf0e10cSrcweir         return;
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	if ( !bChg )
78cdf0e10cSrcweir 	{
79cdf0e10cSrcweir 		if ( pOut->GetConnectMetaFile() )
80cdf0e10cSrcweir 			pOut->Push();
81cdf0e10cSrcweir 		else if ( bOn )
82cdf0e10cSrcweir             aClip = pOut->GetClipRegion();
83cdf0e10cSrcweir 	}
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	if ( !rRect.HasArea() )
86cdf0e10cSrcweir 		pOut->SetClipRegion();
87cdf0e10cSrcweir 	else
88cdf0e10cSrcweir 	{
89cdf0e10cSrcweir         Rectangle aRect( rRect.SVRect() );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         // Having underscores in our line, we enlarged the repaint area
92cdf0e10cSrcweir         // (see frmform.cxx) because for some fonts it could be too small.
93cdf0e10cSrcweir         // Consequently, we have to enlarge the clipping rectangle as well.
94cdf0e10cSrcweir         if ( bEnlargeRect && ! bVertical )
95cdf0e10cSrcweir             aRect.Bottom() += 40;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 		// Wenn das ClipRect identisch ist, passiert nix.
98cdf0e10cSrcweir         if( pOut->IsClipRegion() ) // kein && wg Mac
99cdf0e10cSrcweir         {
100cdf0e10cSrcweir             if ( aRect == pOut->GetClipRegion().GetBoundRect() )
101cdf0e10cSrcweir             {
102cdf0e10cSrcweir                 (SwRect&)rRect = aOldRect;
103cdf0e10cSrcweir                 return;
104cdf0e10cSrcweir             }
105cdf0e10cSrcweir         }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 		if( SwRootFrm::HasSameRect( rRect ) )
108cdf0e10cSrcweir 			pOut->SetClipRegion();
109cdf0e10cSrcweir 		else
110cdf0e10cSrcweir 		{
111cdf0e10cSrcweir 			const Region aClipRegion( aRect );
112cdf0e10cSrcweir 			pOut->SetClipRegion( aClipRegion );
113cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
114cdf0e10cSrcweir             Rectangle aDbgRect = pOut->GetClipRegion().GetBoundRect();
115cdf0e10cSrcweir #endif
116cdf0e10cSrcweir 		}
117cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
118cdf0e10cSrcweir #ifdef DBG_UTIL
119cdf0e10cSrcweir 		static sal_Bool bDbg = sal_False;
120cdf0e10cSrcweir 		if( bDbg )
121cdf0e10cSrcweir 		{
122cdf0e10cSrcweir 			DbgBackColor aDbg( pOut, bDbg, COL_RED );
123cdf0e10cSrcweir 			pOut->DrawRect( aRect );
124cdf0e10cSrcweir 		}
125cdf0e10cSrcweir #endif
126cdf0e10cSrcweir #endif
127cdf0e10cSrcweir 	}
128cdf0e10cSrcweir 	bChg = sal_True;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     (SwRect&)rRect = aOldRect;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 
134