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