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