1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <XPropertyTable.hxx>
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>
29 using namespace com::sun::star
;
31 XBitmapEntry
* XBitmapList::GetBitmap(tools::Long nIndex
) const
33 return static_cast<XBitmapEntry
*>( XPropertyList::Get(nIndex
) );
36 uno::Reference
< container::XNameContainer
> XBitmapList::createInstance()
38 return uno::Reference
< container::XNameContainer
>(
39 SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY
);
42 bool XBitmapList::Create()
47 BitmapEx
XBitmapList::CreateBitmap( tools::Long nIndex
, const Size
& rSize
) const
49 OSL_ENSURE( nIndex
< Count(), "Access out of range" );
53 BitmapEx rBitmapEx
= GetBitmap( nIndex
)->GetGraphicObject().GetGraphic().GetBitmapEx();
54 ScopedVclPtrInstance
< VirtualDevice
> pVirtualDevice
;
55 pVirtualDevice
->SetOutputSizePixel(rSize
);
57 if(rBitmapEx
.IsAlpha())
59 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
61 if(rStyleSettings
.GetPreviewUsesCheckeredBackground())
63 const Point
aNull(0, 0);
64 static const sal_uInt32
nLen(8);
65 static const Color
aW(COL_WHITE
);
66 static const Color
aG(0xef, 0xef, 0xef);
68 pVirtualDevice
->DrawCheckered(aNull
, rSize
, nLen
, aW
, aG
);
72 pVirtualDevice
->SetBackground(rStyleSettings
.GetFieldColor());
73 pVirtualDevice
->Erase();
77 if(rBitmapEx
.GetSizePixel().Width() >= rSize
.Width() && rBitmapEx
.GetSizePixel().Height() >= rSize
.Height())
79 rBitmapEx
.Scale(rSize
);
80 pVirtualDevice
->DrawBitmapEx(Point(0, 0), rBitmapEx
);
84 const Size
aBitmapSize(rBitmapEx
.GetSizePixel());
86 for(tools::Long
y(0); y
< rSize
.Height(); y
+= aBitmapSize
.Height())
88 for(tools::Long
x(0); x
< rSize
.Width(); x
+= aBitmapSize
.Width())
90 pVirtualDevice
->DrawBitmapEx(
96 rBitmapEx
= pVirtualDevice
->GetBitmapEx(Point(0, 0), rSize
);
103 BitmapEx
XBitmapList::CreateBitmapForUI( tools::Long nIndex
)
105 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
106 const Size
& rSize
= rStyleSettings
.GetListBoxPreviewDefaultPixelSize();
107 return CreateBitmap(nIndex
, rSize
);
110 BitmapEx
XBitmapList::GetBitmapForPreview( tools::Long nIndex
, const Size
& rSize
)
112 return CreateBitmap(nIndex
, rSize
);
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */