1*464702f4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*464702f4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*464702f4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*464702f4SAndrew Rist * distributed with this work for additional information 6*464702f4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*464702f4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*464702f4SAndrew Rist * "License"); you may not use this file except in compliance 9*464702f4SAndrew Rist * with the License. You may obtain a copy of the License at 10*464702f4SAndrew Rist * 11*464702f4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*464702f4SAndrew Rist * 13*464702f4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*464702f4SAndrew Rist * software distributed under the License is distributed on an 15*464702f4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*464702f4SAndrew Rist * KIND, either express or implied. See the License for the 17*464702f4SAndrew Rist * specific language governing permissions and limitations 18*464702f4SAndrew Rist * under the License. 19*464702f4SAndrew Rist * 20*464702f4SAndrew Rist *************************************************************/ 21*464702f4SAndrew Rist 22*464702f4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx> 28cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 29cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 30cdf0e10cSrcweir #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> 31cdf0e10cSrcweir #include <drawinglayer/geometry/viewinformation2d.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace drawinglayer 36cdf0e10cSrcweir { 37cdf0e10cSrcweir namespace primitive2d 38cdf0e10cSrcweir { create2DDecomposition(const geometry::ViewInformation2D &) const39cdf0e10cSrcweir Primitive2DSequence WrongSpellPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const 40cdf0e10cSrcweir { 41cdf0e10cSrcweir // ATM this decompose is view-independent, what the original VCL-Display is not. To mimic 42cdf0e10cSrcweir // the old behaviour here if wanted it is necessary to add get2DDecomposition and implement 43cdf0e10cSrcweir // it similar to the usage in e.g. HelplinePrimitive2D. Remembering the ViewTransformation 44cdf0e10cSrcweir // should be enough then. 45cdf0e10cSrcweir // The view-independent wavelines work well (if You ask me). Maybe the old VCL-Behaviour is only 46cdf0e10cSrcweir // in place because it was not possible/too expensive at that time to scale the wavelines with the 47cdf0e10cSrcweir // view... 48cdf0e10cSrcweir // With the VCL-PixelRenderer this will not even be used since it implements WrongSpellPrimitive2D 49cdf0e10cSrcweir // directly and mimics the old VCL-Display there. If You implemented a new renderer without 50cdf0e10cSrcweir // direct WrongSpellPrimitive2D support, You may want to do the described change here. 51cdf0e10cSrcweir 52cdf0e10cSrcweir // get the font height (part of scale), so decompose the matrix 53cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 54cdf0e10cSrcweir double fRotate, fShearX; 55cdf0e10cSrcweir getTransformation().decompose(aScale, aTranslate, fRotate, fShearX); 56cdf0e10cSrcweir 57cdf0e10cSrcweir // calculate distances based on a static default (to allow testing in debugger) 58cdf0e10cSrcweir static double fDefaultDistance(0.03); 59cdf0e10cSrcweir const double fFontHeight(aScale.getY()); 60cdf0e10cSrcweir const double fUnderlineDistance(fFontHeight * fDefaultDistance); 61cdf0e10cSrcweir const double fWaveWidth(2.0 * fUnderlineDistance); 62cdf0e10cSrcweir 63cdf0e10cSrcweir // the Y-distance needs to be relativated to FontHeight since the points get 64cdf0e10cSrcweir // transformed with the transformation containing that scale already. 65cdf0e10cSrcweir const double fRelativeUnderlineDistance(basegfx::fTools::equalZero(aScale.getY()) ? 0.0 : fUnderlineDistance / aScale.getY()); 66cdf0e10cSrcweir basegfx::B2DPoint aStart(getStart(), fRelativeUnderlineDistance); 67cdf0e10cSrcweir basegfx::B2DPoint aStop(getStop(), fRelativeUnderlineDistance); 68cdf0e10cSrcweir basegfx::B2DPolygon aPolygon; 69cdf0e10cSrcweir 70cdf0e10cSrcweir aPolygon.append(getTransformation() * aStart); 71cdf0e10cSrcweir aPolygon.append(getTransformation() * aStop); 72cdf0e10cSrcweir 73cdf0e10cSrcweir // prepare line attribute 74cdf0e10cSrcweir const attribute::LineAttribute aLineAttribute(getColor()); 75cdf0e10cSrcweir 76cdf0e10cSrcweir // create the waveline primitive 77cdf0e10cSrcweir Primitive2DReference xPrimitive(new PolygonWavePrimitive2D(aPolygon, aLineAttribute, fWaveWidth, 0.5 * fWaveWidth)); 78cdf0e10cSrcweir Primitive2DSequence xRetval(&xPrimitive, 1); 79cdf0e10cSrcweir 80cdf0e10cSrcweir return xRetval; 81cdf0e10cSrcweir } 82cdf0e10cSrcweir WrongSpellPrimitive2D(const basegfx::B2DHomMatrix & rTransformation,double fStart,double fStop,const basegfx::BColor & rColor)83cdf0e10cSrcweir WrongSpellPrimitive2D::WrongSpellPrimitive2D( 84cdf0e10cSrcweir const basegfx::B2DHomMatrix& rTransformation, 85cdf0e10cSrcweir double fStart, 86cdf0e10cSrcweir double fStop, 87cdf0e10cSrcweir const basegfx::BColor& rColor) 88cdf0e10cSrcweir : BufferedDecompositionPrimitive2D(), 89cdf0e10cSrcweir maTransformation(rTransformation), 90cdf0e10cSrcweir mfStart(fStart), 91cdf0e10cSrcweir mfStop(fStop), 92cdf0e10cSrcweir maColor(rColor) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir } 95cdf0e10cSrcweir operator ==(const BasePrimitive2D & rPrimitive) const96cdf0e10cSrcweir bool WrongSpellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 97cdf0e10cSrcweir { 98cdf0e10cSrcweir if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir const WrongSpellPrimitive2D& rCompare = (WrongSpellPrimitive2D&)rPrimitive; 101cdf0e10cSrcweir 102cdf0e10cSrcweir return (getTransformation() == rCompare.getTransformation() 103cdf0e10cSrcweir && getStart() == rCompare.getStart() 104cdf0e10cSrcweir && getStop() == rCompare.getStop() 105cdf0e10cSrcweir && getColor() == rCompare.getColor()); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir return false; 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir // provide unique ID 112cdf0e10cSrcweir ImplPrimitrive2DIDBlock(WrongSpellPrimitive2D, PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D) 113cdf0e10cSrcweir 114cdf0e10cSrcweir } // end of namespace primitive2d 115cdf0e10cSrcweir } // end of namespace drawinglayer 116cdf0e10cSrcweir 117cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 118cdf0e10cSrcweir // eof 119