LibreOffice Module sd (master) 1
htmlattr.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 "htmlattr.hxx"
21#include <sdresid.hxx>
22#include <strings.hrc>
23#include <vcl/outdev.hxx>
24
26{
27}
28
30{
31}
32
33void SdHtmlAttrPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect)
34{
35 ::tools::Rectangle aTextRect;
36 aTextRect.SetSize(GetOutputSizePixel());
37
38 rRenderContext.SetLineColor(m_aBackColor);
39 rRenderContext.SetFillColor(m_aBackColor);
40 rRenderContext.DrawRect(rRect);
41 rRenderContext.SetFillColor();
42
43 int nHeight = (aTextRect.Bottom() - aTextRect.Top()) >> 2;
44 aTextRect.SetBottom( nHeight + aTextRect.Top() );
45
46 rRenderContext.SetTextColor(m_aTextColor);
47 rRenderContext.DrawText(aTextRect, SdResId(STR_HTMLATTR_TEXT), DrawTextFlags::Center | DrawTextFlags::VCenter);
48
49 aTextRect.Move(0,nHeight);
50 rRenderContext.SetTextColor(m_aLinkColor);
51 rRenderContext.DrawText(aTextRect, SdResId(STR_HTMLATTR_LINK), DrawTextFlags::Center | DrawTextFlags::VCenter);
52
53 aTextRect.Move(0,nHeight);
54 rRenderContext.SetTextColor(m_aALinkColor);
55 rRenderContext.DrawText(aTextRect, SdResId(STR_HTMLATTR_ALINK), DrawTextFlags::Center | DrawTextFlags::VCenter);
56
57 aTextRect.Move(0,nHeight);
58 rRenderContext.SetTextColor(m_aVLinkColor);
59 rRenderContext.DrawText(aTextRect, SdResId(STR_HTMLATTR_VLINK), DrawTextFlags::Center | DrawTextFlags::VCenter);
60}
61
62void SdHtmlAttrPreview::SetColors(Color const & aBack, Color const & aText, Color const & aLink,
63 Color const & aVLink, Color const & aALink)
64{
65 m_aBackColor = aBack;
66 m_aTextColor = aText;
67 m_aLinkColor = aLink;
68 m_aVLinkColor = aVLink;
69 m_aALinkColor = aALink;
70}
71
72/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void DrawRect(const tools::Rectangle &rRect)
void SetLineColor()
void SetTextColor(const Color &rColor)
void SetFillColor()
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override
Definition: htmlattr.cxx:33
void SetColors(Color const &aBack, Color const &aText, Color const &aLink, Color const &aVLink, Color const &aALink)
Definition: htmlattr.cxx:62
virtual ~SdHtmlAttrPreview() override
Definition: htmlattr.cxx:29
constexpr tools::Long Top() const
void SetSize(const Size &)
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr void SetBottom(tools::Long v)
constexpr tools::Long Bottom() const
Size const & GetOutputSizePixel() const
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83