Kaydet (Commit) bbc58f20 authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Resolves: #i121445# Added transparency support to the gallery

(cherry picked from commit cf417aec)

Conflicts:
	extras/source/gallery/gallery_system/sg2.sdg
	extras/source/gallery/gallery_system/sg2.thm
	svx/inc/galtheme.hrc
	svx/inc/svx/fontworkgallery.hxx
	svx/inc/svx/gallery.hxx
	svx/inc/svx/galtheme.hxx
	svx/source/gallery2/galctrl.cxx
	svx/source/gallery2/galexpl.cxx
	svx/source/gallery2/galobj.cxx
	svx/source/tbxctrls/fontworkgallery.cxx
	vcl/inc/vcl/outdev.hxx
	vcl/source/gdi/outdev6.cxx

Change-Id: I519a2cf4e16bb42ecfd9c4b48094e65adcc35599
(cherry picked from commit ddec662e8dc234b7196c1b3c28db5da743557ec6)
üst 94298db9
...@@ -103,11 +103,11 @@ class SVX_DLLPUBLIC FontWorkGalleryDialog : public ModalDialog ...@@ -103,11 +103,11 @@ class SVX_DLLPUBLIC FontWorkGalleryDialog : public ModalDialog
SdrObject** mppSdrObject; SdrObject** mppSdrObject;
SdrModel* mpDestModel; SdrModel* mpDestModel;
void initfavorites(sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites); void initFavorites(sal_uInt16 nThemeId);
void insertSelectedFontwork(); void insertSelectedFontwork();
void fillFavorites( sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites ); void fillFavorites(sal_uInt16 nThemeId);
std::vector< Bitmap * > maFavoritesHorizontal; std::vector< BitmapEx> maFavoritesHorizontal;
public: public:
FontWorkGalleryDialog( SdrView* pView, Window* pParent, sal_uInt16 nSID ); FontWorkGalleryDialog( SdrView* pView, Window* pParent, sal_uInt16 nSID );
......
...@@ -55,7 +55,7 @@ class FmFormModel; ...@@ -55,7 +55,7 @@ class FmFormModel;
class SdrModel; class SdrModel;
class Graphic; class Graphic;
class FmFormModel; class FmFormModel;
class Bitmap; class BitmapEx;
class OutputDevice; class OutputDevice;
class SVX_DLLPUBLIC GalleryExplorer class SVX_DLLPUBLIC GalleryExplorer
...@@ -94,19 +94,19 @@ public: ...@@ -94,19 +94,19 @@ public:
const sal_uIntPtr nSgaFormat /* = SGA_FORMAT_ALL */ ); const sal_uIntPtr nSgaFormat /* = SGA_FORMAT_ALL */ );
static sal_Bool GetGraphicObj( const String& rThemeName, sal_uIntPtr nPos, static sal_Bool GetGraphicObj( const String& rThemeName, sal_uIntPtr nPos,
Graphic* pGraphic = NULL, Bitmap* pThumb = NULL, Graphic* pGraphic = NULL, BitmapEx* pThumb = NULL,
sal_Bool bProgess = sal_False ); sal_Bool bProgess = sal_False );
static sal_Bool GetGraphicObj( sal_uIntPtr nThemeId, sal_uIntPtr nPos, static sal_Bool GetGraphicObj( sal_uIntPtr nThemeId, sal_uIntPtr nPos,
Graphic* pGraphic = NULL, Bitmap* pThumb = NULL, Graphic* pGraphic = NULL, BitmapEx* pThumb = NULL,
sal_Bool bProgess = sal_False ); sal_Bool bProgess = sal_False );
static sal_uIntPtr GetSdrObjCount( const String& rThemeName ); static sal_uIntPtr GetSdrObjCount( const String& rThemeName );
static sal_uIntPtr GetSdrObjCount( sal_uIntPtr nThemeId ); static sal_uIntPtr GetSdrObjCount( sal_uIntPtr nThemeId );
static sal_Bool GetSdrObj( const String& rThemeName, sal_uIntPtr nSdrModelPos, static sal_Bool GetSdrObj( const String& rThemeName, sal_uIntPtr nSdrModelPos,
SdrModel* pModel = NULL, Bitmap* pThumb = NULL ); SdrModel* pModel = NULL, BitmapEx* pThumb = NULL );
static sal_Bool GetSdrObj( sal_uIntPtr nThemeId, sal_uIntPtr nSdrModelPos, static sal_Bool GetSdrObj( sal_uIntPtr nThemeId, sal_uIntPtr nSdrModelPos,
SdrModel* pModel = NULL, Bitmap* pThumb = NULL ); SdrModel* pModel = NULL, BitmapEx* pThumb = NULL );
static sal_Bool BeginLocking( const String& rThemeName ); static sal_Bool BeginLocking( const String& rThemeName );
static sal_Bool BeginLocking( sal_uIntPtr nThemeId ); static sal_Bool BeginLocking( sal_uIntPtr nThemeId );
......
...@@ -190,7 +190,7 @@ public: ...@@ -190,7 +190,7 @@ public:
return ImplGetGalleryObject( nPos )->aURL; return ImplGetGalleryObject( nPos )->aURL;
} }
sal_Bool GetThumb( sal_uIntPtr nPos, Bitmap& rBmp, sal_Bool bProgress = sal_False ); sal_Bool GetThumb( sal_uIntPtr nPos, BitmapEx& rBmp, sal_Bool bProgress = sal_False );
SVX_DLLPUBLIC sal_Bool GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, sal_Bool bProgress = sal_False ); SVX_DLLPUBLIC sal_Bool GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, sal_Bool bProgress = sal_False );
SVX_DLLPUBLIC sal_Bool InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInsertPos = LIST_APPEND ); SVX_DLLPUBLIC sal_Bool InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInsertPos = LIST_APPEND );
......
...@@ -794,6 +794,14 @@ public: ...@@ -794,6 +794,14 @@ public:
bool DrawEPS( const Point& rPt, const Size& rSz, bool DrawEPS( const Point& rPt, const Size& rSz,
const GfxLink& rGfxLink, GDIMetaFile* pSubst = NULL ); const GfxLink& rGfxLink, GDIMetaFile* pSubst = NULL );
/// Fill the given rectangle with checkered rectangles of size nLen x nLen using the colors aStart and aEnd
void DrawCheckered(
const Point& rPos,
const Size& rSize,
sal_uInt32 nLen = 8,
Color aStart = Color(COL_WHITE),
Color aEnd = Color(COL_BLACK));
Color GetPixel( const Point& rPt ) const; Color GetPixel( const Point& rPt ) const;
Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const; Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const;
......
...@@ -57,7 +57,7 @@ private: ...@@ -57,7 +57,7 @@ private:
protected: protected:
Bitmap aThumbBmp; BitmapEx aThumbBmp; // Allow transparence to survive
GDIMetaFile aThumbMtf; GDIMetaFile aThumbMtf;
INetURLObject aURL; INetURLObject aURL;
String aUserName; String aUserName;
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
virtual SgaObjKind GetObjKind() const = 0; virtual SgaObjKind GetObjKind() const = 0;
virtual sal_uInt16 GetVersion() const = 0; virtual sal_uInt16 GetVersion() const = 0;
virtual Bitmap GetThumbBmp() const { return aThumbBmp; } virtual BitmapEx GetThumbBmp() const { return aThumbBmp; }
const GDIMetaFile& GetThumbMtf() const { return aThumbMtf; } const GDIMetaFile& GetThumbMtf() const { return aThumbMtf; }
const INetURLObject& GetURL() const { return aURL; } const INetURLObject& GetURL() const { return aURL; }
sal_Bool IsValid() const { return bIsValid; } sal_Bool IsValid() const { return bIsValid; }
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
virtual ~SgaObjectSound(); virtual ~SgaObjectSound();
virtual SgaObjKind GetObjKind() const { return SGA_OBJ_SOUND; } virtual SgaObjKind GetObjKind() const { return SGA_OBJ_SOUND; }
virtual Bitmap GetThumbBmp() const; virtual BitmapEx GetThumbBmp() const;
GalSoundType GetSoundType() const { return eSoundType; } GalSoundType GetSoundType() const { return eSoundType; }
}; };
...@@ -136,10 +136,6 @@ public: ...@@ -136,10 +136,6 @@ public:
virtual ~SgaObjectSvDraw() {}; virtual ~SgaObjectSvDraw() {};
virtual SgaObjKind GetObjKind() const { return SGA_OBJ_SVDRAW; } virtual SgaObjKind GetObjKind() const { return SGA_OBJ_SVDRAW; }
public:
static sal_Bool DrawCentered( OutputDevice* pOut, const FmFormModel& rModel );
}; };
class SgaObjectBmp: public SgaObject class SgaObjectBmp: public SgaObject
......
...@@ -22,8 +22,14 @@ ...@@ -22,8 +22,14 @@
#define RID_GALLERYSTR_THEME_START (6000) #define RID_GALLERYSTR_THEME_START (6000)
// ATTENTION: This list has to be in sync with // ATTENTION: This list has to be in sync with
// * svx/inc/svx/gallery.hxx // * include/svx/gallery.hxx
// * share/gallery (theme files are identified by id) // * share/gallery (theme files are identified by id)
//
// These defines are used to map gallery names to translated string ressources. Since
// galleries may be copied from older offices to newer, do *never* change this
// IDs except adding new ones (and adapting RID_GALLERYSTR_THEME_LAST). The ID
// *is* written into the binary file *.thm (which is a galler theme combined of
// three files, *.thm, *.sdv and *.sdg)
#define RID_GALLERYSTR_THEME_3D (RID_GALLERYSTR_THEME_START + 1) #define RID_GALLERYSTR_THEME_3D (RID_GALLERYSTR_THEME_START + 1)
#define RID_GALLERYSTR_THEME_ANIMATIONS (RID_GALLERYSTR_THEME_START + 2) #define RID_GALLERYSTR_THEME_ANIMATIONS (RID_GALLERYSTR_THEME_START + 2)
......
...@@ -258,6 +258,16 @@ void GalleryPreview::PreviewMedia( const INetURLObject& rURL ) ...@@ -258,6 +258,16 @@ void GalleryPreview::PreviewMedia( const INetURLObject& rURL )
} }
} }
void drawCheckered(OutputDevice& rOut, const Point& rPos, const Size& rSize)
{
// draw checkered background
static const sal_uInt32 nLen(8);
static const Color aW(COL_WHITE);
static const Color aG(0xef, 0xef, 0xef);
rOut.DrawCheckered(rPos, rSize, nLen, aW, aG);
}
DBG_NAME(GalleryIconView) DBG_NAME(GalleryIconView)
GalleryIconView::GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) : GalleryIconView::GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
...@@ -311,21 +321,37 @@ void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt ) ...@@ -311,21 +321,37 @@ void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt )
const Rectangle& rRect = rUDEvt.GetRect(); const Rectangle& rRect = rUDEvt.GetRect();
OutputDevice* pDev = rUDEvt.GetDevice(); OutputDevice* pDev = rUDEvt.GetDevice();
Graphic aGraphic; Graphic aGraphic;
bool bTransparent(false);
if( pObj->IsThumbBitmap() ) if( pObj->IsThumbBitmap() )
{ {
Bitmap aBmp( pObj->GetThumbBmp() ); BitmapEx aBitmapEx;
if( pObj->GetObjKind() == SGA_OBJ_SOUND ) if( pObj->GetObjKind() == SGA_OBJ_SOUND )
aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE ); {
Bitmap aTemp = pObj->GetThumbBmp().GetBitmap();
aTemp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
aBitmapEx = BitmapEx(aTemp);
}
else
{
aBitmapEx = pObj->GetThumbBmp();
bTransparent = aBitmapEx.IsTransparent();
}
if( ( pDev->GetBitCount() <= 8 ) && ( aBmp.GetBitCount() >= 8 ) ) if( ( pDev->GetBitCount() <= 8 ) && ( aBitmapEx.GetBitCount() >= 8 ) )
aBmp.Dither( BMP_DITHER_FLOYD ); {
aBitmapEx.Dither( BMP_DITHER_FLOYD );
}
aGraphic = aBmp; aGraphic = aBitmapEx;
} }
else else
{
aGraphic = pObj->GetThumbMtf(); aGraphic = pObj->GetThumbMtf();
bTransparent = true;
}
Size aSize( aGraphic.GetSizePixel( pDev ) ); Size aSize( aGraphic.GetSizePixel( pDev ) );
...@@ -352,6 +378,12 @@ void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt ) ...@@ -352,6 +378,12 @@ void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt )
const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(), const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() ); ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
if(bTransparent)
{
// draw checkered background
drawCheckered(*pDev, aPos, aSize);
}
aGraphic.Draw( pDev, aPos, aSize ); aGraphic.Draw( pDev, aPos, aSize );
} }
...@@ -517,13 +549,24 @@ void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, sa ...@@ -517,13 +549,24 @@ void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, sa
{ {
Rectangle aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) ); Rectangle aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) );
GraphicObject aGrfObj; GraphicObject aGrfObj;
bool bTransparent(false);
if( pObj->GetObjKind() == SGA_OBJ_SOUND ) if( pObj->GetObjKind() == SGA_OBJ_SOUND )
{
aGrfObj = Graphic( BitmapEx( GAL_RES( RID_SVXBMP_GALLERY_MEDIA ) ) ); aGrfObj = Graphic( BitmapEx( GAL_RES( RID_SVXBMP_GALLERY_MEDIA ) ) );
}
else if( pObj->IsThumbBitmap() ) else if( pObj->IsThumbBitmap() )
aGrfObj = Graphic( pObj->GetThumbBmp() ); {
const BitmapEx aBitmapEx(pObj->GetThumbBmp());
bTransparent = aBitmapEx.IsTransparent();
aGrfObj = Graphic(aBitmapEx);
}
else else
{
aGrfObj = Graphic( pObj->GetThumbMtf() ); aGrfObj = Graphic( pObj->GetThumbMtf() );
bTransparent = true;
}
Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) ); Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
...@@ -553,6 +596,12 @@ void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, sa ...@@ -553,6 +596,12 @@ void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, sa
const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(), const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(),
( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() ); ( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() );
if(bTransparent)
{
// draw checkered background
drawCheckered(rDev, aPos, aSize);
}
aGrfObj.Draw( &rDev, aPos, aSize ); aGrfObj.Draw( &rDev, aPos, aSize );
} }
......
...@@ -237,7 +237,7 @@ sal_Bool GalleryExplorer::InsertURL( sal_uIntPtr nThemeId, const String& rURL, c ...@@ -237,7 +237,7 @@ sal_Bool GalleryExplorer::InsertURL( sal_uIntPtr nThemeId, const String& rURL, c
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
sal_Bool GalleryExplorer::GetGraphicObj( const String& rThemeName, sal_uIntPtr nPos, sal_Bool GalleryExplorer::GetGraphicObj( const String& rThemeName, sal_uIntPtr nPos,
Graphic* pGraphic, Bitmap* pThumb, Graphic* pGraphic, BitmapEx* pThumb,
sal_Bool bProgress ) sal_Bool bProgress )
{ {
Gallery* pGal = ImplGetGallery(); Gallery* pGal = ImplGetGallery();
...@@ -266,7 +266,7 @@ sal_Bool GalleryExplorer::GetGraphicObj( const String& rThemeName, sal_uIntPtr n ...@@ -266,7 +266,7 @@ sal_Bool GalleryExplorer::GetGraphicObj( const String& rThemeName, sal_uIntPtr n
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
sal_Bool GalleryExplorer::GetGraphicObj( sal_uIntPtr nThemeId, sal_uIntPtr nPos, sal_Bool GalleryExplorer::GetGraphicObj( sal_uIntPtr nThemeId, sal_uIntPtr nPos,
Graphic* pGraphic, Bitmap* pThumb, Graphic* pGraphic, BitmapEx* pThumb,
sal_Bool bProgress ) sal_Bool bProgress )
{ {
Gallery* pGal = ImplGetGallery(); Gallery* pGal = ImplGetGallery();
...@@ -309,7 +309,7 @@ sal_uIntPtr GalleryExplorer::GetSdrObjCount( sal_uIntPtr nThemeId ) ...@@ -309,7 +309,7 @@ sal_uIntPtr GalleryExplorer::GetSdrObjCount( sal_uIntPtr nThemeId )
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
sal_Bool GalleryExplorer::GetSdrObj( const String& rThemeName, sal_uIntPtr nSdrModelPos, sal_Bool GalleryExplorer::GetSdrObj( const String& rThemeName, sal_uIntPtr nSdrModelPos,
SdrModel* pModel, Bitmap* pThumb ) SdrModel* pModel, BitmapEx* pThumb )
{ {
Gallery* pGal = ImplGetGallery(); Gallery* pGal = ImplGetGallery();
sal_Bool bRet = sal_False; sal_Bool bRet = sal_False;
...@@ -346,7 +346,7 @@ sal_Bool GalleryExplorer::GetSdrObj( const String& rThemeName, sal_uIntPtr nSdrM ...@@ -346,7 +346,7 @@ sal_Bool GalleryExplorer::GetSdrObj( const String& rThemeName, sal_uIntPtr nSdrM
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
sal_Bool GalleryExplorer::GetSdrObj( sal_uIntPtr nThemeId, sal_uIntPtr nSdrModelPos, sal_Bool GalleryExplorer::GetSdrObj( sal_uIntPtr nThemeId, sal_uIntPtr nSdrModelPos,
SdrModel* pModel, Bitmap* pThumb ) SdrModel* pModel, BitmapEx* pThumb )
{ {
Gallery* pGal = ImplGetGallery(); Gallery* pGal = ImplGetGallery();
return( pGal ? GetSdrObj( pGal->GetThemeName( nThemeId ), nSdrModelPos, pModel, pThumb ) : sal_False ); return( pGal ? GetSdrObj( pGal->GetThemeName( nThemeId ), nSdrModelPos, pModel, pThumb ) : sal_False );
......
...@@ -88,7 +88,8 @@ sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic ) ...@@ -88,7 +88,8 @@ sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic )
} }
} }
aThumbBmp = aBmpEx.GetBitmap( &aWhite ); // take over BitmapEx
aThumbBmp = aBmpEx;
if( ( aBmpSize.Width() <= S_THUMB ) && ( aBmpSize.Height() <= S_THUMB ) ) if( ( aBmpSize.Width() <= S_THUMB ) && ( aBmpSize.Height() <= S_THUMB ) )
{ {
...@@ -123,7 +124,7 @@ sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic ) ...@@ -123,7 +124,7 @@ sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic )
aSize.Height() = (sal_Int32)( S_THUMB / fFactor ); aSize.Height() = (sal_Int32)( S_THUMB / fFactor );
const GraphicConversionParameters aParameters(aSize, false, true, true /*TODO: extra ", true" post-#i121194#*/); const GraphicConversionParameters aParameters(aSize, false, true, true /*TODO: extra ", true" post-#i121194#*/);
aThumbBmp = rGraphic.GetBitmap(aParameters); aThumbBmp = rGraphic.GetBitmapEx(aParameters);
if( !aThumbBmp.IsEmpty() ) if( !aThumbBmp.IsEmpty() )
{ {
...@@ -341,7 +342,7 @@ SgaObjectSound::~SgaObjectSound() ...@@ -341,7 +342,7 @@ SgaObjectSound::~SgaObjectSound()
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
Bitmap SgaObjectSound::GetThumbBmp() const BitmapEx SgaObjectSound::GetThumbBmp() const
{ {
sal_uInt16 nId; sal_uInt16 nId;
...@@ -362,9 +363,8 @@ Bitmap SgaObjectSound::GetThumbBmp() const ...@@ -362,9 +363,8 @@ Bitmap SgaObjectSound::GetThumbBmp() const
} }
const BitmapEx aBmpEx( GAL_RES( nId ) ); const BitmapEx aBmpEx( GAL_RES( nId ) );
const Color aTransColor( COL_WHITE );
return aBmpEx.GetBitmap( &aTransColor ); return aBmpEx;
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
...@@ -506,76 +506,50 @@ sal_Bool SgaObjectSvDraw::CreateThumb( const FmFormModel& rModel ) ...@@ -506,76 +506,50 @@ sal_Bool SgaObjectSvDraw::CreateThumb( const FmFormModel& rModel )
sal_Bool bRet = sal_False; sal_Bool bRet = sal_False;
if ( CreateIMapGraphic( rModel, aGraphic, aImageMap ) ) if ( CreateIMapGraphic( rModel, aGraphic, aImageMap ) )
{
bRet = SgaObject::CreateThumb( aGraphic ); bRet = SgaObject::CreateThumb( aGraphic );
}
else else
{ {
VirtualDevice aVDev; const FmFormPage* pPage = static_cast< const FmFormPage* >(rModel.GetPage(0));
aVDev.SetOutputSizePixel( Size( S_THUMB*2, S_THUMB*2 ) ); if(pPage)
bRet = DrawCentered( &aVDev, rModel );
if( bRet )
{ {
aThumbBmp = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() ); const Rectangle aObjRect(pPage->GetAllObjBoundRect());
Size aMS( 2, 2 );
BmpFilterParam aParam( aMS );
aThumbBmp.Filter( BMP_FILTER_MOSAIC, &aParam );
aThumbBmp.Scale( Size( S_THUMB, S_THUMB ) );
aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS ); if(aObjRect.GetWidth() && aObjRect.GetHeight())
} {
} VirtualDevice aVDev;
FmFormView aView(const_cast< FmFormModel* >(&rModel), &aVDev);
return bRet;
}
// ------------------------------------------------------------------------ aView.ShowSdrPage(const_cast< FmFormPage* >(pPage));
aView.MarkAllObj();
aThumbBmp = aView.GetMarkedObjBitmapEx();
sal_Bool SgaObjectSvDraw::DrawCentered( OutputDevice* pOut, const FmFormModel& rModel ) const Size aDiscreteSize(aThumbBmp.GetSizePixel());
{
const FmFormPage* pPage = static_cast< const FmFormPage* >( rModel.GetPage( 0 ) );
sal_Bool bRet = sal_False;
if( pOut && pPage ) if(aDiscreteSize.Width() && aDiscreteSize.Height())
{ {
const Rectangle aObjRect( pPage->GetAllObjBoundRect() ); sal_uInt32 nTargetSizeX(S_THUMB);
const Size aOutSizePix( pOut->GetOutputSizePixel() ); sal_uInt32 nTargetSizeY(S_THUMB);
if( aObjRect.GetWidth() && aObjRect.GetHeight() && aOutSizePix.Width() > 2 && aOutSizePix.Height() > 2 ) if(aDiscreteSize.Width() > aDiscreteSize.Height())
{ {
FmFormView aView( const_cast< FmFormModel* >( &rModel ), pOut ); nTargetSizeY = (aDiscreteSize.Height() * nTargetSizeX) / aDiscreteSize.Width();
MapMode aMap( rModel.GetScaleUnit() ); }
Rectangle aDrawRectPix( Point( 1, 1 ), Size( aOutSizePix.Width() - 2, aOutSizePix.Height() - 2 ) ); else
const double fFactor = (double) aObjRect.GetWidth() / aObjRect.GetHeight(); {
Fraction aFrac( FRound( fFactor < 1. ? aDrawRectPix.GetWidth() * fFactor : aDrawRectPix.GetWidth() ), nTargetSizeX = (aDiscreteSize.Width() * nTargetSizeY) / aDiscreteSize.Height();
pOut->LogicToPixel( aObjRect.GetSize(), aMap ).Width() ); }
aMap.SetScaleX( aFrac );
aMap.SetScaleY( aFrac );
const Size aDrawSize( pOut->PixelToLogic( aDrawRectPix.GetSize(), aMap ) );
Point aOrigin( pOut->PixelToLogic( aDrawRectPix.TopLeft(), aMap ) );
aOrigin.X() += ( ( aDrawSize.Width() - aObjRect.GetWidth() ) >> 1 ) - aObjRect.Left();
aOrigin.Y() += ( ( aDrawSize.Height() - aObjRect.GetHeight() ) >> 1 ) - aObjRect.Top();
aMap.SetOrigin( aOrigin );
aView.SetPageVisible( sal_False );
aView.SetBordVisible( sal_False );
aView.SetGridVisible( sal_False );
aView.SetHlplVisible( sal_False );
aView.SetGlueVisible( sal_False );
pOut->Push();
pOut->SetMapMode( aMap );
aView.ShowSdrPage( const_cast< FmFormPage* >( pPage ));
aView.CompleteRedraw( pOut,
Region(Rectangle(pOut->PixelToLogic(Point()),
pOut->GetOutputSize())));
pOut->Pop();
bRet = sal_True; if(!!aThumbBmp)
{
aThumbBmp.Scale(Size(nTargetSizeX, nTargetSizeY), BMP_SCALE_BESTQUALITY);
aThumbBmp.Convert(BMP_CONVERSION_8BIT_COLORS);
bRet = true;
}
}
}
} }
} }
......
...@@ -769,7 +769,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, sa ...@@ -769,7 +769,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, sa
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
sal_Bool GalleryTheme::GetThumb( sal_uIntPtr nPos, Bitmap& rBmp, sal_Bool ) sal_Bool GalleryTheme::GetThumb( sal_uIntPtr nPos, BitmapEx& rBmp, sal_Bool )
{ {
SgaObject* pObj = AcquireObject( nPos ); SgaObject* pObj = AcquireObject( nPos );
sal_Bool bRet = sal_False; sal_Bool bRet = sal_False;
...@@ -841,9 +841,10 @@ sal_Bool GalleryTheme::GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, sal_Bool ...@@ -841,9 +841,10 @@ sal_Bool GalleryTheme::GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, sal_Bool
if( pObj ) if( pObj )
{ {
Bitmap aBmp( pObj->GetThumbBmp() ); rGraphic = pObj->GetThumbBmp();
aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE ); //Bitmap aBmp( pObj->GetThumbBmp() );
rGraphic = aBmp; //aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
//rGraphic = aBmp;
ReleaseObject( pObj ); ReleaseObject( pObj );
bRet = sal_True; bRet = sal_True;
} }
......
...@@ -93,21 +93,18 @@ FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, Window* pParent ...@@ -93,21 +93,18 @@ FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, Window* pParent
maCtlFavorites.SetLineCount( nLineCount ); maCtlFavorites.SetLineCount( nLineCount );
maCtlFavorites.SetExtraSpacing( 3 ); maCtlFavorites.SetExtraSpacing( 3 );
initfavorites( GALLERY_THEME_FONTWORK, maFavoritesHorizontal ); initFavorites( GALLERY_THEME_FONTWORK );
fillFavorites( GALLERY_THEME_FONTWORK, maFavoritesHorizontal ); fillFavorites( GALLERY_THEME_FONTWORK );
} }
static void delete_bitmap( Bitmap* p ) { delete p; }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
FontWorkGalleryDialog::~FontWorkGalleryDialog() FontWorkGalleryDialog::~FontWorkGalleryDialog()
{ {
std::for_each( maFavoritesHorizontal.begin(), maFavoritesHorizontal.end(), delete_bitmap );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void FontWorkGalleryDialog::initfavorites(sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites) void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
{ {
// Ueber die Gallery werden die Favoriten eingelesen // Ueber die Gallery werden die Favoriten eingelesen
sal_uIntPtr nFavCount = GalleryExplorer::GetSdrObjCount( nThemeId ); sal_uIntPtr nFavCount = GalleryExplorer::GetSdrObjCount( nThemeId );
...@@ -119,20 +116,32 @@ void FontWorkGalleryDialog::initfavorites(sal_uInt16 nThemeId, std::vector< Bitm ...@@ -119,20 +116,32 @@ void FontWorkGalleryDialog::initfavorites(sal_uInt16 nThemeId, std::vector< Bitm
FmFormModel *pModel = NULL; FmFormModel *pModel = NULL;
for( nModelPos = 0; nModelPos < nFavCount; nModelPos++ ) for( nModelPos = 0; nModelPos < nFavCount; nModelPos++ )
{ {
Bitmap* pThumb = new Bitmap; BitmapEx aThumb;
GalleryExplorer::GetSdrObj(nThemeId, nModelPos, pModel, &aThumb);
if( GalleryExplorer::GetSdrObj( nThemeId, nModelPos, pModel, pThumb ) ) if(!!aThumb)
{ {
static const sal_uInt32 nLen(8);
static const Color aW(COL_WHITE);
static const Color aG(0xef, 0xef, 0xef);
VirtualDevice aVDev;
const Point aNull(0, 0);
const Size aSize(aThumb.GetSizePixel());
aVDev.SetOutputSizePixel(aSize);
aVDev.DrawCheckered(aNull, aSize, nLen, aW, aG);
aVDev.DrawBitmapEx(aNull, aThumb);
maFavoritesHorizontal.push_back(aVDev.GetBitmap(aNull, aSize));
} }
rFavorites.push_back( pThumb );
} }
// Gallery thema freigeben // Gallery thema freigeben
GalleryExplorer::EndLocking(nThemeId); GalleryExplorer::EndLocking(nThemeId);
} }
void FontWorkGalleryDialog::fillFavorites( sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites ) void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
{ {
mnThemeId = nThemeId; mnThemeId = nThemeId;
...@@ -142,7 +151,7 @@ void FontWorkGalleryDialog::fillFavorites( sal_uInt16 nThemeId, std::vector< Bit ...@@ -142,7 +151,7 @@ void FontWorkGalleryDialog::fillFavorites( sal_uInt16 nThemeId, std::vector< Bit
aThumbSize.Width() -= 12; aThumbSize.Width() -= 12;
aThumbSize.Height() -= 12; aThumbSize.Height() -= 12;
std::vector< Bitmap * >::size_type nFavCount = rFavorites.size(); std::vector< Bitmap * >::size_type nFavCount = maFavoritesHorizontal.size();
// ValueSet Favoriten // ValueSet Favoriten
if( nFavCount > (nColCount * nLineCount) ) if( nFavCount > (nColCount * nLineCount) )
...@@ -160,7 +169,7 @@ void FontWorkGalleryDialog::fillFavorites( sal_uInt16 nThemeId, std::vector< Bit ...@@ -160,7 +169,7 @@ void FontWorkGalleryDialog::fillFavorites( sal_uInt16 nThemeId, std::vector< Bit
String aStr(SVX_RES(RID_SVXFLOAT3D_FAVORITE)); String aStr(SVX_RES(RID_SVXFLOAT3D_FAVORITE));
aStr += sal_Unicode(' '); aStr += sal_Unicode(' ');
aStr += OUString::number((sal_Int32)nFavorite); aStr += OUString::number((sal_Int32)nFavorite);
Image aThumbImage( *rFavorites[nFavorite-1] ); Image aThumbImage( maFavoritesHorizontal[nFavorite-1] );
maCtlFavorites.InsertItem( (sal_uInt16)nFavorite, aThumbImage, aStr ); maCtlFavorites.InsertItem( (sal_uInt16)nFavorite, aThumbImage, aStr );
} }
} }
......
...@@ -1205,4 +1205,30 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, ...@@ -1205,4 +1205,30 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
return bDrawn; return bDrawn;
} }
// -----------------------------------------------------------------------
void OutputDevice::DrawCheckered(const Point& rPos, const Size& rSize, sal_uInt32 nLen, Color aStart, Color aEnd)
{
const sal_uInt32 nMaxX(rPos.X() + rSize.Width());
const sal_uInt32 nMaxY(rPos.Y() + rSize.Height());
Push();
SetLineColor();
for(sal_uInt32 x(0), nX(rPos.X()); nX < nMaxX; x++, nX += nLen)
{
const sal_uInt32 nRight(std::min(nMaxX, nX + nLen));
for(sal_uInt32 y(0), nY(rPos.Y()); nY < nMaxY; y++, nY += nLen)
{
const sal_uInt32 nBottom(std::min(nMaxY, nY + nLen));
SetFillColor((x & 0x0001) ^ (y & 0x0001) ? aStart : aEnd);
DrawRect(Rectangle(nX, nY, nRight, nBottom));
}
}
Pop();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment