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( !(pOut && bChg) )
29  return;
30 
31  if ( pOut->GetConnectMetaFile() )
32  pOut->Pop();
33  else
34  {
35  if( bOn )
37  else
39  }
40  bChg = false;
41 }
42 
43 void 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 ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
58  {
59  const_cast<SwRect&>(rRect) = aOldRect;
60  return;
61  }
62 
63  if ( !bChg )
64  {
65  if ( pOut->GetConnectMetaFile() )
66  pOut->Push();
67  else if ( bOn )
69  }
70 
71  if ( !rRect.HasArea() )
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( pOut->IsClipRegion() ) // no && because of Mac
92  {
93  if ( aRect == pOut->GetClipRegion().GetBoundRect() )
94  {
95  const_cast<SwRect&>(rRect) = aOldRect;
96  return;
97  }
98  }
99 
100  if( SwRootFrame::HasSameRect( rRect ) )
101  pOut->SetClipRegion();
102  else
103  {
104  const vcl::Region aClipRegion( aRect );
105  pOut->SetClipRegion( aClipRegion );
106  }
107  }
108  bChg = true;
109 
110  const_cast<SwRect&>(rRect) = aOldRect;
111 }
112 
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetClipRegion()
vcl::Region GetClipRegion() const
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:151
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout...
Definition: txtfrm.cxx:471
GDIMetaFile * GetConnectMetaFile() const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
tools::Rectangle GetBoundRect() const
void ChgClip_(const SwRect &rRect, const SwTextFrame *pFrame, bool bEnlargeRect, sal_Int32 nEnlargeTop, sal_Int32 nEnlargeBottom)
Definition: txtpaint.cxx:43
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
vcl::Region aClip
Definition: txtpaint.hxx:28
bool IsClipRegion() const
const bool bOn
Definition: txtpaint.hxx:29
bool HasArea() const
Definition: swrect.hxx:288
bool bChg
Definition: txtpaint.hxx:30
void SwitchLTRtoRTL(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from LTR to RTL layout.
Definition: txtfrm.cxx:681
tools::Rectangle SVRect() const
Definition: swrect.hxx:280
VclPtr< OutputDevice > pOut
Definition: txtpaint.hxx:32
bool IsRightToLeft() const
Definition: frame.hxx:968
bool IsVertical() const
Definition: frame.hxx:954
void Push(PushFlags nFlags=PushFlags::ALL)
static bool HasSameRect(const SwRect &rRect)
Save Clipping if exactly the ClipRect is outputted.
Definition: virtoutp.cxx:39