diff --git a/include/svx/xtable.hxx b/include/svx/xtable.hxx index e17a022702be..a692f39e36ba 100644 --- a/include/svx/xtable.hxx +++ b/include/svx/xtable.hxx @@ -397,6 +397,9 @@ public: class SVX_DLLPUBLIC XPatternList : public XPropertyList { +private: + Bitmap CreateBitmap( long nIndex, const Size& rSize ) const; + protected: virtual Bitmap CreateBitmapForUI(long nIndex) override; @@ -406,9 +409,9 @@ public: using XPropertyList::Replace; using XPropertyList::Remove; - XBitmapEntry* Remove(long nIndex); XBitmapEntry* GetBitmap(long nIndex) const; + Bitmap GetBitmapForPreview(long nIndex, const Size& rSize); virtual css::uno::Reference< css::container::XNameContainer > createInstance() override; virtual bool Create() override; diff --git a/svx/source/xoutdev/xtabptrn.cxx b/svx/source/xoutdev/xtabptrn.cxx index 6fcfec98e32f..9cbda46acb68 100644 --- a/svx/source/xoutdev/xtabptrn.cxx +++ b/svx/source/xoutdev/xtabptrn.cxx @@ -27,6 +27,8 @@ #include #include #include +#include +#include using namespace com::sun::star; @@ -84,9 +86,72 @@ bool XPatternList::Create() return true; } -Bitmap XPatternList::CreateBitmapForUI( long /*nIndex*/ ) +Bitmap XPatternList::CreateBitmap( long nIndex, const Size& rSize ) const { - return Bitmap(); + OSL_ENSURE( nIndex < Count(), "Access out of range" ); + + if(nIndex < Count()) + { + BitmapEx rBitmapEx = GetBitmap( nIndex )->GetGraphicObject().GetGraphic().GetBitmapEx(); + ScopedVclPtrInstance< VirtualDevice > pVirtualDevice; + pVirtualDevice->SetOutputSizePixel(rSize); + + if(rBitmapEx.IsTransparent()) + { + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + if(rStyleSettings.GetPreviewUsesCheckeredBackground()) + { + const Point aNull(0, 0); + static const sal_uInt32 nLen(8); + static const Color aW(COL_WHITE); + static const Color aG(0xef, 0xef, 0xef); + + pVirtualDevice->DrawCheckered(aNull, rSize, nLen, aW, aG); + } + else + { + pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor()); + pVirtualDevice->Erase(); + } + } + + if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height()) + { + rBitmapEx.Scale(rSize); + pVirtualDevice->DrawBitmapEx(Point(0, 0), rBitmapEx); + } + else + { + const Size aBitmapSize(rBitmapEx.GetSizePixel()); + + for(long y(0); y < rSize.Height(); y += aBitmapSize.Height()) + { + for(long x(0); x < rSize.Width(); x += aBitmapSize.Width()) + { + pVirtualDevice->DrawBitmapEx( + Point(x, y), + rBitmapEx); + } + } + } + rBitmapEx = pVirtualDevice->GetBitmap(Point(0, 0), rSize); + return rBitmapEx.GetBitmap(); + } + else + return Bitmap(); +} + +Bitmap XPatternList::CreateBitmapForUI( long nIndex ) +{ + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); + return CreateBitmap(nIndex, rSize); +} + +Bitmap XPatternList::GetBitmapForPreview( long nIndex, const Size& rSize ) +{ + return CreateBitmap(nIndex, rSize); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */