svdograf.cxx (3706bbde) svdograf.cxx (414a0e15)
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

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

65#include <svx/sdr/contact/viewcontactofgraphic.hxx>
66#include <basegfx/polygon/b2dpolygon.hxx>
67#include <basegfx/polygon/b2dpolygontools.hxx>
68#include <osl/thread.hxx>
69#include <vos/mutex.hxx>
70#include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
71#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
72#include <unotools/cacheoptions.hxx>
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

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

65#include <svx/sdr/contact/viewcontactofgraphic.hxx>
66#include <basegfx/polygon/b2dpolygon.hxx>
67#include <basegfx/polygon/b2dpolygontools.hxx>
68#include <osl/thread.hxx>
69#include <vos/mutex.hxx>
70#include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
71#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
72#include <unotools/cacheoptions.hxx>
73#include <basegfx/matrix/b2dhommatrixtools.hxx>
73
74using namespace ::com::sun::star::uno;
75using namespace ::com::sun::star::io;
76
77// -----------
78// - Defines -
79// -----------
80

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

1671 if( pStream )
1672 xStream.set( new utl::OInputStreamWrapper( pStream ) );
1673 }
1674 }
1675
1676 return xStream;
1677}
1678
74
75using namespace ::com::sun::star::uno;
76using namespace ::com::sun::star::io;
77
78// -----------
79// - Defines -
80// -----------
81

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

1672 if( pStream )
1673 xStream.set( new utl::OInputStreamWrapper( pStream ) );
1674 }
1675 }
1676
1677 return xStream;
1678}
1679
1680// moved crop handle creation here; this is the object type using them
1681void SdrGrafObj::addCropHandles(SdrHdlList& rTarget) const
1682{
1683 basegfx::B2DHomMatrix aMatrix;
1684 basegfx::B2DPolyPolygon aPolyPolygon;
1685
1686 // get object transformation
1687 TRGetBaseGeometry(aMatrix, aPolyPolygon);
1688
1689 // part of object transformation correction, but used later, so defined outside next scope
1690 double fShearX(0.0), fRotate(0.0);
1691
1692 { // TTTT correct shear, it comes currently mirrored from TRGetBaseGeometry, can be removed with aw080
1693 basegfx::B2DTuple aScale;
1694 basegfx::B2DTuple aTranslate;
1695
1696 aMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
1697
1698 if(!basegfx::fTools::equalZero(fShearX))
1699 {
1700 // shearX is used, correct it
1701 fShearX = -fShearX;
1702 }
1703
1704 aMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
1705 aScale,
1706 fShearX,
1707 fRotate,
1708 aTranslate);
1709 }
1710
1711 // get crop values
1712 const SdrGrafCropItem& rCrop = static_cast< const SdrGrafCropItem& >(GetMergedItem(SDRATTR_GRAFCROP));
1713
1714 if(rCrop.GetLeft() || rCrop.GetTop() || rCrop.GetRight() ||rCrop.GetBottom())
1715 {
1716 // decompose object transformation to have current translate and scale
1717 basegfx::B2DVector aScale, aTranslate;
1718 double fRotate, fShearX;
1719
1720 aMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
1721
1722 if(!aScale.equalZero())
1723 {
1724 // get crop scale
1725 const basegfx::B2DVector aCropScaleFactor(
1726 GetGraphicObject().calculateCropScaling(
1727 aScale.getX(),
1728 aScale.getY(),
1729 rCrop.GetLeft(),
1730 rCrop.GetTop(),
1731 rCrop.GetRight(),
1732 rCrop.GetBottom()));
1733
1734 // apply crop scale
1735 const double fCropLeft(rCrop.GetLeft() * aCropScaleFactor.getX());
1736 const double fCropTop(rCrop.GetTop() * aCropScaleFactor.getY());
1737 const double fCropRight(rCrop.GetRight() * aCropScaleFactor.getX());
1738 const double fCropBottom(rCrop.GetBottom() * aCropScaleFactor.getY());
1739 basegfx::B2DHomMatrix aMatrixForCropViewHdl(aMatrix);
1740
1741 if(IsMirrored())
1742 {
1743 // create corrected new matrix, TTTT can be removed with aw080
1744 // the old mirror only can mirror horizontally; the vertical mirror
1745 // is faked by using the horizontal and 180 degree rotation. Since
1746 // the object can be rotated differently from 180 degree, this is
1747 // not safe to detect. Just correct horizontal mirror (which is
1748 // in IsMirrored()) and keep the rotation angle
1749 // caution: Do not modify aMatrix, it is used below to calculate
1750 // the exact handle positions
1751 basegfx::B2DHomMatrix aPreMultiply;
1752
1753 // mirrored X, apply
1754 aPreMultiply.translate(-0.5, 0.0);
1755 aPreMultiply.scale(-1.0, 1.0);
1756 aPreMultiply.translate(0.5, 0.0);
1757
1758 aMatrixForCropViewHdl = aMatrixForCropViewHdl * aPreMultiply;
1759 }
1760
1761 rTarget.AddHdl(
1762 new SdrCropViewHdl(
1763 aMatrixForCropViewHdl,
1764 GetGraphicObject().GetGraphic(),
1765 fCropLeft,
1766 fCropTop,
1767 fCropRight,
1768 fCropBottom));
1769 }
1770 }
1771
1772 basegfx::B2DPoint aPos;
1773
1774 aPos = aMatrix * basegfx::B2DPoint(0.0, 0.0);
1775 rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_UPLFT, fShearX, fRotate));
1776 aPos = aMatrix * basegfx::B2DPoint(0.5, 0.0);
1777 rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_UPPER, fShearX, fRotate));
1778 aPos = aMatrix * basegfx::B2DPoint(1.0, 0.0);
1779 rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_UPRGT, fShearX, fRotate));
1780 aPos = aMatrix * basegfx::B2DPoint(0.0, 0.5);
1781 rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_LEFT , fShearX, fRotate));
1782 aPos = aMatrix * basegfx::B2DPoint(1.0, 0.5);
1783 rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_RIGHT, fShearX, fRotate));
1784 aPos = aMatrix * basegfx::B2DPoint(0.0, 1.0);
1785 rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_LWLFT, fShearX, fRotate));
1786 aPos = aMatrix * basegfx::B2DPoint(0.5, 1.0);
1787 rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_LOWER, fShearX, fRotate));
1788 aPos = aMatrix * basegfx::B2DPoint(1.0, 1.0);
1789 rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_LWRGT, fShearX, fRotate));
1790}
1791
1679// eof
1792// eof