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_svx.hxx" 30 #include <svx/sdr/overlay/overlayrollingrectangle.hxx> 31 #include <tools/gen.hxx> 32 #include <vcl/salbtype.hxx> 33 #include <vcl/outdev.hxx> 34 #include <basegfx/matrix/b2dhommatrix.hxx> 35 #include <svx/sdr/overlay/overlaytools.hxx> 36 #include <svx/sdr/overlay/overlaymanager.hxx> 37 #include <basegfx/polygon/b2dpolygontools.hxx> 38 #include <basegfx/polygon/b2dpolygon.hxx> 39 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 40 41 ////////////////////////////////////////////////////////////////////////////// 42 43 namespace sdr 44 { 45 namespace overlay 46 { 47 drawinglayer::primitive2d::Primitive2DSequence OverlayRollingRectangleStriped::createOverlayObjectPrimitive2DSequence() 48 { 49 drawinglayer::primitive2d::Primitive2DSequence aRetval; 50 51 if(getOverlayManager() && (getShowBounds() || getExtendedLines())) 52 { 53 const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor()); 54 const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor()); 55 const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel()); 56 const basegfx::B2DRange aRollingRectangle(getBasePosition(), getSecondPosition()); 57 58 if(getShowBounds()) 59 { 60 // view-independent part, create directly 61 const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aRollingRectangle)); 62 const drawinglayer::primitive2d::Primitive2DReference aReference( 63 new drawinglayer::primitive2d::PolygonMarkerPrimitive2D( 64 aPolygon, 65 aRGBColorA, 66 aRGBColorB, 67 fStripeLengthPixel)); 68 69 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aReference); 70 } 71 72 if(getExtendedLines()) 73 { 74 // view-dependent part, use helper primitive 75 const drawinglayer::primitive2d::Primitive2DReference aReference( 76 new drawinglayer::primitive2d::OverlayRollingRectanglePrimitive( 77 aRollingRectangle, 78 aRGBColorA, 79 aRGBColorB, 80 fStripeLengthPixel)); 81 82 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aReference); 83 } 84 } 85 86 return aRetval; 87 } 88 89 void OverlayRollingRectangleStriped::stripeDefinitionHasChanged() 90 { 91 // react on OverlayManager's stripe definition change 92 objectChange(); 93 } 94 95 OverlayRollingRectangleStriped::OverlayRollingRectangleStriped( 96 const basegfx::B2DPoint& rBasePos, 97 const basegfx::B2DPoint& rSecondPos, 98 bool bExtendedLines, 99 bool bShowBounds) 100 : OverlayObjectWithBasePosition(rBasePos, Color(COL_BLACK)), 101 maSecondPosition(rSecondPos), 102 mbExtendedLines(bExtendedLines), 103 mbShowBounds(bShowBounds) 104 { 105 } 106 107 OverlayRollingRectangleStriped::~OverlayRollingRectangleStriped() 108 { 109 } 110 111 void OverlayRollingRectangleStriped::setSecondPosition(const basegfx::B2DPoint& rNew) 112 { 113 if(rNew != maSecondPosition) 114 { 115 // remember new value 116 maSecondPosition = rNew; 117 118 // register change (after change) 119 objectChange(); 120 } 121 } 122 123 void OverlayRollingRectangleStriped::setExtendedLines(bool bNew) 124 { 125 if(bNew != (bool)mbExtendedLines) 126 { 127 // remember new value 128 mbExtendedLines = bNew; 129 130 // register change (after change) 131 objectChange(); 132 } 133 } 134 135 void OverlayRollingRectangleStriped::setShowBounds(bool bNew) 136 { 137 if(bNew != (bool)mbShowBounds) 138 { 139 // remember new value 140 mbShowBounds = bNew; 141 142 // register change (after change) 143 objectChange(); 144 } 145 } 146 } // end of namespace overlay 147 } // end of namespace sdr 148 149 ////////////////////////////////////////////////////////////////////////////// 150 // eof 151