1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10*f6e50924SAndrew Rist * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f6e50924SAndrew Rist * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19*f6e50924SAndrew Rist * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir #include "svx/EnhancedCustomShape2d.hxx" 27cdf0e10cSrcweir #include "svx/EnhancedCustomShapeGeometry.hxx" 28cdf0e10cSrcweir #include "svx/EnhancedCustomShapeTypeNames.hxx" 29cdf0e10cSrcweir #include <svx/svdoashp.hxx> 30cdf0e10cSrcweir #include <svx/svdtrans.hxx> 31cdf0e10cSrcweir #include <svx/svdocirc.hxx> 32cdf0e10cSrcweir #include <svx/svdogrp.hxx> 33cdf0e10cSrcweir #include <svx/svdopath.hxx> 34cdf0e10cSrcweir #ifndef _SVDOCAPT_HXX 35cdf0e10cSrcweir #include <svx/svdocapt.hxx> 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir #include <svx/svdpage.hxx> 38cdf0e10cSrcweir #include <svx/xflclit.hxx> 39cdf0e10cSrcweir #include <svx/sdasaitm.hxx> 40cdf0e10cSrcweir #include <svx/svdmodel.hxx> 41cdf0e10cSrcweir #include <rtl/crc.h> 42cdf0e10cSrcweir #include <rtl/math.hxx> 43cdf0e10cSrcweir #include <svx/xfillit0.hxx> 44cdf0e10cSrcweir #include <svx/xlnstit.hxx> 45cdf0e10cSrcweir #include <svx/xlnedit.hxx> 46cdf0e10cSrcweir #include <svx/xlnstwit.hxx> 47cdf0e10cSrcweir #include <svx/xlnedwit.hxx> 48cdf0e10cSrcweir #include <svx/xlnstcit.hxx> 49cdf0e10cSrcweir #include <svx/xlnedcit.hxx> 50cdf0e10cSrcweir #include <svx/xflgrit.hxx> 51cdf0e10cSrcweir #include <svx/xflhtit.hxx> 52cdf0e10cSrcweir #include <svx/xbtmpit.hxx> 53cdf0e10cSrcweir #include <svx/xgrad.hxx> 54cdf0e10cSrcweir #include <svx/xbitmap.hxx> 55cdf0e10cSrcweir #include <svx/xhatch.hxx> 56cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 57cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp> 58cdf0e10cSrcweir #ifndef __COM_SUN_STAR_DRAWING_ENHANCEDCUSTOMSHAPESEGMENTCOMMAND_HPP__ 59cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> 60cdf0e10cSrcweir #endif 61cdf0e10cSrcweir #ifndef BOOST_SHARED_PTR_HPP_INCLUDED 62cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 63cdf0e10cSrcweir #endif 64cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx> 65cdf0e10cSrcweir #include <basegfx/color/bcolortools.hxx> 66cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 67cdf0e10cSrcweir 68cdf0e10cSrcweir // #i76201# 69cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 70cdf0e10cSrcweir 71cdf0e10cSrcweir #include <math.h> 72cdf0e10cSrcweir 73cdf0e10cSrcweir using namespace ::com::sun::star::uno; 74cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 75cdf0e10cSrcweir using namespace ::com::sun::star::drawing::EnhancedCustomShapeSegmentCommand; 76cdf0e10cSrcweir 77cdf0e10cSrcweir void EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nValue ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir sal_uInt32 nDat = (sal_uInt32)nValue; 80cdf0e10cSrcweir sal_Int32 nNewValue = nValue; 81cdf0e10cSrcweir 82cdf0e10cSrcweir // check if this is a special point 83cdf0e10cSrcweir if ( ( nDat >> 16 ) == 0x8000 ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir nNewValue = (sal_uInt16)nDat; 86cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::EQUATION; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir else 89cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::NORMAL; 90cdf0e10cSrcweir rParameter.Value <<= nNewValue; 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir rtl::OUString EnhancedCustomShape2d::GetEquation( const sal_uInt16 nFlags, sal_Int16 nP1, sal_Int16 nP2, sal_Int16 nP3 ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir rtl::OUString aEquation; 96cdf0e10cSrcweir sal_Bool b1Special = ( nFlags & 0x2000 ) != 0; 97cdf0e10cSrcweir sal_Bool b2Special = ( nFlags & 0x4000 ) != 0; 98cdf0e10cSrcweir sal_Bool b3Special = ( nFlags & 0x8000 ) != 0; 99cdf0e10cSrcweir switch( nFlags & 0xff ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir case 0 : 102cdf0e10cSrcweir case 14 : 103cdf0e10cSrcweir { 104cdf0e10cSrcweir sal_Int32 nOptimize = 0; 105cdf0e10cSrcweir if ( nP1 ) 106cdf0e10cSrcweir nOptimize |= 1; 107cdf0e10cSrcweir if ( nP2 ) 108cdf0e10cSrcweir nOptimize |= 2; 109cdf0e10cSrcweir if ( b1Special ) 110cdf0e10cSrcweir nOptimize |= 4; 111cdf0e10cSrcweir if ( b2Special ) 112cdf0e10cSrcweir nOptimize |= 8; 113cdf0e10cSrcweir switch( nOptimize ) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir case 0 : 116cdf0e10cSrcweir break; 117cdf0e10cSrcweir case 1 : 118cdf0e10cSrcweir case 4 : 119cdf0e10cSrcweir case 5 : 120cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 121cdf0e10cSrcweir break; 122cdf0e10cSrcweir case 2 : 123cdf0e10cSrcweir case 8 : 124cdf0e10cSrcweir case 10: 125cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 126cdf0e10cSrcweir break; 127cdf0e10cSrcweir default : 128cdf0e10cSrcweir { 129cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 130cdf0e10cSrcweir aEquation += rtl::OUString( (sal_Unicode)'+' ); 131cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir break; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir if ( b3Special || nP3 ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir aEquation += rtl::OUString( (sal_Unicode)'-' ); 138cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir } 141cdf0e10cSrcweir break; 142cdf0e10cSrcweir case 1 : 143cdf0e10cSrcweir { 144cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 145cdf0e10cSrcweir if ( b2Special || ( nP2 != 1 ) ) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir aEquation += rtl::OUString( (sal_Unicode)'*' ); 148cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir if ( b3Special || ( ( nP3 != 1 ) && ( nP3 != 0 ) ) ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir aEquation += rtl::OUString( (sal_Unicode)'/' ); 153cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir } 156cdf0e10cSrcweir break; 157cdf0e10cSrcweir case 2 : 158cdf0e10cSrcweir { 159cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(" ) ); 160cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 161cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) ); 162cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 163cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/2" ) ); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir break; 166cdf0e10cSrcweir case 3 : 167cdf0e10cSrcweir { 168cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "abs(" ) ); 169cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 170cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) ); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir break; 173cdf0e10cSrcweir case 4 : 174cdf0e10cSrcweir { 175cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "min(" ) ); 176cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 177cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) ); 178cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 179cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) ); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir break; 182cdf0e10cSrcweir case 5 : 183cdf0e10cSrcweir { 184cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "max(" ) ); 185cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 186cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) ); 187cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 188cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir break; 191cdf0e10cSrcweir case 6 : 192cdf0e10cSrcweir { 193cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "if(" ) ); 194cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 195cdf0e10cSrcweir aEquation += rtl::OUString( (sal_Unicode)',' ); 196cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 197cdf0e10cSrcweir aEquation += rtl::OUString( (sal_Unicode)',' ); 198cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 199cdf0e10cSrcweir aEquation += rtl::OUString( (sal_Unicode)')' ); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir break; 202cdf0e10cSrcweir case 7 : 203cdf0e10cSrcweir { 204cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) ); 205cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 206cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) ); 207cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 208cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) ); 209cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 210cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) ); 211cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 212cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) ); 213cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 214cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) ); 215cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 216cdf0e10cSrcweir aEquation += rtl::OUString( (sal_Unicode)')' ); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir break; 219cdf0e10cSrcweir case 8 : 220cdf0e10cSrcweir { 221cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "atan2(" ) ); 222cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 223cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) ); 224cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 225cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/(pi/180)" ) ); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir break; 228cdf0e10cSrcweir case 9 : 229cdf0e10cSrcweir { 230cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 231cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sin(" ) ); 232cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 233cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) ); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir break; 236cdf0e10cSrcweir case 10 : 237cdf0e10cSrcweir { 238cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 239cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*cos(" ) ); 240cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 241cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) ); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir break; 244cdf0e10cSrcweir case 11 : 245cdf0e10cSrcweir { 246cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 247cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) ); 248cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "cos(atan2(" ) ); 249cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 250cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) ); 251cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 252cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) ); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir break; 255cdf0e10cSrcweir case 12 : 256cdf0e10cSrcweir { 257cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 258cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) ); 259cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sin(atan2(" ) ); 260cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 261cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) ); 262cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 263cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) ); 264cdf0e10cSrcweir } 265cdf0e10cSrcweir break; 266cdf0e10cSrcweir case 13 : 267cdf0e10cSrcweir { 268cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) ); 269cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 270cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) ); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir break; 273cdf0e10cSrcweir case 15 : 274cdf0e10cSrcweir { 275cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 276cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sqrt(1-(" ) ); 277cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 278cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) ); 279cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 280cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) ); 281cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(" ) ); 282cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 283cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) ); 284cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 285cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) ); 286cdf0e10cSrcweir } 287cdf0e10cSrcweir break; 288cdf0e10cSrcweir case 16 : 289cdf0e10cSrcweir { 290cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 291cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*tan(" ) ); 292cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 293cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) ); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir break; 296cdf0e10cSrcweir case 0x80 : 297cdf0e10cSrcweir { 298cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) ); 299cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 300cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) ); 301cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 302cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-" ) ); 303cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 304cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) ); 305cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 306cdf0e10cSrcweir aEquation += rtl::OUString( (sal_Unicode)')' ); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir break; 309cdf0e10cSrcweir case 0x81 : 310cdf0e10cSrcweir { 311cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(cos(" ) ); 312cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 313cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) ); 314cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 315cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)+sin(" ) ); 316cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 317cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) ); 318cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 319cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) ); 320cdf0e10cSrcweir } 321cdf0e10cSrcweir break; 322cdf0e10cSrcweir case 0x82 : 323cdf0e10cSrcweir { 324cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-(sin(" ) ); 325cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 326cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) ); 327cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special ); 328cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)-cos(" ) ); 329cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special ); 330cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) ); 331cdf0e10cSrcweir EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special ); 332cdf0e10cSrcweir aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) ); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir break; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir return aEquation; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir void EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( rtl::OUString& rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue ) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir if ( bIsSpecialValue ) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir if ( nPara & 0x400 ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "?" ) ); 346cdf0e10cSrcweir rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara & 0xff ) ); 347cdf0e10cSrcweir rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) ); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir else 350cdf0e10cSrcweir { 351cdf0e10cSrcweir switch( nPara ) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir case DFF_Prop_adjustValue : 354cdf0e10cSrcweir case DFF_Prop_adjust2Value : 355cdf0e10cSrcweir case DFF_Prop_adjust3Value : 356cdf0e10cSrcweir case DFF_Prop_adjust4Value : 357cdf0e10cSrcweir case DFF_Prop_adjust5Value : 358cdf0e10cSrcweir case DFF_Prop_adjust6Value : 359cdf0e10cSrcweir case DFF_Prop_adjust7Value : 360cdf0e10cSrcweir case DFF_Prop_adjust8Value : 361cdf0e10cSrcweir case DFF_Prop_adjust9Value : 362cdf0e10cSrcweir case DFF_Prop_adjust10Value : 363cdf0e10cSrcweir { 364cdf0e10cSrcweir rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "$" ) ); 365cdf0e10cSrcweir rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara - DFF_Prop_adjustValue ) ); 366cdf0e10cSrcweir rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) ); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir break; 369cdf0e10cSrcweir case DFF_Prop_geoLeft : 370cdf0e10cSrcweir { 371cdf0e10cSrcweir rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "left" ) ); 372cdf0e10cSrcweir } 373cdf0e10cSrcweir break; 374cdf0e10cSrcweir case DFF_Prop_geoTop : 375cdf0e10cSrcweir { 376cdf0e10cSrcweir rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "top" ) ); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir break; 379cdf0e10cSrcweir case DFF_Prop_geoRight : 380cdf0e10cSrcweir { 381cdf0e10cSrcweir rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "right" ) ); 382cdf0e10cSrcweir } 383cdf0e10cSrcweir break; 384cdf0e10cSrcweir case DFF_Prop_geoBottom : 385cdf0e10cSrcweir { 386cdf0e10cSrcweir rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "bottom" ) ); 387cdf0e10cSrcweir } 388cdf0e10cSrcweir break; 389cdf0e10cSrcweir } 390cdf0e10cSrcweir } 391cdf0e10cSrcweir } 392cdf0e10cSrcweir else 393cdf0e10cSrcweir { 394cdf0e10cSrcweir rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara ) ); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir void EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue, sal_Bool bHorz ) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir sal_Int32 nValue = 0; 401cdf0e10cSrcweir if ( bIsSpecialValue ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir if ( ( nPara >= 0x100 ) && ( nPara <= 0x107 ) ) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir nValue = nPara & 0xff; 406cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::ADJUSTMENT; 407cdf0e10cSrcweir } 408cdf0e10cSrcweir else if ( ( nPara >= 3 ) && ( nPara <= 0x82 ) ) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir nValue = nPara - 3; 411cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::EQUATION; 412cdf0e10cSrcweir } 413cdf0e10cSrcweir else if ( nPara == 0 ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir nValue = 0; 416cdf0e10cSrcweir if ( bHorz ) 417cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::LEFT; 418cdf0e10cSrcweir else 419cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::TOP; 420cdf0e10cSrcweir } 421cdf0e10cSrcweir else if ( nPara == 1 ) 422cdf0e10cSrcweir { 423cdf0e10cSrcweir nValue = 0; 424cdf0e10cSrcweir if ( bHorz ) 425cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::RIGHT; 426cdf0e10cSrcweir else 427cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::BOTTOM; 428cdf0e10cSrcweir } 429cdf0e10cSrcweir else if ( nPara == 2 ) // means to be centered, but should not be 430cdf0e10cSrcweir { // used in our implementation 431cdf0e10cSrcweir nValue = 5600; 432cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::NORMAL; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir else 435cdf0e10cSrcweir { 436cdf0e10cSrcweir nValue = nPara; 437cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::NORMAL; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir } 440cdf0e10cSrcweir else 441cdf0e10cSrcweir { 442cdf0e10cSrcweir nValue = nPara; 443cdf0e10cSrcweir rParameter.Type = EnhancedCustomShapeParameterType::NORMAL; 444cdf0e10cSrcweir } 445cdf0e10cSrcweir rParameter.Value <<= nValue; 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle( 449cdf0e10cSrcweir const com::sun::star::beans::PropertyValues& rHandleProperties, 450cdf0e10cSrcweir EnhancedCustomShape2d::Handle& rDestinationHandle ) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir sal_Bool bRetValue = sal_False; 453cdf0e10cSrcweir sal_uInt32 i, nProperties = rHandleProperties.getLength(); 454cdf0e10cSrcweir if ( nProperties ) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir rDestinationHandle.nFlags = 0; 457cdf0e10cSrcweir for ( i = 0; i < nProperties; i++ ) 458cdf0e10cSrcweir { 459cdf0e10cSrcweir const com::sun::star::beans::PropertyValue& rPropVal = rHandleProperties[ i ]; 460cdf0e10cSrcweir 461cdf0e10cSrcweir const rtl::OUString sPosition ( RTL_CONSTASCII_USTRINGPARAM( "Position" ) ); 462cdf0e10cSrcweir const rtl::OUString sMirroredX ( RTL_CONSTASCII_USTRINGPARAM( "MirroredX" ) ); 463cdf0e10cSrcweir const rtl::OUString sMirroredY ( RTL_CONSTASCII_USTRINGPARAM( "MirroredY" ) ); 464cdf0e10cSrcweir const rtl::OUString sSwitched ( RTL_CONSTASCII_USTRINGPARAM( "Switched" ) ); 465cdf0e10cSrcweir const rtl::OUString sPolar ( RTL_CONSTASCII_USTRINGPARAM( "Polar" ) ); 466cdf0e10cSrcweir // const rtl::OUString sMap ( RTL_CONSTASCII_USTRINGPARAM( "Map" ) ); 467cdf0e10cSrcweir const rtl::OUString sRefX ( RTL_CONSTASCII_USTRINGPARAM( "RefX" ) ); 468cdf0e10cSrcweir const rtl::OUString sRefY ( RTL_CONSTASCII_USTRINGPARAM( "RefY" ) ); 469cdf0e10cSrcweir const rtl::OUString sRefAngle ( RTL_CONSTASCII_USTRINGPARAM( "RefAngle" ) ); 470cdf0e10cSrcweir const rtl::OUString sRefR ( RTL_CONSTASCII_USTRINGPARAM( "RefR" ) ); 471cdf0e10cSrcweir const rtl::OUString sRadiusRangeMinimum ( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMinimum" ) ); 472cdf0e10cSrcweir const rtl::OUString sRadiusRangeMaximum ( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMaximum" ) ); 473cdf0e10cSrcweir const rtl::OUString sRangeXMinimum ( RTL_CONSTASCII_USTRINGPARAM( "RangeXMinimum" ) ); 474cdf0e10cSrcweir const rtl::OUString sRangeXMaximum ( RTL_CONSTASCII_USTRINGPARAM( "RangeXMaximum" ) ); 475cdf0e10cSrcweir const rtl::OUString sRangeYMinimum ( RTL_CONSTASCII_USTRINGPARAM( "RangeYMinimum" ) ); 476cdf0e10cSrcweir const rtl::OUString sRangeYMaximum ( RTL_CONSTASCII_USTRINGPARAM( "RangeYMaximum" ) ); 477cdf0e10cSrcweir 478cdf0e10cSrcweir if ( rPropVal.Name.equals( sPosition ) ) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.aPosition ) 481cdf0e10cSrcweir bRetValue = sal_True; 482cdf0e10cSrcweir } 483cdf0e10cSrcweir else if ( rPropVal.Name.equals( sMirroredX ) ) 484cdf0e10cSrcweir { 485cdf0e10cSrcweir sal_Bool bMirroredX = sal_Bool(); 486cdf0e10cSrcweir if ( rPropVal.Value >>= bMirroredX ) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir if ( bMirroredX ) 489cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_X; 490cdf0e10cSrcweir } 491cdf0e10cSrcweir } 492cdf0e10cSrcweir else if ( rPropVal.Name.equals( sMirroredY ) ) 493cdf0e10cSrcweir { 494cdf0e10cSrcweir sal_Bool bMirroredY = sal_Bool(); 495cdf0e10cSrcweir if ( rPropVal.Value >>= bMirroredY ) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir if ( bMirroredY ) 498cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_Y; 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501cdf0e10cSrcweir else if ( rPropVal.Name.equals( sSwitched ) ) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir sal_Bool bSwitched = sal_Bool(); 504cdf0e10cSrcweir if ( rPropVal.Value >>= bSwitched ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir if ( bSwitched ) 507cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_SWITCHED; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir } 510cdf0e10cSrcweir else if ( rPropVal.Name.equals( sPolar ) ) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.aPolar ) 513cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_POLAR; 514cdf0e10cSrcweir } 515cdf0e10cSrcweir /* seems not to be used. 516cdf0e10cSrcweir else if ( rPropVal.Name.equals( sMap ) ) 517cdf0e10cSrcweir { 518cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair aMap; 519cdf0e10cSrcweir if ( rPropVal.Value >>= aMap ) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir if ( GetValueForEnhancedCustomShapeHandleParameter( nXMap, aMap.First ) ) 522cdf0e10cSrcweir rDestinationHandle.Flags |= 0x800; 523cdf0e10cSrcweir if ( GetValueForEnhancedCustomShapeHandleParameter( nYMap, aMap.Second ) ) 524cdf0e10cSrcweir rDestinationHandle.Flags |= 0x1000; 525cdf0e10cSrcweir rDestinationHandle.Flags |= 0x10; 526cdf0e10cSrcweir } 527cdf0e10cSrcweir } 528cdf0e10cSrcweir */ 529cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRefX ) ) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.nRefX ) 532cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_REFX; 533cdf0e10cSrcweir } 534cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRefY ) ) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.nRefY ) 537cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_REFY; 538cdf0e10cSrcweir } 539cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRefAngle ) ) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.nRefAngle ) 542cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_REFANGLE; 543cdf0e10cSrcweir } 544cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRefR ) ) 545cdf0e10cSrcweir { 546cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.nRefR ) 547cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_REFR; 548cdf0e10cSrcweir } 549cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRadiusRangeMinimum ) ) 550cdf0e10cSrcweir { 551cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMinimum ) 552cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MINIMUM; 553cdf0e10cSrcweir } 554cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRadiusRangeMaximum ) ) 555cdf0e10cSrcweir { 556cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMaximum ) 557cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM; 558cdf0e10cSrcweir } 559cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRangeXMinimum ) ) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.aXRangeMinimum ) 562cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MINIMUM; 563cdf0e10cSrcweir } 564cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRangeXMaximum ) ) 565cdf0e10cSrcweir { 566cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.aXRangeMaximum ) 567cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MAXIMUM; 568cdf0e10cSrcweir } 569cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRangeYMinimum ) ) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.aYRangeMinimum ) 572cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MINIMUM; 573cdf0e10cSrcweir } 574cdf0e10cSrcweir else if ( rPropVal.Name.equals( sRangeYMaximum ) ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir if ( rPropVal.Value >>= rDestinationHandle.aYRangeMaximum ) 577cdf0e10cSrcweir rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MAXIMUM; 578cdf0e10cSrcweir } 579cdf0e10cSrcweir } 580cdf0e10cSrcweir } 581cdf0e10cSrcweir return bRetValue; 582cdf0e10cSrcweir } 583cdf0e10cSrcweir 584cdf0e10cSrcweir const sal_Int32* EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rGeometryItem ) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir const sal_Int32* pDefData = NULL; 587cdf0e10cSrcweir const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType ); 588cdf0e10cSrcweir if ( pDefCustomShape ) 589cdf0e10cSrcweir pDefData = pDefCustomShape->pDefData; 590cdf0e10cSrcweir 591cdf0e10cSrcweir ////////////////////// 592cdf0e10cSrcweir // AdjustmentValues // 593cdf0e10cSrcweir ////////////////////// 594cdf0e10cSrcweir const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) ); 595cdf0e10cSrcweir const Any* pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sAdjustmentValues ); 596cdf0e10cSrcweir if ( pAny ) 597cdf0e10cSrcweir *pAny >>= seqAdjustmentValues; 598cdf0e10cSrcweir 599cdf0e10cSrcweir /////////////// 600cdf0e10cSrcweir // Coordsize // 601cdf0e10cSrcweir /////////////// 602cdf0e10cSrcweir const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) ); 603cdf0e10cSrcweir const Any* pViewBox = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sViewBox ); 604cdf0e10cSrcweir com::sun::star::awt::Rectangle aViewBox; 605cdf0e10cSrcweir if ( pViewBox && (*pViewBox >>= aViewBox ) ) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir nCoordLeft = aViewBox.X; 608cdf0e10cSrcweir nCoordTop = aViewBox.Y; 609cdf0e10cSrcweir nCoordWidth = labs( aViewBox.Width ); 610cdf0e10cSrcweir nCoordHeight= labs( aViewBox.Height); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) ); 613cdf0e10cSrcweir 614cdf0e10cSrcweir ////////////////////// 615cdf0e10cSrcweir // Path/Coordinates // 616cdf0e10cSrcweir ////////////////////// 617cdf0e10cSrcweir const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) ); 618cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sCoordinates ); 619cdf0e10cSrcweir if ( pAny ) 620cdf0e10cSrcweir *pAny >>= seqCoordinates; 621cdf0e10cSrcweir 622cdf0e10cSrcweir ///////////////////// 623cdf0e10cSrcweir // Path/GluePoints // 624cdf0e10cSrcweir ///////////////////// 625cdf0e10cSrcweir const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) ); 626cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sGluePoints ); 627cdf0e10cSrcweir if ( pAny ) 628cdf0e10cSrcweir *pAny >>= seqGluePoints; 629cdf0e10cSrcweir 630cdf0e10cSrcweir /////////////////// 631cdf0e10cSrcweir // Path/Segments // 632cdf0e10cSrcweir /////////////////// 633cdf0e10cSrcweir const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) ); 634cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sSegments ); 635cdf0e10cSrcweir if ( pAny ) 636cdf0e10cSrcweir *pAny >>= seqSegments; 637cdf0e10cSrcweir 638cdf0e10cSrcweir /////////////////// 639cdf0e10cSrcweir // Path/StretchX // 640cdf0e10cSrcweir /////////////////// 641cdf0e10cSrcweir const rtl::OUString sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) ); 642cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchX ); 643cdf0e10cSrcweir if ( pAny ) 644cdf0e10cSrcweir { 645cdf0e10cSrcweir sal_Int32 nStretchX = 0; 646cdf0e10cSrcweir if ( *pAny >>= nStretchX ) 647cdf0e10cSrcweir nXRef = nStretchX; 648cdf0e10cSrcweir } 649cdf0e10cSrcweir 650cdf0e10cSrcweir /////////////////// 651cdf0e10cSrcweir // Path/StretchY // 652cdf0e10cSrcweir /////////////////// 653cdf0e10cSrcweir const rtl::OUString sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) ); 654cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchY ); 655cdf0e10cSrcweir if ( pAny ) 656cdf0e10cSrcweir { 657cdf0e10cSrcweir sal_Int32 nStretchY = 0; 658cdf0e10cSrcweir if ( *pAny >>= nStretchY ) 659cdf0e10cSrcweir nYRef = nStretchY; 660cdf0e10cSrcweir } 661cdf0e10cSrcweir 662cdf0e10cSrcweir ///////////////////// 663cdf0e10cSrcweir // Path/TextFrames // 664cdf0e10cSrcweir ///////////////////// 665cdf0e10cSrcweir const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) ); 666cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sTextFrames ); 667cdf0e10cSrcweir if ( pAny ) 668cdf0e10cSrcweir *pAny >>= seqTextFrames; 669cdf0e10cSrcweir 670cdf0e10cSrcweir /////////////// 671cdf0e10cSrcweir // Equations // 672cdf0e10cSrcweir /////////////// 673cdf0e10cSrcweir const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) ); 674cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sEquations ); 675cdf0e10cSrcweir if ( pAny ) 676cdf0e10cSrcweir *pAny >>= seqEquations; 677cdf0e10cSrcweir 678cdf0e10cSrcweir ///////////// 679cdf0e10cSrcweir // Handles // 680cdf0e10cSrcweir ///////////// 681cdf0e10cSrcweir const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) ); 682cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sHandles ); 683cdf0e10cSrcweir if ( pAny ) 684cdf0e10cSrcweir *pAny >>= seqHandles; 685cdf0e10cSrcweir 686cdf0e10cSrcweir return pDefData; 687cdf0e10cSrcweir } 688cdf0e10cSrcweir 689cdf0e10cSrcweir EnhancedCustomShape2d::~EnhancedCustomShape2d() 690cdf0e10cSrcweir { 691cdf0e10cSrcweir } 692cdf0e10cSrcweir 693cdf0e10cSrcweir EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : 694cdf0e10cSrcweir SfxItemSet ( pAObj->GetMergedItemSet() ), 695cdf0e10cSrcweir pCustomShapeObj ( pAObj ), 696cdf0e10cSrcweir eSpType ( mso_sptNil ), 697cdf0e10cSrcweir nCoordLeft ( 0 ), 698cdf0e10cSrcweir nCoordTop ( 0 ), 699cdf0e10cSrcweir nCoordWidth ( 21600 ), 700cdf0e10cSrcweir nCoordHeight ( 21600 ), 701cdf0e10cSrcweir nXRef ( 0x80000000 ), 702cdf0e10cSrcweir nYRef ( 0x80000000 ), 703cdf0e10cSrcweir nFlags ( 0 ), 704cdf0e10cSrcweir nColorData ( 0 ), 705cdf0e10cSrcweir bTextFlow ( sal_False ), 706cdf0e10cSrcweir bFilled ( ((const XFillStyleItem&)pAObj->GetMergedItem( XATTR_FILLSTYLE )).GetValue() != XFILL_NONE ), 707cdf0e10cSrcweir bStroked ( ((const XLineStyleItem&)pAObj->GetMergedItem( XATTR_LINESTYLE )).GetValue() != XLINE_NONE ), 708cdf0e10cSrcweir bFlipH ( sal_False ), 709cdf0e10cSrcweir bFlipV ( sal_False ) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir // bTextFlow needs to be set before clearing the TextDirection Item 712cdf0e10cSrcweir 713cdf0e10cSrcweir ClearItem( SDRATTR_TEXTDIRECTION ); //SJ: vertical writing is not required, by removing this item no outliner is created 714cdf0e10cSrcweir 715cdf0e10cSrcweir // #i105323# For 2D AtoShapes, the shadow attirbute does not need to be applied to any 716cdf0e10cSrcweir // of the constucted helper SdrObjects. This would lead to problems since the shadow 717cdf0e10cSrcweir // of one helper object would fall on one helper object behind it (e.g. with the 718cdf0e10cSrcweir // eyes of the smiley shape). This is not wanted; instead a single shadow 'behind' 719cdf0e10cSrcweir // the AutoShape visualisation is wanted. This is done with primitive functionailty 720cdf0e10cSrcweir // now in SdrCustomShapePrimitive2D::create2DDecomposition, but only for 2D objects 721cdf0e10cSrcweir // (see there and in EnhancedCustomShape3d::Create3DObject to read more). 722cdf0e10cSrcweir // This exception may be removed later when AutoShapes will create primitives directly. 723cdf0e10cSrcweir // So, currently remove the ShadowAttribute from the ItemSet to not apply it to any 724cdf0e10cSrcweir // 2D helper shape. 725cdf0e10cSrcweir ClearItem(SDRATTR_SHADOW); 726cdf0e10cSrcweir 727cdf0e10cSrcweir Point aP( pCustomShapeObj->GetSnapRect().Center() ); 728cdf0e10cSrcweir Size aS( pCustomShapeObj->GetLogicRect().GetSize() ); 729cdf0e10cSrcweir aP.X() -= aS.Width() / 2; 730cdf0e10cSrcweir aP.Y() -= aS.Height() / 2; 731cdf0e10cSrcweir aLogicRect = Rectangle( aP, aS ); 732cdf0e10cSrcweir 733cdf0e10cSrcweir const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) ); 734cdf0e10cSrcweir const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) ); 735cdf0e10cSrcweir const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) ); 736cdf0e10cSrcweir 737cdf0e10cSrcweir rtl::OUString sShapeType; 738cdf0e10cSrcweir SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)(const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); 739cdf0e10cSrcweir Any* pAny = rGeometryItem.GetPropertyValueByName( sType ); 740cdf0e10cSrcweir if ( pAny ) 741cdf0e10cSrcweir *pAny >>= sShapeType; 742cdf0e10cSrcweir eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType ); 743cdf0e10cSrcweir 744cdf0e10cSrcweir pAny = rGeometryItem.GetPropertyValueByName( sMirroredX ); 745cdf0e10cSrcweir if ( pAny ) 746cdf0e10cSrcweir *pAny >>= bFlipH; 747cdf0e10cSrcweir pAny = rGeometryItem.GetPropertyValueByName( sMirroredY ); 748cdf0e10cSrcweir if ( pAny ) 749cdf0e10cSrcweir *pAny >>= bFlipV; 750cdf0e10cSrcweir 751cdf0e10cSrcweir if ( pCustomShapeObj->ISA( SdrObjCustomShape ) ) // should always be a SdrObjCustomShape, but you don't know 752cdf0e10cSrcweir nRotateAngle = (sal_Int32)(((SdrObjCustomShape*)pCustomShapeObj)->GetObjectRotation() * 100.0); 753cdf0e10cSrcweir else 754cdf0e10cSrcweir nRotateAngle = pCustomShapeObj->GetRotateAngle(); 755cdf0e10cSrcweir 756cdf0e10cSrcweir /*const sal_Int32* pDefData =*/ ApplyShapeAttributes( rGeometryItem ); 757cdf0e10cSrcweir switch( eSpType ) 758cdf0e10cSrcweir { 759cdf0e10cSrcweir case mso_sptCan : nColorData = 0x20400000; break; 760cdf0e10cSrcweir case mso_sptCube : nColorData = 0x302e0000; break; 761cdf0e10cSrcweir case mso_sptActionButtonBlank : nColorData = 0x502ce400; break; 762cdf0e10cSrcweir case mso_sptActionButtonHome : nColorData = 0x702ce4ce; break; 763cdf0e10cSrcweir case mso_sptActionButtonHelp : nColorData = 0x602ce4c0; break; 764cdf0e10cSrcweir case mso_sptActionButtonInformation : nColorData = 0x702ce4c5; break; 765cdf0e10cSrcweir case mso_sptActionButtonBackPrevious : nColorData = 0x602ce4c0; break; 766cdf0e10cSrcweir case mso_sptActionButtonForwardNext : nColorData = 0x602ce4c0; break; 767cdf0e10cSrcweir case mso_sptActionButtonBeginning : nColorData = 0x602ce4c0; break; 768cdf0e10cSrcweir case mso_sptActionButtonEnd : nColorData = 0x602ce4c0; break; 769cdf0e10cSrcweir case mso_sptActionButtonReturn : nColorData = 0x602ce4c0; break; 770cdf0e10cSrcweir case mso_sptActionButtonDocument : nColorData = 0x702ce4ec; break; 771cdf0e10cSrcweir case mso_sptActionButtonSound : nColorData = 0x602ce4c0; break; 772cdf0e10cSrcweir case mso_sptActionButtonMovie : nColorData = 0x602ce4c0; break; 773cdf0e10cSrcweir case mso_sptBevel : nColorData = 0x502ce400; break; 774cdf0e10cSrcweir case mso_sptFoldedCorner : nColorData = 0x20e00000; break; 775cdf0e10cSrcweir case mso_sptSmileyFace : nColorData = 0x20e00000; break; 776cdf0e10cSrcweir case mso_sptNil : 777cdf0e10cSrcweir { 778cdf0e10cSrcweir if( sShapeType.getLength() > 4 && 779cdf0e10cSrcweir sShapeType.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "col-" ))) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir nColorData = sShapeType.copy( 4 ).toInt32( 16 ); 782cdf0e10cSrcweir } 783cdf0e10cSrcweir } 784cdf0e10cSrcweir break; 785cdf0e10cSrcweir case mso_sptCurvedLeftArrow : 786cdf0e10cSrcweir case mso_sptCurvedRightArrow : 787cdf0e10cSrcweir case mso_sptCurvedUpArrow : 788cdf0e10cSrcweir case mso_sptCurvedDownArrow : nColorData = 0x20d00000; break; 789cdf0e10cSrcweir case mso_sptRibbon2 : nColorData = 0x30ee0000; break; 790cdf0e10cSrcweir case mso_sptRibbon : nColorData = 0x30ee0000; break; 791cdf0e10cSrcweir 792cdf0e10cSrcweir case mso_sptEllipseRibbon2 : nColorData = 0x30ee0000; break; 793cdf0e10cSrcweir case mso_sptEllipseRibbon : nColorData = 0x30ee0000; break; 794cdf0e10cSrcweir 795cdf0e10cSrcweir case mso_sptVerticalScroll : nColorData = 0x30ee0000; break; 796cdf0e10cSrcweir case mso_sptHorizontalScroll : nColorData = 0x30ee0000; break; 797cdf0e10cSrcweir default: 798cdf0e10cSrcweir break; 799cdf0e10cSrcweir } 800cdf0e10cSrcweir fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth; 801cdf0e10cSrcweir fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight; 802cdf0e10cSrcweir if ( (sal_uInt32)nXRef != 0x80000000 && aLogicRect.GetHeight() ) 803cdf0e10cSrcweir { 804cdf0e10cSrcweir fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight(); 805cdf0e10cSrcweir if ( fXRatio > 1 ) 806cdf0e10cSrcweir fXScale /= fXRatio; 807cdf0e10cSrcweir else 808cdf0e10cSrcweir fXRatio = 1.0; 809cdf0e10cSrcweir } 810cdf0e10cSrcweir else 811cdf0e10cSrcweir fXRatio = 1.0; 812cdf0e10cSrcweir if ( (sal_uInt32)nYRef != 0x80000000 && aLogicRect.GetWidth() ) 813cdf0e10cSrcweir { 814cdf0e10cSrcweir fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth(); 815cdf0e10cSrcweir if ( fYRatio > 1 ) 816cdf0e10cSrcweir fYScale /= fYRatio; 817cdf0e10cSrcweir else 818cdf0e10cSrcweir fYRatio = 1.0; 819cdf0e10cSrcweir } 820cdf0e10cSrcweir else 821cdf0e10cSrcweir fYRatio = 1.0; 822cdf0e10cSrcweir 823cdf0e10cSrcweir sal_Int32 i, nLength = seqEquations.getLength(); 824cdf0e10cSrcweir 825cdf0e10cSrcweir 826cdf0e10cSrcweir if ( nLength ) 827cdf0e10cSrcweir { 828cdf0e10cSrcweir vNodesSharedPtr.resize( nLength ); 829cdf0e10cSrcweir for ( i = 0; i < seqEquations.getLength(); i++ ) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir try 832cdf0e10cSrcweir { 833cdf0e10cSrcweir vNodesSharedPtr[ i ] = EnhancedCustomShape::FunctionParser::parseFunction( seqEquations[ i ], *this ); 834cdf0e10cSrcweir } 835cdf0e10cSrcweir catch ( EnhancedCustomShape::ParseError& ) 836cdf0e10cSrcweir { 837cdf0e10cSrcweir } 838cdf0e10cSrcweir } 839cdf0e10cSrcweir } 840cdf0e10cSrcweir } 841cdf0e10cSrcweir double EnhancedCustomShape2d::GetEnumFunc( const EnumFunc eFunc ) const 842cdf0e10cSrcweir { 843cdf0e10cSrcweir double fRet = 0.0; 844cdf0e10cSrcweir switch( eFunc ) 845cdf0e10cSrcweir { 846cdf0e10cSrcweir case ENUM_FUNC_PI : fRet = F_PI; break; 847cdf0e10cSrcweir case ENUM_FUNC_LEFT : fRet = 0.0; break; 848cdf0e10cSrcweir case ENUM_FUNC_TOP : fRet = 0.0; break; 849cdf0e10cSrcweir case ENUM_FUNC_RIGHT : fRet = (double)nCoordWidth * fXRatio; break; 850cdf0e10cSrcweir case ENUM_FUNC_BOTTOM : fRet = (double)nCoordHeight * fYRatio; break; 851cdf0e10cSrcweir case ENUM_FUNC_XSTRETCH : fRet = nXRef; break; 852cdf0e10cSrcweir case ENUM_FUNC_YSTRETCH : fRet = nYRef; break; 853cdf0e10cSrcweir case ENUM_FUNC_HASSTROKE : fRet = bStroked ? 1.0 : 0.0; break; 854cdf0e10cSrcweir case ENUM_FUNC_HASFILL : fRet = bFilled ? 1.0 : 0.0; break; 855cdf0e10cSrcweir case ENUM_FUNC_WIDTH : fRet = nCoordWidth; break; 856cdf0e10cSrcweir case ENUM_FUNC_HEIGHT : fRet = nCoordHeight; break; 857cdf0e10cSrcweir case ENUM_FUNC_LOGWIDTH : fRet = aLogicRect.GetWidth(); break; 858cdf0e10cSrcweir case ENUM_FUNC_LOGHEIGHT : fRet = aLogicRect.GetHeight(); break; 859cdf0e10cSrcweir } 860cdf0e10cSrcweir return fRet; 861cdf0e10cSrcweir } 862cdf0e10cSrcweir double EnhancedCustomShape2d::GetAdjustValueAsDouble( const sal_Int32 nIndex ) const 863cdf0e10cSrcweir { 864cdf0e10cSrcweir double fNumber = 0.0; 865cdf0e10cSrcweir if ( nIndex < seqAdjustmentValues.getLength() ) 866cdf0e10cSrcweir { 867cdf0e10cSrcweir if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE ) 868cdf0e10cSrcweir seqAdjustmentValues[ nIndex ].Value >>= fNumber; 869cdf0e10cSrcweir else 870cdf0e10cSrcweir { 871cdf0e10cSrcweir sal_Int32 nNumber = 0; 872cdf0e10cSrcweir seqAdjustmentValues[ nIndex ].Value >>= nNumber; 873cdf0e10cSrcweir fNumber = (double)nNumber; 874cdf0e10cSrcweir } 875cdf0e10cSrcweir } 876cdf0e10cSrcweir return fNumber; 877cdf0e10cSrcweir } 878cdf0e10cSrcweir double EnhancedCustomShape2d::GetEquationValueAsDouble( const sal_Int32 nIndex ) const 879cdf0e10cSrcweir { 880cdf0e10cSrcweir double fNumber = 0.0; 881cdf0e10cSrcweir if ( nIndex < (sal_Int32)vNodesSharedPtr.size() ) 882cdf0e10cSrcweir { 883cdf0e10cSrcweir if ( vNodesSharedPtr[ nIndex ].get() ) 884cdf0e10cSrcweir try 885cdf0e10cSrcweir { 886cdf0e10cSrcweir fNumber = (*vNodesSharedPtr[ nIndex ])(); 887cdf0e10cSrcweir if ( !rtl::math::isFinite( fNumber ) ) 888cdf0e10cSrcweir fNumber = 0.0; 889cdf0e10cSrcweir } 890cdf0e10cSrcweir catch ( ... ) 891cdf0e10cSrcweir { 892cdf0e10cSrcweir /* sal_Bool bUps = sal_True; */ 893cdf0e10cSrcweir } 894cdf0e10cSrcweir } 895cdf0e10cSrcweir return fNumber; 896cdf0e10cSrcweir } 897cdf0e10cSrcweir sal_Int32 EnhancedCustomShape2d::GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault ) const 898cdf0e10cSrcweir { 899cdf0e10cSrcweir sal_Int32 nNumber = nDefault; 900cdf0e10cSrcweir if ( nIndex < seqAdjustmentValues.getLength() ) 901cdf0e10cSrcweir { 902cdf0e10cSrcweir if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE ) 903cdf0e10cSrcweir { 904cdf0e10cSrcweir double fNumber = 0; 905cdf0e10cSrcweir seqAdjustmentValues[ nIndex ].Value >>= fNumber; 906cdf0e10cSrcweir nNumber = (sal_Int32)fNumber; 907cdf0e10cSrcweir } 908cdf0e10cSrcweir else 909cdf0e10cSrcweir seqAdjustmentValues[ nIndex ].Value >>= nNumber; 910cdf0e10cSrcweir } 911cdf0e10cSrcweir return nNumber; 912cdf0e10cSrcweir } 913cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex ) 914cdf0e10cSrcweir { 915cdf0e10cSrcweir sal_Bool bRetValue = sal_False; 916cdf0e10cSrcweir if ( nIndex < seqAdjustmentValues.getLength() ) 917cdf0e10cSrcweir { 918cdf0e10cSrcweir // updating our local adjustment sequence 919cdf0e10cSrcweir seqAdjustmentValues[ nIndex ].Value <<= rValue; 920cdf0e10cSrcweir seqAdjustmentValues[ nIndex ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; 921cdf0e10cSrcweir bRetValue = sal_True; 922cdf0e10cSrcweir } 923cdf0e10cSrcweir return bRetValue; 924cdf0e10cSrcweir } 925cdf0e10cSrcweir 926cdf0e10cSrcweir Point EnhancedCustomShape2d::GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair& rPair, 927cdf0e10cSrcweir const sal_Bool bScale, const sal_Bool bReplaceGeoSize ) const 928cdf0e10cSrcweir { 929cdf0e10cSrcweir Point aRetValue; 930cdf0e10cSrcweir sal_Bool bExchange = ( nFlags & DFF_CUSTOMSHAPE_EXCH ) != 0; // x <-> y 931cdf0e10cSrcweir sal_uInt32 nPass = 0; 932cdf0e10cSrcweir do 933cdf0e10cSrcweir { 934cdf0e10cSrcweir sal_uInt32 nIndex = nPass; 935cdf0e10cSrcweir 936cdf0e10cSrcweir if ( bExchange ) 937cdf0e10cSrcweir nIndex ^= 1; 938cdf0e10cSrcweir 939cdf0e10cSrcweir double fVal; 940cdf0e10cSrcweir const EnhancedCustomShapeParameter& rParameter = nIndex ? rPair.Second : rPair.First; 941cdf0e10cSrcweir if ( nPass ) // height 942cdf0e10cSrcweir { 943cdf0e10cSrcweir GetParameter( fVal, rParameter, sal_False, bReplaceGeoSize ); 944cdf0e10cSrcweir fVal -= nCoordTop; 945cdf0e10cSrcweir if ( bScale ) 946cdf0e10cSrcweir { 947cdf0e10cSrcweir fVal *= fYScale; 948cdf0e10cSrcweir 949cdf0e10cSrcweir if ( nFlags & DFF_CUSTOMSHAPE_FLIP_V ) 950cdf0e10cSrcweir fVal = aLogicRect.GetHeight() - fVal; 951cdf0e10cSrcweir } 952cdf0e10cSrcweir aRetValue.Y() = (sal_Int32)fVal; 953cdf0e10cSrcweir } 954cdf0e10cSrcweir else // width 955cdf0e10cSrcweir { 956cdf0e10cSrcweir GetParameter( fVal, rParameter, bReplaceGeoSize, sal_False ); 957cdf0e10cSrcweir fVal -= nCoordLeft; 958cdf0e10cSrcweir if ( bScale ) 959cdf0e10cSrcweir { 960cdf0e10cSrcweir fVal *= fXScale; 961cdf0e10cSrcweir 962cdf0e10cSrcweir if ( nFlags & DFF_CUSTOMSHAPE_FLIP_H ) 963cdf0e10cSrcweir fVal = aLogicRect.GetWidth() - fVal; 964cdf0e10cSrcweir } 965cdf0e10cSrcweir aRetValue.X() = (sal_Int32)fVal; 966cdf0e10cSrcweir } 967cdf0e10cSrcweir } 968cdf0e10cSrcweir while ( ++nPass < 2 ); 969cdf0e10cSrcweir return aRetValue; 970cdf0e10cSrcweir } 971cdf0e10cSrcweir 972cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::GetParameter( double& rRetValue, const EnhancedCustomShapeParameter& rParameter, 973cdf0e10cSrcweir const sal_Bool bReplaceGeoWidth, const sal_Bool bReplaceGeoHeight ) const 974cdf0e10cSrcweir { 975cdf0e10cSrcweir rRetValue = 0.0; 976cdf0e10cSrcweir sal_Bool bRetValue = sal_False; 977cdf0e10cSrcweir switch ( rParameter.Type ) 978cdf0e10cSrcweir { 979cdf0e10cSrcweir case EnhancedCustomShapeParameterType::ADJUSTMENT : 980cdf0e10cSrcweir { 981cdf0e10cSrcweir sal_Int32 nAdjustmentIndex = 0; 982cdf0e10cSrcweir if ( rParameter.Value >>= nAdjustmentIndex ) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir rRetValue = GetAdjustValueAsDouble( nAdjustmentIndex ); 985cdf0e10cSrcweir bRetValue = sal_True; 986cdf0e10cSrcweir } 987cdf0e10cSrcweir } 988cdf0e10cSrcweir break; 989cdf0e10cSrcweir case EnhancedCustomShapeParameterType::EQUATION : 990cdf0e10cSrcweir { 991cdf0e10cSrcweir sal_Int32 nEquationIndex = 0; 992cdf0e10cSrcweir if ( rParameter.Value >>= nEquationIndex ) 993cdf0e10cSrcweir { 994cdf0e10cSrcweir rRetValue = GetEquationValueAsDouble( nEquationIndex ); 995cdf0e10cSrcweir bRetValue = sal_True; 996cdf0e10cSrcweir } 997cdf0e10cSrcweir } 998cdf0e10cSrcweir break; 999cdf0e10cSrcweir case EnhancedCustomShapeParameterType::NORMAL : 1000cdf0e10cSrcweir { 1001cdf0e10cSrcweir if ( rParameter.Value.getValueTypeClass() == TypeClass_DOUBLE ) 1002cdf0e10cSrcweir { 1003cdf0e10cSrcweir double fValue; 1004cdf0e10cSrcweir if ( rParameter.Value >>= fValue ) 1005cdf0e10cSrcweir { 1006cdf0e10cSrcweir rRetValue = fValue; 1007cdf0e10cSrcweir bRetValue = sal_True; 1008cdf0e10cSrcweir } 1009cdf0e10cSrcweir } 1010cdf0e10cSrcweir else 1011cdf0e10cSrcweir { 1012cdf0e10cSrcweir sal_Int32 nValue = 0; 1013cdf0e10cSrcweir if ( rParameter.Value >>= nValue ) 1014cdf0e10cSrcweir { 1015cdf0e10cSrcweir rRetValue = nValue; 1016cdf0e10cSrcweir bRetValue = sal_True; 1017cdf0e10cSrcweir if ( bReplaceGeoWidth && ( nValue == nCoordWidth ) ) 1018cdf0e10cSrcweir rRetValue *= fXRatio; 1019cdf0e10cSrcweir else if ( bReplaceGeoHeight && ( nValue == nCoordHeight ) ) 1020cdf0e10cSrcweir rRetValue *= fYRatio; 1021cdf0e10cSrcweir } 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir } 1024cdf0e10cSrcweir break; 1025cdf0e10cSrcweir case EnhancedCustomShapeParameterType::LEFT : 1026cdf0e10cSrcweir { 1027cdf0e10cSrcweir rRetValue = 0.0; 1028cdf0e10cSrcweir bRetValue = sal_True; 1029cdf0e10cSrcweir } 1030cdf0e10cSrcweir break; 1031cdf0e10cSrcweir case EnhancedCustomShapeParameterType::TOP : 1032cdf0e10cSrcweir { 1033cdf0e10cSrcweir rRetValue = 0.0; 1034cdf0e10cSrcweir bRetValue = sal_True; 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir break; 1037cdf0e10cSrcweir case EnhancedCustomShapeParameterType::RIGHT : 1038cdf0e10cSrcweir { 1039cdf0e10cSrcweir rRetValue = nCoordWidth; 1040cdf0e10cSrcweir bRetValue = sal_True; 1041cdf0e10cSrcweir } 1042cdf0e10cSrcweir break; 1043cdf0e10cSrcweir case EnhancedCustomShapeParameterType::BOTTOM : 1044cdf0e10cSrcweir { 1045cdf0e10cSrcweir rRetValue = nCoordHeight; 1046cdf0e10cSrcweir bRetValue = sal_True; 1047cdf0e10cSrcweir } 1048cdf0e10cSrcweir break; 1049cdf0e10cSrcweir } 1050cdf0e10cSrcweir return bRetValue; 1051cdf0e10cSrcweir } 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir // nLumDat 28-31 = number of luminance entries in nLumDat 1054cdf0e10cSrcweir // nLumDat 27-24 = nLumDatEntry 0 1055cdf0e10cSrcweir // nLumDat 23-20 = nLumDatEntry 1 ... 1056cdf0e10cSrcweir // each 4bit entry is to be interpreted as a 10 percent signed luminance changing 1057cdf0e10cSrcweir sal_Int32 EnhancedCustomShape2d::GetLuminanceChange( sal_uInt32 nIndex ) const 1058cdf0e10cSrcweir { 1059cdf0e10cSrcweir const sal_uInt32 nCount = nColorData >> 28; 1060cdf0e10cSrcweir if ( !nCount ) 1061cdf0e10cSrcweir return 0; 1062cdf0e10cSrcweir 1063cdf0e10cSrcweir if ( nIndex >= nCount ) 1064cdf0e10cSrcweir nIndex = nCount - 1; 1065cdf0e10cSrcweir 1066cdf0e10cSrcweir const sal_Int32 nLumDat = nColorData << ( ( 1 + nIndex ) << 2 ); 1067cdf0e10cSrcweir return ( nLumDat >> 28 ) * 10; 1068cdf0e10cSrcweir } 1069cdf0e10cSrcweir 1070cdf0e10cSrcweir Color EnhancedCustomShape2d::GetColorData( const Color& rFillColor, sal_uInt32 nIndex ) const 1071cdf0e10cSrcweir { 1072cdf0e10cSrcweir const sal_Int32 nLuminance = GetLuminanceChange(nIndex); 1073cdf0e10cSrcweir if( !nLuminance ) 1074cdf0e10cSrcweir return rFillColor; 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir basegfx::BColor aHSVColor= 1077cdf0e10cSrcweir basegfx::tools::rgb2hsv( 1078cdf0e10cSrcweir basegfx::BColor(rFillColor.GetRed()/255.0, 1079cdf0e10cSrcweir rFillColor.GetGreen()/255.0, 1080cdf0e10cSrcweir rFillColor.GetBlue()/255.0)); 1081cdf0e10cSrcweir if( nLuminance > 0 ) 1082cdf0e10cSrcweir { 1083cdf0e10cSrcweir aHSVColor.setGreen( 1084cdf0e10cSrcweir aHSVColor.getGreen() * (1.0-nLuminance/100.0)); 1085cdf0e10cSrcweir aHSVColor.setBlue( 1086cdf0e10cSrcweir nLuminance/100.0 + 1087cdf0e10cSrcweir (1.0-nLuminance/100.0)*aHSVColor.getBlue()); 1088cdf0e10cSrcweir } 1089cdf0e10cSrcweir else if( nLuminance < 0 ) 1090cdf0e10cSrcweir { 1091cdf0e10cSrcweir aHSVColor.setBlue( 1092cdf0e10cSrcweir (1.0+nLuminance/100.0)*aHSVColor.getBlue()); 1093cdf0e10cSrcweir } 1094cdf0e10cSrcweir 1095cdf0e10cSrcweir aHSVColor = basegfx::tools::hsv2rgb(aHSVColor); 1096cdf0e10cSrcweir return Color( (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getRed(),0.0,1.0) * 255.0 + 0.5 ), 1097cdf0e10cSrcweir (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getGreen(),0.0,1.0) * 255.0 + 0.5 ), 1098cdf0e10cSrcweir (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getBlue(),0.0,1.0) * 255.0 + 0.5 ) ); 1099cdf0e10cSrcweir } 1100cdf0e10cSrcweir 1101cdf0e10cSrcweir Rectangle EnhancedCustomShape2d::GetTextRect() const 1102cdf0e10cSrcweir { 1103cdf0e10cSrcweir sal_Int32 nIndex, nSize = seqTextFrames.getLength(); 1104cdf0e10cSrcweir if ( !nSize ) 1105cdf0e10cSrcweir return aLogicRect; 1106cdf0e10cSrcweir nIndex = 0; 1107cdf0e10cSrcweir if ( bTextFlow && ( nSize > 1 ) ) 1108cdf0e10cSrcweir nIndex++; 1109cdf0e10cSrcweir Point aTopLeft( GetPoint( seqTextFrames[ nIndex ].TopLeft, sal_True, sal_True ) ); 1110cdf0e10cSrcweir Point aBottomRight( GetPoint( seqTextFrames[ nIndex ].BottomRight, sal_True, sal_True ) ); 1111cdf0e10cSrcweir if ( bFlipH ) 1112cdf0e10cSrcweir { 1113cdf0e10cSrcweir aTopLeft.X() = aLogicRect.GetWidth() - aTopLeft.X(); 1114cdf0e10cSrcweir aBottomRight.X() = aLogicRect.GetWidth() - aBottomRight.X(); 1115cdf0e10cSrcweir } 1116cdf0e10cSrcweir if ( bFlipV ) 1117cdf0e10cSrcweir { 1118cdf0e10cSrcweir aTopLeft.Y() = aLogicRect.GetHeight() - aTopLeft.Y(); 1119cdf0e10cSrcweir aBottomRight.Y() = aLogicRect.GetHeight() - aBottomRight.Y(); 1120cdf0e10cSrcweir } 1121cdf0e10cSrcweir Rectangle aRect( aTopLeft, aBottomRight ); 1122cdf0e10cSrcweir aRect.Move( aLogicRect.Left(), aLogicRect.Top() ); 1123cdf0e10cSrcweir aRect.Justify(); 1124cdf0e10cSrcweir return aRect; 1125cdf0e10cSrcweir } 1126cdf0e10cSrcweir 1127cdf0e10cSrcweir sal_uInt32 EnhancedCustomShape2d::GetHdlCount() const 1128cdf0e10cSrcweir { 1129cdf0e10cSrcweir return seqHandles.getLength(); 1130cdf0e10cSrcweir } 1131cdf0e10cSrcweir 1132cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir sal_Bool bRetValue = sal_False; 1135cdf0e10cSrcweir if ( nIndex < GetHdlCount() ) 1136cdf0e10cSrcweir { 1137cdf0e10cSrcweir Handle aHandle; 1138cdf0e10cSrcweir if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) ) 1139cdf0e10cSrcweir { 1140cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_POLAR ) 1141cdf0e10cSrcweir { 1142cdf0e10cSrcweir Point aReferencePoint( GetPoint( aHandle.aPolar, sal_True, sal_False ) ); 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir double fAngle; 1145cdf0e10cSrcweir double fRadius; 1146cdf0e10cSrcweir GetParameter( fRadius, aHandle.aPosition.First, sal_False, sal_False ); 1147cdf0e10cSrcweir GetParameter( fAngle, aHandle.aPosition.Second, sal_False, sal_False ); 1148cdf0e10cSrcweir 1149cdf0e10cSrcweir double a = ( 360.0 - fAngle ) * F_PI180; 1150cdf0e10cSrcweir double dx = fRadius * fXScale; 1151cdf0e10cSrcweir double fX = dx * cos( a ); 1152cdf0e10cSrcweir double fY =-dx * sin( a ); 1153cdf0e10cSrcweir rReturnPosition = 1154cdf0e10cSrcweir Point( 1155cdf0e10cSrcweir Round( fX + aReferencePoint.X() ), 1156cdf0e10cSrcweir basegfx::fTools::equalZero(fXScale) ? aReferencePoint.Y() : 1157cdf0e10cSrcweir Round( ( fY * fYScale ) / fXScale + aReferencePoint.Y() ) ); 1158cdf0e10cSrcweir } 1159cdf0e10cSrcweir else 1160cdf0e10cSrcweir { 1161cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED ) 1162cdf0e10cSrcweir { 1163cdf0e10cSrcweir if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() ) 1164cdf0e10cSrcweir { 1165cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter aFirst = aHandle.aPosition.First; 1166cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter aSecond = aHandle.aPosition.Second; 1167cdf0e10cSrcweir aHandle.aPosition.First = aSecond; 1168cdf0e10cSrcweir aHandle.aPosition.Second = aFirst; 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir } 1171cdf0e10cSrcweir rReturnPosition = GetPoint( aHandle.aPosition, sal_True, sal_False ); 1172cdf0e10cSrcweir } 1173cdf0e10cSrcweir const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() ); 1174cdf0e10cSrcweir if ( aGeoStat.nShearWink ) 1175cdf0e10cSrcweir { 1176cdf0e10cSrcweir double nTan = aGeoStat.nTan; 1177cdf0e10cSrcweir if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV)) 1178cdf0e10cSrcweir nTan = -nTan; 1179cdf0e10cSrcweir ShearPoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan ); 1180cdf0e10cSrcweir } 1181cdf0e10cSrcweir if ( nRotateAngle ) 1182cdf0e10cSrcweir { 1183cdf0e10cSrcweir double a = nRotateAngle * F_PI18000; 1184cdf0e10cSrcweir RotatePoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) ); 1185cdf0e10cSrcweir } 1186cdf0e10cSrcweir if ( bFlipH ) 1187cdf0e10cSrcweir rReturnPosition.X() = aLogicRect.GetWidth() - rReturnPosition.X(); 1188cdf0e10cSrcweir if ( bFlipV ) 1189cdf0e10cSrcweir rReturnPosition.Y() = aLogicRect.GetHeight() - rReturnPosition.Y(); 1190cdf0e10cSrcweir rReturnPosition.Move( aLogicRect.Left(), aLogicRect.Top() ); 1191cdf0e10cSrcweir bRetValue = sal_True; 1192cdf0e10cSrcweir } 1193cdf0e10cSrcweir } 1194cdf0e10cSrcweir return bRetValue; 1195cdf0e10cSrcweir } 1196cdf0e10cSrcweir 1197cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition ) 1198cdf0e10cSrcweir { 1199cdf0e10cSrcweir sal_Bool bRetValue = sal_False; 1200cdf0e10cSrcweir if ( nIndex < GetHdlCount() ) 1201cdf0e10cSrcweir { 1202cdf0e10cSrcweir Handle aHandle; 1203cdf0e10cSrcweir if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) ) 1204cdf0e10cSrcweir { 1205cdf0e10cSrcweir Point aP( rPosition.X, rPosition.Y ); 1206cdf0e10cSrcweir // apply the negative object rotation to the controller position 1207cdf0e10cSrcweir 1208cdf0e10cSrcweir aP.Move( -aLogicRect.Left(), -aLogicRect.Top() ); 1209cdf0e10cSrcweir if ( bFlipH ) 1210cdf0e10cSrcweir aP.X() = aLogicRect.GetWidth() - aP.X(); 1211cdf0e10cSrcweir if ( bFlipV ) 1212cdf0e10cSrcweir aP.Y() = aLogicRect.GetHeight() - aP.Y(); 1213cdf0e10cSrcweir if ( nRotateAngle ) 1214cdf0e10cSrcweir { 1215cdf0e10cSrcweir double a = -nRotateAngle * F_PI18000; 1216cdf0e10cSrcweir RotatePoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) ); 1217cdf0e10cSrcweir } 1218cdf0e10cSrcweir const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() ); 1219cdf0e10cSrcweir if ( aGeoStat.nShearWink ) 1220cdf0e10cSrcweir { 1221cdf0e10cSrcweir double nTan = -aGeoStat.nTan; 1222cdf0e10cSrcweir if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV)) 1223cdf0e10cSrcweir nTan = -nTan; 1224cdf0e10cSrcweir ShearPoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan ); 1225cdf0e10cSrcweir } 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir double fPos1 = aP.X(); //( bFlipH ) ? aLogicRect.GetWidth() - aP.X() : aP.X(); 1228cdf0e10cSrcweir double fPos2 = aP.Y(); //( bFlipV ) ? aLogicRect.GetHeight() -aP.Y() : aP.Y(); 1229cdf0e10cSrcweir fPos1 /= fXScale; 1230cdf0e10cSrcweir fPos2 /= fYScale; 1231cdf0e10cSrcweir 1232cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED ) 1233cdf0e10cSrcweir { 1234cdf0e10cSrcweir if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() ) 1235cdf0e10cSrcweir { 1236cdf0e10cSrcweir double fX = fPos1; 1237cdf0e10cSrcweir double fY = fPos2; 1238cdf0e10cSrcweir fPos1 = fY; 1239cdf0e10cSrcweir fPos2 = fX; 1240cdf0e10cSrcweir } 1241cdf0e10cSrcweir } 1242cdf0e10cSrcweir 1243cdf0e10cSrcweir sal_Int32 nFirstAdjustmentValue = -1, nSecondAdjustmentValue = -1; 1244cdf0e10cSrcweir 1245cdf0e10cSrcweir if ( aHandle.aPosition.First.Type == EnhancedCustomShapeParameterType::ADJUSTMENT ) 1246cdf0e10cSrcweir aHandle.aPosition.First.Value >>= nFirstAdjustmentValue; 1247cdf0e10cSrcweir if ( aHandle.aPosition.Second.Type == EnhancedCustomShapeParameterType::ADJUSTMENT ) 1248cdf0e10cSrcweir aHandle.aPosition.Second.Value>>= nSecondAdjustmentValue; 1249cdf0e10cSrcweir 1250cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_POLAR ) 1251cdf0e10cSrcweir { 1252cdf0e10cSrcweir double fXRef, fYRef, fAngle; 1253cdf0e10cSrcweir GetParameter( fXRef, aHandle.aPolar.First, sal_False, sal_False ); 1254cdf0e10cSrcweir GetParameter( fYRef, aHandle.aPolar.Second, sal_False, sal_False ); 1255cdf0e10cSrcweir const double fDX = fPos1 - fXRef; 1256cdf0e10cSrcweir fAngle = -( atan2( -fPos2 + fYRef, ( ( fDX == 0.0L ) ? 0.000000001 : fDX ) ) / F_PI180 ); 1257cdf0e10cSrcweir double fX = ( fPos1 - fXRef ); 1258cdf0e10cSrcweir double fY = ( fPos2 - fYRef ); 1259cdf0e10cSrcweir double fRadius = sqrt( fX * fX + fY * fY ); 1260cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MINIMUM ) 1261cdf0e10cSrcweir { 1262cdf0e10cSrcweir double fMin; 1263cdf0e10cSrcweir GetParameter( fMin, aHandle.aRadiusRangeMinimum, sal_False, sal_False ); 1264cdf0e10cSrcweir if ( fRadius < fMin ) 1265cdf0e10cSrcweir fRadius = fMin; 1266cdf0e10cSrcweir } 1267cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM ) 1268cdf0e10cSrcweir { 1269cdf0e10cSrcweir double fMax; 1270cdf0e10cSrcweir GetParameter( fMax, aHandle.aRadiusRangeMaximum, sal_False, sal_False ); 1271cdf0e10cSrcweir if ( fRadius > fMax ) 1272cdf0e10cSrcweir fRadius = fMax; 1273cdf0e10cSrcweir } 1274cdf0e10cSrcweir if ( nFirstAdjustmentValue >= 0 ) 1275cdf0e10cSrcweir SetAdjustValueAsDouble( fRadius, nFirstAdjustmentValue ); 1276cdf0e10cSrcweir if ( nSecondAdjustmentValue >= 0 ) 1277cdf0e10cSrcweir SetAdjustValueAsDouble( fAngle, nSecondAdjustmentValue ); 1278cdf0e10cSrcweir } 1279cdf0e10cSrcweir else 1280cdf0e10cSrcweir { 1281cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_REFX ) 1282cdf0e10cSrcweir { 1283cdf0e10cSrcweir nFirstAdjustmentValue = aHandle.nRefX; 1284cdf0e10cSrcweir fPos1 *= 100000.0; 1285cdf0e10cSrcweir fPos1 /= nCoordWidth; 1286cdf0e10cSrcweir } 1287cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_REFY ) 1288cdf0e10cSrcweir { 1289cdf0e10cSrcweir nSecondAdjustmentValue = aHandle.nRefY; 1290cdf0e10cSrcweir fPos2 *= 100000.0; 1291cdf0e10cSrcweir fPos2 /= nCoordHeight; 1292cdf0e10cSrcweir } 1293cdf0e10cSrcweir if ( nFirstAdjustmentValue >= 0 ) 1294cdf0e10cSrcweir { 1295cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MINIMUM ) // check if horizontal handle needs to be within a range 1296cdf0e10cSrcweir { 1297cdf0e10cSrcweir double fXMin; 1298cdf0e10cSrcweir GetParameter( fXMin, aHandle.aXRangeMinimum, sal_False, sal_False ); 1299cdf0e10cSrcweir if ( fPos1 < fXMin ) 1300cdf0e10cSrcweir fPos1 = fXMin; 1301cdf0e10cSrcweir } 1302cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MAXIMUM ) // check if horizontal handle needs to be within a range 1303cdf0e10cSrcweir { 1304cdf0e10cSrcweir double fXMax; 1305cdf0e10cSrcweir GetParameter( fXMax, aHandle.aXRangeMaximum, sal_False, sal_False ); 1306cdf0e10cSrcweir if ( fPos1 > fXMax ) 1307cdf0e10cSrcweir fPos1 = fXMax; 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir SetAdjustValueAsDouble( fPos1, nFirstAdjustmentValue ); 1310cdf0e10cSrcweir } 1311cdf0e10cSrcweir if ( nSecondAdjustmentValue >= 0 ) 1312cdf0e10cSrcweir { 1313cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MINIMUM ) // check if vertical handle needs to be within a range 1314cdf0e10cSrcweir { 1315cdf0e10cSrcweir double fYMin; 1316cdf0e10cSrcweir GetParameter( fYMin, aHandle.aYRangeMinimum, sal_False, sal_False ); 1317cdf0e10cSrcweir if ( fPos2 < fYMin ) 1318cdf0e10cSrcweir fPos2 = fYMin; 1319cdf0e10cSrcweir } 1320cdf0e10cSrcweir if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MAXIMUM ) // check if vertical handle needs to be within a range 1321cdf0e10cSrcweir { 1322cdf0e10cSrcweir double fYMax; 1323cdf0e10cSrcweir GetParameter( fYMax, aHandle.aYRangeMaximum, sal_False, sal_False ); 1324cdf0e10cSrcweir if ( fPos2 > fYMax ) 1325cdf0e10cSrcweir fPos2 = fYMax; 1326cdf0e10cSrcweir } 1327cdf0e10cSrcweir SetAdjustValueAsDouble( fPos2, nSecondAdjustmentValue ); 1328cdf0e10cSrcweir } 1329cdf0e10cSrcweir } 1330cdf0e10cSrcweir // and writing them back into the GeometryItem 1331cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem((SdrCustomShapeGeometryItem&) 1332cdf0e10cSrcweir (const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )); 1333cdf0e10cSrcweir const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) ); 1334cdf0e10cSrcweir com::sun::star::beans::PropertyValue aPropVal; 1335cdf0e10cSrcweir aPropVal.Name = sAdjustmentValues; 1336cdf0e10cSrcweir aPropVal.Value <<= seqAdjustmentValues; 1337cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 1338cdf0e10cSrcweir pCustomShapeObj->SetMergedItem( aGeometryItem ); 1339cdf0e10cSrcweir bRetValue = sal_True; 1340cdf0e10cSrcweir } 1341cdf0e10cSrcweir } 1342cdf0e10cSrcweir return bRetValue; 1343cdf0e10cSrcweir } 1344cdf0e10cSrcweir 1345cdf0e10cSrcweir void EnhancedCustomShape2d::SwapStartAndEndArrow( SdrObject* pObj ) //#108274 1346cdf0e10cSrcweir { 1347cdf0e10cSrcweir XLineStartItem aLineStart; 1348cdf0e10cSrcweir aLineStart.SetLineStartValue(((XLineStartItem&)pObj->GetMergedItem( XATTR_LINEEND )).GetLineStartValue()); 1349cdf0e10cSrcweir XLineStartWidthItem aLineStartWidth(((XLineStartWidthItem&)pObj->GetMergedItem( XATTR_LINEENDWIDTH )).GetValue()); 1350cdf0e10cSrcweir XLineStartCenterItem aLineStartCenter(((XLineStartCenterItem&)pObj->GetMergedItem( XATTR_LINEENDCENTER )).GetValue()); 1351cdf0e10cSrcweir 1352cdf0e10cSrcweir XLineEndItem aLineEnd; 1353cdf0e10cSrcweir aLineEnd.SetLineEndValue(((XLineEndItem&)pObj->GetMergedItem( XATTR_LINESTART )).GetLineEndValue()); 1354cdf0e10cSrcweir XLineEndWidthItem aLineEndWidth(((XLineEndWidthItem&)pObj->GetMergedItem( XATTR_LINESTARTWIDTH )).GetValue()); 1355cdf0e10cSrcweir XLineEndCenterItem aLineEndCenter(((XLineEndCenterItem&)pObj->GetMergedItem( XATTR_LINESTARTCENTER )).GetValue()); 1356cdf0e10cSrcweir 1357cdf0e10cSrcweir pObj->SetMergedItem( aLineStart ); 1358cdf0e10cSrcweir pObj->SetMergedItem( aLineStartWidth ); 1359cdf0e10cSrcweir pObj->SetMergedItem( aLineStartCenter ); 1360cdf0e10cSrcweir pObj->SetMergedItem( aLineEnd ); 1361cdf0e10cSrcweir pObj->SetMergedItem( aLineEndWidth ); 1362cdf0e10cSrcweir pObj->SetMergedItem( aLineEndCenter ); 1363cdf0e10cSrcweir } 1364cdf0e10cSrcweir 1365cdf0e10cSrcweir basegfx::B2DPolygon CreateArc( const Rectangle& rRect, const Point& rStart, const Point& rEnd, const sal_Bool bClockwise ) 1366cdf0e10cSrcweir { 1367cdf0e10cSrcweir Rectangle aRect( rRect ); 1368cdf0e10cSrcweir Point aStart( rStart ); 1369cdf0e10cSrcweir Point aEnd( rEnd ); 1370cdf0e10cSrcweir 1371cdf0e10cSrcweir sal_Int32 bSwapStartEndAngle = 0; 1372cdf0e10cSrcweir 1373cdf0e10cSrcweir if ( aRect.Left() > aRect.Right() ) 1374cdf0e10cSrcweir bSwapStartEndAngle ^= 0x01; 1375cdf0e10cSrcweir if ( aRect.Top() > aRect.Bottom() ) 1376cdf0e10cSrcweir bSwapStartEndAngle ^= 0x11; 1377cdf0e10cSrcweir if ( bSwapStartEndAngle ) 1378cdf0e10cSrcweir { 1379cdf0e10cSrcweir aRect.Justify(); 1380cdf0e10cSrcweir if ( bSwapStartEndAngle & 1 ) 1381cdf0e10cSrcweir { 1382cdf0e10cSrcweir Point aTmp( aStart ); 1383cdf0e10cSrcweir aStart = aEnd; 1384cdf0e10cSrcweir aEnd = aTmp; 1385cdf0e10cSrcweir } 1386cdf0e10cSrcweir } 1387cdf0e10cSrcweir 1388cdf0e10cSrcweir Polygon aTempPoly( aRect, aStart, aEnd, POLY_ARC ); 1389cdf0e10cSrcweir basegfx::B2DPolygon aRetval; 1390cdf0e10cSrcweir 1391cdf0e10cSrcweir if ( bClockwise ) 1392cdf0e10cSrcweir { 1393cdf0e10cSrcweir for ( sal_uInt16 j = aTempPoly.GetSize(); j--; ) 1394cdf0e10cSrcweir { 1395cdf0e10cSrcweir aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y())); 1396cdf0e10cSrcweir } 1397cdf0e10cSrcweir } 1398cdf0e10cSrcweir else 1399cdf0e10cSrcweir { 1400cdf0e10cSrcweir for ( sal_uInt16 j = 0; j < aTempPoly.GetSize(); j++ ) 1401cdf0e10cSrcweir { 1402cdf0e10cSrcweir aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y())); 1403cdf0e10cSrcweir } 1404cdf0e10cSrcweir } 1405cdf0e10cSrcweir 1406cdf0e10cSrcweir return aRetval; 1407cdf0e10cSrcweir } 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList, 1410cdf0e10cSrcweir const sal_Bool bLineGeometryNeededOnly, 1411cdf0e10cSrcweir const sal_Bool bSortFilledObjectsToBack ) 1412cdf0e10cSrcweir { 1413cdf0e10cSrcweir sal_Bool bNoFill = sal_False; 1414cdf0e10cSrcweir sal_Bool bNoStroke = sal_False; 1415cdf0e10cSrcweir 1416cdf0e10cSrcweir basegfx::B2DPolyPolygon aNewB2DPolyPolygon; 1417cdf0e10cSrcweir basegfx::B2DPolygon aNewB2DPolygon; 1418cdf0e10cSrcweir 1419cdf0e10cSrcweir sal_Int32 nCoordSize = seqCoordinates.getLength(); 1420cdf0e10cSrcweir sal_Int32 nSegInfoSize = seqSegments.getLength(); 1421cdf0e10cSrcweir if ( !nSegInfoSize ) 1422cdf0e10cSrcweir { 1423cdf0e10cSrcweir const EnhancedCustomShapeParameterPair* pTmp = seqCoordinates.getArray(); 1424cdf0e10cSrcweir 1425cdf0e10cSrcweir for ( sal_Int32 nPtNum(0L); nPtNum < nCoordSize; nPtNum++ ) 1426cdf0e10cSrcweir { 1427cdf0e10cSrcweir const Point aTempPoint(GetPoint( *pTmp++, sal_True, sal_True )); 1428cdf0e10cSrcweir aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y())); 1429cdf0e10cSrcweir } 1430cdf0e10cSrcweir 1431cdf0e10cSrcweir aNewB2DPolygon.setClosed(true); 1432cdf0e10cSrcweir } 1433cdf0e10cSrcweir else 1434cdf0e10cSrcweir { 1435cdf0e10cSrcweir for ( ;rSegmentInd < nSegInfoSize; ) 1436cdf0e10cSrcweir { 1437cdf0e10cSrcweir sal_Int16 nCommand = seqSegments[ rSegmentInd ].Command; 1438cdf0e10cSrcweir sal_Int16 nPntCount= seqSegments[ rSegmentInd++ ].Count; 1439cdf0e10cSrcweir 1440cdf0e10cSrcweir switch ( nCommand ) 1441cdf0e10cSrcweir { 1442cdf0e10cSrcweir case NOFILL : 1443cdf0e10cSrcweir bNoFill = sal_True; 1444cdf0e10cSrcweir break; 1445cdf0e10cSrcweir case NOSTROKE : 1446cdf0e10cSrcweir bNoStroke = sal_True; 1447cdf0e10cSrcweir break; 1448cdf0e10cSrcweir case MOVETO : 1449cdf0e10cSrcweir { 1450cdf0e10cSrcweir if(aNewB2DPolygon.count() > 1L) 1451cdf0e10cSrcweir { 1452cdf0e10cSrcweir // #i76201# Add conversion to closed polygon when first and last points are equal 1453cdf0e10cSrcweir basegfx::tools::checkClosed(aNewB2DPolygon); 1454cdf0e10cSrcweir aNewB2DPolyPolygon.append(aNewB2DPolygon); 1455cdf0e10cSrcweir } 1456cdf0e10cSrcweir 1457cdf0e10cSrcweir aNewB2DPolygon.clear(); 1458cdf0e10cSrcweir 1459cdf0e10cSrcweir if ( rSrcPt < nCoordSize ) 1460cdf0e10cSrcweir { 1461cdf0e10cSrcweir const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True )); 1462cdf0e10cSrcweir aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y())); 1463cdf0e10cSrcweir } 1464cdf0e10cSrcweir } 1465cdf0e10cSrcweir break; 1466cdf0e10cSrcweir case ENDSUBPATH : 1467cdf0e10cSrcweir break; 1468cdf0e10cSrcweir case CLOSESUBPATH : 1469cdf0e10cSrcweir { 1470cdf0e10cSrcweir if(aNewB2DPolygon.count()) 1471cdf0e10cSrcweir { 1472cdf0e10cSrcweir if(aNewB2DPolygon.count() > 1L) 1473cdf0e10cSrcweir { 1474cdf0e10cSrcweir aNewB2DPolygon.setClosed(true); 1475cdf0e10cSrcweir aNewB2DPolyPolygon.append(aNewB2DPolygon); 1476cdf0e10cSrcweir } 1477cdf0e10cSrcweir 1478cdf0e10cSrcweir aNewB2DPolygon.clear(); 1479cdf0e10cSrcweir } 1480cdf0e10cSrcweir } 1481cdf0e10cSrcweir break; 1482cdf0e10cSrcweir case CURVETO : 1483cdf0e10cSrcweir { 1484cdf0e10cSrcweir for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ ) 1485cdf0e10cSrcweir { 1486cdf0e10cSrcweir const Point aControlA(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True )); 1487cdf0e10cSrcweir const Point aControlB(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True )); 1488cdf0e10cSrcweir const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True )); 1489cdf0e10cSrcweir 1490cdf0e10cSrcweir DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding control point (!)"); 1491cdf0e10cSrcweir aNewB2DPolygon.appendBezierSegment( 1492cdf0e10cSrcweir basegfx::B2DPoint(aControlA.X(), aControlA.Y()), 1493cdf0e10cSrcweir basegfx::B2DPoint(aControlB.X(), aControlB.Y()), 1494cdf0e10cSrcweir basegfx::B2DPoint(aEnd.X(), aEnd.Y())); 1495cdf0e10cSrcweir } 1496cdf0e10cSrcweir } 1497cdf0e10cSrcweir break; 1498cdf0e10cSrcweir 1499cdf0e10cSrcweir case ANGLEELLIPSE : 1500cdf0e10cSrcweir { 1501cdf0e10cSrcweir if(aNewB2DPolygon.count() > 1L) 1502cdf0e10cSrcweir { 1503cdf0e10cSrcweir // #i76201# Add conversion to closed polygon when first and last points are equal 1504cdf0e10cSrcweir basegfx::tools::checkClosed(aNewB2DPolygon); 1505cdf0e10cSrcweir aNewB2DPolyPolygon.append(aNewB2DPolygon); 1506cdf0e10cSrcweir } 1507cdf0e10cSrcweir 1508cdf0e10cSrcweir aNewB2DPolygon.clear(); 1509cdf0e10cSrcweir } 1510cdf0e10cSrcweir case ANGLEELLIPSETO : 1511cdf0e10cSrcweir { 1512cdf0e10cSrcweir for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ ) 1513cdf0e10cSrcweir { 1514cdf0e10cSrcweir // create a circle 1515cdf0e10cSrcweir Point _aCenter( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ) ); 1516cdf0e10cSrcweir double fWidth, fHeight; 1517cdf0e10cSrcweir GetParameter( fWidth, seqCoordinates[ rSrcPt + 1 ].First, sal_True, sal_False ); 1518cdf0e10cSrcweir GetParameter( fHeight, seqCoordinates[ rSrcPt + 1 ].Second, sal_False, sal_True ); 1519cdf0e10cSrcweir fWidth *= fXScale; 1520cdf0e10cSrcweir fHeight*= fYScale; 1521cdf0e10cSrcweir Point aP( (sal_Int32)( _aCenter.X() - fWidth ), (sal_Int32)( _aCenter.Y() - fHeight ) ); 1522cdf0e10cSrcweir Size aS( (sal_Int32)( fWidth * 2.0 ), (sal_Int32)( fHeight * 2.0 ) ); 1523cdf0e10cSrcweir Rectangle aRect( aP, aS ); 1524cdf0e10cSrcweir if ( aRect.GetWidth() && aRect.GetHeight() ) 1525cdf0e10cSrcweir { 1526cdf0e10cSrcweir double fStartAngle, fEndAngle; 1527cdf0e10cSrcweir GetParameter( fStartAngle, seqCoordinates[ rSrcPt + 2 ].First, sal_False, sal_False ); 1528cdf0e10cSrcweir GetParameter( fEndAngle , seqCoordinates[ rSrcPt + 2 ].Second, sal_False, sal_False ); 1529cdf0e10cSrcweir 1530cdf0e10cSrcweir if ( ((sal_Int32)fStartAngle % 360) != ((sal_Int32)fEndAngle % 360) ) 1531cdf0e10cSrcweir { 1532cdf0e10cSrcweir if ( (sal_Int32)fStartAngle & 0x7fff0000 ) // SJ: if the angle was imported from our escher import, then the 1533cdf0e10cSrcweir fStartAngle /= 65536.0; // value is shifted by 16. TODO: already change the fixed float to a 1534cdf0e10cSrcweir if ( (sal_Int32)fEndAngle & 0x7fff0000 ) // double in the import filter 1535cdf0e10cSrcweir { 1536cdf0e10cSrcweir fEndAngle /= 65536.0; 1537cdf0e10cSrcweir fEndAngle = fEndAngle + fStartAngle; 1538cdf0e10cSrcweir if ( fEndAngle < 0 ) 1539cdf0e10cSrcweir { // in the binary filter the endangle is the amount 1540cdf0e10cSrcweir double fTemp = fStartAngle; 1541cdf0e10cSrcweir fStartAngle = fEndAngle; 1542cdf0e10cSrcweir fEndAngle = fTemp; 1543cdf0e10cSrcweir } 1544cdf0e10cSrcweir } 1545cdf0e10cSrcweir double fCenterX = aRect.Center().X(); 1546cdf0e10cSrcweir double fCenterY = aRect.Center().Y(); 1547cdf0e10cSrcweir double fx1 = ( cos( fStartAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX; 1548cdf0e10cSrcweir double fy1 = ( -sin( fStartAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY; 1549cdf0e10cSrcweir double fx2 = ( cos( fEndAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX; 1550cdf0e10cSrcweir double fy2 = ( -sin( fEndAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY; 1551cdf0e10cSrcweir aNewB2DPolygon.append(CreateArc( aRect, Point( (sal_Int32)fx1, (sal_Int32)fy1 ), Point( (sal_Int32)fx2, (sal_Int32)fy2 ), sal_False)); 1552cdf0e10cSrcweir } 1553cdf0e10cSrcweir else 1554cdf0e10cSrcweir { /* SJ: TODO: this block should be replaced sometimes, because the current point 1555cdf0e10cSrcweir is not set correct, it also does not use the correct moveto 1556cdf0e10cSrcweir point if ANGLEELLIPSETO was used, but the method CreateArc 1557cdf0e10cSrcweir is at the moment not able to draw full circles (if startangle is 0 1558cdf0e10cSrcweir and endangle 360 nothing is painted :-( */ 1559cdf0e10cSrcweir sal_Int32 nXControl = (sal_Int32)((double)aRect.GetWidth() * 0.2835 ); 1560cdf0e10cSrcweir sal_Int32 nYControl = (sal_Int32)((double)aRect.GetHeight() * 0.2835 ); 1561cdf0e10cSrcweir Point aCenter( aRect.Center() ); 1562cdf0e10cSrcweir 1563cdf0e10cSrcweir // append start point 1564cdf0e10cSrcweir aNewB2DPolygon.append(basegfx::B2DPoint(aCenter.X(), aRect.Top())); 1565cdf0e10cSrcweir 1566cdf0e10cSrcweir // append four bezier segments 1567cdf0e10cSrcweir aNewB2DPolygon.appendBezierSegment( 1568cdf0e10cSrcweir basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Top()), 1569cdf0e10cSrcweir basegfx::B2DPoint(aRect.Right(), aCenter.Y() - nYControl), 1570cdf0e10cSrcweir basegfx::B2DPoint(aRect.Right(), aCenter.Y())); 1571cdf0e10cSrcweir 1572cdf0e10cSrcweir aNewB2DPolygon.appendBezierSegment( 1573cdf0e10cSrcweir basegfx::B2DPoint(aRect.Right(), aCenter.Y() + nYControl), 1574cdf0e10cSrcweir basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Bottom()), 1575cdf0e10cSrcweir basegfx::B2DPoint(aCenter.X(), aRect.Bottom())); 1576cdf0e10cSrcweir 1577cdf0e10cSrcweir aNewB2DPolygon.appendBezierSegment( 1578cdf0e10cSrcweir basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Bottom()), 1579cdf0e10cSrcweir basegfx::B2DPoint(aRect.Left(), aCenter.Y() + nYControl), 1580cdf0e10cSrcweir basegfx::B2DPoint(aRect.Left(), aCenter.Y())); 1581cdf0e10cSrcweir 1582cdf0e10cSrcweir aNewB2DPolygon.appendBezierSegment( 1583cdf0e10cSrcweir basegfx::B2DPoint(aRect.Left(), aCenter.Y() - nYControl), 1584cdf0e10cSrcweir basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Top()), 1585cdf0e10cSrcweir basegfx::B2DPoint(aCenter.X(), aRect.Top())); 1586cdf0e10cSrcweir 1587cdf0e10cSrcweir // close, rescue last controlpoint, remove double last point 1588cdf0e10cSrcweir basegfx::tools::closeWithGeometryChange(aNewB2DPolygon); 1589cdf0e10cSrcweir } 1590cdf0e10cSrcweir } 1591cdf0e10cSrcweir rSrcPt += 3; 1592cdf0e10cSrcweir } 1593cdf0e10cSrcweir } 1594cdf0e10cSrcweir break; 1595cdf0e10cSrcweir 1596cdf0e10cSrcweir case LINETO : 1597cdf0e10cSrcweir { 1598cdf0e10cSrcweir for ( sal_Int32 i(0L); ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ ) 1599cdf0e10cSrcweir { 1600cdf0e10cSrcweir const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True )); 1601cdf0e10cSrcweir aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y())); 1602cdf0e10cSrcweir } 1603cdf0e10cSrcweir } 1604cdf0e10cSrcweir break; 1605cdf0e10cSrcweir 1606cdf0e10cSrcweir case ARC : 1607cdf0e10cSrcweir case CLOCKWISEARC : 1608cdf0e10cSrcweir { 1609cdf0e10cSrcweir if(aNewB2DPolygon.count() > 1L) 1610cdf0e10cSrcweir { 1611cdf0e10cSrcweir // #i76201# Add conversion to closed polygon when first and last points are equal 1612cdf0e10cSrcweir basegfx::tools::checkClosed(aNewB2DPolygon); 1613cdf0e10cSrcweir aNewB2DPolyPolygon.append(aNewB2DPolygon); 1614cdf0e10cSrcweir } 1615cdf0e10cSrcweir 1616cdf0e10cSrcweir aNewB2DPolygon.clear(); 1617cdf0e10cSrcweir } 1618cdf0e10cSrcweir case ARCTO : 1619cdf0e10cSrcweir case CLOCKWISEARCTO : 1620cdf0e10cSrcweir { 1621cdf0e10cSrcweir sal_Bool bClockwise = ( nCommand == CLOCKWISEARC ) || ( nCommand == CLOCKWISEARCTO ); 1622cdf0e10cSrcweir sal_uInt32 nXor = bClockwise ? 3 : 2; 1623cdf0e10cSrcweir for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 3 ) < nCoordSize ); i++ ) 1624cdf0e10cSrcweir { 1625cdf0e10cSrcweir Rectangle aRect( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ), GetPoint( seqCoordinates[ rSrcPt + 1 ], sal_True, sal_True ) ); 1626cdf0e10cSrcweir if ( aRect.GetWidth() && aRect.GetHeight() ) 1627cdf0e10cSrcweir { 1628cdf0e10cSrcweir Point aCenter( aRect.Center() ); 1629cdf0e10cSrcweir Point aStart( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + nXor ) ], sal_True, sal_True ) ); 1630cdf0e10cSrcweir Point aEnd( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + ( nXor ^ 1 ) ) ], sal_True, sal_True ) ); 1631cdf0e10cSrcweir double fRatio = (double)aRect.GetHeight() / (double)aRect.GetWidth(); 1632cdf0e10cSrcweir aStart.X() = (sal_Int32)( ( (double)( aStart.X() - aCenter.X() ) ) * fRatio ) + aCenter.X(); 1633cdf0e10cSrcweir aStart.Y() = (sal_Int32)( ( (double)( aStart.Y() - aCenter.Y() ) ) ) + aCenter.Y(); 1634cdf0e10cSrcweir aEnd.X() = (sal_Int32)( ( (double)( aEnd.X() - aCenter.X() ) ) * fRatio ) + aCenter.X(); 1635cdf0e10cSrcweir aEnd.Y() = (sal_Int32)( ( (double)( aEnd.Y() - aCenter.Y() ) ) ) + aCenter.Y(); 1636cdf0e10cSrcweir aNewB2DPolygon.append(CreateArc( aRect, aStart, aEnd, bClockwise)); 1637cdf0e10cSrcweir } 1638cdf0e10cSrcweir rSrcPt += 4; 1639cdf0e10cSrcweir } 1640cdf0e10cSrcweir } 1641cdf0e10cSrcweir break; 1642cdf0e10cSrcweir 1643cdf0e10cSrcweir case ELLIPTICALQUADRANTX : 1644cdf0e10cSrcweir case ELLIPTICALQUADRANTY : 1645cdf0e10cSrcweir { 1646cdf0e10cSrcweir bool bFirstDirection(true); 1647cdf0e10cSrcweir basegfx::B2DPoint aControlPointA; 1648cdf0e10cSrcweir basegfx::B2DPoint aControlPointB; 1649cdf0e10cSrcweir 1650cdf0e10cSrcweir for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ ) 1651cdf0e10cSrcweir { 1652cdf0e10cSrcweir sal_uInt32 nModT = ( nCommand == ELLIPTICALQUADRANTX ) ? 1 : 0; 1653cdf0e10cSrcweir Point aCurrent( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ) ); 1654cdf0e10cSrcweir 1655cdf0e10cSrcweir if ( rSrcPt ) // we need a previous point 1656cdf0e10cSrcweir { 1657cdf0e10cSrcweir Point aPrev( GetPoint( seqCoordinates[ rSrcPt - 1 ], sal_True, sal_True ) ); 1658cdf0e10cSrcweir sal_Int32 nX, nY; 1659cdf0e10cSrcweir nX = aCurrent.X() - aPrev.X(); 1660cdf0e10cSrcweir nY = aCurrent.Y() - aPrev.Y(); 1661cdf0e10cSrcweir if ( ( nY ^ nX ) & 0x80000000 ) 1662cdf0e10cSrcweir { 1663cdf0e10cSrcweir if ( !i ) 1664cdf0e10cSrcweir bFirstDirection = true; 1665cdf0e10cSrcweir else if ( !bFirstDirection ) 1666cdf0e10cSrcweir nModT ^= 1; 1667cdf0e10cSrcweir } 1668cdf0e10cSrcweir else 1669cdf0e10cSrcweir { 1670cdf0e10cSrcweir if ( !i ) 1671cdf0e10cSrcweir bFirstDirection = false; 1672cdf0e10cSrcweir else if ( bFirstDirection ) 1673cdf0e10cSrcweir nModT ^= 1; 1674cdf0e10cSrcweir } 1675cdf0e10cSrcweir if ( nModT ) // get the right corner 1676cdf0e10cSrcweir { 1677cdf0e10cSrcweir nX = aCurrent.X(); 1678cdf0e10cSrcweir nY = aPrev.Y(); 1679cdf0e10cSrcweir } 1680cdf0e10cSrcweir else 1681cdf0e10cSrcweir { 1682cdf0e10cSrcweir nX = aPrev.X(); 1683cdf0e10cSrcweir nY = aCurrent.Y(); 1684cdf0e10cSrcweir } 1685cdf0e10cSrcweir sal_Int32 nXVec = ( nX - aPrev.X() ) >> 1; 1686cdf0e10cSrcweir sal_Int32 nYVec = ( nY - aPrev.Y() ) >> 1; 1687cdf0e10cSrcweir Point aControl1( aPrev.X() + nXVec, aPrev.Y() + nYVec ); 1688cdf0e10cSrcweir 1689cdf0e10cSrcweir aControlPointA = basegfx::B2DPoint(aControl1.X(), aControl1.Y()); 1690cdf0e10cSrcweir 1691cdf0e10cSrcweir nXVec = ( nX - aCurrent.X() ) >> 1; 1692cdf0e10cSrcweir nYVec = ( nY - aCurrent.Y() ) >> 1; 1693cdf0e10cSrcweir Point aControl2( aCurrent.X() + nXVec, aCurrent.Y() + nYVec ); 1694cdf0e10cSrcweir 1695cdf0e10cSrcweir aControlPointB = basegfx::B2DPoint(aControl2.X(), aControl2.Y()); 1696cdf0e10cSrcweir 1697cdf0e10cSrcweir aNewB2DPolygon.appendBezierSegment( 1698cdf0e10cSrcweir aControlPointA, 1699cdf0e10cSrcweir aControlPointB, 1700cdf0e10cSrcweir basegfx::B2DPoint(aCurrent.X(), aCurrent.Y())); 1701cdf0e10cSrcweir } 1702cdf0e10cSrcweir else 1703cdf0e10cSrcweir { 1704cdf0e10cSrcweir aNewB2DPolygon.append(basegfx::B2DPoint(aCurrent.X(), aCurrent.Y())); 1705cdf0e10cSrcweir } 1706cdf0e10cSrcweir 1707cdf0e10cSrcweir rSrcPt++; 1708cdf0e10cSrcweir } 1709cdf0e10cSrcweir } 1710cdf0e10cSrcweir break; 1711cdf0e10cSrcweir 1712cdf0e10cSrcweir #ifdef DBG_CUSTOMSHAPE 1713cdf0e10cSrcweir case UNKNOWN : 1714cdf0e10cSrcweir default : 1715cdf0e10cSrcweir { 1716cdf0e10cSrcweir ByteString aString( "CustomShapes::unknown PolyFlagValue :" ); 1717cdf0e10cSrcweir aString.Append( ByteString::CreateFromInt32( nCommand ) ); 1718cdf0e10cSrcweir DBG_ERROR( aString.GetBuffer() ); 1719cdf0e10cSrcweir } 1720cdf0e10cSrcweir break; 1721cdf0e10cSrcweir #endif 1722cdf0e10cSrcweir } 1723cdf0e10cSrcweir if ( nCommand == ENDSUBPATH ) 1724cdf0e10cSrcweir break; 1725cdf0e10cSrcweir } 1726cdf0e10cSrcweir } 1727cdf0e10cSrcweir if ( rSegmentInd == nSegInfoSize ) 1728cdf0e10cSrcweir rSegmentInd++; 1729cdf0e10cSrcweir 1730cdf0e10cSrcweir if(aNewB2DPolygon.count() > 1L) 1731cdf0e10cSrcweir { 1732cdf0e10cSrcweir // #i76201# Add conversion to closed polygon when first and last points are equal 1733cdf0e10cSrcweir basegfx::tools::checkClosed(aNewB2DPolygon); 1734cdf0e10cSrcweir aNewB2DPolyPolygon.append(aNewB2DPolygon); 1735cdf0e10cSrcweir } 1736cdf0e10cSrcweir 1737cdf0e10cSrcweir if(aNewB2DPolyPolygon.count()) 1738cdf0e10cSrcweir { 1739cdf0e10cSrcweir // #i37011# 1740cdf0e10cSrcweir bool bForceCreateTwoObjects(false); 1741cdf0e10cSrcweir 1742cdf0e10cSrcweir if(!bSortFilledObjectsToBack && !aNewB2DPolyPolygon.isClosed() && !bNoStroke) 1743cdf0e10cSrcweir { 1744cdf0e10cSrcweir bForceCreateTwoObjects = true; 1745cdf0e10cSrcweir } 1746cdf0e10cSrcweir 1747cdf0e10cSrcweir if(bLineGeometryNeededOnly) 1748cdf0e10cSrcweir { 1749cdf0e10cSrcweir bForceCreateTwoObjects = true; 1750cdf0e10cSrcweir bNoFill = true; 1751cdf0e10cSrcweir bNoStroke = false; 1752cdf0e10cSrcweir } 1753cdf0e10cSrcweir 1754cdf0e10cSrcweir if(bForceCreateTwoObjects || bSortFilledObjectsToBack) 1755cdf0e10cSrcweir { 1756cdf0e10cSrcweir if(bFilled && !bNoFill) 1757cdf0e10cSrcweir { 1758cdf0e10cSrcweir basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon); 1759cdf0e10cSrcweir aClosedPolyPolygon.setClosed(true); 1760cdf0e10cSrcweir SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon); 1761cdf0e10cSrcweir SfxItemSet aTempSet(*this); 1762cdf0e10cSrcweir aTempSet.Put(SdrShadowItem(sal_False)); 1763cdf0e10cSrcweir aTempSet.Put(XLineStyleItem(XLINE_NONE)); 1764cdf0e10cSrcweir pFill->SetMergedItemSet(aTempSet); 1765cdf0e10cSrcweir rObjectList.push_back(pFill); 1766cdf0e10cSrcweir } 1767cdf0e10cSrcweir 1768cdf0e10cSrcweir if(!bNoStroke) 1769cdf0e10cSrcweir { 1770cdf0e10cSrcweir // there is no reason to use OBJ_PLIN here when the polygon is actually closed, 1771cdf0e10cSrcweir // the non-fill is defined by XFILL_NONE. Since SdrPathObj::ImpForceKind() needs 1772cdf0e10cSrcweir // to correct the polygon (here: open it) using the type, the last edge may get lost. 1773cdf0e10cSrcweir // Thus, use a type that fits the polygon 1774cdf0e10cSrcweir SdrPathObj* pStroke = new SdrPathObj( 1775cdf0e10cSrcweir aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN, 1776cdf0e10cSrcweir aNewB2DPolyPolygon); 1777cdf0e10cSrcweir SfxItemSet aTempSet(*this); 1778cdf0e10cSrcweir aTempSet.Put(SdrShadowItem(sal_False)); 1779cdf0e10cSrcweir aTempSet.Put(XFillStyleItem(XFILL_NONE)); 1780cdf0e10cSrcweir pStroke->SetMergedItemSet(aTempSet); 1781cdf0e10cSrcweir rObjectList.push_back(pStroke); 1782cdf0e10cSrcweir } 1783cdf0e10cSrcweir } 1784cdf0e10cSrcweir else 1785cdf0e10cSrcweir { 1786cdf0e10cSrcweir SdrPathObj* pObj = 0; 1787cdf0e10cSrcweir SfxItemSet aTempSet(*this); 1788cdf0e10cSrcweir aTempSet.Put(SdrShadowItem(sal_False)); 1789cdf0e10cSrcweir 1790cdf0e10cSrcweir if(bNoFill) 1791cdf0e10cSrcweir { 1792cdf0e10cSrcweir // see comment above about OBJ_PLIN 1793cdf0e10cSrcweir pObj = new SdrPathObj( 1794cdf0e10cSrcweir aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN, 1795cdf0e10cSrcweir aNewB2DPolyPolygon); 1796cdf0e10cSrcweir aTempSet.Put(XFillStyleItem(XFILL_NONE)); 1797cdf0e10cSrcweir } 1798cdf0e10cSrcweir else 1799cdf0e10cSrcweir { 1800cdf0e10cSrcweir aNewB2DPolyPolygon.setClosed(true); 1801cdf0e10cSrcweir pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon); 1802cdf0e10cSrcweir } 1803cdf0e10cSrcweir 1804cdf0e10cSrcweir if(bNoStroke) 1805cdf0e10cSrcweir { 1806cdf0e10cSrcweir aTempSet.Put(XLineStyleItem(XLINE_NONE)); 1807cdf0e10cSrcweir } 1808cdf0e10cSrcweir 1809cdf0e10cSrcweir if(pObj) 1810cdf0e10cSrcweir { 1811cdf0e10cSrcweir pObj->SetMergedItemSet(aTempSet); 1812cdf0e10cSrcweir rObjectList.push_back(pObj); 1813cdf0e10cSrcweir } 1814cdf0e10cSrcweir } 1815cdf0e10cSrcweir } 1816cdf0e10cSrcweir } 1817cdf0e10cSrcweir 1818cdf0e10cSrcweir void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::vector< SdrPathObj* >& vObjectList ) 1819cdf0e10cSrcweir { 1820cdf0e10cSrcweir sal_Bool bAccent = sal_False; 1821cdf0e10cSrcweir switch( eSpType ) 1822cdf0e10cSrcweir { 1823cdf0e10cSrcweir case mso_sptCallout1 : 1824cdf0e10cSrcweir case mso_sptBorderCallout1 : 1825cdf0e10cSrcweir case mso_sptCallout90 : 1826cdf0e10cSrcweir case mso_sptBorderCallout90 : 1827cdf0e10cSrcweir default: 1828cdf0e10cSrcweir break; 1829cdf0e10cSrcweir 1830cdf0e10cSrcweir case mso_sptAccentCallout1 : 1831cdf0e10cSrcweir case mso_sptAccentBorderCallout1 : 1832cdf0e10cSrcweir case mso_sptAccentCallout90 : 1833cdf0e10cSrcweir case mso_sptAccentBorderCallout90 : 1834cdf0e10cSrcweir { 1835cdf0e10cSrcweir sal_uInt32 i, nLine = 0; 1836cdf0e10cSrcweir for ( i = 0; i < vObjectList.size(); i++ ) 1837cdf0e10cSrcweir { 1838cdf0e10cSrcweir SdrPathObj* pObj( vObjectList[ i ] ); 1839cdf0e10cSrcweir if(pObj->IsLine()) 1840cdf0e10cSrcweir { 1841cdf0e10cSrcweir nLine++; 1842cdf0e10cSrcweir if ( nLine == nLineObjectCount ) 1843cdf0e10cSrcweir { 1844cdf0e10cSrcweir pObj->ClearMergedItem( XATTR_LINESTART ); 1845cdf0e10cSrcweir pObj->ClearMergedItem( XATTR_LINEEND ); 1846cdf0e10cSrcweir } 1847cdf0e10cSrcweir } 1848cdf0e10cSrcweir } 1849cdf0e10cSrcweir } 1850cdf0e10cSrcweir break; 1851cdf0e10cSrcweir 1852cdf0e10cSrcweir // switch start & end 1853cdf0e10cSrcweir case mso_sptAccentCallout2 : 1854cdf0e10cSrcweir case mso_sptAccentBorderCallout2 : 1855cdf0e10cSrcweir bAccent = sal_True; 1856cdf0e10cSrcweir case mso_sptCallout2 : 1857cdf0e10cSrcweir case mso_sptBorderCallout2 : 1858cdf0e10cSrcweir { 1859cdf0e10cSrcweir sal_uInt32 i, nLine = 0; 1860cdf0e10cSrcweir for ( i = 0; i < vObjectList.size(); i++ ) 1861cdf0e10cSrcweir { 1862cdf0e10cSrcweir SdrPathObj* pObj( vObjectList[ i ] ); 1863cdf0e10cSrcweir if(pObj->IsLine()) 1864cdf0e10cSrcweir { 1865cdf0e10cSrcweir nLine++; 1866cdf0e10cSrcweir if ( nLine == 1 ) 1867cdf0e10cSrcweir pObj->ClearMergedItem( XATTR_LINEEND ); 1868cdf0e10cSrcweir else if ( ( bAccent && ( nLine == nLineObjectCount - 1 ) ) || ( !bAccent && ( nLine == nLineObjectCount ) ) ) 1869cdf0e10cSrcweir pObj->ClearMergedItem( XATTR_LINESTART ); 1870cdf0e10cSrcweir else 1871cdf0e10cSrcweir { 1872cdf0e10cSrcweir pObj->ClearMergedItem( XATTR_LINESTART ); 1873cdf0e10cSrcweir pObj->ClearMergedItem( XATTR_LINEEND ); 1874cdf0e10cSrcweir } 1875cdf0e10cSrcweir } 1876cdf0e10cSrcweir } 1877cdf0e10cSrcweir } 1878cdf0e10cSrcweir break; 1879cdf0e10cSrcweir 1880cdf0e10cSrcweir case mso_sptAccentCallout3 : 1881cdf0e10cSrcweir case mso_sptAccentBorderCallout3 : 1882cdf0e10cSrcweir bAccent = sal_False; 1883cdf0e10cSrcweir case mso_sptCallout3 : 1884cdf0e10cSrcweir case mso_sptBorderCallout3 : 1885cdf0e10cSrcweir { 1886cdf0e10cSrcweir sal_uInt32 i, nLine = 0; 1887cdf0e10cSrcweir for ( i = 0; i < vObjectList.size(); i++ ) 1888cdf0e10cSrcweir { 1889cdf0e10cSrcweir SdrPathObj* pObj( vObjectList[ i ] ); 1890cdf0e10cSrcweir if(pObj->IsLine()) 1891cdf0e10cSrcweir { 1892cdf0e10cSrcweir if ( nLine ) 1893cdf0e10cSrcweir { 1894cdf0e10cSrcweir pObj->ClearMergedItem( XATTR_LINESTART ); 1895cdf0e10cSrcweir pObj->ClearMergedItem( XATTR_LINEEND ); 1896cdf0e10cSrcweir } 1897cdf0e10cSrcweir else 1898cdf0e10cSrcweir EnhancedCustomShape2d::SwapStartAndEndArrow( pObj ); 1899cdf0e10cSrcweir 1900cdf0e10cSrcweir nLine++; 1901cdf0e10cSrcweir } 1902cdf0e10cSrcweir } 1903cdf0e10cSrcweir } 1904cdf0e10cSrcweir break; 1905cdf0e10cSrcweir } 1906cdf0e10cSrcweir } 1907cdf0e10cSrcweir 1908cdf0e10cSrcweir void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet, 1909cdf0e10cSrcweir sal_uInt32& nColorIndex, sal_uInt32 nColorCount) 1910cdf0e10cSrcweir { 1911cdf0e10cSrcweir if ( !rObj.IsLine() ) 1912cdf0e10cSrcweir { 1913cdf0e10cSrcweir const XFillStyle eFillStyle = ((const XFillStyleItem&)rObj.GetMergedItem(XATTR_FILLSTYLE)).GetValue(); 1914cdf0e10cSrcweir switch( eFillStyle ) 1915cdf0e10cSrcweir { 1916cdf0e10cSrcweir default: 1917cdf0e10cSrcweir case XFILL_SOLID: 1918cdf0e10cSrcweir { 1919cdf0e10cSrcweir Color aFillColor; 1920cdf0e10cSrcweir if ( nColorCount ) 1921cdf0e10cSrcweir { 1922cdf0e10cSrcweir aFillColor = GetColorData( 1923cdf0e10cSrcweir ((XFillColorItem&)rCustomShapeSet.Get( XATTR_FILLCOLOR )).GetColorValue(), 1924cdf0e10cSrcweir std::min(nColorIndex, nColorCount-1) ); 1925cdf0e10cSrcweir rObj.SetMergedItem( XFillColorItem( String(), aFillColor ) ); 1926cdf0e10cSrcweir } 1927cdf0e10cSrcweir break; 1928cdf0e10cSrcweir } 1929cdf0e10cSrcweir case XFILL_GRADIENT: 1930cdf0e10cSrcweir { 1931cdf0e10cSrcweir XGradient aXGradient(((const XFillGradientItem&)rObj.GetMergedItem(XATTR_FILLGRADIENT)).GetGradientValue()); 1932cdf0e10cSrcweir if ( nColorCount ) 1933cdf0e10cSrcweir { 1934cdf0e10cSrcweir aXGradient.SetStartColor( 1935cdf0e10cSrcweir GetColorData( 1936cdf0e10cSrcweir aXGradient.GetStartColor(), 1937cdf0e10cSrcweir std::min(nColorIndex, nColorCount-1) )); 1938cdf0e10cSrcweir aXGradient.SetEndColor( 1939cdf0e10cSrcweir GetColorData( 1940cdf0e10cSrcweir aXGradient.GetEndColor(), 1941cdf0e10cSrcweir std::min(nColorIndex, nColorCount-1) )); 1942cdf0e10cSrcweir } 1943cdf0e10cSrcweir 1944cdf0e10cSrcweir rObj.SetMergedItem( XFillGradientItem( String(), aXGradient ) ); 1945cdf0e10cSrcweir break; 1946cdf0e10cSrcweir } 1947cdf0e10cSrcweir case XFILL_HATCH: 1948cdf0e10cSrcweir { 1949cdf0e10cSrcweir XHatch aXHatch(((const XFillHatchItem&)rObj.GetMergedItem(XATTR_FILLHATCH)).GetHatchValue()); 1950cdf0e10cSrcweir if ( nColorCount ) 1951cdf0e10cSrcweir { 1952cdf0e10cSrcweir aXHatch.SetColor( 1953cdf0e10cSrcweir GetColorData( 1954cdf0e10cSrcweir aXHatch.GetColor(), 1955cdf0e10cSrcweir std::min(nColorIndex, nColorCount-1) )); 1956cdf0e10cSrcweir } 1957cdf0e10cSrcweir 1958cdf0e10cSrcweir rObj.SetMergedItem( XFillHatchItem( String(), aXHatch ) ); 1959cdf0e10cSrcweir break; 1960cdf0e10cSrcweir } 1961cdf0e10cSrcweir case XFILL_BITMAP: 1962cdf0e10cSrcweir { 1963cdf0e10cSrcweir Bitmap aBitmap(((const XFillBitmapItem&)rObj.GetMergedItem(XATTR_FILLBITMAP)).GetBitmapValue().GetBitmap()); 1964cdf0e10cSrcweir if ( nColorCount ) 1965cdf0e10cSrcweir { 1966cdf0e10cSrcweir aBitmap.Adjust( 1967cdf0e10cSrcweir static_cast< short > ( GetLuminanceChange( 1968cdf0e10cSrcweir std::min(nColorIndex, nColorCount-1)))); 1969cdf0e10cSrcweir } 1970cdf0e10cSrcweir 1971cdf0e10cSrcweir rObj.SetMergedItem( XFillBitmapItem( String(), aBitmap ) ); 1972cdf0e10cSrcweir break; 1973cdf0e10cSrcweir } 1974cdf0e10cSrcweir } 1975cdf0e10cSrcweir 1976cdf0e10cSrcweir if ( nColorIndex < nColorCount ) 1977cdf0e10cSrcweir nColorIndex++; 1978cdf0e10cSrcweir } 1979cdf0e10cSrcweir } 1980cdf0e10cSrcweir 1981cdf0e10cSrcweir SdrObject* EnhancedCustomShape2d::CreatePathObj( sal_Bool bLineGeometryNeededOnly ) 1982cdf0e10cSrcweir { 1983cdf0e10cSrcweir sal_Int32 nCoordSize = seqCoordinates.getLength(); 1984cdf0e10cSrcweir if ( !nCoordSize ) 1985cdf0e10cSrcweir return NULL; 1986cdf0e10cSrcweir 1987cdf0e10cSrcweir sal_uInt16 nSrcPt = 0; 1988cdf0e10cSrcweir sal_uInt16 nSegmentInd = 0; 1989cdf0e10cSrcweir 1990cdf0e10cSrcweir std::vector< SdrPathObj* > vObjectList; 1991cdf0e10cSrcweir sal_Bool bSortFilledObjectsToBack = SortFilledObjectsToBackByDefault( eSpType ); 1992cdf0e10cSrcweir 1993cdf0e10cSrcweir while( nSegmentInd <= seqSegments.getLength() ) 1994cdf0e10cSrcweir { 1995cdf0e10cSrcweir CreateSubPath( nSrcPt, nSegmentInd, vObjectList, bLineGeometryNeededOnly, bSortFilledObjectsToBack ); 1996cdf0e10cSrcweir } 1997cdf0e10cSrcweir 1998cdf0e10cSrcweir SdrObject* pRet = NULL; 1999cdf0e10cSrcweir sal_uInt32 i; 2000cdf0e10cSrcweir 2001cdf0e10cSrcweir if ( !vObjectList.empty() ) 2002cdf0e10cSrcweir { 2003cdf0e10cSrcweir const SfxItemSet& rCustomShapeSet = pCustomShapeObj->GetMergedItemSet(); 2004cdf0e10cSrcweir Color aFillColor; 2005cdf0e10cSrcweir sal_uInt32 nColorCount = nColorData >> 28; 2006cdf0e10cSrcweir sal_uInt32 nColorIndex = 0; 2007cdf0e10cSrcweir 2008cdf0e10cSrcweir // #i37011# remove invisible objects 2009cdf0e10cSrcweir if(!vObjectList.empty()) 2010cdf0e10cSrcweir { 2011cdf0e10cSrcweir std::vector< SdrPathObj* > vTempList; 2012cdf0e10cSrcweir 2013cdf0e10cSrcweir for(i = 0L; i < vObjectList.size(); i++) 2014cdf0e10cSrcweir { 2015cdf0e10cSrcweir SdrPathObj* pObj(vObjectList[i]); 2016cdf0e10cSrcweir const XLineStyle eLineStyle = ((const XLineStyleItem&)pObj->GetMergedItem(XATTR_LINESTYLE)).GetValue(); 2017cdf0e10cSrcweir const XFillStyle eFillStyle = ((const XFillStyleItem&)pObj->GetMergedItem(XATTR_FILLSTYLE)).GetValue(); 2018cdf0e10cSrcweir 2019cdf0e10cSrcweir //SJ: #i40600# if bLineGeometryNeededOnly is set linystyle does not matter 2020cdf0e10cSrcweir if( !bLineGeometryNeededOnly && ( XLINE_NONE == eLineStyle ) && ( XFILL_NONE == eFillStyle ) ) 2021cdf0e10cSrcweir delete pObj; 2022cdf0e10cSrcweir else 2023cdf0e10cSrcweir vTempList.push_back(pObj); 2024cdf0e10cSrcweir } 2025cdf0e10cSrcweir 2026cdf0e10cSrcweir vObjectList = vTempList; 2027cdf0e10cSrcweir } 2028cdf0e10cSrcweir 2029cdf0e10cSrcweir if(1L == vObjectList.size()) 2030cdf0e10cSrcweir { 2031cdf0e10cSrcweir // a single object, correct some values 2032cdf0e10cSrcweir AdaptObjColor(*vObjectList[0L],rCustomShapeSet,nColorIndex,nColorCount); 2033cdf0e10cSrcweir } 2034cdf0e10cSrcweir else 2035cdf0e10cSrcweir { 2036cdf0e10cSrcweir sal_Int32 nLineObjectCount = 0; 2037cdf0e10cSrcweir sal_Int32 nAreaObjectCount = 0; 2038cdf0e10cSrcweir 2039cdf0e10cSrcweir // correct some values and collect content data 2040cdf0e10cSrcweir for ( i = 0; i < vObjectList.size(); i++ ) 2041cdf0e10cSrcweir { 2042cdf0e10cSrcweir SdrPathObj* pObj( vObjectList[ i ] ); 2043cdf0e10cSrcweir 2044cdf0e10cSrcweir if(pObj->IsLine()) 2045cdf0e10cSrcweir { 2046cdf0e10cSrcweir nLineObjectCount++; 2047cdf0e10cSrcweir } 2048cdf0e10cSrcweir else 2049cdf0e10cSrcweir { 2050cdf0e10cSrcweir nAreaObjectCount++; 2051cdf0e10cSrcweir AdaptObjColor(*pObj,rCustomShapeSet,nColorIndex,nColorCount); 2052cdf0e10cSrcweir } 2053cdf0e10cSrcweir } 2054cdf0e10cSrcweir 2055cdf0e10cSrcweir // #i88870# correct line arrows for callouts 2056cdf0e10cSrcweir if ( nLineObjectCount ) 2057cdf0e10cSrcweir CorrectCalloutArrows( eSpType, nLineObjectCount, vObjectList ); 2058cdf0e10cSrcweir 2059cdf0e10cSrcweir // sort objects so that filled ones are in front. Necessary 2060cdf0e10cSrcweir // for some strange objects 2061cdf0e10cSrcweir if ( bSortFilledObjectsToBack ) 2062cdf0e10cSrcweir { 2063cdf0e10cSrcweir std::vector< SdrPathObj* > vTempList; 2064cdf0e10cSrcweir 2065cdf0e10cSrcweir for ( i = 0; i < vObjectList.size(); i++ ) 2066cdf0e10cSrcweir { 2067cdf0e10cSrcweir SdrPathObj* pObj( vObjectList[ i ] ); 2068cdf0e10cSrcweir 2069cdf0e10cSrcweir if ( !pObj->IsLine() ) 2070cdf0e10cSrcweir { 2071cdf0e10cSrcweir vTempList.push_back(pObj); 2072cdf0e10cSrcweir } 2073cdf0e10cSrcweir } 2074cdf0e10cSrcweir 2075cdf0e10cSrcweir for ( i = 0; i < vObjectList.size(); i++ ) 2076cdf0e10cSrcweir { 2077cdf0e10cSrcweir SdrPathObj* pObj( vObjectList[ i ] ); 2078cdf0e10cSrcweir 2079cdf0e10cSrcweir if ( pObj->IsLine() ) 2080cdf0e10cSrcweir { 2081cdf0e10cSrcweir vTempList.push_back(pObj); 2082cdf0e10cSrcweir } 2083cdf0e10cSrcweir } 2084cdf0e10cSrcweir 2085cdf0e10cSrcweir vObjectList = vTempList; 2086cdf0e10cSrcweir } 2087cdf0e10cSrcweir } 2088cdf0e10cSrcweir } 2089cdf0e10cSrcweir 2090cdf0e10cSrcweir // #i37011# 2091cdf0e10cSrcweir if(!vObjectList.empty()) 2092cdf0e10cSrcweir { 2093cdf0e10cSrcweir // copy remaining objects to pRet 2094cdf0e10cSrcweir if(vObjectList.size() > 1L) 2095cdf0e10cSrcweir { 2096cdf0e10cSrcweir pRet = new SdrObjGroup; 2097cdf0e10cSrcweir 2098cdf0e10cSrcweir for (i = 0L; i < vObjectList.size(); i++) 2099cdf0e10cSrcweir { 2100cdf0e10cSrcweir SdrObject* pObj(vObjectList[i]); 2101cdf0e10cSrcweir pRet->GetSubList()->NbcInsertObject(pObj); 2102cdf0e10cSrcweir } 2103cdf0e10cSrcweir } 2104cdf0e10cSrcweir else if(1L == vObjectList.size()) 2105cdf0e10cSrcweir { 2106cdf0e10cSrcweir pRet = vObjectList[0L]; 2107cdf0e10cSrcweir } 2108cdf0e10cSrcweir 2109cdf0e10cSrcweir if(pRet) 2110cdf0e10cSrcweir { 2111cdf0e10cSrcweir // move to target position 2112cdf0e10cSrcweir Rectangle aCurRect(pRet->GetSnapRect()); 2113cdf0e10cSrcweir aCurRect.Move(aLogicRect.Left(), aLogicRect.Top()); 2114cdf0e10cSrcweir pRet->NbcSetSnapRect(aCurRect); 2115cdf0e10cSrcweir } 2116cdf0e10cSrcweir } 2117cdf0e10cSrcweir 2118cdf0e10cSrcweir return pRet; 2119cdf0e10cSrcweir } 2120cdf0e10cSrcweir 2121cdf0e10cSrcweir SdrObject* EnhancedCustomShape2d::CreateObject( sal_Bool bLineGeometryNeededOnly ) 2122cdf0e10cSrcweir { 2123cdf0e10cSrcweir SdrObject* pRet = NULL; 2124cdf0e10cSrcweir 2125cdf0e10cSrcweir if ( eSpType == mso_sptRectangle ) 2126cdf0e10cSrcweir { 2127cdf0e10cSrcweir pRet = new SdrRectObj( aLogicRect ); 2128cdf0e10cSrcweir // SJ: not setting model, so we save a lot of broadcasting and the model is not modified any longer 2129cdf0e10cSrcweir // pRet->SetModel( pCustomShapeObj->GetModel() ); 2130cdf0e10cSrcweir pRet->SetMergedItemSet( *this ); 2131cdf0e10cSrcweir } 2132cdf0e10cSrcweir if ( !pRet ) 2133cdf0e10cSrcweir pRet = CreatePathObj( bLineGeometryNeededOnly ); 2134cdf0e10cSrcweir 2135cdf0e10cSrcweir return pRet; 2136cdf0e10cSrcweir } 2137cdf0e10cSrcweir 2138cdf0e10cSrcweir void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj ) 2139cdf0e10cSrcweir { 2140cdf0e10cSrcweir if ( pObj && seqGluePoints.getLength() ) 2141cdf0e10cSrcweir { 2142cdf0e10cSrcweir sal_uInt32 i, nCount = seqGluePoints.getLength(); 2143cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 2144cdf0e10cSrcweir { 2145cdf0e10cSrcweir SdrGluePoint aGluePoint; 2146cdf0e10cSrcweir 2147cdf0e10cSrcweir aGluePoint.SetPos( GetPoint( seqGluePoints[ i ], sal_True, sal_True ) ); 2148cdf0e10cSrcweir aGluePoint.SetPercent( sal_False ); 2149cdf0e10cSrcweir 2150cdf0e10cSrcweir // const Point& rPoint = GetPoint( seqGluePoints[ i ], sal_True, sal_True ); 2151cdf0e10cSrcweir // double fXRel = rPoint.X(); 2152cdf0e10cSrcweir // double fYRel = rPoint.Y(); 2153cdf0e10cSrcweir // fXRel = aLogicRect.GetWidth() == 0 ? 0.0 : fXRel / aLogicRect.GetWidth() * 10000; 2154cdf0e10cSrcweir // fYRel = aLogicRect.GetHeight() == 0 ? 0.0 : fYRel / aLogicRect.GetHeight() * 10000; 2155cdf0e10cSrcweir // aGluePoint.SetPos( Point( (sal_Int32)fXRel, (sal_Int32)fYRel ) ); 2156cdf0e10cSrcweir // aGluePoint.SetPercent( sal_True ); 2157cdf0e10cSrcweir aGluePoint.SetAlign( SDRVERTALIGN_TOP | SDRHORZALIGN_LEFT ); 2158cdf0e10cSrcweir aGluePoint.SetEscDir( SDRESC_SMART ); 2159cdf0e10cSrcweir SdrGluePointList* pList = pObj->ForceGluePointList(); 2160cdf0e10cSrcweir if( pList ) 2161cdf0e10cSrcweir /* sal_uInt16 nId = */ pList->Insert( aGluePoint ); 2162cdf0e10cSrcweir } 2163cdf0e10cSrcweir } 2164cdf0e10cSrcweir } 2165cdf0e10cSrcweir 2166cdf0e10cSrcweir SdrObject* EnhancedCustomShape2d::CreateLineGeometry() 2167cdf0e10cSrcweir { 2168cdf0e10cSrcweir return CreateObject( sal_True ); 2169cdf0e10cSrcweir } 2170cdf0e10cSrcweir 2171cdf0e10cSrcweir 2172