Kaydet (Commit) 528391f3 authored tarafından Thorsten Behrens's avatar Thorsten Behrens Kaydeden (comit) Thorsten Behrens

Resuscitate old vcl unit tests.

Needs a deleted canvastools method, move code into more idiomatic
vcl/qa place, adapt to new unit test framework.

Change-Id: Iddb9c2249673b4d580e46a1d72029be0a8c4d9ba
üst 7727b9e8
...@@ -90,6 +90,14 @@ namespace vcl ...@@ -90,6 +90,14 @@ namespace vcl
// Color conversions (vcl/tools Color <-> canvas standard color space) // Color conversions (vcl/tools Color <-> canvas standard color space)
// =================================================================== // ===================================================================
/** Create a device-specific color sequence from VCL/Tools color
Note that this method assumes a color space equivalent to
the one returned from createStandardColorSpace()
*/
::com::sun::star::uno::Sequence< double >
VCL_DLLPUBLIC colorToStdColorSpaceSequence( const Color& rColor );
/** Convert color to device color sequence /** Convert color to device color sequence
@param rColor @param rColor
......
...@@ -9,7 +9,13 @@ ...@@ -9,7 +9,13 @@
$(eval $(call gb_CppunitTest_CppunitTest,vcl_complextext)) $(eval $(call gb_CppunitTest_CppunitTest,vcl_complextext))
$(eval $(call gb_CppunitTest_set_include,vcl_complextext,\
$$(INCLUDE) \
-I$(SRCDIR)/vcl/inc \
))
$(eval $(call gb_CppunitTest_add_exception_objects,vcl_complextext, \ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_complextext, \
vcl/qa/cppunit/canvasbitmaptest \
vcl/qa/cppunit/complextext \ vcl/qa/cppunit/complextext \
)) ))
......
...@@ -19,15 +19,8 @@ ...@@ -19,15 +19,8 @@
// bootstrap stuff // bootstrap stuff
#include <sal/main.h> #include <test/bootstrapfixture.hxx>
#include <rtl/bootstrap.hxx>
#include <rtl/ref.hxx>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/servicefactory.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/registry/XSimpleRegistry.hpp>
#include <com/sun/star/util/Endianness.hpp> #include <com/sun/star/util/Endianness.hpp>
#include <com/sun/star/rendering/ColorComponentTag.hpp> #include <com/sun/star/rendering/ColorComponentTag.hpp>
#include <com/sun/star/rendering/ColorSpaceType.hpp> #include <com/sun/star/rendering/ColorSpaceType.hpp>
...@@ -37,46 +30,23 @@ ...@@ -37,46 +30,23 @@
#include <com/sun/star/rendering/XBitmapPalette.hpp> #include <com/sun/star/rendering/XBitmapPalette.hpp>
#include <cppuhelper/compbase3.hxx> #include <cppuhelper/compbase3.hxx>
#include <tools/diagnose_ex.h> #include <tools/diagnose_ex.h>
#include <tools/extendapplicationenvironment.hxx> #include <rtl/ref.hxx>
#include "vcl/svapp.hxx" #include "vcl/svapp.hxx"
#include "vcl/canvastools.hxx" #include "vcl/canvastools.hxx"
#include "vcl/canvasbitmap.hxx"
#include "vcl/dialog.hxx" #include "vcl/dialog.hxx"
#include "vcl/outdev.hxx" #include "vcl/outdev.hxx"
#include "vcl/bmpacc.hxx" #include "vcl/bmpacc.hxx"
#include "vcl/virdev.hxx" #include "vcl/virdev.hxx"
#include "vcl/bitmapex.hxx" #include "vcl/bitmapex.hxx"
#include "canvasbitmap.hxx"
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::vcl::unotools; using namespace ::vcl::unotools;
void Main();
SAL_IMPLEMENT_MAIN()
{
tools::extendApplicationEnvironment();
uno::Reference< lang::XMultiServiceFactory > xMS;
xMS = cppu::createRegistryServiceFactory(
OUString( "applicat.rdb" ),
sal_True );
comphelper::setProcessServiceFactory( xMS );
InitVCL();
::Main();
DeInitVCL();
return 0;
}
namespace com { namespace sun { namespace star { namespace rendering namespace com { namespace sun { namespace star { namespace rendering
{ {
...@@ -95,45 +65,18 @@ bool operator==( const ARGBColor& rLHS, const RGBColor& rRHS ) ...@@ -95,45 +65,18 @@ bool operator==( const ARGBColor& rLHS, const RGBColor& rRHS )
namespace namespace
{ {
class TestApp : public Application class CanvasBitmapTest : public test::BootstrapFixture
{ {
public: public:
virtual void Main(); CanvasBitmapTest() : BootstrapFixture(true, false) {}
virtual sal_uInt16 Exception( sal_uInt16 nError );
};
class TestWindow : public Dialog void runTest();
{
public:
TestWindow() : Dialog( (Window *) NULL )
{
SetText( OUString("CanvasBitmap test harness") );
SetSizePixel( Size( 1024, 1024 ) );
EnablePaint( true );
Show();
}
virtual ~TestWindow() {} CPPUNIT_TEST_SUITE(CanvasBitmapTest);
virtual void Paint( const Rectangle& rRect ); CPPUNIT_TEST(runTest);
CPPUNIT_TEST_SUITE_END();
}; };
static bool g_failure=false;
void test( bool bResult, const char* msg )
{
if( bResult )
{
OSL_TRACE("Testing: %s - PASSED", msg);
}
else
{
g_failure = true;
OSL_TRACE("Testing: %s - FAILED", msg);
}
}
bool rangeCheck( const rendering::RGBColor& rColor ) bool rangeCheck( const rendering::RGBColor& rColor )
{ {
return rColor.Red < 0.0 || rColor.Red > 1.0 || return rColor.Red < 0.0 || rColor.Red > 1.0 ||
...@@ -141,7 +84,6 @@ bool rangeCheck( const rendering::RGBColor& rColor ) ...@@ -141,7 +84,6 @@ bool rangeCheck( const rendering::RGBColor& rColor )
rColor.Blue < 0.0 || rColor.Blue > 1.0; rColor.Blue < 0.0 || rColor.Blue > 1.0;
} }
void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp, void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
const char* msg, const char* msg,
int nOriginalDepth ) int nOriginalDepth )
...@@ -158,52 +100,52 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp, ...@@ -158,52 +100,52 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
nDepth = pAcc->GetBitCount(); nDepth = pAcc->GetBitCount();
} }
test( aContainedBmp.GetSizePixel() == Size(200,200), CPPUNIT_ASSERT_MESSAGE( "Original bitmap size not (200,200)",
"Original bitmap size" ); aContainedBmp.GetSizePixel() == Size(200,200));
test( xBmp->getSize().Width == 200 && xBmp->getSize().Height == 200, CPPUNIT_ASSERT_MESSAGE( "Original bitmap size via API not (200,200)",
"Original bitmap size via API" ); xBmp->getSize().Width == 200 && xBmp->getSize().Height == 200);
test( xBmp->hasAlpha() == aContainedBmpEx.IsTransparent(), CPPUNIT_ASSERT_MESSAGE( "alpha state mismatch",
"Correct alpha state" ); xBmp->hasAlpha() == aContainedBmpEx.IsTransparent());
test( xBmp->getScaledBitmap( geometry::RealSize2D(500,500), sal_False ).is(), CPPUNIT_ASSERT_MESSAGE( "getScaledBitmap() failed",
"getScaledBitmap()" ); xBmp->getScaledBitmap( geometry::RealSize2D(500,500), sal_False ).is());
rendering::IntegerBitmapLayout aLayout; rendering::IntegerBitmapLayout aLayout;
uno::Sequence<sal_Int8> aPixelData = xBmp->getData(aLayout, geometry::IntegerRectangle2D(0,0,1,1)); uno::Sequence<sal_Int8> aPixelData = xBmp->getData(aLayout, geometry::IntegerRectangle2D(0,0,1,1));
const sal_Int32 nExpectedBitsPerPixel( const sal_Int32 nExpectedBitsPerPixel(
aContainedBmpEx.IsTransparent() ? std::max(8,nDepth)+8 : nDepth); aContainedBmpEx.IsTransparent() ? std::max(8,nDepth)+8 : nDepth);
test( aLayout.ScanLines == 1, CPPUNIT_ASSERT_MESSAGE( "# scanlines not 1",
"# scanlines" ); aLayout.ScanLines == 1);
test( aLayout.ScanLineBytes == (nExpectedBitsPerPixel+7)/8, CPPUNIT_ASSERT_MESSAGE( "# scanline bytes mismatch",
"# scanline bytes" ); aLayout.ScanLineBytes == (nExpectedBitsPerPixel+7)/8);
test( aLayout.ScanLineStride == (nExpectedBitsPerPixel+7)/8 || CPPUNIT_ASSERT_MESSAGE( "# scanline stride mismatch",
aLayout.ScanLineStride == -(nExpectedBitsPerPixel+7)/8, aLayout.ScanLineStride == (nExpectedBitsPerPixel+7)/8 ||
"# scanline stride" ); aLayout.ScanLineStride == -(nExpectedBitsPerPixel+7)/8);
test( aLayout.PlaneStride == 0, CPPUNIT_ASSERT_MESSAGE( "# plane stride not 0",
"# plane stride" ); aLayout.PlaneStride == 0);
test( aLayout.ColorSpace.is(), CPPUNIT_ASSERT_MESSAGE( "Color space not there",
"Color space there" ); aLayout.ColorSpace.is());
test( aLayout.Palette.is() == (nDepth <= 8), CPPUNIT_ASSERT_MESSAGE( "Palette existance does not conform to bitmap",
"Palette existance conforms to bitmap" ); aLayout.Palette.is() == (nDepth <= 8));
uno::Sequence<sal_Int8> aPixelData2 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(0,0) ); uno::Sequence<sal_Int8> aPixelData2 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(0,0) );
test( aPixelData2.getLength() == aPixelData.getLength(), CPPUNIT_ASSERT_MESSAGE( "getData and getPixel did not return same amount of data",
"getData and getPixel return same amount of data" ); aPixelData2.getLength() == aPixelData.getLength());
aPixelData = xBmp->getData(aLayout, geometry::IntegerRectangle2D(0,0,200,1)); aPixelData = xBmp->getData(aLayout, geometry::IntegerRectangle2D(0,0,200,1));
test( aLayout.ScanLines == 1, CPPUNIT_ASSERT_MESSAGE( "# scanlines not 1 for getPixel",
"# scanlines" ); aLayout.ScanLines == 1);
test( aLayout.ScanLineBytes == (200*nExpectedBitsPerPixel+7)/8, CPPUNIT_ASSERT_MESSAGE( "# scanline bytes mismatch for getPixel",
"# scanline bytes" ); aLayout.ScanLineBytes == (200*nExpectedBitsPerPixel+7)/8);
test( aLayout.ScanLineStride == (200*nExpectedBitsPerPixel+7)/8 || CPPUNIT_ASSERT_MESSAGE( "# scanline stride mismatch for getPixel",
aLayout.ScanLineStride == -(200*nExpectedBitsPerPixel+7)/8, aLayout.ScanLineStride == (200*nExpectedBitsPerPixel+7)/8 ||
"# scanline stride" ); aLayout.ScanLineStride == -(200*nExpectedBitsPerPixel+7)/8);
uno::Sequence< rendering::RGBColor > aRGBColors = xBmp->convertIntegerToRGB( aPixelData ); uno::Sequence< rendering::RGBColor > aRGBColors = xBmp->convertIntegerToRGB( aPixelData );
uno::Sequence< rendering::ARGBColor > aARGBColors = xBmp->convertIntegerToARGB( aPixelData ); uno::Sequence< rendering::ARGBColor > aARGBColors = xBmp->convertIntegerToARGB( aPixelData );
...@@ -213,51 +155,53 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp, ...@@ -213,51 +155,53 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
const rendering::ARGBColor* pARGBStart( aARGBColors.getConstArray() ); const rendering::ARGBColor* pARGBStart( aARGBColors.getConstArray() );
std::pair<const rendering::RGBColor*, std::pair<const rendering::RGBColor*,
const rendering::ARGBColor*> aRes = std::mismatch( pRGBStart, pRGBEnd, pARGBStart ); const rendering::ARGBColor*> aRes = std::mismatch( pRGBStart, pRGBEnd, pARGBStart );
test( aRes.first == pRGBEnd, CPPUNIT_ASSERT_MESSAGE( "argb and rgb colors are not equal",
"argb and rgb colors are equal" ); aRes.first == pRGBEnd);
test( std::find_if(pRGBStart,pRGBEnd,&rangeCheck) == pRGBEnd, CPPUNIT_ASSERT_MESSAGE( "rgb colors are not within [0,1] range",
"rgb colors are within [0,1] range" ); std::find_if(pRGBStart,pRGBEnd,&rangeCheck) == pRGBEnd);
test( pRGBStart[0].Red == 1.0 && pRGBStart[0].Green == 1.0 && pRGBStart[0].Blue == 1.0, CPPUNIT_ASSERT_MESSAGE( "First pixel is not white",
"First pixel is white" ); pRGBStart[0].Red == 1.0 && pRGBStart[0].Green == 1.0 && pRGBStart[0].Blue == 1.0);
test( pARGBStart[1].Alpha == 1.0, CPPUNIT_ASSERT_MESSAGE( "Second pixel is not opaque",
"Second pixel is opaque" ); pARGBStart[1].Alpha == 1.0);
if( aContainedBmpEx.IsTransparent() ) if( aContainedBmpEx.IsTransparent() )
{ {
test( pARGBStart[0].Alpha == 0.0, CPPUNIT_ASSERT_MESSAGE( "First pixel is not fully transparent",
"First pixel is fully transparent" ); pARGBStart[0].Alpha == 0.0);
} }
test( pRGBStart[1].Red == 0.0 && pRGBStart[1].Green == 0.0 && pRGBStart[1].Blue == 0.0, CPPUNIT_ASSERT_MESSAGE( "Second pixel is not black",
"Second pixel is black" ); pRGBStart[1].Red == 0.0 && pRGBStart[1].Green == 0.0 && pRGBStart[1].Blue == 0.0);
if( nOriginalDepth > 8 ) if( nOriginalDepth > 8 )
{ {
const Color aCol(COL_GREEN); const Color aCol(COL_GREEN);
test( pRGBStart[5].Red == vcl::unotools::toDoubleColor(aCol.GetRed()) && CPPUNIT_ASSERT_MESSAGE( "Sixth pixel is not green",
pRGBStart[5].Green == vcl::unotools::toDoubleColor(aCol.GetGreen()) && pRGBStart[5].Red == vcl::unotools::toDoubleColor(aCol.GetRed()) &&
pRGBStart[5].Blue == vcl::unotools::toDoubleColor(aCol.GetBlue()), pRGBStart[5].Green == vcl::unotools::toDoubleColor(aCol.GetGreen()) &&
"Sixth pixel is green" ); pRGBStart[5].Blue == vcl::unotools::toDoubleColor(aCol.GetBlue()));
} }
else if( nDepth <= 8 ) else if( nDepth <= 8 )
{ {
uno::Reference<rendering::XBitmapPalette> xPal = xBmp->getPalette(); uno::Reference<rendering::XBitmapPalette> xPal = xBmp->getPalette();
test( xPal.is(), CPPUNIT_ASSERT_MESSAGE( "8bit or less: missing palette",
"8bit or less: needs palette" ); xPal.is());
test( xPal->getNumberOfEntries() == 1L << nOriginalDepth, CPPUNIT_ASSERT_MESSAGE( "Palette incorrect entry count",
"Palette has correct entry count" ); xPal->getNumberOfEntries() == 1L << nOriginalDepth);
uno::Sequence<double> aIndex; uno::Sequence<double> aIndex;
test( xPal->setIndex(aIndex,sal_True,0) == sal_False, CPPUNIT_ASSERT_MESSAGE( "Palette is not read-only",
"Palette is read-only" ); xPal->setIndex(aIndex,sal_True,0) == sal_False);
test( xPal->getIndex(aIndex,0), CPPUNIT_ASSERT_MESSAGE( "Palette entry 0 is not opaque",
"Palette entry 0 is opaque" ); xPal->getIndex(aIndex,0));
test( xPal->getColorSpace().is(), CPPUNIT_ASSERT_MESSAGE( "Palette has no valid color space",
"Palette has a valid color space" ); xPal->getColorSpace().is());
} }
test( pRGBStart[150].Red == 1.0 && pRGBStart[150].Green == 1.0 && pRGBStart[150].Blue == 1.0, CPPUNIT_ASSERT_MESSAGE( "150th pixel is not white",
"150th pixel is white" ); pRGBStart[150].Red == 1.0 &&
pRGBStart[150].Green == 1.0 &&
pRGBStart[150].Blue == 1.0);
if( nOriginalDepth > 8 ) if( nOriginalDepth > 8 )
{ {
...@@ -278,14 +222,14 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp, ...@@ -278,14 +222,14 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
aPixel3 = xBmp->convertIntegerFromARGB( aARGBColor ); aPixel3 = xBmp->convertIntegerFromARGB( aARGBColor );
aPixel4 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(5,0) ); aPixel4 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(5,0) );
test( aPixel3 == aPixel4, CPPUNIT_ASSERT_MESSAGE( "Green pixel from bitmap mismatch with manually converted green pixel",
"Green pixel from bitmap matches with manually converted green pixel" ); aPixel3 == aPixel4);
if( !aContainedBmpEx.IsTransparent() ) if( !aContainedBmpEx.IsTransparent() )
{ {
aPixel3 = xBmp->convertIntegerFromRGB( aRGBColor ); aPixel3 = xBmp->convertIntegerFromRGB( aRGBColor );
test( aPixel3 == aPixel4, CPPUNIT_ASSERT_MESSAGE( "Green pixel from bitmap mismatch with manually RGB-converted green pixel",
"Green pixel from bitmap matches with manually RGB-converted green pixel" ); aPixel3 == aPixel4);
} }
} }
} }
...@@ -312,10 +256,10 @@ private: ...@@ -312,10 +256,10 @@ private:
const geometry::IntegerRectangle2D& rect ) throw (lang::IndexOutOfBoundsException, const geometry::IntegerRectangle2D& rect ) throw (lang::IndexOutOfBoundsException,
rendering::VolatileContentDestroyedException, uno::RuntimeException) rendering::VolatileContentDestroyedException, uno::RuntimeException)
{ {
test( rect.X1 >= 0, "X1 within bounds" ); CPPUNIT_ASSERT_MESSAGE( "X1 out of bounds", rect.X1 >= 0 );
test( rect.Y1 >= 0, "Y1 within bounds" ); CPPUNIT_ASSERT_MESSAGE( "Y1 out of bounds", rect.Y1 >= 0 );
test( rect.X2 <= maSize.Width, "X2 within bounds" ); CPPUNIT_ASSERT_MESSAGE( "X2 out of bounds", rect.X2 <= maSize.Width );
test( rect.Y2 <= maSize.Height, "Y2 within bounds" ); CPPUNIT_ASSERT_MESSAGE( "Y2 out of bounds", rect.Y2 <= maSize.Height );
bitmapLayout = getMemoryLayout(); bitmapLayout = getMemoryLayout();
...@@ -358,7 +302,7 @@ private: ...@@ -358,7 +302,7 @@ private:
const geometry::IntegerPoint2D& ) throw (lang::IndexOutOfBoundsException, const geometry::IntegerPoint2D& ) throw (lang::IndexOutOfBoundsException,
rendering::VolatileContentDestroyedException, uno::RuntimeException) rendering::VolatileContentDestroyedException, uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("getPixel: method not implemented", false);
return uno::Sequence< sal_Int8 >(); return uno::Sequence< sal_Int8 >();
} }
...@@ -388,8 +332,8 @@ private: ...@@ -388,8 +332,8 @@ private:
// XBitmapPalette // XBitmapPalette
virtual sal_Int32 SAL_CALL getNumberOfEntries() throw (uno::RuntimeException) virtual sal_Int32 SAL_CALL getNumberOfEntries() throw (uno::RuntimeException)
{ {
test( getPalette().is(), CPPUNIT_ASSERT_MESSAGE( "Got palette getNumberOfEntries interface call without handing out palette",
"Got palette interface call without handing out palette?!" ); getPalette().is() );
return 255; return 255;
} }
...@@ -398,14 +342,14 @@ private: ...@@ -398,14 +342,14 @@ private:
::sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, ::sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException,
uno::RuntimeException) uno::RuntimeException)
{ {
test( getPalette().is(), CPPUNIT_ASSERT_MESSAGE( "Got palette getIndex interface call without handing out palette",
"Got palette interface call without handing out palette?!" ); getPalette().is() );
test( nIndex >= 0 && nIndex < 256, CPPUNIT_ASSERT_MESSAGE( "getIndex: index out of range",
"Index out of range" ); nIndex >= 0 && nIndex < 256 );
entry = colorToStdColorSpaceSequence( entry = colorToStdColorSpaceSequence(
Color(UINT8(nIndex), Color(sal_uInt8(nIndex),
UINT8(nIndex), sal_uInt8(nIndex),
UINT8(nIndex)) ); sal_uInt8(nIndex)) );
return sal_True; // no palette transparency here. return sal_True; // no palette transparency here.
} }
...@@ -416,10 +360,10 @@ private: ...@@ -416,10 +360,10 @@ private:
lang::IllegalArgumentException, lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test( getPalette().is(), CPPUNIT_ASSERT_MESSAGE( "Got palette setIndex interface call without handing out palette",
"Got palette interface call without handing out palette?!" ); getPalette().is());
test( nIndex >= 0 && nIndex < 256, CPPUNIT_ASSERT_MESSAGE( "setIndex: index out of range",
"Index out of range" ); nIndex >= 0 && nIndex < 256);
return sal_False; return sal_False;
} }
...@@ -457,56 +401,56 @@ private: ...@@ -457,56 +401,56 @@ private:
virtual uno::Sequence< beans::PropertyValue > SAL_CALL getProperties( ) throw (uno::RuntimeException) virtual uno::Sequence< beans::PropertyValue > SAL_CALL getProperties( ) throw (uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("getProperties: method not implemented", false );
return uno::Sequence< ::beans::PropertyValue >(); return uno::Sequence< ::beans::PropertyValue >();
} }
virtual uno::Sequence< double > SAL_CALL convertColorSpace( const uno::Sequence< double >&, virtual uno::Sequence< double > SAL_CALL convertColorSpace( const uno::Sequence< double >&,
const uno::Reference< rendering::XColorSpace >& ) throw (uno::RuntimeException) const uno::Reference< rendering::XColorSpace >& ) throw (uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertColorSpace: method not implemented", false);
return uno::Sequence< double >(); return uno::Sequence< double >();
} }
virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertToRGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException, virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertToRGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertToRGB: method not implemented", false);
return uno::Sequence< rendering::RGBColor >(); return uno::Sequence< rendering::RGBColor >();
} }
virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToARGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException, virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToARGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertToARGB: method not implemented", false);
return uno::Sequence< rendering::ARGBColor >(); return uno::Sequence< rendering::ARGBColor >();
} }
virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException, virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertToPARGB: method not implemented", false);
return uno::Sequence< rendering::ARGBColor >(); return uno::Sequence< rendering::ARGBColor >();
} }
virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& ) throw (lang::IllegalArgumentException, virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertFromRGB: method not implemented", false);
return uno::Sequence< double >(); return uno::Sequence< double >();
} }
virtual uno::Sequence< double > SAL_CALL convertFromARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException, virtual uno::Sequence< double > SAL_CALL convertFromARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "This method is not expected to be called!"); CPPUNIT_ASSERT_MESSAGE("convertFromARGB: this method is not expected to be called!", false);
return uno::Sequence< double >(); return uno::Sequence< double >();
} }
virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException, virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "This method is not expected to be called!"); CPPUNIT_ASSERT_MESSAGE("convertFromPARGB: this method is not expected to be called!", false);
return uno::Sequence< double >(); return uno::Sequence< double >();
} }
...@@ -529,7 +473,7 @@ private: ...@@ -529,7 +473,7 @@ private:
const uno::Reference< rendering::XColorSpace >& ) throw (lang::IllegalArgumentException, const uno::Reference< rendering::XColorSpace >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertFromIntegerColorSpace: method not implemented", false);
return uno::Sequence< double >(); return uno::Sequence< double >();
} }
...@@ -537,7 +481,7 @@ private: ...@@ -537,7 +481,7 @@ private:
const uno::Reference< rendering::XIntegerBitmapColorSpace >& ) throw (lang::IllegalArgumentException, const uno::Reference< rendering::XIntegerBitmapColorSpace >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertToIntegerColorSpace: method not implemented", false);
return uno::Sequence< sal_Int8 >(); return uno::Sequence< sal_Int8 >();
} }
...@@ -563,8 +507,8 @@ private: ...@@ -563,8 +507,8 @@ private:
{ {
const sal_Size nLen( deviceColor.getLength() ); const sal_Size nLen( deviceColor.getLength() );
const sal_Int32 nBytesPerPixel(mnBitsPerPixel == 8 ? 1 : 4); const sal_Int32 nBytesPerPixel(mnBitsPerPixel == 8 ? 1 : 4);
test(nLen%nBytesPerPixel==0, CPPUNIT_ASSERT_MESSAGE("number of channels no multiple of pixel element count",
"number of channels no multiple of pixel element count"); nLen%nBytesPerPixel==0);
uno::Sequence< rendering::ARGBColor > aRes( nLen / nBytesPerPixel ); uno::Sequence< rendering::ARGBColor > aRes( nLen / nBytesPerPixel );
rendering::ARGBColor* pOut( aRes.getArray() ); rendering::ARGBColor* pOut( aRes.getArray() );
...@@ -600,8 +544,8 @@ private: ...@@ -600,8 +544,8 @@ private:
{ {
const sal_Size nLen( deviceColor.getLength() ); const sal_Size nLen( deviceColor.getLength() );
const sal_Int32 nBytesPerPixel(mnBitsPerPixel == 8 ? 1 : 4); const sal_Int32 nBytesPerPixel(mnBitsPerPixel == 8 ? 1 : 4);
test(nLen%nBytesPerPixel==0, CPPUNIT_ASSERT_MESSAGE("number of channels no multiple of pixel element count",
"number of channels no multiple of pixel element count"); nLen%nBytesPerPixel==0);
uno::Sequence< rendering::ARGBColor > aRes( nLen / nBytesPerPixel ); uno::Sequence< rendering::ARGBColor > aRes( nLen / nBytesPerPixel );
rendering::ARGBColor* pOut( aRes.getArray() ); rendering::ARGBColor* pOut( aRes.getArray() );
...@@ -636,21 +580,21 @@ private: ...@@ -636,21 +580,21 @@ private:
virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& ) throw (lang::IllegalArgumentException, virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertIntegerFromRGB: method not implemented", false);
return uno::Sequence< sal_Int8 >(); return uno::Sequence< sal_Int8 >();
} }
virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException, virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertIntegerFromARGB: method not implemented", false);
return uno::Sequence< sal_Int8 >(); return uno::Sequence< sal_Int8 >();
} }
virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException, virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException) uno::RuntimeException)
{ {
test(false, "Method not implemented"); CPPUNIT_ASSERT_MESSAGE("convertIntegerFromPARGB: method not implemented", false);
return uno::Sequence< sal_Int8 >(); return uno::Sequence< sal_Int8 >();
} }
...@@ -699,174 +643,152 @@ public: ...@@ -699,174 +643,152 @@ public:
void TestWindow::Paint( const Rectangle& ) void CanvasBitmapTest::runTest()
{ {
static const sal_Int8 lcl_depths[]={1,4,8,16,24}; static const sal_Int8 lcl_depths[]={1,4,8,16,24};
try // Testing VclCanvasBitmap wrapper
{ // ===============================
// Testing VclCanvasBitmap wrapper
// ===============================
for( unsigned int i=0; i<SAL_N_ELEMENTS(lcl_depths); ++i ) for( unsigned int i=0; i<SAL_N_ELEMENTS(lcl_depths); ++i )
{
const sal_Int8 nDepth( lcl_depths[i] );
Bitmap aBitmap(Size(200,200),nDepth);
aBitmap.Erase(COL_WHITE);
{ {
const sal_Int8 nDepth( lcl_depths[i] ); Bitmap::ScopedWriteAccess pAcc(aBitmap);
Bitmap aBitmap(Size(200,200),nDepth); if( pAcc.get() )
aBitmap.Erase(COL_WHITE);
{ {
Bitmap::ScopedWriteAccess pAcc(aBitmap); BitmapColor aBlack(0);
if( pAcc.get() ) BitmapColor aWhite(0);
if( pAcc->HasPalette() )
{
aBlack.SetIndex( sal::static_int_cast<sal_Int8>(pAcc->GetBestPaletteIndex(BitmapColor(0,0,0))) );
aWhite.SetIndex( sal::static_int_cast<sal_Int8>(pAcc->GetBestPaletteIndex(BitmapColor(255,255,255))) );
}
else
{ {
BitmapColor aBlack(0); aBlack = Color(COL_BLACK);
BitmapColor aWhite(0); aWhite = Color(COL_WHITE);
if( pAcc->HasPalette() )
{
aBlack.SetIndex( sal::static_int_cast<BYTE>(pAcc->GetBestPaletteIndex(BitmapColor(0,0,0))) );
aWhite.SetIndex( sal::static_int_cast<BYTE>(pAcc->GetBestPaletteIndex(BitmapColor(255,255,255))) );
}
else
{
aBlack = Color(COL_BLACK);
aWhite = Color(COL_WHITE);
}
pAcc->SetFillColor(COL_GREEN);
pAcc->FillRect(Rectangle(0,0,100,100));
pAcc->SetPixel(0,0,aWhite);
pAcc->SetPixel(0,1,aBlack);
pAcc->SetPixel(0,2,aWhite);
} }
pAcc->SetFillColor(COL_GREEN);
pAcc->FillRect(Rectangle(0,0,100,100));
pAcc->SetPixel(0,0,aWhite);
pAcc->SetPixel(0,1,aBlack);
pAcc->SetPixel(0,2,aWhite);
} }
}
rtl::Reference<VclCanvasBitmap> xBmp( new VclCanvasBitmap(aBitmap) ); rtl::Reference<VclCanvasBitmap> xBmp( new VclCanvasBitmap(aBitmap) );
checkCanvasBitmap( xBmp, "single bitmap", nDepth ); checkCanvasBitmap( xBmp, "single bitmap", nDepth );
Bitmap aMask(Size(200,200),1); Bitmap aMask(Size(200,200),1);
aMask.Erase(COL_WHITE); aMask.Erase(COL_WHITE);
{
Bitmap::ScopedWriteAccess pAcc(aMask);
if( pAcc.get() )
{ {
Bitmap::ScopedWriteAccess pAcc(aMask); pAcc->SetFillColor(COL_BLACK);
if( pAcc.get() ) pAcc->FillRect(Rectangle(0,0,100,100));
{ pAcc->SetPixel(0,0,BitmapColor(1));
pAcc->SetFillColor(COL_BLACK); pAcc->SetPixel(0,1,BitmapColor(0));
pAcc->FillRect(Rectangle(0,0,100,100)); pAcc->SetPixel(0,2,BitmapColor(1));
pAcc->SetPixel(0,0,BitmapColor(1));
pAcc->SetPixel(0,1,BitmapColor(0));
pAcc->SetPixel(0,2,BitmapColor(1));
}
} }
}
xBmp.set( new VclCanvasBitmap(BitmapEx(aBitmap,aMask)) ); xBmp.set( new VclCanvasBitmap(BitmapEx(aBitmap,aMask)) );
checkCanvasBitmap( xBmp, "masked bitmap", nDepth ); checkCanvasBitmap( xBmp, "masked bitmap", nDepth );
AlphaMask aAlpha(Size(200,200)); AlphaMask aAlpha(Size(200,200));
aAlpha.Erase(255); aAlpha.Erase(255);
{
BitmapWriteAccess* pAcc = aAlpha.AcquireWriteAccess();
if( pAcc )
{ {
BitmapWriteAccess* pAcc = aAlpha.AcquireWriteAccess(); pAcc->SetFillColor(COL_BLACK);
if( pAcc ) pAcc->FillRect(Rectangle(0,0,100,100));
{ pAcc->SetPixel(0,0,BitmapColor(255));
pAcc->SetFillColor(COL_BLACK); pAcc->SetPixel(0,1,BitmapColor(0));
pAcc->FillRect(Rectangle(0,0,100,100)); pAcc->SetPixel(0,2,BitmapColor(255));
pAcc->SetPixel(0,0,BitmapColor(255)); aAlpha.ReleaseAccess(pAcc);
pAcc->SetPixel(0,1,BitmapColor(0));
pAcc->SetPixel(0,2,BitmapColor(255));
aAlpha.ReleaseAccess(pAcc);
}
} }
}
xBmp.set( new VclCanvasBitmap(BitmapEx(aBitmap,aAlpha)) ); xBmp.set( new VclCanvasBitmap(BitmapEx(aBitmap,aAlpha)) );
checkCanvasBitmap( xBmp, "alpha bitmap", nDepth ); checkCanvasBitmap( xBmp, "alpha bitmap", nDepth );
} }
// Testing XBitmap import // Testing XBitmap import
// ====================== // ======================
uno::Reference< rendering::XIntegerReadOnlyBitmap > xTestBmp( uno::Reference< rendering::XIntegerReadOnlyBitmap > xTestBmp(
new TestBitmap( geometry::IntegerSize2D(10,10), true )); new TestBitmap( geometry::IntegerSize2D(10,10), true ));
BitmapEx aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp);
test( aBmp.IsTransparent() == false,
"Palette bitmap is not transparent" );
test( aBmp.GetSizePixel() == Size(10,10),
"Bitmap has size (10,10)" );
test( aBmp.GetBitCount() == 8,
"Bitmap has bitcount of 8" );
{
BitmapReadAccess* pBmpAcc = aBmp.GetBitmap().AcquireReadAccess();
test( pBmpAcc, BitmapEx aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp);
"Bitmap has valid BitmapReadAccess" ); CPPUNIT_ASSERT_MESSAGE( "Palette bitmap is transparent",
aBmp.IsTransparent() == false);
CPPUNIT_ASSERT_MESSAGE( "Bitmap does not have size (10,10)",
aBmp.GetSizePixel() == Size(10,10));
CPPUNIT_ASSERT_MESSAGE( "Bitmap does not have bitcount of 8",
aBmp.GetBitCount() == 8);
{
BitmapReadAccess* pBmpAcc = aBmp.GetBitmap().AcquireReadAccess();
test(pBmpAcc->GetPixel(0,0) == BitmapColor(0), CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid BitmapReadAccess",
"(0,0) correct content"); pBmpAcc );
test(pBmpAcc->GetPixel(2,2) == BitmapColor(2),
"(2,2) correct content");
test(pBmpAcc->GetPixel(2,9) == BitmapColor(9),
"(9,2) correct content");
aBmp.GetBitmap().ReleaseAccess(pBmpAcc); CPPUNIT_ASSERT_MESSAGE("(0,0) incorrect content",
} pBmpAcc->GetPixel(0,0) == BitmapColor(0));
CPPUNIT_ASSERT_MESSAGE("(2,2) incorrect content",
pBmpAcc->GetPixel(2,2) == BitmapColor(2));
CPPUNIT_ASSERT_MESSAGE("(9,2) incorrect content",
pBmpAcc->GetPixel(2,9) == BitmapColor(9));
xTestBmp.set( new TestBitmap( geometry::IntegerSize2D(10,10), false )); aBmp.GetBitmap().ReleaseAccess(pBmpAcc);
aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp);
test( aBmp.IsTransparent() == TRUE,
"Palette bitmap is transparent" );
test( aBmp.IsAlpha() == TRUE,
"Palette bitmap has alpha" );
test( aBmp.GetSizePixel() == Size(10,10),
"Bitmap has size (10,10)" );
test( aBmp.GetBitCount() == 24,
"Bitmap has bitcount of 24" );
{
BitmapReadAccess* pBmpAcc = aBmp.GetBitmap().AcquireReadAccess();
BitmapReadAccess* pAlphaAcc = aBmp.GetAlpha().AcquireReadAccess();
test( pBmpAcc,
"Bitmap has valid BitmapReadAccess" );
test( pAlphaAcc,
"Bitmap has valid alpha BitmapReadAccess" );
test(pBmpAcc->GetPixel(0,0) == BitmapColor(0,1,0),
"(0,0) correct content");
test(pAlphaAcc->GetPixel(0,0) == BitmapColor(255),
"(0,0) correct alpha content");
test(pBmpAcc->GetPixel(2,2) == BitmapColor(0,3,2),
"(2,2) correct content");
test(pAlphaAcc->GetPixel(2,2) == BitmapColor(253),
"(2,2) correct alpha content");
test(pBmpAcc->GetPixel(2,9) == BitmapColor(0,3,9),
"(9,2) correct content");
test(pAlphaAcc->GetPixel(2,9) == BitmapColor(253),
"(9,2) correct alpha content");
aBmp.GetAlpha().ReleaseAccess(pAlphaAcc);
aBmp.GetBitmap().ReleaseAccess(pBmpAcc);
}
} }
catch( uno::Exception& )
{ xTestBmp.set( new TestBitmap( geometry::IntegerSize2D(10,10), false ));
DBG_UNHANDLED_EXCEPTION();
exit(2); aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp);
} CPPUNIT_ASSERT_MESSAGE( "Palette bitmap is not transparent",
catch( std::exception& ) aBmp.IsTransparent() == true);
CPPUNIT_ASSERT_MESSAGE( "Palette bitmap has no alpha",
aBmp.IsAlpha() == true);
CPPUNIT_ASSERT_MESSAGE( "Bitmap does not have size (10,10)",
aBmp.GetSizePixel() == Size(10,10));
CPPUNIT_ASSERT_MESSAGE( "Bitmap has bitcount of 24",
aBmp.GetBitCount() == 24);
{ {
OSL_TRACE( "Caught std exception!" ); BitmapReadAccess* pBmpAcc = aBmp.GetBitmap().AcquireReadAccess();
} BitmapReadAccess* pAlphaAcc = aBmp.GetAlpha().AcquireReadAccess();
CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid BitmapReadAccess",
pBmpAcc);
CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid alpha BitmapReadAccess",
pAlphaAcc);
if( g_failure ) CPPUNIT_ASSERT_MESSAGE("(0,0) incorrect content",
exit(2); pBmpAcc->GetPixel(0,0) == BitmapColor(0,1,0));
CPPUNIT_ASSERT_MESSAGE("(0,0) incorrect alpha content",
pAlphaAcc->GetPixel(0,0) == BitmapColor(255));
CPPUNIT_ASSERT_MESSAGE("(2,2) incorrect content",
pBmpAcc->GetPixel(2,2) == BitmapColor(0,3,2));
CPPUNIT_ASSERT_MESSAGE("(2,2) incorrect alpha content",
pAlphaAcc->GetPixel(2,2) == BitmapColor(253));
CPPUNIT_ASSERT_MESSAGE("(9,2) incorrect content",
pBmpAcc->GetPixel(2,9) == BitmapColor(0,3,9));
CPPUNIT_ASSERT_MESSAGE("(9,2) correct alpha content",
pAlphaAcc->GetPixel(2,9) == BitmapColor(253));
aBmp.GetAlpha().ReleaseAccess(pAlphaAcc);
aBmp.GetBitmap().ReleaseAccess(pBmpAcc);
}
} }
} // namespace } // namespace
void Main() CPPUNIT_TEST_SUITE_REGISTRATION(CanvasBitmapTest);
{
TestWindow aWindow;
aWindow.Execute();
aWindow.SetText( OUString( "VCL - canvasbitmaptest" ) );
Application::Execute();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -17,15 +17,18 @@ ...@@ -17,15 +17,18 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <unotest/filters-test.hxx>
#include <test/bootstrapfixture.hxx>
#include <vcl/event.hxx> #include <vcl/event.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx> #include <vcl/wrkwin.hxx>
#include <vcl/msgbox.hxx> #include <vcl/msgbox.hxx>
#include <vcl/lstbox.hxx> #include <vcl/lstbox.hxx>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/servicefactory.hxx>
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
#include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/datatransfer/XTransferable.hpp> #include <com/sun/star/datatransfer/XTransferable.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
...@@ -34,9 +37,6 @@ ...@@ -34,9 +37,6 @@
#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp> #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp> #include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp> #include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp>
#include <osl/process.h>
#include <stdio.h>
using namespace ::rtl; using namespace ::rtl;
using namespace ::com::sun::star::io; using namespace ::com::sun::star::io;
...@@ -48,16 +48,6 @@ using namespace ::com::sun::star::datatransfer::dnd; ...@@ -48,16 +48,6 @@ using namespace ::com::sun::star::datatransfer::dnd;
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
class MyApp : public Application
{
public:
void Main();
};
MyApp aMyApp;
// -----------------------------------------------------------------------
class MyWin : public WorkWindow class MyWin : public WorkWindow
{ {
public: public:
...@@ -142,72 +132,39 @@ public: ...@@ -142,72 +132,39 @@ public:
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void MyApp::Main() class VclDnDTest : public test::BootstrapFixture
{ {
OUString aRegistry; public:
VclDnDTest() : BootstrapFixture(true, false) {}
for( sal_Int32 n = 0, nmax = osl_getCommandArgCount(); n < nmax; n++ )
{
OUString aArg;
osl_getCommandArg( n, &aArg.pData );
if( aArg.startsWith( "-r" ) )
{
if ( n + 1 < nmax )
osl_getCommandArg( ++n, &aRegistry.pData );
}
}
Reference< XMultiServiceFactory > xServiceManager;
if( aRegistry.getLength() )
{
xServiceManager = ::cppu::createRegistryServiceFactory( aRegistry, sal_True );
if( xServiceManager.is() )
{
::comphelper::setProcessServiceFactory( xServiceManager );
}
if( ! xServiceManager.is() ) /// Play with drag and drop
printf( "No servicemanager available.\n" ); void testDnD();
else
printf( "Ok\n" );
} CPPUNIT_TEST_SUITE(VclDnDTest);
else CPPUNIT_TEST(testDnD);
fprintf( stderr, "Usage: %s -r full-path-to-applicat.rdb\n", "dnddemo" ); CPPUNIT_TEST_SUITE_END();
};
// -----------------------------------------------------------------------
void VclDnDTest::testDnD()
{
MyWin aMainWin( NULL, WB_APP | WB_STDWORK ); MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
aMainWin.SetText( OUString( "Drag And Drop - Workbench" ) ); aMainWin.SetText( OUString( "Drag And Drop - Workbench" ) );
aMainWin.Show(); aMainWin.Show();
// test the clipboard code // test the clipboard code
Reference< XClipboard > xClipboard = aMainWin.GetClipboard(); Reference< XClipboard > xClipboard = aMainWin.GetClipboard();
if( xClipboard.is() ) CPPUNIT_ASSERT_MESSAGE("System clipboard not available",
{ xClipboard.is());
printf( "System clipboard available.\n" );
xClipboard->getContents();
}
else
fprintf( stderr, "System clipboard not available.\n" );
MyInfoBox aInfoBox( &aMainWin ); MyInfoBox aInfoBox( &aMainWin );
aInfoBox.Execute(); aInfoBox.Execute();
MyListBox aListBox( &aMainWin ); MyListBox aListBox( &aMainWin );
aListBox.SetPosSizePixel( 10, 10, 100, 100 ); aListBox.setPosSizePixel( 10, 10, 100, 100 );
aListBox.InsertEntry( OUString("TestItem")); aListBox.InsertEntry( OUString("TestItem"));
aListBox.Show(); aListBox.Show();
Execute();
Reference< XComponent > xComponent( xServiceManager, UNO_QUERY );
if( xComponent.is() )
xComponent->dispose();
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -282,19 +239,14 @@ void MyWin::Resize() ...@@ -282,19 +239,14 @@ void MyWin::Resize()
void SAL_CALL MyDragAndDropListener::dragGestureRecognized( const DragGestureEvent& dge ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dragGestureRecognized( const DragGestureEvent& dge ) throw(RuntimeException)
{ {
printf( "XDragGestureListener::dragGestureRecognized called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dge.DragOriginX, dge.DragOriginY );
Reference< XDragSource > xDragSource( dge.DragSource, UNO_QUERY ); Reference< XDragSource > xDragSource( dge.DragSource, UNO_QUERY );
xDragSource->startDrag( dge, -1, 0, 0, new StringTransferable( OUString("TestString") ), this ); xDragSource->startDrag( dge, -1, 0, 0, new StringTransferable( OUString("TestString") ), this );
printf( "XDragSource::startDrag returned.\n" );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) throw(RuntimeException)
{ {
printf( "XDropTargetListener::drop called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
dtde.Context->dropComplete( sal_True ); dtde.Context->dropComplete( sal_True );
} }
...@@ -302,7 +254,6 @@ void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) thr ...@@ -302,7 +254,6 @@ void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) thr
void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent& dtdee ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent& dtdee ) throw(RuntimeException)
{ {
printf( "XDropTargetListener::dragEnter called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dtdee.LocationX, dtdee.LocationY );
dtdee.Context->acceptDrag( dtdee.DropAction ); dtdee.Context->acceptDrag( dtdee.DropAction );
} }
...@@ -310,14 +261,12 @@ void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent& ...@@ -310,14 +261,12 @@ void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent&
void SAL_CALL MyDragAndDropListener::dragExit( const DropTargetEvent& ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dragExit( const DropTargetEvent& ) throw(RuntimeException)
{ {
printf( "XDropTargetListener::dragExit called ( Window: %p ).\n", m_pWindow );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde ) throw(RuntimeException)
{ {
printf( "XDropTargetListener::dragOver called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
dtde.Context->acceptDrag( dtde.DropAction ); dtde.Context->acceptDrag( dtde.DropAction );
} }
...@@ -325,50 +274,43 @@ void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde ) ...@@ -325,50 +274,43 @@ void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde )
void SAL_CALL MyDragAndDropListener::dropActionChanged( const DropTargetDragEvent& dtde ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dropActionChanged( const DropTargetDragEvent& dtde ) throw(RuntimeException)
{ {
printf( "XDropTargetListener::dropActionChanged called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
dtde.Context->acceptDrag( dtde.DropAction ); dtde.Context->acceptDrag( dtde.DropAction );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragDropEnd( const DragSourceDropEvent& dsde ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dragDropEnd( const DragSourceDropEvent& ) throw(RuntimeException)
{ {
printf( "XDragSourceListener::dropDropEnd called ( Window: %p, %s ).\n", m_pWindow, dsde.DropSuccess ? "success" : "failed" );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragEnter( const DragSourceDragEvent& ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dragEnter( const DragSourceDragEvent& ) throw(RuntimeException)
{ {
printf( "XDragSourceListener::dragEnter called ( Window: %p ).\n", m_pWindow );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragExit( const DragSourceEvent& ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dragExit( const DragSourceEvent& ) throw(RuntimeException)
{ {
printf( "XDragSourceListener::dragExit called ( Window: %p ).\n", m_pWindow );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragOver( const DragSourceDragEvent& ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dragOver( const DragSourceDragEvent& ) throw(RuntimeException)
{ {
printf( "XDragSourceListener::dragOver called ( Window: %p ).\n", m_pWindow );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dropActionChanged( const DragSourceDragEvent& ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::dropActionChanged( const DragSourceDragEvent& ) throw(RuntimeException)
{ {
printf( "XDragSourceListener::dropActionChanged called ( Window: %p ).\n", m_pWindow );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::disposing( const EventObject& ) throw(RuntimeException) void SAL_CALL MyDragAndDropListener::disposing( const EventObject& ) throw(RuntimeException)
{ {
printf( "XEventListener::disposing called ( Window: %p ).\n", m_pWindow );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -432,5 +374,6 @@ sal_Bool SAL_CALL StringTransferable::isDataFlavorSupported( const DataFlavor& ) ...@@ -432,5 +374,6 @@ sal_Bool SAL_CALL StringTransferable::isDataFlavorSupported( const DataFlavor& )
return sal_True; return sal_True;
} }
CPPUNIT_TEST_SUITE_REGISTRATION(VclDnDTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -575,6 +575,21 @@ namespace vcl ...@@ -575,6 +575,21 @@ namespace vcl
} }
uno::Sequence< double > colorToStdColorSpaceSequence( const Color& rColor )
{
uno::Sequence< double > aRet(4);
double* pRet = aRet.getArray();
pRet[0] = toDoubleColor(rColor.GetRed());
pRet[1] = toDoubleColor(rColor.GetGreen());
pRet[2] = toDoubleColor(rColor.GetBlue());
// VCL's notion of alpha is different from the rest of the world's
pRet[3] = 1.0 - toDoubleColor(rColor.GetTransparency());
return aRet;
}
Color stdColorSpaceSequenceToColor( const uno::Sequence< double >& rColor ) Color stdColorSpaceSequenceToColor( const uno::Sequence< double >& rColor )
{ {
ENSURE_ARG_OR_THROW( rColor.getLength() == 4, ENSURE_ARG_OR_THROW( rColor.getLength() == 4,
......
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