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
24class SwRect; // SwSaveClip
25class SwTextFrame;
26
27class 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 );
38public:
39 explicit SwSaveClip(OutputDevice* pOutDev)
40 : m_bOn(pOutDev && pOutDev->IsClipRegion())
41 , m_bChg(false)
42 , m_pOut(pOutDev)
43 {
44 }
45
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
61{
62protected:
64public:
65 inline SwDbgOut( OutputDevice* pOutDev, const bool bOn );
66};
67
68class DbgBackColor : public SwDbgOut
69{
71public:
72 DbgBackColor( OutputDevice* pOut, const bool bOn );
74};
75
76class DbgRect : public SwDbgOut
77{
78public:
80 const bool bOn,
81 Color eColor );
82};
83
84inline SwDbgOut::SwDbgOut( OutputDevice* pOutDev, const bool bOn )
85 :pOut( bOn ? pOutDev : nullptr )
86{ }
87
88inline DbgBackColor::DbgBackColor( OutputDevice* pOutDev, const bool bOn )
89 :SwDbgOut( pOutDev, bOn )
90{
91 if( pOut )
92 {
93 aOldFillColor = pOut->GetFillColor();
94 pOut->SetFillColor( COL_RED );
95 }
96}
97
99{
100 if( pOut )
101 {
102 pOut->SetFillColor( aOldFillColor );
103 }
104}
105
106inline 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();
117 pOut->SetFillColor( COL_TRANSPARENT );
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: */
DbgBackColor(OutputDevice *pOut, const bool bOn)
Definition: txtpaint.hxx:88
Color aOldFillColor
Definition: txtpaint.hxx:70
DbgRect(OutputDevice *pOut, const tools::Rectangle &rRect, const bool bOn, Color eColor)
Definition: txtpaint.hxx:106
SwDbgOut(OutputDevice *pOutDev, const bool bOn)
Definition: txtpaint.hxx:84
VclPtr< OutputDevice > pOut
Definition: txtpaint.hxx:63
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
bool m_bChg
Definition: txtpaint.hxx:31
vcl::Region m_aClip
Definition: txtpaint.hxx:29
VclPtr< OutputDevice > m_pOut
Definition: txtpaint.hxx:33
bool IsOn() const
Definition: txtpaint.hxx:53
bool IsChg() const
Definition: txtpaint.hxx:54
const bool m_bOn
Definition: txtpaint.hxx:30
SwSaveClip(OutputDevice *pOutDev)
Definition: txtpaint.hxx:39
void ChgClip(const SwRect &rRect, const SwTextFrame *pFrame=nullptr, bool bEnlargeRect=false, sal_Int32 nEnlargeTop=0, sal_Int32 nEnlargeBottom=0)
Definition: txtpaint.hxx:47
void ChgClip_(const SwRect &rRect, const SwTextFrame *pFrame, bool bEnlargeRect, sal_Int32 nEnlargeTop, sal_Int32 nEnlargeBottom)
Definition: txtpaint.cxx:43
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
constexpr ::Color COL_RED(0x80, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
oslFileHandle & pOut