summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-02-06 09:36:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-02-06 12:55:02 +0100
commit23abe10fb2d058dc25acd31ea089123c3cbe515c (patch)
tree02ec54850a9847de5f718ba1f908d4b3bf4b9d3e
parentbca870566c65e22d9665b9f7dcb2144ca0f59a8a (diff)
flatten some drawinglayer code
Change-Id: I2d7fd0da565e4cddb37ae2053c686d8e6befcf83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163039 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--drawinglayer/source/primitive2d/PolyPolygonHairlinePrimitive2D.cxx9
-rw-r--r--drawinglayer/source/primitive2d/PolyPolygonMarkerPrimitive2D.cxx11
-rw-r--r--drawinglayer/source/primitive2d/PolyPolygonStrokePrimitive2D.cxx9
-rw-r--r--drawinglayer/source/primitive2d/glowprimitive2d.cxx111
-rw-r--r--drawinglayer/source/primitive2d/metafileprimitive2d.cxx74
-rw-r--r--drawinglayer/source/primitive2d/patternfillprimitive2d.cxx10
-rw-r--r--drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx331
-rw-r--r--svx/source/sdr/primitive2d/sdrframeborderprimitive2d.cxx94
8 files changed, 318 insertions, 331 deletions
diff --git a/drawinglayer/source/primitive2d/PolyPolygonHairlinePrimitive2D.cxx b/drawinglayer/source/primitive2d/PolyPolygonHairlinePrimitive2D.cxx
index 2e4dc1dfe9f6..8f6ad15abb9e 100644
--- a/drawinglayer/source/primitive2d/PolyPolygonHairlinePrimitive2D.cxx
+++ b/drawinglayer/source/primitive2d/PolyPolygonHairlinePrimitive2D.cxx
@@ -34,13 +34,10 @@ void PolyPolygonHairlinePrimitive2D::create2DDecomposition(
const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
const sal_uInt32 nCount(aPolyPolygon.count());
- if (nCount)
+ for (sal_uInt32 a(0); a < nCount; a++)
{
- for (sal_uInt32 a(0); a < nCount; a++)
- {
- rContainer.push_back(
- new PolygonHairlinePrimitive2D(aPolyPolygon.getB2DPolygon(a), getBColor()));
- }
+ rContainer.push_back(
+ new PolygonHairlinePrimitive2D(aPolyPolygon.getB2DPolygon(a), getBColor()));
}
}
diff --git a/drawinglayer/source/primitive2d/PolyPolygonMarkerPrimitive2D.cxx b/drawinglayer/source/primitive2d/PolyPolygonMarkerPrimitive2D.cxx
index b486b76b9724..a8ee5e5d25de 100644
--- a/drawinglayer/source/primitive2d/PolyPolygonMarkerPrimitive2D.cxx
+++ b/drawinglayer/source/primitive2d/PolyPolygonMarkerPrimitive2D.cxx
@@ -34,14 +34,11 @@ void PolyPolygonMarkerPrimitive2D::create2DDecomposition(
const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
const sal_uInt32 nCount(aPolyPolygon.count());
- if (nCount)
+ for (sal_uInt32 a(0); a < nCount; a++)
{
- for (sal_uInt32 a(0); a < nCount; a++)
- {
- rContainer.push_back(new PolygonMarkerPrimitive2D(aPolyPolygon.getB2DPolygon(a),
- getRGBColorA(), getRGBColorB(),
- getDiscreteDashLength()));
- }
+ rContainer.push_back(new PolygonMarkerPrimitive2D(aPolyPolygon.getB2DPolygon(a),
+ getRGBColorA(), getRGBColorB(),
+ getDiscreteDashLength()));
}
}
diff --git a/drawinglayer/source/primitive2d/PolyPolygonStrokePrimitive2D.cxx b/drawinglayer/source/primitive2d/PolyPolygonStrokePrimitive2D.cxx
index 0b23c92bc606..2ee13898711e 100644
--- a/drawinglayer/source/primitive2d/PolyPolygonStrokePrimitive2D.cxx
+++ b/drawinglayer/source/primitive2d/PolyPolygonStrokePrimitive2D.cxx
@@ -34,13 +34,10 @@ void PolyPolygonStrokePrimitive2D::create2DDecomposition(
const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
const sal_uInt32 nCount(aPolyPolygon.count());
- if (nCount)
+ for (sal_uInt32 a(0); a < nCount; a++)
{
- for (sal_uInt32 a(0); a < nCount; a++)
- {
- rContainer.push_back(new PolygonStrokePrimitive2D(
- aPolyPolygon.getB2DPolygon(a), getLineAttribute(), getStrokeAttribute()));
- }
+ rContainer.push_back(new PolygonStrokePrimitive2D(
+ aPolyPolygon.getB2DPolygon(a), getLineAttribute(), getStrokeAttribute()));
}
}
diff --git a/drawinglayer/source/primitive2d/glowprimitive2d.cxx b/drawinglayer/source/primitive2d/glowprimitive2d.cxx
index c843129e7ec6..6bf9dea8af83 100644
--- a/drawinglayer/source/primitive2d/glowprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/glowprimitive2d.cxx
@@ -179,71 +179,70 @@ void GlowPrimitive2D::create2DDecomposition(
std::move(xEmbedSeq), aViewInformation2D, nDiscreteClippedWidth, nDiscreteClippedHeight,
nMaximumQuadraticPixels));
- if (!aAlpha.IsEmpty())
- {
- const Size& rBitmapExSizePixel(aAlpha.GetSizePixel());
+ if (aAlpha.IsEmpty())
+ return;
- if (rBitmapExSizePixel.Width() > 0 && rBitmapExSizePixel.Height() > 0)
- {
- // We may have to take a corrective scaling into account when the
- // MaximumQuadraticPixel limit was used/triggered
- double fScale(1.0);
+ const Size& rBitmapExSizePixel(aAlpha.GetSizePixel());
- if (static_cast<sal_uInt32>(rBitmapExSizePixel.Width()) != nDiscreteClippedWidth
- || static_cast<sal_uInt32>(rBitmapExSizePixel.Height()) != nDiscreteClippedHeight)
- {
- // scale in X and Y should be the same (see fReduceFactor in createAlphaMask),
- // so adapt numerically to a single scale value, they are integer rounded values
- const double fScaleX(static_cast<double>(rBitmapExSizePixel.Width())
- / static_cast<double>(nDiscreteClippedWidth));
- const double fScaleY(static_cast<double>(rBitmapExSizePixel.Height())
- / static_cast<double>(nDiscreteClippedHeight));
-
- fScale = (fScaleX + fScaleY) * 0.5;
- }
+ if (rBitmapExSizePixel.Width() <= 0 || rBitmapExSizePixel.Height() <= 0)
+ return;
- // fDiscreteGlowRadius is the size of the halo from each side of the object. The halo is the
- // border of glow color that fades from glow transparency level to fully transparent
- // When blurring a sharp boundary (our case), it gets 50% of original intensity, and
- // fades to both sides by the blur radius; thus blur radius is half of glow radius.
- // Consider glow transparency (initial transparency near the object edge)
- AlphaMask mask(ProcessAndBlurAlphaMask(aAlpha, fDiscreteGlowRadius * fScale / 2.0,
- fDiscreteGlowRadius * fScale / 2.0,
- 255 - getGlowColor().GetAlpha()));
+ // We may have to take a corrective scaling into account when the
+ // MaximumQuadraticPixel limit was used/triggered
+ double fScale(1.0);
- // The end result is the bitmap filled with glow color and blurred 8-bit alpha mask
- Bitmap bmp(aAlpha.GetSizePixel(), vcl::PixelFormat::N24_BPP);
- bmp.Erase(getGlowColor());
- BitmapEx result(bmp, mask);
+ if (static_cast<sal_uInt32>(rBitmapExSizePixel.Width()) != nDiscreteClippedWidth
+ || static_cast<sal_uInt32>(rBitmapExSizePixel.Height()) != nDiscreteClippedHeight)
+ {
+ // scale in X and Y should be the same (see fReduceFactor in createAlphaMask),
+ // so adapt numerically to a single scale value, they are integer rounded values
+ const double fScaleX(static_cast<double>(rBitmapExSizePixel.Width())
+ / static_cast<double>(nDiscreteClippedWidth));
+ const double fScaleY(static_cast<double>(rBitmapExSizePixel.Height())
+ / static_cast<double>(nDiscreteClippedHeight));
+
+ fScale = (fScaleX + fScaleY) * 0.5;
+ }
-#ifdef DBG_UTIL
- static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore
- if (bDoSaveForVisualControl)
- {
- // VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
- static const OUString sDumpPath(
- OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
- if (!sDumpPath.isEmpty())
- {
- SvFileStream aNew(sDumpPath + "test_glow.png",
- StreamMode::WRITE | StreamMode::TRUNC);
- vcl::PngImageWriter aPNGWriter(aNew);
- aPNGWriter.write(result);
- }
- }
-#endif
+ // fDiscreteGlowRadius is the size of the halo from each side of the object. The halo is the
+ // border of glow color that fades from glow transparency level to fully transparent
+ // When blurring a sharp boundary (our case), it gets 50% of original intensity, and
+ // fades to both sides by the blur radius; thus blur radius is half of glow radius.
+ // Consider glow transparency (initial transparency near the object edge)
+ AlphaMask mask(ProcessAndBlurAlphaMask(aAlpha, fDiscreteGlowRadius * fScale / 2.0,
+ fDiscreteGlowRadius * fScale / 2.0,
+ 255 - getGlowColor().GetAlpha()));
- // Independent from discrete sizes of glow alpha creation, always
- // map and project glow result to geometry range extended by glow
- // radius, but to the eventually clipped instance (ClippedRange)
- const primitive2d::Primitive2DReference xEmbedRefBitmap(new BitmapPrimitive2D(
- result, basegfx::utils::createScaleTranslateB2DHomMatrix(
- aClippedRange.getWidth(), aClippedRange.getHeight(),
- aClippedRange.getMinX(), aClippedRange.getMinY())));
+ // The end result is the bitmap filled with glow color and blurred 8-bit alpha mask
+ Bitmap bmp(aAlpha.GetSizePixel(), vcl::PixelFormat::N24_BPP);
+ bmp.Erase(getGlowColor());
+ BitmapEx result(bmp, mask);
- rContainer = primitive2d::Primitive2DContainer{ xEmbedRefBitmap };
+#ifdef DBG_UTIL
+ static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore
+ if (bDoSaveForVisualControl)
+ {
+ // VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
+ static const OUString sDumpPath(
+ OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
+ if (!sDumpPath.isEmpty())
+ {
+ SvFileStream aNew(sDumpPath + "test_glow.png", StreamMode::WRITE | StreamMode::TRUNC);
+ vcl::PngImageWriter aPNGWriter(aNew);
+ aPNGWriter.write(result);
}
}
+#endif
+
+ // Independent from discrete sizes of glow alpha creation, always
+ // map and project glow result to geometry range extended by glow
+ // radius, but to the eventually clipped instance (ClippedRange)
+ const primitive2d::Primitive2DReference xEmbedRefBitmap(
+ new BitmapPrimitive2D(result, basegfx::utils::createScaleTranslateB2DHomMatrix(
+ aClippedRange.getWidth(), aClippedRange.getHeight(),
+ aClippedRange.getMinX(), aClippedRange.getMinY())));
+
+ rContainer = primitive2d::Primitive2DContainer{ xEmbedRefBitmap };
}
// Using tooling class BufferedDecompositionGroupPrimitive2D now, so
diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
index d8c20c1ff72d..67f9fcdad4d3 100644
--- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
@@ -37,51 +37,51 @@ namespace drawinglayer::primitive2d
// but iterating will be the right thing to do when some push/pop is not closed
Primitive2DContainer xRetval(wmfemfhelper::interpretMetafile(getMetaFile(), rViewInformation));
- if(!xRetval.empty())
+ if(xRetval.empty())
+ return;
+
+ // get target size
+ const ::tools::Rectangle aMtfTarget(getMetaFile().GetPrefMapMode().GetOrigin(), getMetaFile().GetPrefSize());
+ const basegfx::B2DRange aMtfRange(vcl::unotools::b2DRectangleFromRectangle(aMtfTarget));
+
+ // tdf#113197 get content range and check if we have an overlap with
+ // defined target range (aMtfRange)
+ if (!aMtfRange.isEmpty())
{
- // get target size
- const ::tools::Rectangle aMtfTarget(getMetaFile().GetPrefMapMode().GetOrigin(), getMetaFile().GetPrefSize());
- const basegfx::B2DRange aMtfRange(vcl::unotools::b2DRectangleFromRectangle(aMtfTarget));
+ const basegfx::B2DRange aContentRange(xRetval.getB2DRange(rViewInformation));
- // tdf#113197 get content range and check if we have an overlap with
- // defined target range (aMtfRange)
- if (!aMtfRange.isEmpty())
+ // also test equal since isInside gives also true for equal
+ if (!aMtfRange.equal(aContentRange) && !aMtfRange.isInside(aContentRange))
{
- const basegfx::B2DRange aContentRange(xRetval.getB2DRange(rViewInformation));
-
- // also test equal since isInside gives also true for equal
- if (!aMtfRange.equal(aContentRange) && !aMtfRange.isInside(aContentRange))
- {
- // contentRange is partly larger than aMtfRange (stuff sticks
- // outside), clipping is needed
- const drawinglayer::primitive2d::Primitive2DReference xMask(
- new drawinglayer::primitive2d::MaskPrimitive2D(
- basegfx::B2DPolyPolygon(
- basegfx::utils::createPolygonFromRect(
- aMtfRange)),
- std::move(xRetval)));
-
- xRetval = drawinglayer::primitive2d::Primitive2DContainer{ xMask };
- }
+ // contentRange is partly larger than aMtfRange (stuff sticks
+ // outside), clipping is needed
+ const drawinglayer::primitive2d::Primitive2DReference xMask(
+ new drawinglayer::primitive2d::MaskPrimitive2D(
+ basegfx::B2DPolyPolygon(
+ basegfx::utils::createPolygonFromRect(
+ aMtfRange)),
+ std::move(xRetval)));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DContainer{ xMask };
}
+ }
- // create transformation
- basegfx::B2DHomMatrix aAdaptedTransform;
+ // create transformation
+ basegfx::B2DHomMatrix aAdaptedTransform;
- aAdaptedTransform.translate(-aMtfTarget.Left(), -aMtfTarget.Top());
- aAdaptedTransform.scale(
- aMtfTarget.getOpenWidth() ? 1.0 / aMtfTarget.getOpenWidth() : 1.0,
- aMtfTarget.getOpenHeight() ? 1.0 / aMtfTarget.getOpenHeight() : 1.0);
- aAdaptedTransform = getTransform() * aAdaptedTransform;
+ aAdaptedTransform.translate(-aMtfTarget.Left(), -aMtfTarget.Top());
+ aAdaptedTransform.scale(
+ aMtfTarget.getOpenWidth() ? 1.0 / aMtfTarget.getOpenWidth() : 1.0,
+ aMtfTarget.getOpenHeight() ? 1.0 / aMtfTarget.getOpenHeight() : 1.0);
+ aAdaptedTransform = getTransform() * aAdaptedTransform;
- // embed to target transformation
- const Primitive2DReference aEmbeddedTransform(
- new TransformPrimitive2D(
- aAdaptedTransform,
- std::move(xRetval)));
+ // embed to target transformation
+ const Primitive2DReference aEmbeddedTransform(
+ new TransformPrimitive2D(
+ aAdaptedTransform,
+ std::move(xRetval)));
- xRetval = Primitive2DContainer { aEmbeddedTransform };
- }
+ xRetval = Primitive2DContainer { aEmbeddedTransform };
rContainer.append(std::move(xRetval));
}
diff --git a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
index 42875ba42570..84ff2f39a142 100644
--- a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
@@ -254,12 +254,10 @@ namespace drawinglayer::primitive2d
}
// embed result in mask
- {
- rContainer.push_back(
- new MaskPrimitive2D(
- getMask(),
- std::move(aRetval)));
- }
+ rContainer.push_back(
+ new MaskPrimitive2D(
+ getMask(),
+ std::move(aRetval)));
}
PatternFillPrimitive2D::PatternFillPrimitive2D(
diff --git a/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx b/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
index e575c4279b24..633a525f3628 100644
--- a/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
@@ -33,179 +33,180 @@ namespace drawinglayer::primitive2d
{
void WallpaperBitmapPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const
{
+
+ if(getLocalObjectRange().isEmpty() || getBitmapEx().IsEmpty())
+ return;
+
Primitive2DReference aRetval;
- if(!getLocalObjectRange().isEmpty() && !getBitmapEx().IsEmpty())
- {
- // get bitmap PIXEL size
- const Size& rPixelSize = getBitmapEx().GetSizePixel();
+ // get bitmap PIXEL size
+ const Size& rPixelSize = getBitmapEx().GetSizePixel();
- if(rPixelSize.Width() > 0 && rPixelSize.Height() > 0)
+ if(rPixelSize.Width() <= 0 || rPixelSize.Height() <= 0)
+ return;
+
+ if(WallpaperStyle::Scale == getWallpaperStyle())
+ {
+ // shortcut for scale; use simple BitmapPrimitive2D
+ basegfx::B2DHomMatrix aObjectTransform;
+
+ aObjectTransform.set(0, 0, getLocalObjectRange().getWidth());
+ aObjectTransform.set(1, 1, getLocalObjectRange().getHeight());
+ aObjectTransform.set(0, 2, getLocalObjectRange().getMinX());
+ aObjectTransform.set(1, 2, getLocalObjectRange().getMinY());
+
+ aRetval.set(
+ new BitmapPrimitive2D(
+ getBitmapEx(),
+ aObjectTransform));
+ }
+ else
+ {
+ // transform to logic size
+ basegfx::B2DHomMatrix aInverseViewTransformation(getViewTransformation());
+ aInverseViewTransformation.invert();
+ basegfx::B2DVector aLogicSize(rPixelSize.Width(), rPixelSize.Height());
+ aLogicSize = aInverseViewTransformation * aLogicSize;
+
+ // apply layout
+ basegfx::B2DPoint aTargetTopLeft(getLocalObjectRange().getMinimum());
+ bool bUseTargetTopLeft(true);
+ bool bNeedsClipping(false);
+
+ switch(getWallpaperStyle())
{
- if(WallpaperStyle::Scale == getWallpaperStyle())
+ default: //case WallpaperStyle::Tile :, also WallpaperStyle::NONE and WallpaperStyle::ApplicationGradient
+ {
+ bUseTargetTopLeft = false;
+ break;
+ }
+ case WallpaperStyle::Scale :
+ {
+ // handled by shortcut above
+ break;
+ }
+ case WallpaperStyle::TopLeft :
+ {
+ // nothing to do
+ break;
+ }
+ case WallpaperStyle::Top :
+ {
+ const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
+ aTargetTopLeft.setX(aCenter.getX() - (aLogicSize.getX() * 0.5));
+ break;
+ }
+ case WallpaperStyle::TopRight :
+ {
+ aTargetTopLeft.setX(getLocalObjectRange().getMaxX() - aLogicSize.getX());
+ break;
+ }
+ case WallpaperStyle::Left :
+ {
+ const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
+ aTargetTopLeft.setY(aCenter.getY() - (aLogicSize.getY() * 0.5));
+ break;
+ }
+ case WallpaperStyle::Center :
+ {
+ const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
+ aTargetTopLeft = aCenter - (aLogicSize * 0.5);
+ break;
+ }
+ case WallpaperStyle::Right :
+ {
+ const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
+ aTargetTopLeft.setX(getLocalObjectRange().getMaxX() - aLogicSize.getX());
+ aTargetTopLeft.setY(aCenter.getY() - (aLogicSize.getY() * 0.5));
+ break;
+ }
+ case WallpaperStyle::BottomLeft :
+ {
+ aTargetTopLeft.setY(getLocalObjectRange().getMaxY() - aLogicSize.getY());
+ break;
+ }
+ case WallpaperStyle::Bottom :
{
- // shortcut for scale; use simple BitmapPrimitive2D
- basegfx::B2DHomMatrix aObjectTransform;
-
- aObjectTransform.set(0, 0, getLocalObjectRange().getWidth());
- aObjectTransform.set(1, 1, getLocalObjectRange().getHeight());
- aObjectTransform.set(0, 2, getLocalObjectRange().getMinX());
- aObjectTransform.set(1, 2, getLocalObjectRange().getMinY());
-
- aRetval.set(
- new BitmapPrimitive2D(
- getBitmapEx(),
- aObjectTransform));
+ const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
+ aTargetTopLeft.setX(aCenter.getX() - (aLogicSize.getX() * 0.5));
+ aTargetTopLeft.setY(getLocalObjectRange().getMaxY() - aLogicSize.getY());
+ break;
}
- else
+ case WallpaperStyle::BottomRight :
+ {
+ aTargetTopLeft = getLocalObjectRange().getMaximum() - aLogicSize;
+ break;
+ }
+ }
+
+ if(bUseTargetTopLeft)
+ {
+ // fill target range
+ const basegfx::B2DRange aTargetRange(aTargetTopLeft, aTargetTopLeft + aLogicSize);
+
+ // create aligned, single BitmapPrimitive2D
+ basegfx::B2DHomMatrix aObjectTransform;
+
+ aObjectTransform.set(0, 0, aTargetRange.getWidth());
+ aObjectTransform.set(1, 1, aTargetRange.getHeight());
+ aObjectTransform.set(0, 2, aTargetRange.getMinX());
+ aObjectTransform.set(1, 2, aTargetRange.getMinY());
+
+ aRetval.set(
+ new BitmapPrimitive2D(
+ getBitmapEx(),
+ aObjectTransform));
+
+ // clip when not completely inside object range
+ bNeedsClipping = !getLocalObjectRange().isInside(aTargetRange);
+ }
+ else
+ {
+ // WallpaperStyle::Tile, WallpaperStyle::NONE, WallpaperStyle::ApplicationGradient
+ // convert to relative positions
+ const basegfx::B2DVector aRelativeSize(
+ aLogicSize.getX() / (getLocalObjectRange().getWidth() ? getLocalObjectRange().getWidth() : 1.0),
+ aLogicSize.getY() / (getLocalObjectRange().getHeight() ? getLocalObjectRange().getHeight() : 1.0));
+ basegfx::B2DPoint aRelativeTopLeft(0.0, 0.0);
+
+ if(WallpaperStyle::Tile != getWallpaperStyle())
{
- // transform to logic size
- basegfx::B2DHomMatrix aInverseViewTransformation(getViewTransformation());
- aInverseViewTransformation.invert();
- basegfx::B2DVector aLogicSize(rPixelSize.Width(), rPixelSize.Height());
- aLogicSize = aInverseViewTransformation * aLogicSize;
-
- // apply layout
- basegfx::B2DPoint aTargetTopLeft(getLocalObjectRange().getMinimum());
- bool bUseTargetTopLeft(true);
- bool bNeedsClipping(false);
-
- switch(getWallpaperStyle())
- {
- default: //case WallpaperStyle::Tile :, also WallpaperStyle::NONE and WallpaperStyle::ApplicationGradient
- {
- bUseTargetTopLeft = false;
- break;
- }
- case WallpaperStyle::Scale :
- {
- // handled by shortcut above
- break;
- }
- case WallpaperStyle::TopLeft :
- {
- // nothing to do
- break;
- }
- case WallpaperStyle::Top :
- {
- const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
- aTargetTopLeft.setX(aCenter.getX() - (aLogicSize.getX() * 0.5));
- break;
- }
- case WallpaperStyle::TopRight :
- {
- aTargetTopLeft.setX(getLocalObjectRange().getMaxX() - aLogicSize.getX());
- break;
- }
- case WallpaperStyle::Left :
- {
- const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
- aTargetTopLeft.setY(aCenter.getY() - (aLogicSize.getY() * 0.5));
- break;
- }
- case WallpaperStyle::Center :
- {
- const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
- aTargetTopLeft = aCenter - (aLogicSize * 0.5);
- break;
- }
- case WallpaperStyle::Right :
- {
- const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
- aTargetTopLeft.setX(getLocalObjectRange().getMaxX() - aLogicSize.getX());
- aTargetTopLeft.setY(aCenter.getY() - (aLogicSize.getY() * 0.5));
- break;
- }
- case WallpaperStyle::BottomLeft :
- {
- aTargetTopLeft.setY(getLocalObjectRange().getMaxY() - aLogicSize.getY());
- break;
- }
- case WallpaperStyle::Bottom :
- {
- const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter());
- aTargetTopLeft.setX(aCenter.getX() - (aLogicSize.getX() * 0.5));
- aTargetTopLeft.setY(getLocalObjectRange().getMaxY() - aLogicSize.getY());
- break;
- }
- case WallpaperStyle::BottomRight :
- {
- aTargetTopLeft = getLocalObjectRange().getMaximum() - aLogicSize;
- break;
- }
- }
-
- if(bUseTargetTopLeft)
- {
- // fill target range
- const basegfx::B2DRange aTargetRange(aTargetTopLeft, aTargetTopLeft + aLogicSize);
-
- // create aligned, single BitmapPrimitive2D
- basegfx::B2DHomMatrix aObjectTransform;
-
- aObjectTransform.set(0, 0, aTargetRange.getWidth());
- aObjectTransform.set(1, 1, aTargetRange.getHeight());
- aObjectTransform.set(0, 2, aTargetRange.getMinX());
- aObjectTransform.set(1, 2, aTargetRange.getMinY());
-
- aRetval.set(
- new BitmapPrimitive2D(
- getBitmapEx(),
- aObjectTransform));
-
- // clip when not completely inside object range
- bNeedsClipping = !getLocalObjectRange().isInside(aTargetRange);
- }
- else
- {
- // WallpaperStyle::Tile, WallpaperStyle::NONE, WallpaperStyle::ApplicationGradient
- // convert to relative positions
- const basegfx::B2DVector aRelativeSize(
- aLogicSize.getX() / (getLocalObjectRange().getWidth() ? getLocalObjectRange().getWidth() : 1.0),
- aLogicSize.getY() / (getLocalObjectRange().getHeight() ? getLocalObjectRange().getHeight() : 1.0));
- basegfx::B2DPoint aRelativeTopLeft(0.0, 0.0);
-
- if(WallpaperStyle::Tile != getWallpaperStyle())
- {
- aRelativeTopLeft.setX(0.5 - aRelativeSize.getX());
- aRelativeTopLeft.setY(0.5 - aRelativeSize.getY());
- }
-
- // prepare FillGraphicAttribute
- const attribute::FillGraphicAttribute aFillGraphicAttribute(
- Graphic(getBitmapEx()),
- basegfx::B2DRange(aRelativeTopLeft, aRelativeTopLeft+ aRelativeSize),
- true);
-
- // create ObjectTransform
- const basegfx::B2DHomMatrix aObjectTransform(
- basegfx::utils::createScaleTranslateB2DHomMatrix(
- getLocalObjectRange().getRange(),
- getLocalObjectRange().getMinimum()));
-
- // create FillBitmapPrimitive
- aRetval.set(
- new drawinglayer::primitive2d::FillGraphicPrimitive2D(
- aObjectTransform,
- aFillGraphicAttribute));
-
- // always embed tiled fill to clipping
- bNeedsClipping = true;
- }
-
- if(bNeedsClipping)
- {
- // embed to clipping; this is necessary for tiled fills
- basegfx::B2DPolyPolygon aPolyPolygon(
- basegfx::utils::createPolygonFromRect(getLocalObjectRange()));
- const drawinglayer::primitive2d::Primitive2DReference xClippedFill(
- new drawinglayer::primitive2d::MaskPrimitive2D(
- std::move(aPolyPolygon),
- { aRetval }));
- aRetval = xClippedFill;
- }
+ aRelativeTopLeft.setX(0.5 - aRelativeSize.getX());
+ aRelativeTopLeft.setY(0.5 - aRelativeSize.getY());
}
+
+ // prepare FillGraphicAttribute
+ const attribute::FillGraphicAttribute aFillGraphicAttribute(
+ Graphic(getBitmapEx()),
+ basegfx::B2DRange(aRelativeTopLeft, aRelativeTopLeft+ aRelativeSize),
+ true);
+
+ // create ObjectTransform
+ const basegfx::B2DHomMatrix aObjectTransform(
+ basegfx::utils::createScaleTranslateB2DHomMatrix(
+ getLocalObjectRange().getRange(),
+ getLocalObjectRange().getMinimum()));
+
+ // create FillBitmapPrimitive
+ aRetval.set(
+ new drawinglayer::primitive2d::FillGraphicPrimitive2D(
+ aObjectTransform,
+ aFillGraphicAttribute));
+
+ // always embed tiled fill to clipping
+ bNeedsClipping = true;
+ }
+
+ if(bNeedsClipping)
+ {
+ // embed to clipping; this is necessary for tiled fills
+ basegfx::B2DPolyPolygon aPolyPolygon(
+ basegfx::utils::createPolygonFromRect(getLocalObjectRange()));
+ const drawinglayer::primitive2d::Primitive2DReference xClippedFill(
+ new drawinglayer::primitive2d::MaskPrimitive2D(
+ std::move(aPolyPolygon),
+ { aRetval }));
+ aRetval = xClippedFill;
}
}
diff --git a/svx/source/sdr/primitive2d/sdrframeborderprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrframeborderprimitive2d.cxx
index e2f2fa772dd8..02a1373aa004 100644
--- a/svx/source/sdr/primitive2d/sdrframeborderprimitive2d.cxx
+++ b/svx/source/sdr/primitive2d/sdrframeborderprimitive2d.cxx
@@ -780,65 +780,63 @@ namespace drawinglayer::primitive2d
? mfMinimalNonZeroBorderWidthUsedForDecompose
: 0.0);
+ // decompose all buffered SdrFrameBorderData entries and try to merge them
+ // to reduce existing number of BorderLinePrimitive2D(s)
+ for(const auto& rCandidate : getFrameBorders())
{
- // decompose all buffered SdrFrameBorderData entries and try to merge them
- // to reduce existing number of BorderLinePrimitive2D(s)
- for(const auto& rCandidate : getFrameBorders())
- {
- // get decomposition on one SdrFrameBorderData entry
- Primitive2DContainer aPartial;
- rCandidate.create2DDecomposition(
- aPartial,
- fMinimalDiscreteUnit);
+ // get decomposition on one SdrFrameBorderData entry
+ Primitive2DContainer aPartial;
+ rCandidate.create2DDecomposition(
+ aPartial,
+ fMinimalDiscreteUnit);
- for(const auto& aCandidatePartial : aPartial)
+ for(const auto& aCandidatePartial : aPartial)
+ {
+ if(aRetval.empty())
{
- if(aRetval.empty())
- {
- // no local data yet, just add as 1st entry, done
- aRetval.append(aCandidatePartial);
- }
- else
+ // no local data yet, just add as 1st entry, done
+ aRetval.append(aCandidatePartial);
+ }
+ else
+ {
+ bool bDidMerge(false);
+
+ for(auto& aCandidateRetval : aRetval)
{
- bool bDidMerge(false);
+ // try to merge by appending new data to existing data
+ const drawinglayer::primitive2d::Primitive2DReference aMergeRetvalPartial(
+ drawinglayer::primitive2d::tryMergeBorderLinePrimitive2D(
+ static_cast<BorderLinePrimitive2D*>(aCandidateRetval.get()),
+ static_cast<BorderLinePrimitive2D*>(aCandidatePartial.get())));
- for(auto& aCandidateRetval : aRetval)
+ if(aMergeRetvalPartial.is())
{
- // try to merge by appending new data to existing data
- const drawinglayer::primitive2d::Primitive2DReference aMergeRetvalPartial(
- drawinglayer::primitive2d::tryMergeBorderLinePrimitive2D(
- static_cast<BorderLinePrimitive2D*>(aCandidateRetval.get()),
- static_cast<BorderLinePrimitive2D*>(aCandidatePartial.get())));
-
- if(aMergeRetvalPartial.is())
- {
- // could append, replace existing data with merged data, done
- aCandidateRetval = aMergeRetvalPartial;
- bDidMerge = true;
- break;
- }
-
- // try to merge by appending existing data to new data
- const drawinglayer::primitive2d::Primitive2DReference aMergePartialRetval(
- drawinglayer::primitive2d::tryMergeBorderLinePrimitive2D(
- static_cast<BorderLinePrimitive2D*>(aCandidatePartial.get()),
- static_cast<BorderLinePrimitive2D*>(aCandidateRetval.get())));
-
- if(aMergePartialRetval.is())
- {
- // could append, replace existing data with merged data, done
- aCandidateRetval = aMergePartialRetval;
- bDidMerge = true;
- break;
- }
+ // could append, replace existing data with merged data, done
+ aCandidateRetval = aMergeRetvalPartial;
+ bDidMerge = true;
+ break;
}
- if(!bDidMerge)
+ // try to merge by appending existing data to new data
+ const drawinglayer::primitive2d::Primitive2DReference aMergePartialRetval(
+ drawinglayer::primitive2d::tryMergeBorderLinePrimitive2D(
+ static_cast<BorderLinePrimitive2D*>(aCandidatePartial.get()),
+ static_cast<BorderLinePrimitive2D*>(aCandidateRetval.get())));
+
+ if(aMergePartialRetval.is())
{
- // no merge after checking all existing data, append as new segment
- aRetval.append(aCandidatePartial);
+ // could append, replace existing data with merged data, done
+ aCandidateRetval = aMergePartialRetval;
+ bDidMerge = true;
+ break;
}
}
+
+ if(!bDidMerge)
+ {
+ // no merge after checking all existing data, append as new segment
+ aRetval.append(aCandidatePartial);
+ }
}
}
}