LibreOffice Module svx (master) 1
xtabbtmp.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 <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
29using namespace com::sun::star;
30
32{
33 return static_cast<XBitmapEntry*>( XPropertyList::Get(nIndex) );
34}
35
36uno::Reference< container::XNameContainer > XBitmapList::createInstance()
37{
39}
40
42{
43 return true;
44}
45
47{
48 OSL_ENSURE( nIndex < Count(), "Access out of range" );
49
50 if(nIndex < Count())
51 {
54 pVirtualDevice->SetOutputSizePixel(rSize);
55
56 if(rBitmapEx.IsAlpha())
57 {
59
60 if(rStyleSettings.GetPreviewUsesCheckeredBackground())
61 {
62 const Point aNull(0, 0);
63 static const sal_uInt32 nLen(8);
64 static const Color aW(COL_WHITE);
65 static const Color aG(0xef, 0xef, 0xef);
66
67 pVirtualDevice->DrawCheckered(aNull, rSize, nLen, aW, aG);
68 }
69 else
70 {
71 pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor());
72 pVirtualDevice->Erase();
73 }
74 }
75
76 if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height())
77 {
78 rBitmapEx.Scale(rSize);
79 pVirtualDevice->DrawBitmapEx(Point(0, 0), rBitmapEx);
80 }
81 else
82 {
83 const Size aBitmapSize(rBitmapEx.GetSizePixel());
84
85 for(tools::Long y(0); y < rSize.Height(); y += aBitmapSize.Height())
86 {
87 for(tools::Long x(0); x < rSize.Width(); x += aBitmapSize.Width())
88 {
89 pVirtualDevice->DrawBitmapEx(
90 Point(x, y),
91 rBitmapEx);
92 }
93 }
94 }
95 rBitmapEx = pVirtualDevice->GetBitmapEx(Point(0, 0), rSize);
96 return rBitmapEx;
97 }
98 else
99 return BitmapEx();
100}
101
103{
104 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
105 const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize();
106 return CreateBitmap(nIndex, rSize);
107}
108
110{
111 return CreateBitmap(nIndex, rSize);
112}
113
114/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
uno::Reference< container::XNameContainer > SvxUnoXBitmapTable_createInstance(XPropertyList &rTable) noexcept
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
bool IsAlpha() const
const Size & GetSizePixel() const
const Graphic & GetGraphic() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
bool GetPreviewUsesCheckeredBackground() const
const Color & GetFieldColor() const
const Size & GetListBoxPreviewDefaultPixelSize() const
const GraphicObject & GetGraphicObject() const
Definition: xtable.hxx:125
virtual BitmapEx CreateBitmapForUI(tools::Long nIndex) override
Definition: xtabbtmp.cxx:102
XBitmapEntry * GetBitmap(tools::Long nIndex) const
Definition: xtabbtmp.cxx:31
virtual css::uno::Reference< css::container::XNameContainer > createInstance() override
Definition: xtabbtmp.cxx:36
BitmapEx GetBitmapForPreview(tools::Long nIndex, const Size &rSize)
Definition: xtabbtmp.cxx:109
BitmapEx CreateBitmap(tools::Long nIndex, const Size &rSize) const
Definition: xtabbtmp.cxx:46
virtual bool Create() override
Definition: xtabbtmp.cxx:41
tools::Long Count() const
Definition: xtable.cxx:121
XPropertyEntry * Get(tools::Long nIndex) const
Definition: xtable.cxx:131
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
float y
float x
sal_Int32 nIndex
long Long