incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1210905 - in /incubator/ooo/branches/alg/svgreplacement/main: drawinglayer/ drawinglayer/inc/drawinglayer/primitive2d/ drawinglayer/source/primitive2d/ svx/inc/svx/sdr/contact/ svx/source/svdraw/ sw/source/core/doc/
Date Tue, 06 Dec 2011 13:36:11 GMT
Author: alg
Date: Tue Dec  6 13:36:10 2011
New Revision: 1210905

URL: http://svn.apache.org/viewvc?rev=1210905&view=rev
Log:
svg: cropping unified using CropPrimitive2D, cropping never worked for mirrored images, fixed.
Added suppiort in Writer to draw Svg graphics using the primitive representation, added support
for mirroring and cropping.

Added:
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/cropprimitive2d.hxx
  (with props)
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/cropprimitive2d.cxx
  (with props)
Modified:
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svx/inc/svx/sdr/contact/objectcontacttools.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svddrgmt.cxx
    incubator/ooo/branches/alg/svgreplacement/main/sw/source/core/doc/notxtfrm.cxx

Modified: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk?rev=1210905&r1=1210904&r2=1210905&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk Tue
Dec  6 13:36:10 2011
@@ -96,6 +96,7 @@ $(eval $(call gb_Library_add_exception_o
 	drawinglayer/source/primitive2d/borderlineprimitive2d \
 	drawinglayer/source/primitive2d/chartprimitive2d \
 	drawinglayer/source/primitive2d/controlprimitive2d \
+	drawinglayer/source/primitive2d/cropprimitive2d \
 	drawinglayer/source/primitive2d/discretebitmapprimitive2d \
 	drawinglayer/source/primitive2d/discreteshadowprimitive2d \
 	drawinglayer/source/primitive2d/embedded3dprimitive2d \

Modified: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk?rev=1210905&r1=1210904&r2=1210905&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk Tue Dec  6
13:36:10 2011
@@ -36,6 +36,7 @@ $(eval $(call gb_Package_add_file,drawin
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx,drawinglayer/primitive2d/borderlineprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/chartprimitive2d.hxx,drawinglayer/primitive2d/chartprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/controlprimitive2d.hxx,drawinglayer/primitive2d/controlprimitive2d.hxx))
+$(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/cropprimitive2d.hxx,drawinglayer/primitive2d/cropprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/discretebitmapprimitive2d.hxx,drawinglayer/primitive2d/discretebitmapprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/discreteshadowprimitive2d.hxx,drawinglayer/primitive2d/discreteshadowprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx,drawinglayer/primitive2d/embedded3dprimitive2d.hxx))

Added: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/cropprimitive2d.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/cropprimitive2d.hxx?rev=1210905&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/cropprimitive2d.hxx
(added)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/cropprimitive2d.hxx
Tue Dec  6 13:36:10 2011
@@ -0,0 +1,105 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CROPPRIMITIVE2D_HXX
+#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CROPPRIMITIVE2D_HXX
+
+#include <drawinglayer/drawinglayerdllapi.h>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+    namespace primitive2d
+    {
+        /** CropPrimitive2D class
+        
+            Caution: Due to old constraints (old core definitions) the
+            crop distances describe how the uncropped content is defined
+            relative to the current object size. This means that maTransformation
+            describes the rurrent object size (the part of the object visible
+            with the crop applied). To get the original size and orientation
+            of the uncropped content it is necessary to calc back from the
+            current situation (maTransformation) using the crop values
+            to get to the uncropped original content.
+
+            Thus a transformation has to be calculated which will be applied
+            to the already exsisting content to get it to the uncropped state
+            ans then this is masked with the current state (mask polygon
+            created from unit polygon and maTransformation).
+
+            At least in this primitive the units of the crop values are
+            already in the local coordinate system; inthe core these distances 
+            are defined relative to the object content size (PrefMapMode
+            and PrefSize of the content)...
+
+            Of course this is a primitive, so feel free to just ignore all that 
+            stuff and use the automatically generated decomposition. Sigh.
+        */
+        class DRAWINGLAYER_DLLPUBLIC CropPrimitive2D : public GroupPrimitive2D
+        {
+        private:
+            // the transformation already applied to the child geometry
+            basegfx::B2DHomMatrix           maTransformation;
+
+            // the crop offsets relative to the range of the unrotated content
+            double                          mfCropLeft;
+            double                          mfCropTop;
+            double                          mfCropRight;
+            double                          mfCropBottom;
+
+        public:
+            /// constructor
+            CropPrimitive2D(
+                const Primitive2DSequence& rChildren,
+                const basegfx::B2DHomMatrix& rTransformation, 
+                double fCropLeft,
+                double fCropTop,
+                double fCropRight,
+                double fCropBottom);
+
+            /// data read access
+            const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation;
}
+            double getCropLeft() const { return mfCropLeft; }
+            double getCropTop() const { return mfCropTop; }
+            double getCropRight() const { return mfCropRight; }
+            double getCropBottom() const { return mfCropBottom; }
+
+            /// compare operator
+            virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
+
+            /// local decomposition
+            virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D&
rViewInformation) const;
+
+            /// provide unique ID
+            DeclPrimitrive2DIDBlock()
+        };
+    } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CROPPRIMITIVE2D_HXX
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/cropprimitive2d.hxx
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx?rev=1210905&r1=1210904&r2=1210905&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
Tue Dec  6 13:36:10 2011
@@ -103,6 +103,7 @@
 #define PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D         (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER|
64)
 #define PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D             (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER|
65)
 #define PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D             (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER|
66)
+#define PRIMITIVE2D_ID_CROPPRIMITIVE2D                      (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER|
67)
 
 //////////////////////////////////////////////////////////////////////////////
 

Added: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/cropprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/cropprimitive2d.cxx?rev=1210905&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/cropprimitive2d.cxx
(added)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/cropprimitive2d.cxx
Tue Dec  6 13:36:10 2011
@@ -0,0 +1,194 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_drawinglayer.hxx"
+
+#include <drawinglayer/primitive2d/cropprimitive2d.hxx>
+#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+    namespace primitive2d
+    {
+        CropPrimitive2D::CropPrimitive2D(
+            const Primitive2DSequence& rChildren,
+            const basegfx::B2DHomMatrix& rTransformation, 
+            double fCropLeft,
+            double fCropTop,
+            double fCropRight,
+            double fCropBottom)
+        :   GroupPrimitive2D(rChildren),
+            maTransformation(rTransformation),
+            mfCropLeft(fCropLeft),
+            mfCropTop(fCropTop),
+            mfCropRight(fCropRight),
+            mfCropBottom(fCropBottom)
+        {
+        }
+
+        bool CropPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+        {
+            if(GroupPrimitive2D::operator==(rPrimitive))
+            {
+                const CropPrimitive2D& rCompare = static_cast< const CropPrimitive2D&
>(rPrimitive);
+
+                return (getTransformation() == rCompare.getTransformation()
+                    && getCropLeft() == rCompare.getCropLeft()
+                    && getCropTop() == rCompare.getCropTop()
+                    && getCropRight() == rCompare.getCropRight()
+                    && getCropBottom() == rCompare.getCropBottom());
+            }
+
+            return false;
+        }
+
+        Primitive2DSequence CropPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D&
/*rViewInformation*/) const
+        {
+            Primitive2DSequence xRetval;
+
+            if(getChildren().hasElements())
+            {
+                // decompose to have current translate and scale
+                basegfx::B2DVector aScale, aTranslate;
+                double fRotate, fShearX;
+
+                getTransformation().decompose(aScale, aTranslate, fRotate, fShearX);
+
+                // detect 180 degree rotation, this is the same as mirrored in X and Y,
+                // thus change to mirroring. Prefer mirroring here. Use the equal call
+                // with getSmallValue here, the original which uses rtl::math::approxEqual
+                // is too correct here. Maybe this changes with enhanced precision in aw080
+                // to the better so that this can be reduced to the more precise call again
+                if(basegfx::fTools::equal(fRotate, F_PI, 0.000000001))
+                {
+                    aScale.setX(aScale.getX() * -1.0);
+                    aScale.setY(aScale.getY() * -1.0);
+                    fRotate = 0.0;
+                }
+
+                // create target translate and scale
+                const bool bMirroredX(aScale.getX() < 0.0);
+                const bool bMirroredY(aScale.getY() < 0.0);
+                basegfx::B2DVector aTargetScale(aScale);
+                basegfx::B2DVector aTargetTranslate(aTranslate);
+
+                if(bMirroredX)
+                {
+                    aTargetTranslate.setX(aTargetTranslate.getX() + getCropRight());
+                    aTargetScale.setX(aTargetScale.getX() - getCropLeft() - getCropRight());
+                }
+                else
+                {
+                    aTargetTranslate.setX(aTargetTranslate.getX() - getCropLeft());
+                    aTargetScale.setX(aTargetScale.getX() + getCropRight() + getCropLeft());
+                }
+
+                if(bMirroredY)
+                {
+                    aTargetTranslate.setY(aTargetTranslate.getY() + getCropBottom());
+                    aTargetScale.setY(aTargetScale.getY() - getCropTop() - getCropBottom());
+                }
+                else
+                {
+                    aTargetTranslate.setY(aTargetTranslate.getY() - getCropTop());
+                    aTargetScale.setY(aTargetScale.getY() + getCropBottom() + getCropTop());
+                }
+
+                // create ranges to make comparisons
+                const basegfx::B2DRange aCurrent(
+                    aTranslate.getX(), aTranslate.getY(), 
+                    aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY());
+                const basegfx::B2DRange aCropped(
+                    aTargetTranslate.getX(), aTargetTranslate.getY(), 
+                    aTargetTranslate.getX() + aTargetScale.getX(), aTargetTranslate.getY()
+ aTargetScale.getY());
+
+                if(aCropped.isEmpty())
+                {
+                    // nothing to return since cropped content is completely empty
+                }
+                else if(aCurrent.isInside(aCropped))
+                {
+                    // crop just shrunk so that its inside content, 
+                    // no need to use a mask since not really cropped.
+                    xRetval = getChildren();
+                }
+                else
+                {
+                    // build new combined content transformation
+                    basegfx::B2DHomMatrix aNewObjectTransform(getTransformation());
+
+                    // remove content transform by inverting
+                    aNewObjectTransform.invert();
+
+                    // add target values and original shear/rotate
+                    aNewObjectTransform = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+                        aTargetScale.getX(),
+                        aTargetScale.getY(),
+                        fShearX, 
+                        fRotate, 
+                        aTargetTranslate.getX(), 
+                        aTargetTranslate.getY()) 
+                            * aNewObjectTransform;
+
+                    // prepare TransformPrimitive2D with xPrimitive
+                    const Primitive2DReference xTransformPrimitive(
+                        new TransformPrimitive2D(
+                            aNewObjectTransform, 
+                            getChildren()));
+
+                    // mask with original object's bounds
+                    basegfx::B2DPolyPolygon aMaskPolyPolygon(basegfx::tools::createUnitPolygon());
+                    aMaskPolyPolygon.transform(getTransformation());
+
+                    // create maskPrimitive with aMaskPolyPolygon and aMaskContentVector
+                    const Primitive2DReference xMask(
+                        new MaskPrimitive2D(
+                            aMaskPolyPolygon, 
+                            Primitive2DSequence(&xTransformPrimitive, 1)));
+
+                    xRetval = Primitive2DSequence(&xMask, 1);
+                }
+            }
+
+            return xRetval;
+        }
+
+        // provide unique ID
+        ImplPrimitrive2DIDBlock(CropPrimitive2D, PRIMITIVE2D_ID_CROPPRIMITIVE2D)
+
+    } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/cropprimitive2d.cxx
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/graphicprimitive2d.cxx?rev=1210905&r1=1210904&r2=1210905&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
Tue Dec  6 13:36:10 2011
@@ -32,8 +32,10 @@
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
-#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <drawinglayer/primitive2d/cropprimitive2d.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <drawinglayer/primitive2d/cropprimitive2d.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // helper class for animated graphics
@@ -784,105 +786,58 @@ namespace drawinglayer
 					}
 				}
 
-				if(xPrimitive.is())
-				{
-					// check for cropping
-					if(getGraphicAttr().IsCropped())
-					{
-						// decompose to get current pos and size
-						basegfx::B2DVector aScale, aTranslate;
-						double fRotate, fShearX;
-						getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
-
-						// create ranges. The current object range is just scale and translate
-						const basegfx::B2DRange aCurrent(
-							aTranslate.getX(), aTranslate.getY(), 
-							aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY());
-
-						// calculate scalings between real image size and logic object size. This
-						// is necessary since the crop values are relative to original bitmap size
-						double fFactorX(1.0);
-						double fFactorY(1.0);
-
-						{
-							const MapMode aMapMode100thmm(MAP_100TH_MM);
-							Size aBitmapSize(rGraphicObject.GetPrefSize());
-							
-							// #i95968# better support PrefMapMode; special for MAP_PIXEL was missing
-							if(MAP_PIXEL == rGraphicObject.GetPrefMapMode().GetMapUnit())
-							{
-								aBitmapSize = Application::GetDefaultDevice()->PixelToLogic(aBitmapSize, aMapMode100thmm);
-							}
-							else
-							{
-								aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize, rGraphicObject.GetPrefMapMode(),
aMapMode100thmm);
-							}
-
-							const double fDivX(aBitmapSize.Width() - getGraphicAttr().GetLeftCrop() - getGraphicAttr().GetRightCrop());
-							const double fDivY(aBitmapSize.Height() - getGraphicAttr().GetTopCrop() - getGraphicAttr().GetBottomCrop());
-
-							if(!basegfx::fTools::equalZero(fDivX))
-							{
-								fFactorX = aScale.getX() / fDivX;
-							}
-
-							if(!basegfx::fTools::equalZero(fDivY))
-							{
-								fFactorY = aScale.getY() / fDivY;
-							}
-						}
-
-						// Create cropped range, describes the bounds of the original graphic
-						basegfx::B2DRange aCropped;
-						aCropped.expand(aCurrent.getMinimum() - basegfx::B2DPoint(getGraphicAttr().GetLeftCrop()
* fFactorX, getGraphicAttr().GetTopCrop() * fFactorY));
-						aCropped.expand(aCurrent.getMaximum() + basegfx::B2DPoint(getGraphicAttr().GetRightCrop()
* fFactorX, getGraphicAttr().GetBottomCrop() * fFactorY));
-
-						if(aCropped.isEmpty())
-						{
-							// nothing to add since cropped bitmap is completely empty
-							// xPrimitive will not be used
-						}
-						else
-						{
-							// build new object transformation for transform primitive which contains xPrimitive
-							basegfx::B2DHomMatrix aNewObjectTransform(getTransform());
-							aNewObjectTransform.invert();
-							aNewObjectTransform = basegfx::tools::createScaleTranslateB2DHomMatrix(
-								aCropped.getWidth(), aCropped.getHeight(),
-								aCropped.getMinX() - aCurrent.getMinX(), aCropped.getMinY() - aCurrent.getMinY())
-								* aNewObjectTransform;
-
-							// add shear, rotate and translate using combined matrix to speedup
-							const basegfx::B2DHomMatrix aCombinedMatrix(basegfx::tools::createShearXRotateTranslateB2DHomMatrix(
-								fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
-							aNewObjectTransform = aCombinedMatrix * aNewObjectTransform;
+                if(xPrimitive.is())
+                {
+                    // check for cropping
+                    if(getGraphicAttr().IsCropped())
+                    {
+                        // calculate scalings between real image size and logic object size.
This
+                        // is necessary since the crop values are relative to original bitmap
size
+                        double fFactorX(1.0);
+                        double fFactorY(1.0);
+                        
+                        {
+                            const MapMode aMapMode100thmm(MAP_100TH_MM);
+                            Size aBitmapSize(rGraphicObject.GetPrefSize());
+                            
+                            // #i95968# better support PrefMapMode; special for MAP_PIXEL
was missing
+                            if(MAP_PIXEL == rGraphicObject.GetPrefMapMode().GetMapUnit())
+                            {
+                                aBitmapSize = Application::GetDefaultDevice()->PixelToLogic(aBitmapSize,
aMapMode100thmm);
+                            }
+                            else
+                            {
+                                aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize,
rGraphicObject.GetPrefMapMode(), aMapMode100thmm);
+                            }
+                            
+                            const double fDivX(aBitmapSize.Width() - getGraphicAttr().GetLeftCrop()
- getGraphicAttr().GetRightCrop());
+                            const double fDivY(aBitmapSize.Height() - getGraphicAttr().GetTopCrop()
- getGraphicAttr().GetBottomCrop());
+                            const basegfx::B2DVector aScale(aTransform * basegfx::B2DVector(1.0,
1.0));
+                            
+                            if(!basegfx::fTools::equalZero(fDivX))
+                            {
+                                fFactorX = fabs(aScale.getX()) / fDivX;
+                            }
+                            
+                            if(!basegfx::fTools::equalZero(fDivY))
+                            {
+                                fFactorY = fabs(aScale.getY()) / fDivY;
+                            }
+                        }
 
-							// prepare TransformPrimitive2D with xPrimitive
-							const Primitive2DReference xTransformPrimitive(new TransformPrimitive2D(aNewObjectTransform,
Primitive2DSequence(&xPrimitive, 1L)));
+                        // embed content in cropPrimitive
+                        xPrimitive = new CropPrimitive2D(
+                            Primitive2DSequence(&xPrimitive, 1),
+                            aTransform,
+                            getGraphicAttr().GetLeftCrop() * fFactorX,
+                            getGraphicAttr().GetTopCrop() * fFactorY,
+                            getGraphicAttr().GetRightCrop() * fFactorX,
+                            getGraphicAttr().GetBottomCrop() * fFactorY);
+                    }
 
-							if(aCurrent.isInside(aCropped))
-							{
-								// cropped just got smaller, no need to really use a mask. Add to destination directly
-								appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xTransformPrimitive);
-							}
-							else
-							{
-								// cropped got bigger, mask it with original object's bounds
-								basegfx::B2DPolyPolygon aMaskPolyPolygon(basegfx::tools::createUnitPolygon());
-								aMaskPolyPolygon.transform(getTransform());
-
-								// create maskPrimitive with aMaskPolyPolygon and aMaskContentVector
-								const Primitive2DReference xRefB(new MaskPrimitive2D(aMaskPolyPolygon, Primitive2DSequence(&xTransformPrimitive,
1L)));
-								appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xRefB);
-							}
-						}
-					}
-					else
-					{
-						// add to decomposition
-						appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xPrimitive);
-					}
-				}
+                    // add to decomposition
+                    appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xPrimitive);
+                }
 			}
 
 			return aRetval;

Modified: incubator/ooo/branches/alg/svgreplacement/main/svx/inc/svx/sdr/contact/objectcontacttools.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svx/inc/svx/sdr/contact/objectcontacttools.hxx?rev=1210905&r1=1210904&r2=1210905&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svx/inc/svx/sdr/contact/objectcontacttools.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svx/inc/svx/sdr/contact/objectcontacttools.hxx
Tue Dec  6 13:36:10 2011
@@ -25,6 +25,7 @@
 #define _SDR_CONTACT_OBJECTCONTACTTOOLS_HXX
 
 #include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <svx/svxdllapi.h>
 
 //////////////////////////////////////////////////////////////////////////////
 // predeclarations
@@ -44,7 +45,7 @@ namespace sdr
 		// create a mating VCL-Provessor for given OutputDevice. This includes
 		// looking for MetaFile-recording. The returned renderer changes owner,
 		// deletion is duty of the caller
-		drawinglayer::processor2d::BaseProcessor2D* createBaseProcessor2DFromOutputDevice(
+		SVX_DLLPUBLIC drawinglayer::processor2d::BaseProcessor2D* createBaseProcessor2DFromOutputDevice(
             OutputDevice& rTargetOutDev, 
             const drawinglayer::geometry::ViewInformation2D& rViewInformation2D);
 

Modified: incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svddrgmt.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svddrgmt.cxx?rev=1210905&r1=1210904&r2=1210905&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svddrgmt.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svddrgmt.cxx Tue Dec
 6 13:36:10 2011
@@ -3628,6 +3628,19 @@ bool SdrDragCrop::EndSdrDrag(bool bCopy)
 	double fScaleX = ( aGraphicSize.Width() - rOldCrop.GetLeft() - rOldCrop.GetRight() ) / (double)aOldRect.GetWidth();
 	double fScaleY = ( aGraphicSize.Height() - rOldCrop.GetTop() - rOldCrop.GetBottom() ) /
(double)aOldRect.GetHeight();
 
+    // to correct the never working combination of cropped images and mirroring
+    // I have to correct the rectangles the calculation is based on here. In the current
+    // core geometry stuff a vertical mirror is expressed as 180 degree rotation. All
+    // this can be removed again when aw080 will have cleaned up the old 
+    // (non-)transformation mess in the core.
+    if(18000 == pObj->GetGeoStat().nDrehWink)
+    {
+        // old notation of vertical mirror, need to correct diffs since both rects
+        // are rotated by 180 degrees
+        aOldRect = Rectangle(aOldRect.TopLeft() - (aOldRect.BottomRight() - aOldRect.TopLeft()),
aOldRect.TopLeft());
+        aNewRect = Rectangle(aNewRect.TopLeft() - (aNewRect.BottomRight() - aNewRect.TopLeft()),
aNewRect.TopLeft());
+    }
+
 	sal_Int32 nDiffLeft = aNewRect.nLeft - aOldRect.nLeft;
 	sal_Int32 nDiffTop = aNewRect.nTop - aOldRect.nTop;
 	sal_Int32 nDiffRight = aNewRect.nRight - aOldRect.nRight;

Modified: incubator/ooo/branches/alg/svgreplacement/main/sw/source/core/doc/notxtfrm.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/sw/source/core/doc/notxtfrm.cxx?rev=1210905&r1=1210904&r2=1210905&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/sw/source/core/doc/notxtfrm.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/sw/source/core/doc/notxtfrm.cxx Tue Dec
 6 13:36:10 2011
@@ -78,6 +78,11 @@
 #include <dview.hxx>
 // <--
 
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/contact/objectcontacttools.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
 using namespace com::sun::star;
 
 #define DEFTEXTSIZE  12
@@ -940,10 +945,102 @@ void SwNoTxtFrm::PaintPicture( OutputDev
                                         aAlignedGrfArea.SSize(), long(this),
 										0, GRFMGR_DRAW_STANDARD, pVout );
 				}
-				else
-                    rGrfObj.DrawWithPDFHandling( *pOut,
-                                                 aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(),
-                                                 &aGrfAttr );
+                else
+                {
+                    const SvgDataPtr& rSvgDataPtr = rGrfObj.GetGraphic().getSvgData();
+                    bool bDone(false);
+
+                    if(rSvgDataPtr.get())
+                    {
+                        // Graphic is Svg and can be painted as primitives (vector graphic)
+                        const basegfx::B2DRange& rRange = rSvgDataPtr->getRange();
+                        const double fWidth(rRange.getWidth());
+                        const double fHeight(rRange.getHeight());
+                        const drawinglayer::primitive2d::Primitive2DSequence& rSequence
= rSvgDataPtr->getPrimitive2DSequence();
+
+                        if(rSequence.hasElements() && !basegfx::fTools::equalZero(fWidth)
&& !basegfx::fTools::equalZero(fHeight))
+                        {
+                            // get target range
+                            const basegfx::B2DRange aTargetRange(
+                                aAlignedGrfArea.Left(), aAlignedGrfArea.Top(), 
+                                aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
+
+                            // prepare evtl. cropped range
+                            basegfx::B2DRange aCroppedTargetRange(aTargetRange);
+
+                            if(aGrfAttr.IsCropped())
+                            {
+                                // calculate original TargetRange
+                                const double fFactor100thmmToTwips(72.0 / 127.0);
+
+                                aCroppedTargetRange = basegfx::B2DRange(
+                                    aTargetRange.getMinX() - (aGrfAttr.GetLeftCrop() * fFactor100thmmToTwips),
+                                    aTargetRange.getMinY() - (aGrfAttr.GetTopCrop() * fFactor100thmmToTwips),
+                                    aTargetRange.getMaxX() + (aGrfAttr.GetRightCrop() * fFactor100thmmToTwips),
+                                    aTargetRange.getMaxY() + (aGrfAttr.GetBottomCrop() *
fFactor100thmmToTwips));
+                            }
+
+                            const double fTargetWidth(aCroppedTargetRange.getWidth());
+                            const double fTargetHeight(aCroppedTargetRange.getHeight());
+                            
+                            if(!basegfx::fTools::equalZero(fTargetWidth) && !basegfx::fTools::equalZero(fTargetHeight))
+                            {
+                                // map graphic range to target range. This will automatically
include
+                                // tme mapping from Svg 1/100th mm content to twips since
the target
+                                // range is twips already
+                                basegfx::B2DHomMatrix aMappingTransform(
+                                    basegfx::tools::createTranslateB2DHomMatrix(
+                                        -rRange.getMinX(), 
+                                        -rRange.getMinY()));
+
+                                aMappingTransform.scale(fTargetWidth / fWidth, fTargetHeight
/ fHeight);
+                                aMappingTransform.translate(aCroppedTargetRange.getMinX(),
aCroppedTargetRange.getMinY());
+
+                                // check for and apply mirrorings
+                                const bool bMirrorHor(aGrfAttr.GetMirrorFlags() & BMP_MIRROR_HORZ);
+                                const bool bMirrorVer(aGrfAttr.GetMirrorFlags() & BMP_MIRROR_VERT);
+
+                                if(bMirrorHor || bMirrorVer)
+                                {
+                                    aMappingTransform.translate(-aCroppedTargetRange.getCenterX(),
-aCroppedTargetRange.getCenterY());
+                                    aMappingTransform.scale(bMirrorHor ? -1.0 : 1.0, bMirrorVer
? -1.0 : 1.0);
+                                    aMappingTransform.translate(aCroppedTargetRange.getCenterX(),
aCroppedTargetRange.getCenterY());
+                                }
+
+                                // Fill ViewInformation. Use MappingTransform here, so there
is no need to
+                                // embed the primitives to it. Use original TargetRange here
so there is also
+                                // no need to embed the primitives to a MaskPrimitive for
cropping. This works 
+                                // only in this case where the graphic object cannot be rotated,
though.
+                                const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
+                                    aMappingTransform, 
+                                    pOut->GetViewTransformation(), 
+                                    aTargetRange, 
+                                    0,
+                                    0.0, 
+                                    com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue
>());
+
+                                // get a primitive processor for rendering
+                                drawinglayer::processor2d::BaseProcessor2D* pProcessor2D
= sdr::contact::createBaseProcessor2DFromOutputDevice(
+                                    *pOut, 
+                                    aViewInformation2D);
+
+                                if(pProcessor2D)
+                                {
+                                    // render and cleanup
+                                    pProcessor2D->process(rSequence);
+                                    delete pProcessor2D;
+                                    bDone = true;
+                                }
+                            }
+                        }
+                    }
+
+                    if(!bDone)
+                    {
+                        // fallback paint, uses replacement image
+                        rGrfObj.DrawWithPDFHandling(*pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(),
&aGrfAttr);
+                    }
+                }
 			}
 			else
 			{



Mime
View raw message