LibreOffice Module sw (master)  1
txtpaint.hxx
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 #pragma once
21 
22 #include <vcl/outdev.hxx>
23 
24 class SwRect; // SwSaveClip
25 class SwTextFrame;
26 
27 class SwSaveClip final
28 {
30  const bool m_bOn;
31  bool m_bChg;
32 
34  void ChgClip_( const SwRect &rRect, const SwTextFrame* pFrame,
35  bool bEnlargeRect,
36  sal_Int32 nEnlargeTop,
37  sal_Int32 nEnlargeBottom );
38 public:
39  explicit SwSaveClip(OutputDevice* pOutDev)
40  : m_bOn(pOutDev && pOutDev->IsClipRegion())
41  , m_bChg(false)
42  , m_pOut(pOutDev)
43  {
44  }
45 
46  ~SwSaveClip();
47  void ChgClip( const SwRect &rRect, const SwTextFrame* pFrame = nullptr,
48  bool bEnlargeRect = false,
49  sal_Int32 nEnlargeTop = 0,
50  sal_Int32 nEnlargeBottom = 0)
51  { if( m_pOut ) ChgClip_( rRect, pFrame,
52  bEnlargeRect, nEnlargeTop, nEnlargeBottom ); }
53  bool IsOn() const { return m_bOn; }
54  bool IsChg() const { return m_bChg; }
55 };
56 
57 
58 #ifdef DBG_UTIL
59 
60 class SwDbgOut
61 {
62 protected:
64 public:
65  inline SwDbgOut( OutputDevice* pOutDev, const bool bOn );
66 };
67 
68 class DbgBackColor : public SwDbgOut
69 {
71 public:
72  DbgBackColor( OutputDevice* pOut, const bool bOn );
73  ~DbgBackColor();
74 };
75 
76 class DbgRect : public SwDbgOut
77 {
78 public:
79  DbgRect( OutputDevice* pOut, const tools::Rectangle &rRect,
80  const bool bOn,
81  Color eColor );
82 };
83 
84 inline SwDbgOut::SwDbgOut( OutputDevice* pOutDev, const bool bOn )
85  :pOut( bOn ? pOutDev : nullptr )
86 { }
87 
88 inline DbgBackColor::DbgBackColor( OutputDevice* pOutDev, const bool bOn )
89  :SwDbgOut( pOutDev, bOn )
90 {
91  if( pOut )
92  {
95  }
96 }
97 
99 {
100  if( pOut )
101  {
103  }
104 }
105 
106 inline DbgRect::DbgRect( OutputDevice* pOutDev, const tools::Rectangle &rRect,
107  const bool bOn,
108  Color eColor )
109  : SwDbgOut( pOutDev, bOn )
110 {
111  if( pOut )
112  {
113  const Color aColor( eColor );
114  Color aLineColor = pOut->GetLineColor();
115  pOut->SetLineColor( aColor );
116  Color aFillColor = pOut->GetFillColor();
118  pOut->DrawRect( rRect );
119  pOut->SetLineColor( aLineColor );
120  pOut->SetFillColor( aFillColor );
121  }
122 }
123 
124 #endif
125 
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:158
constexpr::Color COL_RED(0x80, 0x00, 0x00)
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
Color aOldFillColor
Definition: txtpaint.hxx:70
VclPtr< OutputDevice > m_pOut
Definition: txtpaint.hxx:33
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
void ChgClip_(const SwRect &rRect, const SwTextFrame *pFrame, bool bEnlargeRect, sal_Int32 nEnlargeTop, sal_Int32 nEnlargeBottom)
Definition: txtpaint.cxx:43
SwSaveClip(OutputDevice *pOutDev)
Definition: txtpaint.hxx:39
oslFileHandle & pOut
bool IsOn() const
Definition: txtpaint.hxx:53
void DrawRect(const tools::Rectangle &rRect)
SwDbgOut(OutputDevice *pOutDev, const bool bOn)
Definition: txtpaint.hxx:84
void SetLineColor()
vcl::Region m_aClip
Definition: txtpaint.hxx:29
DbgBackColor(OutputDevice *pOut, const bool bOn)
Definition: txtpaint.hxx:88
void SetFillColor()
const Color & GetLineColor() const
DbgRect(OutputDevice *pOut, const tools::Rectangle &rRect, const bool bOn, Color eColor)
Definition: txtpaint.hxx:106
void ChgClip(const SwRect &rRect, const SwTextFrame *pFrame=nullptr, bool bEnlargeRect=false, sal_Int32 nEnlargeTop=0, sal_Int32 nEnlargeBottom=0)
Definition: txtpaint.hxx:47
bool m_bChg
Definition: txtpaint.hxx:31
bool IsChg() const
Definition: txtpaint.hxx:54
VclPtr< OutputDevice > pOut
Definition: txtpaint.hxx:63
const Color & GetFillColor() const
const bool m_bOn
Definition: txtpaint.hxx:30