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