Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sfx2/source/control/templateviewitem.cxx
Line
Count
Source
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
10
#include <templateviewitem.hxx>
11
12
#include <basegfx/matrix/b2dhommatrixtools.hxx>
13
#include <basegfx/polygon/b2dpolygon.hxx>
14
#include <drawinglayer/attribute/fillgraphicattribute.hxx>
15
#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
16
#include <drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx>
17
#include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
18
#include <drawinglayer/primitive2d/PolyPolygonSelectionPrimitive2D.hxx>
19
#include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx>
20
#include <drawinglayer/processor2d/baseprocessor2d.hxx>
21
#include <tools/color.hxx>
22
#include <tools/poly.hxx>
23
#include <vcl/graph.hxx>
24
25
#include <bitmaps.hlst>
26
27
using namespace basegfx;
28
using namespace basegfx::utils;
29
using namespace drawinglayer::attribute;
30
using namespace drawinglayer::primitive2d;
31
32
TemplateViewItem::TemplateViewItem(ThumbnailView& rView, sal_uInt16 nId)
33
0
    : ThumbnailViewItem(rView, nId),
34
0
      mnRegionId(USHRT_MAX),
35
0
      mnDocId(USHRT_MAX),
36
0
      maDefaultBitmap(BMP_DEFAULT),
37
0
      mbIsDefaultTemplate(false)
38
0
{
39
0
}
40
41
TemplateViewItem::~TemplateViewItem ()
42
0
{
43
0
}
44
45
Point TemplateViewItem::getDefaultIconPosition() const
46
0
{
47
0
    ::tools::Rectangle aArea(getDrawArea());
48
0
    return Point(aArea.Left() + THUMBNAILVIEW_ITEM_CORNER, aArea.Top() + THUMBNAILVIEW_ITEM_CORNER);
49
0
}
50
51
void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D* pProcessor,
52
                             const ThumbnailItemAttributes& rAttrs)
53
0
{
54
0
    BColor aFillColor = rAttrs.aFillColor;
55
56
0
    drawinglayer::primitive2d::Primitive2DContainer aSeq(5);
57
0
    double fTransparence = 0.0;
58
59
    // Draw background
60
0
    if( mbSelected && mbHover)
61
0
        aFillColor = rAttrs.aHighlightColor;
62
0
    else if (mbSelected || mbHover)
63
0
    {
64
0
        aFillColor = rAttrs.aHighlightColor;
65
0
        if (mbHover)
66
0
            fTransparence = rAttrs.fHighlightTransparence;
67
0
    }
68
69
0
    aSeq[0] =
70
0
            new PolyPolygonSelectionPrimitive2D( B2DPolyPolygon(::tools::Polygon(maDrawArea,5,5).getB2DPolygon()),
71
0
                                                 aFillColor,
72
0
                                                 fTransparence,
73
0
                                                 0.0,
74
0
                                                 true);
75
76
    // Draw thumbnail
77
0
    Size aImageSize = maPreview.GetSizePixel();
78
79
0
    float fWidth = aImageSize.Width();
80
0
    float fHeight = aImageSize.Height();
81
0
    float fPosX = maPrev1Pos.getX();
82
0
    float fPosY = maPrev1Pos.getY();
83
84
0
    B2DPolygon aBounds;
85
0
    aBounds.append(B2DPoint(fPosX,fPosY));
86
0
    aBounds.append(B2DPoint(fPosX+fWidth,fPosY));
87
0
    aBounds.append(B2DPoint(fPosX+fWidth,fPosY+fHeight));
88
0
    aBounds.append(B2DPoint(fPosX,fPosY+fHeight));
89
0
    aBounds.setClosed(true);
90
91
0
    aSeq[1] = new PolyPolygonColorPrimitive2D(
92
0
                    B2DPolyPolygon(aBounds), COL_WHITE.getBColor());
93
94
0
    aSeq[2] = new FillGraphicPrimitive2D(
95
0
                    createTranslateB2DHomMatrix(maPrev1Pos.X(),maPrev1Pos.Y()),
96
0
                    FillGraphicAttribute(Graphic(maPreview),
97
0
                                        B2DRange(
98
0
                                            B2DPoint(0,0),
99
0
                                            B2DPoint(aImageSize.Width(),aImageSize.Height())),
100
0
                                        false)
101
0
                    );
102
103
    // draw thumbnail borders
104
0
    aSeq[3] = createBorderLine(aBounds);
105
106
0
    if(mbIsDefaultTemplate)
107
0
    {
108
0
        const Point aIconPos = getDefaultIconPosition();
109
110
0
        aSeq[4] = new DiscreteBitmapPrimitive2D( maDefaultBitmap,
111
0
                    B2DPoint(aIconPos.X(), aIconPos.Y()));
112
0
    }
113
114
0
    addTextPrimitives(maTitle, rAttrs, maTextPos, aSeq);
115
116
0
    pProcessor->process(aSeq);
117
0
}
118
119
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
120
121