svdhdl.cxx (1cd65da9) svdhdl.cxx (2376739d)
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

--- 49 unchanged lines hidden (view full) ---

58#include <svx/sdr/overlay/overlaytriangle.hxx>
59#include <svx/sdr/overlay/overlayrectangle.hxx>
60#include <svx/sdrpagewindow.hxx>
61#include <svx/sdrpaintwindow.hxx>
62#include <vcl/svapp.hxx>
63#include <svx/sdr/overlay/overlaypolypolygon.hxx>
64#include <vcl/lazydelete.hxx>
65
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

--- 49 unchanged lines hidden (view full) ---

58#include <svx/sdr/overlay/overlaytriangle.hxx>
59#include <svx/sdr/overlay/overlayrectangle.hxx>
60#include <svx/sdrpagewindow.hxx>
61#include <svx/sdrpaintwindow.hxx>
62#include <vcl/svapp.hxx>
63#include <svx/sdr/overlay/overlaypolypolygon.hxx>
64#include <vcl/lazydelete.hxx>
65
66#include <basegfx/polygon/b2dpolygontools.hxx>
67#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
68#include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
69#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
70#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
71#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
72
66////////////////////////////////////////////////////////////////////////////////////////////////////
67// #i15222#
68// Due to the ressource problems in Win95/98 with bitmap ressources i
69// will change this handle bitmap provinging class. Old version was splitting
70// and preparing all small handle bitmaps in device bitmap format, now this will
71// be done on the fly. Thus, tehre is only the one big bitmap remembered. With
72// three source bitmaps, this will be 3 system bitmap ressources instead of hundreds.
73// The price for that needs to be evaluated. Maybe we will need another change here

--- 2354 unchanged lines hidden (view full) ---

2428 maOverlayGroup.append(*pOverlayObject);
2429 }
2430 }
2431 }
2432 }
2433 }
2434}
2435
73////////////////////////////////////////////////////////////////////////////////////////////////////
74// #i15222#
75// Due to the ressource problems in Win95/98 with bitmap ressources i
76// will change this handle bitmap provinging class. Old version was splitting
77// and preparing all small handle bitmaps in device bitmap format, now this will
78// be done on the fly. Thus, tehre is only the one big bitmap remembered. With
79// three source bitmaps, this will be 3 system bitmap ressources instead of hundreds.
80// The price for that needs to be evaluated. Maybe we will need another change here

--- 2354 unchanged lines hidden (view full) ---

2435 maOverlayGroup.append(*pOverlayObject);
2436 }
2437 }
2438 }
2439 }
2440 }
2441}
2442
2436// --------------------------------------------------------------------
2443////////////////////////////////////////////////////////////////////////////////////////////////////
2444
2445SdrCropViewHdl::SdrCropViewHdl(
2446 const basegfx::B2DHomMatrix& rObjectTransform,
2447 const Graphic& rGraphic,
2448 double fCropLeft,
2449 double fCropTop,
2450 double fCropRight,
2451 double fCropBottom,
2452 bool bExtraMirrorXFromGraphic)
2453: SdrHdl(Point(), HDL_USER),
2454 maObjectTransform(rObjectTransform),
2455 maGraphic(rGraphic),
2456 mfCropLeft(fCropLeft),
2457 mfCropTop(fCropTop),
2458 mfCropRight(fCropRight),
2459 mfCropBottom(fCropBottom),
2460 mbExtraMirrorXFromGraphic(bExtraMirrorXFromGraphic)
2461{
2462}
2463
2464void SdrCropViewHdl::CreateB2dIAObject()
2465{
2466 GetRidOfIAObject();
2467 SdrMarkView* pView = pHdlList ? pHdlList->GetView() : 0;
2468 SdrPageView* pPageView = pView ? pView->GetSdrPageView() : 0;
2469
2470 if(pPageView && pView->areMarkHandlesHidden())
2471 {
2472 return;
2473 }
2474
2475 // decompose to have current translate and scale
2476 basegfx::B2DVector aScale, aTranslate;
2477 double fRotate, fShearX;
2478
2479 maObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX);
2480
2481 if(aScale.equalZero())
2482 {
2483 return;
2484 }
2485
2486 // detect 180 degree rotation, this is the same as mirrored in X and Y,
2487 // thus change to mirroring. Prefer mirroring here. Use the equal call
2488 // with getSmallValue here, the original which uses rtl::math::approxEqual
2489 // is too correct here. Maybe this changes with enhanced precision in aw080
2490 // to the better so that this can be reduced to the more precise call again
2491 if(basegfx::fTools::equal(fabs(fRotate), F_PI, 0.000000001))
2492 {
2493 aScale.setX(aScale.getX() * -1.0);
2494 aScale.setY(aScale.getY() * -1.0);
2495 fRotate = 0.0;
2496 }
2497
2498 // remember mirroring, reset at Scale and adapt crop values for usage;
2499 // mirroring can stay in the object transformation, so do not have to
2500 // cope with it here (except later for the CroppedImage transformation,
2501 // see below)
2502 const bool bMirroredX(aScale.getX() < 0.0);
2503 const bool bMirroredY(aScale.getY() < 0.0);
2504 double fCropLeft(mfCropLeft);
2505 double fCropTop(mfCropTop);
2506 double fCropRight(mfCropRight);
2507 double fCropBottom(mfCropBottom);
2508
2509 if(bMirroredX)
2510 {
2511 aScale.setX(-aScale.getX());
2512 fCropLeft = mfCropRight;
2513 fCropRight = mfCropLeft;
2514 }
2515
2516 if(bMirroredY)
2517 {
2518 aScale.setY(-aScale.getY());
2519 fCropTop = mfCropBottom;
2520 fCropBottom = mfCropTop;
2521 }
2522
2523 // create target translate and scale
2524 const basegfx::B2DVector aTargetScale(
2525 aScale.getX() + fCropRight + fCropLeft,
2526 aScale.getY() + fCropBottom + fCropTop);
2527 const basegfx::B2DVector aTargetTranslate(
2528 aTranslate.getX() - fCropLeft,
2529 aTranslate.getY() - fCropTop);
2530
2531 // create ranges to make comparisons
2532 const basegfx::B2DRange aCurrentForCompare(
2533 aTranslate.getX(), aTranslate.getY(),
2534 aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY());
2535 basegfx::B2DRange aCropped(
2536 aTargetTranslate.getX(), aTargetTranslate.getY(),
2537 aTargetTranslate.getX() + aTargetScale.getX(), aTargetTranslate.getY() + aTargetScale.getY());
2538
2539 if(aCropped.isEmpty())
2540 {
2541 // nothing to return since cropped content is completely empty
2542 return;
2543 }
2544
2545 if(aCurrentForCompare.equal(aCropped))
2546 {
2547 // no crop at all
2548 return;
2549 }
2550
2551 // back-transform to have values in unit coordinates
2552 basegfx::B2DHomMatrix aBackToUnit;
2553 aBackToUnit.translate(-aTranslate.getX(), -aTranslate.getY());
2554 aBackToUnit.scale(
2555 basegfx::fTools::equalZero(aScale.getX()) ? 1.0 : 1.0 / aScale.getX(),
2556 basegfx::fTools::equalZero(aScale.getY()) ? 1.0 : 1.0 / aScale.getY());
2557
2558 // transform cropped back to unit coordinates
2559 aCropped.transform(aBackToUnit);
2560
2561 // prepare crop PolyPolygon
2562 basegfx::B2DPolyPolygon aCropPolyPolygon(
2563 basegfx::tools::createPolygonFromRect(
2564 aCropped));
2565
2566 // current range is unit range
2567 basegfx::B2DRange aOverlap(0.0, 0.0, 1.0, 1.0);
2568
2569 aOverlap.intersect(aCropped);
2570
2571 if(!aOverlap.isEmpty())
2572 {
2573 aCropPolyPolygon.append(
2574 basegfx::tools::createPolygonFromRect(
2575 aOverlap));
2576 }
2577
2578 // transform to object coordinates to prepare for clip
2579 aCropPolyPolygon.transform(maObjectTransform);
2580
2581 // create cropped transformation
2582 basegfx::B2DHomMatrix aCroppedTransform;
2583 const bool bCombinedMirrorX(mbExtraMirrorXFromGraphic || bMirroredX);
2584
2585 aCroppedTransform.scale(
2586 bCombinedMirrorX ? -aCropped.getWidth() : aCropped.getWidth(),
2587 bMirroredY ? -aCropped.getHeight() : aCropped.getHeight());
2588 aCroppedTransform.translate(
2589 bCombinedMirrorX ? aCropped.getMaxX() : aCropped.getMinX(),
2590 bMirroredY ? aCropped.getMaxY() : aCropped.getMinY());
2591 aCroppedTransform = maObjectTransform * aCroppedTransform;
2592
2593 // prepare graphic primitive (tranformed)
2594 const drawinglayer::primitive2d::Primitive2DReference aGraphic(
2595 new drawinglayer::primitive2d::GraphicPrimitive2D(
2596 aCroppedTransform,
2597 maGraphic));
2598
2599 // embed to MaskPrimitive2D
2600 const drawinglayer::primitive2d::Primitive2DReference aMaskedGraphic(
2601 new drawinglayer::primitive2d::MaskPrimitive2D(
2602 aCropPolyPolygon,
2603 drawinglayer::primitive2d::Primitive2DSequence(&aGraphic, 1)));
2604
2605 // embed to UnifiedTransparencePrimitive2D
2606 const drawinglayer::primitive2d::Primitive2DReference aTransparenceMaskedGraphic(
2607 new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
2608 drawinglayer::primitive2d::Primitive2DSequence(&aMaskedGraphic, 1),
2609 0.8));
2610
2611 const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aTransparenceMaskedGraphic, 1);
2612
2613 for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
2614 {
2615 // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
2616 const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
2617
2618 if(rPageWindow.GetPaintWindow().OutputToWindow())
2619 {
2620 if(rPageWindow.GetOverlayManager())
2621 {
2622 ::sdr::overlay::OverlayObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aSequence);
2623 DBG_ASSERT(pNew, "Got NO new IAO!");
2624
2625 if(pNew)
2626 {
2627 // only informative object, no hit
2628 pNew->setHittable(false);
2629
2630 rPageWindow.GetOverlayManager()->add(*pNew);
2631 maOverlayGroup.append(*pNew);
2632 }
2633 }
2634 }
2635 }
2636}
2637
2638////////////////////////////////////////////////////////////////////////////////////////////////////
2639// eof