eraser01: merge with DEV300 m68
This commit is contained in:
commit
3f77adb947
@ -30,7 +30,7 @@
|
||||
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
#include <basegfx/vector/b2isize.hxx>
|
||||
#include <basegfx/point/b2ipoint.hxx>
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
#include <basegfx/vector/b2isize.hxx>
|
||||
#include <basegfx/range/b2irange.hxx>
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
#include <basegfx/vector/b2isize.hxx>
|
||||
#include <basegfx/range/b2irange.hxx>
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
#include <basegfx/vector/b2isize.hxx>
|
||||
#include <basegfx/point/b2ipoint.hxx>
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
#include <basegfx/vector/b2isize.hxx>
|
||||
#include <basegfx/range/b2drange.hxx>
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
#include <basegfx/vector/b2isize.hxx>
|
||||
#include <basegfx/point/b2ipoint.hxx>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
#
|
||||
# Copyright 2008 by Sun Microsystems, Inc.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
@ -57,7 +57,7 @@ CFLAGS += -fno-inline
|
||||
|
||||
# SunStudio 12 (-m64 and -m32 modes): three test cases of the unit tests fail
|
||||
# if compiled with default -xalias_level (and optimization level -xO3)
|
||||
.IF "$(OS)"=="SOLARIS"
|
||||
.IF "$(OS)"=="SOLARIS"
|
||||
# For Sun Studio 8 this switch does not work: compilation fails on bitmapdevice.cxx
|
||||
.IF "$(CCNUMVER)"!="00050005"
|
||||
CDEFS+=-xalias_level=compatible
|
||||
@ -65,9 +65,10 @@ CDEFS+=-xalias_level=compatible
|
||||
.ENDIF
|
||||
|
||||
# --- Common ----------------------------------------------------------
|
||||
.IF "$(L10N_framework)"==""
|
||||
|
||||
# BEGIN ----------------------------------------------------------------
|
||||
# auto generated Target:tests by codegen.pl
|
||||
# auto generated Target:tests by codegen.pl
|
||||
SHL1OBJS= \
|
||||
$(SLO)$/basictest.obj \
|
||||
$(SLO)$/bmpmasktest.obj \
|
||||
@ -85,17 +86,17 @@ SHL1OBJS= \
|
||||
# here, because not yet delivered. Need the functionality to test, so
|
||||
# we're linking it in statically. Need to keep this in sync with
|
||||
# source/makefile.mk
|
||||
|
||||
SHL1TARGET= tests
|
||||
SHL1STDLIBS= $(SALLIB) \
|
||||
$(TESTSHL2LIB)\
|
||||
$(CPPUNITLIB) \
|
||||
$(BASEGFXLIB)
|
||||
$(BASEGFXLIB)
|
||||
|
||||
SHL1IMPLIB= i$(SHL1TARGET)
|
||||
|
||||
DEF1NAME =$(SHL1TARGET)
|
||||
SHL1VERSIONMAP = export.map
|
||||
|
||||
SHL1VERSIONMAP = export.map
|
||||
.ENDIF
|
||||
# END ------------------------------------------------------------------
|
||||
|
||||
#APP2TARGET= bmpdemo
|
||||
@ -111,7 +112,7 @@ SHL1VERSIONMAP = export.map
|
||||
# $(CPPUHELPERLIB) \
|
||||
# $(UCBHELPERLIB) \
|
||||
# $(SALLIB) \
|
||||
# $(VCLLIB)
|
||||
# $(VCLLIB)
|
||||
#
|
||||
#.IF "$(GUI)"!="UNX"
|
||||
#APP2DEF= $(MISC)$/$(TARGET).def
|
||||
@ -119,19 +120,21 @@ SHL1VERSIONMAP = export.map
|
||||
|
||||
#------------------------------- All object files -------------------------------
|
||||
# do this here, so we get right dependencies
|
||||
SLOFILES=$(SHL1OBJS)
|
||||
SLOFILES=$(SHL1OBJS)
|
||||
|
||||
# --- Targets ------------------------------------------------------
|
||||
|
||||
.INCLUDE : target.mk
|
||||
.INCLUDE : _cppunit.mk
|
||||
.INCLUDE : _cppunit.mk
|
||||
|
||||
# --- Enable test execution in normal build ------------------------
|
||||
.IF "$(L10N_framework)"==""
|
||||
|
||||
unittest : $(SHL1TARGETN)
|
||||
@echo ----------------------------------------------------------
|
||||
@echo - start unit test on library $(SHL1TARGETN)
|
||||
@echo ----------------------------------------------------------
|
||||
$(AUGMENT_LIBRARY_PATH) testshl2 -sf $(mktmp ) $(SHL1TARGETN)
|
||||
$(TESTSHL2) -sf $(mktmp ) $(SHL1TARGETN)
|
||||
|
||||
ALLTAR : unittest
|
||||
.ENDIF
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
#include <basegfx/vector/b2isize.hxx>
|
||||
#include <basegfx/range/b2irange.hxx>
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
#include <basegfx/vector/b2isize.hxx>
|
||||
#include <basegfx/range/b2irange.hxx>
|
||||
|
76
basegfx/inc/basegfx/color/bcolortools.hxx
Normal file
76
basegfx/inc/basegfx/color/bcolortools.hxx
Normal file
@ -0,0 +1,76 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: bcolor.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _BGFX_COLOR_BCOLORTOOLS_HXX
|
||||
#define _BGFX_COLOR_BCOLORTOOLS_HXX
|
||||
|
||||
#include <sal/types.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace basegfx
|
||||
{
|
||||
class BColor;
|
||||
|
||||
namespace tools
|
||||
{
|
||||
/// Transform from RGB to HSL
|
||||
BColor rgb2hsl(const BColor& rRGBColor);
|
||||
/// Transform from HSL to RGB
|
||||
BColor hsl2rgb(const BColor& rHSLColor);
|
||||
|
||||
/// Transform from RGB to HSV
|
||||
BColor rgb2hsv(const BColor& rRGBColor);
|
||||
/// Transform from HSV to RGB
|
||||
BColor hsv2rgb(const BColor& rHSVColor);
|
||||
|
||||
/// Transform from R'G'B' to YIQ (NTSC color model - Y is used in monochrome mode)
|
||||
BColor rgb2yiq(const BColor& rRGBColor);
|
||||
/// Transform from YIQ to R'G'B' (NTSC color model - Y is used in monochrome mode)
|
||||
BColor yiq2rgb(const BColor& rYIQColor);
|
||||
|
||||
/// Transform from R'G'B' to Y'PbPr (the [0,1]x[-.5,.5]x[-.5,.5] equivalent of Y'CbCr (which is scaled into 8bit))
|
||||
BColor rgb2ypbpr(const BColor& rRGBColor);
|
||||
/// Transform from Y'PbPr (the [0,1]x[-.5,.5]x[-.5,.5] equivalent of Y'CbCr (which is scaled into 8bit)) into R'G'B'
|
||||
BColor ypbpr2rgb(const BColor& rYPbPrColor);
|
||||
|
||||
/// Transform from CIE XYZ into Rec. 709 RGB (D65 white point)
|
||||
BColor ciexyz2rgb( const BColor& rXYZColor );
|
||||
/// Transform from Rec. 709 RGB (D65 white point) into CIE XYZ
|
||||
BColor rgb2ciexyz( const BColor& rRGBColor );
|
||||
|
||||
}
|
||||
} // end of namespace basegfx
|
||||
|
||||
#endif /* _BGFX_COLOR_BCOLORTOOLS_HXX */
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// eof
|
@ -203,6 +203,22 @@ namespace basegfx
|
||||
sense to use reserve(4) at the vector as preparation.
|
||||
*/
|
||||
void getAllExtremumPositions(::std::vector< double >& rResults) const;
|
||||
|
||||
/** Get optimum-split position on this segment
|
||||
|
||||
This method calculates the positions of all points of the segment
|
||||
that have the maximimum distance to the corresponding line from
|
||||
startpoint-endpoint. This helps to approximate the bezier curve
|
||||
with a minimum number of line segments
|
||||
|
||||
@param fResults
|
||||
Result positions are in the range ]0.0 .. 1.0[
|
||||
Cubic beziers have at most two of these positions
|
||||
|
||||
@return
|
||||
Returns the number of split positions found
|
||||
*/
|
||||
int getMaxDistancePositions( double fResults[2]) const;
|
||||
};
|
||||
} // end of namespace basegfx
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: b2dpolygon.hxx,v $
|
||||
* $Revision: 1.14 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
@ -88,7 +87,9 @@ namespace basegfx
|
||||
|
||||
/// Coordinate insert/append
|
||||
void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rPoint, sal_uInt32 nCount = 1);
|
||||
void append(const basegfx::B2DPoint& rPoint, sal_uInt32 nCount = 1);
|
||||
void append(const basegfx::B2DPoint& rPoint, sal_uInt32 nCount);
|
||||
void append(const basegfx::B2DPoint& rPoint);
|
||||
void reserve(sal_uInt32 nCount);
|
||||
|
||||
/// Basic ControlPoint interface
|
||||
basegfx::B2DPoint getPrevControlPoint(sal_uInt32 nIndex) const;
|
||||
|
@ -104,6 +104,15 @@ namespace basegfx
|
||||
// DIFF: Return all areas where CandidateA is not covered by CandidateB (cut B out of A)
|
||||
B2DPolyPolygon solvePolygonOperationDiff(const B2DPolyPolygon& rCandidateA, const B2DPolyPolygon& rCandidateB);
|
||||
|
||||
/** merge all single PolyPolygons to a single, OR-ed PolyPolygon
|
||||
|
||||
@param rInput
|
||||
The source PolyPolygons
|
||||
|
||||
@return A single PolyPolygon containing the Or-merged result
|
||||
*/
|
||||
B2DPolyPolygon mergeToSinglePolyPolygon(const std::vector< basegfx::B2DPolyPolygon >& rInput);
|
||||
|
||||
} // end of namespace tools
|
||||
} // end of namespace basegfx
|
||||
|
||||
|
@ -262,6 +262,20 @@ namespace basegfx
|
||||
bool equal(const B2DPolyPolygon& rCandidateA, const B2DPolyPolygon& rCandidateB, const double& rfSmallValue);
|
||||
bool equal(const B2DPolyPolygon& rCandidateA, const B2DPolyPolygon& rCandidateB);
|
||||
|
||||
/** snap some polygon coordinates to discrete coordinates
|
||||
|
||||
This method allows to snap some polygon points to discrete (integer) values
|
||||
which equals e.g. a snap to discrete coordinates. It will snap points of
|
||||
horizontal and vertical edges
|
||||
|
||||
@param rCandidate
|
||||
The source polygon
|
||||
|
||||
@return
|
||||
The modified version of the source polygon
|
||||
*/
|
||||
B2DPolyPolygon snapPointsOfHorizontalOrVerticalEdges(const B2DPolyPolygon& rCandidate);
|
||||
|
||||
} // end of namespace tools
|
||||
} // end of namespace basegfx
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: b1drange.hxx,v $
|
||||
* $Revision: 1.15 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
@ -131,6 +130,11 @@ namespace basegfx
|
||||
return maRange.overlaps(rRange.maRange);
|
||||
}
|
||||
|
||||
bool overlapsMore(const B1DRange& rRange) const
|
||||
{
|
||||
return maRange.overlapsMore(rRange.maRange);
|
||||
}
|
||||
|
||||
void expand(double fValue)
|
||||
{
|
||||
maRange.expand(fValue);
|
||||
|
@ -7,7 +7,6 @@
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: b2drange.hxx,v $
|
||||
* $Revision: 1.19 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
@ -222,6 +221,14 @@ namespace basegfx
|
||||
);
|
||||
}
|
||||
|
||||
bool overlapsMore(const B2DRange& rRange) const
|
||||
{
|
||||
return (
|
||||
maRangeX.overlapsMore(rRange.maRangeX)
|
||||
&& maRangeY.overlapsMore(rRange.maRangeY)
|
||||
);
|
||||
}
|
||||
|
||||
void expand(const B2DTuple& rTuple)
|
||||
{
|
||||
maRangeX.expand(rTuple.getX());
|
||||
|
@ -7,7 +7,6 @@
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: basicrange.hxx,v $
|
||||
* $Revision: 1.15 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
@ -142,6 +141,14 @@ namespace basegfx
|
||||
}
|
||||
}
|
||||
|
||||
bool overlapsMore(const BasicRange& rRange) const
|
||||
{
|
||||
if(isEmpty() || rRange.isEmpty())
|
||||
return false;
|
||||
// returns true if the overlap is more than just a touching at the limits
|
||||
return ((rRange.mnMaximum > mnMinimum) && (rRange.mnMinimum < mnMaximum));
|
||||
}
|
||||
|
||||
bool operator==( const BasicRange& rRange ) const
|
||||
{
|
||||
return (mnMinimum == rRange.mnMinimum && mnMaximum == rRange.mnMaximum);
|
||||
|
@ -96,6 +96,7 @@ mkdir: %_DEST%\inc%_EXT%\basegfx\tools
|
||||
|
||||
mkdir: %_DEST%\inc%_EXT%\basegfx\color
|
||||
..\inc\basegfx\color\bcolor.hxx %_DEST%\inc%_EXT%\basegfx\color\bcolor.hxx
|
||||
..\inc\basegfx\color\bcolortools.hxx %_DEST%\inc%_EXT%\basegfx\color\bcolortools.hxx
|
||||
..\inc\basegfx\color\bcolormodifier.hxx %_DEST%\inc%_EXT%\basegfx\color\bcolormodifier.hxx
|
||||
|
||||
mkdir: %_DEST%\inc%_EXT%\basegfx\pixel
|
||||
|
272
basegfx/source/color/bcolortools.cxx
Normal file
272
basegfx/source/color/bcolortools.cxx
Normal file
@ -0,0 +1,272 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: bcolor.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_basegfx.hxx"
|
||||
|
||||
#include <basegfx/numeric/ftools.hxx>
|
||||
#include <basegfx/color/bcolor.hxx>
|
||||
#include <basegfx/color/bcolortools.hxx>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace basegfx { namespace tools
|
||||
{
|
||||
BColor rgb2hsl(const BColor& rRGBColor)
|
||||
{
|
||||
const double r=rRGBColor.getRed(), g=rRGBColor.getGreen(), b=rRGBColor.getBlue();
|
||||
const double minVal = ::std::min( ::std::min( r, g ), b );
|
||||
const double maxVal = ::std::max( ::std::max( r, g ), b );
|
||||
const double d = maxVal - minVal;
|
||||
|
||||
double h=0, s=0, l=0;
|
||||
|
||||
l = (maxVal + minVal) / 2.0;
|
||||
|
||||
if( ::basegfx::fTools::equalZero(d) )
|
||||
{
|
||||
s = h = 0; // hue undefined (achromatic case)
|
||||
}
|
||||
else
|
||||
{
|
||||
s = l > 0.5 ? d/(2.0-maxVal-minVal) :
|
||||
d/(maxVal + minVal);
|
||||
|
||||
if( r == maxVal )
|
||||
h = (g - b)/d;
|
||||
else if( g == maxVal )
|
||||
h = 2.0 + (b - r)/d;
|
||||
else
|
||||
h = 4.0 + (r - h)/d;
|
||||
|
||||
h *= 60.0;
|
||||
|
||||
if( h < 0.0 )
|
||||
h += 360.0;
|
||||
}
|
||||
|
||||
return BColor(h,s,l);
|
||||
}
|
||||
|
||||
static inline double hsl2rgbHelper( double nValue1, double nValue2, double nHue )
|
||||
{
|
||||
// clamp hue to [0,360]
|
||||
nHue = fmod( nHue, 360.0 );
|
||||
|
||||
// cope with wrap-arounds
|
||||
if( nHue < 0.0 )
|
||||
nHue += 360.0;
|
||||
|
||||
if( nHue < 60.0 )
|
||||
return nValue1 + (nValue2 - nValue1)*nHue/60.0;
|
||||
else if( nHue < 180.0 )
|
||||
return nValue2;
|
||||
else if( nHue < 240.0 )
|
||||
return nValue1 + (nValue2 - nValue1)*(240.0 - nHue)/60.0;
|
||||
else
|
||||
return nValue1;
|
||||
}
|
||||
|
||||
BColor hsl2rgb(const BColor& rHSLColor)
|
||||
{
|
||||
const double h=rHSLColor.getRed(), s=rHSLColor.getGreen(), l=rHSLColor.getBlue();
|
||||
|
||||
if( fTools::equalZero(s) )
|
||||
return BColor(l, l, l ); // achromatic case
|
||||
|
||||
const double nVal1( l <= 0.5 ? l*(1.0 + s) : l + s - l*s );
|
||||
const double nVal2( 2.0*l - nVal1 );
|
||||
|
||||
return BColor(
|
||||
hsl2rgbHelper(nVal2,
|
||||
nVal1,
|
||||
h + 120.0),
|
||||
hsl2rgbHelper(nVal2,
|
||||
nVal1,
|
||||
h),
|
||||
hsl2rgbHelper(nVal2,
|
||||
nVal1,
|
||||
h - 120.0) );
|
||||
}
|
||||
|
||||
BColor rgb2hsv(const BColor& rRGBColor)
|
||||
{
|
||||
const double r=rRGBColor.getRed(), g=rRGBColor.getGreen(), b=rRGBColor.getBlue();
|
||||
const double maxVal = std::max(std::max(r,g),b);
|
||||
const double minVal = std::min(std::min(r,g),b);
|
||||
const double delta = maxVal-minVal;
|
||||
|
||||
double h=0, s=0, v=0;
|
||||
|
||||
v = maxVal;
|
||||
if( fTools::equalZero(v) )
|
||||
s = 0;
|
||||
else
|
||||
s = delta / v;
|
||||
|
||||
if( !fTools::equalZero(s) )
|
||||
{
|
||||
if( maxVal == r )
|
||||
{
|
||||
h = (g - b) / delta;
|
||||
}
|
||||
else if( maxVal == g )
|
||||
{
|
||||
h = 2.0 + (b - r) / delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = 4.0 + (r - g) / delta;
|
||||
}
|
||||
|
||||
h *= 60.0;
|
||||
|
||||
if( h < 0 )
|
||||
h += 360;
|
||||
}
|
||||
|
||||
return BColor(h,s,v);
|
||||
}
|
||||
|
||||
BColor hsv2rgb(const BColor& rHSVColor)
|
||||
{
|
||||
double h=rHSVColor.getRed();
|
||||
const double s=rHSVColor.getGreen(), v=rHSVColor.getBlue();
|
||||
|
||||
if( fTools::equalZero(s) )
|
||||
{
|
||||
// achromatic case: no hue.
|
||||
return BColor(v,v,v);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fTools::equal(h,360) )
|
||||
h = 0; // 360 degrees is equivalent to 0 degrees
|
||||
|
||||
h /= 60.0;
|
||||
const sal_Int32 intval = static_cast< sal_Int32 >( h );
|
||||
const double f = h - intval;
|
||||
const double p = v*(1.0-s);
|
||||
const double q = v*(1.0-(s*f));
|
||||
const double t = v*(1.0-(s*(1.0-f)));
|
||||
|
||||
/* which hue area? */
|
||||
switch( intval )
|
||||
{
|
||||
case 0:
|
||||
return BColor(v,t,p);
|
||||
|
||||
case 1:
|
||||
return BColor(q,v,p);
|
||||
|
||||
case 2:
|
||||
return BColor(p,v,t);
|
||||
|
||||
case 3:
|
||||
return BColor(p,q,v);
|
||||
|
||||
case 4:
|
||||
return BColor(t,p,v);
|
||||
|
||||
case 5:
|
||||
return BColor(v,p,q);
|
||||
|
||||
default:
|
||||
// hue overflow
|
||||
return BColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BColor rgb2yiq(const BColor& rRGBColor)
|
||||
{
|
||||
// from Foley, van Dam, Computer Graphics
|
||||
const double r=rRGBColor.getRed(), g=rRGBColor.getGreen(), b=rRGBColor.getBlue();
|
||||
return BColor(
|
||||
0.299*r + 0.587*g + 0.114*b,
|
||||
0.596*r - 0.274*g - 0.322*b,
|
||||
0.211*r - 0.522*g + 0.311*b);
|
||||
}
|
||||
|
||||
BColor yiq2rgb(const BColor& rYIQColor)
|
||||
{
|
||||
// from Foley, van Dam, Computer Graphics
|
||||
const double y=rYIQColor.getRed(), i=rYIQColor.getGreen(), q=rYIQColor.getBlue();
|
||||
return BColor(
|
||||
y + 0.956*i + 0.623*q,
|
||||
y - 0.272*i - 0.648*q,
|
||||
y - 1.105*i + 1.705*q );
|
||||
}
|
||||
|
||||
BColor ciexyz2rgb( const BColor& rXYZColor )
|
||||
{
|
||||
// from Poynton color faq, and SMPTE RP 177-1993, Derivation
|
||||
// of Basic Television Color Equations
|
||||
const double x=rXYZColor.getRed(), y=rXYZColor.getGreen(), z=rXYZColor.getBlue();
|
||||
return BColor(
|
||||
3.240479*x - 1.53715*y - 0.498535*z,
|
||||
-0.969256*x + 1.875991*y + 0.041556*z,
|
||||
0.055648*x - 0.204043*y + 1.057311*z );
|
||||
}
|
||||
|
||||
BColor rgb2ciexyz( const BColor& rRGBColor )
|
||||
{
|
||||
// from Poynton color faq, and SMPTE RP 177-1993, Derivation
|
||||
// of Basic Television Color Equations
|
||||
const double r=rRGBColor.getRed(), g=rRGBColor.getGreen(), b=rRGBColor.getBlue();
|
||||
return BColor(
|
||||
0.412453*r + 0.35758*g + 0.180423*b,
|
||||
0.212671*r + 0.71516*g + 0.072169*b,
|
||||
0.019334*r + 0.119193*g + 0.950227*b);
|
||||
}
|
||||
|
||||
BColor rgb2ypbpr(const BColor& rRGBColor)
|
||||
{
|
||||
const double r=rRGBColor.getRed(), g=rRGBColor.getGreen(), b=rRGBColor.getBlue();
|
||||
return BColor(
|
||||
0.299*r + 0.587*g + 0.114*b,
|
||||
-0.168736*r - 0.331264*g + 0.5*b,
|
||||
0.5*r - 0.418688*g - 0.081312*b);
|
||||
}
|
||||
|
||||
BColor ypbpr2rgb(const BColor& rYPbPrColor)
|
||||
{
|
||||
const double y=rYPbPrColor.getRed(), pb=rYPbPrColor.getGreen(), pr=rYPbPrColor.getBlue();
|
||||
return BColor(
|
||||
1.*y + 0.*pb + 1.402*pr,
|
||||
1.*y - 0.344136*pb - 0.714136*pr,
|
||||
1.*y + 1.772*pb + 0.*pr);
|
||||
}
|
||||
|
||||
} } // end of namespace basegfx
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// eof
|
@ -45,6 +45,7 @@ TARGET=color
|
||||
|
||||
SLOFILES= \
|
||||
$(SLO)$/bcolor.obj \
|
||||
$(SLO)$/bcolortools.obj \
|
||||
$(SLO)$/bcolormodifier.obj
|
||||
|
||||
# --- Targets ----------------------------------
|
||||
|
@ -7,7 +7,6 @@
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: b2dcubicbezier.cxx,v $
|
||||
* $Revision: 1.16 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
@ -443,21 +442,32 @@ namespace basegfx
|
||||
bool bAIsTrivial(aVecA.equalZero());
|
||||
bool bBIsTrivial(aVecB.equalZero());
|
||||
|
||||
// #i102241# prepare inverse edge length to normalize cross values;
|
||||
// else the small compare value used in fTools::equalZero
|
||||
// will be length dependent and this detection will work as less
|
||||
// precise as longer the edge is. In principle, the length of the control
|
||||
// vector would need to be used too, but to be trivial it is assumed to
|
||||
// be of roughly equal length to the edge, so edge length can be used
|
||||
// for both. Only needed when one of both is not trivial per se.
|
||||
const double fInverseEdgeLength(bAIsTrivial && bBIsTrivial
|
||||
? 1.0
|
||||
: 1.0 / aEdge.getLength());
|
||||
|
||||
// if A is not zero, check if it could be
|
||||
if(!bAIsTrivial)
|
||||
{
|
||||
// parallel to edge? Check aVecA, aEdge
|
||||
// B2DVector::areParallel is too correct, uses differences in the e15 region,
|
||||
// thus do own test here
|
||||
const double fValA(aVecA.getX() * aEdge.getY());
|
||||
const double fValB(aVecA.getY() * aEdge.getX());
|
||||
// #i102241# parallel to edge? Check aVecA, aEdge. Use cross() which does what
|
||||
// we need here with the precision we need
|
||||
const double fCross(aVecA.cross(aEdge) * fInverseEdgeLength);
|
||||
|
||||
if(fTools::equalZero(fabs(fValA) - fabs(fValB)))
|
||||
if(fTools::equalZero(fCross))
|
||||
{
|
||||
// get scale to edge. Use bigger distance for numeric quality
|
||||
const double fScale(fabs(aEdge.getX()) > fabs(aEdge.getY()) ? aVecA.getX() / aEdge.getX() : aVecA.getY() / aEdge.getY());
|
||||
const double fScale(fabs(aEdge.getX()) > fabs(aEdge.getY())
|
||||
? aVecA.getX() / aEdge.getX()
|
||||
: aVecA.getY() / aEdge.getY());
|
||||
|
||||
// end point of vector in edge range?
|
||||
// relative end point of vector in edge range?
|
||||
if(fTools::moreOrEqual(fScale, 0.0) && fTools::lessOrEqual(fScale, 1.0))
|
||||
{
|
||||
bAIsTrivial = true;
|
||||
@ -470,13 +480,14 @@ namespace basegfx
|
||||
if(bAIsTrivial && !bBIsTrivial)
|
||||
{
|
||||
// parallel to edge? Check aVecB, aEdge
|
||||
const double fValA(aVecB.getX() * aEdge.getY());
|
||||
const double fValB(aVecB.getY() * aEdge.getX());
|
||||
const double fCross(aVecB.cross(aEdge) * fInverseEdgeLength);
|
||||
|
||||
if(fTools::equalZero(fabs(fValA) - fabs(fValB)))
|
||||
if(fTools::equalZero(fCross))
|
||||
{
|
||||
// get scale to edge. Use bigger distance for numeric quality
|
||||
const double fScale(fabs(aEdge.getX()) > fabs(aEdge.getY()) ? aVecB.getX() / aEdge.getX() : aVecB.getY() / aEdge.getY());
|
||||
const double fScale(fabs(aEdge.getX()) > fabs(aEdge.getY())
|
||||
? aVecB.getX() / aEdge.getX()
|
||||
: aVecB.getY() / aEdge.getY());
|
||||
|
||||
// end point of vector in edge range? Caution: controlB is directed AGAINST edge
|
||||
if(fTools::lessOrEqual(fScale, 0.0) && fTools::moreOrEqual(fScale, -1.0))
|
||||
@ -1033,6 +1044,65 @@ namespace basegfx
|
||||
impCheckExtremumResult(fCY / (2 * fBY), rResults);
|
||||
}
|
||||
}
|
||||
|
||||
int B2DCubicBezier::getMaxDistancePositions( double pResult[2]) const
|
||||
{
|
||||
// the distance from the bezier to a line through start and end
|
||||
// is proportional to (ENDx-STARTx,ENDy-STARTy)*(+BEZIERy(t),-BEZIERx(t))
|
||||
// this distance becomes zero for at least t==0 and t==1
|
||||
// its extrema that are between 0..1 are interesting as split candidates
|
||||
// its derived function has the form dD/dt = fA*t^2 + 2*fB*t + fC
|
||||
const B2DPoint aRelativeEndPoint(maEndPoint-maStartPoint);
|
||||
const double fA = 3 * (maEndPoint.getX() - maControlPointB.getX()) * aRelativeEndPoint.getY()
|
||||
- 3 * (maEndPoint.getY() - maControlPointB.getY()) * aRelativeEndPoint.getX();
|
||||
const double fB = (maControlPointB.getX() - maControlPointA.getX()) * aRelativeEndPoint.getY()
|
||||
- (maControlPointB.getY() - maControlPointA.getY()) * aRelativeEndPoint.getX();
|
||||
const double fC = (maControlPointA.getX() - maStartPoint.getX()) * aRelativeEndPoint.getY()
|
||||
- (maControlPointA.getY() - maStartPoint.getY()) * aRelativeEndPoint.getX();
|
||||
|
||||
// test for degenerated case: non-cubic curve
|
||||
if( fTools::equalZero(fA) )
|
||||
{
|
||||
// test for degenerated case: straight line
|
||||
if( fTools::equalZero(fB) )
|
||||
return 0;
|
||||
|
||||
// degenerated case: quadratic bezier
|
||||
pResult[0] = -fC / (2*fB);
|
||||
|
||||
// test root: ignore it when it is outside the curve
|
||||
int nCount = ((pResult[0] > 0) && (pResult[0] < 1));
|
||||
return nCount;
|
||||
}
|
||||
|
||||
// derivative is polynomial of order 2
|
||||
// check if the polynomial has non-imaginary roots
|
||||
const double fD = fB*fB - fA*fC;
|
||||
if( fD >= 0.0 ) // TODO: is this test needed? geometrically not IMHO
|
||||
{
|
||||
// calculate the first root
|
||||
const double fS = sqrt(fD);
|
||||
const double fQ = fB + ((fB >= 0) ? +fS : -fS);
|
||||
pResult[0] = fQ / fA;
|
||||
// test root: ignore it when it is outside the curve
|
||||
int nCount = ((pResult[0] > 0) && (pResult[0] < 1));
|
||||
|
||||
// ignore multiplicit roots
|
||||
if( !fTools::equalZero(fD) )
|
||||
{
|
||||
// calculate the second root
|
||||
const double fRoot = fC / fQ;
|
||||
pResult[ nCount ] = fC / fQ;
|
||||
// test root: ignore it when it is outside the curve
|
||||
nCount += ((fRoot > 0) && (fRoot < 1));
|
||||
}
|
||||
|
||||
return nCount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // end of namespace basegfx
|
||||
|
||||
// eof
|
||||
|
@ -352,13 +352,12 @@ namespace basegfx
|
||||
// Unfortunately, while it would be geometrically correct to not add
|
||||
// the in-between points EdgeEnd and EdgeStart, it leads to rounding
|
||||
// errors when converting to integer polygon coordinates for painting
|
||||
const B2DVector aEdgeVector(rEdge.getEndPoint() - rEdge.getStartPoint());
|
||||
|
||||
if(rEdge.isBezier())
|
||||
{
|
||||
// prepare target and data common for upper and lower
|
||||
B2DPolygon aBezierPolygon;
|
||||
const double fEdgeLength(aEdgeVector.getLength());
|
||||
const B2DVector aPureEdgeVector(rEdge.getEndPoint() - rEdge.getStartPoint());
|
||||
const double fEdgeLength(aPureEdgeVector.getLength());
|
||||
const bool bIsEdgeLengthZero(fTools::equalZero(fEdgeLength));
|
||||
const B2DVector aTangentA(rEdge.getTangent(0.0));
|
||||
const B2DVector aTangentB(rEdge.getTangent(1.0));
|
||||
@ -441,7 +440,11 @@ namespace basegfx
|
||||
}
|
||||
else
|
||||
{
|
||||
const B2DVector aPerpendEdgeVector(getNormalizedPerpendicular(aEdgeVector) * fHalfLineWidth);
|
||||
// #i101491# emulate rEdge.getTangent call which applies a factor of 0.3 to the
|
||||
// full-length edge vector to have numerically exactly the same results as in the
|
||||
// createAreaGeometryForJoin implementation
|
||||
const B2DVector aEdgeTangent((rEdge.getEndPoint() - rEdge.getStartPoint()) * 0.3);
|
||||
const B2DVector aPerpendEdgeVector(getNormalizedPerpendicular(aEdgeTangent) * fHalfLineWidth);
|
||||
B2DPolygon aEdgePolygon;
|
||||
|
||||
// create upper edge
|
||||
@ -495,45 +498,75 @@ namespace basegfx
|
||||
}
|
||||
}
|
||||
|
||||
// create first polygon part for edge
|
||||
aEdgePolygon.append(aEndPoint);
|
||||
aEdgePolygon.append(rPoint);
|
||||
aEdgePolygon.append(aStartPoint);
|
||||
|
||||
if(B2DLINEJOIN_MITER == eJoin)
|
||||
switch(eJoin)
|
||||
{
|
||||
// Look for the cut point between start point along rTangentPrev and
|
||||
// end point along rTangentEdge. -rTangentEdge should be used, but since
|
||||
// the cut value is used for interpolating along the first edge, the negation
|
||||
// is not needed since the same fCut will be found on the first edge.
|
||||
// If it exists, insert it to complete the mitered fill polygon.
|
||||
double fCutPos(0.0);
|
||||
tools::findCut(aStartPoint, rTangentPrev, aEndPoint, rTangentEdge, CUTFLAG_ALL, &fCutPos);
|
||||
|
||||
if(0.0 != fCutPos)
|
||||
case B2DLINEJOIN_MITER :
|
||||
{
|
||||
const B2DPoint aCutPoint(interpolate(aStartPoint, aStartPoint + rTangentPrev, fCutPos));
|
||||
aEdgePolygon.append(aCutPoint);
|
||||
}
|
||||
}
|
||||
else if(B2DLINEJOIN_ROUND == eJoin)
|
||||
{
|
||||
// use tooling to add needed EllipseSegment
|
||||
double fAngleStart(atan2(rPerpendPrev.getY(), rPerpendPrev.getX()));
|
||||
double fAngleEnd(atan2(rPerpendEdge.getY(), rPerpendEdge.getX()));
|
||||
aEdgePolygon.append(aEndPoint);
|
||||
aEdgePolygon.append(rPoint);
|
||||
aEdgePolygon.append(aStartPoint);
|
||||
|
||||
// atan2 results are [-PI .. PI], consolidate to [0.0 .. 2PI]
|
||||
if(fAngleStart < 0.0)
|
||||
// Look for the cut point between start point along rTangentPrev and
|
||||
// end point along rTangentEdge. -rTangentEdge should be used, but since
|
||||
// the cut value is used for interpolating along the first edge, the negation
|
||||
// is not needed since the same fCut will be found on the first edge.
|
||||
// If it exists, insert it to complete the mitered fill polygon.
|
||||
double fCutPos(0.0);
|
||||
tools::findCut(aStartPoint, rTangentPrev, aEndPoint, rTangentEdge, CUTFLAG_ALL, &fCutPos);
|
||||
|
||||
if(0.0 != fCutPos)
|
||||
{
|
||||
const B2DPoint aCutPoint(interpolate(aStartPoint, aStartPoint + rTangentPrev, fCutPos));
|
||||
aEdgePolygon.append(aCutPoint);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case B2DLINEJOIN_ROUND :
|
||||
{
|
||||
fAngleStart += F_2PI;
|
||||
}
|
||||
// use tooling to add needed EllipseSegment
|
||||
double fAngleStart(atan2(rPerpendPrev.getY(), rPerpendPrev.getX()));
|
||||
double fAngleEnd(atan2(rPerpendEdge.getY(), rPerpendEdge.getX()));
|
||||
|
||||
if(fAngleEnd < 0.0)
|
||||
// atan2 results are [-PI .. PI], consolidate to [0.0 .. 2PI]
|
||||
if(fAngleStart < 0.0)
|
||||
{
|
||||
fAngleStart += F_2PI;
|
||||
}
|
||||
|
||||
if(fAngleEnd < 0.0)
|
||||
{
|
||||
fAngleEnd += F_2PI;
|
||||
}
|
||||
|
||||
const B2DPolygon aBow(tools::createPolygonFromEllipseSegment(rPoint, fHalfLineWidth, fHalfLineWidth, fAngleStart, fAngleEnd));
|
||||
|
||||
if(aBow.count() > 1)
|
||||
{
|
||||
// #i101491#
|
||||
// use the original start/end positions; the ones from bow creation may be numerically
|
||||
// different due to their different creation. To guarantee good merging quality with edges
|
||||
// and edge roundings (and to reduce point count)
|
||||
aEdgePolygon = aBow;
|
||||
aEdgePolygon.setB2DPoint(0, aStartPoint);
|
||||
aEdgePolygon.setB2DPoint(aEdgePolygon.count() - 1, aEndPoint);
|
||||
aEdgePolygon.append(rPoint);
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// wanted fall-through to default
|
||||
}
|
||||
}
|
||||
default: // B2DLINEJOIN_BEVEL
|
||||
{
|
||||
fAngleEnd += F_2PI;
|
||||
}
|
||||
aEdgePolygon.append(aEndPoint);
|
||||
aEdgePolygon.append(rPoint);
|
||||
aEdgePolygon.append(aStartPoint);
|
||||
|
||||
aEdgePolygon.append(tools::createPolygonFromEllipseSegment(rPoint, fHalfLineWidth, fHalfLineWidth, fAngleStart, fAngleEnd));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// create last polygon part for edge
|
||||
|
@ -7,7 +7,6 @@
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: b2dpolygon.cxx,v $
|
||||
* $Revision: 1.22 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
@ -123,6 +122,16 @@ public:
|
||||
maVector[nIndex].setCoordinate(rValue);
|
||||
}
|
||||
|
||||
void reserve(sal_uInt32 nCount)
|
||||
{
|
||||
maVector.reserve(nCount);
|
||||
}
|
||||
|
||||
void append(const CoordinateData2D& rValue)
|
||||
{
|
||||
maVector.push_back(rValue);
|
||||
}
|
||||
|
||||
void insert(sal_uInt32 nIndex, const CoordinateData2D& rValue, sal_uInt32 nCount)
|
||||
{
|
||||
if(nCount)
|
||||
@ -380,6 +389,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void append(const ControlVectorPair2D& rValue)
|
||||
{
|
||||
maVector.push_back(rValue);
|
||||
|
||||
if(!rValue.getPrevVector().equalZero())
|
||||
mnUsedVectors += 1;
|
||||
|
||||
if(!rValue.getNextVector().equalZero())
|
||||
mnUsedVectors += 1;
|
||||
}
|
||||
|
||||
void insert(sal_uInt32 nIndex, const ControlVectorPair2D& rValue, sal_uInt32 nCount)
|
||||
{
|
||||
if(nCount)
|
||||
@ -741,6 +761,24 @@ public:
|
||||
maPoints.setCoordinate(nIndex, rValue);
|
||||
}
|
||||
|
||||
void reserve(sal_uInt32 nCount)
|
||||
{
|
||||
maPoints.reserve(nCount);
|
||||
}
|
||||
|
||||
void append(const basegfx::B2DPoint& rPoint)
|
||||
{
|
||||
mpBufferedData.reset(); // TODO: is this needed?
|
||||
const CoordinateData2D aCoordinate(rPoint);
|
||||
maPoints.append(aCoordinate);
|
||||
|
||||
if(mpControlVector)
|
||||
{
|
||||
const ControlVectorPair2D aVectorPair;
|
||||
mpControlVector->append(aVectorPair);
|
||||
}
|
||||
}
|
||||
|
||||
void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rPoint, sal_uInt32 nCount)
|
||||
{
|
||||
if(nCount)
|
||||
@ -1190,6 +1228,11 @@ namespace basegfx
|
||||
}
|
||||
}
|
||||
|
||||
void B2DPolygon::reserve(sal_uInt32 nCount)
|
||||
{
|
||||
mpPolygon->reserve(nCount);
|
||||
}
|
||||
|
||||
void B2DPolygon::insert(sal_uInt32 nIndex, const B2DPoint& rPoint, sal_uInt32 nCount)
|
||||
{
|
||||
OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)");
|
||||
@ -1208,6 +1251,11 @@ namespace basegfx
|
||||
}
|
||||
}
|
||||
|
||||
void B2DPolygon::append(const B2DPoint& rPoint)
|
||||
{
|
||||
mpPolygon->append(rPoint);
|
||||
}
|
||||
|
||||
B2DPoint B2DPolygon::getPrevControlPoint(sal_uInt32 nIndex) const
|
||||
{
|
||||
OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
|
||||
|
@ -7,7 +7,6 @@
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: b2dpolygoncutandtouch.cxx,v $
|
||||
* $Revision: 1.8 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
@ -110,7 +109,10 @@ namespace basegfx
|
||||
{
|
||||
// #i76891# mergeTemporaryPointsAndPolygon redesigned to be able to correctly handle
|
||||
// single edges with/without control points
|
||||
if(rTempPoints.size())
|
||||
// #i101491# added counter for non-changing element count
|
||||
const sal_uInt32 nTempPointCount(rTempPoints.size());
|
||||
|
||||
if(nTempPointCount)
|
||||
{
|
||||
B2DPolygon aRetval;
|
||||
const sal_uInt32 nCount(rCandidate.count());
|
||||
@ -138,7 +140,7 @@ namespace basegfx
|
||||
double fLeftStart(0.0);
|
||||
|
||||
// now add all points targeted to be at this index
|
||||
while(nNewInd < rTempPoints.size() && rTempPoints[nNewInd].getIndex() == a)
|
||||
while(nNewInd < nTempPointCount && rTempPoints[nNewInd].getIndex() == a)
|
||||
{
|
||||
const temporaryPoint& rTempPoint = rTempPoints[nNewInd++];
|
||||
|
||||
@ -160,7 +162,7 @@ namespace basegfx
|
||||
else
|
||||
{
|
||||
// add all points targeted to be at this index
|
||||
while(nNewInd < rTempPoints.size() && rTempPoints[nNewInd].getIndex() == a)
|
||||
while(nNewInd < nTempPointCount && rTempPoints[nNewInd].getIndex() == a)
|
||||
{
|
||||
const temporaryPoint& rTempPoint = rTempPoints[nNewInd++];
|
||||
const B2DPoint aNewPoint(rTempPoint.getPoint());
|
||||
@ -427,6 +429,7 @@ namespace basegfx
|
||||
|
||||
// create subdivided polygons and find cuts between them
|
||||
// Keep adaptiveSubdivideByCount due to needed quality
|
||||
aTempPolygonA.reserve(SUBDIVIDE_FOR_CUT_TEST_COUNT + 8);
|
||||
aTempPolygonA.append(rCubicA.getStartPoint());
|
||||
rCubicA.adaptiveSubdivideByCount(aTempPolygonA, SUBDIVIDE_FOR_CUT_TEST_COUNT);
|
||||
aTempPolygonEdge.append(rCurrB);
|
||||
@ -467,8 +470,10 @@ namespace basegfx
|
||||
|
||||
// create subdivided polygons and find cuts between them
|
||||
// Keep adaptiveSubdivideByCount due to needed quality
|
||||
aTempPolygonA.reserve(SUBDIVIDE_FOR_CUT_TEST_COUNT + 8);
|
||||
aTempPolygonA.append(rCubicA.getStartPoint());
|
||||
rCubicA.adaptiveSubdivideByCount(aTempPolygonA, SUBDIVIDE_FOR_CUT_TEST_COUNT);
|
||||
aTempPolygonB.reserve(SUBDIVIDE_FOR_CUT_TEST_COUNT + 8);
|
||||
aTempPolygonB.append(rCubicB.getStartPoint());
|
||||
rCubicB.adaptiveSubdivideByCount(aTempPolygonB, SUBDIVIDE_FOR_CUT_TEST_COUNT);
|
||||
|
||||
@ -494,6 +499,13 @@ namespace basegfx
|
||||
const B2DCubicBezier& rCubicA,
|
||||
sal_uInt32 nInd, temporaryPointVector& rTempPoints)
|
||||
{
|
||||
// avoid expensive part of this method if possible
|
||||
// TODO: use hasAnyExtremum() method instead when it becomes available
|
||||
double fDummy;
|
||||
const bool bHasAnyExtremum = rCubicA.getMinimumExtremumPosition( fDummy );
|
||||
if( !bHasAnyExtremum )
|
||||
return;
|
||||
|
||||
// find all self-intersections on the given bezier segment. Add an entry to the tempPoints
|
||||
// for each self intersection point with the cut value describing the relative position on given
|
||||
// bezier segment.
|
||||
@ -502,6 +514,7 @@ namespace basegfx
|
||||
|
||||
// create subdivided polygon and find cuts on it
|
||||
// Keep adaptiveSubdivideByCount due to needed quality
|
||||
aTempPolygon.reserve(SUBDIVIDE_FOR_CUT_TEST_COUNT + 8);
|
||||
aTempPolygon.append(rCubicA.getStartPoint());
|
||||
rCubicA.adaptiveSubdivideByCount(aTempPolygon, SUBDIVIDE_FOR_CUT_TEST_COUNT);
|
||||
findCuts(aTempPolygon, aTempPointVector);
|
||||
@ -554,7 +567,14 @@ namespace basegfx
|
||||
const bool bEdgeBIsCurve(aCubicB.isBezier());
|
||||
const B2DRange aRangeB(aCubicB.getRange());
|
||||
|
||||
if(aRangeA.overlaps(aRangeB))
|
||||
// only overlapping segments need to be tested
|
||||
// consecutive segments touch of course
|
||||
bool bOverlap = false;
|
||||
if( b > a+1)
|
||||
bOverlap = aRangeA.overlaps(aRangeB);
|
||||
else
|
||||
bOverlap = aRangeA.overlapsMore(aRangeB);
|
||||
if( bOverlap)
|
||||
{
|
||||
if(bEdgeAIsCurve && bEdgeBIsCurve)
|
||||
{
|
||||
@ -596,7 +616,13 @@ namespace basegfx
|
||||
const B2DPoint aNextB(rCandidate.getB2DPoint(b + 1L == nPointCount ? 0L : b + 1L));
|
||||
const B2DRange aRangeB(aCurrB, aNextB);
|
||||
|
||||
if(aRangeA.overlaps(aRangeB))
|
||||
// consecutive segments touch of course
|
||||
bool bOverlap = false;
|
||||
if( b > a+1)
|
||||
bOverlap = aRangeA.overlaps(aRangeB);
|
||||
else
|
||||
bOverlap = aRangeA.overlapsMore(aRangeB);
|
||||
if( bOverlap)
|
||||
{
|
||||
findEdgeCutsTwoEdges(aCurrA, aNextA, aCurrB, aNextB, a, b, rTempPoints, rTempPoints);
|
||||
}
|
||||
@ -685,6 +711,7 @@ namespace basegfx
|
||||
|
||||
// create subdivided polygon and find cuts on it
|
||||
// Keep adaptiveSubdivideByCount due to needed quality
|
||||
aTempPolygon.reserve(SUBDIVIDE_FOR_CUT_TEST_COUNT + 8);
|
||||
aTempPolygon.append(rCubicA.getStartPoint());
|
||||
rCubicA.adaptiveSubdivideByCount(aTempPolygon, SUBDIVIDE_FOR_CUT_TEST_COUNT);
|
||||
findTouches(aTempPolygon, rPointPolygon, aTempPointVector);
|
||||
@ -793,7 +820,13 @@ namespace basegfx
|
||||
const bool bEdgeBIsCurve(aCubicB.isBezier());
|
||||
const B2DRange aRangeB(aCubicB.getRange());
|
||||
|
||||
if(aRangeA.overlaps(aRangeB))
|
||||
// consecutive segments touch of course
|
||||
bool bOverlap = false;
|
||||
if( b > a+1)
|
||||
bOverlap = aRangeA.overlaps(aRangeB);
|
||||
else
|
||||
bOverlap = aRangeA.overlapsMore(aRangeB);
|
||||
if( bOverlap)
|
||||
{
|
||||
if(bEdgeAIsCurve && bEdgeBIsCurve)
|
||||
{
|
||||
@ -835,7 +868,13 @@ namespace basegfx
|
||||
const B2DPoint aNextB(rCandidateB.getB2DPoint(b + 1L == nPointCountB ? 0L : b + 1L));
|
||||
const B2DRange aRangeB(aCurrB, aNextB);
|
||||
|
||||
if(aRangeA.overlaps(aRangeB))
|
||||
// consecutive segments touch of course
|
||||
bool bOverlap = false;
|
||||
if( b > a+1)
|
||||
bOverlap = aRangeA.overlaps(aRangeB);
|
||||
else
|
||||
bOverlap = aRangeA.overlapsMore(aRangeB);
|
||||
if( bOverlap)
|
||||
{
|
||||
// test for simple edge-edge cuts
|
||||
findEdgeCutsTwoEdges(aCurrA, aNextA, aCurrB, aNextB, a, b, rTempPointsA, rTempPointsB);
|
||||
|
@ -7,7 +7,6 @@
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: b2dpolygontools.cxx,v $
|
||||
* $Revision: 1.29.4.1 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
@ -192,6 +191,9 @@ namespace basegfx
|
||||
B2DCubicBezier aBezier;
|
||||
aBezier.setStartPoint(rCandidate.getB2DPoint(0));
|
||||
|
||||
// perf: try to avoid too many realloctions by guessing the result's pointcount
|
||||
aRetval.reserve(nPointCount*4);
|
||||
|
||||
// add start point (always)
|
||||
aRetval.append(aBezier.getStartPoint());
|
||||
|
||||
@ -272,6 +274,9 @@ namespace basegfx
|
||||
B2DCubicBezier aBezier;
|
||||
aBezier.setStartPoint(rCandidate.getB2DPoint(0));
|
||||
|
||||
// perf: try to avoid too many realloctions by guessing the result's pointcount
|
||||
aRetval.reserve(nPointCount*4);
|
||||
|
||||
// add start point (always)
|
||||
aRetval.append(aBezier.getStartPoint());
|
||||
|
||||
@ -342,6 +347,9 @@ namespace basegfx
|
||||
B2DCubicBezier aBezier;
|
||||
aBezier.setStartPoint(rCandidate.getB2DPoint(0));
|
||||
|
||||
// perf: try to avoid too many realloctions by guessing the result's pointcount
|
||||
aRetval.reserve(nPointCount*4);
|
||||
|
||||
// add start point (always)
|
||||
aRetval.append(aBezier.getStartPoint());
|
||||
|
||||
@ -3269,6 +3277,9 @@ namespace basegfx
|
||||
B2DCubicBezier aBezier;
|
||||
aBezier.setStartPoint(rCandidate.getB2DPoint(0));
|
||||
|
||||
// try to avoid costly reallocations
|
||||
aRetval.reserve( nEdgeCount+1);
|
||||
|
||||
// add start point
|
||||
aRetval.append(aBezier.getStartPoint());
|
||||
|
||||
|
@ -929,6 +929,85 @@ namespace basegfx
|
||||
}
|
||||
}
|
||||
|
||||
B2DPolyPolygon mergeToSinglePolyPolygon(const std::vector< basegfx::B2DPolyPolygon >& rInput)
|
||||
{
|
||||
std::vector< basegfx::B2DPolyPolygon > aInput(rInput);
|
||||
|
||||
// first step: prepareForPolygonOperation and simple merge of non-overlapping
|
||||
// PolyPolygons for speedup; this is possible for the wanted OR-operation
|
||||
if(aInput.size())
|
||||
{
|
||||
std::vector< basegfx::B2DPolyPolygon > aResult;
|
||||
aResult.reserve(aInput.size());
|
||||
|
||||
for(sal_uInt32 a(0); a < aInput.size(); a++)
|
||||
{
|
||||
const basegfx::B2DPolyPolygon aCandidate(prepareForPolygonOperation(aInput[a]));
|
||||
|
||||
if(aResult.size())
|
||||
{
|
||||
const B2DRange aCandidateRange(aCandidate.getB2DRange());
|
||||
bool bCouldMergeSimple(false);
|
||||
|
||||
for(sal_uInt32 b(0); !bCouldMergeSimple && b < aResult.size(); b++)
|
||||
{
|
||||
basegfx::B2DPolyPolygon aTarget(aResult[b]);
|
||||
const B2DRange aTargetRange(aTarget.getB2DRange());
|
||||
|
||||
if(!aCandidateRange.overlaps(aTargetRange))
|
||||
{
|
||||
aTarget.append(aCandidate);
|
||||
aResult[b] = aTarget;
|
||||
bCouldMergeSimple = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!bCouldMergeSimple)
|
||||
{
|
||||
aResult.push_back(aCandidate);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aResult.push_back(aCandidate);
|
||||
}
|
||||
}
|
||||
|
||||
aInput = aResult;
|
||||
}
|
||||
|
||||
// second step: melt pairwise to a single PolyPolygon
|
||||
while(aInput.size() > 1)
|
||||
{
|
||||
std::vector< basegfx::B2DPolyPolygon > aResult;
|
||||
aResult.reserve((aInput.size() / 2) + 1);
|
||||
|
||||
for(sal_uInt32 a(0); a < aInput.size(); a += 2)
|
||||
{
|
||||
if(a + 1 < aInput.size())
|
||||
{
|
||||
// a pair for processing
|
||||
aResult.push_back(solvePolygonOperationOr(aInput[a], aInput[a + 1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
// last single PolyPolygon; copy to target to not lose it
|
||||
aResult.push_back(aInput[a]);
|
||||
}
|
||||
}
|
||||
|
||||
aInput = aResult;
|
||||
}
|
||||
|
||||
// third step: get result
|
||||
if(1 == aInput.size())
|
||||
{
|
||||
return aInput[0];
|
||||
}
|
||||
|
||||
return B2DPolyPolygon();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // end of namespace tools
|
||||
|
@ -569,6 +569,18 @@ namespace basegfx
|
||||
return equal(rCandidateA, rCandidateB, fSmallValue);
|
||||
}
|
||||
|
||||
B2DPolyPolygon snapPointsOfHorizontalOrVerticalEdges(const B2DPolyPolygon& rCandidate)
|
||||
{
|
||||
B2DPolyPolygon aRetval;
|
||||
|
||||
for(sal_uInt32 a(0L); a < rCandidate.count(); a++)
|
||||
{
|
||||
aRetval.append(snapPointsOfHorizontalOrVerticalEdges(rCandidate.getB2DPolygon(a)));
|
||||
}
|
||||
|
||||
return aRetval;
|
||||
}
|
||||
|
||||
} // end of namespace tools
|
||||
} // end of namespace basegfx
|
||||
|
||||
|
@ -875,52 +875,147 @@ namespace basegfx
|
||||
}
|
||||
else
|
||||
{
|
||||
bool bRetval(false);
|
||||
const B3DVector aPlaneNormal(rCandidate.getNormal());
|
||||
|
||||
if(!aPlaneNormal.equalZero())
|
||||
{
|
||||
const double fAbsX(fabs(aPlaneNormal.getX()));
|
||||
const double fAbsY(fabs(aPlaneNormal.getY()));
|
||||
const double fAbsZ(fabs(aPlaneNormal.getZ()));
|
||||
const sal_uInt32 nPointCount(rCandidate.count());
|
||||
|
||||
if(fAbsX > fAbsY && fAbsX > fAbsZ)
|
||||
if(nPointCount)
|
||||
{
|
||||
// normal points mostly in X-Direction, use YZ-Polygon projection for check
|
||||
B3DHomMatrix aTrans;
|
||||
B3DPoint aCurrentPoint(rCandidate.getB3DPoint(nPointCount - 1));
|
||||
const double fAbsX(fabs(aPlaneNormal.getX()));
|
||||
const double fAbsY(fabs(aPlaneNormal.getY()));
|
||||
const double fAbsZ(fabs(aPlaneNormal.getZ()));
|
||||
|
||||
aTrans.set(0, 0, 0.0);
|
||||
aTrans.set(0, 1, 1.0);
|
||||
aTrans.set(1, 1, 0.0);
|
||||
aTrans.set(1, 2, 1.0);
|
||||
if(fAbsX > fAbsY && fAbsX > fAbsZ)
|
||||
{
|
||||
// normal points mostly in X-Direction, use YZ-Polygon projection for check
|
||||
// x -> y, y -> z
|
||||
for(sal_uInt32 a(0); a < nPointCount; a++)
|
||||
{
|
||||
const B3DPoint aPreviousPoint(aCurrentPoint);
|
||||
aCurrentPoint = rCandidate.getB3DPoint(a);
|
||||
|
||||
const B2DPolygon aYZ(createB2DPolygonFromB3DPolygon(rCandidate, aTrans));
|
||||
// cross-over in Z?
|
||||
const bool bCompZA(fTools::more(aPreviousPoint.getZ(), rPoint.getZ()));
|
||||
const bool bCompZB(fTools::more(aCurrentPoint.getZ(), rPoint.getZ()));
|
||||
|
||||
return isInside(aYZ, B2DPoint(rPoint.getY(), rPoint.getZ()), bWithBorder);
|
||||
}
|
||||
else if(fAbsY > fAbsX && fAbsY > fAbsZ)
|
||||
{
|
||||
// normal points mostly in Y-Direction, use XZ-Polygon projection for check
|
||||
B3DHomMatrix aTrans;
|
||||
if(bCompZA != bCompZB)
|
||||
{
|
||||
// cross-over in Y?
|
||||
const bool bCompYA(fTools::more(aPreviousPoint.getY(), rPoint.getY()));
|
||||
const bool bCompYB(fTools::more(aCurrentPoint.getY(), rPoint.getY()));
|
||||
|
||||
aTrans.set(1, 1, 0.0);
|
||||
aTrans.set(1, 2, 1.0);
|
||||
if(bCompYA == bCompYB)
|
||||
{
|
||||
if(bCompYA)
|
||||
{
|
||||
bRetval = !bRetval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const double fCompare(
|
||||
aCurrentPoint.getY() - (aCurrentPoint.getZ() - rPoint.getZ()) *
|
||||
(aPreviousPoint.getY() - aCurrentPoint.getY()) /
|
||||
(aPreviousPoint.getZ() - aCurrentPoint.getZ()));
|
||||
|
||||
const B2DPolygon aXZ(createB2DPolygonFromB3DPolygon(rCandidate, aTrans));
|
||||
if(fTools::more(fCompare, rPoint.getY()))
|
||||
{
|
||||
bRetval = !bRetval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(fAbsY > fAbsX && fAbsY > fAbsZ)
|
||||
{
|
||||
// normal points mostly in Y-Direction, use XZ-Polygon projection for check
|
||||
// x -> x, y -> z
|
||||
for(sal_uInt32 a(0); a < nPointCount; a++)
|
||||
{
|
||||
const B3DPoint aPreviousPoint(aCurrentPoint);
|
||||
aCurrentPoint = rCandidate.getB3DPoint(a);
|
||||
|
||||
return isInside(aXZ, B2DPoint(rPoint.getX(), rPoint.getZ()), bWithBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal points mostly in Z-Direction, use XY-Polygon projection for check
|
||||
B3DHomMatrix aTrans;
|
||||
// cross-over in Z?
|
||||
const bool bCompZA(fTools::more(aPreviousPoint.getZ(), rPoint.getZ()));
|
||||
const bool bCompZB(fTools::more(aCurrentPoint.getZ(), rPoint.getZ()));
|
||||
|
||||
const B2DPolygon aXY(createB2DPolygonFromB3DPolygon(rCandidate, aTrans));
|
||||
if(bCompZA != bCompZB)
|
||||
{
|
||||
// cross-over in X?
|
||||
const bool bCompXA(fTools::more(aPreviousPoint.getX(), rPoint.getX()));
|
||||
const bool bCompXB(fTools::more(aCurrentPoint.getX(), rPoint.getX()));
|
||||
|
||||
return isInside(aXY, B2DPoint(rPoint.getX(), rPoint.getY()), bWithBorder);
|
||||
if(bCompXA == bCompXB)
|
||||
{
|
||||
if(bCompXA)
|
||||
{
|
||||
bRetval = !bRetval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const double fCompare(
|
||||
aCurrentPoint.getX() - (aCurrentPoint.getZ() - rPoint.getZ()) *
|
||||
(aPreviousPoint.getX() - aCurrentPoint.getX()) /
|
||||
(aPreviousPoint.getZ() - aCurrentPoint.getZ()));
|
||||
|
||||
if(fTools::more(fCompare, rPoint.getX()))
|
||||
{
|
||||
bRetval = !bRetval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal points mostly in Z-Direction, use XY-Polygon projection for check
|
||||
// x -> x, y -> y
|
||||
for(sal_uInt32 a(0); a < nPointCount; a++)
|
||||
{
|
||||
const B3DPoint aPreviousPoint(aCurrentPoint);
|
||||
aCurrentPoint = rCandidate.getB3DPoint(a);
|
||||
|
||||
// cross-over in Y?
|
||||
const bool bCompYA(fTools::more(aPreviousPoint.getY(), rPoint.getY()));
|
||||
const bool bCompYB(fTools::more(aCurrentPoint.getY(), rPoint.getY()));
|
||||
|
||||
if(bCompYA != bCompYB)
|
||||
{
|
||||
// cross-over in X?
|
||||
const bool bCompXA(fTools::more(aPreviousPoint.getX(), rPoint.getX()));
|
||||
const bool bCompXB(fTools::more(aCurrentPoint.getX(), rPoint.getX()));
|
||||
|
||||
if(bCompXA == bCompXB)
|
||||
{
|
||||
if(bCompXA)
|
||||
{
|
||||
bRetval = !bRetval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const double fCompare(
|
||||
aCurrentPoint.getX() - (aCurrentPoint.getY() - rPoint.getY()) *
|
||||
(aPreviousPoint.getX() - aCurrentPoint.getX()) /
|
||||
(aPreviousPoint.getY() - aCurrentPoint.getY()));
|
||||
|
||||
if(fTools::more(fCompare, rPoint.getX()))
|
||||
{
|
||||
bRetval = !bRetval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return bRetval;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "precompiled_basegfx.hxx"
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
namespace basegfx1d
|
||||
{
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "precompiled_basegfx.hxx"
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
#include <basegfx/matrix/b2dhommatrix.hxx>
|
||||
#include <basegfx/polygon/b2dpolygon.hxx>
|
||||
@ -43,6 +43,8 @@
|
||||
#include <basegfx/polygon/b2dpolypolygontools.hxx>
|
||||
#include <basegfx/range/b2dmultirange.hxx>
|
||||
#include <basegfx/numeric/ftools.hxx>
|
||||
#include <basegfx/color/bcolor.hxx>
|
||||
#include <basegfx/color/bcolortools.hxx>
|
||||
|
||||
#include <basegfx/tools/debugplotter.hxx>
|
||||
|
||||
@ -1443,6 +1445,178 @@ public:
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
}; // class b2dvector
|
||||
|
||||
class bcolor : public CppUnit::TestFixture
|
||||
{
|
||||
BColor maWhite;
|
||||
BColor maBlack;
|
||||
BColor maRed;
|
||||
BColor maGreen;
|
||||
BColor maBlue;
|
||||
BColor maYellow;
|
||||
BColor maMagenta;
|
||||
BColor maCyan;
|
||||
|
||||
public:
|
||||
bcolor() :
|
||||
maWhite(1,1,1),
|
||||
maBlack(0,0,0),
|
||||
maRed(1,0,0),
|
||||
maGreen(0,1,0),
|
||||
maBlue(0,0,1),
|
||||
maYellow(1,1,0),
|
||||
maMagenta(1,0,1),
|
||||
maCyan(0,1,1)
|
||||
{}
|
||||
|
||||
|
||||
// initialise your test code values here.
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
// insert your test code here.
|
||||
void hslTest()
|
||||
{
|
||||
CPPUNIT_ASSERT_MESSAGE("white",
|
||||
tools::rgb2hsl(maWhite) == BColor(0,0,1));
|
||||
CPPUNIT_ASSERT_MESSAGE("black",
|
||||
tools::rgb2hsl(maBlack) == BColor(0,0,0));
|
||||
CPPUNIT_ASSERT_MESSAGE("red",
|
||||
tools::rgb2hsl(maRed) == BColor(0,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("green",
|
||||
tools::rgb2hsl(maGreen) == BColor(120,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("blue",
|
||||
tools::rgb2hsl(maBlue) == BColor(240,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("yellow",
|
||||
tools::rgb2hsl(maYellow) == BColor(60,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("magenta",
|
||||
tools::rgb2hsl(maMagenta) == BColor(300,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("cyan",
|
||||
tools::rgb2hsl(maCyan) == BColor(180,1,0.5));
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip white",
|
||||
tools::hsl2rgb(tools::rgb2hsl(maWhite)) == maWhite);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip black",
|
||||
tools::hsl2rgb(tools::rgb2hsl(maBlack)) == maBlack);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip red",
|
||||
tools::hsl2rgb(tools::rgb2hsl(maRed)) == maRed);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip green",
|
||||
tools::hsl2rgb(tools::rgb2hsl(maGreen)) == maGreen);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip blue",
|
||||
tools::hsl2rgb(tools::rgb2hsl(maBlue)) == maBlue);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip yellow",
|
||||
tools::hsl2rgb(tools::rgb2hsl(maYellow)) == maYellow);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip magenta",
|
||||
tools::hsl2rgb(tools::rgb2hsl(maMagenta)) == maMagenta);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip cyan",
|
||||
tools::hsl2rgb(tools::rgb2hsl(maCyan)) == maCyan);
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("grey10",
|
||||
tools::rgb2hsl(maWhite*.1) == BColor(0,0,.1));
|
||||
CPPUNIT_ASSERT_MESSAGE("grey90",
|
||||
tools::rgb2hsl(maWhite*.9) == BColor(0,0,.9));
|
||||
CPPUNIT_ASSERT_MESSAGE("red/2",
|
||||
tools::rgb2hsl(maRed*.5) == BColor(0,1,0.25));
|
||||
CPPUNIT_ASSERT_MESSAGE("green/2",
|
||||
tools::rgb2hsl(maGreen*.5) == BColor(120,1,0.25));
|
||||
CPPUNIT_ASSERT_MESSAGE("blue/2",
|
||||
tools::rgb2hsl(maBlue*.5) == BColor(240,1,0.25));
|
||||
CPPUNIT_ASSERT_MESSAGE("yellow/2",
|
||||
tools::rgb2hsl(maYellow*.5) == BColor(60,1,0.25));
|
||||
CPPUNIT_ASSERT_MESSAGE("magenta/2",
|
||||
tools::rgb2hsl(maMagenta*.5) == BColor(300,1,0.25));
|
||||
CPPUNIT_ASSERT_MESSAGE("cyan/2",
|
||||
tools::rgb2hsl(maCyan*.5) == BColor(180,1,0.25));
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("pastel",
|
||||
tools::rgb2hsl(BColor(.75,.25,.25)) == BColor(0,.5,.5));
|
||||
}
|
||||
|
||||
// insert your test code here.
|
||||
void hsvTest()
|
||||
{
|
||||
CPPUNIT_ASSERT_MESSAGE("white",
|
||||
tools::rgb2hsv(maWhite) == BColor(0,0,1));
|
||||
CPPUNIT_ASSERT_MESSAGE("black",
|
||||
tools::rgb2hsv(maBlack) == BColor(0,0,0));
|
||||
CPPUNIT_ASSERT_MESSAGE("red",
|
||||
tools::rgb2hsv(maRed) == BColor(0,1,1));
|
||||
CPPUNIT_ASSERT_MESSAGE("green",
|
||||
tools::rgb2hsv(maGreen) == BColor(120,1,1));
|
||||
CPPUNIT_ASSERT_MESSAGE("blue",
|
||||
tools::rgb2hsv(maBlue) == BColor(240,1,1));
|
||||
CPPUNIT_ASSERT_MESSAGE("yellow",
|
||||
tools::rgb2hsv(maYellow) == BColor(60,1,1));
|
||||
CPPUNIT_ASSERT_MESSAGE("magenta",
|
||||
tools::rgb2hsv(maMagenta) == BColor(300,1,1));
|
||||
CPPUNIT_ASSERT_MESSAGE("cyan",
|
||||
tools::rgb2hsv(maCyan) == BColor(180,1,1));
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip white",
|
||||
tools::hsv2rgb(tools::rgb2hsv(maWhite)) == maWhite);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip black",
|
||||
tools::hsv2rgb(tools::rgb2hsv(maBlack)) == maBlack);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip red",
|
||||
tools::hsv2rgb(tools::rgb2hsv(maRed)) == maRed);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip green",
|
||||
tools::hsv2rgb(tools::rgb2hsv(maGreen)) == maGreen);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip blue",
|
||||
tools::hsv2rgb(tools::rgb2hsv(maBlue)) == maBlue);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip yellow",
|
||||
tools::hsv2rgb(tools::rgb2hsv(maYellow)) == maYellow);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip magenta",
|
||||
tools::hsv2rgb(tools::rgb2hsv(maMagenta)) == maMagenta);
|
||||
CPPUNIT_ASSERT_MESSAGE("roundtrip cyan",
|
||||
tools::hsv2rgb(tools::rgb2hsv(maCyan)) == maCyan);
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("grey10",
|
||||
tools::rgb2hsv(maWhite*.1) == BColor(0,0,.1));
|
||||
CPPUNIT_ASSERT_MESSAGE("grey90",
|
||||
tools::rgb2hsv(maWhite*.9) == BColor(0,0,.9));
|
||||
CPPUNIT_ASSERT_MESSAGE("red/2",
|
||||
tools::rgb2hsv(maRed*.5) == BColor(0,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("green/2",
|
||||
tools::rgb2hsv(maGreen*.5) == BColor(120,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("blue/2",
|
||||
tools::rgb2hsv(maBlue*.5) == BColor(240,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("yellow/2",
|
||||
tools::rgb2hsv(maYellow*.5) == BColor(60,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("magenta/2",
|
||||
tools::rgb2hsv(maMagenta*.5) == BColor(300,1,0.5));
|
||||
CPPUNIT_ASSERT_MESSAGE("cyan/2",
|
||||
tools::rgb2hsv(maCyan*.5) == BColor(180,1,0.5));
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("pastel",
|
||||
tools::rgb2hsv(BColor(.5,.25,.25)) == BColor(0,.5,.5));
|
||||
}
|
||||
|
||||
void ciexyzTest()
|
||||
{
|
||||
tools::rgb2ciexyz(maWhite);
|
||||
tools::rgb2ciexyz(maBlack);
|
||||
tools::rgb2ciexyz(maRed);
|
||||
tools::rgb2ciexyz(maGreen);
|
||||
tools::rgb2ciexyz(maBlue);
|
||||
tools::rgb2ciexyz(maYellow);
|
||||
tools::rgb2ciexyz(maMagenta);
|
||||
tools::rgb2ciexyz(maCyan);
|
||||
}
|
||||
|
||||
// Change the following lines only, if you add, remove or rename
|
||||
// member functions of the current class,
|
||||
// because these macros are need by auto register mechanism.
|
||||
|
||||
CPPUNIT_TEST_SUITE(bcolor);
|
||||
CPPUNIT_TEST(hslTest);
|
||||
CPPUNIT_TEST(hsvTest);
|
||||
CPPUNIT_TEST(ciexyzTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
}; // class b2dvector
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dmultirange, "basegfx2d");
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dsvgdimpex, "basegfx2d");
|
||||
@ -1458,6 +1632,7 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dquadraticbezier, "basegfx2d"
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2drange, "basegfx2d");
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dtuple, "basegfx2d");
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dvector, "basegfx2d");
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::bcolor, "basegfx2d");
|
||||
} // namespace basegfx2d
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "precompiled_basegfx.hxx"
|
||||
// autogenerated file with codegen.pl
|
||||
|
||||
#include <cppunit/simpleheader.hxx>
|
||||
#include <testshl/simpleheader.hxx>
|
||||
|
||||
namespace basegfx3d
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
#
|
||||
# Copyright 2008 by Sun Microsystems, Inc.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
@ -46,7 +46,7 @@ SHL1OBJS= \
|
||||
$(SLO)$/basegfx1d.obj \
|
||||
$(SLO)$/basegfx2d.obj \
|
||||
$(SLO)$/basegfx3d.obj \
|
||||
$(SLO)$/testtools.obj
|
||||
$(SLO)$/testtools.obj
|
||||
|
||||
# linking statically against basegfx parts
|
||||
SHL1LIBS=\
|
||||
@ -58,6 +58,7 @@ SHL1LIBS=\
|
||||
$(SLB)$/range.lib \
|
||||
$(SLB)$/tuple.lib \
|
||||
$(SLB)$/tools.lib \
|
||||
$(SLB)$/color.lib \
|
||||
$(SLB)$/vector.lib
|
||||
|
||||
SHL1TARGET= basegfx_tests
|
||||
@ -65,23 +66,24 @@ SHL1STDLIBS= \
|
||||
$(SALLIB) \
|
||||
$(CPPUHELPERLIB) \
|
||||
$(CPPULIB) \
|
||||
$(TESTSHL2LIB) \
|
||||
$(CPPUNITLIB)
|
||||
|
||||
SHL1IMPLIB= i$(SHL1TARGET)
|
||||
|
||||
DEF1NAME =$(SHL1TARGET)
|
||||
SHL1VERSIONMAP = export.map
|
||||
SHL1VERSIONMAP = export.map
|
||||
|
||||
# END ------------------------------------------------------------------
|
||||
|
||||
#------------------------------- All object files -------------------------------
|
||||
# do this here, so we get right dependencies
|
||||
SLOFILES=$(SHL1OBJS)
|
||||
SLOFILES=$(SHL1OBJS)
|
||||
|
||||
# --- Targets ------------------------------------------------------
|
||||
|
||||
.INCLUDE : target.mk
|
||||
.INCLUDE : _cppunit.mk
|
||||
.INCLUDE : _cppunit.mk
|
||||
|
||||
# --- Enable testshl2 execution in normal build ------------------------
|
||||
|
||||
@ -89,7 +91,7 @@ $(MISC)$/unittest_succeeded : $(SHL1TARGETN)
|
||||
@echo ----------------------------------------------------------
|
||||
@echo - start unit test on library $(SHL1TARGETN)
|
||||
@echo ----------------------------------------------------------
|
||||
$(AUGMENT_LIBRARY_PATH) testshl2 -sf $(mktmp ) -forward $(BIN)$/ $(SHL1TARGETN)
|
||||
$(TESTSHL2) -sf $(mktmp ) -forward $(BIN)$/ $(SHL1TARGETN)
|
||||
$(TOUCH) $@
|
||||
|
||||
ALLTAR : $(MISC)$/unittest_succeeded
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <basegfx/numeric/ftools.hxx>
|
||||
|
||||
#include <vcl/metric.hxx>
|
||||
#include <i18npool/mslangid.hxx>
|
||||
|
||||
#include "cairo_canvasfont.hxx"
|
||||
#include "cairo_textlayout.hxx"
|
||||
@ -86,6 +87,8 @@ namespace cairocanvas
|
||||
maFont->SetWeight( static_cast<FontWeight>(rFontRequest.FontDescription.FontDescription.Weight) );
|
||||
maFont->SetItalic( (rFontRequest.FontDescription.FontDescription.Letterform<=8) ? ITALIC_NONE : ITALIC_NORMAL );
|
||||
|
||||
maFont->SetLanguage(MsLangId::convertLocaleToLanguage(rFontRequest.Locale));
|
||||
|
||||
// adjust to stretched/shrinked font
|
||||
if( !::rtl::math::approxEqual( rFontMatrix.m00, rFontMatrix.m11) )
|
||||
{
|
||||
|
@ -888,7 +888,7 @@ namespace cairocanvas
|
||||
nY = aP.getY();
|
||||
cairo_matrix_transform_point( &aOrigMatrix, &nX, &nY );
|
||||
|
||||
if( ! bIsBezier && bIsRectangle ) {
|
||||
if( ! bIsBezier && (bIsRectangle || aOperation == Clip) ) {
|
||||
nX = basegfx::fround( nX );
|
||||
nY = basegfx::fround( nY );
|
||||
}
|
||||
|
@ -44,6 +44,12 @@
|
||||
#include <tools/prewin.h>
|
||||
#include <windows.h>
|
||||
#include <tools/postwin.h>
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#endif
|
||||
#include <vcl/sysdata.hxx>
|
||||
|
||||
|
@ -49,7 +49,7 @@ DLLPRE =
|
||||
# --- X11 Mac build currently doesn't work with cairo -----------
|
||||
.IF "$(OS)" == "MACOSX" && "$(GUIBASE)" == "unx"
|
||||
@all:
|
||||
@echo "Cannot build cairocanvas with X11..."
|
||||
@echo "Cannot build cairocanvas with X11..."
|
||||
.ENDIF
|
||||
.ENDIF
|
||||
|
||||
@ -65,7 +65,7 @@ CFLAGS+=-I$(SOLARINCDIR)/cairo
|
||||
.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
|
||||
CDEFS+= -DVERBOSE
|
||||
.ENDIF
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SLOFILES = $(SLO)$/cairo_cachedbitmap.obj \
|
||||
$(SLO)$/cairo_cairo.obj \
|
||||
$(SLO)$/cairo_canvas.obj \
|
||||
@ -84,7 +84,7 @@ SLOFILES = $(SLO)$/cairo_cachedbitmap.obj \
|
||||
|
||||
SHL1TARGET=$(TARGET).uno
|
||||
|
||||
SHL1STDLIBS= $(CPPULIB) $(TKLIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB) $(TOOLSLIB)
|
||||
SHL1STDLIBS= $(CPPULIB) $(TKLIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB) $(TOOLSLIB) $(I18NISOLANGLIB)
|
||||
|
||||
.IF "$(GUI)"=="UNX"
|
||||
|
||||
@ -97,7 +97,6 @@ SHL1STDLIBS+= -lcairo
|
||||
.IF "$(GUIBASE)"=="aqua"
|
||||
# native Mac OS X (Quartz)
|
||||
SLOFILES+= $(SLO)$/cairo_quartz_cairo.obj
|
||||
OBJCXXFLAGS=-x objective-c++ -fobjc-exceptions
|
||||
CFLAGSCXX+=$(OBJCXXFLAGS)
|
||||
.ELSE # "$(GUIBASE)"=="aqua"
|
||||
|
||||
@ -131,7 +130,7 @@ SHL1VERSIONMAP=exports.map
|
||||
DEF1NAME=$(SHL1TARGET)
|
||||
DEF1EXPORTFILE=exports.dxp
|
||||
|
||||
|
||||
.ENDIF
|
||||
# ==========================================================================
|
||||
|
||||
.INCLUDE : target.mk
|
||||
|
@ -956,11 +956,43 @@ namespace dxcanvas
|
||||
{
|
||||
if(hr != D3DERR_DEVICELOST)
|
||||
return false;
|
||||
hr = mpDevice->Reset(&mad3dpp);
|
||||
if(SUCCEEDED(hr))
|
||||
return true;
|
||||
if(hr == D3DERR_DEVICELOST)
|
||||
return true;
|
||||
|
||||
// interestingly enough, sometimes the Reset() below
|
||||
// *still* causes DeviceLost errors. So, cycle until
|
||||
// DX was kind enough to really reset the device...
|
||||
do
|
||||
{
|
||||
mpVertexBuffer.reset();
|
||||
hr = mpDevice->Reset(&mad3dpp);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
IDirect3DVertexBuffer9 *pVB(NULL);
|
||||
DWORD aFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
||||
if( FAILED(mpDevice->CreateVertexBuffer(sizeof(dxvertex)*maNumVertices,
|
||||
D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,
|
||||
aFVF,
|
||||
D3DPOOL_DEFAULT,
|
||||
&pVB,
|
||||
NULL)) )
|
||||
{
|
||||
throw lang::NoSupportException(
|
||||
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
|
||||
"Could not create DirectX device - out of memory!")),NULL);
|
||||
}
|
||||
mpVertexBuffer=COMReference<IDirect3DVertexBuffer9>(pVB);
|
||||
|
||||
// retry after the restore
|
||||
if(SUCCEEDED(mpSwapChain->Present(&aRect,&aRect,NULL,NULL,0)))
|
||||
return true;
|
||||
}
|
||||
|
||||
TimeValue aTimeout;
|
||||
aTimeout.Seconds=1;
|
||||
aTimeout.Nanosec=0;
|
||||
osl_waitThread(&aTimeout);
|
||||
}
|
||||
while(hr == D3DERR_DEVICELOST);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,9 @@ namespace dxcanvas
|
||||
}
|
||||
}
|
||||
|
||||
void DXCanvasItem::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& ) {}
|
||||
void DXCanvasItem::Commit() {}
|
||||
|
||||
bool DXCanvasItem::isDeviceUsable( const DeviceInfo& rDeviceInfo ) const
|
||||
{
|
||||
return maValues.find(rDeviceInfo) == maValues.end();
|
||||
|
@ -77,6 +77,8 @@ namespace dxcanvas
|
||||
bool isBlacklistCurrentDevice() const;
|
||||
void blacklistDevice( const DeviceInfo& rDeviceInfo );
|
||||
void adaptMaxTextureSize( basegfx::B2IVector& io_maxTextureSize ) const;
|
||||
virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
|
||||
virtual void Commit();
|
||||
|
||||
private:
|
||||
typedef std::set< DeviceInfo > ValueSet;
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include "dx_surfacegraphics.hxx"
|
||||
#include "dx_impltools.hxx"
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
namespace dxcanvas
|
||||
{
|
||||
namespace
|
||||
@ -75,11 +77,12 @@ namespace dxcanvas
|
||||
tools::setupGraphics( *pGraphics );
|
||||
pRet.reset(pGraphics,
|
||||
GraphicsDeleter(rSurface, aHDC));
|
||||
return pRet;
|
||||
}
|
||||
else
|
||||
rSurface->ReleaseDC( aHDC );
|
||||
}
|
||||
|
||||
return pRet;
|
||||
throw uno::RuntimeException();
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include <canvas/debug.hxx>
|
||||
#include "dx_impltools.hxx"
|
||||
#include <vcl/sysdata.hxx>
|
||||
#include <i18npool/mslangid.hxx>
|
||||
#include "dx_textlayout_drawhelper.hxx"
|
||||
#include "dx_bitmap.hxx"
|
||||
#include "dx_canvasfont.hxx"
|
||||
@ -135,6 +136,8 @@ namespace dxcanvas
|
||||
aFont.SetWeight( static_cast<FontWeight>(rFontRequest.FontDescription.FontDescription.Weight) );
|
||||
aFont.SetItalic( (rFontRequest.FontDescription.FontDescription.Letterform<=8) ? ITALIC_NONE : ITALIC_NORMAL );
|
||||
|
||||
aFont.SetLanguage(MsLangId::convertLocaleToLanguage(rFontRequest.Locale));
|
||||
|
||||
// setup font color
|
||||
aFont.SetColor( aColor );
|
||||
aFont.SetFillColor( aColor );
|
||||
|
@ -97,25 +97,18 @@
|
||||
|
||||
#undef DrawText
|
||||
|
||||
// Needed for #?$&/@ gdiplus header
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#define __WORKAROUND_MAX_DEFINED__
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#define __WORKAROUND_MIN_DEFINED__
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
using ::std::max;
|
||||
using ::std::min;
|
||||
#endif
|
||||
|
||||
#include <gdiplus.h>
|
||||
|
||||
#ifdef __WORKAROUND_MAX_DEFINED__
|
||||
#undef max
|
||||
#ifdef min
|
||||
# undef min
|
||||
#endif
|
||||
|
||||
#ifdef __WORKAROUND_MIN_DEFINED__
|
||||
#undef min
|
||||
#ifdef max
|
||||
# undef max
|
||||
#endif
|
||||
|
||||
namespace dxcanvas
|
||||
|
@ -96,7 +96,7 @@ GDIPLUS_SLOFILES = \
|
||||
$(SLO)$/dx_canvas.obj
|
||||
GDIPLUS_SLOFILES += $(SHARED_SLOFILES)
|
||||
|
||||
STDLIBS= $(CPPULIB) $(TKLIB) $(SALLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB) $(VCLLIB) $(TOOLSLIB) $(UNOTOOLSLIB)
|
||||
STDLIBS= $(CPPULIB) $(TKLIB) $(SALLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB) $(VCLLIB) $(TOOLSLIB) $(UNOTOOLSLIB) $(I18NISOLANGLIB)
|
||||
|
||||
|
||||
########################################################
|
||||
@ -194,7 +194,7 @@ LIB3OBJFILES = $(GDIPLUS_SLOFILES)
|
||||
SHL3TARGET=$(TARGET3).uno
|
||||
|
||||
# Links import libraries.
|
||||
SHL3STDLIBS= $(CPPULIB) $(TKLIB) $(SALLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB) $(VCLLIB) $(TOOLSLIB) $(UNOTOOLSLIB)
|
||||
SHL3STDLIBS= $(CPPULIB) $(TKLIB) $(SALLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB) $(VCLLIB) $(TOOLSLIB) $(UNOTOOLSLIB) $(I18NISOLANGLIB)
|
||||
|
||||
# Specifies an import library to create. For Win32 only.
|
||||
SHL3IMPLIB=i$(TARGET3).lib
|
||||
|
@ -37,7 +37,7 @@ ENABLE_EXCEPTIONS = TRUE
|
||||
|
||||
.INCLUDE : settings.mk
|
||||
DLLPRE =
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SLOFILES = \
|
||||
$(SLO)$/cf_service.obj
|
||||
|
||||
@ -55,6 +55,6 @@ SHL1LIBS = $(SLB)$/$(TARGET).lib
|
||||
SHL1DEF = $(MISC)$/$(SHL1TARGET).def
|
||||
|
||||
DEF1NAME = $(SHL1TARGET)
|
||||
|
||||
.ENDIF
|
||||
.INCLUDE : target.mk
|
||||
|
||||
|
@ -45,7 +45,7 @@ DLLPRE =
|
||||
.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
|
||||
CDEFS+= -DVERBOSE
|
||||
.ENDIF
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SLOFILES = $(SLO)$/null_canvasbitmap.obj \
|
||||
$(SLO)$/null_canvascustomsprite.obj \
|
||||
$(SLO)$/null_canvasfont.obj \
|
||||
@ -68,7 +68,7 @@ SHL1VERSIONMAP=exports.map
|
||||
|
||||
DEF1NAME=$(SHL1TARGET)
|
||||
DEF1EXPORTFILE=exports.dxp
|
||||
|
||||
.ENDIF
|
||||
# ==========================================================================
|
||||
|
||||
.INCLUDE : target.mk
|
||||
|
@ -45,7 +45,7 @@ DLLPRE =
|
||||
.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
|
||||
CDEFS+= -DVERBOSE
|
||||
.ENDIF
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SLOFILES = $(SLO)$/simplecanvasimpl.obj
|
||||
|
||||
SHL1TARGET=$(TARGET).uno
|
||||
@ -60,6 +60,7 @@ SHL1VERSIONMAP=exports.map
|
||||
|
||||
DEF1NAME=$(SHL1TARGET)
|
||||
DEF1EXPORTFILE=exports.dxp
|
||||
.ENDIF
|
||||
|
||||
# ==========================================================================
|
||||
|
||||
|
@ -51,7 +51,7 @@ CDEFS+= -DPROFILER
|
||||
#CFLAGS +:= /Ox /Ot # THIS IS IMPORTANT
|
||||
|
||||
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SLOFILES = \
|
||||
$(SLO)$/cachedprimitivebase.obj \
|
||||
$(SLO)$/canvascustomspritehelper.obj \
|
||||
@ -95,7 +95,7 @@ DEFLIB1NAME =$(TARGET)
|
||||
.IF "$(GUI)" == "WNT"
|
||||
SHL1STDLIBS += $(WINMMLIB) $(KERNEL32LIB)
|
||||
.ENDIF
|
||||
|
||||
.ENDIF
|
||||
|
||||
# ==========================================================================
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
#include <rtl/math.hxx>
|
||||
#include <basegfx/numeric/ftools.hxx>
|
||||
|
||||
#include <i18npool/mslangid.hxx>
|
||||
#include <vcl/metric.hxx>
|
||||
|
||||
#include "canvasfont.hxx"
|
||||
@ -67,6 +67,8 @@ namespace vclcanvas
|
||||
maFont->SetWeight( static_cast<FontWeight>(rFontRequest.FontDescription.FontDescription.Weight) );
|
||||
maFont->SetItalic( (rFontRequest.FontDescription.FontDescription.Letterform<=8) ? ITALIC_NONE : ITALIC_NORMAL );
|
||||
|
||||
maFont->SetLanguage(MsLangId::convertLocaleToLanguage(rFontRequest.Locale));
|
||||
|
||||
// adjust to stretched/shrinked font
|
||||
if( !::rtl::math::approxEqual( rFontMatrix.m00, rFontMatrix.m11) )
|
||||
{
|
||||
@ -125,8 +127,19 @@ namespace vclcanvas
|
||||
{
|
||||
tools::LocalGuard aGuard;
|
||||
|
||||
// TODO(F1)
|
||||
return rendering::FontMetrics();
|
||||
OutputDevice& rOutDev = mpOutDevProvider->getOutDev();
|
||||
VirtualDevice aVDev( rOutDev );
|
||||
aVDev.SetFont(getVCLFont());
|
||||
const ::FontMetric& aMetric( aVDev.GetFontMetric() );
|
||||
|
||||
return rendering::FontMetrics(
|
||||
aMetric.GetAscent(),
|
||||
aMetric.GetDescent(),
|
||||
aMetric.GetIntLeading(),
|
||||
aMetric.GetExtLeading(),
|
||||
0,
|
||||
aMetric.GetDescent() / 2.0,
|
||||
aMetric.GetAscent() / 2.0);
|
||||
}
|
||||
|
||||
uno::Sequence< double > SAL_CALL CanvasFont::getAvailableSizes( ) throw (uno::RuntimeException)
|
||||
|
@ -73,7 +73,7 @@ SLOFILES = $(SLO)$/backbuffer.obj \
|
||||
|
||||
SHL1TARGET=$(TARGET).uno
|
||||
|
||||
SHL1STDLIBS= $(TOOLSLIB) $(TKLIB) $(CPPULIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB) $(GOODIESLIB)
|
||||
SHL1STDLIBS= $(TOOLSLIB) $(TKLIB) $(CPPULIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB) $(GOODIESLIB) $(I18NISOLANGLIB)
|
||||
|
||||
SHL1IMPLIB=i$(TARGET)
|
||||
SHL1LIBS=$(SLB)$/$(TARGET).lib
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <tools/diagnose_ex.h>
|
||||
#include <canvas/canvastools.hxx>
|
||||
|
||||
#include <com/sun/star/rendering/CompositeOperation.hpp>
|
||||
#include <com/sun/star/rendering/TextDirection.hpp>
|
||||
|
||||
#include <vcl/metric.hxx>
|
||||
@ -42,6 +43,7 @@
|
||||
|
||||
#include <basegfx/matrix/b2dhommatrix.hxx>
|
||||
#include <basegfx/numeric/ftools.hxx>
|
||||
#include <basegfx/tools/canvastools.hxx>
|
||||
|
||||
#include "impltools.hxx"
|
||||
#include "textlayout.hxx"
|
||||
@ -116,16 +118,104 @@ namespace vclcanvas
|
||||
{
|
||||
tools::LocalGuard aGuard;
|
||||
|
||||
// TODO(F1)
|
||||
return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
|
||||
OutputDevice& rOutDev = mpOutDevProvider->getOutDev();
|
||||
VirtualDevice aVDev( rOutDev );
|
||||
aVDev.SetFont( mpFont->getVCLFont() );
|
||||
|
||||
setupLayoutMode( aVDev, mnTextDirection );
|
||||
|
||||
const rendering::ViewState aViewState(
|
||||
geometry::AffineMatrix2D(1,0,0, 0,1,0),
|
||||
NULL);
|
||||
|
||||
rendering::RenderState aRenderState (
|
||||
geometry::AffineMatrix2D(1,0,0,0,1,0),
|
||||
NULL,
|
||||
uno::Sequence<double>(4),
|
||||
rendering::CompositeOperation::SOURCE);
|
||||
|
||||
::boost::scoped_array< sal_Int32 > aOffsets(new sal_Int32[maLogicalAdvancements.getLength()]);
|
||||
setupTextOffsets(aOffsets.get(), maLogicalAdvancements, aViewState, aRenderState);
|
||||
|
||||
uno::Sequence< uno::Reference< rendering::XPolyPolygon2D> > aOutlineSequence;
|
||||
::basegfx::B2DPolyPolygonVector aOutlines;
|
||||
if (aVDev.GetTextOutlines(
|
||||
aOutlines,
|
||||
maText.Text,
|
||||
::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
|
||||
::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
|
||||
::canvas::tools::numeric_cast<USHORT>(maText.Length),
|
||||
FALSE,
|
||||
0,
|
||||
aOffsets.get()))
|
||||
{
|
||||
aOutlineSequence.realloc(aOutlines.size());
|
||||
sal_Int32 nIndex (0);
|
||||
for (::basegfx::B2DPolyPolygonVector::const_iterator
|
||||
iOutline(aOutlines.begin()),
|
||||
iEnd(aOutlines.end());
|
||||
iOutline!=iEnd;
|
||||
++iOutline)
|
||||
{
|
||||
aOutlineSequence[nIndex++] = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
|
||||
mxDevice,
|
||||
*iOutline);
|
||||
}
|
||||
}
|
||||
|
||||
return aOutlineSequence;
|
||||
}
|
||||
|
||||
uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException)
|
||||
{
|
||||
tools::LocalGuard aGuard;
|
||||
|
||||
// TODO(F1)
|
||||
return uno::Sequence< geometry::RealRectangle2D >();
|
||||
|
||||
OutputDevice& rOutDev = mpOutDevProvider->getOutDev();
|
||||
VirtualDevice aVDev( rOutDev );
|
||||
aVDev.SetFont( mpFont->getVCLFont() );
|
||||
|
||||
setupLayoutMode( aVDev, mnTextDirection );
|
||||
|
||||
const rendering::ViewState aViewState(
|
||||
geometry::AffineMatrix2D(1,0,0, 0,1,0),
|
||||
NULL);
|
||||
|
||||
rendering::RenderState aRenderState (
|
||||
geometry::AffineMatrix2D(1,0,0,0,1,0),
|
||||
NULL,
|
||||
uno::Sequence<double>(4),
|
||||
rendering::CompositeOperation::SOURCE);
|
||||
|
||||
::boost::scoped_array< sal_Int32 > aOffsets(new sal_Int32[maLogicalAdvancements.getLength()]);
|
||||
setupTextOffsets(aOffsets.get(), maLogicalAdvancements, aViewState, aRenderState);
|
||||
|
||||
MetricVector aMetricVector;
|
||||
uno::Sequence<geometry::RealRectangle2D> aBoundingBoxes;
|
||||
if (aVDev.GetGlyphBoundRects(
|
||||
Point(0,0),
|
||||
maText.Text,
|
||||
::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
|
||||
::canvas::tools::numeric_cast<USHORT>(maText.Length),
|
||||
::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
|
||||
aMetricVector))
|
||||
{
|
||||
aBoundingBoxes.realloc(aMetricVector.size());
|
||||
sal_Int32 nIndex (0);
|
||||
for (MetricVector::const_iterator
|
||||
iMetric(aMetricVector.begin()),
|
||||
iEnd(aMetricVector.end());
|
||||
iMetric!=iEnd;
|
||||
++iMetric)
|
||||
{
|
||||
aBoundingBoxes[nIndex++] = geometry::RealRectangle2D(
|
||||
iMetric->getX(),
|
||||
iMetric->getY(),
|
||||
iMetric->getX() + iMetric->getWidth(),
|
||||
iMetric->getY() + iMetric->getHeight());
|
||||
}
|
||||
}
|
||||
return aBoundingBoxes;
|
||||
}
|
||||
|
||||
uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException)
|
||||
@ -171,7 +261,7 @@ namespace vclcanvas
|
||||
|
||||
setupLayoutMode( aVDev, mnTextDirection );
|
||||
|
||||
const sal_Int32 nAboveBaseline( -aMetric.GetIntLeading() - aMetric.GetAscent() );
|
||||
const sal_Int32 nAboveBaseline( /*-aMetric.GetIntLeading()*/ - aMetric.GetAscent() );
|
||||
const sal_Int32 nBelowBaseline( aMetric.GetDescent() );
|
||||
|
||||
if( maLogicalAdvancements.getLength() )
|
||||
|
212
comphelper/inc/comphelper/docpasswordhelper.hxx
Normal file
212
comphelper/inc/comphelper/docpasswordhelper.hxx
Normal file
@ -0,0 +1,212 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: docpasswordhelper.hxx,v $
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef COMPHELPER_DOCPASSWORDHELPR_HXX
|
||||
#define COMPHELPER_DOCPASSWORDHELPR_HXX
|
||||
|
||||
#include "comphelper/comphelperdllapi.h"
|
||||
#include <vector>
|
||||
#include "comphelper/docpasswordrequest.hxx"
|
||||
|
||||
namespace com { namespace sun { namespace star { namespace task { class XInteractionHandler; } } } }
|
||||
|
||||
namespace comphelper {
|
||||
|
||||
class MediaDescriptor;
|
||||
|
||||
// ============================================================================
|
||||
|
||||
enum DocPasswordVerifierResult
|
||||
{
|
||||
DocPasswordVerifierResult_OK,
|
||||
DocPasswordVerifierResult_WRONG_PASSWORD,
|
||||
DocPasswordVerifierResult_ABORT
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
||||
/** Base class for a password verifier used by the DocPasswordHelper class
|
||||
below.
|
||||
|
||||
Users have to implement the virtual function and pass an instance of the
|
||||
verifier to one of the password request functions.
|
||||
*/
|
||||
class COMPHELPER_DLLPUBLIC IDocPasswordVerifier
|
||||
{
|
||||
public:
|
||||
virtual ~IDocPasswordVerifier();
|
||||
|
||||
/** Will be called everytime a password needs to be verified.
|
||||
|
||||
@return The result of the verification.
|
||||
- DocPasswordVerifierResult_OK, if and only if the passed password
|
||||
is valid and can be used to process the related document.
|
||||
- DocPasswordVerifierResult_WRONG_PASSWORD, if the password is
|
||||
wrong. The user may be asked again for a new password.
|
||||
- DocPasswordVerifierResult_ABORT, if an unrecoverable error
|
||||
occured while password verification. The password request loop
|
||||
will be aborted.
|
||||
*/
|
||||
virtual DocPasswordVerifierResult verifyPassword( const ::rtl::OUString& rPassword ) = 0;
|
||||
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
||||
/** Helper that asks for a document password and checks its validity.
|
||||
*/
|
||||
class COMPHELPER_DLLPUBLIC DocPasswordHelper
|
||||
{
|
||||
public:
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** This helper function tries to request and verify a password to load a
|
||||
protected document.
|
||||
|
||||
First, the list of default passwords will be tried if provided. This is
|
||||
needed by import filters for external file formats that have to check a
|
||||
predefined password in some cases without asking the user for a
|
||||
password. Every password is checked using the passed password verifier.
|
||||
|
||||
If not successful, the passed password of a medium is tried, that has
|
||||
been set e.g. by an API call to load a document. If existing, the
|
||||
password is checked using the passed password verifier.
|
||||
|
||||
If still not successful, the passed interaction handler is used to
|
||||
request a password from the user. This will be repeated until the
|
||||
passed password verifier validates the entered password, or if the user
|
||||
chooses to cancel password input.
|
||||
|
||||
@param rVerifier
|
||||
The password verifier used to check every processed password.
|
||||
|
||||
@param rMediaPassword
|
||||
If not empty, will be passed to the password validator before
|
||||
requesting a password from the user. This password usually should
|
||||
be querried from a media descriptor.
|
||||
|
||||
@param rxInteractHandler
|
||||
The interaction handler that will be used to request a password
|
||||
from the user, e.g. by showing a password input dialog.
|
||||
|
||||
@param rDocumentName
|
||||
The name of the related document that will be shown in the password
|
||||
input dialog.
|
||||
|
||||
@param eRequestType
|
||||
The password request type that will be passed to the
|
||||
DocPasswordRequest object created internally. See
|
||||
docpasswordrequest.hxx for more details.
|
||||
|
||||
@param pDefaultPasswords
|
||||
If not null, contains default passwords that will be tried before a
|
||||
password will be requested from the media descriptor or the user.
|
||||
|
||||
@param pbIsDefaultPassword
|
||||
(output parameter) If not null, the type of the found password will
|
||||
be returned. True means the password has been found in the passed
|
||||
list of default passwords. False means the password has been taken
|
||||
from the rMediaPassword parameter or has been entered by the user.
|
||||
|
||||
@return
|
||||
If not empty, contains the password that has been validated by the
|
||||
passed password verifier. If empty, no valid password has been
|
||||
found, or the user has chossen to cancel password input.
|
||||
*/
|
||||
static ::rtl::OUString requestAndVerifyDocPassword(
|
||||
IDocPasswordVerifier& rVerifier,
|
||||
const ::rtl::OUString& rMediaPassword,
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::task::XInteractionHandler >& rxInteractHandler,
|
||||
const ::rtl::OUString& rDocumentName,
|
||||
DocPasswordRequestType eRequestType,
|
||||
const ::std::vector< ::rtl::OUString >* pDefaultPasswords = 0,
|
||||
bool* pbIsDefaultPassword = 0 );
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** This helper function tries to find a password for the document
|
||||
described by the passed media descriptor.
|
||||
|
||||
First, the list of default passwords will be tried if provided. This is
|
||||
needed by import filters for external file formats that have to check a
|
||||
predefined password in some cases without asking the user for a
|
||||
password. Every password is checked using the passed password verifier.
|
||||
|
||||
If not successful, the passed media descriptor is asked for a password,
|
||||
that has been set e.g. by an API call to load a document. If existing,
|
||||
the password is checked using the passed password verifier.
|
||||
|
||||
If still not successful, the interaction handler contained in the
|
||||
passed nmedia descriptor is used to request a password from the user.
|
||||
This will be repeated until the passed password verifier validates the
|
||||
entered password, or if the user chooses to cancel password input.
|
||||
|
||||
@param rVerifier
|
||||
The password verifier used to check every processed password.
|
||||
|
||||
@param rMediaDesc
|
||||
The media descriptor of the document that needs to be opened with
|
||||
a password. If a valid password (that is not contained in the
|
||||
passed list of default passwords) was found, it will be inserted
|
||||
into the "Password" property of this descriptor.
|
||||
|
||||
@param eRequestType
|
||||
The password request type that will be passed to the
|
||||
DocPasswordRequest object created internally. See
|
||||
docpasswordrequest.hxx for more details.
|
||||
|
||||
@param pDefaultPasswords
|
||||
If not null, contains default passwords that will be tried before a
|
||||
password will be requested from the media descriptor or the user.
|
||||
|
||||
@return
|
||||
If not empty, contains the password that has been validated by the
|
||||
passed password verifier. If empty, no valid password has been
|
||||
found, or the user has chossen to cancel password input.
|
||||
*/
|
||||
static ::rtl::OUString requestAndVerifyDocPassword(
|
||||
IDocPasswordVerifier& rVerifier,
|
||||
MediaDescriptor& rMediaDesc,
|
||||
DocPasswordRequestType eRequestType,
|
||||
const ::std::vector< ::rtl::OUString >* pDefaultPasswords = 0 );
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
private:
|
||||
~DocPasswordHelper();
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
||||
} // namespace comphelper
|
||||
|
||||
#endif
|
||||
|
91
comphelper/inc/comphelper/docpasswordrequest.hxx
Normal file
91
comphelper/inc/comphelper/docpasswordrequest.hxx
Normal file
@ -0,0 +1,91 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: docpasswordrequest.hxx,v $
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef COMPHELPER_DOCPASSWORDREQUEST_HXX
|
||||
#define COMPHELPER_DOCPASSWORDREQUEST_HXX
|
||||
|
||||
#include "comphelper/comphelperdllapi.h"
|
||||
#include <com/sun/star/task/PasswordRequestMode.hpp>
|
||||
#include <com/sun/star/task/XInteractionRequest.hpp>
|
||||
#include <cppuhelper/implbase1.hxx>
|
||||
|
||||
namespace comphelper {
|
||||
|
||||
// ============================================================================
|
||||
|
||||
/** Selects which UNO document password request type to use. */
|
||||
enum DocPasswordRequestType
|
||||
{
|
||||
DocPasswordRequestType_STANDARD, /// Uses the standard com.sun.star.task.DocumentPasswordRequest request.
|
||||
DocPasswordRequestType_MS /// Uses the com.sun.star.task.DocumentMSPasswordRequest request.
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
||||
class AbortContinuation;
|
||||
class PasswordContinuation;
|
||||
|
||||
/** Implements the task.XInteractionRequest interface for requesting a password
|
||||
string for a document.
|
||||
*/
|
||||
class COMPHELPER_DLLPUBLIC DocPasswordRequest : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
|
||||
{
|
||||
public:
|
||||
explicit DocPasswordRequest(
|
||||
DocPasswordRequestType eType,
|
||||
::com::sun::star::task::PasswordRequestMode eMode,
|
||||
const ::rtl::OUString& rDocumentName );
|
||||
virtual ~DocPasswordRequest();
|
||||
|
||||
bool isAbort() const;
|
||||
bool isPassword() const;
|
||||
::rtl::OUString getPassword() const;
|
||||
|
||||
private:
|
||||
virtual ::com::sun::star::uno::Any SAL_CALL
|
||||
getRequest() throw( ::com::sun::star::uno::RuntimeException );
|
||||
|
||||
virtual ::com::sun::star::uno::Sequence<
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL
|
||||
getContinuations() throw( ::com::sun::star::uno::RuntimeException );
|
||||
|
||||
private:
|
||||
::com::sun::star::uno::Any maRequest;
|
||||
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > maContinuations;
|
||||
AbortContinuation* mpAbort;
|
||||
PasswordContinuation* mpPassword;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
||||
} // namespace comphelper
|
||||
|
||||
#endif
|
||||
|
@ -74,8 +74,10 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap
|
||||
does not work as expected under windows (under unix it works as well)
|
||||
these way must be used :-(
|
||||
*/
|
||||
static const ::rtl::OUString& PROP_ABORTED();
|
||||
static const ::rtl::OUString& PROP_ASTEMPLATE();
|
||||
static const ::rtl::OUString& PROP_CHARACTERSET();
|
||||
static const ::rtl::OUString& PROP_COMPONENTDATA();
|
||||
static const ::rtl::OUString& PROP_DEEPDETECTION();
|
||||
static const ::rtl::OUString& PROP_DETECTSERVICE();
|
||||
static const ::rtl::OUString& PROP_DOCUMENTSERVICE();
|
||||
|
@ -79,10 +79,19 @@ COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XI
|
||||
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArgs
|
||||
) SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) );
|
||||
|
||||
/**
|
||||
* This function gets the process service factory's default component context.
|
||||
* If no service factory is set the function returns a null interface.
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
|
||||
getProcessComponentContext();
|
||||
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
/// @internal
|
||||
/// @internal ATTENTION returns ACQUIRED pointer! release it explicitly!
|
||||
COMPHELPER_DLLPUBLIC
|
||||
::com::sun::star::uno::XComponentContext *
|
||||
comphelper_getProcessComponentContext();
|
||||
|
@ -169,21 +169,20 @@ template <bool> struct with_args;
|
||||
|
||||
/// @internal
|
||||
namespace detail {
|
||||
|
||||
template <typename ImplT>
|
||||
class ServiceImpl
|
||||
: public ::cppu::ImplInheritanceHelper1<ImplT, css::lang::XServiceInfo>,
|
||||
class OwnServiceImpl
|
||||
: public ImplT,
|
||||
private ::boost::noncopyable
|
||||
{
|
||||
typedef ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> BaseT;
|
||||
typedef ImplT BaseT;
|
||||
|
||||
public:
|
||||
ServiceImpl(
|
||||
OwnServiceImpl(
|
||||
ServiceDecl const& rServiceDecl,
|
||||
css::uno::Sequence<css::uno::Any> const& args,
|
||||
css::uno::Reference<css::uno::XComponentContext> const& xContext )
|
||||
: BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {}
|
||||
ServiceImpl(
|
||||
:BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {}
|
||||
OwnServiceImpl(
|
||||
ServiceDecl const& rServiceDecl,
|
||||
css::uno::Reference<css::uno::XComponentContext> const& xContext )
|
||||
: BaseT(xContext), m_rServiceDecl(rServiceDecl) {}
|
||||
@ -206,6 +205,22 @@ private:
|
||||
ServiceDecl const& m_rServiceDecl;
|
||||
};
|
||||
|
||||
template <typename ImplT>
|
||||
class ServiceImpl : public OwnServiceImpl< ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> >
|
||||
{
|
||||
typedef OwnServiceImpl< ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> > ServiceImpl_BASE;
|
||||
public:
|
||||
ServiceImpl(
|
||||
ServiceDecl const& rServiceDecl,
|
||||
css::uno::Sequence<css::uno::Any> const& args,
|
||||
css::uno::Reference<css::uno::XComponentContext> const& xContext )
|
||||
: ServiceImpl_BASE(rServiceDecl, args, xContext) {}
|
||||
ServiceImpl(
|
||||
ServiceDecl const& rServiceDecl,
|
||||
css::uno::Reference<css::uno::XComponentContext> const& xContext )
|
||||
: ServiceImpl_BASE(rServiceDecl, xContext) {}
|
||||
};
|
||||
|
||||
template <typename ServiceImplT>
|
||||
struct PostProcessDefault {
|
||||
css::uno::Reference<css::uno::XInterface>
|
||||
@ -230,7 +245,7 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<false> > {
|
||||
const& xContext ) const
|
||||
{
|
||||
return m_postProcessFunc(
|
||||
new ServiceImpl<ImplT>( rServiceDecl, xContext ) );
|
||||
new ImplT( rServiceDecl, xContext ) );
|
||||
}
|
||||
};
|
||||
|
||||
@ -247,7 +262,7 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<true> > {
|
||||
const& xContext ) const
|
||||
{
|
||||
return m_postProcessFunc(
|
||||
new ServiceImpl<ImplT>( rServiceDecl, args, xContext ) );
|
||||
new ImplT( rServiceDecl, args, xContext ) );
|
||||
}
|
||||
};
|
||||
|
||||
@ -261,18 +276,17 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<true> > {
|
||||
or just (uno::Reference<uno::XComponentContext>)
|
||||
*/
|
||||
template <typename ImplT_, typename WithArgsT = with_args<false> >
|
||||
struct class_ {
|
||||
struct serviceimpl_base {
|
||||
typedef ImplT_ ImplT;
|
||||
typedef detail::ServiceImpl<ImplT_> ServiceImplT;
|
||||
|
||||
detail::CreateFuncF const m_createFunc;
|
||||
|
||||
typedef detail::PostProcessDefault<ServiceImplT> PostProcessDefaultT;
|
||||
typedef detail::PostProcessDefault<ImplT> PostProcessDefaultT;
|
||||
|
||||
/** Default ctor. Implementation class without args, expecting
|
||||
component context as single argument.
|
||||
*/
|
||||
class_() : m_createFunc(
|
||||
serviceimpl_base() : m_createFunc(
|
||||
detail::CreateFunc<ImplT, PostProcessDefaultT, WithArgsT>(
|
||||
PostProcessDefaultT() ) ) {}
|
||||
|
||||
@ -284,11 +298,29 @@ struct class_ {
|
||||
uno::Reference<uno::XInterface>
|
||||
*/
|
||||
template <typename PostProcessFuncT>
|
||||
explicit class_( PostProcessFuncT const& postProcessFunc )
|
||||
explicit serviceimpl_base( PostProcessFuncT const& postProcessFunc )
|
||||
: m_createFunc( detail::CreateFunc<ImplT, PostProcessFuncT, WithArgsT>(
|
||||
postProcessFunc ) ) {}
|
||||
};
|
||||
|
||||
template <typename ImplT_, typename WithArgsT = with_args<false> >
|
||||
struct class_ : public serviceimpl_base< detail::ServiceImpl<ImplT_>, WithArgsT >
|
||||
{
|
||||
typedef serviceimpl_base< detail::ServiceImpl<ImplT_>, WithArgsT > baseT;
|
||||
/** Default ctor. Implementation class without args, expecting
|
||||
component context as single argument.
|
||||
*/
|
||||
class_() : baseT() {}
|
||||
template <typename PostProcessFuncT>
|
||||
/** Ctor to pass a post processing function/functor.
|
||||
|
||||
@tpl PostProcessDefaultT let your compiler deduce this
|
||||
@param postProcessFunc function/functor that gets the yet unacquired
|
||||
ImplT_ pointer returning a
|
||||
uno::Reference<uno::XInterface>
|
||||
*/
|
||||
explicit class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {}
|
||||
};
|
||||
|
||||
//
|
||||
// component_... helpers with arbitrary service declarations:
|
||||
|
@ -49,6 +49,7 @@
|
||||
|
||||
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <com/sun/star/uno/Reference.hxx>
|
||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||
|
||||
@ -191,6 +192,59 @@ inline mem_fun1_t<_Tp,_Arg> mem_fun(void (_Tp::*__f)(_Arg))
|
||||
return mem_fun1_t<_Tp,_Arg>(__f);
|
||||
}
|
||||
|
||||
//.........................................................................
|
||||
/** output iterator that appends OUStrings into an OUStringBuffer.
|
||||
*/
|
||||
class OUStringBufferAppender :
|
||||
public ::std::iterator< ::std::output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
public:
|
||||
typedef OUStringBufferAppender Self;
|
||||
typedef ::std::output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void reference;
|
||||
typedef void pointer;
|
||||
typedef size_t difference_type;
|
||||
|
||||
OUStringBufferAppender(::rtl::OUStringBuffer & i_rBuffer)
|
||||
: m_rBuffer(i_rBuffer) { }
|
||||
Self & operator=(::rtl::OUString const & i_rStr)
|
||||
{
|
||||
m_rBuffer.append( i_rStr );
|
||||
return *this;
|
||||
}
|
||||
Self & operator*() { return *this; } // so operator= works
|
||||
Self & operator++() { return *this; }
|
||||
Self & operator++(int) { return *this; }
|
||||
|
||||
private:
|
||||
::rtl::OUStringBuffer & m_rBuffer;
|
||||
};
|
||||
|
||||
//.........................................................................
|
||||
/** algorithm similar to std::copy, but inserts a separator between elements.
|
||||
*/
|
||||
template< typename ForwardIter, typename OutputIter, typename T >
|
||||
OutputIter intersperse(
|
||||
ForwardIter start, ForwardIter end, OutputIter out, T const & separator)
|
||||
{
|
||||
if (start != end) {
|
||||
*out = *start;
|
||||
++start;
|
||||
++out;
|
||||
}
|
||||
|
||||
while (start != end) {
|
||||
*out = separator;
|
||||
++out;
|
||||
*out = *start;
|
||||
++start;
|
||||
++out;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
//.........................................................................
|
||||
}
|
||||
//... namespace comphelper ................................................
|
||||
|
@ -5,9 +5,9 @@
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: stlunosequence.hxx,v $
|
||||
* $RCSfile: $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
@ -31,457 +31,59 @@
|
||||
#define _COMPHELPER_STLUNOITERATOR_HXX
|
||||
|
||||
#include <com/sun/star/uno/Sequence.hxx>
|
||||
#include <iterator>
|
||||
#include <sal/types.h>
|
||||
|
||||
namespace comphelper { namespace stlunosequence {
|
||||
template<typename S, typename V>
|
||||
class StlSequence;
|
||||
|
||||
template<typename S, typename V>
|
||||
class StlSequenceIterator : public std::iterator<std::random_access_iterator_tag, V, sal_Int32>
|
||||
{
|
||||
public:
|
||||
typedef ::std::random_access_iterator_tag iterator_category;
|
||||
typedef V& reference;
|
||||
typedef V value_type;
|
||||
typedef sal_Int32 difference_type;
|
||||
typedef V* pointer;
|
||||
typedef const V& const_reference;
|
||||
|
||||
StlSequenceIterator();
|
||||
StlSequenceIterator(S * uno_sequence, typename StlSequenceIterator<S,V>::difference_type index);
|
||||
|
||||
reference operator*() const;
|
||||
StlSequenceIterator<S,V>& operator++();
|
||||
StlSequenceIterator<S,V> operator++(int);
|
||||
StlSequenceIterator<S,V>& operator--();
|
||||
StlSequenceIterator<S,V> operator--(int);
|
||||
StlSequenceIterator<S,V>& operator+=(const typename StlSequenceIterator<S,V>::difference_type by);
|
||||
StlSequenceIterator<S,V>& operator-=(const typename StlSequenceIterator<S,V>::difference_type by);
|
||||
StlSequenceIterator<S,V> operator+(const typename StlSequenceIterator<S,V>::difference_type by) const;
|
||||
StlSequenceIterator<S,V> operator-(const typename StlSequenceIterator<S,V>::difference_type by) const;
|
||||
typename StlSequenceIterator<S,V>::difference_type operator-(const StlSequenceIterator<S,V>& to) const;
|
||||
|
||||
bool operator==(const StlSequenceIterator<S,V>& other) const;
|
||||
bool operator!=(const StlSequenceIterator<S,V>& other) const;
|
||||
bool operator<(const StlSequenceIterator<S,V>& other) const;
|
||||
reference operator[](const typename StlSequenceIterator<S,V>::difference_type by) const;
|
||||
|
||||
|
||||
protected:
|
||||
friend class StlSequence<S,V>;
|
||||
S * m_UnoSequence;
|
||||
typename StlSequenceIterator<S,V>::difference_type m_Index;
|
||||
};
|
||||
|
||||
template<typename S, typename V>
|
||||
class StlSequenceConstIterator : public StlSequenceIterator<S,V>
|
||||
{
|
||||
public:
|
||||
typedef const V& reference;
|
||||
StlSequenceConstIterator();
|
||||
StlSequenceConstIterator(S * uno_sequence, typename StlSequenceIterator<S,V>::difference_type by);
|
||||
typename StlSequenceIterator<S,V>::const_reference operator*() const
|
||||
{
|
||||
return (*(this->m_UnoSequence))[this->m_Index];
|
||||
}
|
||||
|
||||
typename StlSequenceIterator<S,V>::const_reference operator[](const typename StlSequenceIterator<S,V>::difference_type by) const
|
||||
{
|
||||
return (*(this->m_UnoSequence))[this->m_Index+by];
|
||||
}
|
||||
};
|
||||
|
||||
template<typename S, typename V>
|
||||
class StlSequence
|
||||
{
|
||||
public:
|
||||
typedef sal_Int32 size_type;
|
||||
typedef V& reference;
|
||||
typedef const V& const_reference;
|
||||
typedef sal_Int32 difference_type;
|
||||
typedef V value_type;
|
||||
typedef StlSequenceIterator<S,V> iterator;
|
||||
typedef StlSequenceConstIterator<S,V> const_iterator;
|
||||
|
||||
StlSequence(S& uno_sequence);
|
||||
|
||||
typename StlSequence<S,V>::size_type size() const;
|
||||
typename StlSequence<S,V>::size_type max_size() const;
|
||||
bool empty() const;
|
||||
void swap(StlSequence<S,V>& other);
|
||||
typename StlSequence<S,V>::iterator begin();
|
||||
typename StlSequence<S,V>::iterator end();
|
||||
typename StlSequence<S,V>::const_iterator begin() const;
|
||||
typename StlSequence<S,V>::const_iterator end() const;
|
||||
|
||||
bool operator==(const StlSequence<S,V>& other) const;
|
||||
bool operator!=(const StlSequence<S,V>& other) const;
|
||||
bool operator<(const StlSequence<S,V>& other) const;
|
||||
bool operator>(const StlSequence<S,V>& other) const;
|
||||
bool operator<=(const StlSequence<S,V>& other) const;
|
||||
bool operator>=(const StlSequence<S,V>& other) const;
|
||||
|
||||
|
||||
private:
|
||||
friend class StlSequenceIterator<S,V>;
|
||||
S * m_UnoSequence;
|
||||
static const typename StlSequence<S,V>::size_type begin_of_sequence;
|
||||
static const typename StlSequence<S,V>::size_type end_of_sequence;
|
||||
};
|
||||
|
||||
//StlSequenceIterator
|
||||
template<typename S, typename V>
|
||||
StlSequenceIterator<S,V>::StlSequenceIterator()
|
||||
: m_UnoSequence(0), m_Index(StlSequence<S,V>::end_of_sequence)
|
||||
{}
|
||||
|
||||
template<typename S, typename V>
|
||||
StlSequenceConstIterator<S,V>::StlSequenceConstIterator()
|
||||
{}
|
||||
|
||||
template<typename S, typename V>
|
||||
StlSequenceIterator<S, V>::StlSequenceIterator(S * uno_sequence, typename StlSequenceIterator<S,V>::difference_type index)
|
||||
: m_UnoSequence(uno_sequence), m_Index(index)
|
||||
{}
|
||||
|
||||
template<typename S, typename V>
|
||||
StlSequenceConstIterator<S, V>::StlSequenceConstIterator(S * uno_sequence, typename StlSequenceIterator<S,V>::difference_type index)
|
||||
: StlSequenceIterator<S,V>(uno_sequence, index)
|
||||
{}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline typename StlSequenceIterator<S,V>::reference StlSequenceIterator<S, V>::operator*() const
|
||||
{
|
||||
return (*m_UnoSequence)[m_Index];
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline StlSequenceIterator<S,V>& StlSequenceIterator<S, V>::operator++()
|
||||
{
|
||||
++m_Index;
|
||||
if(m_Index>=m_UnoSequence->getLength())
|
||||
m_Index = StlSequence<S,V>::end_of_sequence;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline StlSequenceIterator<S,V> StlSequenceIterator<S, V>::operator++(int)
|
||||
{
|
||||
StlSequenceIterator<S,V> temp = *this;
|
||||
++*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline StlSequenceIterator<S,V>& StlSequenceIterator<S, V>::operator--()
|
||||
{
|
||||
if(m_Index==StlSequence<S,V>::end_of_sequence)
|
||||
m_Index = m_UnoSequence->getLength();
|
||||
--m_Index;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline StlSequenceIterator<S,V> StlSequenceIterator<S, V>::operator--(int)
|
||||
{
|
||||
StlSequenceIterator<S,V> temp = *this;
|
||||
--*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline StlSequenceIterator<S,V>& StlSequenceIterator<S, V>::operator+=(const typename StlSequenceIterator<S,V>::difference_type by)
|
||||
{
|
||||
if(by<0)
|
||||
{
|
||||
this->operator-=(-by);
|
||||
return *this;
|
||||
}
|
||||
if(by==0)
|
||||
return *this;
|
||||
m_Index+=by;
|
||||
if(m_Index>=m_UnoSequence->getLength())
|
||||
m_Index=StlSequence<S,V>::end_of_sequence;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline StlSequenceIterator<S,V>& StlSequenceIterator<S, V>::operator-=(const typename StlSequenceIterator<S,V>::difference_type by)
|
||||
{
|
||||
if(by<0)
|
||||
{
|
||||
if(-by==by) return *this; // breaking infinitive loop on MIN_INT
|
||||
this->operator+=(-by);
|
||||
return *this;
|
||||
}
|
||||
if(by==0)
|
||||
return *this;
|
||||
if(m_Index==StlSequence<S,V>::end_of_sequence)
|
||||
m_Index=m_UnoSequence->getLength();
|
||||
m_Index-=by;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline StlSequenceIterator<S,V> StlSequenceIterator<S, V>::operator+(const typename StlSequenceIterator<S,V>::difference_type by) const
|
||||
{
|
||||
StlSequenceIterator<S,V> result = StlSequenceIterator<S,V>(*this);
|
||||
result+=by;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline StlSequenceIterator<S,V> StlSequenceIterator<S, V>::operator-(const typename StlSequenceIterator<S,V>::difference_type by) const
|
||||
{
|
||||
StlSequenceIterator<S,V> result = StlSequenceIterator<S,V>(*this);
|
||||
result-=by;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline typename StlSequenceIterator<S,V>::difference_type StlSequenceIterator<S, V>::operator-(const StlSequenceIterator<S,V>& to) const
|
||||
{
|
||||
if(m_Index==StlSequence<S,V>::end_of_sequence ^ to.m_Index==StlSequence<S,V>::end_of_sequence)
|
||||
{
|
||||
if(m_Index==StlSequence<S,V>::end_of_sequence)
|
||||
return m_UnoSequence->getLength()-to.m_Index;
|
||||
else
|
||||
return m_Index-m_UnoSequence->getLength();
|
||||
}
|
||||
return m_Index-to.m_Index;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequenceIterator<S, V>::operator==(const StlSequenceIterator<S,V>& other) const
|
||||
{
|
||||
return (m_Index == other.m_Index);
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequenceIterator<S, V>::operator!=(const StlSequenceIterator<S,V>& other) const
|
||||
{
|
||||
return !this->operator==(other);
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequenceIterator<S, V>::operator<(const StlSequenceIterator<S,V>& other) const
|
||||
{
|
||||
if(m_Index==StlSequence<S,V>::end_of_sequence ^ other.m_Index==StlSequence<S,V>::end_of_sequence)
|
||||
return other.m_Index==StlSequence<S,V>::end_of_sequence;
|
||||
return m_Index<other.m_Index;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline typename StlSequenceIterator<S,V>::reference StlSequenceIterator<S, V>::operator[](const typename StlSequenceIterator<S,V>::difference_type by) const
|
||||
{
|
||||
return (*(this->m_UnoSequence))[this->m_Index+by];
|
||||
}
|
||||
|
||||
// StlSequence
|
||||
template<typename S, typename V>
|
||||
StlSequence<S,V>::StlSequence(S& uno_sequence)
|
||||
: m_UnoSequence(&uno_sequence)
|
||||
{}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline typename StlSequence<S,V>::size_type StlSequence<S,V>::size() const
|
||||
{
|
||||
return m_UnoSequence->getLength();
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline typename StlSequence<S,V>::size_type StlSequence<S,V>::max_size() const
|
||||
{
|
||||
return this->size();
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequence<S,V>::empty() const
|
||||
{
|
||||
return this->size() == 0;
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline void StlSequence<S,V>::swap(StlSequence<S,V>& other)
|
||||
{
|
||||
::std::swap(*this, other);
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline typename StlSequence<S,V>::iterator StlSequence<S,V>::begin()
|
||||
{
|
||||
return typename StlSequence<S,V>::iterator(m_UnoSequence, begin_of_sequence);
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline typename StlSequence<S,V>::iterator StlSequence<S,V>::end()
|
||||
{
|
||||
return typename StlSequence<S,V>::iterator(m_UnoSequence, end_of_sequence);
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline typename StlSequence<S,V>::const_iterator StlSequence<S,V>::begin() const
|
||||
{
|
||||
return typename StlSequence<S,V>::const_iterator(m_UnoSequence, begin_of_sequence);
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline typename StlSequence<S,V>::const_iterator StlSequence<S,V>::end() const
|
||||
{
|
||||
return typename StlSequence<S,V>::const_iterator(m_UnoSequence, end_of_sequence);
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequence<S,V>::operator==(const StlSequence<S,V>& other) const
|
||||
{
|
||||
if(this->size() != other.size()) return false;
|
||||
return ::std::equal(this->begin(), this->end(), other.begin());
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequence<S,V>::operator<(const StlSequence<S,V>& other) const
|
||||
{
|
||||
return ::std::lexicographical_compare(this->begin(), this->end(), other.begin(), other.end());
|
||||
}
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequence<S,V>::operator!=(const StlSequence<S,V>& other) const
|
||||
{ return !(*this == other); }
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequence<S,V>::operator>(const StlSequence<S,V>& other) const
|
||||
{ return (other < *this); }
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequence<S,V>::operator<=(const StlSequence<S,V>& other) const
|
||||
{ return !(other < *this); }
|
||||
|
||||
template<typename S, typename V>
|
||||
inline bool StlSequence<S,V>::operator>=(const StlSequence<S,V>& other) const
|
||||
{ return !(*this < other); }
|
||||
|
||||
template<typename S, typename V>
|
||||
const typename StlSequence<S,V>::size_type StlSequence<S,V>::begin_of_sequence = 0;
|
||||
|
||||
template<typename S, typename V>
|
||||
const typename StlSequence<S,V>::size_type StlSequence<S,V>::end_of_sequence = -1;
|
||||
}}
|
||||
|
||||
|
||||
namespace comphelper
|
||||
{
|
||||
/**
|
||||
@short a wrapper-class that provides stl-container-like access to an existing
|
||||
::com::sun::star::uno::Sequence
|
||||
@descr This template class allows using an existing ::com::sun::star::uno::Sequence
|
||||
like any other stl container. It provides standard-compliant mutable random access
|
||||
iterators. Because random access iterators are the most generic iterators defined
|
||||
by the stl, any stl algorithm can be applied to the Sequence.
|
||||
<p>
|
||||
This is just a basic stl forward container, but _not_ an stl sequence (the size of the
|
||||
::com::sun::star::uno::Sequence cannot be changed using the StlUnoSequence interface).
|
||||
Inserts are expensive operations on ::com::sun::star::uno::Sequence - use
|
||||
::std::copy() to a efficient stl container implementing the stl sequence interface
|
||||
and the available insert iterator adapters you need those.
|
||||
<p>
|
||||
@attention There is one requirement of an stl container that this class does not meet:
|
||||
It is _not_ owner of its contents and thus it does not destroy its contents when destructed.
|
||||
@attention No additional boundschecking over the requirements of the STL are performed.
|
||||
E.g. sequence.begin()-- results in undefined behavior.
|
||||
@attention StlUnoSequence is not threadsafe.
|
||||
<p>
|
||||
Example: (creating a ::std::list from a ::com::sun::star::uno::Sequence)
|
||||
<code>
|
||||
::com::sun::star::uno::Sequence<sal_Int32> uno_seq(10);
|
||||
::comphelper::StlUnoSequence<sal_Int32> stl_seq(&uno_seq);
|
||||
::std::list stl_list(stl_seq.begin(), stl_seq.end());
|
||||
</code>
|
||||
<p>
|
||||
Example: (sorting ::com::sun::star::uno::Sequence inplace)
|
||||
<code>
|
||||
::com::sun::star::uno::Sequence<sal_Int32> uno_seq(10);
|
||||
::comphelper::StlUnoSequence<sal_Int32> stl_seq(&uno_seq);
|
||||
::std::sort(stl_seq.begin(), stl_seq.end());
|
||||
</code>
|
||||
<p>
|
||||
Example: (counting occurrences of 4711 in a ::com::sun::star::uno::Sequence)
|
||||
<code>
|
||||
::com::sun::star::uno::Sequence<sal_Int32> uno_seq(10);
|
||||
::comphelper::StlUnoSequence<sal_Int32> stl_seq(&uno_seq);
|
||||
sal_Int32 count = 0;
|
||||
::std::count(stl_seq.begin(), stl_seq.end(), 4711, count);
|
||||
</code>
|
||||
<p>
|
||||
Example: (inserting the second half of one Sequence after the first element of another)
|
||||
<code>
|
||||
::com::sun::star::uno::Sequence<sal_Int32> uno_seq1(10);
|
||||
::com::sun::star::uno::Sequence<sal_Int32> uno_seq2(10);
|
||||
::com::sun::star::uno::Sequence<sal_Int32> result(15);
|
||||
::comphelper::StlUnoSequence<sal_Int32> stl_seq1(&uno_seq1);
|
||||
::comphelper::StlUnoSequence<sal_Int32> stl_seq2(&uno_seq1);
|
||||
::comphelper::StlUnoSequence<sal_Int32> stl_result(&result);
|
||||
::std::list<sal_Int32> temp(uno_seq1.begin(), uno_seq1.end());
|
||||
::std::copy(uno_seq2.begin()+5, uno_seq2.end(), ::std::insert_iterator< ::std::list<sal_Int32> >(temp, ++temp.begin()));
|
||||
::std::copy(temp.begin(), temp.end(), result.begin());
|
||||
</code>
|
||||
@short stl-container-like access to an existing ::com::sun::star::uno::Sequence
|
||||
@descr These template functions allows using an existing
|
||||
::com::sun::star::uno::Sequence using stl algorithms. They provides
|
||||
standard-compliant mutable random access iterators. Because random access
|
||||
iterators are the most generic iterators defined by the stl, any stl algorithm
|
||||
can be applied to the Sequence (excluding algorithms requiring output
|
||||
iterators).
|
||||
<p>
|
||||
Example: (creating a ::std::list from a ::com::sun::star::uno::Sequence)
|
||||
<code>
|
||||
::com::sun::star::uno::Sequence<sal_Int32> aSeq(10);
|
||||
::std::list stl_list(stl_begin(aSeq), stl_end(aSeq));
|
||||
</code>
|
||||
<p>
|
||||
Example: (sorting ::com::sun::star::uno::Sequence inplace)
|
||||
<code>
|
||||
::com::sun::star::uno::Sequence<sal_Int32> aSeq(10);
|
||||
::std::sort(stl_begin(aSeq), stl_seq.end(aSeq));
|
||||
</code>
|
||||
<p>
|
||||
Example: (counting occurrences of 4711 in a ::com::sun::star::uno::Sequence)
|
||||
<code>
|
||||
::com::sun::star::uno::Sequence<sal_Int32> aSeq(10);
|
||||
sal_Int32 count = 0;
|
||||
::std::count(stl_begin(aSeq), stl_end(aSeq), 4711, count);
|
||||
</code>
|
||||
<p>
|
||||
|
||||
@see http://www.sgi.com/tech/stl/Container.html
|
||||
@see http://www.sgi.com/tech/stl/Sequence.html
|
||||
@see http://www.sgi.com/tech/stl/RandomAccessIterator.html
|
||||
@see http://www.sgi.com/tech/stl/Container.html
|
||||
@see http://www.sgi.com/tech/stl/Sequence.html
|
||||
@see http://www.sgi.com/tech/stl/RandomAccessIterator.html
|
||||
*/
|
||||
|
||||
template <typename V>
|
||||
class StlUnoSequence : public stlunosequence::StlSequence< ::com::sun::star::uno::Sequence<V>, V>
|
||||
{
|
||||
public:
|
||||
/*
|
||||
@short named constructor (these are needed to keep const-correctness)
|
||||
*/
|
||||
static StlUnoSequence<V> createInstance(::com::sun::star::uno::Sequence<V>& uno_sequence)
|
||||
{ return StlUnoSequence<V>(uno_sequence); }
|
||||
/*
|
||||
@short named constructor (these are needed to keep const-correctness)
|
||||
*/
|
||||
static const StlUnoSequence<V> createInstance(const ::com::sun::star::uno::Sequence<V>& uno_sequence)
|
||||
{ return StlUnoSequence<V>(const_cast< ::com::sun::star::uno::Sequence<V>& >(uno_sequence)); }
|
||||
private:
|
||||
StlUnoSequence(::com::sun::star::uno::Sequence<V>& uno_sequence)
|
||||
: stlunosequence::StlSequence< ::com::sun::star::uno::Sequence<V>, V>(uno_sequence)
|
||||
{}
|
||||
};
|
||||
V* stl_begin(::com::sun::star::uno::Sequence<V>& rSeq)
|
||||
{ return rSeq.getArray(); }
|
||||
|
||||
/*
|
||||
@short shortcut for StlUnoSequence<V>::createInstance(uno_sequence).begin()
|
||||
*/
|
||||
template <typename V>
|
||||
typename StlUnoSequence<V>::iterator stl_begin(::com::sun::star::uno::Sequence<V>& uno_sequence)
|
||||
{ return StlUnoSequence<V>::createInstance(uno_sequence).begin(); }
|
||||
V* stl_end(::com::sun::star::uno::Sequence<V>& rSeq)
|
||||
{ return rSeq.getArray() + rSeq.getLength(); }
|
||||
|
||||
/*
|
||||
@short shortcut for StlUnoSequence<V>::createInstance(uno_sequence).end()
|
||||
*/
|
||||
template <typename V>
|
||||
typename StlUnoSequence<V>::iterator stl_end(::com::sun::star::uno::Sequence<V>& uno_sequence)
|
||||
{ return StlUnoSequence<V>::createInstance(uno_sequence).end(); }
|
||||
const V* stl_begin(const ::com::sun::star::uno::Sequence<V>& rSeq)
|
||||
{ return rSeq.getConstArray(); }
|
||||
|
||||
/*
|
||||
@short shortcut for StlUnoSequence<V>::createInstance(uno_sequence).begin()
|
||||
*/
|
||||
template <typename V>
|
||||
typename StlUnoSequence<V>::const_iterator stl_begin(const ::com::sun::star::uno::Sequence<V>& uno_sequence)
|
||||
{
|
||||
return StlUnoSequence<V>::createInstance(uno_sequence).begin();
|
||||
}
|
||||
|
||||
/*
|
||||
@short shortcut for StlUnoSequence<V>::createInstance(uno_sequence).end()
|
||||
*/
|
||||
template <typename V>
|
||||
typename StlUnoSequence<V>::const_iterator stl_end(const ::com::sun::star::uno::Sequence<V>& uno_sequence)
|
||||
{
|
||||
return StlUnoSequence<V>::createInstance(uno_sequence).end();
|
||||
}
|
||||
const V* stl_end(const ::com::sun::star::uno::Sequence<V>& rSeq)
|
||||
{ return rSeq.getConstArray() + rSeq.getLength(); }
|
||||
}
|
||||
#endif
|
||||
|
@ -48,9 +48,6 @@
|
||||
|
||||
namespace comphelper {
|
||||
|
||||
sal_Bool COMPHELPER_DLLPUBLIC IsValidZipEntryFileName(
|
||||
const sal_Unicode *pChar, sal_Int32 nLength, sal_Bool bSlashAllowed );
|
||||
|
||||
class COMPHELPER_DLLPUBLIC OStorageHelper
|
||||
{
|
||||
public:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
#
|
||||
# Copyright 2008 by Sun Microsystems, Inc.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
@ -43,7 +43,7 @@ INCPRE += $(MISC)$/$(TARGET)$/inc
|
||||
|
||||
SHL1TARGET = $(TARGET)_weakbag
|
||||
SHL1OBJS = $(SLO)$/test_weakbag.obj
|
||||
SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(CPPUNITLIB) $(SALLIB)
|
||||
SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(CPPUNITLIB) $(TESTSHL2LIB) $(SALLIB)
|
||||
SHL1VERSIONMAP = version.map
|
||||
SHL1IMPLIB = i$(SHL1TARGET)
|
||||
DEF1NAME = $(SHL1TARGET)
|
||||
@ -55,4 +55,4 @@ SLOFILES = $(SHL1OBJS)
|
||||
ALLTAR: test
|
||||
|
||||
test .PHONY: $(SHL1TARGETN)
|
||||
testshl2 $(SHL1TARGETN)
|
||||
$(TESTSHL2) $(SHL1TARGETN)
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "sal/config.h"
|
||||
|
||||
#include "comphelper/string.hxx"
|
||||
#include "cppunit/simpleheader.hxx"
|
||||
#include "testshl/simpleheader.hxx"
|
||||
#include "rtl/string.h"
|
||||
#include "rtl/ustring.h"
|
||||
#include "rtl/ustring.hxx"
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "com/sun/star/uno/XInterface.hpp"
|
||||
#include "comphelper/weakbag.hxx"
|
||||
#include "cppuhelper/weak.hxx"
|
||||
#include "cppunit/simpleheader.hxx"
|
||||
#include "testshl/simpleheader.hxx"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -39,6 +39,7 @@ extern void createRegistryInfo_AnyCompareFactory();
|
||||
extern void createRegistryInfo_OfficeInstallationDirectories();
|
||||
extern void createRegistryInfo_OInstanceLocker();
|
||||
extern void createRegistryInfo_Map();
|
||||
extern void createRegistryInfo_OSimpleLogRing();
|
||||
|
||||
//........................................................................
|
||||
namespace comphelper { namespace module
|
||||
@ -63,6 +64,7 @@ namespace comphelper { namespace module
|
||||
createRegistryInfo_OfficeInstallationDirectories();
|
||||
createRegistryInfo_OInstanceLocker();
|
||||
createRegistryInfo_Map();
|
||||
createRegistryInfo_OSimpleLogRing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
152
comphelper/source/misc/docpasswordhelper.cxx
Normal file
152
comphelper/source/misc/docpasswordhelper.cxx
Normal file
@ -0,0 +1,152 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: docpasswordhelper.cxx,v $
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_comphelper.hxx"
|
||||
|
||||
#include "comphelper/docpasswordhelper.hxx"
|
||||
#include <com/sun/star/task/XInteractionHandler.hpp>
|
||||
#include "comphelper/mediadescriptor.hxx"
|
||||
|
||||
using ::rtl::OUString;
|
||||
using ::com::sun::star::uno::Exception;
|
||||
using ::com::sun::star::uno::Reference;
|
||||
using ::com::sun::star::uno::UNO_SET_THROW;
|
||||
using ::com::sun::star::task::PasswordRequestMode;
|
||||
using ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER;
|
||||
using ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER;
|
||||
using ::com::sun::star::task::XInteractionHandler;
|
||||
using ::com::sun::star::task::XInteractionRequest;
|
||||
|
||||
namespace comphelper {
|
||||
|
||||
// ============================================================================
|
||||
|
||||
IDocPasswordVerifier::~IDocPasswordVerifier()
|
||||
{
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
/*static*/ OUString DocPasswordHelper::requestAndVerifyDocPassword(
|
||||
IDocPasswordVerifier& rVerifier,
|
||||
const OUString& rMediaPassword,
|
||||
const Reference< XInteractionHandler >& rxInteractHandler,
|
||||
const OUString& rDocumentName,
|
||||
DocPasswordRequestType eRequestType,
|
||||
const ::std::vector< OUString >* pDefaultPasswords,
|
||||
bool* pbIsDefaultPassword )
|
||||
{
|
||||
OUString aPassword;
|
||||
DocPasswordVerifierResult eResult = DocPasswordVerifierResult_WRONG_PASSWORD;
|
||||
|
||||
// first, try provided default passwords
|
||||
if( pbIsDefaultPassword )
|
||||
*pbIsDefaultPassword = false;
|
||||
if( pDefaultPasswords )
|
||||
{
|
||||
for( ::std::vector< OUString >::const_iterator aIt = pDefaultPasswords->begin(), aEnd = pDefaultPasswords->end(); (eResult == DocPasswordVerifierResult_WRONG_PASSWORD) && (aIt != aEnd); ++aIt )
|
||||
{
|
||||
aPassword = *aIt;
|
||||
OSL_ENSURE( aPassword.getLength() > 0, "DocPasswordHelper::requestAndVerifyDocPassword - unexpected empty default password" );
|
||||
if( aPassword.getLength() > 0 )
|
||||
{
|
||||
eResult = rVerifier.verifyPassword( aPassword );
|
||||
if( pbIsDefaultPassword )
|
||||
*pbIsDefaultPassword = eResult == DocPasswordVerifierResult_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try media password (skip, if result is OK or ABORT)
|
||||
if( eResult == DocPasswordVerifierResult_WRONG_PASSWORD )
|
||||
{
|
||||
aPassword = rMediaPassword;
|
||||
if( aPassword.getLength() > 0 )
|
||||
eResult = rVerifier.verifyPassword( aPassword );
|
||||
}
|
||||
|
||||
// request a password (skip, if result is OK or ABORT)
|
||||
if( (eResult == DocPasswordVerifierResult_WRONG_PASSWORD) && rxInteractHandler.is() ) try
|
||||
{
|
||||
PasswordRequestMode eRequestMode = PasswordRequestMode_PASSWORD_ENTER;
|
||||
while( eResult == DocPasswordVerifierResult_WRONG_PASSWORD )
|
||||
{
|
||||
DocPasswordRequest* pRequest = new DocPasswordRequest( eRequestType, eRequestMode, rDocumentName );
|
||||
Reference< XInteractionRequest > xRequest( pRequest );
|
||||
rxInteractHandler->handle( xRequest );
|
||||
if( pRequest->isPassword() )
|
||||
{
|
||||
aPassword = pRequest->getPassword();
|
||||
if( aPassword.getLength() > 0 )
|
||||
eResult = rVerifier.verifyPassword( aPassword );
|
||||
}
|
||||
else
|
||||
{
|
||||
eResult = DocPasswordVerifierResult_ABORT;
|
||||
}
|
||||
eRequestMode = PasswordRequestMode_PASSWORD_REENTER;
|
||||
}
|
||||
}
|
||||
catch( Exception& )
|
||||
{
|
||||
}
|
||||
|
||||
return (eResult == DocPasswordVerifierResult_OK) ? aPassword : OUString();
|
||||
}
|
||||
|
||||
/*static*/ OUString DocPasswordHelper::requestAndVerifyDocPassword(
|
||||
IDocPasswordVerifier& rVerifier,
|
||||
MediaDescriptor& rMediaDesc,
|
||||
DocPasswordRequestType eRequestType,
|
||||
const ::std::vector< OUString >* pDefaultPasswords )
|
||||
{
|
||||
OUString aMediaPassword = rMediaDesc.getUnpackedValueOrDefault(
|
||||
MediaDescriptor::PROP_PASSWORD(), OUString() );
|
||||
Reference< XInteractionHandler > xInteractHandler = rMediaDesc.getUnpackedValueOrDefault(
|
||||
MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() );
|
||||
OUString aDocumentName = rMediaDesc.getUnpackedValueOrDefault(
|
||||
MediaDescriptor::PROP_URL(), OUString() );
|
||||
|
||||
bool bIsDefaultPassword = false;
|
||||
OUString aPassword = requestAndVerifyDocPassword(
|
||||
rVerifier, aMediaPassword, xInteractHandler, aDocumentName, eRequestType, pDefaultPasswords, &bIsDefaultPassword );
|
||||
|
||||
// insert valid password into media descriptor (but not a default password)
|
||||
if( (aPassword.getLength() > 0) && !bIsDefaultPassword )
|
||||
rMediaDesc[ MediaDescriptor::PROP_PASSWORD() ] <<= aPassword;
|
||||
|
||||
return aPassword;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
} // namespace comphelper
|
||||
|
153
comphelper/source/misc/docpasswordrequest.cxx
Normal file
153
comphelper/source/misc/docpasswordrequest.cxx
Normal file
@ -0,0 +1,153 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: docpasswordrequest.cxx,v $
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_comphelper.hxx"
|
||||
|
||||
#include "comphelper/docpasswordrequest.hxx"
|
||||
#include <com/sun/star/task/DocumentMSPasswordRequest.hpp>
|
||||
#include <com/sun/star/task/DocumentPasswordRequest.hpp>
|
||||
#include <com/sun/star/task/XInteractionAbort.hpp>
|
||||
#include <com/sun/star/task/XInteractionPassword.hpp>
|
||||
|
||||
using ::rtl::OUString;
|
||||
using ::com::sun::star::uno::Any;
|
||||
using ::com::sun::star::uno::Reference;
|
||||
using ::com::sun::star::uno::RuntimeException;
|
||||
using ::com::sun::star::uno::Sequence;
|
||||
using ::com::sun::star::uno::XInterface;
|
||||
using ::com::sun::star::task::InteractionClassification_QUERY;
|
||||
using ::com::sun::star::task::DocumentMSPasswordRequest;
|
||||
using ::com::sun::star::task::DocumentPasswordRequest;
|
||||
using ::com::sun::star::task::PasswordRequestMode;
|
||||
using ::com::sun::star::task::XInteractionAbort;
|
||||
using ::com::sun::star::task::XInteractionContinuation;
|
||||
using ::com::sun::star::task::XInteractionPassword;
|
||||
|
||||
namespace comphelper {
|
||||
|
||||
// ============================================================================
|
||||
|
||||
class AbortContinuation : public ::cppu::WeakImplHelper1< XInteractionAbort >
|
||||
{
|
||||
public:
|
||||
inline explicit AbortContinuation() : mbSelected( false ) {}
|
||||
|
||||
inline bool isSelected() const { return mbSelected; }
|
||||
inline void reset() { mbSelected = false; }
|
||||
|
||||
virtual void SAL_CALL select() throw( RuntimeException ) { mbSelected = true; }
|
||||
|
||||
private:
|
||||
bool mbSelected;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
||||
class PasswordContinuation : public ::cppu::WeakImplHelper1< XInteractionPassword >
|
||||
{
|
||||
public:
|
||||
inline explicit PasswordContinuation() : mbSelected( false ) {}
|
||||
|
||||
inline bool isSelected() const { return mbSelected; }
|
||||
inline void reset() { mbSelected = false; }
|
||||
|
||||
virtual void SAL_CALL select() throw( RuntimeException ) { mbSelected = true; }
|
||||
virtual void SAL_CALL setPassword( const OUString& rPass ) throw( RuntimeException ) { maPassword = rPass; }
|
||||
virtual OUString SAL_CALL getPassword() throw( RuntimeException ) { return maPassword; }
|
||||
|
||||
private:
|
||||
OUString maPassword;
|
||||
bool mbSelected;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
||||
DocPasswordRequest::DocPasswordRequest( DocPasswordRequestType eType,
|
||||
PasswordRequestMode eMode, const OUString& rDocumentName )
|
||||
{
|
||||
switch( eType )
|
||||
{
|
||||
case DocPasswordRequestType_STANDARD:
|
||||
{
|
||||
DocumentPasswordRequest aRequest( OUString(), Reference< XInterface >(),
|
||||
InteractionClassification_QUERY, eMode, rDocumentName );
|
||||
maRequest <<= aRequest;
|
||||
}
|
||||
break;
|
||||
case DocPasswordRequestType_MS:
|
||||
{
|
||||
DocumentMSPasswordRequest aRequest( OUString(), Reference< XInterface >(),
|
||||
InteractionClassification_QUERY, eMode, rDocumentName );
|
||||
maRequest <<= aRequest;
|
||||
}
|
||||
break;
|
||||
/* no 'default', so compilers will complain about missing
|
||||
implementation of a new enum value. */
|
||||
}
|
||||
|
||||
maContinuations.realloc( 2 );
|
||||
maContinuations[ 0 ].set( mpAbort = new AbortContinuation );
|
||||
maContinuations[ 1 ].set( mpPassword = new PasswordContinuation );
|
||||
}
|
||||
|
||||
DocPasswordRequest::~DocPasswordRequest()
|
||||
{
|
||||
}
|
||||
|
||||
bool DocPasswordRequest::isAbort() const
|
||||
{
|
||||
return mpAbort->isSelected();
|
||||
}
|
||||
|
||||
bool DocPasswordRequest::isPassword() const
|
||||
{
|
||||
return mpPassword->isSelected();
|
||||
}
|
||||
|
||||
OUString DocPasswordRequest::getPassword() const
|
||||
{
|
||||
return mpPassword->getPassword();
|
||||
}
|
||||
|
||||
Any SAL_CALL DocPasswordRequest::getRequest() throw( RuntimeException )
|
||||
{
|
||||
return maRequest;
|
||||
}
|
||||
|
||||
Sequence< Reference< XInteractionContinuation > > SAL_CALL DocPasswordRequest::getContinuations() throw( RuntimeException )
|
||||
{
|
||||
return maContinuations;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
} // namespace comphelper
|
||||
|
182
comphelper/source/misc/documentiologring.cxx
Normal file
182
comphelper/source/misc/documentiologring.cxx
Normal file
@ -0,0 +1,182 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: documentiologring.hxx,v $
|
||||
* $Revision: 1.0 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_comphelper.hxx"
|
||||
|
||||
#include <com/sun/star/frame/DoubleInitializationException.hpp>
|
||||
#include <com/sun/star/lang/IllegalArgumentException.hpp>
|
||||
|
||||
#include <comphelper_module.hxx>
|
||||
|
||||
#include "documentiologring.hxx"
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
namespace comphelper
|
||||
{
|
||||
|
||||
// ----------------------------------------------------------
|
||||
OSimpleLogRing::OSimpleLogRing( const uno::Reference< uno::XComponentContext >& /*xContext*/ )
|
||||
: m_aMessages( SIMPLELOGRING_SIZE )
|
||||
, m_bInitialized( sal_False )
|
||||
, m_bFull( sal_False )
|
||||
, m_nPos( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
OSimpleLogRing::~OSimpleLogRing()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
uno::Sequence< ::rtl::OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames_static()
|
||||
{
|
||||
uno::Sequence< rtl::OUString > aResult( 1 );
|
||||
aResult[0] = getServiceName_static();
|
||||
return aResult;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
::rtl::OUString SAL_CALL OSimpleLogRing::getImplementationName_static()
|
||||
{
|
||||
return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.logging.SimpleLogRing" ) );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
::rtl::OUString SAL_CALL OSimpleLogRing::getSingletonName_static()
|
||||
{
|
||||
return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.DocumentIOLogRing" ) );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
::rtl::OUString SAL_CALL OSimpleLogRing::getServiceName_static()
|
||||
{
|
||||
return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.SimpleLogRing" ) );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
uno::Reference< uno::XInterface > SAL_CALL OSimpleLogRing::Create( const uno::Reference< uno::XComponentContext >& rxContext )
|
||||
{
|
||||
return static_cast< cppu::OWeakObject* >( new OSimpleLogRing( rxContext ) );
|
||||
}
|
||||
|
||||
// XSimpleLogRing
|
||||
// ----------------------------------------------------------
|
||||
void SAL_CALL OSimpleLogRing::logString( const ::rtl::OUString& aMessage ) throw (uno::RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
m_aMessages[m_nPos] = aMessage;
|
||||
if ( ++m_nPos >= m_aMessages.getLength() )
|
||||
{
|
||||
m_nPos = 0;
|
||||
m_bFull = sal_True;
|
||||
}
|
||||
|
||||
// if used once then default initialized
|
||||
m_bInitialized = sal_True;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
uno::Sequence< ::rtl::OUString > SAL_CALL OSimpleLogRing::getCollectedLog() throw (uno::RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
sal_Int32 nResLen = m_bFull ? m_aMessages.getLength() : m_nPos;
|
||||
sal_Int32 nStart = m_bFull ? m_nPos : 0;
|
||||
uno::Sequence< ::rtl::OUString > aResult( nResLen );
|
||||
|
||||
for ( sal_Int32 nInd = 0; nInd < nResLen; nInd++ )
|
||||
aResult[nInd] = m_aMessages[ ( nStart + nInd ) % m_aMessages.getLength() ];
|
||||
|
||||
// if used once then default initialized
|
||||
m_bInitialized = sal_True;
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
// XInitialization
|
||||
// ----------------------------------------------------------
|
||||
void SAL_CALL OSimpleLogRing::initialize( const uno::Sequence< uno::Any >& aArguments ) throw (uno::Exception, uno::RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
if ( m_bInitialized )
|
||||
throw frame::DoubleInitializationException();
|
||||
|
||||
if ( !m_refCount )
|
||||
throw uno::RuntimeException(); // the object must be refcounted already!
|
||||
|
||||
sal_Int32 nLen = 0;
|
||||
if ( aArguments.getLength() == 1 && ( aArguments[0] >>= nLen ) && nLen )
|
||||
m_aMessages.realloc( nLen );
|
||||
else
|
||||
throw lang::IllegalArgumentException(
|
||||
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Nonnull size is expected as the first argument!" ) ),
|
||||
uno::Reference< uno::XInterface >(),
|
||||
0 );
|
||||
|
||||
m_bInitialized = sal_True;
|
||||
}
|
||||
|
||||
// XServiceInfo
|
||||
// ----------------------------------------------------------
|
||||
::rtl::OUString SAL_CALL OSimpleLogRing::getImplementationName() throw (uno::RuntimeException)
|
||||
{
|
||||
return getImplementationName_static();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
::sal_Bool SAL_CALL OSimpleLogRing::supportsService( const ::rtl::OUString& aServiceName ) throw (uno::RuntimeException)
|
||||
{
|
||||
const uno::Sequence< rtl::OUString > & aSupportedNames = getSupportedServiceNames_static();
|
||||
for ( sal_Int32 nInd = 0; nInd < aSupportedNames.getLength(); nInd++ )
|
||||
{
|
||||
if ( aSupportedNames[ nInd ].equals( aServiceName ) )
|
||||
return sal_True;
|
||||
}
|
||||
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
uno::Sequence< ::rtl::OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames() throw (uno::RuntimeException)
|
||||
{
|
||||
return getSupportedServiceNames_static();
|
||||
}
|
||||
|
||||
} // namespace comphelper
|
||||
|
||||
void createRegistryInfo_OSimpleLogRing()
|
||||
{
|
||||
static ::comphelper::module::OAutoRegistration< ::comphelper::OSimpleLogRing > aAutoRegistration;
|
||||
static ::comphelper::module::OSingletonRegistration< ::comphelper::OSimpleLogRing > aSingletonRegistration;
|
||||
}
|
91
comphelper/source/misc/documentiologring.hxx
Normal file
91
comphelper/source/misc/documentiologring.hxx
Normal file
@ -0,0 +1,91 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: documentiologring.hxx,v $
|
||||
* $Revision: 1.0 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef __DOCUMENTIOLOGRING_HXX_
|
||||
#define __DOCUMENTIOLOGRING_HXX_
|
||||
|
||||
#include <com/sun/star/logging/XSimpleLogRing.hpp>
|
||||
#include <com/sun/star/uno/XComponentContext.hpp>
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#include <com/sun/star/lang/XInitialization.hpp>
|
||||
|
||||
#include <osl/mutex.hxx>
|
||||
#include <cppuhelper/implbase3.hxx>
|
||||
|
||||
#define SIMPLELOGRING_SIZE 256
|
||||
|
||||
namespace comphelper
|
||||
{
|
||||
|
||||
class OSimpleLogRing : public ::cppu::WeakImplHelper3< ::com::sun::star::logging::XSimpleLogRing,
|
||||
::com::sun::star::lang::XInitialization,
|
||||
::com::sun::star::lang::XServiceInfo >
|
||||
{
|
||||
::osl::Mutex m_aMutex;
|
||||
::com::sun::star::uno::Sequence< ::rtl::OUString > m_aMessages;
|
||||
|
||||
sal_Bool m_bInitialized;
|
||||
sal_Bool m_bFull;
|
||||
sal_Int32 m_nPos;
|
||||
|
||||
public:
|
||||
OSimpleLogRing( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
|
||||
virtual ~OSimpleLogRing();
|
||||
|
||||
static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
|
||||
getSupportedServiceNames_static();
|
||||
|
||||
static ::rtl::OUString SAL_CALL getImplementationName_static();
|
||||
|
||||
static ::rtl::OUString SAL_CALL getSingletonName_static();
|
||||
|
||||
static ::rtl::OUString SAL_CALL getServiceName_static();
|
||||
|
||||
static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
|
||||
Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
|
||||
|
||||
// XSimpleLogRing
|
||||
virtual void SAL_CALL logString( const ::rtl::OUString& aMessage ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCollectedLog() throw (::com::sun::star::uno::RuntimeException);
|
||||
|
||||
// XInitialization
|
||||
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
|
||||
|
||||
// XServiceInfo
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
|
||||
|
||||
};
|
||||
|
||||
} // namespace comphelper
|
||||
|
||||
#endif
|
||||
|
@ -57,7 +57,10 @@ SLOFILES= \
|
||||
$(SLO)$/componentcontext.obj \
|
||||
$(SLO)$/componentmodule.obj \
|
||||
$(SLO)$/configurationhelper.obj \
|
||||
$(SLO)$/docpasswordhelper.obj \
|
||||
$(SLO)$/docpasswordrequest.obj \
|
||||
$(SLO)$/documentinfo.obj \
|
||||
$(SLO)$/documentiologring.obj \
|
||||
$(SLO)$/evtlistenerhlp.obj \
|
||||
$(SLO)$/ihwrapnofilter.obj \
|
||||
$(SLO)$/instancelocker.obj \
|
||||
|
@ -114,6 +114,12 @@ namespace css = ::com::sun::star;
|
||||
/*-----------------------------------------------
|
||||
10.03.2004 07:35
|
||||
-----------------------------------------------*/
|
||||
const ::rtl::OUString& MediaDescriptor::PROP_ABORTED()
|
||||
{
|
||||
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Aborted"));
|
||||
return sProp;
|
||||
}
|
||||
|
||||
const ::rtl::OUString& MediaDescriptor::PROP_ASTEMPLATE()
|
||||
{
|
||||
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("AsTemplate"));
|
||||
@ -126,6 +132,12 @@ const ::rtl::OUString& MediaDescriptor::PROP_CHARACTERSET()
|
||||
return sProp;
|
||||
}
|
||||
|
||||
const ::rtl::OUString& MediaDescriptor::PROP_COMPONENTDATA()
|
||||
{
|
||||
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("ComponentData"));
|
||||
return sProp;
|
||||
}
|
||||
|
||||
const ::rtl::OUString& MediaDescriptor::PROP_DEEPDETECTION()
|
||||
{
|
||||
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("DeepDetection"));
|
||||
@ -726,8 +738,13 @@ class StillReadWriteInteraction : public ::ucbhelper::InterceptedInteraction
|
||||
css::ucb::InteractiveIOException exIO;
|
||||
xRequest->getRequest() >>= exIO;
|
||||
bAbort = (
|
||||
(exIO.Code == css::ucb::IOErrorCode_ACCESS_DENIED ) ||
|
||||
(exIO.Code == css::ucb::IOErrorCode_LOCKING_VIOLATION )
|
||||
(exIO.Code == css::ucb::IOErrorCode_ACCESS_DENIED )
|
||||
|| (exIO.Code == css::ucb::IOErrorCode_LOCKING_VIOLATION )
|
||||
#ifdef MACOSX
|
||||
// this is a workaround for MAC, on this platform if the file is locked
|
||||
// the returned error code looks to be wrong
|
||||
|| (exIO.Code == css::ucb::IOErrorCode_GENERAL )
|
||||
#endif
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
@ -36,10 +36,13 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "comphelper/string.hxx"
|
||||
#include "rtl/ustring.hxx"
|
||||
#include "sal/types.h"
|
||||
#include "comphelper/stlunosequence.hxx"
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <sal/types.h>
|
||||
|
||||
#include <comphelper/string.hxx>
|
||||
#include <comphelper/stlunosequence.hxx>
|
||||
#include <comphelper/stl_types.hxx>
|
||||
|
||||
|
||||
namespace comphelper { namespace string {
|
||||
@ -96,12 +99,12 @@ rtl::OUString searchAndReplaceAsciiL(
|
||||
::rtl::OUString convertCommaSeparated(
|
||||
::com::sun::star::uno::Sequence< ::rtl::OUString > const& i_rSeq)
|
||||
{
|
||||
::rtl::OUString ret;
|
||||
for (sal_Int32 i = 0; i < i_rSeq.getLength(); ++i) {
|
||||
if (i != 0) ret += ::rtl::OUString::createFromAscii(", ");
|
||||
ret += i_rSeq[i];
|
||||
}
|
||||
return ret;
|
||||
::rtl::OUStringBuffer buf;
|
||||
::comphelper::intersperse(
|
||||
::comphelper::stl_begin(i_rSeq), ::comphelper::stl_end(i_rSeq),
|
||||
::comphelper::OUStringBufferAppender(buf),
|
||||
::rtl::OUString::createFromAscii(", "));
|
||||
return buf.makeStringAndClear();
|
||||
}
|
||||
|
||||
::com::sun::star::uno::Sequence< ::rtl::OUString >
|
||||
@ -119,10 +122,6 @@ rtl::OUString searchAndReplaceAsciiL(
|
||||
} while (idx >= 0);
|
||||
::com::sun::star::uno::Sequence< ::rtl::OUString > kws(vec.size());
|
||||
std::copy(vec.begin(), vec.end(), stl_begin(kws));
|
||||
/*
|
||||
for (size_t i = 0; i < vec.size(); ++i) {
|
||||
kws[i] = vec.at(i);
|
||||
}*/
|
||||
return kws;
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,7 @@ sal_Bool operator ==(const Time& _rLeft, const Time& _rRight)
|
||||
sal_Int32 getINT32(const Any& _rAny)
|
||||
{
|
||||
sal_Int32 nReturn = 0;
|
||||
_rAny >>= nReturn;
|
||||
|
||||
OSL_VERIFY( _rAny >>= nReturn );
|
||||
return nReturn;
|
||||
}
|
||||
|
||||
@ -96,7 +95,7 @@ sal_Int32 getINT32(const Any& _rAny)
|
||||
sal_Int16 getINT16(const Any& _rAny)
|
||||
{
|
||||
sal_Int16 nReturn = 0;
|
||||
_rAny >>= nReturn;
|
||||
OSL_VERIFY( _rAny >>= nReturn );
|
||||
return nReturn;
|
||||
}
|
||||
|
||||
@ -104,7 +103,7 @@ sal_Int16 getINT16(const Any& _rAny)
|
||||
double getDouble(const Any& _rAny)
|
||||
{
|
||||
double nReturn = 0.0;
|
||||
_rAny >>= nReturn;
|
||||
OSL_VERIFY( _rAny >>= nReturn );
|
||||
return nReturn;
|
||||
}
|
||||
|
||||
@ -112,7 +111,7 @@ double getDouble(const Any& _rAny)
|
||||
float getFloat(const Any& _rAny)
|
||||
{
|
||||
float nReturn = 0.0;
|
||||
_rAny >>= nReturn;
|
||||
OSL_VERIFY( _rAny >>= nReturn );
|
||||
return nReturn;
|
||||
}
|
||||
|
||||
@ -120,7 +119,7 @@ float getFloat(const Any& _rAny)
|
||||
::rtl::OUString getString(const Any& _rAny)
|
||||
{
|
||||
::rtl::OUString nReturn;
|
||||
_rAny >>= nReturn;
|
||||
OSL_VERIFY( _rAny >>= nReturn );
|
||||
return nReturn;
|
||||
}
|
||||
|
||||
|
@ -218,11 +218,15 @@ namespace comphelper
|
||||
// public UiEventsLogger interface
|
||||
sal_Bool UiEventsLogger::isEnabled()
|
||||
{
|
||||
try {
|
||||
UiEventsLogger_Impl::prepareMutex();
|
||||
Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex);
|
||||
return UiEventsLogger_Impl::getInstance()->m_Active;
|
||||
} catch(...) { return false; } // never throws
|
||||
if ( UiEventsLogger_Impl::getEnabledFromCfg() )
|
||||
{
|
||||
try {
|
||||
UiEventsLogger_Impl::prepareMutex();
|
||||
Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex);
|
||||
return UiEventsLogger_Impl::getInstance()->m_Active;
|
||||
} catch(...) { return false; } // never throws
|
||||
} // if ( )
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
sal_Int32 UiEventsLogger::getSessionLogEventCount()
|
||||
@ -375,9 +379,20 @@ namespace comphelper
|
||||
}
|
||||
else
|
||||
logdata[2] = UNKNOWN_ORIGIN;
|
||||
logdata[3] = url.Complete;
|
||||
if(url.Complete.match(URL_FILE))
|
||||
logdata[3] = URL_FILE;
|
||||
else
|
||||
logdata[3] = url.Main;
|
||||
OSL_TRACE("UiEventsLogger Logging: %s,%s,%s,%s,%s,%s,%s,%s",
|
||||
OUStringToOString(logdata[0],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[1],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[2],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[3],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[4],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[5],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[6],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[7],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[8],RTL_TEXTENCODING_UTF8).getStr());
|
||||
m_Logger->log(LogLevel::INFO, m_Formatter->formatMultiColumn(logdata));
|
||||
m_SessionLogEventCount++;
|
||||
}
|
||||
@ -386,6 +401,16 @@ namespace comphelper
|
||||
{
|
||||
Sequence<OUString> logdata = Sequence<OUString>(COLUMNS);
|
||||
logdata[0] = ETYPE_ROTATED;
|
||||
OSL_TRACE("UiEventsLogger Logging: %s,%s,%s,%s,%s,%s,%s,%s",
|
||||
OUStringToOString(logdata[0],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[1],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[2],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[3],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[4],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[5],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[6],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[7],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[8],RTL_TEXTENCODING_UTF8).getStr());
|
||||
m_Logger->log(LogLevel::INFO, m_Formatter->formatMultiColumn(logdata));
|
||||
}
|
||||
|
||||
@ -407,6 +432,16 @@ namespace comphelper
|
||||
logdata[6] = id;
|
||||
logdata[7] = method;
|
||||
logdata[8] = param;
|
||||
OSL_TRACE("UiEventsLogger Logging: %s,%s,%s,%s,%s,%s,%s,%s",
|
||||
OUStringToOString(logdata[0],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[1],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[2],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[3],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[4],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[5],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[6],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[7],RTL_TEXTENCODING_UTF8).getStr(),
|
||||
OUStringToOString(logdata[8],RTL_TEXTENCODING_UTF8).getStr());
|
||||
m_Logger->log(LogLevel::INFO, m_Formatter->formatMultiColumn(logdata));
|
||||
m_SessionLogEventCount++;
|
||||
}
|
||||
|
@ -98,24 +98,30 @@ Reference< XInterface > createProcessComponentWithArguments( const ::rtl::OUStri
|
||||
return xComponent;
|
||||
}
|
||||
|
||||
} // namesapce comphelper
|
||||
|
||||
extern "C" {
|
||||
uno::XComponentContext * comphelper_getProcessComponentContext()
|
||||
Reference< XComponentContext > getProcessComponentContext()
|
||||
{
|
||||
uno::Reference<uno::XComponentContext> xRet;
|
||||
Reference< XComponentContext > xRet;
|
||||
uno::Reference<beans::XPropertySet> const xProps(
|
||||
comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
|
||||
if (xProps.is()) {
|
||||
try {
|
||||
xRet.set( xProps->getPropertyValue(
|
||||
rtl::OUString(
|
||||
xRet.set( xProps->getPropertyValue( rtl::OUString(
|
||||
RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ),
|
||||
uno::UNO_QUERY );
|
||||
}
|
||||
catch (beans::UnknownPropertyException const&) {
|
||||
}
|
||||
}
|
||||
return xRet;
|
||||
}
|
||||
|
||||
} // namespace comphelper
|
||||
|
||||
extern "C" {
|
||||
uno::XComponentContext * comphelper_getProcessComponentContext()
|
||||
{
|
||||
uno::Reference<uno::XComponentContext> xRet;
|
||||
xRet = ::comphelper::getProcessComponentContext();
|
||||
if (xRet.is())
|
||||
xRet->acquire();
|
||||
return xRet.get();
|
||||
|
@ -76,7 +76,7 @@ void ChainablePropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount )
|
||||
{
|
||||
OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US );
|
||||
|
||||
#ifndef PRODUCT
|
||||
#ifdef DBG_UTIL
|
||||
PropertyInfoHash::iterator aIter = maMap.find( aName );
|
||||
if( aIter != maMap.end() )
|
||||
OSL_ENSURE( sal_False, "Warning: PropertyInfo added twice, possible error!");
|
||||
|
@ -84,7 +84,7 @@ void MasterPropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount, sal_uInt8
|
||||
{
|
||||
OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US );
|
||||
|
||||
#ifndef PRODUCT
|
||||
#ifdef DBG_UTIL
|
||||
PropertyDataHash::iterator aIter = maMap.find( aName );
|
||||
if( aIter != maMap.end() )
|
||||
OSL_ENSURE( sal_False, "Warning: PropertyInfo added twice, possible error!");
|
||||
@ -102,7 +102,7 @@ void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId )
|
||||
|
||||
while ( aIter != aEnd )
|
||||
{
|
||||
#ifndef PRODUCT
|
||||
#ifdef DBG_UTIL
|
||||
PropertyDataHash::iterator aDebugIter = maMap.find( (*aIter).first );
|
||||
if( aDebugIter != maMap.end() )
|
||||
OSL_ENSURE( sal_False, "Warning: PropertyInfo added twice, possible error!");
|
||||
|
@ -180,8 +180,7 @@ void GenericPropertySet::_setPropertyValues( const PropertyMapEntry** ppEntries,
|
||||
aEvt.PropertyName = aPropertyName;
|
||||
aEvt.NewValue = *pValues;
|
||||
aGuard.clear();
|
||||
pHelper->forEach<XPropertyChangeListener>(
|
||||
::boost::bind(&XPropertyChangeListener::propertyChange,_1,boost::cref(aEvt)));
|
||||
pHelper->notifyEach( &XPropertyChangeListener::propertyChange, aEvt );
|
||||
aGuard.reset();
|
||||
}
|
||||
|
||||
|
@ -168,10 +168,11 @@ namespace comphelper
|
||||
// will throw an UnknownPropertyException if necessary
|
||||
if ( ( rProp.Attributes & PropertyAttribute::REMOVEABLE ) == 0 )
|
||||
throw NotRemoveableException( ::rtl::OUString(), NULL );
|
||||
const sal_Int32 nHandle = rProp.Handle;
|
||||
|
||||
revokeProperty( rProp.Handle );
|
||||
revokeProperty( nHandle );
|
||||
|
||||
m_pImpl->aDefaults.erase( rProp.Handle );
|
||||
m_pImpl->aDefaults.erase( nHandle );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -76,12 +76,12 @@ namespace
|
||||
// comparing two property descriptions (by name)
|
||||
struct PropertyDescriptionNameMatch : public ::std::unary_function< PropertyDescription, bool >
|
||||
{
|
||||
const ::rtl::OUString& m_rCompare;
|
||||
::rtl::OUString m_rCompare;
|
||||
PropertyDescriptionNameMatch( const ::rtl::OUString& _rCompare ) : m_rCompare( _rCompare ) { }
|
||||
|
||||
bool operator() (const PropertyDescription& x ) const
|
||||
{
|
||||
return x.aProperty.Name == m_rCompare;
|
||||
return x.aProperty.Name.equals(m_rCompare);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void PropertyMapImpl::add( PropertyMapEntry* pMap, sal_Int32 nCount ) throw()
|
||||
{
|
||||
OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US );
|
||||
|
||||
#ifndef PRODUCT
|
||||
#ifdef DBG_UTIL
|
||||
PropertyMap::iterator aIter = maPropertyMap.find( aName );
|
||||
if( aIter != maPropertyMap.end() )
|
||||
{
|
||||
|
@ -35,15 +35,16 @@
|
||||
|
||||
#include <com/sun/star/io/XStream.hpp>
|
||||
#include <com/sun/star/io/XSeekableInputStream.hpp>
|
||||
#include <com/sun/star/io/XTruncate.hpp>
|
||||
#include <com/sun/star/uno/XComponentContext.hpp>
|
||||
#include <cppuhelper/implbase3.hxx>
|
||||
#include <cppuhelper/implbase4.hxx>
|
||||
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
using ::rtl::OUString;
|
||||
using ::cppu::OWeakObject;
|
||||
using ::cppu::WeakImplHelper3;
|
||||
using ::cppu::WeakImplHelper4;
|
||||
using namespace ::com::sun::star::io;
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::lang;
|
||||
@ -52,7 +53,7 @@ using namespace ::osl;
|
||||
namespace comphelper
|
||||
{
|
||||
|
||||
class UNOMemoryStream : public WeakImplHelper3 < XStream, XSeekableInputStream, XOutputStream >
|
||||
class UNOMemoryStream : public WeakImplHelper4 < XStream, XSeekableInputStream, XOutputStream, XTruncate >
|
||||
{
|
||||
public:
|
||||
UNOMemoryStream();
|
||||
@ -79,6 +80,9 @@ public:
|
||||
virtual void SAL_CALL flush() throw (NotConnectedException, BufferSizeExceededException, IOException, RuntimeException);
|
||||
virtual void SAL_CALL closeOutput() throw (NotConnectedException, BufferSizeExceededException, IOException, RuntimeException);
|
||||
|
||||
// XTruncate
|
||||
virtual void SAL_CALL truncate() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
|
||||
|
||||
// XServiceInfo - static versions (used for component registration)
|
||||
static ::rtl::OUString SAL_CALL getImplementationName_static();
|
||||
static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
|
||||
@ -116,8 +120,7 @@ sal_Int32 SAL_CALL UNOMemoryStream::readBytes( Sequence< sal_Int8 >& aData, sal_
|
||||
throw IOException();
|
||||
|
||||
nBytesToRead = std::min( nBytesToRead, available() );
|
||||
if( aData.getLength() < nBytesToRead )
|
||||
aData.realloc( nBytesToRead );
|
||||
aData.realloc( nBytesToRead );
|
||||
|
||||
if( nBytesToRead )
|
||||
{
|
||||
@ -157,9 +160,16 @@ void SAL_CALL UNOMemoryStream::closeInput() throw (NotConnectedException, IOExce
|
||||
// XSeekable
|
||||
void SAL_CALL UNOMemoryStream::seek( sal_Int64 location ) throw (IllegalArgumentException, IOException, RuntimeException)
|
||||
{
|
||||
if( (location < 0) || (location > SAL_MAX_INT32) || (location > static_cast< sal_Int64 >( maData.size() )) )
|
||||
if( (location < 0) || (location > SAL_MAX_INT32) )
|
||||
throw IllegalArgumentException( OUString(RTL_CONSTASCII_USTRINGPARAM("this implementation does not support more than 2GB!")), Reference< XInterface >(static_cast<OWeakObject*>(this)), 0 );
|
||||
|
||||
// seek operation should be able to resize the stream
|
||||
if ( location > static_cast< sal_Int64 >( maData.size() ) )
|
||||
maData.resize( static_cast< sal_Int32 >( location ) );
|
||||
|
||||
if ( location > static_cast< sal_Int64 >( maData.size() ) )
|
||||
maData.resize( static_cast< sal_Int32 >( location ) );
|
||||
|
||||
mnCursor = static_cast< sal_Int32 >( location );
|
||||
}
|
||||
|
||||
@ -206,6 +216,13 @@ void SAL_CALL UNOMemoryStream::closeOutput() throw (NotConnectedException, Buffe
|
||||
mnCursor = 0;
|
||||
}
|
||||
|
||||
//XTruncate
|
||||
void SAL_CALL UNOMemoryStream::truncate() throw (IOException, RuntimeException)
|
||||
{
|
||||
maData.resize( 0 );
|
||||
mnCursor = 0;
|
||||
}
|
||||
|
||||
::rtl::OUString SAL_CALL UNOMemoryStream::getImplementationName_static()
|
||||
{
|
||||
static const OUString sImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.MemoryStream" ) );
|
||||
|
@ -83,6 +83,7 @@
|
||||
#include <vcl/metric.hxx>
|
||||
#include <vcl/graphictools.hxx>
|
||||
#include <tools/poly.hxx>
|
||||
#include <i18npool/mslangid.hxx>
|
||||
|
||||
#include <implrenderer.hxx>
|
||||
#include <tools.hxx>
|
||||
@ -956,6 +957,9 @@ namespace cppcanvas
|
||||
rParms.mrParms.maFontLetterForm.getValue() :
|
||||
(rFont.GetItalic() == ITALIC_NONE) ? 0 : 9;
|
||||
|
||||
LanguageType aLang = rFont.GetLanguage();
|
||||
aFontRequest.Locale = MsLangId::convertLanguageToLocale(aLang, false);
|
||||
|
||||
// setup state-local text transformation,
|
||||
// if the font be rotated
|
||||
const short nFontAngle( rFont.GetOrientation() );
|
||||
|
@ -50,7 +50,7 @@ LIB1FILES=\
|
||||
|
||||
SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
|
||||
SHL1IMPLIB= i$(TARGET)
|
||||
SHL1STDLIBS= $(TOOLSLIB) $(CPPULIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CANVASTOOLSLIB) $(CPPUHELPERLIB) $(BASEGFXLIB)
|
||||
SHL1STDLIBS= $(TOOLSLIB) $(CPPULIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CANVASTOOLSLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(I18NISOLANGLIB)
|
||||
|
||||
.IF "$(debug)$(dbgutil)"!=""
|
||||
SHL1STDLIBS += $(CPPUHELPERLIB)
|
||||
|
@ -10,8 +10,6 @@ dr dtrans\source\win32\dnd nmake - w dr_win32_dnd dr_cnttype dr_win32_misc.w
|
||||
dr dtrans\source\win32\dtobj nmake - w dr_win32_dtobj dr_win32_clipb.w dr_win32_misc.w dr_win32_ftransl.w dr_inc NULL
|
||||
dr dtrans\source\os2\clipb nmake - p dr_os2_clipb dr_inc NULL
|
||||
dr dtrans\util nmake - all dr_util dr_cnttype dr_win32_misc.w dr_win32_mtaole.w dr_win32_ftransl.w dr_win32_clipb.w dr_win32_dnd.w dr_win32_dtobj.w dr_inc NULL
|
||||
dr dtrans\source\X11 nmake - u dr_X11 dr_inc NULL
|
||||
dr dtrans\source\aqua nmake - u dr_aqua dr_inc NULL
|
||||
dr dtrans\source\generic nmake - all dr_generic dr_inc NULL
|
||||
|
||||
|
||||
|
@ -5,6 +5,5 @@
|
||||
..\source\win32\clipb\sysdtrans.xml %_DEST%\xml%_EXT%\sysdtrans.xml
|
||||
..\source\win32\dnd\dnd.xml %_DEST%\xml%_EXT%\dnd.xml
|
||||
..\source\win32\ftransl\ftransl.xml %_DEST%\xml%_EXT%\ftransl.xml
|
||||
..\source\X11\dtransX11.xml %_DEST%\xml%_EXT%\dtransX11.xml
|
||||
..\source\cnttype\mcnttype.xml %_DEST%\xml%_EXT%\mcnttype.xml
|
||||
..\source\generic\dtrans.xml %_DEST%\xml%_EXT%\dtrans.xml
|
||||
|
@ -1,303 +0,0 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: X11_service.cxx,v $
|
||||
* $Revision: 1.11 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_dtrans.hxx"
|
||||
|
||||
#include <X11_clipboard.hxx>
|
||||
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
||||
#include <com/sun/star/registry/XRegistryKey.hpp>
|
||||
#include <uno/dispatcher.h> // declaration of generic uno interface
|
||||
#include <uno/mapping.hxx> // mapping stuff
|
||||
#include <cppuhelper/factory.hxx>
|
||||
#include <cppuhelper/compbase1.hxx>
|
||||
|
||||
using namespace rtl;
|
||||
using namespace cppu;
|
||||
using namespace com::sun::star::lang;
|
||||
using namespace com::sun::star::datatransfer::clipboard;
|
||||
using namespace com::sun::star::awt;
|
||||
using namespace x11;
|
||||
|
||||
namespace x11 {
|
||||
|
||||
class X11ClipboardFactory : public ::cppu::WeakComponentImplHelper1 <
|
||||
::com::sun::star::lang::XSingleServiceFactory
|
||||
>
|
||||
{
|
||||
::osl::Mutex m_aMutex;
|
||||
::std::hash_map< OUString, ::std::hash_map< Atom, Reference< XClipboard > >, ::rtl::OUStringHash > m_aInstances;
|
||||
public:
|
||||
X11ClipboardFactory();
|
||||
virtual ~X11ClipboardFactory();
|
||||
|
||||
/*
|
||||
* XSingleServiceFactory
|
||||
*/
|
||||
virtual Reference< XInterface > createInstance() throw();
|
||||
virtual Reference< XInterface > createInstanceWithArguments( const Sequence< Any >& rArgs ) throw();
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
X11ClipboardFactory::X11ClipboardFactory() :
|
||||
::cppu::WeakComponentImplHelper1<
|
||||
::com::sun::star::lang::XSingleServiceFactory
|
||||
>( m_aMutex )
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
X11ClipboardFactory::~X11ClipboardFactory()
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Reference< XInterface > X11ClipboardFactory::createInstance() throw()
|
||||
{
|
||||
return createInstanceWithArguments( Sequence< Any >() );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Reference< XInterface > X11ClipboardFactory::createInstanceWithArguments( const Sequence< Any >& arguments ) throw()
|
||||
{
|
||||
OUString aDisplayName;
|
||||
Atom nSelection;
|
||||
|
||||
// extract display name from connection argument. An exception is thrown
|
||||
// by SelectionManager.initialize() if no display connection is given.
|
||||
if( arguments.getLength() > 0 )
|
||||
{
|
||||
Reference< XDisplayConnection > xConn;
|
||||
arguments.getConstArray()[0] >>= xConn;
|
||||
|
||||
if( xConn.is() )
|
||||
{
|
||||
Any aIdentifier = xConn->getIdentifier();
|
||||
aIdentifier >>= aDisplayName;
|
||||
}
|
||||
}
|
||||
|
||||
SelectionManager& rManager = SelectionManager::get( aDisplayName );
|
||||
rManager.initialize( arguments );
|
||||
|
||||
// check if any other selection than clipboard selection is specified
|
||||
if( arguments.getLength() > 1 )
|
||||
{
|
||||
OUString aSelectionName;
|
||||
|
||||
arguments.getConstArray()[1] >>= aSelectionName;
|
||||
nSelection = rManager.getAtom( aSelectionName );
|
||||
}
|
||||
else
|
||||
{
|
||||
// default atom is clipboard selection
|
||||
nSelection = rManager.getAtom( OUString::createFromAscii( "CLIPBOARD" ) );
|
||||
}
|
||||
|
||||
::std::hash_map< Atom, Reference< XClipboard > >& rMap( m_aInstances[ aDisplayName ] );
|
||||
::std::hash_map< Atom, Reference< XClipboard > >::iterator it = rMap.find( nSelection );
|
||||
if( it != rMap.end() )
|
||||
return it->second;
|
||||
|
||||
X11Clipboard* pClipboard = new X11Clipboard( rManager, nSelection );
|
||||
rMap[ nSelection ] = pClipboard;
|
||||
|
||||
return static_cast<OWeakObject*>(pClipboard);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Sequence< OUString > SAL_CALL X11Clipboard_getSupportedServiceNames()
|
||||
{
|
||||
Sequence< OUString > aRet(1);
|
||||
aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.clipboard.SystemClipboard");
|
||||
return aRet;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Sequence< OUString > SAL_CALL Xdnd_getSupportedServiceNames()
|
||||
{
|
||||
Sequence< OUString > aRet(1);
|
||||
aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DragSource");
|
||||
return aRet;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Reference< XInterface > SAL_CALL Xdnd_createInstance(
|
||||
const Reference< XMultiServiceFactory > & )
|
||||
{
|
||||
return Reference < XInterface >( ( OWeakObject * ) new SelectionManagerHolder() );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Sequence< OUString > SAL_CALL Xdnd_dropTarget_getSupportedServiceNames()
|
||||
{
|
||||
Sequence< OUString > aRet(1);
|
||||
aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DropTarget");
|
||||
return aRet;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Reference< XInterface > SAL_CALL Xdnd_dropTarget_createInstance(
|
||||
const Reference< XMultiServiceFactory > & )
|
||||
{
|
||||
return Reference < XInterface >( ( OWeakObject * ) new DropTarget() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static const OUString& getClipboardImplementationName()
|
||||
{
|
||||
static OUString aImpl = OUString::createFromAscii(X11_CLIPBOARD_IMPLEMENTATION_NAME);
|
||||
return aImpl;
|
||||
}
|
||||
|
||||
static const OUString& getClipboardServiceName()
|
||||
{
|
||||
static OUString aImpl = OUString::createFromAscii("com.sun.star.datatransfer.clipboard.SystemClipboard" );
|
||||
return aImpl;
|
||||
}
|
||||
|
||||
static const OUString& getXdndImplementationName()
|
||||
{
|
||||
static OUString aImpl = OUString::createFromAscii(XDND_IMPLEMENTATION_NAME );
|
||||
return aImpl;
|
||||
}
|
||||
|
||||
static const OUString& getXdndServiceName()
|
||||
{
|
||||
static OUString aImpl = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DragSource" );
|
||||
return aImpl;
|
||||
}
|
||||
|
||||
static const OUString& getXdndDropTargetImplementationName()
|
||||
{
|
||||
static OUString aImpl = OUString::createFromAscii(XDND_DROPTARGET_IMPLEMENTATION_NAME);
|
||||
return aImpl;
|
||||
}
|
||||
|
||||
static const OUString& getXdndDropTargetServiceName()
|
||||
{
|
||||
static OUString aImpl = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DropTarget" );
|
||||
return aImpl;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void SAL_CALL component_getImplementationEnvironment(
|
||||
const sal_Char** ppEnvTypeName,
|
||||
uno_Environment** )
|
||||
{
|
||||
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL component_writeInfo( void*, void* pXUnoKey )
|
||||
{
|
||||
if( pXUnoKey )
|
||||
{
|
||||
try
|
||||
{
|
||||
Reference< ::com::sun::star::registry::XRegistryKey > xKey( reinterpret_cast< ::com::sun::star::registry::XRegistryKey* >( pXUnoKey ) );
|
||||
|
||||
OUString aImplName = OUString::createFromAscii( "/" );
|
||||
aImplName += getClipboardImplementationName();
|
||||
aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/" );
|
||||
aImplName += getClipboardServiceName();
|
||||
xKey->createKey( aImplName );
|
||||
|
||||
aImplName = OUString::createFromAscii( "/" );
|
||||
aImplName += getXdndImplementationName();
|
||||
aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/" );
|
||||
aImplName += getXdndServiceName();
|
||||
xKey->createKey( aImplName );
|
||||
|
||||
aImplName = OUString::createFromAscii( "/" );
|
||||
aImplName += getXdndDropTargetImplementationName();
|
||||
aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/" );
|
||||
aImplName += getXdndDropTargetServiceName();
|
||||
xKey->createKey( aImplName );
|
||||
|
||||
return sal_True;
|
||||
}
|
||||
catch( ::com::sun::star::registry::InvalidRegistryException& )
|
||||
{
|
||||
}
|
||||
}
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
void* SAL_CALL component_getFactory(
|
||||
const sal_Char* pImplementationName,
|
||||
void* pXUnoSMgr,
|
||||
void*
|
||||
)
|
||||
{
|
||||
void* pRet = 0;
|
||||
|
||||
::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) );
|
||||
|
||||
if( pXUnoSMgr )
|
||||
{
|
||||
Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr(
|
||||
reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr )
|
||||
);
|
||||
Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
|
||||
if( aImplName.equals( getClipboardImplementationName() ) )
|
||||
xFactory = new X11ClipboardFactory();
|
||||
else if( aImplName.equals( getXdndImplementationName() ) )
|
||||
{
|
||||
xFactory = ::cppu::createSingleFactory(
|
||||
xMgr, aImplName, Xdnd_createInstance,
|
||||
Xdnd_getSupportedServiceNames() );
|
||||
}
|
||||
else if( aImplName.equals( getXdndDropTargetImplementationName() ) )
|
||||
{
|
||||
xFactory = ::cppu::createSingleFactory(
|
||||
xMgr, aImplName, Xdnd_dropTarget_createInstance,
|
||||
Xdnd_dropTarget_getSupportedServiceNames() );
|
||||
}
|
||||
if( xFactory.is() )
|
||||
{
|
||||
xFactory->acquire();
|
||||
pRet = xFactory.get();
|
||||
}
|
||||
}
|
||||
return pRet;
|
||||
}
|
||||
|
||||
} /* extern "C" */
|
@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
|
||||
<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<module-name> dtransX11 </module-name>
|
||||
<component-description>
|
||||
<author> Tino Rachui </author>
|
||||
<name> com.sun.star.comp.datatransfer.X11 </name>
|
||||
<description>
|
||||
The X11 implementation of the datatransfer service.
|
||||
</description>
|
||||
<loader-name> com.sun.star.loader.SharedLibrary </loader-name>
|
||||
<language> c++ </language>
|
||||
<status value="beta"/>
|
||||
<supported-service> com.sun.star.datatransfer.clipboard.SystemClipboard </supported-service>
|
||||
<supported-service> com.sun.star.datatransfer.dnd.X11DragSource </supported-service>
|
||||
<supported-service> com.sun.star.datatransfer.dnd.X11DropTarget </supported-service>
|
||||
<service-dependency> ... </service-dependency>
|
||||
<type> com.sun.star.datatransfer.clipboard.XClipboardEx </type>
|
||||
<type> com.sun.star.datatransfer.XTransferable </type>
|
||||
<type> com.sun.star.datatransfer.clipboard.RenderingCapabilities </type>
|
||||
<type> com.sun.star.datatransfer.clipboard.XClipboardOwner </type>
|
||||
<type> com.sun.star.datatransfer.clipboard.XClipboardListener </type>
|
||||
<type> com.sun.star.datatransfer.clipboard.XClipboardNotifier </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDropTargetDropContext </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDropTargetDragContext </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDropTarget </type>
|
||||
<type> com.sun.star.datatransfer.dnd.DNDConstants </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDragSource </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDragSourceContext </type>
|
||||
<type> com.sun.star.awt.XDisplayConnection </type>
|
||||
<type> com.sun.star.lang.DisposedException </type>
|
||||
<type> com.sun.star.lang.IllegalArgumentException </type>
|
||||
<type> com.sun.star.lang.XComponent </type>
|
||||
<type> com.sun.star.lang.XMultiServiceFactory </type>
|
||||
<type> com.sun.star.lang.XSingleServiceFactory </type>
|
||||
<type> com.sun.star.lang.XServiceInfo </type>
|
||||
<type> com.sun.star.lang.XTypeProvider </type>
|
||||
<type> com.sun.star.uno.TypeClass </type>
|
||||
<type> com.sun.star.uno.XWeak </type>
|
||||
<type> com.sun.star.uno.XAggregation </type>
|
||||
<type> com.sun.star.registry.XRegistryKey </type>
|
||||
<type> com.sun.star.container.XSet </type>
|
||||
</component-description>
|
||||
<project-build-dependency> cppuhelper </project-build-dependency>
|
||||
<project-build-dependency> cppu </project-build-dependency>
|
||||
<project-build-dependency> sal </project-build-dependency>
|
||||
<runtime-module-dependency> cppuhelper </runtime-module-dependency>
|
||||
<runtime-module-dependency> cppu2 </runtime-module-dependency>
|
||||
<runtime-module-dependency> sal2 </runtime-module-dependency>
|
||||
</module-description>
|
@ -1,10 +0,0 @@
|
||||
UDK_3_0_0 {
|
||||
global:
|
||||
GetVersionInfo;
|
||||
component_getImplementationEnvironment;
|
||||
component_getFactory;
|
||||
component_writeInfo;
|
||||
|
||||
local:
|
||||
*;
|
||||
};
|
@ -1,47 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
|
||||
<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<module-name> dtransaqua </module-name>
|
||||
<component-description>
|
||||
<author> Tino Rachui </author>
|
||||
<name> com.sun.star.comp.datatransfer.aqua </name>
|
||||
<description>
|
||||
The aqua implementation of the datatransfer service.
|
||||
</description>
|
||||
<loader-name> com.sun.star.loader.SharedLibrary </loader-name>
|
||||
<language> c++ </language>
|
||||
<status value="beta"/>
|
||||
<supported-service> com.sun.star.datatransfer.clipboard.SystemClipboard </supported-service>
|
||||
<service-dependency> ... </service-dependency>
|
||||
<type> com.sun.star.datatransfer.clipboard.XClipboardEx </type>
|
||||
<type> com.sun.star.datatransfer.XTransferable </type>
|
||||
<type> com.sun.star.datatransfer.clipboard.RenderingCapabilities </type>
|
||||
<type> com.sun.star.datatransfer.clipboard.XClipboardOwner </type>
|
||||
<type> com.sun.star.datatransfer.clipboard.XClipboardListener </type>
|
||||
<type> com.sun.star.datatransfer.clipboard.XClipboardNotifier </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDropTargetDropContext </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDropTargetDragContext </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDropTarget </type>
|
||||
<type> com.sun.star.datatransfer.dnd.DNDConstants </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDragSource </type>
|
||||
<type> com.sun.star.datatransfer.dnd.XDragSourceContext </type>
|
||||
<type> com.sun.star.lang.DisposedException </type>
|
||||
<type> com.sun.star.lang.IllegalArgumentException </type>
|
||||
<type> com.sun.star.lang.XComponent </type>
|
||||
<type> com.sun.star.lang.XMultiServiceFactory </type>
|
||||
<type> com.sun.star.lang.XSingleServiceFactory </type>
|
||||
<type> com.sun.star.lang.XServiceInfo </type>
|
||||
<type> com.sun.star.lang.XTypeProvider </type>
|
||||
<type> com.sun.star.uno.TypeClass </type>
|
||||
<type> com.sun.star.uno.XWeak </type>
|
||||
<type> com.sun.star.uno.XAggregation </type>
|
||||
<type> com.sun.star.registry.XRegistryKey </type>
|
||||
<type> com.sun.star.container.XSet </type>
|
||||
</component-description>
|
||||
<project-build-dependency> cppuhelper </project-build-dependency>
|
||||
<project-build-dependency> cppu </project-build-dependency>
|
||||
<project-build-dependency> sal </project-build-dependency>
|
||||
<runtime-module-dependency> cppuhelper </runtime-module-dependency>
|
||||
<runtime-module-dependency> cppu2 </runtime-module-dependency>
|
||||
<runtime-module-dependency> sal2 </runtime-module-dependency>
|
||||
</module-description>
|
@ -1,210 +0,0 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: service_entry.cxx,v $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_dtrans.hxx"
|
||||
|
||||
#include "DragSource.hxx"
|
||||
#include "DropTarget.hxx"
|
||||
#include "aqua_clipboard.hxx"
|
||||
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
|
||||
#include <cppuhelper/factory.hxx>
|
||||
#include <cppuhelper/compbase1.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
|
||||
#include "cppuhelper/implementationentry.hxx"
|
||||
|
||||
using namespace ::osl;
|
||||
using namespace ::rtl;
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::registry;
|
||||
using namespace ::cppu;
|
||||
using namespace ::com::sun::star::lang;
|
||||
using namespace ::com::sun::star::datatransfer::clipboard;
|
||||
|
||||
|
||||
rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
|
||||
|
||||
|
||||
extern rtl::OUString dragSource_getImplementationName();
|
||||
extern com::sun::star::uno::Sequence<rtl::OUString> dragSource_getSupportedServiceNames();
|
||||
extern rtl::OUString dropTarget_getImplementationName();
|
||||
extern com::sun::star::uno::Sequence<rtl::OUString> dropTarget_getSupportedServiceNames();
|
||||
extern rtl::OUString clipboard_getImplementationName();
|
||||
extern com::sun::star::uno::Sequence<rtl::OUString> clipboard_getSupportedServiceNames();
|
||||
|
||||
|
||||
Reference<XInterface> SAL_CALL createDragSource(const Reference<XComponentContext>& rComponentContext);
|
||||
Reference<XInterface> SAL_CALL createDropTarget(const Reference<XComponentContext>& rComponentContext);
|
||||
Reference<XInterface> SAL_CALL createClipboard(const Reference<XComponentContext>& rComponentContext);
|
||||
|
||||
|
||||
cppu::ImplementationEntry entries[] = {
|
||||
{ createDragSource,
|
||||
dragSource_getImplementationName,
|
||||
dragSource_getSupportedServiceNames,
|
||||
cppu::createSingleComponentFactory, 0, 0 },
|
||||
{ createDropTarget,
|
||||
dropTarget_getImplementationName,
|
||||
dropTarget_getSupportedServiceNames,
|
||||
cppu::createSingleComponentFactory, 0, 0 },
|
||||
{ createClipboard,
|
||||
clipboard_getImplementationName,
|
||||
clipboard_getSupportedServiceNames,
|
||||
cppu::createSingleComponentFactory, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
class AquaClipboardFactory : public WeakComponentImplHelper1<XSingleComponentFactory>
|
||||
{
|
||||
public:
|
||||
AquaClipboardFactory();
|
||||
virtual ~AquaClipboardFactory();
|
||||
|
||||
/*
|
||||
* XSingleComponentFactory
|
||||
*/
|
||||
virtual Reference<XInterface> createInstanceWithContext(const Reference<XComponentContext>& Context)
|
||||
throw (Exception);
|
||||
|
||||
virtual Reference<XInterface> createInstanceWithArgumentsAndContext(const Sequence<Any>& rArgs,
|
||||
const Reference<XComponentContext>& Context)
|
||||
throw(Exception);
|
||||
|
||||
private:
|
||||
static Mutex m_aMutex;
|
||||
static Reference<XInterface> mSingleInstance;
|
||||
};
|
||||
|
||||
Reference<XInterface> AquaClipboardFactory::mSingleInstance;
|
||||
Mutex AquaClipboardFactory::m_aMutex;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
AquaClipboardFactory::AquaClipboardFactory() :
|
||||
WeakComponentImplHelper1<XSingleComponentFactory>(m_aMutex)
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
AquaClipboardFactory::~AquaClipboardFactory()
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Reference<XInterface> AquaClipboardFactory::createInstanceWithContext(const Reference<XComponentContext>& Context) throw(Exception)
|
||||
{
|
||||
return createInstanceWithArgumentsAndContext(Sequence<Any>(), Context);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Reference< XInterface > AquaClipboardFactory::createInstanceWithArgumentsAndContext(const Sequence<Any>& arguments,
|
||||
const Reference<XComponentContext>& Context) throw(Exception)
|
||||
{
|
||||
MutexGuard aGuard(m_aMutex);
|
||||
|
||||
if (!mSingleInstance.is())
|
||||
{
|
||||
AquaClipboardFactory::mSingleInstance = createClipboard(Context);
|
||||
}
|
||||
|
||||
return AquaClipboardFactory::mSingleInstance;
|
||||
}
|
||||
|
||||
|
||||
Reference<XInterface> SAL_CALL createDragSource( const Reference< XComponentContext >& rComponentContext)
|
||||
{
|
||||
return Reference<XInterface>(static_cast< XInitialization* >(new DragSource(rComponentContext)), UNO_QUERY);
|
||||
}
|
||||
|
||||
Reference<XInterface> SAL_CALL createDropTarget( const Reference< XComponentContext >& rComponentContext)
|
||||
{
|
||||
return Reference<XInterface>(static_cast< XInitialization* >(new DropTarget(rComponentContext)), UNO_QUERY);
|
||||
}
|
||||
|
||||
Reference< XInterface > SAL_CALL createClipboard( const Reference< XComponentContext >& rComponentContext)
|
||||
{
|
||||
return Reference<XInterface>(static_cast< XClipboard* >(new AquaClipboard(rComponentContext)), UNO_QUERY);
|
||||
}
|
||||
|
||||
|
||||
extern "C" sal_Bool SAL_CALL component_writeInfo(
|
||||
void * serviceManager, void * registryKey)
|
||||
{
|
||||
return cppu::component_writeInfoHelper(
|
||||
serviceManager, registryKey, entries);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void * SAL_CALL component_getFactory(
|
||||
char const * implName, void * serviceManager, void * registryKey)
|
||||
{
|
||||
void* pRet = NULL;
|
||||
OUString iName = OUString::createFromAscii(implName);
|
||||
Reference<XSingleComponentFactory> xFac;
|
||||
|
||||
if (iName.equalsIgnoreAsciiCase(clipboard_getImplementationName()))
|
||||
{
|
||||
xFac = new AquaClipboardFactory();
|
||||
}
|
||||
else
|
||||
{
|
||||
return component_getFactoryHelper(implName,
|
||||
serviceManager,
|
||||
registryKey,
|
||||
entries);
|
||||
}
|
||||
|
||||
if (xFac.is())
|
||||
{
|
||||
xFac->acquire();
|
||||
pRet = xFac.get();
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
|
||||
extern "C" void SAL_CALL component_getImplementationEnvironment(
|
||||
char const ** envTypeName, uno_Environment **)
|
||||
{
|
||||
*envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
|
||||
}
|
||||
|
||||
|
||||
extern "C" sal_Bool SAL_CALL component_canUnload( TimeValue *pTime )
|
||||
{
|
||||
return g_moduleCount.canUnload( &g_moduleCount , pTime );
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ COMP1TYPELIST=dtrans
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
.INCLUDE : settings.mk
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
SLOFILES= \
|
||||
@ -66,5 +66,6 @@ DEF1NAME= $(SHL1TARGET)
|
||||
DEF1EXPORTFILE= exports.dxp
|
||||
|
||||
# --- Targets ------------------------------------------------------
|
||||
.ENDIF # L10N_framework
|
||||
|
||||
.INCLUDE : target.mk
|
||||
|
@ -41,7 +41,7 @@ TARGET4=dnd
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
.INCLUDE : settings.mk
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
|
||||
# --- mcnttype dynlib ----------------------------------------------
|
||||
|
||||
@ -180,6 +180,7 @@ DEF3NAME= $(SHL3TARGET)
|
||||
DEF3EXPORTFILE= exports.dxp
|
||||
|
||||
.ENDIF # "$(GUI)"=="OS2"
|
||||
.ENDIF # L10N_framework
|
||||
|
||||
.INCLUDE : target.mk
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include <svtools/lstner.hxx>
|
||||
#include <svl/lstner.hxx>
|
||||
|
||||
class ChannelItem;
|
||||
class ChannelList;
|
||||
|
@ -31,7 +31,7 @@
|
||||
#define _GOODIES_HRC
|
||||
|
||||
#ifndef _SOLAR_HRC
|
||||
#include <svtools/solar.hrc>
|
||||
#include <svl/solar.hrc>
|
||||
#endif
|
||||
|
||||
// Dialoge ---------------------------------------------------------------
|
||||
|
@ -96,13 +96,13 @@
|
||||
#include "rtl/uuid.h"
|
||||
|
||||
#include "svtools/FilterConfigItem.hxx"
|
||||
#include "svtools/cacheoptions.hxx"
|
||||
#include "unotools/cacheoptions.hxx"
|
||||
#include "svtools/fltcall.hxx"
|
||||
#include "svtools/itemprop.hxx"
|
||||
#include "svtools/lstner.hxx"
|
||||
#include "svtools/solar.hrc"
|
||||
#include "svl/itemprop.hxx"
|
||||
#include "svl/lstner.hxx"
|
||||
#include "svl/solar.hrc"
|
||||
#include "svtools/stdctrl.hxx"
|
||||
#include "svtools/svarray.hxx"
|
||||
#include "svl/svarray.hxx"
|
||||
|
||||
#include "toolkit/helper/vclunohelper.hxx"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
go goodies : svtools NULL
|
||||
go goodies : l10n svtools NULL
|
||||
go goodies usr1 - all g_mkout NULL
|
||||
go goodies\inc nmake - all g_inc NULL
|
||||
go goodies\prj get - all g_prj NULL
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <vcl/msgbox.hxx>
|
||||
#include <vcl/window.hxx>
|
||||
#include <svtools/solar.hrc>
|
||||
#include <svl/solar.hrc>
|
||||
#include <svtools/fltcall.hxx>
|
||||
#include <svtools/FilterConfigItem.hxx>
|
||||
#include "giflzwc.hxx"
|
||||
|
@ -49,17 +49,18 @@ CDEFS+= -DEDITDEBUG
|
||||
SRS1NAME=$(TARGET)
|
||||
SRC1FILES = dlgegif.src \
|
||||
egifstr.src
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SLOFILES= $(SLO)$/egif.obj \
|
||||
$(SLO)$/dlgegif.obj \
|
||||
$(SLO)$/giflzwc.obj
|
||||
|
||||
.ENDIF
|
||||
|
||||
# ==========================================================================
|
||||
|
||||
RESLIB1NAME=$(TARGET2)
|
||||
RESLIB1SRSFILES=$(SRS)$/$(TARGET).srs
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SHL1TARGET= egi$(DLLPOSTFIX)
|
||||
SHL1IMPLIB= egif
|
||||
SHL1STDLIBS= $(TOOLSLIB) $(VCLLIB) $(CPPULIB) $(SVTOOLLIB) $(SALLIB)
|
||||
@ -75,7 +76,7 @@ SHL1OBJS= $(SLO)$/egif.obj
|
||||
SHL1VERSIONMAP=exports.map
|
||||
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
|
||||
DEF1NAME=$(SHL1TARGET)
|
||||
|
||||
.ENDIF
|
||||
# ==========================================================================
|
||||
|
||||
.INCLUDE : target.mk
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include <vcl/virdev.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <vcl/msgbox.hxx>
|
||||
#include <svtools/solar.hrc>
|
||||
#include <svl/solar.hrc>
|
||||
#include "strings.hrc"
|
||||
#include "dlgeos2.hxx"
|
||||
|
||||
@ -1753,7 +1753,7 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF )
|
||||
Polygon aSimplePoly;
|
||||
const Polygon& rPoly = pA->GetPolygon();
|
||||
if ( rPoly.HasFlags() )
|
||||
rPoly.GetSimple( aSimplePoly );
|
||||
rPoly.AdaptiveSubdivide( aSimplePoly );
|
||||
else
|
||||
aSimplePoly = rPoly;
|
||||
METLine( aSimplePoly );
|
||||
@ -1772,7 +1772,7 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF )
|
||||
Polygon aSimplePoly;
|
||||
const Polygon& rPoly = pA->GetPolygon();
|
||||
if ( rPoly.HasFlags() )
|
||||
rPoly.GetSimple( aSimplePoly );
|
||||
rPoly.AdaptiveSubdivide( aSimplePoly );
|
||||
else
|
||||
aSimplePoly = rPoly;
|
||||
if( aGDIFillColor != Color( COL_TRANSPARENT ) )
|
||||
@ -1809,7 +1809,7 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF )
|
||||
if ( aSimplePolyPoly[ i ].HasFlags() )
|
||||
{
|
||||
Polygon aSimplePoly;
|
||||
aSimplePolyPoly[ i ].GetSimple( aSimplePoly );
|
||||
aSimplePolyPoly[ i ].AdaptiveSubdivide( aSimplePoly );
|
||||
aSimplePolyPoly[ i ] = aSimplePoly;
|
||||
}
|
||||
}
|
||||
|
@ -49,15 +49,15 @@ CDEFS+= -DEDITDEBUG
|
||||
SRS1NAME=$(TARGET)
|
||||
SRC1FILES= dlgeos2.src \
|
||||
eos2mstr.src
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SLOFILES = $(SLO)$/eos2met.obj \
|
||||
$(SLO)$/dlgeos2.obj
|
||||
|
||||
.ENDIF
|
||||
# ==========================================================================
|
||||
|
||||
RESLIB1NAME=$(TARGET2)
|
||||
RESLIB1SRSFILES=$(SRS)$/$(TARGET).srs
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SHL1TARGET= eme$(DLLPOSTFIX)
|
||||
SHL1IMPLIB= eos2met
|
||||
SHL1STDLIBS= $(TOOLSLIB) $(VCLLIB) $(SVTOOLLIB) $(CPPULIB) $(SALLIB)
|
||||
@ -72,7 +72,7 @@ SHL1OBJS= $(SLO)$/eos2met.obj
|
||||
SHL1VERSIONMAP=exports.map
|
||||
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
|
||||
DEF1NAME=$(SHL1TARGET)
|
||||
|
||||
.ENDIF
|
||||
# ==========================================================================
|
||||
|
||||
.INCLUDE : target.mk
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <vcl/graph.hxx>
|
||||
#include <vcl/bmpacc.hxx>
|
||||
#include <vcl/msgbox.hxx>
|
||||
#include <svtools/solar.hrc>
|
||||
#include <svl/solar.hrc>
|
||||
#include <svtools/fltcall.hxx>
|
||||
#include <svtools/FilterConfigItem.hxx>
|
||||
#include "strings.hrc"
|
||||
|
@ -49,15 +49,15 @@ CDEFS+= -DEDITDEBUG
|
||||
SRS1NAME=$(TARGET)
|
||||
SRC1FILES= dlgepbm.src \
|
||||
epbmstr.src
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SLOFILES = $(SLO)$/epbm.obj \
|
||||
$(SLO)$/dlgepbm.obj
|
||||
|
||||
.ENDIF
|
||||
# ==========================================================================
|
||||
|
||||
RESLIB1NAME=$(TARGET2)
|
||||
RESLIB1SRSFILES=$(SRS)$/$(TARGET).srs
|
||||
|
||||
.IF "$(L10N_framework)"==""
|
||||
SHL1TARGET= epb$(DLLPOSTFIX)
|
||||
SHL1IMPLIB= epbm
|
||||
SHL1STDLIBS= $(TOOLSLIB) $(VCLLIB) $(CPPULIB) $(SVTOOLLIB) $(SALLIB)
|
||||
@ -73,7 +73,7 @@ SHL1OBJS= $(SLO)$/epbm.obj
|
||||
SHL1VERSIONMAP=exports.map
|
||||
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
|
||||
DEF1NAME=$(SHL1TARGET)
|
||||
|
||||
.ENDIF
|
||||
# ==========================================================================
|
||||
|
||||
.INCLUDE : target.mk
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user