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 : #include "txtpaint.hxx"
21 : #include "swrect.hxx"
22 : #include "rootfrm.hxx"
23 :
24 : /*************************************************************************
25 : * SwSaveClip::Reset()
26 : *************************************************************************/
27 :
28 9368 : void SwSaveClip::Reset()
29 : {
30 : // We recover the old state
31 9368 : if( pOut && bChg )
32 : {
33 5353 : if ( pOut->GetConnectMetaFile() )
34 0 : pOut->Pop();
35 : else
36 : {
37 5353 : if( bOn )
38 0 : pOut->SetClipRegion( aClip );
39 : else
40 5353 : pOut->SetClipRegion();
41 : }
42 5353 : bChg = false;
43 : }
44 9368 : }
45 :
46 : /*************************************************************************
47 : * SwSaveClip::_ChgClip()
48 : *************************************************************************/
49 :
50 5411 : void SwSaveClip::_ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm,
51 : bool bEnlargeRect )
52 : {
53 5411 : SwRect aOldRect( rRect );
54 5411 : const bool bVertical = pFrm && pFrm->IsVertical();
55 :
56 5411 : if ( pFrm && pFrm->IsRightToLeft() )
57 2 : pFrm->SwitchLTRtoRTL( (SwRect&)rRect );
58 :
59 5411 : if ( bVertical )
60 0 : pFrm->SwitchHorizontalToVertical( (SwRect&)rRect );
61 :
62 5411 : if ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
63 : {
64 0 : (SwRect&)rRect = aOldRect;
65 0 : return;
66 : }
67 :
68 5411 : if ( !bChg )
69 : {
70 5353 : if ( pOut->GetConnectMetaFile() )
71 0 : pOut->Push();
72 5353 : else if ( bOn )
73 0 : aClip = pOut->GetClipRegion();
74 : }
75 :
76 5411 : if ( !rRect.HasArea() )
77 0 : pOut->SetClipRegion();
78 : else
79 : {
80 5411 : Rectangle aRect( rRect.SVRect() );
81 :
82 : // Having underscores in our line, we enlarged the repaint area
83 : // (see frmform.cxx) because for some fonts it could be too small.
84 : // Consequently, we have to enlarge the clipping rectangle as well.
85 5411 : if ( bEnlargeRect && ! bVertical )
86 5 : aRect.Bottom() += 40;
87 :
88 : // If the ClipRect is identical, nothing will happen
89 5411 : if( pOut->IsClipRegion() ) // no && because of Mac
90 : {
91 58 : if ( aRect == pOut->GetClipRegion().GetBoundRect() )
92 : {
93 0 : (SwRect&)rRect = aOldRect;
94 0 : return;
95 : }
96 : }
97 :
98 5411 : if( SwRootFrm::HasSameRect( rRect ) )
99 0 : pOut->SetClipRegion();
100 : else
101 : {
102 5411 : const Region aClipRegion( aRect );
103 5411 : pOut->SetClipRegion( aClipRegion );
104 : }
105 : #ifdef DBG_UTIL
106 : static bool bDbg = false;
107 : if( bDbg )
108 : {
109 : DbgBackColor aDbg( pOut, bDbg, COL_RED );
110 : pOut->DrawRect( aRect );
111 : }
112 : #endif
113 : }
114 5411 : bChg = true;
115 :
116 5411 : (SwRect&)rRect = aOldRect;
117 : }
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|