bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / filter / html / htmlattr.cxx
blobfe709ff7bea4c8bb299fca73fabc9c4a3b458ce3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "htmlattr.hxx"
21 #include "htmlex.hxx"
22 #include <vcl/decoview.hxx>
23 #include <vcl/builderfactory.hxx>
25 SdHtmlAttrPreview::SdHtmlAttrPreview(vcl::Window* pParent, WinBits nStyle)
26 : Control(pParent, nStyle)
30 VCL_BUILDER_DECL_FACTORY(SdHtmlAttrPreview)
32 WinBits nWinStyle = 0;
34 OString sBorder = VclBuilder::extractCustomProperty(rMap);
35 if (!sBorder.isEmpty())
36 nWinStyle |= WB_BORDER;
38 rRet = VclPtr<SdHtmlAttrPreview>::Create(pParent, nWinStyle);
41 SdHtmlAttrPreview::~SdHtmlAttrPreview()
45 void SdHtmlAttrPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
47 DecorationView aDecoView(&rRenderContext);
49 Rectangle aTextRect;
50 aTextRect.SetSize(GetOutputSize());
52 rRenderContext.SetLineColor(m_aBackColor);
53 rRenderContext.SetFillColor(m_aBackColor);
54 rRenderContext.DrawRect(rRect);
55 rRenderContext.SetFillColor();
57 int nHeight = (aTextRect.Bottom() - aTextRect.Top()) >> 2;
58 aTextRect.Bottom() = nHeight + aTextRect.Top();
60 rRenderContext.SetTextColor(m_aTextColor);
61 rRenderContext.DrawText(aTextRect, SD_RESSTR(STR_HTMLATTR_TEXT), DrawTextFlags::Center | DrawTextFlags::VCenter);
63 aTextRect.Move(0,nHeight);
64 rRenderContext.SetTextColor(m_aLinkColor);
65 rRenderContext.DrawText(aTextRect, SD_RESSTR(STR_HTMLATTR_LINK), DrawTextFlags::Center | DrawTextFlags::VCenter);
67 aTextRect.Move(0,nHeight);
68 rRenderContext.SetTextColor(m_aALinkColor);
69 rRenderContext.DrawText(aTextRect, SD_RESSTR(STR_HTMLATTR_ALINK), DrawTextFlags::Center | DrawTextFlags::VCenter);
71 aTextRect.Move(0,nHeight);
72 rRenderContext.SetTextColor(m_aVLinkColor);
73 rRenderContext.DrawText(aTextRect, SD_RESSTR(STR_HTMLATTR_VLINK), DrawTextFlags::Center | DrawTextFlags::VCenter);
76 void SdHtmlAttrPreview::SetColors(Color& aBack, Color& aText, Color& aLink,
77 Color& aVLink, Color& aALink)
79 m_aBackColor = aBack;
80 m_aTextColor = aText;
81 m_aLinkColor = aLink;
82 m_aVLinkColor = aVLink;
83 m_aALinkColor = aALink;
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */