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 14309 : void SwSaveClip::Reset()
25 : {
26 : // We recover the old state
27 14309 : if( pOut && bChg )
28 : {
29 7540 : if ( pOut->GetConnectMetaFile() )
30 1 : pOut->Pop();
31 : else
32 : {
33 7539 : if( bOn )
34 0 : pOut->SetClipRegion( aClip );
35 : else
36 7539 : pOut->SetClipRegion();
37 : }
38 7540 : bChg = false;
39 : }
40 14309 : }
41 :
42 7668 : void SwSaveClip::_ChgClip( const SwRect &rRect, const SwTextFrm* pFrm,
43 : bool bEnlargeRect )
44 : {
45 7668 : SwRect aOldRect( rRect );
46 7668 : const bool bVertical = pFrm && pFrm->IsVertical();
47 :
48 7668 : if ( pFrm && pFrm->IsRightToLeft() )
49 6 : pFrm->SwitchLTRtoRTL( (SwRect&)rRect );
50 :
51 7668 : if ( bVertical )
52 0 : pFrm->SwitchHorizontalToVertical( (SwRect&)rRect );
53 :
54 7668 : if ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
55 : {
56 0 : (SwRect&)rRect = aOldRect;
57 0 : return;
58 : }
59 :
60 7668 : if ( !bChg )
61 : {
62 7540 : if ( pOut->GetConnectMetaFile() )
63 1 : pOut->Push();
64 7539 : else if ( bOn )
65 0 : aClip = pOut->GetClipRegion();
66 : }
67 :
68 7668 : if ( !rRect.HasArea() )
69 0 : pOut->SetClipRegion();
70 : else
71 : {
72 7668 : 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 7668 : if ( bEnlargeRect && ! bVertical )
78 17 : aRect.Bottom() += 40;
79 :
80 : // If the ClipRect is identical, nothing will happen
81 7668 : if( pOut->IsClipRegion() ) // no && because of Mac
82 : {
83 128 : if ( aRect == pOut->GetClipRegion().GetBoundRect() )
84 : {
85 0 : (SwRect&)rRect = aOldRect;
86 0 : return;
87 : }
88 : }
89 :
90 7668 : if( SwRootFrm::HasSameRect( rRect ) )
91 0 : pOut->SetClipRegion();
92 : else
93 : {
94 7668 : const vcl::Region aClipRegion( aRect );
95 7668 : 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 7668 : bChg = true;
107 :
108 7668 : (SwRect&)rRect = aOldRect;
109 177 : }
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|