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