svddrgmt.cxx (64b14621) | svddrgmt.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 --- 928 unchanged lines hidden (view full) --- 937 { 938 // switch off solid dragging if connector is not visible 939 if(!pEdge->HasLineStyle()) 940 { 941 bUseSolidDragging = false; 942 } 943 } 944 | 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 --- 928 unchanged lines hidden (view full) --- 937 { 938 // switch off solid dragging if connector is not visible 939 if(!pEdge->HasLineStyle()) 940 { 941 bUseSolidDragging = false; 942 } 943 } 944 |
945 if(bUseSolidDragging) 946 { 947 const SfxItemSet& rItemSet = pEdge->GetMergedItemSet(); 948 const drawinglayer::attribute::SdrLineAttribute aLine( 949 drawinglayer::primitive2d::createNewSdrLineAttribute(rItemSet)); | 945 if(bUseSolidDragging) 946 { 947 const SfxItemSet& rItemSet = pEdge->GetMergedItemSet(); 948 const drawinglayer::attribute::SdrLineAttribute aLine( 949 drawinglayer::primitive2d::createNewSdrLineAttribute(rItemSet)); |
950 | 950 |
951 if(!aLine.isDefault()) 952 { 953 const drawinglayer::attribute::SdrLineStartEndAttribute aLineStartEnd( 954 drawinglayer::primitive2d::createNewSdrLineStartEndAttribute( 955 rItemSet, 956 aLine.getWidth())); 957 958 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence( 959 aRetval, drawinglayer::primitive2d::createPolygonLinePrimitive( 960 aEdgePolygon, 961 aLine, 962 aLineStartEnd)); 963 } 964 } 965 else | 951 if(!aLine.isDefault()) 952 { 953 const drawinglayer::attribute::SdrLineStartEndAttribute aLineStartEnd( 954 drawinglayer::primitive2d::createNewSdrLineStartEndAttribute( 955 rItemSet, 956 aLine.getWidth())); 957 958 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence( 959 aRetval, drawinglayer::primitive2d::createPolygonLinePrimitive( 960 aEdgePolygon, 961 basegfx::B2DHomMatrix(), 962 aLine, 963 aLineStartEnd)); 964 } 965 } 966 else |
966 { 967 const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; 968 basegfx::BColor aColA(aSvtOptionsDrawinglayer.GetStripeColorA().getBColor()); 969 basegfx::BColor aColB(aSvtOptionsDrawinglayer.GetStripeColorB().getBColor()); 970 const double fStripeLength(aSvtOptionsDrawinglayer.GetStripeLength()); 971 972 if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) 973 { --- 2702 unchanged lines hidden (view full) --- 3676 _MovAllPoints(rTarget); 3677} 3678 3679//////////////////////////////////////////////////////////////////////////////////////////////////// 3680 3681TYPEINIT1(SdrDragCrop,SdrDragResize); 3682 3683SdrDragCrop::SdrDragCrop(SdrDragView& rNewView) | 967 { 968 const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; 969 basegfx::BColor aColA(aSvtOptionsDrawinglayer.GetStripeColorA().getBColor()); 970 basegfx::BColor aColB(aSvtOptionsDrawinglayer.GetStripeColorB().getBColor()); 971 const double fStripeLength(aSvtOptionsDrawinglayer.GetStripeLength()); 972 973 if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) 974 { --- 2702 unchanged lines hidden (view full) --- 3677 _MovAllPoints(rTarget); 3678} 3679 3680//////////////////////////////////////////////////////////////////////////////////////////////////// 3681 3682TYPEINIT1(SdrDragCrop,SdrDragResize); 3683 3684SdrDragCrop::SdrDragCrop(SdrDragView& rNewView) |
3684: SdrDragResize(rNewView) | 3685: SdrDragObjOwn(rNewView) |
3685{ 3686 // switch off solid dragging for crop; it just makes no sense since showing 3687 // a 50% transparent object above the original will not be visible 3688 setSolidDraggingActive(false); 3689} 3690 3691void SdrDragCrop::TakeSdrDragComment(XubString& rStr) const 3692{ --- 8 unchanged lines hidden (view full) --- 3701 getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr); 3702 rStr += aStr; 3703 rStr += sal_Unicode(')'); 3704 3705 if(getSdrDragView().IsDragWithCopy()) 3706 rStr += ImpGetResStr(STR_EditWithCopy); 3707} 3708 | 3686{ 3687 // switch off solid dragging for crop; it just makes no sense since showing 3688 // a 50% transparent object above the original will not be visible 3689 setSolidDraggingActive(false); 3690} 3691 3692void SdrDragCrop::TakeSdrDragComment(XubString& rStr) const 3693{ --- 8 unchanged lines hidden (view full) --- 3702 getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr); 3703 rStr += aStr; 3704 rStr += sal_Unicode(')'); 3705 3706 if(getSdrDragView().IsDragWithCopy()) 3707 rStr += ImpGetResStr(STR_EditWithCopy); 3708} 3709 |
3709bool SdrDragCrop::EndSdrDrag(bool bCopy) | 3710bool SdrDragCrop::BeginSdrDrag() |
3710{ | 3711{ |
3712 // call parent 3713 bool bRetval(SdrDragObjOwn::BeginSdrDrag()); 3714 3715 if(!GetDragHdl()) 3716 { 3717 // we need the DragHdl, break if not there 3718 bRetval = false; 3719 } 3720 3721 return bRetval; 3722} 3723 3724bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/) 3725{ |
|
3711 Hide(); 3712 3713 if( DragStat().GetDX()==0 && DragStat().GetDY()==0 ) 3714 return false; 3715 3716 const SdrMarkList& rMarkList = getSdrDragView().GetMarkedObjectList(); 3717 3718 if( rMarkList.GetMarkCount() != 1 ) --- 21 unchanged lines hidden (view full) --- 3740 const bool bUndo = getSdrDragView().IsUndoEnabled(); 3741 3742 if( bUndo ) 3743 { 3744 String aUndoStr; 3745 ImpTakeDescriptionStr(STR_DragMethCrop, aUndoStr); 3746 3747 getSdrDragView().BegUndo( aUndoStr ); | 3726 Hide(); 3727 3728 if( DragStat().GetDX()==0 && DragStat().GetDY()==0 ) 3729 return false; 3730 3731 const SdrMarkList& rMarkList = getSdrDragView().GetMarkedObjectList(); 3732 3733 if( rMarkList.GetMarkCount() != 1 ) --- 21 unchanged lines hidden (view full) --- 3755 const bool bUndo = getSdrDragView().IsUndoEnabled(); 3756 3757 if( bUndo ) 3758 { 3759 String aUndoStr; 3760 ImpTakeDescriptionStr(STR_DragMethCrop, aUndoStr); 3761 3762 getSdrDragView().BegUndo( aUndoStr ); |
3748 getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); | 3763 getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); 3764 // also need attr undo, the SdrGrafCropItem will be changed 3765 getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); |
3749 } 3750 | 3766 } 3767 |
3751 Rectangle aOldRect( pObj->GetLogicRect() ); 3752 getSdrDragView().ResizeMarkedObj(DragStat().Ref1(),aXFact,aYFact,bCopy); 3753 Rectangle aNewRect( pObj->GetLogicRect() ); | 3768 // new part to comute the user's drag activities 3769 // get the original objects transformation 3770 basegfx::B2DHomMatrix aOriginalMatrix; 3771 basegfx::B2DPolyPolygon aPolyPolygon; 3772 bool bShearCorrected(false); |
3754 | 3773 |
3755 double fScaleX = ( aGraphicSize.Width() - rOldCrop.GetLeft() - rOldCrop.GetRight() ) / (double)aOldRect.GetWidth(); 3756 double fScaleY = ( aGraphicSize.Height() - rOldCrop.GetTop() - rOldCrop.GetBottom() ) / (double)aOldRect.GetHeight(); | 3774 // get transformation from object 3775 pObj->TRGetBaseGeometry(aOriginalMatrix, aPolyPolygon); |
3757 | 3776 |
3758 // to correct the never working combination of cropped images and mirroring 3759 // I have to correct the rectangles the calculation is based on here. In the current 3760 // core geometry stuff a vertical mirror is expressed as 180 degree rotation. All 3761 // this can be removed again when aw080 will have cleaned up the old 3762 // (non-)transformation mess in the core. 3763 if(18000 == pObj->GetGeoStat().nDrehWink) | 3777 { // TTTT correct shear, it comes currently mirrored from TRGetBaseGeometry, can be removed with aw080 3778 basegfx::B2DTuple aScale; 3779 basegfx::B2DTuple aTranslate; 3780 double fRotate(0.0), fShearX(0.0); 3781 3782 aOriginalMatrix.decompose(aScale, aTranslate, fRotate, fShearX); 3783 3784 if(!basegfx::fTools::equalZero(fShearX)) 3785 { 3786 bShearCorrected = true; 3787 aOriginalMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 3788 aScale, 3789 -fShearX, 3790 fRotate, 3791 aTranslate); 3792 } 3793 } 3794 3795 // invert it to be able to work on unit coordinates 3796 basegfx::B2DHomMatrix aInverse(aOriginalMatrix); 3797 3798 aInverse.invert(); 3799 3800 // gererate start point of original drag vector in unit coordinates (the 3801 // vis-a-vis of the drag point) 3802 basegfx::B2DPoint aLocalStart(0.0, 0.0); 3803 bool bOnAxis(false); 3804 3805 switch(GetDragHdlKind()) |
3764 { | 3806 { |
3765 // old notation of vertical mirror, need to correct diffs since both rects 3766 // are rotated by 180 degrees 3767 aOldRect = Rectangle(aOldRect.TopLeft() - (aOldRect.BottomRight() - aOldRect.TopLeft()), aOldRect.TopLeft()); 3768 aNewRect = Rectangle(aNewRect.TopLeft() - (aNewRect.BottomRight() - aNewRect.TopLeft()), aNewRect.TopLeft()); | 3807 case HDL_UPLFT: aLocalStart.setX(1.0); aLocalStart.setY(1.0); break; 3808 case HDL_UPPER: aLocalStart.setX(0.5); aLocalStart.setY(1.0); bOnAxis = true; break; 3809 case HDL_UPRGT: aLocalStart.setX(0.0); aLocalStart.setY(1.0); break; 3810 case HDL_LEFT : aLocalStart.setX(1.0); aLocalStart.setY(0.5); bOnAxis = true; break; 3811 case HDL_RIGHT: aLocalStart.setX(0.0); aLocalStart.setY(0.5); bOnAxis = true; break; 3812 case HDL_LWLFT: aLocalStart.setX(1.0); aLocalStart.setY(0.0); break; 3813 case HDL_LOWER: aLocalStart.setX(0.5); aLocalStart.setY(0.0); bOnAxis = true; break; 3814 case HDL_LWRGT: aLocalStart.setX(0.0); aLocalStart.setY(0.0); break; 3815 default: break; |
3769 } 3770 | 3816 } 3817 |
3818 // create the current drag position in unit coordinates 3819 basegfx::B2DPoint aLocalCurrent(aInverse * basegfx::B2DPoint(DragStat().GetNow().X(), DragStat().GetNow().Y())); 3820 3821 // if one of the edge handles is used, limit to X or Y drag only 3822 if(bOnAxis) 3823 { 3824 if(basegfx::fTools::equal(aLocalStart.getX(), 0.5)) 3825 { 3826 aLocalCurrent.setX(aLocalStart.getX()); 3827 } 3828 else 3829 { 3830 aLocalCurrent.setY(aLocalStart.getY()); 3831 } 3832 } 3833 3834 // create internal change in unit coordinates 3835 basegfx::B2DHomMatrix aDiscreteChangeMatrix; 3836 3837 if(!basegfx::fTools::equal(aLocalCurrent.getX(), aLocalStart.getX())) 3838 { 3839 if(aLocalStart.getX() < 0.5) 3840 { 3841 aDiscreteChangeMatrix.scale(aLocalCurrent.getX(), 1.0); 3842 } 3843 else 3844 { 3845 aDiscreteChangeMatrix.scale(1.0 - aLocalCurrent.getX(), 1.0); 3846 aDiscreteChangeMatrix.translate(aLocalCurrent.getX(), 0.0); 3847 } 3848 } 3849 3850 if(!basegfx::fTools::equal(aLocalCurrent.getY(), aLocalStart.getY())) 3851 { 3852 if(aLocalStart.getY() < 0.5) 3853 { 3854 aDiscreteChangeMatrix.scale(1.0, aLocalCurrent.getY()); 3855 } 3856 else 3857 { 3858 aDiscreteChangeMatrix.scale(1.0, 1.0 - aLocalCurrent.getY()); 3859 aDiscreteChangeMatrix.translate(0.0, aLocalCurrent.getY()); 3860 } 3861 } 3862 3863 // preparematrix to apply to object; evtl. back-correct shear 3864 basegfx::B2DHomMatrix aNewObjectMatrix(aOriginalMatrix * aDiscreteChangeMatrix); 3865 3866 if(bShearCorrected) 3867 { 3868 // TTTT back-correct shear 3869 basegfx::B2DTuple aScale; 3870 basegfx::B2DTuple aTranslate; 3871 double fRotate(0.0), fShearX(0.0); 3872 3873 aNewObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX); 3874 aNewObjectMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 3875 aScale, 3876 -fShearX, 3877 fRotate, 3878 aTranslate); 3879 } 3880 3881 // apply change to object by applying the unit coordinate change followed 3882 // by the original change 3883 pObj->TRSetBaseGeometry(aNewObjectMatrix, aPolyPolygon); 3884 3885 // the following old code uses aOldRect/aNewRect to calculate the crop change for 3886 // the crop item. It implies unrotated objects, so create the unrotated original 3887 // erctangle and the unrotated modified rectangle. Latter can in case of shear and/or 3888 // rotation not be fetched by using 3889 // 3890 //Rectangle aNewRect( pObj->GetLogicRect() ); 3891 // 3892 // as it was done before because the top-left of that new rect *will* have an offset 3893 // caused by the evtl. existing shear and/or rotation, so calculate a unrotated 3894 // rectangle how it would be as a result when appling the unit coordinate change 3895 // to the unrotated original transformation. 3896 basegfx::B2DTuple aScale; 3897 basegfx::B2DTuple aTranslate; 3898 double fRotate, fShearX; 3899 3900 // get access to scale and translate 3901 aOriginalMatrix.decompose(aScale, aTranslate, fRotate, fShearX); 3902 3903 // prepare unsheared/unrotated versions of the old and new transformation 3904 const basegfx::B2DHomMatrix aMatrixOriginalNoShearNoRotate( 3905 basegfx::tools::createScaleTranslateB2DHomMatrix( 3906 basegfx::absolute(aScale), 3907 aTranslate)); 3908 3909 // create the ranges for these 3910 basegfx::B2DRange aRangeOriginalNoShearNoRotate(0.0, 0.0, 1.0, 1.0); 3911 basegfx::B2DRange aRangeNewNoShearNoRotate(0.0, 0.0, 1.0, 1.0); 3912 3913 aRangeOriginalNoShearNoRotate.transform(aMatrixOriginalNoShearNoRotate); 3914 aRangeNewNoShearNoRotate.transform(aMatrixOriginalNoShearNoRotate * aDiscreteChangeMatrix); 3915 3916 // extract the old Rectangle structures 3917 Rectangle aOldRect( 3918 basegfx::fround(aRangeOriginalNoShearNoRotate.getMinX()), 3919 basegfx::fround(aRangeOriginalNoShearNoRotate.getMinY()), 3920 basegfx::fround(aRangeOriginalNoShearNoRotate.getMaxX()), 3921 basegfx::fround(aRangeOriginalNoShearNoRotate.getMaxY())); 3922 Rectangle aNewRect( 3923 basegfx::fround(aRangeNewNoShearNoRotate.getMinX()), 3924 basegfx::fround(aRangeNewNoShearNoRotate.getMinY()), 3925 basegfx::fround(aRangeNewNoShearNoRotate.getMaxX()), 3926 basegfx::fround(aRangeNewNoShearNoRotate.getMaxY())); 3927 3928 // continue with the old original stuff 3929 double fScaleX = ( aGraphicSize.Width() - rOldCrop.GetLeft() - rOldCrop.GetRight() ) / (double)aOldRect.GetWidth(); 3930 double fScaleY = ( aGraphicSize.Height() - rOldCrop.GetTop() - rOldCrop.GetBottom() ) / (double)aOldRect.GetHeight(); 3931 3932 // not needed since the modification is done in unit coordinates, free from shear/rotate and mirror 3933 // // TTTT may be removed or exhanged by other stuff in aw080 3934 // // to correct the never working combination of cropped images and mirroring 3935 // // I have to correct the rectangles the calculation is based on here. In the current 3936 // // core geometry stuff a vertical mirror is expressed as 180 degree rotation. All 3937 // // this can be removed again when aw080 will have cleaned up the old 3938 // // (non-)transformation mess in the core. 3939 // if(18000 == pObj->GetGeoStat().nDrehWink) 3940 // { 3941 // // old notation of vertical mirror, need to correct diffs since both rects 3942 // // are rotated by 180 degrees 3943 // aOldRect = Rectangle(aOldRect.TopLeft() - (aOldRect.BottomRight() - aOldRect.TopLeft()), aOldRect.TopLeft()); 3944 // aNewRect = Rectangle(aNewRect.TopLeft() - (aNewRect.BottomRight() - aNewRect.TopLeft()), aNewRect.TopLeft()); 3945 // } 3946 |
|
3771 sal_Int32 nDiffLeft = aNewRect.nLeft - aOldRect.nLeft; 3772 sal_Int32 nDiffTop = aNewRect.nTop - aOldRect.nTop; 3773 sal_Int32 nDiffRight = aNewRect.nRight - aOldRect.nRight; 3774 sal_Int32 nDiffBottom = aNewRect.nBottom - aOldRect.nBottom; 3775 | 3947 sal_Int32 nDiffLeft = aNewRect.nLeft - aOldRect.nLeft; 3948 sal_Int32 nDiffTop = aNewRect.nTop - aOldRect.nTop; 3949 sal_Int32 nDiffRight = aNewRect.nRight - aOldRect.nRight; 3950 sal_Int32 nDiffBottom = aNewRect.nBottom - aOldRect.nBottom; 3951 |
3952 if(pObj->IsMirrored()) 3953 { 3954 // mirrored X or Y, for old stuff, exchange X 3955 // TTTT: check for aw080 3956 sal_Int32 nTmp(nDiffLeft); 3957 nDiffLeft = -nDiffRight; 3958 nDiffRight = -nTmp; 3959 } 3960 |
|
3776 sal_Int32 nLeftCrop = static_cast<sal_Int32>( rOldCrop.GetLeft() + nDiffLeft * fScaleX ); 3777 sal_Int32 nTopCrop = static_cast<sal_Int32>( rOldCrop.GetTop() + nDiffTop * fScaleY ); 3778 sal_Int32 nRightCrop = static_cast<sal_Int32>( rOldCrop.GetRight() - nDiffRight * fScaleX ); 3779 sal_Int32 nBottomCrop = static_cast<sal_Int32>( rOldCrop.GetBottom() - nDiffBottom * fScaleY ); 3780 3781 SfxItemPool& rPool = getSdrDragView().GetModel()->GetItemPool(); 3782 SfxItemSet aSet( rPool, SDRATTR_GRAFCROP, SDRATTR_GRAFCROP ); 3783 aSet.Put( SdrGrafCropItem( nLeftCrop, nTopCrop, nRightCrop, nBottomCrop ) ); --- 15 unchanged lines hidden --- | 3961 sal_Int32 nLeftCrop = static_cast<sal_Int32>( rOldCrop.GetLeft() + nDiffLeft * fScaleX ); 3962 sal_Int32 nTopCrop = static_cast<sal_Int32>( rOldCrop.GetTop() + nDiffTop * fScaleY ); 3963 sal_Int32 nRightCrop = static_cast<sal_Int32>( rOldCrop.GetRight() - nDiffRight * fScaleX ); 3964 sal_Int32 nBottomCrop = static_cast<sal_Int32>( rOldCrop.GetBottom() - nDiffBottom * fScaleY ); 3965 3966 SfxItemPool& rPool = getSdrDragView().GetModel()->GetItemPool(); 3967 SfxItemSet aSet( rPool, SDRATTR_GRAFCROP, SDRATTR_GRAFCROP ); 3968 aSet.Put( SdrGrafCropItem( nLeftCrop, nTopCrop, nRightCrop, nBottomCrop ) ); --- 15 unchanged lines hidden --- |