1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "txtpaint.hxx"
23 #include <rootfrm.hxx>
25 SwSaveClip::~SwSaveClip()
27 // We recover the old state
28 if( !(m_pOut
&& m_bChg
) )
31 if ( m_pOut
->GetConnectMetaFile() )
36 m_pOut
->SetClipRegion( m_aClip
);
38 m_pOut
->SetClipRegion();
43 void SwSaveClip::ChgClip_( const SwRect
&rRect
, const SwTextFrame
* pFrame
,
45 sal_Int32 nEnlargeTop
,
46 sal_Int32 nEnlargeBottom
)
48 SwRect
aOldRect( rRect
);
49 const bool bVertical
= pFrame
&& pFrame
->IsVertical();
51 if ( pFrame
&& pFrame
->IsRightToLeft() )
52 pFrame
->SwitchLTRtoRTL( const_cast<SwRect
&>(rRect
) );
55 pFrame
->SwitchHorizontalToVertical( const_cast<SwRect
&>(rRect
) );
57 if ( !m_pOut
|| (!rRect
.HasArea() && !m_pOut
->IsClipRegion()) )
59 const_cast<SwRect
&>(rRect
) = aOldRect
;
65 if ( m_pOut
->GetConnectMetaFile() )
68 m_aClip
= m_pOut
->GetClipRegion();
71 if ( !rRect
.HasArea() )
72 m_pOut
->SetClipRegion();
75 tools::Rectangle
aRect( rRect
.SVRect() );
77 // Having underscores in our line, we enlarged the repaint area
78 // (see frmform.cxx) because for some fonts it could be too small.
79 // Consequently, we have to enlarge the clipping rectangle as well.
80 if ( bEnlargeRect
&& ! bVertical
)
81 aRect
.AdjustBottom(40 );
83 // enlarge clip for paragraph margins at small fixed line height
84 if ( nEnlargeTop
> 0 )
85 aRect
.AdjustTop( -nEnlargeTop
);
87 if ( nEnlargeBottom
> 0 )
88 aRect
.AdjustBottom( nEnlargeBottom
);
90 // If the ClipRect is identical, nothing will happen
91 if( m_pOut
->IsClipRegion() ) // no && because of Mac
93 if ( aRect
== m_pOut
->GetClipRegion().GetBoundRect() )
95 const_cast<SwRect
&>(rRect
) = aOldRect
;
100 if( SwRootFrame::HasSameRect( rRect
) )
101 m_pOut
->SetClipRegion();
104 const vcl::Region
aClipRegion( aRect
);
105 m_pOut
->SetClipRegion( aClipRegion
);
110 const_cast<SwRect
&>(rRect
) = aOldRect
;
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */