Lines 2051-2056
Link Here
|
2051 |
return bRetValue; |
2051 |
return bRetValue; |
2052 |
} |
2052 |
} |
2053 |
|
2053 |
|
|
|
2054 |
|
2055 |
/* |
2056 |
in MS,the connector including 9 types : |
2057 |
"straightConnector1", |
2058 |
"bentConnector2","bentConnector3","bentConnector4","bentConnector5" |
2059 |
"curvedConnector2","curvedConnector3","curvedConnector4","curvedConnector5" |
2060 |
in AOO,including 4 types:"standard","lines","line","curve" |
2061 |
when save as MS file, the connector must be convert to corresponding type. |
2062 |
"line" and "lines" <-> "straightConnector1" |
2063 |
"standard" <-> "bentConnector2-5" |
2064 |
"curve" <-> "curvedConnector2-5" |
2065 |
*/ |
2066 |
sal_Int32 lcl_GetAdjustValueCount( const XPolygon& rPoly ) |
2067 |
{ |
2068 |
int nRet = 0; |
2069 |
switch ( rPoly.GetSize() ) |
2070 |
{ |
2071 |
case 2 : |
2072 |
case 3: |
2073 |
nRet = 0; |
2074 |
break; |
2075 |
case 4: |
2076 |
nRet = 1; |
2077 |
break; |
2078 |
case 5: |
2079 |
nRet = 2; |
2080 |
break; |
2081 |
default: |
2082 |
if ( rPoly.GetSize()>=6 ) |
2083 |
nRet = 3; |
2084 |
break; |
2085 |
} |
2086 |
return nRet; |
2087 |
} |
2088 |
/* |
2089 |
Adjust value decide the position which connector should turn a corner |
2090 |
*/ |
2091 |
sal_Int32 lcl_GetConnectorAdjustValue ( const XPolygon& rPoly, sal_uInt16 nIndex ) |
2092 |
{ |
2093 |
sal_uInt16 k = rPoly.GetSize(); |
2094 |
OSL_ASSERT ( k >= ( 3 + nIndex ) ); |
2095 |
|
2096 |
Point aPt; |
2097 |
Point aStart = rPoly[0]; |
2098 |
Point aEnd = rPoly[k-1]; |
2099 |
if ( aEnd.Y() == aStart.Y() ) |
2100 |
aEnd.Y() = aStart.Y() +4; |
2101 |
if ( aEnd.X() == aStart.X() ) |
2102 |
aEnd.X() = aStart.X() +4; |
2103 |
|
2104 |
sal_Bool bVertical = ( rPoly[1].X()-aStart.X() ) == 0 ; |
2105 |
//vertical and horizon alternate |
2106 |
if ( nIndex%2 == 1 ) bVertical = !bVertical; |
2107 |
aPt = rPoly[ nIndex + 1]; |
2108 |
|
2109 |
sal_Int32 nAdjustValue; |
2110 |
if ( bVertical ) |
2111 |
nAdjustValue = ( aPt.Y()-aStart.Y())* 21600 /(aEnd.Y()-aStart.Y()); |
2112 |
else |
2113 |
nAdjustValue = ( aPt.X()-aStart.X() )* 21600 /(aEnd.X()-aStart.X()); |
2114 |
|
2115 |
return nAdjustValue; |
2116 |
} |
2117 |
|
2118 |
|
2119 |
void lcl_Rotate(sal_Int32 nAngle, Point center, Point& pt) |
2120 |
{ |
2121 |
while ( nAngle<0) |
2122 |
nAngle +=36000; |
2123 |
while (nAngle>=36000) |
2124 |
nAngle -=36000; |
2125 |
|
2126 |
int cs, sn; |
2127 |
switch (nAngle) |
2128 |
{ |
2129 |
case 0: |
2130 |
cs =1; |
2131 |
sn =0; |
2132 |
break; |
2133 |
case 9000: |
2134 |
cs =0; |
2135 |
sn =1; |
2136 |
break; |
2137 |
case 18000: |
2138 |
cs = -1; |
2139 |
sn = 0; |
2140 |
break; |
2141 |
case 27000: |
2142 |
cs = 0; |
2143 |
sn = -1; |
2144 |
break; |
2145 |
default: |
2146 |
return; |
2147 |
break; |
2148 |
} |
2149 |
sal_Int32 x0 =pt.X()-center.X(); |
2150 |
sal_Int32 y0 =pt.Y()-center.Y(); |
2151 |
pt.X()=center.X()+ x0*cs-y0*sn; |
2152 |
pt.Y()=center.Y()+ y0*cs+x0*sn; |
2153 |
} |
2154 |
/* |
2155 |
FlipV defines that the shape will be flipped vertically about the center of its bounding box. |
2156 |
Generally, draw the connector from top to bottom, from left to right when meet the adjust value, |
2157 |
but when (X1>X2 or Y1>Y2),the draw director must be reverse, FlipV or FlipH should be set to true. |
2158 |
*/ |
2159 |
sal_Bool lcl_GetAngle(Polygon &rPoly,sal_uInt16& rShapeFlags,sal_Int32& nAngle ) |
2160 |
{ |
2161 |
Point aStart = rPoly[0]; |
2162 |
Point aEnd = rPoly[rPoly.GetSize()-1]; |
2163 |
nAngle = ( rPoly[1].X() == aStart.X() ) ? 9000: 0 ; |
2164 |
Point p1(aStart.X(),aStart.Y()); |
2165 |
Point p2(aEnd.X(),aEnd.Y()); |
2166 |
if ( nAngle ) |
2167 |
{ |
2168 |
Point center((aEnd.X()+aStart.X())>>1,(aEnd.Y()+aStart.Y())>>1); |
2169 |
lcl_Rotate(-nAngle, center,p1); |
2170 |
lcl_Rotate(-nAngle, center,p2); |
2171 |
} |
2172 |
if ( p1.X() > p2.X() ) |
2173 |
{ |
2174 |
if ( nAngle ) |
2175 |
rShapeFlags |= SHAPEFLAG_FLIPV; |
2176 |
else |
2177 |
rShapeFlags |= SHAPEFLAG_FLIPH; |
2178 |
|
2179 |
} |
2180 |
if ( p1.Y() > p2.Y() ) |
2181 |
{ |
2182 |
if ( nAngle ) |
2183 |
rShapeFlags |= SHAPEFLAG_FLIPH; |
2184 |
else |
2185 |
rShapeFlags |= SHAPEFLAG_FLIPV; |
2186 |
} |
2187 |
|
2188 |
if ( (rShapeFlags&SHAPEFLAG_FLIPH) && (rShapeFlags&SHAPEFLAG_FLIPV) ) |
2189 |
{ |
2190 |
rShapeFlags &= ~( SHAPEFLAG_FLIPH | SHAPEFLAG_FLIPV ); |
2191 |
nAngle +=18000; |
2192 |
} |
2193 |
|
2194 |
if ( nAngle ) |
2195 |
{ |
2196 |
// Set angle properties |
2197 |
nAngle *= 655; |
2198 |
nAngle += 0x8000; |
2199 |
nAngle &=~0xffff; // nAngle auf volle Gradzahl runden |
2200 |
return sal_True; |
2201 |
} |
2202 |
return sal_False; |
2203 |
} |
2054 |
sal_Bool EscherPropertyContainer::CreateConnectorProperties( |
2204 |
sal_Bool EscherPropertyContainer::CreateConnectorProperties( |
2055 |
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape, |
2205 |
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape, |
2056 |
EscherSolverContainer& rSolverContainer, ::com::sun::star::awt::Rectangle& rGeoRect, |
2206 |
EscherSolverContainer& rSolverContainer, ::com::sun::star::awt::Rectangle& rGeoRect, |
Lines 2061-2067
Link Here
|
2061 |
static String sEdgeEndPoint ( RTL_CONSTASCII_USTRINGPARAM( "EdgeEndPoint" ) ); |
2211 |
static String sEdgeEndPoint ( RTL_CONSTASCII_USTRINGPARAM( "EdgeEndPoint" ) ); |
2062 |
static String sEdgeStartConnection ( RTL_CONSTASCII_USTRINGPARAM( "EdgeStartConnection" ) ); |
2212 |
static String sEdgeStartConnection ( RTL_CONSTASCII_USTRINGPARAM( "EdgeStartConnection" ) ); |
2063 |
static String sEdgeEndConnection ( RTL_CONSTASCII_USTRINGPARAM( "EdgeEndConnection" ) ); |
2213 |
static String sEdgeEndConnection ( RTL_CONSTASCII_USTRINGPARAM( "EdgeEndConnection" ) ); |
2064 |
|
2214 |
static String sEdgePath ( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygonBezier") ); |
2065 |
sal_Bool bRetValue = sal_False; |
2215 |
sal_Bool bRetValue = sal_False; |
2066 |
rShapeType = rShapeFlags = 0; |
2216 |
rShapeType = rShapeFlags = 0; |
2067 |
|
2217 |
|
Lines 2087-2104
Link Here
|
2087 |
rShapeFlags = SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT | SHAPEFLAG_CONNECTOR; |
2237 |
rShapeFlags = SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT | SHAPEFLAG_CONNECTOR; |
2088 |
rGeoRect = ::com::sun::star::awt::Rectangle( aStartPoint.X, aStartPoint.Y, |
2238 |
rGeoRect = ::com::sun::star::awt::Rectangle( aStartPoint.X, aStartPoint.Y, |
2089 |
( aEndPoint.X - aStartPoint.X ) + 1, ( aEndPoint.Y - aStartPoint.Y ) + 1 ); |
2239 |
( aEndPoint.X - aStartPoint.X ) + 1, ( aEndPoint.Y - aStartPoint.Y ) + 1 ); |
2090 |
if ( rGeoRect.Height < 0 ) // justify |
2240 |
//set standard's FLIP in below code |
|
|
2241 |
if ( eCt != ::com::sun::star::drawing::ConnectorType_STANDARD) |
2091 |
{ |
2242 |
{ |
2092 |
rShapeFlags |= SHAPEFLAG_FLIPV; |
2243 |
if ( rGeoRect.Height < 0 ) // justify |
2093 |
rGeoRect.Y = aEndPoint.Y; |
2244 |
{ |
2094 |
rGeoRect.Height = -rGeoRect.Height; |
2245 |
rShapeFlags |= SHAPEFLAG_FLIPV; |
|
|
2246 |
rGeoRect.Y = aEndPoint.Y; |
2247 |
rGeoRect.Height = -rGeoRect.Height; |
2248 |
} |
2249 |
if ( rGeoRect.Width < 0 ) |
2250 |
{ |
2251 |
rShapeFlags |= SHAPEFLAG_FLIPH; |
2252 |
rGeoRect.X = aEndPoint.X; |
2253 |
rGeoRect.Width = -rGeoRect.Width; |
2254 |
} |
2095 |
} |
2255 |
} |
2096 |
if ( rGeoRect.Width < 0 ) |
|
|
2097 |
{ |
2098 |
rShapeFlags |= SHAPEFLAG_FLIPH; |
2099 |
rGeoRect.X = aEndPoint.X; |
2100 |
rGeoRect.Width = -rGeoRect.Width; |
2101 |
} |
2102 |
sal_uInt32 nAdjustValue1, nAdjustValue2, nAdjustValue3; |
2256 |
sal_uInt32 nAdjustValue1, nAdjustValue2, nAdjustValue3; |
2103 |
nAdjustValue1 = nAdjustValue2 = nAdjustValue3 = 0x2a30; |
2257 |
nAdjustValue1 = nAdjustValue2 = nAdjustValue3 = 0x2a30; |
2104 |
|
2258 |
|
Lines 2142-2153
Link Here
|
2142 |
break; |
2296 |
break; |
2143 |
|
2297 |
|
2144 |
case ::com::sun::star::drawing::ConnectorType_STANDARD :// Connector 2->5 |
2298 |
case ::com::sun::star::drawing::ConnectorType_STANDARD :// Connector 2->5 |
2145 |
{ |
2299 |
{ |
2146 |
rShapeType = ESCHER_ShpInst_BentConnector3; |
2300 |
if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, sEdgePath ) ) |
2147 |
AddOpt( ESCHER_Prop_cxstyle, ESCHER_cxstyleBent ); |
2301 |
{ |
2148 |
} |
2302 |
PolyPolygon aPolyPolygon = GetPolyPolygon( aAny ); |
2149 |
break; |
2303 |
Polygon aPoly; |
2150 |
|
2304 |
if ( aPolyPolygon.Count() > 0 ) |
|
|
2305 |
{ |
2306 |
AddOpt( ESCHER_Prop_cxstyle, ESCHER_cxstyleBent ); |
2307 |
aPoly = aPolyPolygon[ 0 ]; |
2308 |
sal_Int32 nAdjCount = lcl_GetAdjustValueCount( aPoly ); |
2309 |
rShapeType = ( sal_uInt16 )( ESCHER_ShpInst_BentConnector2 + nAdjCount); |
2310 |
for ( sal_Int32 i = 0 ; i < nAdjCount; ++ i) |
2311 |
AddOpt( (sal_uInt16) ( ESCHER_Prop_adjustValue+i) , lcl_GetConnectorAdjustValue( aPoly, i ) ); |
2312 |
bRetValue = sal_True; |
2313 |
} |
2314 |
sal_Int32 nAngle=0; |
2315 |
if (lcl_GetAngle(aPoly,rShapeFlags,nAngle )) |
2316 |
{ |
2317 |
AddOpt( ESCHER_Prop_Rotation, nAngle ); |
2318 |
} |
2319 |
} |
2320 |
else |
2321 |
{ |
2322 |
rShapeType = ESCHER_ShpInst_BentConnector3; |
2323 |
AddOpt( ESCHER_Prop_cxstyle, ESCHER_cxstyleBent ); |
2324 |
} |
2325 |
} |
2326 |
break; |
2151 |
default: |
2327 |
default: |
2152 |
case ::com::sun::star::drawing::ConnectorType_LINE : |
2328 |
case ::com::sun::star::drawing::ConnectorType_LINE : |
2153 |
case ::com::sun::star::drawing::ConnectorType_LINES : // Connector 2->5 |
2329 |
case ::com::sun::star::drawing::ConnectorType_LINES : // Connector 2->5 |
Lines 2158-2164
Link Here
|
2158 |
break; |
2334 |
break; |
2159 |
} |
2335 |
} |
2160 |
CreateLineProperties( aXPropSet, sal_False ); |
2336 |
CreateLineProperties( aXPropSet, sal_False ); |
2161 |
bRetValue = bSuppressRotation = sal_True; |
2337 |
bRetValue = sal_True; |
|
|
2338 |
bSuppressRotation = sal_False; |
2162 |
} |
2339 |
} |
2163 |
} |
2340 |
} |
2164 |
} |
2341 |
} |