sdrfillgraphicattribute.cxx (64b14621) | sdrfillgraphicattribute.cxx (e7d68668) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 28 unchanged lines hidden (view full) --- 37 class ImpSdrFillGraphicAttribute 38 { 39 public: 40 // refcounter 41 sal_uInt32 mnRefCount; 42 43 // data definitions 44 Graphic maFillGraphic; | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 28 unchanged lines hidden (view full) --- 37 class ImpSdrFillGraphicAttribute 38 { 39 public: 40 // refcounter 41 sal_uInt32 mnRefCount; 42 43 // data definitions 44 Graphic maFillGraphic; |
45 basegfx::B2DVector maGraphicLogicSize; |
|
45 basegfx::B2DVector maSize; 46 basegfx::B2DVector maOffset; 47 basegfx::B2DVector maOffsetPosition; 48 basegfx::B2DVector maRectPoint; 49 50 // bitfield 51 unsigned mbTiling : 1; 52 unsigned mbStretch : 1; 53 unsigned mbLogSize : 1; 54 55 ImpSdrFillGraphicAttribute( 56 const Graphic& rFillGraphic, | 46 basegfx::B2DVector maSize; 47 basegfx::B2DVector maOffset; 48 basegfx::B2DVector maOffsetPosition; 49 basegfx::B2DVector maRectPoint; 50 51 // bitfield 52 unsigned mbTiling : 1; 53 unsigned mbStretch : 1; 54 unsigned mbLogSize : 1; 55 56 ImpSdrFillGraphicAttribute( 57 const Graphic& rFillGraphic, |
58 const basegfx::B2DVector& rGraphicLogicSize, |
|
57 const basegfx::B2DVector& rSize, 58 const basegfx::B2DVector& rOffset, 59 const basegfx::B2DVector& rOffsetPosition, 60 const basegfx::B2DVector& rRectPoint, 61 bool bTiling, 62 bool bStretch, 63 bool bLogSize) 64 : mnRefCount(0), 65 maFillGraphic(rFillGraphic), | 59 const basegfx::B2DVector& rSize, 60 const basegfx::B2DVector& rOffset, 61 const basegfx::B2DVector& rOffsetPosition, 62 const basegfx::B2DVector& rRectPoint, 63 bool bTiling, 64 bool bStretch, 65 bool bLogSize) 66 : mnRefCount(0), 67 maFillGraphic(rFillGraphic), |
68 maGraphicLogicSize(rGraphicLogicSize), |
|
66 maSize(rSize), 67 maOffset(rOffset), 68 maOffsetPosition(rOffsetPosition), 69 maRectPoint(rRectPoint), 70 mbTiling(bTiling), 71 mbStretch(bStretch), 72 mbLogSize(bLogSize) 73 { 74 } 75 76 // data read access 77 const Graphic& getFillGraphic() const { return maFillGraphic; } | 69 maSize(rSize), 70 maOffset(rOffset), 71 maOffsetPosition(rOffsetPosition), 72 maRectPoint(rRectPoint), 73 mbTiling(bTiling), 74 mbStretch(bStretch), 75 mbLogSize(bLogSize) 76 { 77 } 78 79 // data read access 80 const Graphic& getFillGraphic() const { return maFillGraphic; } |
81 const basegfx::B2DVector& getGraphicLogicSize() const { return maGraphicLogicSize; } |
|
78 const basegfx::B2DVector& getSize() const { return maSize; } 79 const basegfx::B2DVector& getOffset() const { return maOffset; } 80 const basegfx::B2DVector& getOffsetPosition() const { return maOffsetPosition; } 81 const basegfx::B2DVector& getRectPoint() const { return maRectPoint; } 82 bool getTiling() const { return mbTiling; } 83 bool getStretch() const { return mbStretch; } 84 bool getLogSize() const { return mbLogSize; } 85 86 bool operator==(const ImpSdrFillGraphicAttribute& rCandidate) const 87 { 88 return (getFillGraphic() == rCandidate.getFillGraphic() | 82 const basegfx::B2DVector& getSize() const { return maSize; } 83 const basegfx::B2DVector& getOffset() const { return maOffset; } 84 const basegfx::B2DVector& getOffsetPosition() const { return maOffsetPosition; } 85 const basegfx::B2DVector& getRectPoint() const { return maRectPoint; } 86 bool getTiling() const { return mbTiling; } 87 bool getStretch() const { return mbStretch; } 88 bool getLogSize() const { return mbLogSize; } 89 90 bool operator==(const ImpSdrFillGraphicAttribute& rCandidate) const 91 { 92 return (getFillGraphic() == rCandidate.getFillGraphic() |
93 && getGraphicLogicSize() == rCandidate.getGraphicLogicSize() |
|
89 && getSize() == rCandidate.getSize() 90 && getOffset() == rCandidate.getOffset() 91 && getOffsetPosition() == rCandidate.getOffsetPosition() 92 && getRectPoint() == rCandidate.getRectPoint() 93 && getTiling() == rCandidate.getTiling() 94 && getStretch() == rCandidate.getStretch() 95 && getLogSize() == rCandidate.getLogSize()); 96 } 97 98 static ImpSdrFillGraphicAttribute* get_global_default() 99 { 100 static ImpSdrFillGraphicAttribute* pDefault = 0; 101 102 if(!pDefault) 103 { 104 pDefault = new ImpSdrFillGraphicAttribute( 105 Graphic(), 106 basegfx::B2DVector(), 107 basegfx::B2DVector(), | 94 && getSize() == rCandidate.getSize() 95 && getOffset() == rCandidate.getOffset() 96 && getOffsetPosition() == rCandidate.getOffsetPosition() 97 && getRectPoint() == rCandidate.getRectPoint() 98 && getTiling() == rCandidate.getTiling() 99 && getStretch() == rCandidate.getStretch() 100 && getLogSize() == rCandidate.getLogSize()); 101 } 102 103 static ImpSdrFillGraphicAttribute* get_global_default() 104 { 105 static ImpSdrFillGraphicAttribute* pDefault = 0; 106 107 if(!pDefault) 108 { 109 pDefault = new ImpSdrFillGraphicAttribute( 110 Graphic(), 111 basegfx::B2DVector(), 112 basegfx::B2DVector(), |
113 basegfx::B2DVector(), |
|
108 basegfx::B2DVector(), 109 basegfx::B2DVector(), 110 false, 111 false, 112 false); 113 114 // never delete; start with RefCount 1, not 0 115 pDefault->mnRefCount++; 116 } 117 118 return pDefault; 119 } 120 }; 121 122 SdrFillGraphicAttribute::SdrFillGraphicAttribute( 123 const Graphic& rFillGraphic, | 114 basegfx::B2DVector(), 115 basegfx::B2DVector(), 116 false, 117 false, 118 false); 119 120 // never delete; start with RefCount 1, not 0 121 pDefault->mnRefCount++; 122 } 123 124 return pDefault; 125 } 126 }; 127 128 SdrFillGraphicAttribute::SdrFillGraphicAttribute( 129 const Graphic& rFillGraphic, |
130 const basegfx::B2DVector& rGraphicLogicSize, |
|
124 const basegfx::B2DVector& rSize, 125 const basegfx::B2DVector& rOffset, 126 const basegfx::B2DVector& rOffsetPosition, 127 const basegfx::B2DVector& rRectPoint, 128 bool bTiling, 129 bool bStretch, 130 bool bLogSize) 131 : mpSdrFillGraphicAttribute( 132 new ImpSdrFillGraphicAttribute( 133 rFillGraphic, | 131 const basegfx::B2DVector& rSize, 132 const basegfx::B2DVector& rOffset, 133 const basegfx::B2DVector& rOffsetPosition, 134 const basegfx::B2DVector& rRectPoint, 135 bool bTiling, 136 bool bStretch, 137 bool bLogSize) 138 : mpSdrFillGraphicAttribute( 139 new ImpSdrFillGraphicAttribute( 140 rFillGraphic, |
141 rGraphicLogicSize, |
|
134 rSize, 135 rOffset, 136 rOffsetPosition, 137 rRectPoint, 138 bTiling, 139 bStretch, 140 bLogSize)) 141 { --- 63 unchanged lines hidden (view full) --- 205 return (*rCandidate.mpSdrFillGraphicAttribute == *mpSdrFillGraphicAttribute); 206 } 207 208 const Graphic& SdrFillGraphicAttribute::getFillGraphic() const 209 { 210 return mpSdrFillGraphicAttribute->getFillGraphic(); 211 } 212 | 142 rSize, 143 rOffset, 144 rOffsetPosition, 145 rRectPoint, 146 bTiling, 147 bStretch, 148 bLogSize)) 149 { --- 63 unchanged lines hidden (view full) --- 213 return (*rCandidate.mpSdrFillGraphicAttribute == *mpSdrFillGraphicAttribute); 214 } 215 216 const Graphic& SdrFillGraphicAttribute::getFillGraphic() const 217 { 218 return mpSdrFillGraphicAttribute->getFillGraphic(); 219 } 220 |
221 const basegfx::B2DVector& SdrFillGraphicAttribute::getGraphicLogicSize() const 222 { 223 return mpSdrFillGraphicAttribute->getGraphicLogicSize(); 224 } 225 |
|
213 const basegfx::B2DVector& SdrFillGraphicAttribute::getSize() const 214 { 215 return mpSdrFillGraphicAttribute->getSize(); 216 } 217 218 const basegfx::B2DVector& SdrFillGraphicAttribute::getOffset() const 219 { 220 return mpSdrFillGraphicAttribute->getOffset(); --- 23 unchanged lines hidden (view full) --- 244 { 245 return mpSdrFillGraphicAttribute->getLogSize(); 246 } 247 248 FillGraphicAttribute SdrFillGraphicAttribute::createFillGraphicAttribute(const basegfx::B2DRange& rRange) const 249 { 250 // get logical size of bitmap (before expanding eventually) 251 Graphic aGraphic(getFillGraphic()); | 226 const basegfx::B2DVector& SdrFillGraphicAttribute::getSize() const 227 { 228 return mpSdrFillGraphicAttribute->getSize(); 229 } 230 231 const basegfx::B2DVector& SdrFillGraphicAttribute::getOffset() const 232 { 233 return mpSdrFillGraphicAttribute->getOffset(); --- 23 unchanged lines hidden (view full) --- 257 { 258 return mpSdrFillGraphicAttribute->getLogSize(); 259 } 260 261 FillGraphicAttribute SdrFillGraphicAttribute::createFillGraphicAttribute(const basegfx::B2DRange& rRange) const 262 { 263 // get logical size of bitmap (before expanding eventually) 264 Graphic aGraphic(getFillGraphic()); |
252 const basegfx::B2DVector aLogicalSize(aGraphic.GetPrefSize().getWidth(), aGraphic.GetPrefSize().getHeight()); | |
253 | 265 |
254 // init values with defaults for stretched | 266 // init values with defaults |
255 basegfx::B2DPoint aBitmapSize(1.0, 1.0); 256 basegfx::B2DVector aBitmapTopLeft(0.0, 0.0); 257 | 267 basegfx::B2DPoint aBitmapSize(1.0, 1.0); 268 basegfx::B2DVector aBitmapTopLeft(0.0, 0.0); 269 |
258 //UUUU are changes needed? When streched we are already done, all other values will have no influence | 270 // are changes needed? |
259 if(getTiling() || !getStretch()) 260 { 261 // init values with range sizes 262 const double fRangeWidth(0.0 != rRange.getWidth() ? rRange.getWidth() : 1.0); 263 const double fRangeHeight(0.0 != rRange.getHeight() ? rRange.getHeight() : 1.0); 264 aBitmapSize = basegfx::B2DPoint(fRangeWidth, fRangeHeight); 265 266 // size changes --- 5 unchanged lines hidden (view full) --- 272 } 273 else 274 { 275 aBitmapSize.setX(getSize().getX()); 276 } 277 } 278 else 279 { | 271 if(getTiling() || !getStretch()) 272 { 273 // init values with range sizes 274 const double fRangeWidth(0.0 != rRange.getWidth() ? rRange.getWidth() : 1.0); 275 const double fRangeHeight(0.0 != rRange.getHeight() ? rRange.getHeight() : 1.0); 276 aBitmapSize = basegfx::B2DPoint(fRangeWidth, fRangeHeight); 277 278 // size changes --- 5 unchanged lines hidden (view full) --- 284 } 285 else 286 { 287 aBitmapSize.setX(getSize().getX()); 288 } 289 } 290 else 291 { |
280 aBitmapSize.setX(aLogicalSize.getX()); | 292 // #124002# use GraphicLogicSize directly, do not try to use GetPrefSize 293 // of the graphic, that may not be adapted to the MapMode of the target 294 aBitmapSize.setX(getGraphicLogicSize().getX()); |
281 } 282 283 if(0.0 != getSize().getY()) 284 { 285 if(getSize().getY() < 0.0) 286 { 287 aBitmapSize.setY(aBitmapSize.getY() * (getSize().getY() * -0.01)); 288 } 289 else 290 { 291 aBitmapSize.setY(getSize().getY()); 292 } 293 } 294 else 295 { | 295 } 296 297 if(0.0 != getSize().getY()) 298 { 299 if(getSize().getY() < 0.0) 300 { 301 aBitmapSize.setY(aBitmapSize.getY() * (getSize().getY() * -0.01)); 302 } 303 else 304 { 305 aBitmapSize.setY(getSize().getY()); 306 } 307 } 308 else 309 { |
296 aBitmapSize.setY(aLogicalSize.getY()); | 310 // #124002# use GraphicLogicSize directly, do not try to use GetPrefSize 311 // of the graphic, that may not be adapted to the MapMode of the target 312 aBitmapSize.setY(getGraphicLogicSize().getY()); |
297 } 298 | 313 } 314 |
315 // get values, force to centered if necessary 316 const basegfx::B2DVector aRectPoint(getTiling() ? getRectPoint() : basegfx::B2DVector(0.0, 0.0)); 317 |
|
299 // position changes X | 318 // position changes X |
300 if(0.0 == getRectPoint().getX()) | 319 if(0.0 == aRectPoint.getX()) |
301 { 302 aBitmapTopLeft.setX((fRangeWidth - aBitmapSize.getX()) * 0.5); 303 } | 320 { 321 aBitmapTopLeft.setX((fRangeWidth - aBitmapSize.getX()) * 0.5); 322 } |
304 else if(1.0 == getRectPoint().getX()) | 323 else if(1.0 == aRectPoint.getX()) |
305 { 306 aBitmapTopLeft.setX(fRangeWidth - aBitmapSize.getX()); 307 } 308 | 324 { 325 aBitmapTopLeft.setX(fRangeWidth - aBitmapSize.getX()); 326 } 327 |
309 // offset positions are only meaningful when tiled | |
310 if(getTiling() && 0.0 != getOffsetPosition().getX()) 311 { 312 aBitmapTopLeft.setX(aBitmapTopLeft.getX() + (aBitmapSize.getX() * (getOffsetPosition().getX() * 0.01))); 313 } 314 315 // position changes Y | 328 if(getTiling() && 0.0 != getOffsetPosition().getX()) 329 { 330 aBitmapTopLeft.setX(aBitmapTopLeft.getX() + (aBitmapSize.getX() * (getOffsetPosition().getX() * 0.01))); 331 } 332 333 // position changes Y |
316 if(0.0 == getRectPoint().getY()) | 334 if(0.0 == aRectPoint.getY()) |
317 { 318 aBitmapTopLeft.setY((fRangeHeight - aBitmapSize.getY()) * 0.5); 319 } | 335 { 336 aBitmapTopLeft.setY((fRangeHeight - aBitmapSize.getY()) * 0.5); 337 } |
320 else if(1.0 == getRectPoint().getY()) | 338 else if(1.0 == aRectPoint.getY()) |
321 { 322 aBitmapTopLeft.setY(fRangeHeight - aBitmapSize.getY()); 323 } 324 | 339 { 340 aBitmapTopLeft.setY(fRangeHeight - aBitmapSize.getY()); 341 } 342 |
325 // offset positions are only meaningful when tiled | |
326 if(getTiling() && 0.0 != getOffsetPosition().getY()) 327 { 328 aBitmapTopLeft.setY(aBitmapTopLeft.getY() + (aBitmapSize.getY() * (getOffsetPosition().getY() * 0.01))); 329 } 330 331 // apply bitmap size scaling to unit rectangle 332 aBitmapTopLeft.setX(aBitmapTopLeft.getX() / fRangeWidth); 333 aBitmapTopLeft.setY(aBitmapTopLeft.getY() / fRangeHeight); --- 21 unchanged lines hidden --- | 343 if(getTiling() && 0.0 != getOffsetPosition().getY()) 344 { 345 aBitmapTopLeft.setY(aBitmapTopLeft.getY() + (aBitmapSize.getY() * (getOffsetPosition().getY() * 0.01))); 346 } 347 348 // apply bitmap size scaling to unit rectangle 349 aBitmapTopLeft.setX(aBitmapTopLeft.getX() / fRangeWidth); 350 aBitmapTopLeft.setY(aBitmapTopLeft.getY() / fRangeHeight); --- 21 unchanged lines hidden --- |