diff options
author | Rishabh Kumar <kris.kr296@gmail.com> | 2016-07-20 00:59:13 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-07-20 21:52:42 +0000 |
commit | b0db1f4c79e12b4fc96f82b362b332d9ffb6e87c (patch) | |
tree | a16285bf1e30b85f31beffdd1b773979da400f16 /svx | |
parent | d77081946f59127aab4b017f455b0c5b489dcb84 (diff) |
Make pattern preset preview resizeable
Change-Id: I24e46ca08993cb359eddade72cd9bc4fda4512ff
Reviewed-on: https://gerrit.libreoffice.org/27323
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/xoutdev/xtabptrn.cxx | 69 |
1 files changed, 67 insertions, 2 deletions
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 <svx/xtable.hxx> #include <svx/xpool.hxx> #include <svx/xbtmpit.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> 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: */ |