1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_drawinglayer.hxx" 30 31 #include <drawinglayer/processor2d/linegeometryextractor2d.hxx> 32 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> 33 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 34 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> 35 #include <drawinglayer/primitive2d/transformprimitive2d.hxx> 36 37 ////////////////////////////////////////////////////////////////////////////// 38 39 using namespace com::sun::star; 40 41 ////////////////////////////////////////////////////////////////////////////// 42 43 namespace drawinglayer 44 { 45 namespace processor2d 46 { 47 LineGeometryExtractor2D::LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation) 48 : BaseProcessor2D(rViewInformation), 49 maExtractedHairlines(), 50 maExtractedLineFills(), 51 mbInLineGeometry(false) 52 { 53 } 54 55 LineGeometryExtractor2D::~LineGeometryExtractor2D() 56 { 57 } 58 59 void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) 60 { 61 switch(rCandidate.getPrimitive2DID()) 62 { 63 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D : 64 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D : 65 { 66 // enter a line geometry group (with or without LineEnds) 67 bool bOldState(mbInLineGeometry); 68 mbInLineGeometry = true; 69 process(rCandidate.get2DDecomposition(getViewInformation2D())); 70 mbInLineGeometry = bOldState; 71 break; 72 } 73 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D : 74 { 75 if(mbInLineGeometry) 76 { 77 // extract hairline line geometry in world coordinates 78 const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate)); 79 basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon()); 80 aLocalPolygon.transform(getViewInformation2D().getObjectTransformation()); 81 maExtractedHairlines.push_back(aLocalPolygon); 82 } 83 break; 84 } 85 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D : 86 { 87 if(mbInLineGeometry) 88 { 89 // extract filled line geometry (line with width) 90 const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate)); 91 basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); 92 aLocalPolyPolygon.transform(getViewInformation2D().getObjectTransformation()); 93 maExtractedLineFills.push_back(aLocalPolyPolygon); 94 } 95 break; 96 } 97 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D : 98 { 99 // remember current transformation and ViewInformation 100 const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate)); 101 const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); 102 103 // create new transformations for CurrentTransformation and for local ViewInformation2D 104 const geometry::ViewInformation2D aViewInformation2D( 105 getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(), 106 getViewInformation2D().getViewTransformation(), 107 getViewInformation2D().getViewport(), 108 getViewInformation2D().getVisualizedPage(), 109 getViewInformation2D().getViewTime(), 110 getViewInformation2D().getExtendedInformationSequence()); 111 updateViewInformation(aViewInformation2D); 112 113 // proccess content 114 process(rTransformCandidate.getChildren()); 115 116 // restore transformations 117 updateViewInformation(aLastViewInformation2D); 118 119 break; 120 } 121 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D : 122 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D : 123 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : 124 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : 125 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : 126 case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : 127 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : 128 case PRIMITIVE2D_ID_MASKPRIMITIVE2D : 129 { 130 // ignorable primitives 131 break; 132 } 133 default : 134 { 135 // process recursively 136 process(rCandidate.get2DDecomposition(getViewInformation2D())); 137 break; 138 } 139 } 140 } 141 } // end of namespace processor2d 142 } // end of namespace drawinglayer 143 144 ////////////////////////////////////////////////////////////////////////////// 145 // eof 146