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)
36  mpMetaFile->AddAction(new MetaPushAction(nFlags));
37 
38  maOutDevStateStack.emplace_back();
39  vcl::State& rState = maOutDevStateStack.back();
40 
41  rState.mnFlags = nFlags;
42 
43  if (nFlags & vcl::PushFlags::LINECOLOR && mbLineColor)
44  rState.mpLineColor = maLineColor;
45 
46  if (nFlags & vcl::PushFlags::FILLCOLOR && mbFillColor)
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 
67  if (nFlags & vcl::PushFlags::TEXTLAYOUTMODE)
69 
70  if (nFlags & vcl::PushFlags::TEXTLANGUAGE)
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 
85  if (nFlags & vcl::PushFlags::REFPOINT && mbRefPoint)
86  rState.mpRefPoint = maRefPoint;
87 
88  if (mpAlphaVDev)
89  mpAlphaVDev->Push();
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 
132  if ( rState.mnFlags & vcl::PushFlags::TEXTFILLCOLOR )
133  {
134  if ( rState.mpTextFillColor )
136  else
138  }
139 
140  if ( rState.mnFlags & vcl::PushFlags::TEXTLINECOLOR )
141  {
142  if ( rState.mpTextLineColor )
144  else
146  }
147 
148  if ( rState.mnFlags & vcl::PushFlags::OVERLINECOLOR )
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: */
const Color & GetTextColor() const
Definition: outdev.hxx:1011
void SetDigitLanguage(LanguageType)
Definition: text.cxx:68
LanguageType meTextLanguage
Definition: State.hxx:115
SAL_DLLPRIVATE void SetDeviceClipRegion(const vcl::Region *pRegion)
const Color & GetTextLineColor() const
Definition: outdev.hxx:1020
Color maLineColor
Definition: outdev.hxx:225
TextAlign GetTextAlign() const
Definition: outdev.hxx:1029
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:33
bool IsTextLineColor() const
Definition: outdev.hxx:1021
vcl::Region maRegion
Definition: outdev.hxx:224
std::optional< MapMode > mpMapMode
Definition: State.hxx:103
void SetTextFillColor()
Definition: text.cxx:706
vcl::text::ComplexTextLayoutFlags GetLayoutMode() const
Definition: outdev.hxx:486
bool mbMap
Definition: outdev.hxx:239
text::ComplexTextLayoutFlags mnTextLayoutMode
Definition: State.hxx:114
void SetMapMode()
Definition: map.cxx:594
MapMode maMapMode
Definition: outdev.hxx:234
const Color & GetOverlineColor() const
Definition: outdev.hxx:1025
Color GetTextFillColor() const
Definition: text.cxx:738
int nCount
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
Definition: text.cxx:57
void Pop()
Definition: stack.cxx:92
void ClearStack()
Definition: stack.cxx:193
std::optional< Color > mpTextColor
Definition: State.hxx:108
Color maFillColor
Definition: outdev.hxx:226
std::optional< vcl::Font > mpFont
Definition: State.hxx:104
void SetTextLineColor()
Definition: textline.cxx:881
std::vector< vcl::State > maOutDevStateStack
Definition: outdev.hxx:187
RasterOp meRasterOp
Definition: State.hxx:113
bool IsTextFillColor() const
Definition: outdev.hxx:1016
void SetLineColor()
Definition: line.cxx:36
void SetRefPoint()
Definition: outdev.cxx:287
std::optional< Color > mpFillColor
Definition: State.hxx:107
PushFlags mnFlags
Definition: State.hxx:116
void SetFillColor()
Definition: fill.cxx:29
void SetTextColor(const Color &rColor)
Definition: text.cxx:688
vcl::Font maFont
Definition: outdev.hxx:227
bool mbLineColor
Definition: outdev.hxx:245
void SetOverlineColor()
Definition: textline.cxx:906
PushFlags
Definition: State.hxx:40
bool mbRefPoint
Definition: outdev.hxx:256
std::unique_ptr< vcl::Region > mpClipRegion
Definition: State.hxx:102
std::optional< Point > mpRefPoint
Definition: State.hxx:105
std::optional< Color > mpOverlineColor
Definition: State.hxx:111
bool mbFillColor
Definition: outdev.hxx:246
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:195
std::optional< Color > mpTextLineColor
Definition: State.hxx:110
bool mbClipRegion
Definition: outdev.hxx:240
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:53
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:562
LanguageType GetDigitLanguage() const
Definition: outdev.hxx:489
void SetRasterOp(RasterOp eRasterOp)
Definition: outdev.cxx:312
std::optional< Color > mpTextFillColor
Definition: State.hxx:109
RasterOp GetRasterOp() const
Definition: outdev.hxx:492
bool mbMapActive
Definition: State.hxx:117
#define SAL_WARN(area, stream)
TextAlign meTextAlign
Definition: State.hxx:112
bool IsOverlineColor() const
Definition: outdev.hxx:1026
std::optional< Color > mpLineColor
Definition: State.hxx:106
Point maRefPoint
Definition: outdev.hxx:235
void SetTextAlign(TextAlign eAlign)
Definition: text.cxx:746
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:184