android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / text / txtpaint.cxx
blobccd9647bd99c425e9f2bc57b04f568bfaf3369f4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
21 #include <txtfrm.hxx>
22 #include <swrect.hxx>
23 #include <rootfrm.hxx>
25 SwSaveClip::~SwSaveClip()
27 // We recover the old state
28 if( !(m_pOut && m_bChg) )
29 return;
31 if ( m_pOut->GetConnectMetaFile() )
32 m_pOut->Pop();
33 else
35 if( m_bOn )
36 m_pOut->SetClipRegion( m_aClip );
37 else
38 m_pOut->SetClipRegion();
40 m_bChg = false;
43 void SwSaveClip::ChgClip_( const SwRect &rRect, const SwTextFrame* pFrame,
44 bool bEnlargeRect,
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) );
54 if ( bVertical )
55 pFrame->SwitchHorizontalToVertical( const_cast<SwRect&>(rRect) );
57 if ( !m_pOut || (!rRect.HasArea() && !m_pOut->IsClipRegion()) )
59 const_cast<SwRect&>(rRect) = aOldRect;
60 return;
63 if ( !m_bChg )
65 if ( m_pOut->GetConnectMetaFile() )
66 m_pOut->Push();
67 else if ( m_bOn )
68 m_aClip = m_pOut->GetClipRegion();
71 if ( !rRect.HasArea() )
72 m_pOut->SetClipRegion();
73 else
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;
96 return;
100 if( SwRootFrame::HasSameRect( rRect ) )
101 m_pOut->SetClipRegion();
102 else
104 const vcl::Region aClipRegion( aRect );
105 m_pOut->SetClipRegion( aClipRegion );
108 m_bChg = true;
110 const_cast<SwRect&>(rRect) = aOldRect;
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */