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