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/gdimtf.hxx>
25#include <vcl/metaact.hxx>
27#include <vcl/virdev.hxx>
28#include <vcl/settings.hxx>
29
30#include <drawmode.hxx>
31#include <salgdi.hxx>
32
34{
35 if (mpMetaFile)
37
38 maOutDevStateStack.emplace_back();
39 vcl::State& rState = maOutDevStateStack.back();
40
41 rState.mnFlags = nFlags;
42
44 rState.mpLineColor = maLineColor;
45
47 rState.mpFillColor = maFillColor;
48
49 if (nFlags & vcl::PushFlags::FONT)
50 rState.mpFont = maFont;
51
52 if (nFlags & vcl::PushFlags::TEXTCOLOR)
53 rState.mpTextColor = GetTextColor();
54
57
60
63
64 if (nFlags & vcl::PushFlags::TEXTALIGN)
65 rState.meTextAlign = GetTextAlign();
66
69
72
73 if (nFlags & vcl::PushFlags::RASTEROP)
74 rState.meRasterOp = GetRasterOp();
75
76 if (nFlags & vcl::PushFlags::MAPMODE)
77 {
78 rState.mpMapMode = maMapMode;
79 rState.mbMapActive = mbMap;
80 }
81
83 rState.mpClipRegion.reset(new vcl::Region(maRegion));
84
86 rState.mpRefPoint = maRefPoint;
87
88 if (mpAlphaVDev)
90}
91
93{
94 if( mpMetaFile )
96
97 GDIMetaFile* pOldMetaFile = mpMetaFile;
98 mpMetaFile = nullptr;
99
100 if ( maOutDevStateStack.empty() )
101 {
102 SAL_WARN( "vcl.gdi", "OutputDevice::Pop() without OutputDevice::Push()" );
103 return;
104 }
105 const vcl::State& rState = maOutDevStateStack.back();
106
107 if( mpAlphaVDev )
108 mpAlphaVDev->Pop();
109
110 if ( rState.mnFlags & vcl::PushFlags::LINECOLOR )
111 {
112 if ( rState.mpLineColor )
113 SetLineColor( *rState.mpLineColor );
114 else
115 SetLineColor();
116 }
117
118 if ( rState.mnFlags & vcl::PushFlags::FILLCOLOR )
119 {
120 if ( rState.mpFillColor )
121 SetFillColor( *rState.mpFillColor );
122 else
123 SetFillColor();
124 }
125
126 if ( rState.mnFlags & vcl::PushFlags::FONT )
127 SetFont( *rState.mpFont );
128
129 if ( rState.mnFlags & vcl::PushFlags::TEXTCOLOR )
130 SetTextColor( *rState.mpTextColor );
131
133 {
134 if ( rState.mpTextFillColor )
136 else
138 }
139
141 {
142 if ( rState.mpTextLineColor )
144 else
146 }
147
149 {
150 if ( rState.mpOverlineColor )
152 else
154 }
155
156 if ( rState.mnFlags & vcl::PushFlags::TEXTALIGN )
157 SetTextAlign( rState.meTextAlign );
158
161
164
165 if ( rState.mnFlags & vcl::PushFlags::RASTEROP )
166 SetRasterOp( rState.meRasterOp );
167
168 if ( rState.mnFlags & vcl::PushFlags::MAPMODE )
169 {
170 if ( rState.mpMapMode )
171 SetMapMode( *rState.mpMapMode );
172 else
173 SetMapMode();
174 mbMap = rState.mbMapActive;
175 }
176
177 if ( rState.mnFlags & vcl::PushFlags::CLIPREGION )
178 SetDeviceClipRegion( rState.mpClipRegion.get() );
179
180 if ( rState.mnFlags & vcl::PushFlags::REFPOINT )
181 {
182 if ( rState.mpRefPoint )
183 SetRefPoint( *rState.mpRefPoint );
184 else
185 SetRefPoint();
186 }
187
188 maOutDevStateStack.pop_back();
189
190 mpMetaFile = pOldMetaFile;
191}
192
194{
195 sal_uInt32 nCount = maOutDevStateStack.size();
196 while( nCount-- )
197 Pop();
198}
199
200/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:581
bool IsOverlineColor() const
Definition: outdev.hxx:1019
vcl::Region maRegion
Definition: outdev.hxx:226
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
RasterOp GetRasterOp() const
Definition: outdev.hxx:497
void SetTextAlign(TextAlign eAlign)
Definition: text.cxx:774
bool mbFillColor
Definition: outdev.hxx:248
bool mbRefPoint
Definition: outdev.hxx:258
MapMode maMapMode
Definition: outdev.hxx:236
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:186
void ClearStack()
Definition: stack.cxx:193
bool mbMap
Definition: outdev.hxx:241
bool mbClipRegion
Definition: outdev.hxx:242
void SetLineColor()
Definition: line.cxx:37
void SetMapMode()
Definition: map.cxx:620
const Color & GetOverlineColor() const
Definition: outdev.hxx:1018
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
vcl::Font maFont
Definition: outdev.hxx:229
void SetRefPoint()
Definition: outdev.cxx:296
void SetDigitLanguage(LanguageType)
Definition: text.cxx:71
vcl::text::ComplexTextLayoutFlags GetLayoutMode() const
Definition: outdev.hxx:491
std::vector< vcl::State > maOutDevStateStack
Definition: outdev.hxx:189
void SetFillColor()
Definition: fill.cxx:29
Point maRefPoint
Definition: outdev.hxx:237
void SetRasterOp(RasterOp eRasterOp)
Definition: outdev.cxx:321
TextAlign GetTextAlign() const
Definition: outdev.hxx:1022
bool IsTextFillColor() const
Definition: outdev.hxx:1009
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:197
const Color & GetTextColor() const
Definition: outdev.hxx:1004
void SetTextFillColor()
Definition: text.cxx:734
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:33
void Pop()
Definition: stack.cxx:92
Color maLineColor
Definition: outdev.hxx:227
Color GetTextFillColor() const
Definition: text.cxx:766
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
Definition: text.cxx:60
bool IsTextLineColor() const
Definition: outdev.hxx:1014
Color maFillColor
Definition: outdev.hxx:228
void SetOverlineColor()
Definition: textline.cxx:908
bool mbLineColor
Definition: outdev.hxx:247
SAL_DLLPRIVATE void SetDeviceClipRegion(const vcl::Region *pRegion)
LanguageType GetDigitLanguage() const
Definition: outdev.hxx:494
const Color & GetTextLineColor() const
Definition: outdev.hxx:1013
void SetTextLineColor()
Definition: textline.cxx:883
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