summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drawinglayer/source/attribute/fillhatchattribute.cxx17
-rw-r--r--drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx42
-rw-r--r--drawinglayer/source/primitive2d/metafileprimitive2d.cxx1
-rw-r--r--drawinglayer/source/primitive2d/primitivetools2d.cxx2
-rw-r--r--include/drawinglayer/attribute/fillhatchattribute.hxx14
-rw-r--r--include/drawinglayer/primitive2d/fillhatchprimitive2d.hxx11
-rw-r--r--include/drawinglayer/primitive2d/primitivetools2d.hxx7
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx1
-rw-r--r--svx/source/sdr/overlay/overlaytools.cxx1
-rw-r--r--svx/source/sdr/primitive2d/sdrattributecreator.cxx1
10 files changed, 88 insertions, 9 deletions
diff --git a/drawinglayer/source/attribute/fillhatchattribute.cxx b/drawinglayer/source/attribute/fillhatchattribute.cxx
index e89628b43a69..1d56badae5ee 100644
--- a/drawinglayer/source/attribute/fillhatchattribute.cxx
+++ b/drawinglayer/source/attribute/fillhatchattribute.cxx
@@ -35,6 +35,7 @@ namespace drawinglayer
double mfDistance;
double mfAngle;
basegfx::BColor maColor;
+ sal_uInt32 mnMinimalDiscreteDistance;
// bitfield
unsigned mbFillBackground : 1;
@@ -44,11 +45,13 @@ namespace drawinglayer
double fDistance,
double fAngle,
const basegfx::BColor& rColor,
+ sal_uInt32 nMinimalDiscreteDistance,
bool bFillBackground)
: meStyle(eStyle),
mfDistance(fDistance),
mfAngle(fAngle),
maColor(rColor),
+ mnMinimalDiscreteDistance(nMinimalDiscreteDistance),
mbFillBackground(bFillBackground)
{
}
@@ -58,6 +61,7 @@ namespace drawinglayer
mfDistance(0.0),
mfAngle(0.0),
maColor(basegfx::BColor()),
+ mnMinimalDiscreteDistance(3), // same as VCL
mbFillBackground(false)
{
}
@@ -67,6 +71,7 @@ namespace drawinglayer
double getDistance() const { return mfDistance; }
double getAngle() const { return mfAngle; }
const basegfx::BColor& getColor() const { return maColor; }
+ sal_uInt32 getMinimalDiscreteDistance() const { return mnMinimalDiscreteDistance; }
bool isFillBackground() const { return mbFillBackground; }
bool operator==(const ImpFillHatchAttribute& rCandidate) const
@@ -75,7 +80,8 @@ namespace drawinglayer
&& getDistance() == rCandidate.getDistance()
&& getAngle() == rCandidate.getAngle()
&& getColor() == rCandidate.getColor()
- && isFillBackground() == rCandidate.isFillBackground());
+ && getMinimalDiscreteDistance() == rCandidate.getMinimalDiscreteDistance()
+ && isFillBackground() == rCandidate.isFillBackground());
}
};
@@ -90,9 +96,11 @@ namespace drawinglayer
double fDistance,
double fAngle,
const basegfx::BColor& rColor,
+ sal_uInt32 nMinimalDiscreteDistance,
bool bFillBackground)
: mpFillHatchAttribute(ImpFillHatchAttribute(
- eStyle, fDistance, fAngle, rColor, bFillBackground))
+ eStyle, fDistance, fAngle, rColor,
+ nMinimalDiscreteDistance, bFillBackground))
{
}
@@ -147,6 +155,11 @@ namespace drawinglayer
return mpFillHatchAttribute->getColor();
}
+ sal_uInt32 FillHatchAttribute::getMinimalDiscreteDistance() const
+ {
+ return mpFillHatchAttribute->getMinimalDiscreteDistance();
+ }
+
bool FillHatchAttribute::isFillBackground() const
{
return mpFillHatchAttribute->isFillBackground();
diff --git a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
index 1fc7e32b2986..556265c7cebf 100644
--- a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
@@ -25,6 +25,7 @@
#include <basegfx/tools/canvastools.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
//////////////////////////////////////////////////////////////////////////////
@@ -39,12 +40,26 @@ namespace drawinglayer
Primitive2DSequence FillHatchPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
{
Primitive2DSequence aRetval;
+
if(!getFillHatch().isDefault())
{
// create hatch
const basegfx::BColor aHatchColor(getFillHatch().getColor());
const double fAngle(getFillHatch().getAngle());
::std::vector< basegfx::B2DHomMatrix > aMatrices;
+ double fDistance(getFillHatch().getDistance());
+ const bool bAdaptDistance(0 != getFillHatch().getMinimalDiscreteDistance());
+
+ // #i120230# evtl. adapt distance
+ if(bAdaptDistance)
+ {
+ const double fDiscreteDistance(getFillHatch().getDistance() / getDiscreteUnit());
+
+ if(fDiscreteDistance < (double)getFillHatch().getMinimalDiscreteDistance())
+ {
+ fDistance = (double)getFillHatch().getMinimalDiscreteDistance() * getDiscreteUnit();
+ }
+ }
// get hatch transformations
switch(getFillHatch().getStyle())
@@ -52,7 +67,7 @@ namespace drawinglayer
case attribute::HATCHSTYLE_TRIPLE:
{
// rotated 45 degrees
- texture::GeoTexSvxHatch aHatch(getObjectRange(), getFillHatch().getDistance(), fAngle - F_PI4);
+ texture::GeoTexSvxHatch aHatch(getObjectRange(), fDistance, fAngle - F_PI4);
aHatch.appendTransformations(aMatrices);
// fall-through by purpose
@@ -60,7 +75,7 @@ namespace drawinglayer
case attribute::HATCHSTYLE_DOUBLE:
{
// rotated 90 degrees
- texture::GeoTexSvxHatch aHatch(getObjectRange(), getFillHatch().getDistance(), fAngle - F_PI2);
+ texture::GeoTexSvxHatch aHatch(getObjectRange(), fDistance, fAngle - F_PI2);
aHatch.appendTransformations(aMatrices);
// fall-through by purpose
@@ -68,7 +83,7 @@ namespace drawinglayer
case attribute::HATCHSTYLE_SINGLE:
{
// angle as given
- texture::GeoTexSvxHatch aHatch(getObjectRange(), getFillHatch().getDistance(), fAngle);
+ texture::GeoTexSvxHatch aHatch(getObjectRange(), fDistance, fAngle);
aHatch.appendTransformations(aMatrices);
}
}
@@ -113,7 +128,7 @@ namespace drawinglayer
const basegfx::B2DRange& rObjectRange,
const basegfx::BColor& rBColor,
const attribute::FillHatchAttribute& rFillHatch)
- : BufferedDecompositionPrimitive2D(),
+ : DiscreteMetricDependentPrimitive2D(),
maObjectRange(rObjectRange),
maFillHatch(rFillHatch),
maBColor(rBColor)
@@ -122,7 +137,7 @@ namespace drawinglayer
bool FillHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
{
- if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
{
const FillHatchPrimitive2D& rCompare = (FillHatchPrimitive2D&)rPrimitive;
@@ -140,6 +155,23 @@ namespace drawinglayer
return getObjectRange();
}
+ Primitive2DSequence FillHatchPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ bool bAdaptDistance(0 != getFillHatch().getMinimalDiscreteDistance());
+
+ if(bAdaptDistance)
+ {
+ // behave view-dependent
+ return DiscreteMetricDependentPrimitive2D::get2DDecomposition(rViewInformation);
+ }
+ else
+ {
+ // behave view-independent
+ return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
+ }
+ }
+
// provide unique ID
ImplPrimitrive2DIDBlock(FillHatchPrimitive2D, PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D)
diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
index f0767052d324..180d122dcc59 100644
--- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
@@ -958,6 +958,7 @@ namespace
(double)rHatch.GetDistance(),
(double)rHatch.GetAngle() * F_PI1800,
rHatch.GetColor().getBColor(),
+ 3, // same default as VCL, a minimum of three discrete units (pixels) offset
false);
}
diff --git a/drawinglayer/source/primitive2d/primitivetools2d.cxx b/drawinglayer/source/primitive2d/primitivetools2d.cxx
index 24c8341f6c18..063aa1cc073e 100644
--- a/drawinglayer/source/primitive2d/primitivetools2d.cxx
+++ b/drawinglayer/source/primitive2d/primitivetools2d.cxx
@@ -43,7 +43,7 @@ namespace drawinglayer
if(!getBuffered2DDecomposition().hasElements())
{
// remember new valid DiscreteUnit
- const_cast< DiscreteMetricDependentPrimitive2D* >(this)->mfDiscreteUnit = fDiscreteUnit;
+ const_cast< DiscreteMetricDependentPrimitive2D* >(this)->updateDiscreteUnit(fDiscreteUnit);
}
// call base implementation
diff --git a/include/drawinglayer/attribute/fillhatchattribute.hxx b/include/drawinglayer/attribute/fillhatchattribute.hxx
index 7e6244be090b..30e054085815 100644
--- a/include/drawinglayer/attribute/fillhatchattribute.hxx
+++ b/include/drawinglayer/attribute/fillhatchattribute.hxx
@@ -69,6 +69,7 @@ namespace drawinglayer
double fDistance,
double fAngle,
const basegfx::BColor& rColor,
+ sal_uInt32 nMinimalDiscreteDistance,
bool bFillBackground);
FillHatchAttribute();
FillHatchAttribute(const FillHatchAttribute& rCandidate);
@@ -86,6 +87,19 @@ namespace drawinglayer
double getDistance() const;
double getAngle() const;
const basegfx::BColor& getColor() const;
+
+ // #i120230# If a minimal discrete distance is wanted (VCL used 3,
+ // this is the default for the global instance, too), set this
+ // unequal to zero. Zero means not to use it. If set bigger zero
+ // (should be at least two, one leads to a full plane filled with
+ // lines when Distance in discrete views is smaller than one) this
+ // will be used when the discrete value is less than the given one.
+ // This is used to 'emulate' old VCL behaviour which makes hatches
+ // look better by not making distances as small as needed, but
+ // keeping them on a minimal discrete value for more appealing
+ // visualisation.
+ sal_uInt32 getMinimalDiscreteDistance() const;
+
bool isFillBackground() const;
};
} // end of namespace attribute
diff --git a/include/drawinglayer/primitive2d/fillhatchprimitive2d.hxx b/include/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
index b0c27ba89107..f8e52c27d951 100644
--- a/include/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
@@ -23,6 +23,7 @@
#include <drawinglayer/drawinglayerdllapi.h>
#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <drawinglayer/primitive2d/primitivetools2d.hxx>
#include <drawinglayer/attribute/fillhatchattribute.hxx>
#include <basegfx/color/bcolor.hxx>
@@ -40,9 +41,14 @@ namespace drawinglayer
If the background is to be filled, a flag in FillHatchAttribute is set and
the BColor defines the background color.
+ #i120230# This primitive is now evtl. metric dependent due to the value
+ MinimalDiscreteDistance in the FillHatchAttribute if the value is not zero.
+ This is used for a more appealing, VCL-like visualisation by not letting the
+ distances get too small between lines.
+
The decomposition will deliver the hatch lines.
*/
- class DRAWINGLAYER_DLLPUBLIC FillHatchPrimitive2D : public BufferedDecompositionPrimitive2D
+ class DRAWINGLAYER_DLLPUBLIC FillHatchPrimitive2D : public DiscreteMetricDependentPrimitive2D
{
private:
/// the geometric definition
@@ -76,6 +82,9 @@ namespace drawinglayer
/// get range
virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
+ /// get local decomposition. Overloaded since this decomposition is view-dependent
+ virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
+
/// provide unique ID
DeclPrimitrive2DIDBlock()
};
diff --git a/include/drawinglayer/primitive2d/primitivetools2d.hxx b/include/drawinglayer/primitive2d/primitivetools2d.hxx
index 6ef63f1e916b..3d208231b7ea 100644
--- a/include/drawinglayer/primitive2d/primitivetools2d.hxx
+++ b/include/drawinglayer/primitive2d/primitivetools2d.hxx
@@ -47,6 +47,13 @@ namespace drawinglayer
*/
double mfDiscreteUnit;
+ protected:
+ /// helper to update discrete unit
+ void updateDiscreteUnit(double fNew)
+ {
+ mfDiscreteUnit = fNew;
+ }
+
public:
/// constructor
DiscreteMetricDependentPrimitive2D()
diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
index fe82ff2a6a11..cad3b14d9df3 100644
--- a/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
@@ -128,6 +128,7 @@ namespace sdr
125.0, // 1.25 mm
45.0 * F_PI180, // 45 degree diagonal
Color(COL_BLACK).getBColor(), // black color
+ 3, // same default as VCL, a minimum of three discrete units (pixels) offset
false); // no filling
const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(
diff --git a/svx/source/sdr/overlay/overlaytools.cxx b/svx/source/sdr/overlay/overlaytools.cxx
index 501ad81ac54b..181604c49b4c 100644
--- a/svx/source/sdr/overlay/overlaytools.cxx
+++ b/svx/source/sdr/overlay/overlaytools.cxx
@@ -230,6 +230,7 @@ namespace drawinglayer
getDiscreteHatchDistance() * getDiscreteUnit(),
getHatchRotation() - getRotation(),
getHatchColor(),
+ 3, // same default as VCL, a minimum of three discrete units (pixels) offset
false);
const Primitive2DReference aPrimitive(
new PolyPolygonHatchPrimitive2D(
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
index 88fce3ce1f3b..10e3dd171a60 100644
--- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx
+++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
@@ -453,6 +453,7 @@ namespace drawinglayer
(double)rHatch.GetDistance(),
(double)rHatch.GetAngle() * F_PI1800,
aColorB.getBColor(),
+ 3, // same default as VCL, a minimum of three discrete units (pixels) offset
((const XFillBackgroundItem&)(rSet.Get(XATTR_FILLBACKGROUND))).GetValue());
break;