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