LibreOffice Module starmath (master) 1
tmpdevice.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 <smmod.hxx>
21#include <utility.hxx>
22
23#include "tmpdevice.hxx"
24
25#include <svtools/colorcfg.hxx>
26#include <sal/log.hxx>
27
28// SmTmpDevice
29// Allows for font and color changes. The original settings will be restored
30// in the destructor.
31// It's main purpose is to allow for the "const" in the 'OutputDevice'
32// argument in the 'Arrange' functions and restore changes made in the 'Draw'
33// functions.
34// Usually a MapMode of 1/100th mm will be used.
35
36SmTmpDevice::SmTmpDevice(OutputDevice &rTheDev, bool bUseMap100th_mm) :
37 rOutDev(rTheDev)
38{
41 if (bUseMap100th_mm && SmMapUnit() != rOutDev.GetMapMode().GetMapUnit())
42 {
43 SAL_WARN("starmath", "incorrect MapMode?");
44 rOutDev.SetMapMode(MapMode(SmMapUnit())); // format for 100% always
45 }
46}
47
48
50{
51 if (rTextColor == COL_AUTO)
52 {
53 Color aConfigFontColor = SM_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
54 Color aConfigDocColor = SM_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
55 return rOutDev.GetReadableFontColor(aConfigFontColor, aConfigDocColor);
56 }
57
58 return rTextColor;
59}
60
61
62void SmTmpDevice::SetFont(const vcl::Font &rNewFont)
63{
64 rOutDev.SetFont(rNewFont);
66}
67
68/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
MapUnit GetMapUnit() const
void SetFont(const vcl::Font &rNewFont)
virtual Color GetReadableFontColor(const Color &rFontColor, const Color &rBgColor) const
void SetMapMode()
void SetTextColor(const Color &rColor)
const MapMode & GetMapMode() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
void SetFont(const vcl::Font &rNewFont)
Definition: tmpdevice.cxx:62
OutputDevice & rOutDev
Definition: tmpdevice.hxx:27
Color GetTextColor(const Color &rTextColor)
Definition: tmpdevice.cxx:49
SmTmpDevice(const SmTmpDevice &)=delete
const Color & GetColor() const
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define SAL_WARN(area, stream)
#define SM_MOD()
Definition: smmod.hxx:98
MapUnit SmMapUnit()
Definition: utility.hxx:121