LibreOffice Module sw (master) 1
txtpaint.cxx
Go to the documentation of this file.
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 <txtfrm.hxx>
22#include <swrect.hxx>
23#include <rootfrm.hxx>
24
26{
27 // We recover the old state
28 if( !(m_pOut && m_bChg) )
29 return;
30
31 if ( m_pOut->GetConnectMetaFile() )
32 m_pOut->Pop();
33 else
34 {
35 if( m_bOn )
36 m_pOut->SetClipRegion( m_aClip );
37 else
38 m_pOut->SetClipRegion();
39 }
40 m_bChg = false;
41}
42
43void SwSaveClip::ChgClip_( const SwRect &rRect, const SwTextFrame* pFrame,
44 bool bEnlargeRect,
45 sal_Int32 nEnlargeTop,
46 sal_Int32 nEnlargeBottom )
47{
48 SwRect aOldRect( rRect );
49 const bool bVertical = pFrame && pFrame->IsVertical();
50
51 if ( pFrame && pFrame->IsRightToLeft() )
52 pFrame->SwitchLTRtoRTL( const_cast<SwRect&>(rRect) );
53
54 if ( bVertical )
55 pFrame->SwitchHorizontalToVertical( const_cast<SwRect&>(rRect) );
56
57 if ( !m_pOut || (!rRect.HasArea() && !m_pOut->IsClipRegion()) )
58 {
59 const_cast<SwRect&>(rRect) = aOldRect;
60 return;
61 }
62
63 if ( !m_bChg )
64 {
65 if ( m_pOut->GetConnectMetaFile() )
66 m_pOut->Push();
67 else if ( m_bOn )
68 m_aClip = m_pOut->GetClipRegion();
69 }
70
71 if ( !rRect.HasArea() )
72 m_pOut->SetClipRegion();
73 else
74 {
75 tools::Rectangle aRect( rRect.SVRect() );
76
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 );
82
83 // enlarge clip for paragraph margins at small fixed line height
84 if ( nEnlargeTop > 0 )
85 aRect.AdjustTop( -nEnlargeTop );
86
87 if ( nEnlargeBottom > 0 )
88 aRect.AdjustBottom( nEnlargeBottom );
89
90 // If the ClipRect is identical, nothing will happen
91 if( m_pOut->IsClipRegion() ) // no && because of Mac
92 {
93 if ( aRect == m_pOut->GetClipRegion().GetBoundRect() )
94 {
95 const_cast<SwRect&>(rRect) = aOldRect;
96 return;
97 }
98 }
99
100 if( SwRootFrame::HasSameRect( rRect ) )
101 m_pOut->SetClipRegion();
102 else
103 {
104 const vcl::Region aClipRegion( aRect );
105 m_pOut->SetClipRegion( aClipRegion );
106 }
107 }
108 m_bChg = true;
109
110 const_cast<SwRect&>(rRect) = aOldRect;
111}
112
113/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsRightToLeft() const
Definition: frame.hxx:993
bool IsVertical() const
Definition: frame.hxx:979
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
bool HasArea() const
Definition: swrect.hxx:300
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
static bool HasSameRect(const SwRect &rRect)
Save Clipping if exactly the ClipRect is outputted.
Definition: virtoutp.cxx:40
bool m_bChg
Definition: txtpaint.hxx:31
vcl::Region m_aClip
Definition: txtpaint.hxx:29
VclPtr< OutputDevice > m_pOut
Definition: txtpaint.hxx:33
const bool m_bOn
Definition: txtpaint.hxx:30
void ChgClip_(const SwRect &rRect, const SwTextFrame *pFrame, bool bEnlargeRect, sal_Int32 nEnlargeTop, sal_Int32 nEnlargeBottom)
Definition: txtpaint.cxx:43
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
void SwitchLTRtoRTL(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from LTR to RTL layout.
Definition: txtfrm.cxx:683
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout.
Definition: txtfrm.cxx:473
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustBottom(tools::Long nVertMoveDelta)