Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "txtpaint.hxx"
22 : #include "swrect.hxx"
23 : #include "rootfrm.hxx"
24 :
25 : /*************************************************************************
26 : * SwSaveClip::Reset()
27 : *************************************************************************/
28 :
29 477 : void SwSaveClip::Reset()
30 : {
31 : // We recover the old state
32 477 : if( pOut && bChg )
33 : {
34 74 : if ( pOut->GetConnectMetaFile() )
35 0 : pOut->Pop();
36 : else
37 : {
38 74 : if( bOn )
39 0 : pOut->SetClipRegion( aClip );
40 : else
41 74 : pOut->SetClipRegion();
42 : }
43 74 : bChg = sal_False;
44 : }
45 477 : }
46 :
47 : /*************************************************************************
48 : * SwSaveClip::_ChgClip()
49 : *************************************************************************/
50 :
51 74 : void SwSaveClip::_ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm,
52 : sal_Bool bEnlargeRect )
53 : {
54 74 : SwRect aOldRect( rRect );
55 74 : const sal_Bool bVertical = pFrm && pFrm->IsVertical();
56 :
57 74 : if ( pFrm && pFrm->IsRightToLeft() )
58 0 : pFrm->SwitchLTRtoRTL( (SwRect&)rRect );
59 :
60 74 : if ( bVertical )
61 0 : pFrm->SwitchHorizontalToVertical( (SwRect&)rRect );
62 :
63 74 : if ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
64 : {
65 0 : (SwRect&)rRect = aOldRect;
66 : return;
67 : }
68 :
69 74 : if ( !bChg )
70 : {
71 74 : if ( pOut->GetConnectMetaFile() )
72 0 : pOut->Push();
73 74 : else if ( bOn )
74 0 : aClip = pOut->GetClipRegion();
75 : }
76 :
77 74 : if ( !rRect.HasArea() )
78 0 : pOut->SetClipRegion();
79 : else
80 : {
81 74 : Rectangle aRect( rRect.SVRect() );
82 :
83 : // Having underscores in our line, we enlarged the repaint area
84 : // (see frmform.cxx) because for some fonts it could be too small.
85 : // Consequently, we have to enlarge the clipping rectangle as well.
86 74 : if ( bEnlargeRect && ! bVertical )
87 6 : aRect.Bottom() += 40;
88 :
89 : // If the ClipRect is identical, nothing will happen
90 74 : if( pOut->IsClipRegion() ) // no && because of Mac
91 : {
92 0 : if ( aRect == pOut->GetClipRegion().GetBoundRect() )
93 : {
94 0 : (SwRect&)rRect = aOldRect;
95 : return;
96 : }
97 : }
98 :
99 74 : if( SwRootFrm::HasSameRect( rRect ) )
100 0 : pOut->SetClipRegion();
101 : else
102 : {
103 74 : const Region aClipRegion( aRect );
104 74 : pOut->SetClipRegion( aClipRegion );
105 : }
106 : #ifdef DBG_UTIL
107 : static sal_Bool bDbg = sal_False;
108 : if( bDbg )
109 : {
110 : DbgBackColor aDbg( pOut, bDbg, COL_RED );
111 : pOut->DrawRect( aRect );
112 : }
113 : #endif
114 : }
115 74 : bChg = sal_True;
116 :
117 74 : (SwRect&)rRect = aOldRect;
118 : }
119 :
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|