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