diff options
author | Rishabh Kumar <kris.kr296@gmail.com> | 2016-07-07 19:47:30 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-07-08 20:07:06 +0000 |
commit | 94a001bc62abc4e561e99fdd82c7eee46579fe4e (patch) | |
tree | 8ff34d23051492b52d42dc005d6723a1cff45350 | |
parent | 731be5ca597a5c83d5bb82478058458a3779345b (diff) |
Make bitmap preset preview resizable
Change-Id: I733994c93b598a357dfe24c525d74978d3f70237
Reviewed-on: https://gerrit.libreoffice.org/27011
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r-- | include/svx/xtable.hxx | 4 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabbtmp.cxx | 70 |
2 files changed, 72 insertions, 2 deletions
diff --git a/include/svx/xtable.hxx b/include/svx/xtable.hxx index 93b6f39706ce..e17a022702be 100644 --- a/include/svx/xtable.hxx +++ b/include/svx/xtable.hxx @@ -375,6 +375,9 @@ public: class SVX_DLLPUBLIC XBitmapList : public XPropertyList { +private: + Bitmap CreateBitmap( long nIndex, const Size& rSize ) const; + protected: virtual Bitmap CreateBitmapForUI(long nIndex) override; @@ -386,6 +389,7 @@ public: 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/xtabbtmp.cxx b/svx/source/xoutdev/xtabbtmp.cxx index bfc086671559..e0a280a14e7a 100644 --- a/svx/source/xoutdev/xtabbtmp.cxx +++ b/svx/source/xoutdev/xtabbtmp.cxx @@ -27,6 +27,9 @@ #include <svx/xtable.hxx> #include <svx/xpool.hxx> #include <svx/xbtmpit.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> using namespace com::sun::star; @@ -51,9 +54,72 @@ bool XBitmapList::Create() return true; } -Bitmap XBitmapList::CreateBitmapForUI( long /*nIndex*/ ) +Bitmap XBitmapList::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 XBitmapList::CreateBitmapForUI( long nIndex ) +{ + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); + return CreateBitmap(nIndex, rSize); +} + +Bitmap XBitmapList::GetBitmapForPreview( long nIndex, const Size& rSize ) +{ + return CreateBitmap(nIndex, rSize); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |