diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-08-25 18:49:34 +1000 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-10 18:33:37 +0200 |
commit | c9517311f4c209f549668867c9b07ffa18246dee (patch) | |
tree | e566c7fe3f1cac8a319b9856b9213ffd30c883c8 /vcl/source/outdev/stack.cxx | |
parent | 98492e9d8169c080d224e6ee60feb3277c5b1a17 (diff) |
vcl: move outdevstate.cxx to stack.cxx
Change-Id: I674be4eb758178468dbba70cb45d68d009952ebc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121024
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/outdev/stack.cxx')
-rw-r--r-- | vcl/source/outdev/stack.cxx | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/vcl/source/outdev/stack.cxx b/vcl/source/outdev/stack.cxx new file mode 100644 index 000000000000..ee8eddf07fb1 --- /dev/null +++ b/vcl/source/outdev/stack.cxx @@ -0,0 +1,201 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> +#include <sal/log.hxx> +#include <tools/debug.hxx> + +#include <vcl/gdimtf.hxx> +#include <vcl/metaact.hxx> +#include <vcl/outdevstate.hxx> +#include <vcl/virdev.hxx> +#include <vcl/settings.hxx> + +#include <outdev.h> +#include <drawmode.hxx> +#include <salgdi.hxx> + +void OutputDevice::Push(PushFlags nFlags) +{ + if (mpMetaFile) + mpMetaFile->AddAction(new MetaPushAction(nFlags)); + + maOutDevStateStack.emplace_back(); + OutDevState& rState = maOutDevStateStack.back(); + + rState.mnFlags = nFlags; + + if (nFlags & PushFlags::LINECOLOR && mbLineColor) + rState.mpLineColor = maLineColor; + + if (nFlags & PushFlags::FILLCOLOR && mbFillColor) + rState.mpFillColor = maFillColor; + + if (nFlags & PushFlags::FONT) + rState.mpFont = maFont; + + if (nFlags & PushFlags::TEXTCOLOR) + rState.mpTextColor = GetTextColor(); + + if (nFlags & PushFlags::TEXTFILLCOLOR && IsTextFillColor()) + rState.mpTextFillColor = GetTextFillColor(); + + if (nFlags & PushFlags::TEXTLINECOLOR && IsTextLineColor()) + rState.mpTextLineColor = GetTextLineColor(); + + if (nFlags & PushFlags::OVERLINECOLOR && IsOverlineColor()) + rState.mpOverlineColor = GetOverlineColor(); + + if (nFlags & PushFlags::TEXTALIGN) + rState.meTextAlign = GetTextAlign(); + + if (nFlags & PushFlags::TEXTLAYOUTMODE) + rState.mnTextLayoutMode = GetLayoutMode(); + + if (nFlags & PushFlags::TEXTLANGUAGE) + rState.meTextLanguage = GetDigitLanguage(); + + if (nFlags & PushFlags::RASTEROP) + rState.meRasterOp = GetRasterOp(); + + if (nFlags & PushFlags::MAPMODE) + { + rState.mpMapMode = maMapMode; + rState.mbMapActive = mbMap; + } + + if (nFlags & PushFlags::CLIPREGION && mbClipRegion) + rState.mpClipRegion.reset(new vcl::Region(maRegion)); + + if (nFlags & PushFlags::REFPOINT && mbRefPoint) + rState.mpRefPoint = maRefPoint; + + if (mpAlphaVDev) + mpAlphaVDev->Push(); +} + +void OutputDevice::Pop() +{ + if( mpMetaFile ) + mpMetaFile->AddAction( new MetaPopAction() ); + + GDIMetaFile* pOldMetaFile = mpMetaFile; + mpMetaFile = nullptr; + + if ( maOutDevStateStack.empty() ) + { + SAL_WARN( "vcl.gdi", "OutputDevice::Pop() without OutputDevice::Push()" ); + return; + } + const OutDevState& rState = maOutDevStateStack.back(); + + if( mpAlphaVDev ) + mpAlphaVDev->Pop(); + + if ( rState.mnFlags & PushFlags::LINECOLOR ) + { + if ( rState.mpLineColor ) + SetLineColor( *rState.mpLineColor ); + else + SetLineColor(); + } + + if ( rState.mnFlags & PushFlags::FILLCOLOR ) + { + if ( rState.mpFillColor ) + SetFillColor( *rState.mpFillColor ); + else + SetFillColor(); + } + + if ( rState.mnFlags & PushFlags::FONT ) + SetFont( *rState.mpFont ); + + if ( rState.mnFlags & PushFlags::TEXTCOLOR ) + SetTextColor( *rState.mpTextColor ); + + if ( rState.mnFlags & PushFlags::TEXTFILLCOLOR ) + { + if ( rState.mpTextFillColor ) + SetTextFillColor( *rState.mpTextFillColor ); + else + SetTextFillColor(); + } + + if ( rState.mnFlags & PushFlags::TEXTLINECOLOR ) + { + if ( rState.mpTextLineColor ) + SetTextLineColor( *rState.mpTextLineColor ); + else + SetTextLineColor(); + } + + if ( rState.mnFlags & PushFlags::OVERLINECOLOR ) + { + if ( rState.mpOverlineColor ) + SetOverlineColor( *rState.mpOverlineColor ); + else + SetOverlineColor(); + } + + if ( rState.mnFlags & PushFlags::TEXTALIGN ) + SetTextAlign( rState.meTextAlign ); + + if( rState.mnFlags & PushFlags::TEXTLAYOUTMODE ) + SetLayoutMode( rState.mnTextLayoutMode ); + + if( rState.mnFlags & PushFlags::TEXTLANGUAGE ) + SetDigitLanguage( rState.meTextLanguage ); + + if ( rState.mnFlags & PushFlags::RASTEROP ) + SetRasterOp( rState.meRasterOp ); + + if ( rState.mnFlags & PushFlags::MAPMODE ) + { + if ( rState.mpMapMode ) + SetMapMode( *rState.mpMapMode ); + else + SetMapMode(); + mbMap = rState.mbMapActive; + } + + if ( rState.mnFlags & PushFlags::CLIPREGION ) + SetDeviceClipRegion( rState.mpClipRegion.get() ); + + if ( rState.mnFlags & PushFlags::REFPOINT ) + { + if ( rState.mpRefPoint ) + SetRefPoint( *rState.mpRefPoint ); + else + SetRefPoint(); + } + + maOutDevStateStack.pop_back(); + + mpMetaFile = pOldMetaFile; +} + +void OutputDevice::ClearStack() +{ + sal_uInt32 nCount = maOutDevStateStack.size(); + while( nCount-- ) + Pop(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |