summaryrefslogtreecommitdiff
path: root/drawinglayer/source
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-05-04 14:16:22 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-03-13 11:22:20 +0000
commiteceecd4a3806f64c2e8fb0a3bcdcc43e1384779f (patch)
treee8c81552d7e3a1374a903cf5ca522a6eb77853e3 /drawinglayer/source
parentcc22c25de9be13596960b8af6c6f40fc2e3fd27d (diff)
Related: #i119125# corrected gradient rendering
and added stuff to add Title and Description to primitives for later usage Conflicts: drawinglayer/Library_drawinglayer.mk drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx svgio/Package_inc.mk svx/source/sdr/contact/viewcontactofsdrobj.cxx Change-Id: I301c9f5f4ae0efc02d937cd3f56018e27c94a630
Diffstat (limited to 'drawinglayer/source')
-rw-r--r--drawinglayer/source/primitive2d/objectinfoprimitive2d.cxx64
-rw-r--r--drawinglayer/source/primitive2d/svggradientprimitive2d.cxx102
-rw-r--r--drawinglayer/source/processor2d/vclprocessor2d.cxx35
3 files changed, 143 insertions, 58 deletions
diff --git a/drawinglayer/source/primitive2d/objectinfoprimitive2d.cxx b/drawinglayer/source/primitive2d/objectinfoprimitive2d.cxx
new file mode 100644
index 000000000000..e87b7c184ba7
--- /dev/null
+++ b/drawinglayer/source/primitive2d/objectinfoprimitive2d.cxx
@@ -0,0 +1,64 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
+#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ ObjectInfoPrimitive2D::ObjectInfoPrimitive2D(
+ const Primitive2DSequence& rChildren,
+ const rtl::OUString& rName,
+ const rtl::OUString& rTitle,
+ const rtl::OUString& rDesc)
+ : GroupPrimitive2D(rChildren),
+ maName(rName),
+ maTitle(rTitle),
+ maDesc(rDesc)
+ {
+ }
+
+ bool ObjectInfoPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(GroupPrimitive2D::operator==(rPrimitive))
+ {
+ const ObjectInfoPrimitive2D& rCompare = (ObjectInfoPrimitive2D&)rPrimitive;
+
+ return (getName() == rCompare.getName()
+ && getTitle() == rCompare.getTitle()
+ && getDesc() == rCompare.getDesc());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(ObjectInfoPrimitive2D, PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
index ef1c7ba7b3da..19788c308af5 100644
--- a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
@@ -354,13 +354,18 @@ namespace drawinglayer
rFrom.getColor(), rFrom.getOffset() + nOffset,
rTo.getColor(), rTo.getOffset() + nOffset));
- const double fTransFrom(1.0 - rFrom.getOpacity());
- const double fTransTo(1.0 - rTo.getOpacity());
+ if(!getFullyOpaque())
+ {
+ const double fTransFrom(1.0 - rFrom.getOpacity());
+ const double fTransTo(1.0 - rTo.getOpacity());
+ const basegfx::BColor aColorFrom(fTransFrom, fTransFrom, fTransFrom);
+ const basegfx::BColor aColorTo(fTransTo, fTransTo, fTransTo);
- rTargetOpacity.push_back(
- new SvgLinearAtomPrimitive2D(
- basegfx::BColor(fTransFrom, fTransFrom, fTransFrom), rFrom.getOffset() + nOffset,
- basegfx::BColor(fTransTo,fTransTo, fTransTo), rTo.getOffset() + nOffset));
+ rTargetOpacity.push_back(
+ new SvgLinearAtomPrimitive2D(
+ aColorFrom, rFrom.getOffset() + nOffset,
+ aColorTo, rTo.getOffset() + nOffset));
+ }
}
}
@@ -552,6 +557,10 @@ namespace drawinglayer
{
}
+ SvgLinearGradientPrimitive2D::~SvgLinearGradientPrimitive2D()
+ {
+ }
+
bool SvgLinearGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
{
const SvgGradientHelper* pSvgGradientHelper = dynamic_cast< const SvgGradientHelper* >(&rPrimitive);
@@ -635,27 +644,30 @@ namespace drawinglayer
rTo.getColor(), fScaleTo));
}
- const double fTransFrom(1.0 - rFrom.getOpacity());
- const double fTransTo(1.0 - rTo.getOpacity());
- const basegfx::BColor aColorFrom(fTransFrom, fTransFrom, fTransFrom);
- const basegfx::BColor aColorTo(fTransTo, fTransTo, fTransTo);
-
- if(isFocalSet())
+ if(!getFullyOpaque())
{
- const basegfx::B2DVector aTranslateFrom(maFocalVector * (maFocalLength - fScaleFrom));
- const basegfx::B2DVector aTranslateTo(maFocalVector * (maFocalLength - fScaleTo));
+ const double fTransFrom(1.0 - rFrom.getOpacity());
+ const double fTransTo(1.0 - rTo.getOpacity());
+ const basegfx::BColor aColorFrom(fTransFrom, fTransFrom, fTransFrom);
+ const basegfx::BColor aColorTo(fTransTo, fTransTo, fTransTo);
- rTargetOpacity.push_back(
- new SvgRadialAtomPrimitive2D(
- aColorFrom, fScaleFrom, aTranslateFrom,
- aColorTo, fScaleTo, aTranslateTo));
- }
- else
- {
- rTargetOpacity.push_back(
- new SvgRadialAtomPrimitive2D(
- aColorFrom, fScaleFrom,
- aColorTo, fScaleTo));
+ if(isFocalSet())
+ {
+ const basegfx::B2DVector aTranslateFrom(maFocalVector * (maFocalLength - fScaleFrom));
+ const basegfx::B2DVector aTranslateTo(maFocalVector * (maFocalLength - fScaleTo));
+
+ rTargetOpacity.push_back(
+ new SvgRadialAtomPrimitive2D(
+ aColorFrom, fScaleFrom, aTranslateFrom,
+ aColorTo, fScaleTo, aTranslateTo));
+ }
+ else
+ {
+ rTargetOpacity.push_back(
+ new SvgRadialAtomPrimitive2D(
+ aColorFrom, fScaleFrom,
+ aColorTo, fScaleTo));
+ }
}
}
}
@@ -826,7 +838,7 @@ namespace drawinglayer
maMirroredGradientEntries(),
mbFocalSet(false)
{
- if(pFocal)
+ if(pFocal && !pFocal->equal(getStart()))
{
maFocal = *pFocal;
maFocalVector = maFocal - getStart();
@@ -834,6 +846,10 @@ namespace drawinglayer
}
}
+ SvgRadialGradientPrimitive2D::~SvgRadialGradientPrimitive2D()
+ {
+ }
+
bool SvgRadialGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
{
const SvgGradientHelper* pSvgGradientHelper = dynamic_cast< const SvgGradientHelper* >(&rPrimitive);
@@ -893,28 +909,30 @@ namespace drawinglayer
// use color distance and discrete lengths to calculate step count
const sal_uInt32 nSteps(calculateStepsForSvgGradient(getColorA(), getColorB(), fDelta, fDiscreteUnit));
- // prepare loop and polygon (with overlap for linear gradients)
- double fStart(0.0);
- double fStep(fDelta / nSteps);
+ // prepare polygon in needed width at start position (with discrete overlap)
const basegfx::B2DPolygon aPolygon(
basegfx::tools::createPolygonFromRect(
basegfx::B2DRange(
getOffsetA() - fDiscreteUnit,
0.0,
- getOffsetA() + fStep + fDiscreteUnit,
+ getOffsetA() + (fDelta / nSteps) + fDiscreteUnit,
1.0)));
- // loop and create primitives
+ // prepare loop (inside to outside, [0.0 .. 1.0[)
+ double fUnitScale(0.0);
+ const double fUnitStep(1.0 / nSteps);
+
+ // prepare result set (known size)
xRetval.realloc(nSteps);
- for(sal_uInt32 a(0); a < nSteps; a++, fStart += fStep)
+ for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
{
basegfx::B2DPolygon aNew(aPolygon);
- aNew.transform(basegfx::tools::createTranslateB2DHomMatrix(fStart, 0.0));
+ aNew.transform(basegfx::tools::createTranslateB2DHomMatrix(fDelta * fUnitScale, 0.0));
xRetval[a] = new PolyPolygonColorPrimitive2D(
basegfx::B2DPolyPolygon(aNew),
- basegfx::interpolate(getColorA(), getColorB(), fStart/fDelta));
+ basegfx::interpolate(getColorA(), getColorB(), fUnitScale));
}
}
@@ -978,24 +996,24 @@ namespace drawinglayer
// use color distance and discrete lengths to calculate step count
const sal_uInt32 nSteps(calculateStepsForSvgGradient(getColorA(), getColorB(), fDeltaScale, fDiscreteUnit));
- // prepare loop (outside to inside, full polygons, no polypolygons with holes)
- double fEndScale(getScaleB());
- double fStepScale(fDeltaScale / nSteps);
+ // prepare loop ([0.0 .. 1.0[, full polygons, no polypolygons with holes)
+ double fUnitScale(0.0);
+ const double fUnitStep(1.0 / nSteps);
- // loop and create primitives
+ // prepare result set (known size)
xRetval.realloc(nSteps);
- for(sal_uInt32 a(0); a < nSteps; a++, fEndScale -= fStepScale)
+ for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
{
- const double fUnitScale(fEndScale/fDeltaScale);
basegfx::B2DHomMatrix aTransform;
+ const double fEndScale(getScaleB() - (fDeltaScale * fUnitScale));
if(isTranslateSet())
{
const basegfx::B2DVector aTranslate(
basegfx::interpolate(
- getTranslateA(),
getTranslateB(),
+ getTranslateA(),
fUnitScale));
aTransform = basegfx::tools::createScaleTranslateB2DHomMatrix(
@@ -1016,7 +1034,7 @@ namespace drawinglayer
aNew.transform(aTransform);
xRetval[a] = new PolyPolygonColorPrimitive2D(
basegfx::B2DPolyPolygon(aNew),
- basegfx::interpolate(getColorA(), getColorB(), fUnitScale));
+ basegfx::interpolate(getColorB(), getColorA(), fUnitScale));
}
}
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index 5a0710f0ce00..842306989d00 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -1430,27 +1430,30 @@ namespace drawinglayer
// use color distance and discrete lengths to calculate step count
const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, fDelta, fDiscreteUnit));
- // prepare loop and polygon
- double fStart(0.0);
- double fStep(fDelta / nSteps);
+ // switch off line painting
+ mpOutputDevice->SetLineColor();
+
+ // prepare polygon in needed width at start position (with discrete overlap)
const basegfx::B2DPolygon aPolygon(
basegfx::tools::createPolygonFromRect(
basegfx::B2DRange(
rCandidate.getOffsetA() - fDiscreteUnit,
0.0,
- rCandidate.getOffsetA() + fStep + fDiscreteUnit,
+ rCandidate.getOffsetA() + (fDelta / nSteps) + fDiscreteUnit,
1.0)));
- // switch off line painting
- mpOutputDevice->SetLineColor();
+
+ // prepare loop ([0.0 .. 1.0[)
+ double fUnitScale(0.0);
+ const double fUnitStep(1.0 / nSteps);
// loop and paint
- for(sal_uInt32 a(0); a < nSteps; a++, fStart += fStep)
+ for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
{
basegfx::B2DPolygon aNew(aPolygon);
- aNew.transform(maCurrentTransformation * basegfx::tools::createTranslateB2DHomMatrix(fStart, 0.0));
- mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorA, aColorB, fStart/fDelta)));
+ aNew.transform(maCurrentTransformation * basegfx::tools::createTranslateB2DHomMatrix(fDelta * fUnitScale, 0.0));
+ mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorA, aColorB, fUnitScale)));
mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
}
}
@@ -1472,21 +1475,21 @@ namespace drawinglayer
// switch off line painting
mpOutputDevice->SetLineColor();
- // prepare loop (outside to inside)
- double fEndScale(rCandidate.getScaleB());
- double fStepScale(fDeltaScale / nSteps);
+ // prepare loop ([0.0 .. 1.0[, full polygons, no polypolygons with holes)
+ double fUnitScale(0.0);
+ const double fUnitStep(1.0 / nSteps);
- for(sal_uInt32 a(0); a < nSteps; a++, fEndScale -= fStepScale)
+ for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
{
- const double fUnitScale(fEndScale/fDeltaScale);
basegfx::B2DHomMatrix aTransform;
+ const double fEndScale(rCandidate.getScaleB() - (fDeltaScale * fUnitScale));
if(rCandidate.isTranslateSet())
{
const basegfx::B2DVector aTranslate(
basegfx::interpolate(
- rCandidate.getTranslateA(),
rCandidate.getTranslateB(),
+ rCandidate.getTranslateA(),
fUnitScale));
aTransform = basegfx::tools::createScaleTranslateB2DHomMatrix(
@@ -1505,7 +1508,7 @@ namespace drawinglayer
basegfx::B2DPolygon aNew(basegfx::tools::createPolygonFromUnitCircle());
aNew.transform(maCurrentTransformation * aTransform);
- mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorA, aColorB, fUnitScale)));
+ mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorB, aColorA, fUnitScale)));
mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
}
}