LibreOffice Module vcl (master) 1
stack.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 <sal/config.h>
21#include <sal/log.hxx>
22#include <tools/debug.hxx>
23
24#include <vcl/metaact.hxx>
26#include <vcl/virdev.hxx>
27#include <vcl/settings.hxx>
28
29#include <drawmode.hxx>
30#include <salgdi.hxx>
31
33{
34 if (mpMetaFile)
36
37 maOutDevStateStack.emplace_back();
38 vcl::State& rState = maOutDevStateStack.back();
39
40 rState.mnFlags = nFlags;
41
43 rState.mpLineColor = maLineColor;
44
46 rState.mpFillColor = maFillColor;
47
48 if (nFlags & vcl::PushFlags::FONT)
49 rState.mpFont = maFont;
50
51 if (nFlags & vcl::PushFlags::TEXTCOLOR)
52 rState.mpTextColor = GetTextColor();
53
56
59
62
63 if (nFlags & vcl::PushFlags::TEXTALIGN)
64 rState.meTextAlign = GetTextAlign();
65
68
71
72 if (nFlags & vcl::PushFlags::RASTEROP)
73 rState.meRasterOp = GetRasterOp();
74
75 if (nFlags & vcl::PushFlags::MAPMODE)
76 {
77 rState.mpMapMode = maMapMode;
78 rState.mbMapActive = mbMap;
79 }
80
82 rState.mpClipRegion.reset(new vcl::Region(maRegion));
83
85 rState.mpRefPoint = maRefPoint;
86
87 if (mpAlphaVDev)
89}
90
92{
93 if( mpMetaFile )
95
96 GDIMetaFile* pOldMetaFile = mpMetaFile;
97 mpMetaFile = nullptr;
98
99 if ( maOutDevStateStack.empty() )
100 {
101 SAL_WARN( "vcl.gdi", "OutputDevice::Pop() without OutputDevice::Push()" );
102 return;
103 }
104 const vcl::State& rState = maOutDevStateStack.back();
105
106 if( mpAlphaVDev )
107 mpAlphaVDev->Pop();
108
109 if ( rState.mnFlags & vcl::PushFlags::LINECOLOR )
110 {
111 if ( rState.mpLineColor )
112 SetLineColor( *rState.mpLineColor );
113 else
114 SetLineColor();
115 }
116
117 if ( rState.mnFlags & vcl::PushFlags::FILLCOLOR )
118 {
119 if ( rState.mpFillColor )
120 SetFillColor( *rState.mpFillColor );
121 else
122 SetFillColor();
123 }
124
125 if ( rState.mnFlags & vcl::PushFlags::FONT )
126 SetFont( *rState.mpFont );
127
128 if ( rState.mnFlags & vcl::PushFlags::TEXTCOLOR )
129 SetTextColor( *rState.mpTextColor );
130
132 {
133 if ( rState.mpTextFillColor )
135 else
137 }
138
140 {
141 if ( rState.mpTextLineColor )
143 else
145 }
146
148 {
149 if ( rState.mpOverlineColor )
151 else
153 }
154
155 if ( rState.mnFlags & vcl::PushFlags::TEXTALIGN )
156 SetTextAlign( rState.meTextAlign );
157
160
163
164 if ( rState.mnFlags & vcl::PushFlags::RASTEROP )
165 SetRasterOp( rState.meRasterOp );
166
167 if ( rState.mnFlags & vcl::PushFlags::MAPMODE )
168 {
169 if ( rState.mpMapMode )
170 SetMapMode( *rState.mpMapMode );
171 else
172 SetMapMode();
173 mbMap = rState.mbMapActive;
174 }
175
176 if ( rState.mnFlags & vcl::PushFlags::CLIPREGION )
177 SetDeviceClipRegion( rState.mpClipRegion.get() );
178
179 if ( rState.mnFlags & vcl::PushFlags::REFPOINT )
180 {
181 if ( rState.mpRefPoint )
182 SetRefPoint( *rState.mpRefPoint );
183 else
184 SetRefPoint();
185 }
186
187 maOutDevStateStack.pop_back();
188
189 mpMetaFile = pOldMetaFile;
190}
191
193{
194 sal_uInt32 nCount = maOutDevStateStack.size();
195 while( nCount-- )
196 Pop();
197}
198
199/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:585
bool IsOverlineColor() const
Definition: outdev.hxx:1018
vcl::Region maRegion
Definition: outdev.hxx:225
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
RasterOp GetRasterOp() const
Definition: outdev.hxx:496
void SetTextAlign(TextAlign eAlign)
Definition: text.cxx:774
bool mbFillColor
Definition: outdev.hxx:247
bool mbRefPoint
Definition: outdev.hxx:257
MapMode maMapMode
Definition: outdev.hxx:235
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:185
void ClearStack()
Definition: stack.cxx:192
bool mbMap
Definition: outdev.hxx:240
bool mbClipRegion
Definition: outdev.hxx:241
void SetLineColor()
Definition: line.cxx:37
void SetMapMode()
Definition: map.cxx:597
const Color & GetOverlineColor() const
Definition: outdev.hxx:1017
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
vcl::Font maFont
Definition: outdev.hxx:228
void SetRefPoint()
Definition: outdev.cxx:295
void SetDigitLanguage(LanguageType)
Definition: text.cxx:71
vcl::text::ComplexTextLayoutFlags GetLayoutMode() const
Definition: outdev.hxx:490
std::vector< vcl::State > maOutDevStateStack
Definition: outdev.hxx:188
void SetFillColor()
Definition: fill.cxx:29
Point maRefPoint
Definition: outdev.hxx:236
void SetRasterOp(RasterOp eRasterOp)
Definition: outdev.cxx:320
TextAlign GetTextAlign() const
Definition: outdev.hxx:1021
bool IsTextFillColor() const
Definition: outdev.hxx:1008
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:196
const Color & GetTextColor() const
Definition: outdev.hxx:1003
void SetTextFillColor()
Definition: text.cxx:734
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:32
void Pop()
Definition: stack.cxx:91
Color maLineColor
Definition: outdev.hxx:226
Color GetTextFillColor() const
Definition: text.cxx:766
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
Definition: text.cxx:60
bool IsTextLineColor() const
Definition: outdev.hxx:1013
Color maFillColor
Definition: outdev.hxx:227
void SetOverlineColor()
Definition: textline.cxx:919
bool mbLineColor
Definition: outdev.hxx:246
SAL_DLLPRIVATE void SetDeviceClipRegion(const vcl::Region *pRegion)
LanguageType GetDigitLanguage() const
Definition: outdev.hxx:493
const Color & GetTextLineColor() const
Definition: outdev.hxx:1012
void SetTextLineColor()
Definition: textline.cxx:894
int nCount
#define SAL_WARN(area, stream)
PushFlags
Definition: State.hxx:40
std::optional< Color > mpTextColor
Definition: State.hxx:107
std::unique_ptr< vcl::Region > mpClipRegion
Definition: State.hxx:101
std::optional< Point > mpRefPoint
Definition: State.hxx:104
std::optional< MapMode > mpMapMode
Definition: State.hxx:102
std::optional< Color > mpTextLineColor
Definition: State.hxx:109
PushFlags mnFlags
Definition: State.hxx:115
std::optional< vcl::Font > mpFont
Definition: State.hxx:103
std::optional< Color > mpFillColor
Definition: State.hxx:106
std::optional< Color > mpTextFillColor
Definition: State.hxx:108
TextAlign meTextAlign
Definition: State.hxx:111
RasterOp meRasterOp
Definition: State.hxx:112
LanguageType meTextLanguage
Definition: State.hxx:114
std::optional< Color > mpOverlineColor
Definition: State.hxx:110
std::optional< Color > mpLineColor
Definition: State.hxx:105
text::ComplexTextLayoutFlags mnTextLayoutMode
Definition: State.hxx:113
bool mbMapActive
Definition: State.hxx:116