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  {
30  if ( pOut->GetConnectMetaFile() )
31  pOut->Pop();
32  else
33  {
34  if( bOn )
36  else
38  }
39  bChg = false;
40  }
41 }
42 
43 void SwSaveClip::ChgClip_( const SwRect &rRect, const SwTextFrame* pFrame,
44  bool bEnlargeRect )
45 {
46  SwRect aOldRect( rRect );
47  const bool bVertical = pFrame && pFrame->IsVertical();
48 
49  if ( pFrame && pFrame->IsRightToLeft() )
50  pFrame->SwitchLTRtoRTL( const_cast<SwRect&>(rRect) );
51 
52  if ( bVertical )
53  pFrame->SwitchHorizontalToVertical( const_cast<SwRect&>(rRect) );
54 
55  if ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
56  {
57  const_cast<SwRect&>(rRect) = aOldRect;
58  return;
59  }
60 
61  if ( !bChg )
62  {
63  if ( pOut->GetConnectMetaFile() )
64  pOut->Push();
65  else if ( bOn )
67  }
68 
69  if ( !rRect.HasArea() )
71  else
72  {
73  tools::Rectangle aRect( rRect.SVRect() );
74 
75  // Having underscores in our line, we enlarged the repaint area
76  // (see frmform.cxx) because for some fonts it could be too small.
77  // Consequently, we have to enlarge the clipping rectangle as well.
78  if ( bEnlargeRect && ! bVertical )
79  aRect.AdjustBottom(40 );
80 
81  // If the ClipRect is identical, nothing will happen
82  if( pOut->IsClipRegion() ) // no && because of Mac
83  {
84  if ( aRect == pOut->GetClipRegion().GetBoundRect() )
85  {
86  const_cast<SwRect&>(rRect) = aOldRect;
87  return;
88  }
89  }
90 
91  if( SwRootFrame::HasSameRect( rRect ) )
93  else
94  {
95  const vcl::Region aClipRegion( aRect );
96  pOut->SetClipRegion( aClipRegion );
97  }
98  }
99  bChg = true;
100 
101  const_cast<SwRect&>(rRect) = aOldRect;
102 }
103 
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetClipRegion()
vcl::Region GetClipRegion() const
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout...
Definition: txtfrm.cxx:483
GDIMetaFile * GetConnectMetaFile() const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
tools::Rectangle GetBoundRect() const
long AdjustBottom(long nVertMoveDelta)
void ChgClip_(const SwRect &rRect, const SwTextFrame *pFrame, bool bEnlargeRect)
Definition: txtpaint.cxx:43
vcl::Region aClip
Definition: txtpaint.hxx:28
bool IsClipRegion() const
const bool bOn
Definition: txtpaint.hxx:29
bool HasArea() const
Definition: swrect.hxx:290
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:693
tools::Rectangle SVRect() const
Definition: swrect.hxx:282
VclPtr< OutputDevice > pOut
Definition: txtpaint.hxx:32
bool IsRightToLeft() const
Definition: frame.hxx:963
bool IsVertical() const
Definition: frame.hxx:949
void Push(PushFlags nFlags=PushFlags::ALL)
static bool HasSameRect(const SwRect &rRect)
Save Clipping if exactly the ClipRect is outputted.
Definition: virtoutp.cxx:39