diff options
author | Armin Le Grand <alg@apache.org> | 2012-05-04 14:16:22 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-03-13 11:22:20 +0000 |
commit | eceecd4a3806f64c2e8fb0a3bcdcc43e1384779f (patch) | |
tree | e8c81552d7e3a1374a903cf5ca522a6eb77853e3 | |
parent | Translate German comments, clean up some whitespace (diff) | |
download | core-eceecd4a3806f64c2e8fb0a3bcdcc43e1384779f.tar.gz core-eceecd4a3806f64c2e8fb0a3bcdcc43e1384779f.zip |
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
23 files changed, 548 insertions, 126 deletions
diff --git a/drawinglayer/Library_drawinglayer.mk b/drawinglayer/Library_drawinglayer.mk index e913601c5f7a..8e7d44e1a3fe 100644 --- a/drawinglayer/Library_drawinglayer.mk +++ b/drawinglayer/Library_drawinglayer.mk @@ -112,6 +112,7 @@ $(eval $(call gb_Library_add_exception_objects,drawinglayer,\ drawinglayer/source/primitive2d/mediaprimitive2d \ drawinglayer/source/primitive2d/metafileprimitive2d \ drawinglayer/source/primitive2d/modifiedcolorprimitive2d \ + drawinglayer/source/primitive2d/objectinfoprimitive2d \ drawinglayer/source/primitive2d/pagepreviewprimitive2d \ drawinglayer/source/primitive2d/patternfillprimitive2d \ drawinglayer/source/primitive2d/pointarrayprimitive2d \ diff --git a/drawinglayer/Package_inc.mk b/drawinglayer/Package_inc.mk index 0a40b0f8db48..fe492b16101f 100644 --- a/drawinglayer/Package_inc.mk +++ b/drawinglayer/Package_inc.mk @@ -76,6 +76,7 @@ $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/ $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/mediaprimitive2d.hxx,drawinglayer/primitive2d/mediaprimitive2d.hxx)) $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/metafileprimitive2d.hxx,drawinglayer/primitive2d/metafileprimitive2d.hxx)) $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx,drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx)) +$(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/objectinfoprimitive2d.hxx,drawinglayer/primitive2d/objectinfoprimitive2d.hxx)) $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/pagepreviewprimitive2d.hxx,drawinglayer/primitive2d/pagepreviewprimitive2d.hxx)) $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/patternfillprimitive2d.hxx,drawinglayer/primitive2d/patternfillprimitive2d.hxx)) $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/pointarrayprimitive2d.hxx,drawinglayer/primitive2d/pointarrayprimitive2d.hxx)) diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index e44a8ebc1f23..cb8ff0efd0ff 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -100,6 +100,7 @@ #define PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 65) #define PRIMITIVE2D_ID_CROPPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 66) #define PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 67) +#define PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 68) #define PRIMITIVE2D_ID_CLIPPEDBORDERLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 68) diff --git a/drawinglayer/inc/drawinglayer/primitive2d/objectinfoprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/objectinfoprimitive2d.hxx new file mode 100644 index 000000000000..230a7399ff1d --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/objectinfoprimitive2d.hxx @@ -0,0 +1,73 @@ +/* + * 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 . + */ +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_INFOHIERARCHYPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_INFOHIERARCHYPRIMITIVE2D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <tools/string.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + /** ObjectInfoPrimitive2D class + + Info hierarchy helper class to hold contents like Name, Title and + Description which are valid for the child content, e.g. created for + primitives based on DrawingLayer objects or SVG parts. It decomposes + to it's content, so all direct renderers may ignore it. May e.g. + be used when re-creating graphical content from a sequence of primitives + */ + class DRAWINGLAYER_DLLPUBLIC ObjectInfoPrimitive2D : public GroupPrimitive2D + { + private: + rtl::OUString maName; + rtl::OUString maTitle; + rtl::OUString maDesc; + + public: + /// constructor + ObjectInfoPrimitive2D( + const Primitive2DSequence& rChildren, + const rtl::OUString& rName, + const rtl::OUString& rTitle, + const rtl::OUString& rDesc); + + /// data read access + const rtl::OUString& getName() const { return maName; } + const rtl::OUString& getTitle() const { return maTitle; } + const rtl::OUString& getDesc() const { return maDesc; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_INFOHIERARCHYPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx index 2c9e34fe96e1..0e7dab93ff14 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx @@ -203,7 +203,7 @@ namespace drawinglayer const basegfx::B2DPoint& rEnd, bool bUseUnitCoordinates, SpreadMethod aSpreadMethod = Spread_pad); - virtual ~SvgLinearGradientPrimitive2D() {} + virtual ~SvgLinearGradientPrimitive2D(); /// data read access const basegfx::B2DPoint& getEnd() const { return maEnd; } @@ -217,7 +217,7 @@ namespace drawinglayer /// provide unique ID DeclPrimitrive2DIDBlock() }; -} // end of namespace primitive2d + } // end of namespace primitive2d } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// @@ -272,6 +272,7 @@ namespace drawinglayer bool bUseUnitCoordinates, SpreadMethod aSpreadMethod = Spread_pad, const basegfx::B2DPoint* pFocal = 0); + virtual ~SvgRadialGradientPrimitive2D(); /// data read access double getRadius() const { return mfRadius; } 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)); } } diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk index 21312d6f76eb..cff8a0fb8307 100644 --- a/svgio/Library_svgio.mk +++ b/svgio/Library_svgio.mk @@ -66,6 +66,7 @@ $(eval $(call gb_Library_add_exception_objects,svgio,\ svgio/source/svgreader/svgsvgnode \ svgio/source/svgreader/svgsymbolnode \ svgio/source/svgreader/svgtextnode \ + svgio/source/svgreader/svgtitledescnode \ svgio/source/svgreader/svgtoken \ svgio/source/svgreader/svgtrefnode \ svgio/source/svgreader/svgtools \ diff --git a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx index ee1edf5ad67f..81682ab1c243 100644 --- a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx +++ b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx @@ -169,6 +169,8 @@ namespace svgio TextAnchor maTextAnchor; SvgPaint maColor; SvgNumber maOpacity; + rtl::OUString maTitle; + rtl::OUString maDesc; /// link to content. If set, the node can be fetched on demand rtl::OUString maClipPathXLink; @@ -373,6 +375,14 @@ namespace svgio const SvgNumber getOpacity() const { return maOpacity; } void setOpacity(const SvgNumber& rOpacity = SvgNumber()) { maOpacity = rOpacity; } + // Title content + const rtl::OUString& getTitle() const { return maTitle; } + void setTitle(const rtl::OUString& rNew) { maTitle = rNew; } + + // Desc content + const rtl::OUString& getDesc() const { return maDesc; } + void setDesc(const rtl::OUString& rNew) { maDesc = rNew; } + // ClipPathXLink content const rtl::OUString getClipPathXLink() const { return maClipPathXLink; } void setClipPathXLink(const rtl::OUString& rNew) { maClipPathXLink = rNew; } diff --git a/svgio/inc/svgio/svgreader/svgtitledescnode.hxx b/svgio/inc/svgio/svgreader/svgtitledescnode.hxx new file mode 100644 index 000000000000..d84b06dab1b5 --- /dev/null +++ b/svgio/inc/svgio/svgreader/svgtitledescnode.hxx @@ -0,0 +1,55 @@ +/* + * 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 . + */ +#ifndef INCLUDED_SVGIO_SVGREADER_SVGTITLEDESCNODE_HXX +#define INCLUDED_SVGIO_SVGREADER_SVGTITLEDESCNODE_HXX + +#include <svgio/svgreader/svgnode.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace svgio +{ + namespace svgreader + { + class SvgTitleDescNode : public SvgNode + { + private: + /// contained chars + rtl::OUString maText; + + public: + SvgTitleDescNode( + SVGToken aType, + SvgDocument& rDocument, + SvgNode* pParent); + virtual ~SvgTitleDescNode(); + + /// add new chars + void concatenate(const rtl::OUString& rChars); + + /// x content, set if found in current context + const rtl::OUString& getText() const { return maText; } + }; + } // end of namespace svgreader +} // end of namespace svgio + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_SVGIO_SVGREADER_SVGTITLEDESCNODE_HXX + +// eof diff --git a/svgio/inc/svgio/svgreader/svgtoken.hxx b/svgio/inc/svgio/svgreader/svgtoken.hxx index 0519d9c14680..e1218620a85d 100644 --- a/svgio/inc/svgio/svgreader/svgtoken.hxx +++ b/svgio/inc/svgio/svgreader/svgtoken.hxx @@ -103,6 +103,8 @@ namespace svgio SVGTokenPatternContentUnits, SVGTokenPatternTransform, SVGTokenOpacity, + SVGTokenTitle, + SVGTokenDesc, // AspectRatio and params SVGTokenPreserveAspectRatio, @@ -181,6 +183,8 @@ namespace svgio SVGToken StrToSVGToken(const rtl::OUString& rStr); + const rtl::OUString& getStrTitle(); + const rtl::OUString& getStrDesc(); } // end of namespace svgreader } // end of namespace svgio diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx index 9cad386043fb..29c40b30cd30 100644 --- a/svgio/source/svgreader/svgdocumenthandler.cxx +++ b/svgio/source/svgreader/svgdocumenthandler.cxx @@ -43,6 +43,7 @@ #include <svgio/svgreader/svgmasknode.hxx> #include <svgio/svgreader/svgmarkernode.hxx> #include <svgio/svgreader/svgpatternnode.hxx> +#include <svgio/svgreader/svgtitledescnode.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -246,6 +247,15 @@ namespace svgio break; } + /// title and description + case SVGTokenTitle: + case SVGTokenDesc: + { + /// new node for Title and/or Desc + mpTarget = new SvgTitleDescNode(aSVGToken, maDocument, mpTarget); + break; + } + /// gradients case SVGTokenLinearGradient: case SVGTokenRadialGradient: @@ -360,6 +370,7 @@ namespace svgio const SVGToken aSVGToken(StrToSVGToken(aName)); SvgNode* pWhitespaceCheck(SVGTokenText == aSVGToken ? mpTarget : 0); SvgStyleNode* pCssStyle(SVGTokenStyle == aSVGToken ? static_cast< SvgStyleNode* >(mpTarget) : 0); + SvgTitleDescNode* pSvgTitleDescNode(SVGTokenTitle == aSVGToken || SVGTokenDesc == aSVGToken ? static_cast< SvgTitleDescNode* >(mpTarget) : 0); switch(aSVGToken) { @@ -382,6 +393,10 @@ namespace svgio case SVGTokenRect: case SVGTokenImage: + /// title and description + case SVGTokenTitle: + case SVGTokenDesc: + /// gradients case SVGTokenLinearGradient: case SVGTokenRadialGradient: @@ -432,6 +447,23 @@ namespace svgio } } + if(pSvgTitleDescNode && mpTarget) + { + const rtl::OUString aText(pSvgTitleDescNode->getText()); + + if(aText.getLength()) + { + if(SVGTokenTitle == aSVGToken) + { + mpTarget->parseAttribute(getStrTitle(), aSVGToken, aText); + } + else // if(SVGTokenDesc == aSVGToken) + { + mpTarget->parseAttribute(getStrDesc(), aSVGToken, aText); + } + } + } + if(pCssStyle && pCssStyle->isTextCss()) { // css style parsing @@ -457,72 +489,74 @@ namespace svgio void SvgDocHdl::characters( const ::rtl::OUString& aChars ) throw (xml::sax::SAXException, uno::RuntimeException) { - if(mpTarget) - { - const sal_uInt32 nLength(aChars.getLength()); + const sal_uInt32 nLength(aChars.getLength()); - if(nLength && - (SVGTokenText == mpTarget->getType() || - SVGTokenTspan == mpTarget->getType() || - SVGTokenTextPath == mpTarget->getType() || - SVGTokenStyle == mpTarget->getType())) + if(mpTarget && nLength) + { + switch(mpTarget->getType()) { - switch(mpTarget->getType()) + case SVGTokenText: + case SVGTokenTspan: + case SVGTokenTextPath: { - case SVGTokenText: - case SVGTokenTspan: - case SVGTokenTextPath: - { - const SvgNodeVector& rChilds = mpTarget->getChildren(); - SvgCharacterNode* pTarget = 0; + const SvgNodeVector& rChilds = mpTarget->getChildren(); + SvgCharacterNode* pTarget = 0; - if(rChilds.size()) - { - pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1]); - } + if(rChilds.size()) + { + pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1]); + } - if(pTarget) - { - // concatenate to current character span - pTarget->concatenate(aChars); - } - else - { - // add character span as simplified tspan (no arguments) - // as direct child of SvgTextNode/SvgTspanNode/SvgTextPathNode - new SvgCharacterNode(maDocument, mpTarget, aChars); - } - break; + if(pTarget) + { + // concatenate to current character span + pTarget->concatenate(aChars); } - case SVGTokenStyle: + else { - SvgStyleNode& rSvgStyleNode = static_cast< SvgStyleNode& >(*mpTarget); + // add character span as simplified tspan (no arguments) + // as direct child of SvgTextNode/SvgTspanNode/SvgTextPathNode + new SvgCharacterNode(maDocument, mpTarget, aChars); + } + break; + } + case SVGTokenStyle: + { + SvgStyleNode& rSvgStyleNode = static_cast< SvgStyleNode& >(*mpTarget); - if(rSvgStyleNode.isTextCss()) + if(rSvgStyleNode.isTextCss()) + { + // collect characters for css style + if(maCssContents.size()) { - // collect characters for css style - if(maCssContents.size()) - { - const ::rtl::OUString aTrimmedChars(aChars.trim()); + const ::rtl::OUString aTrimmedChars(aChars.trim()); - if(aTrimmedChars.getLength()) - { - std::vector< rtl::OUString >::iterator aString(maCssContents.end() - 1); - (*aString) += aTrimmedChars; - } - } - else + if(aTrimmedChars.getLength()) { - OSL_ENSURE(false, "Closing CssStyle, but no collector string on stack (!)"); + std::vector< rtl::OUString >::iterator aString(maCssContents.end() - 1); + (*aString) += aTrimmedChars; } } - break; - } - default: - { - // characters not used by a known node - break; + else + { + OSL_ENSURE(false, "Closing CssStyle, but no collector string on stack (!)"); + } } + break; + } + case SVGTokenTitle: + case SVGTokenDesc: + { + SvgTitleDescNode& rSvgTitleDescNode = static_cast< SvgTitleDescNode& >(*mpTarget); + + // add text directly to SvgTitleDescNode + rSvgTitleDescNode.concatenate(aChars); + break; + } + default: + { + // characters not used by a known node + break; } } } diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index e453c08a3ebb..acab42aeadee 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -21,6 +21,7 @@ #include <svgio/svgreader/svgdocument.hxx> #include <svgio/svgreader/svgnode.hxx> #include <svgio/svgreader/svgstyleattributes.hxx> +#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -183,6 +184,40 @@ namespace svgio OSL_ENSURE(false, "Null-Pointer in child node list (!)"); } } + + if(rTarget.hasElements()) + { + const SvgStyleAttributes* pStyles = getSvgStyleAttributes(); + + if(pStyles) + { + // check if we have Title or Desc + const rtl::OUString& rTitle = pStyles->getTitle(); + const rtl::OUString& rDesc = pStyles->getDesc(); + + if(rTitle.getLength() || rDesc.getLength()) + { + // default object name is empty + rtl::OUString aObjectName; + + // use path as object name when outmost element + if(SVGTokenSvg == getType()) + { + aObjectName = getDocument().getAbsolutePath(); + } + + // pack in ObjectInfoPrimitive2D group + const drawinglayer::primitive2d::Primitive2DReference xRef( + new drawinglayer::primitive2d::ObjectInfoPrimitive2D( + rTarget, + aObjectName, + rTitle, + rDesc)); + + rTarget = drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1); + } + } + } } } diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index f015523671ba..f5370729d56e 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -1186,6 +1186,8 @@ namespace svgio maTextAnchor(TextAnchor_notset), maColor(), maOpacity(1.0), + maTitle(), + maDesc(), maClipPathXLink(), maMaskXLink(), maMarkerStartXLink(), @@ -1755,6 +1757,16 @@ namespace svgio } break; } + case SVGTokenTitle: + { + setTitle(aContent); + break; + } + case SVGTokenDesc: + { + setDesc(aContent); + break; + } case SVGTokenClipPathProperty: { readLocalUrl(aContent, maClipPathXLink); diff --git a/svgio/source/svgreader/svgtitledescnode.cxx b/svgio/source/svgreader/svgtitledescnode.cxx new file mode 100644 index 000000000000..2a5b546980ac --- /dev/null +++ b/svgio/source/svgreader/svgtitledescnode.cxx @@ -0,0 +1,48 @@ +/* + * 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 <svgio/svgreader/svgtitledescnode.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace svgio +{ + namespace svgreader + { + SvgTitleDescNode::SvgTitleDescNode( + SVGToken aType, + SvgDocument& rDocument, + SvgNode* pParent) + : SvgNode(aType, rDocument, pParent), + maText() + { + } + + SvgTitleDescNode::~SvgTitleDescNode() + { + } + + void SvgTitleDescNode::concatenate(const rtl::OUString& rChars) + { + maText += rChars; + } + } // end of namespace svgreader +} // end of namespace svgio + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx index 05e6441de202..44b20d49f2d6 100644 --- a/svgio/source/svgreader/svgtoken.cxx +++ b/svgio/source/svgreader/svgtoken.cxx @@ -92,6 +92,8 @@ namespace svgio static rtl::OUString aSVGStrPatternContentUnits(rtl::OUString::createFromAscii("patternContentUnits")); static rtl::OUString aSVGStrPatternTransform(rtl::OUString::createFromAscii("patternTransform")); static rtl::OUString aSVGStrOpacity(rtl::OUString::createFromAscii("opacity")); + static rtl::OUString aSVGStrTitle(rtl::OUString::createFromAscii("title")); + static rtl::OUString aSVGStrDesc(rtl::OUString::createFromAscii("desc")); static rtl::OUString aSVGStrPreserveAspectRatio(rtl::OUString::createFromAscii("preserveAspectRatio")); static rtl::OUString aSVGStrDefer(rtl::OUString::createFromAscii("defer")); @@ -231,6 +233,8 @@ namespace svgio aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPatternContentUnits, SVGTokenPatternContentUnits)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPatternTransform, SVGTokenPatternTransform)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrOpacity, SVGTokenOpacity)); + aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrTitle, SVGTokenTitle)); + aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrDesc, SVGTokenDesc)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPreserveAspectRatio, SVGTokenPreserveAspectRatio)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrDefer, SVGTokenDefer)); @@ -309,6 +313,16 @@ namespace svgio return aResult->second; } } + + const rtl::OUString& getStrTitle() + { + return aSVGStrTitle; + } + + const rtl::OUString& getStrDesc() + { + return aSVGStrDesc; + } } // end of namespace svgreader } // end of namespace svgio diff --git a/svx/inc/svx/sdr/contact/viewcontact.hxx b/svx/inc/svx/sdr/contact/viewcontact.hxx index 0a1c43905609..8e136e03afba 100644 --- a/svx/inc/svx/sdr/contact/viewcontact.hxx +++ b/svx/inc/svx/sdr/contact/viewcontact.hxx @@ -147,6 +147,11 @@ namespace sdr // add Gluepoints (if available) virtual drawinglayer::primitive2d::Primitive2DSequence createGluePointPrimitive2DSequence() const; + // allow embedding if needed (e.g. for SdrObjects, evtl. Name, Title and description get added). This + // is a helper normally used from getViewIndependentPrimitive2DSequence(), but there is one exception + // for 3D scenes + virtual drawinglayer::primitive2d::Primitive2DSequence embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence& rSource) const; + // delete all existing VOCs including DrawHierarchy which will invalidate all // visualisations, too. Used mostly at object removal from DrawHierarchy to // delete all existing VOCs by purpose, but can also be used for other purposes. diff --git a/svx/inc/svx/sdr/contact/viewcontactofsdrobj.hxx b/svx/inc/svx/sdr/contact/viewcontactofsdrobj.hxx index 26ce6ec42584..b628637cb707 100644 --- a/svx/inc/svx/sdr/contact/viewcontactofsdrobj.hxx +++ b/svx/inc/svx/sdr/contact/viewcontactofsdrobj.hxx @@ -80,6 +80,11 @@ namespace sdr // add Gluepoints (if available) virtual drawinglayer::primitive2d::Primitive2DSequence createGluePointPrimitive2DSequence() const; + + // allow embedding if needed (e.g. for SdrObjects, evtl. Name, Title and description get added). This + // is a helper normally used from getViewIndependentPrimitive2DSequence(), but there is one exception + // for 3D scenes + virtual drawinglayer::primitive2d::Primitive2DSequence embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence& rSource) const; }; } // end of namespace contact } // end of namespace sdr diff --git a/svx/source/sdr/contact/viewcontact.cxx b/svx/source/sdr/contact/viewcontact.cxx index 1dd952a7abd6..ff89ac6eaf39 100644 --- a/svx/source/sdr/contact/viewcontact.cxx +++ b/svx/source/sdr/contact/viewcontact.cxx @@ -277,7 +277,13 @@ namespace sdr drawinglayer::primitive2d::Primitive2DSequence ViewContact::getViewIndependentPrimitive2DSequence() const { // local up-to-date checks. Create new list and compare. - const drawinglayer::primitive2d::Primitive2DSequence xNew(createViewIndependentPrimitive2DSequence()); + drawinglayer::primitive2d::Primitive2DSequence xNew(createViewIndependentPrimitive2DSequence()); + + if(xNew.hasElements()) + { + // allow evtl. embedding in object-specific infos, e.g. Name, Title, Description + xNew = embedToObjectSpecificInformation(xNew); + } if(!drawinglayer::primitive2d::arePrimitive2DSequencesEqual(mxViewIndependentPrimitive2DSequence, xNew)) { @@ -296,6 +302,12 @@ namespace sdr return drawinglayer::primitive2d::Primitive2DSequence(); } + drawinglayer::primitive2d::Primitive2DSequence ViewContact::embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence& rSource) const + { + // nothing to do for default + return rSource; + } + void ViewContact::flushViewObjectContacts(bool bWithHierarchy) { if(bWithHierarchy) diff --git a/svx/source/sdr/contact/viewcontactofsdrobj.cxx b/svx/source/sdr/contact/viewcontactofsdrobj.cxx index 15c9429d06d8..72c4c608cf97 100644 --- a/svx/source/sdr/contact/viewcontactofsdrobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrobj.cxx @@ -28,6 +28,7 @@ #include <svx/sdr/contact/objectcontact.hxx> #include <basegfx/color/bcolor.hxx> #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> +#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx> #include <svx/sdr/contact/objectcontactofpageview.hxx> #include <svx/sdrpagewindow.hxx> #include <svx/sdrpaintwindow.hxx> @@ -175,6 +176,27 @@ namespace sdr return xRetval; } + + drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence& rSource) const + { + if(rSource.hasElements() && + (!GetSdrObject().GetName().isEmpty() || + !GetSdrObject().GetTitle().isEmpty() || + !GetSdrObject().GetDescription().isEmpty())) + { + const drawinglayer::primitive2d::Primitive2DReference xRef( + new drawinglayer::primitive2d::ObjectInfoPrimitive2D( + rSource, + GetSdrObject().GetName(), + GetSdrObject().GetTitle(), + GetSdrObject().GetDescription())); + + return drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1); + } + + return rSource; + } + } // end of namespace contact } // end of namespace sdr diff --git a/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx b/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx index 58e3cf828e49..e9515f082762 100644 --- a/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx @@ -90,6 +90,9 @@ namespace sdr if(xRetval.hasElements()) { + // allow evtl. embedding in object-specific infos, e.g. Name, Title, Description + xRetval = rViewContact.embedToObjectSpecificInformation(xRetval); + // handle GluePoint if(!GetObjectContact().isOutputToPrinter() && GetObjectContact().AreGluePointsVisible()) { diff --git a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx index aeccd8611bec..8548566eb93d 100644 --- a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx @@ -50,6 +50,19 @@ namespace drawinglayer getSdrLFSTAttribute().getFillFloatTransGradient())); } + // add graphic content + if(255L != getGraphicAttr().GetTransparency()) + { + // standard graphic fill + const Primitive2DReference xGraphicContentPrimitive( + new GraphicPrimitive2D( + getTransform(), + getGraphicObject(), + getGraphicAttr())); + + appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xGraphicContentPrimitive); + } + // add line if(!getSdrLFSTAttribute().getLine().isDefault()) { @@ -86,19 +99,6 @@ namespace drawinglayer } } - // add graphic content - if(255L != getGraphicAttr().GetTransparency()) - { - // standard graphic fill - const Primitive2DReference xGraphicContentPrimitive( - new GraphicPrimitive2D( - getTransform(), - getGraphicObject(), - getGraphicAttr())); - - appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xGraphicContentPrimitive); - } - // add text if(!getSdrLFSTAttribute().getText().isDefault()) { |