Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/svx/source/xoutdev/xtabbtmp.cxx
Line
Count
Source (jump to first uncovered line)
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 <XPropertyTable.hxx>
21
22
#include <osl/diagnose.h>
23
#include <vcl/virdev.hxx>
24
#include <svx/xtable.hxx>
25
#include <vcl/bitmapex.hxx>
26
#include <vcl/settings.hxx>
27
#include <vcl/svapp.hxx>
28
29
using namespace com::sun::star;
30
31
XBitmapEntry* XBitmapList::GetBitmap(tools::Long nIndex) const
32
0
{
33
0
    return static_cast<XBitmapEntry*>( XPropertyList::Get(nIndex) );
34
0
}
35
36
uno::Reference< container::XNameContainer > XBitmapList::createInstance()
37
981
{
38
981
    return SvxUnoXBitmapTable_createInstance( *this );
39
981
}
40
41
bool XBitmapList::Create()
42
1.20k
{
43
1.20k
    return true;
44
1.20k
}
45
46
BitmapEx XBitmapList::CreateBitmap( tools::Long nIndex, const Size& rSize ) const
47
0
{
48
0
    OSL_ENSURE( nIndex < Count(), "Access out of range" );
49
50
0
    if(nIndex < Count())
51
0
    {
52
0
        BitmapEx rBitmapEx = GetBitmap( nIndex )->GetGraphicObject().GetGraphic().GetBitmapEx();
53
0
        ScopedVclPtrInstance< VirtualDevice > pVirtualDevice;
54
0
        pVirtualDevice->SetOutputSizePixel(rSize);
55
56
0
        if(rBitmapEx.IsAlpha())
57
0
        {
58
0
            const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
59
60
0
            if(rStyleSettings.GetPreviewUsesCheckeredBackground())
61
0
            {
62
0
                const Point aNull(0, 0);
63
0
                static const sal_uInt32 nLen(8);
64
0
                static const Color aW(COL_WHITE);
65
0
                static const Color aG(0xef, 0xef, 0xef);
66
67
0
                pVirtualDevice->DrawCheckered(aNull, rSize, nLen, aW, aG);
68
0
            }
69
0
            else
70
0
            {
71
0
                pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor());
72
0
                pVirtualDevice->Erase();
73
0
            }
74
0
        }
75
76
0
        if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height())
77
0
        {
78
0
            rBitmapEx.Scale(rSize);
79
0
            pVirtualDevice->DrawBitmapEx(Point(0, 0), rBitmapEx);
80
0
        }
81
0
        else
82
0
        {
83
0
            const Size aBitmapSize(rBitmapEx.GetSizePixel());
84
85
0
            for(tools::Long y(0); y < rSize.Height(); y += aBitmapSize.Height())
86
0
            {
87
0
                for(tools::Long x(0); x < rSize.Width(); x += aBitmapSize.Width())
88
0
                {
89
0
                    pVirtualDevice->DrawBitmapEx(
90
0
                        Point(x, y),
91
0
                        rBitmapEx);
92
0
                }
93
0
            }
94
0
        }
95
0
        rBitmapEx = pVirtualDevice->GetBitmapEx(Point(0, 0), rSize);
96
0
        return rBitmapEx;
97
0
    }
98
0
    else
99
0
        return BitmapEx();
100
0
}
101
102
BitmapEx XBitmapList::CreateBitmapForUI( tools::Long nIndex )
103
0
{
104
0
    const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
105
0
    const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize();
106
0
    return CreateBitmap(nIndex, rSize);
107
0
}
108
109
BitmapEx XBitmapList::GetBitmapForPreview( tools::Long nIndex, const Size& rSize )
110
0
{
111
0
    return CreateBitmap(nIndex, rSize);
112
0
}
113
114
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */