Kaydet (Commit) 83c00b33 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:mergerclass merge FillAttrLB with SvxFillAttrBox

Change-Id: I5dfa7689eb219548bde7ce181a0a453c84b0f066
Reviewed-on: https://gerrit.libreoffice.org/43136Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst b93ae66b
...@@ -31,7 +31,6 @@ merge EscherPersistTable with EscherEx ...@@ -31,7 +31,6 @@ merge EscherPersistTable with EscherEx
merge ExcBoolRecord with Exc1904 merge ExcBoolRecord with Exc1904
merge ExportTyp with ExportBiff5 merge ExportTyp with ExportBiff5
merge FailTest with testMathMalformedXml merge FailTest with testMathMalformedXml
merge FillAttrLB with SvxFillAttrBox
merge FillTypeLB with SvxFillTypeBox merge FillTypeLB with SvxFillTypeBox
merge FmGridListener with FmXGridPeer::GridListenerDelegator merge FmGridListener with FmXGridPeer::GridListenerDelegator
merge FmXDisposeListener with DisposeListenerGridBridge merge FmXDisposeListener with DisposeListenerGridBridge
......
...@@ -229,22 +229,6 @@ public: ...@@ -229,22 +229,6 @@ public:
/************************************************************************/ /************************************************************************/
class SAL_WARN_UNUSED SVX_DLLPUBLIC FillAttrLB : public ListBox
{
private:
BitmapEx maBitmapEx;
public:
FillAttrLB( vcl::Window* pParent, WinBits aWB );
void Fill( const XHatchListRef &pList );
void Fill( const XGradientListRef &pList );
void Fill( const XBitmapListRef &pList );
void Fill( const XPatternListRef &pList );
};
/************************************************************************/
class SAL_WARN_UNUSED SVX_DLLPUBLIC FillTypeLB : public ListBox class SAL_WARN_UNUSED SVX_DLLPUBLIC FillTypeLB : public ListBox
{ {
......
...@@ -108,19 +108,22 @@ private: ...@@ -108,19 +108,22 @@ private:
static void ReleaseFocus_Impl(); static void ReleaseFocus_Impl();
}; };
// class SvxFillAttrBox -------------------------------------------------- class SVX_DLLPUBLIC SvxFillAttrBox : public ListBox
class SVX_DLLPUBLIC SvxFillAttrBox : public FillAttrLB
{ {
public: public:
SvxFillAttrBox( vcl::Window* pParent ); SvxFillAttrBox( vcl::Window* pParent );
void Fill( const XHatchListRef &pList );
void Fill( const XGradientListRef &pList );
void Fill( const XBitmapListRef &pList );
void Fill( const XPatternListRef &pList );
protected: protected:
virtual bool PreNotify( NotifyEvent& rNEvt ) override; virtual bool PreNotify( NotifyEvent& rNEvt ) override;
virtual bool EventNotify( NotifyEvent& rNEvt ) override; virtual bool EventNotify( NotifyEvent& rNEvt ) override;
private: private:
sal_uInt16 nCurPos; sal_uInt16 nCurPos;
BitmapEx maBitmapEx;
static void ReleaseFocus_Impl(); static void ReleaseFocus_Impl();
}; };
......
...@@ -1044,27 +1044,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeHatchingLB(VclPtr<vcl::Window> ...@@ -1044,27 +1044,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeHatchingLB(VclPtr<vcl::Window>
// Fills the listbox (provisional) with strings // Fills the listbox (provisional) with strings
void FillAttrLB::Fill( const XHatchListRef &pList )
{
long nCount = pList->Count();
ListBox::SetUpdateMode( false );
for( long i = 0; i < nCount; i++ )
{
const XHatchEntry* pEntry = pList->GetHatch(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap));
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode( true );
}
// Fills the listbox (provisional) with strings
GradientLB::GradientLB( vcl::Window* pParent, WinBits aWB) GradientLB::GradientLB( vcl::Window* pParent, WinBits aWB)
: ListBox( pParent, aWB ) : ListBox( pParent, aWB )
{ {
...@@ -1082,27 +1061,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeGradientLB(VclPtr<vcl::Window> ...@@ -1082,27 +1061,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeGradientLB(VclPtr<vcl::Window>
rRet = pListBox; rRet = pListBox;
} }
// Fills the listbox (provisional) with strings
void FillAttrLB::Fill( const XGradientListRef &pList )
{
long nCount = pList->Count();
ListBox::SetUpdateMode( false );
for( long i = 0; i < nCount; i++ )
{
const XGradientEntry* pEntry = pList->GetGradient(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap));
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode( true );
}
// BitmapLB Constructor // BitmapLB Constructor
BitmapLB::BitmapLB( vcl::Window* pParent, WinBits aWB) BitmapLB::BitmapLB( vcl::Window* pParent, WinBits aWB)
...@@ -1122,107 +1080,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeBitmapLB(VclPtr<vcl::Window> & ...@@ -1122,107 +1080,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeBitmapLB(VclPtr<vcl::Window> &
rRet = pListBox; rRet = pListBox;
} }
namespace
{
void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize)
{
if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0)
{
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);
}
}
} // end of anonymous namespace
FillAttrLB::FillAttrLB(vcl::Window* pParent, WinBits aWB)
: ListBox(pParent, aWB)
{
}
void FillAttrLB::Fill( const XBitmapListRef &pList )
{
const long nCount(pList->Count());
const XBitmapEntry* pEntry;
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
ListBox::SetUpdateMode(false);
for(long i(0); i < nCount; i++)
{
pEntry = pList->GetBitmap( i );
maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
formatBitmapExToSize(maBitmapEx, aSize);
ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx));
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode(true);
}
void FillAttrLB::Fill( const XPatternListRef &pList )
{
const long nCount(pList->Count());
const XBitmapEntry* pEntry;
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
ListBox::SetUpdateMode(false);
for(long i(0); i < nCount; i++)
{
pEntry = pList->GetBitmap( i );
maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
formatBitmapExToSize(maBitmapEx, aSize);
ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx));
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode(true);
}
void FillTypeLB::Fill() void FillTypeLB::Fill()
{ {
SetUpdateMode( false ); SetUpdateMode( false );
......
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::frame; using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans; using namespace ::com::sun::star::beans;
...@@ -461,7 +460,7 @@ void SvxFillTypeBox::ReleaseFocus_Impl() ...@@ -461,7 +460,7 @@ void SvxFillTypeBox::ReleaseFocus_Impl()
} }
SvxFillAttrBox::SvxFillAttrBox( vcl::Window* pParent ) : SvxFillAttrBox::SvxFillAttrBox( vcl::Window* pParent ) :
FillAttrLB( pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_TABSTOP ), ListBox(pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_TABSTOP),
nCurPos( 0 ) nCurPos( 0 )
{ {
SetPosPixel( Point( 90, 0 ) ); SetPosPixel( Point( 90, 0 ) );
...@@ -478,13 +477,13 @@ bool SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt ) ...@@ -478,13 +477,13 @@ bool SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt )
if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType || MouseNotifyEvent::GETFOCUS == nType ) if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType || MouseNotifyEvent::GETFOCUS == nType )
nCurPos = GetSelectedEntryPos(); nCurPos = GetSelectedEntryPos();
return FillAttrLB::PreNotify( rNEvt ); return ListBox::PreNotify( rNEvt );
} }
bool SvxFillAttrBox::EventNotify( NotifyEvent& rNEvt ) bool SvxFillAttrBox::EventNotify( NotifyEvent& rNEvt )
{ {
bool bHandled = FillAttrLB::EventNotify( rNEvt ); bool bHandled = ListBox::EventNotify( rNEvt );
if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
{ {
...@@ -521,4 +520,142 @@ void SvxFillAttrBox::ReleaseFocus_Impl() ...@@ -521,4 +520,142 @@ void SvxFillAttrBox::ReleaseFocus_Impl()
} }
} }
// Fills the listbox (provisional) with strings
void SvxFillAttrBox::Fill( const XHatchListRef &pList )
{
long nCount = pList->Count();
ListBox::SetUpdateMode( false );
for( long i = 0; i < nCount; i++ )
{
const XHatchEntry* pEntry = pList->GetHatch(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap));
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode( true );
}
// Fills the listbox (provisional) with strings
void SvxFillAttrBox::Fill( const XGradientListRef &pList )
{
long nCount = pList->Count();
ListBox::SetUpdateMode( false );
for( long i = 0; i < nCount; i++ )
{
const XGradientEntry* pEntry = pList->GetGradient(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap));
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode( true );
}
namespace
{
void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize)
{
if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0)
{
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);
}
}
} // end of anonymous namespace
void SvxFillAttrBox::Fill( const XBitmapListRef &pList )
{
const long nCount(pList->Count());
const XBitmapEntry* pEntry;
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
ListBox::SetUpdateMode(false);
for(long i(0); i < nCount; i++)
{
pEntry = pList->GetBitmap( i );
maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
formatBitmapExToSize(maBitmapEx, aSize);
ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx));
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode(true);
}
void SvxFillAttrBox::Fill( const XPatternListRef &pList )
{
const long nCount(pList->Count());
const XBitmapEntry* pEntry;
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
ListBox::SetUpdateMode(false);
for(long i(0); i < nCount; i++)
{
pEntry = pList->GetBitmap( i );
maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
formatBitmapExToSize(maBitmapEx, aSize);
ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx));
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode(true);
}
/* 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