From e7ca5458fe9b87768206d1a653b5d0ff60acbf95 Mon Sep 17 00:00:00 2001 From: Armin Weiss Date: Thu, 20 Sep 2007 08:51:46 +0000 Subject: #i39532# Waveline usage, tuning text primitive --- .../primitive2d/drawinglayer_primitivetypes2d.hxx | 6 +- .../primitive2d/polygonprimitive2d.hxx | 52 +++++++- .../primitive2d/textdecoratedprimitive2d.hxx | 42 ++----- .../primitive2d/wrongspellprimitive2d.hxx | 97 +++++++++++++++ .../drawinglayer/processor2d/vclprocessor2d.hxx | 6 +- drawinglayer/prj/d.lst | 1 + drawinglayer/source/primitive2d/makefile.mk | 7 +- .../source/primitive2d/polygonprimitive2d.cxx | 94 +++++++++++++- .../primitive2d/textdecoratedprimitive2d.cxx | 132 +++++++++++++------- .../source/primitive2d/wrongspellprimitive2d.cxx | 138 +++++++++++++++++++++ .../source/processor2d/vclmetafileprocessor2d.cxx | 10 +- .../source/processor2d/vclpixelprocessor2d.cxx | 25 +++- drawinglayer/source/processor2d/vclprocessor2d.cxx | 117 ++++++++--------- 13 files changed, 567 insertions(+), 160 deletions(-) create mode 100644 drawinglayer/inc/drawinglayer/primitive2d/wrongspellprimitive2d.hxx create mode 100644 drawinglayer/source/primitive2d/wrongspellprimitive2d.cxx (limited to 'drawinglayer') diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 181d641f4b59..fdd625966bfb 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: drawinglayer_primitivetypes2d.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2007-08-03 10:43:04 $ + * last change: $Author: aw $ $Date: 2007-09-20 09:51:21 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -88,6 +88,8 @@ #define PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 39) #define PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 40) #define PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 41) +#define PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 42) +#define PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 43) ////////////////////////////////////////////////////////////////////////////// diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx index 64ee7d0a8cdb..ef3ad8117670 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: polygonprimitive2d.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2006-11-07 15:49:05 $ + * last change: $Author: aw $ $Date: 2007-09-20 09:51:21 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -134,8 +134,8 @@ namespace drawinglayer class PolygonStrokePrimitive2D : public BasePrimitive2D { private: - basegfx::B2DPolygon maPolygon; - attribute::StrokeAttribute maStrokeAttribute; + basegfx::B2DPolygon maPolygon; + attribute::StrokeAttribute maStrokeAttribute; protected: // local decomposition. @@ -162,6 +162,50 @@ namespace drawinglayer } // end of namespace primitive2d } // end of namespace drawinglayer +////////////////////////////////////////////////////////////////////////////// +// PolygonStrokePrimitive2D class + +namespace drawinglayer +{ + namespace primitive2d + { + class PolygonWavePrimitive2D : public BasePrimitive2D + { + private: + basegfx::B2DPolygon maPolygon; + basegfx::BColor maBColor; + double mfWaveWidth; + double mfWaveHeight; + + protected: + // local decomposition. + virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + PolygonWavePrimitive2D( + const basegfx::B2DPolygon& rPolygon, + const basegfx::BColor& rBColor, + double fWaveWidth, + double fWaveHeight); + + // get data + basegfx::B2DPolygon getB2DPolygon() const { return maPolygon; } + const basegfx::BColor& getBColor() const { return maBColor; } + double getWaveWidth() const { return mfWaveWidth; } + double getWaveHeight() const { return mfWaveHeight; } + + // compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + + // get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + // provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + ////////////////////////////////////////////////////////////////////////////// // PolygonStrokeArrowPrimitive2D class diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx index f5fe74965cee..5a505129e6f9 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: textdecoratedprimitive2d.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2007-08-03 10:43:04 $ + * last change: $Author: aw $ $Date: 2007-09-20 09:51:21 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -40,6 +40,10 @@ #include #endif +#ifndef _COM_SUN_STAR_I18N_XBREAKITERATOR_HPP_ +#include +#endif + ////////////////////////////////////////////////////////////////////////////// namespace drawinglayer @@ -94,29 +98,6 @@ namespace drawinglayer FONT_RELIEF_ENGRAVED }; - class WrongSpellEntry - { - sal_uInt32 mnStart; - sal_uInt32 mnEnd; - - public: - WrongSpellEntry(sal_uInt32 nS, sal_uInt32 nE) - : mnStart(nS), - mnEnd(nE) - {} - - // compare operator - bool operator==(const WrongSpellEntry& rEntry) const - { - return (mnStart == rEntry.mnStart && mnEnd == rEntry.mnEnd); - } - - sal_uInt32 getStart() const { return mnStart; } - sal_uInt32 getEnd() const { return mnEnd; } - }; - - typedef std::vector< WrongSpellEntry > WrongSpellVector; - class TextDecoratedPortionPrimitive2D : public TextSimplePortionPrimitive2D { private: @@ -125,7 +106,6 @@ namespace drawinglayer FontStrikeout meFontStrikeout; FontEmphasisMark meFontEmphasisMark; FontRelief meFontRelief; - WrongSpellVector maWrongSpellVector; // bitfield unsigned mbUnderlineAbove : 1; @@ -134,6 +114,12 @@ namespace drawinglayer unsigned mbEmphasisMarkBelow : 1; unsigned mbShadow : 1; + // break iterator support + // made static so it only needs to be fetched once, even with many single + // constructed VclMetafileProcessor2D. It's still incarnated on demand, + // but exists for OOo runtime now by purpose. + static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > mxBreakIterator; + protected: // local decomposition. virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; @@ -159,8 +145,7 @@ namespace drawinglayer bool bEmphasisMarkAbove = true, bool bEmphasisMarkBelow = false, FontRelief eFontRelief = FONT_RELIEF_NONE, - bool bShadow = false, - const WrongSpellVector& rWrongSpellVector = WrongSpellVector()); + bool bShadow = false); // get data FontUnderline getFontUnderline() const { return meFontUnderline; } @@ -168,7 +153,6 @@ namespace drawinglayer FontEmphasisMark getFontEmphasisMark() const { return meFontEmphasisMark; } FontRelief getFontRelief() const { return meFontRelief; } basegfx::BColor getTextlineColor() const { return maTextlineColor; } - const WrongSpellVector& getWrongSpellVector() const { return maWrongSpellVector; } bool getUnderlineAbove() const { return mbUnderlineAbove; } bool getWordLineMode() const { return mbWordLineMode; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/wrongspellprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/wrongspellprimitive2d.hxx new file mode 100644 index 000000000000..91dc7391f36d --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/wrongspellprimitive2d.hxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: wrongspellprimitive2d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2007-09-20 09:51:21 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_WRONGSPELLPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_WRONGSPELLPRIMITIVE2D_HXX + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BASEPRIMITIVE2D_HXX +#include +#endif + +#ifndef _BGFX_COLOR_BCOLOR_HXX +#include +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include +#endif + +////////////////////////////////////////////////////////////////////////////// +// WrongSpellPrimitive2D class + +namespace drawinglayer +{ + namespace primitive2d + { + class WrongSpellPrimitive2D : public BasePrimitive2D + { + private: + basegfx::B2DHomMatrix maTransformation; + double mfStart; + double mfStop; + basegfx::BColor maColor; + + protected: + // create local decomposition + virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + WrongSpellPrimitive2D( + const basegfx::B2DHomMatrix& rTransformation, + double fStart, + double fStop, + const basegfx::BColor& rColor); + + // get data + const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } + double getStart() const { return mfStart; } + double getStop() const { return mfStop; } + const basegfx::BColor& getColor() const { return maColor; } + + // 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_WRONGSPELLPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx index e1355140e37b..593239caa0bd 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: vclprocessor2d.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2007-07-27 09:03:17 $ + * last change: $Author: aw $ $Date: 2007-09-20 09:51:21 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -70,6 +70,7 @@ namespace drawinglayer { namespace primitive2d { class MarkerArrayPrimitive2D; class PointArrayPrimitive2D; class ModifiedColorPrimitive2D; + class WrongSpellPrimitive2D; }} ////////////////////////////////////////////////////////////////////////////// @@ -106,6 +107,7 @@ namespace drawinglayer void RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate); void RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate); void RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate); + void RenderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate); // as tooling, the process() implementation takes over API handling and calls this // virtual render method when the primitive implementation is BasePrimitive2D-based. diff --git a/drawinglayer/prj/d.lst b/drawinglayer/prj/d.lst index 57f4ba6487bd..250866a5398d 100644 --- a/drawinglayer/prj/d.lst +++ b/drawinglayer/prj/d.lst @@ -39,6 +39,7 @@ mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive2d ..\inc\drawinglayer\primitive2d\texthierarchyprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\texthierarchyprimitive2d.hxx ..\inc\drawinglayer\primitive2d\transformprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\transformprimitive2d.hxx ..\inc\drawinglayer\primitive2d\unifiedalphaprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\unifiedalphaprimitive2d.hxx +..\inc\drawinglayer\primitive2d\wrongspellprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\wrongspellprimitive2d.hxx mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive3d ..\inc\drawinglayer\primitive3d\drawinglayer_primitivetypes3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\drawinglayer_primitivetypes3d.hxx diff --git a/drawinglayer/source/primitive2d/makefile.mk b/drawinglayer/source/primitive2d/makefile.mk index 75d589019299..3b28b07ce7ce 100644 --- a/drawinglayer/source/primitive2d/makefile.mk +++ b/drawinglayer/source/primitive2d/makefile.mk @@ -4,9 +4,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.6 $ +# $Revision: 1.7 $ # -# last change: $Author: aw $ $Date: 2007-08-03 10:43:04 $ +# last change: $Author: aw $ $Date: 2007-09-20 09:51:38 $ # # The Contents of this file are made available subject to # the terms of GNU Lesser General Public License Version 2.1. @@ -75,7 +75,8 @@ SLOFILES= \ $(SLO)$/textdecoratedprimitive2d.obj \ $(SLO)$/texthierarchyprimitive2d.obj \ $(SLO)$/transformprimitive2d.obj \ - $(SLO)$/unifiedalphaprimitive2d.obj + $(SLO)$/unifiedalphaprimitive2d.obj \ + $(SLO)$/wrongspellprimitive2d.obj # --- Targets ---------------------------------- diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx index 9c5957d30d14..336bfaf7d097 100644 --- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: polygonprimitive2d.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2007-03-06 12:34:30 $ + * last change: $Author: aw $ $Date: 2007-09-20 09:51:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -315,6 +315,96 @@ namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence PolygonWavePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + Primitive2DSequence aRetval; + + if(getB2DPolygon().count()) + { + const bool bHasWidth(!basegfx::fTools::equalZero(getWaveWidth())); + const bool bHasHeight(!basegfx::fTools::equalZero(getWaveHeight())); + + if(bHasWidth && bHasHeight) + { + // create waveline curve + const basegfx::B2DPolygon aWaveline(basegfx::tools::createWaveline(getB2DPolygon(), getWaveWidth(), getWaveHeight())); + const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(aWaveline, getBColor())); + aRetval = Primitive2DSequence(&xRef, 1); + } + else + { + // flat waveline, decompose to PolygonHairlinePrimitive2D + const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(getB2DPolygon(), getBColor())); + aRetval = Primitive2DSequence(&xRef, 1); + } + } + + return aRetval; + } + + PolygonWavePrimitive2D::PolygonWavePrimitive2D( + const basegfx::B2DPolygon& rPolygon, + const basegfx::BColor& rBColor, + double fWaveWidth, + double fWaveHeight) + : BasePrimitive2D(), + maPolygon(rPolygon), + maBColor(rBColor), + mfWaveWidth(fWaveWidth), + mfWaveHeight(fWaveHeight) + { + if(mfWaveWidth < 0.0) + { + mfWaveWidth = 0.0; + } + + if(mfWaveHeight < 0.0) + { + mfWaveHeight = 0.0; + } + } + + bool PolygonWavePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const PolygonWavePrimitive2D& rCompare = (PolygonWavePrimitive2D&)rPrimitive; + + return (getB2DPolygon() == rCompare.getB2DPolygon() + && getBColor() == rCompare.getBColor() + && getWaveWidth() == rCompare.getWaveWidth() + && getWaveHeight() == rCompare.getWaveHeight()); + } + + return false; + } + + basegfx::B2DRange PolygonWavePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // get range of it (subdivided) + basegfx::B2DRange aRetval(basegfx::tools::getRange(basegfx::tools::adaptiveSubdivideByAngle(getB2DPolygon()))); + + // if WaveHeight, grow by it + if(!basegfx::fTools::equalZero(getWaveHeight())) + { + aRetval.grow(getWaveHeight()); + } + + return aRetval; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(PolygonWavePrimitive2D, PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive2d diff --git a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx index f03fc284179c..80c00afe22e8 100644 --- a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: textdecoratedprimitive2d.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2007-08-13 15:30:25 $ + * last change: $Author: aw $ $Date: 2007-09-20 09:51:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -61,6 +61,86 @@ namespace drawinglayer { namespace primitive2d { +/* Primitive2DSequence TextDecoratedPortionPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + const sal_uInt16 nTextLength(getText().Len()); + Primitive2DSequence aRetval; + + if(nTextLength) + { + if(getWordLineMode()) + { + // support for single word mode + if(!mxBreakIterator.is()) + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF(::comphelper::getProcessServiceFactory()); + mxBreakIterator.set(xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator")), ::com::sun::star::uno::UNO_QUERY); + } + + if(mxBreakIterator.is()) + { + for(sal_Int32 nPos(0); nPos < nTextLength;) + { + ::com::sun::star::i18n::Boundary nNextWordBoundary(mxBreakIterator->getWordBoundary( + getText(), nPos, getLocale(), ::com::sun::star::i18n::WordType::ANY_WORD, sal_True)); + const String aNewText(getText(), nPos, nNextWordBoundary - nPos); + ::std::vector< double > aNewDXArray(getDXArray().begin() + nPos, getDXArray().end() + nNextWordBoundary); + + TextDecoratedPortionPrimitive2D aNewPrimitive( + getTextTransform(), + aNewText, + aNewDXArray, + getFontAttributes(), + getLocale(), + getFontColor(), + getTextlineColor(), + getFontUnderline(), + getUnderlineAbove(), + getFontStrikeout(), + false, // no WordLineMode + getFontEmphasisMark(), + getEmphasisMarkAbove(), + getEmphasisMarkBelow(), + RELIEF_NONE, // no relief + false); // no shadow + + appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aNewPrimitive.get2DDecomposition(rViewInformation)); + + nPos = nNextWordBoundary; + } + } + } + else + { + // no single words needed, decompose + std::vector< BasePrimitive2D* > aNewPrimitives; + + + + // prepare return sequence + for(sal_uInt32 a(0); a < aNewPrimitives.size(); a++) + { + aRetval[a] = Primitive2DReference(aNewPrimitives[a]); + } + } + + if(aRetval.hasElements()) + { + Primitive2DSequence aContent(aRetval); + + if(getShadow()) + { + } + + if(RELIEF_NONE != getFontRelief()) + { + } + } + } + + return aRetval; + } */ + Primitive2DSequence TextDecoratedPortionPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { std::vector< BasePrimitive2D* > aNewPrimitives; @@ -73,13 +153,11 @@ namespace drawinglayer const bool bNeedFontStrikeout(getFontStrikeout() != FONT_STRIKEOUT_NONE); const bool bNeedEmphasisMarkAbove(getEmphasisMarkAbove() != FONT_EMPHASISMARK_NONE); const bool bNeedEmphasisMarkBelow(getEmphasisMarkBelow() != FONT_EMPHASISMARK_NONE); - const sal_uInt32 nSpellVectorSize(maWrongSpellVector.size()); if(bNeedFontUnderline || bNeedFontStrikeout || bNeedEmphasisMarkAbove - || bNeedEmphasisMarkBelow - || 0 != nSpellVectorSize) + || bNeedEmphasisMarkBelow) { // prepare transformations basegfx::B2DVector aScale, aTranslate; @@ -376,46 +454,7 @@ namespace drawinglayer // if( getWordLineMode() ) // if( getUnderlineAbove() ) - if(nSpellVectorSize && !getDXArray().empty()) - { - // TODO: take care of WrongSpellVector; create redlining (red wavelines) accordingly. - // For test purposes, create single lines as long as no waveline primitive is created - const ::std::vector< double >& rDXArray = getDXArray(); - const sal_uInt32 nDXCount(rDXArray.size()); - const basegfx::BColor aSpellColor(1.0, 0.0, 0.0); // red - - for(sal_uInt32 a(0); a < nSpellVectorSize; a++) - { - const WrongSpellEntry& rCandidate = maWrongSpellVector[a]; - - if(rCandidate.getStart() < rCandidate.getEnd()) - { - ::basegfx::B2DPoint aStart; - ::basegfx::B2DPoint aEnd; - - if(rCandidate.getStart() > 0 && rCandidate.getStart() - 1 < nDXCount) - { - aStart.setX(rDXArray[rCandidate.getStart() - 1] * aScale.getX()); - } - - if(rCandidate.getEnd() > 0 && rCandidate.getEnd() - 1 < nDXCount) - { - aEnd.setX(rDXArray[rCandidate.getEnd() - 1] * aScale.getX()); - } - if(aStart != aEnd) - { - basegfx::B2DPolygon aPolygon; - - aPolygon.append(aStart); - aPolygon.append(aEnd); - aPolygon.transform(aUnscaledTransform); - - aNewPrimitives.push_back(new PolygonHairlinePrimitive2D(aPolygon, aSpellColor)); - } - } - } - } } // prepare return sequence @@ -449,15 +488,13 @@ namespace drawinglayer bool bEmphasisMarkAbove, bool bEmphasisMarkBelow, FontRelief eFontRelief, - bool bShadow, - const WrongSpellVector& rWrongSpellVector) + bool bShadow) : TextSimplePortionPrimitive2D(rNewTransform, rText, rDXArray, rFontAttributes, rLocale, rFontColor), maTextlineColor(rTextlineColor), meFontUnderline(eFontUnderline), meFontStrikeout(eFontStrikeout), meFontEmphasisMark(eFontEmphasisMark), meFontRelief(eFontRelief), - maWrongSpellVector(rWrongSpellVector), mbUnderlineAbove(bUnderlineAbove), mbWordLineMode(bWordLineMode), mbEmphasisMarkAbove(bEmphasisMarkAbove), @@ -477,7 +514,6 @@ namespace drawinglayer && getFontStrikeout() == rCompare.getFontStrikeout() && getFontEmphasisMark() == rCompare.getFontEmphasisMark() && getFontRelief() == rCompare.getFontRelief() - && getWrongSpellVector() == rCompare.getWrongSpellVector() && getUnderlineAbove() == rCompare.getUnderlineAbove() && getWordLineMode() == rCompare.getWordLineMode() && getEmphasisMarkAbove() == rCompare.getEmphasisMarkAbove() diff --git a/drawinglayer/source/primitive2d/wrongspellprimitive2d.cxx b/drawinglayer/source/primitive2d/wrongspellprimitive2d.cxx new file mode 100644 index 000000000000..bb59c16cb882 --- /dev/null +++ b/drawinglayer/source/primitive2d/wrongspellprimitive2d.cxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: wrongspellprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2007-09-20 09:51:38 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_WRONGSPELLPRIMITIVE2D_HXX +#include +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PRIMITIVETYPES2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence WrongSpellPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // ATM this decompose is view-independent, what the original VCL-Display is not. To mimic + // the old behaviour here if wanted it is necessary to add get2DDecomposition and implement + // it similar to the usage in e.g. HelplinePrimitive2D. Remembering the ViewTransformation + // should be enough then. + // The view-independent wavelines work well (if You ask me). Maybe the old VCL-Behaviour is only + // in place because it was not possible/too expensive at that time to scale the wavelines with the + // view... + // With the VCL-PixelRenderer this will not even be used since it implements WrongSpellPrimitive2D + // directly and mimics the old VCL-Display there. If You implemented a new renderer without + // direct WrongSpellPrimitive2D support, You may want to do the described change here. + + // get the font height (part of scale), so decompose the matrix + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + getTransformation().decompose(aScale, aTranslate, fRotate, fShearX); + + // calculate distances based on a static default (to allow testing in debugger) + static double fDefaultDistance(0.03); + const double fFontHeight(aScale.getY()); + const double fUnderlineDistance(fFontHeight * fDefaultDistance); + const double fWaveWidth(2.0 * fUnderlineDistance); + + // the Y-distance needs to be relativated to FontHeight since the points get + // transformed with the transformation containing that scale already. + const double fRelativeUnderlineDistance(basegfx::fTools::equalZero(aScale.getY()) ? 0.0 : fUnderlineDistance / aScale.getY()); + basegfx::B2DPoint aStart(getStart(), fRelativeUnderlineDistance); + basegfx::B2DPoint aStop(getStop(), fRelativeUnderlineDistance); + basegfx::B2DPolygon aPolygon; + + aPolygon.append(getTransformation() * aStart); + aPolygon.append(getTransformation() * aStop); + + // create the waveline primitive + Primitive2DReference xPrimitive(new PolygonWavePrimitive2D(aPolygon, getColor(), fWaveWidth, 0.5 * fWaveWidth)); + Primitive2DSequence xRetval(&xPrimitive, 1); + + return xRetval; + } + + WrongSpellPrimitive2D::WrongSpellPrimitive2D( + const basegfx::B2DHomMatrix& rTransformation, + double fStart, + double fStop, + const basegfx::BColor& rColor) + : BasePrimitive2D(), + maTransformation(rTransformation), + mfStart(fStart), + mfStop(fStop), + maColor(rColor) + { + } + + bool WrongSpellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const WrongSpellPrimitive2D& rCompare = (WrongSpellPrimitive2D&)rPrimitive; + + return (getTransformation() == rCompare.getTransformation() + && getStart() == rCompare.getStart() + && getStop() == rCompare.getStop() + && getColor() == rCompare.getColor()); + } + + return false; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(WrongSpellPrimitive2D, PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 58204eb7542e..21939c6e2658 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclmetafileprocessor2d.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2007-08-07 15:48:40 $ + * last change: $Author: aw $ $Date: 2007-09-20 09:51:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -633,6 +633,12 @@ namespace drawinglayer { switch(rCandidate.getPrimitiveID()) { + case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D : + { + // directdraw of wrong spell primitive + // Ignore for VclMetafileProcessor2D, this is for printing and MetaFile recording only + break; + } case PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D : { const primitive2d::GraphicPrimitive2D& rGraphicPrimitive = static_cast< const primitive2d::GraphicPrimitive2D& >(rCandidate); diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 6194a09150da..d0dca1bece22 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclpixelprocessor2d.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2007-08-08 15:27:54 $ + * last change: $Author: aw $ $Date: 2007-09-20 09:51:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -93,6 +93,10 @@ #include #endif +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_WRONGSPELLPRIMITIVE2D_HXX +#include +#endif + ////////////////////////////////////////////////////////////////////////////// namespace drawinglayer @@ -120,11 +124,26 @@ namespace drawinglayer { switch(rCandidate.getPrimitiveID()) { + case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D : + { + // directdraw of wrong spell primitive; added test possibility to check wrong spell decompose + static bool bHandleWrongSpellDirectly(true); + + if(bHandleWrongSpellDirectly) + { + RenderWrongSpellPrimitive2D(static_cast< const primitive2d::WrongSpellPrimitive2D& >(rCandidate)); + } + else + { + process(rCandidate.get2DDecomposition(getViewInformation2D())); + } + break; + } case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D : case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D : { // directdraw of text simple portion; added test possibility to check text decompose - static bool bHandleTextDirectly(true); + static bool bHandleTextDirectly(false); if(bHandleTextDirectly) { diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 9c33eee1df77..313a18c464e5 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclprocessor2d.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: aw $ $Date: 2007-08-08 15:27:54 $ + * last change: $Author: aw $ $Date: 2007-09-20 09:51:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -133,6 +133,10 @@ #include #endif +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_WRONGSPELLPRIMITIVE2D_HXX +#include +#endif + ////////////////////////////////////////////////////////////////////////////// using namespace com::sun::star; @@ -304,65 +308,6 @@ namespace drawinglayer mpOutputDevice->DrawTextArray(aStartPoint, rTextCandidate.getText(), aTransformedDXArray.size() ? &(aTransformedDXArray[0]) : NULL); bPrimitiveAccepted = true; - - if(pTCPP && aTransformedDXArray.size()) - { - // basic redlining support - const primitive2d::WrongSpellVector& rWrongSpellVector = pTCPP->getWrongSpellVector(); - const sal_uInt32 nSpellVectorSize(rWrongSpellVector.size()); - const sal_uInt32 nDXCount(aTransformedDXArray.size()); - - if(nSpellVectorSize && nDXCount) - { - const sal_uInt32 nFontPixelHeight(mpOutputDevice->LogicToPixel(Size(0, static_cast< sal_Int32 >(aScale.getY()))).Height()); - static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 5 - static const sal_uInt32 nSmallFontHeight(11); // #define WRONG_SHOW_SMALL 11 - static const sal_uInt32 nMediumFontHeight(15); // #define WRONG_SHOW_MEDIUM 15 - - if(nFontPixelHeight > nMinimumFontHeight) - { - sal_uInt16 nWaveStyle(WAVE_FLAT); - - if(nFontPixelHeight > nMediumFontHeight) - { - nWaveStyle = WAVE_NORMAL; - } - else if(nFontPixelHeight > nSmallFontHeight) - { - nWaveStyle = WAVE_SMALL; - } - - mpOutputDevice->SetLineColor(COL_LIGHTRED); - mpOutputDevice->SetFillColor(); - - for(sal_uInt32 a(0); a < nSpellVectorSize; a++) - { - const primitive2d::WrongSpellEntry& rCandidate = rWrongSpellVector[a]; - - if(rCandidate.getStart() < rCandidate.getEnd()) - { - Point aStart(aStartPoint); - Point aEnd(aStartPoint); - - if(rCandidate.getStart() > 0 && rCandidate.getStart() - 1 < nDXCount) - { - aStart += Point(aTransformedDXArray[rCandidate.getStart() - 1], 0); - } - - if(rCandidate.getEnd() > 0 && rCandidate.getEnd() - 1 < nDXCount) - { - aEnd += Point(aTransformedDXArray[rCandidate.getEnd() - 1], 0); - } - - if(aStart != aEnd) - { - mpOutputDevice->DrawWaveLine(aStart, aEnd, nWaveStyle); - } - } - } - } - } - } } } @@ -759,17 +704,24 @@ namespace drawinglayer // transform group. void VclProcessor2D::RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate) { - // remember current transformation - basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation); + // remember current transformation and ViewInformation + const basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation); + const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); - // create new transformations + // create new transformations for CurrentTransformation + // and for local ViewInformation2D maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation(); + maViewInformation2D = geometry::ViewInformation2D( + getViewInformation2D().getViewTransformation() * rTransformCandidate.getTransformation(), + getViewInformation2D().getViewport(), + getViewInformation2D().getViewTime()); - // let break down + // proccess content process(rTransformCandidate.getChildren()); // restore transformations maCurrentTransformation = aLastCurrentTransformation; + maViewInformation2D = aLastViewInformation2D; } // marker @@ -869,6 +821,41 @@ namespace drawinglayer } } + // wrong spell primitive + void VclProcessor2D::RenderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate) + { + const basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rWrongSpellCandidate.getTransformation()); + const basegfx::B2DVector aFontVectorPixel(aLocalTransform * basegfx::B2DVector(0.0, 1.0)); + const sal_uInt32 nFontPixelHeight(basegfx::fround(aFontVectorPixel.getLength())); + + static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 5 + static const sal_uInt32 nSmallFontHeight(11); // #define WRONG_SHOW_SMALL 11 + static const sal_uInt32 nMediumFontHeight(15); // #define WRONG_SHOW_MEDIUM 15 + + if(nFontPixelHeight > nMinimumFontHeight) + { + const basegfx::B2DPoint aStart(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0)); + const basegfx::B2DPoint aStop(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0)); + const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY())); + const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY())); + sal_uInt16 nWaveStyle(WAVE_FLAT); + + if(nFontPixelHeight > nMediumFontHeight) + { + nWaveStyle = WAVE_NORMAL; + } + else if(nFontPixelHeight > nSmallFontHeight) + { + nWaveStyle = WAVE_SMALL; + } + + const basegfx::BColor aProcessedColor(maBColorModifierStack.getModifiedColor(rWrongSpellCandidate.getColor())); + mpOutputDevice->SetLineColor(Color(aProcessedColor)); + mpOutputDevice->SetFillColor(); + mpOutputDevice->DrawWaveLine(aVclStart, aVclStop, nWaveStyle); + } + } + ////////////////////////////////////////////////////////////////////////////// // process support -- cgit