ximpcustomshape.cxx (2b71a0a5) ximpcustomshape.cxx (0a792eef)
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

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

47#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
48#include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
49#include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
50#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
51#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
52#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
53#include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
54#include <com/sun/star/drawing/ProjectionMode.hpp>
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

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

47#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
48#include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
49#include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
50#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
51#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
52#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
53#include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
54#include <com/sun/star/drawing/ProjectionMode.hpp>
55#include <basegfx/vector/b2dvector.hxx>
55#include <hash_map>
56
57using namespace ::com::sun::star;
58using namespace ::xmloff::token;
59using namespace ::xmloff::EnhancedCustomShapeToken;
60
61TYPEINIT1( XMLEnhancedCustomShapeContext, SvXMLImportContext );
62

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

848 GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredX );
849 break;
850 case EAS_mirror_vertical :
851 GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredY );
852 break;
853 case EAS_viewBox :
854 {
855 SdXMLImExViewBox aViewBox( rValue, GetImport().GetMM100UnitConverter() );
56#include <hash_map>
57
58using namespace ::com::sun::star;
59using namespace ::xmloff::token;
60using namespace ::xmloff::EnhancedCustomShapeToken;
61
62TYPEINIT1( XMLEnhancedCustomShapeContext, SvXMLImportContext );
63

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

849 GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredX );
850 break;
851 case EAS_mirror_vertical :
852 GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredY );
853 break;
854 case EAS_viewBox :
855 {
856 SdXMLImExViewBox aViewBox( rValue, GetImport().GetMM100UnitConverter() );
856 awt::Rectangle aRect( aViewBox.GetX(), aViewBox.GetY(), aViewBox.GetWidth(), aViewBox.GetHeight() );
857 awt::Rectangle aRect(
858 basegfx::fround(aViewBox.GetX()),
859 basegfx::fround(aViewBox.GetY()),
860 basegfx::fround(aViewBox.GetWidth()),
861 basegfx::fround(aViewBox.GetHeight()));
862
863 if(0 == aRect.Width && 0 == aRect.Height)
864 {
865 // #124452# If in svg:viewBox no width and height is given the objects should normally
866 // not be visible at all, but in this case it is a bug in LO to write empty svg:viewBox
867 // entries for CustomShapes. To allow for a better ODF user experience, just correct this
868 // here by getting the real object scale from the already set transformation from the xShape.
869 // Hopefully LO will fix that bug (but this will still leave the files with the error), but
870 // even when not this will do no harm as long noone uses this state explicitely for some
871 // purpose (e.g. to really have CustomShapes without content, but unlikely).
872 // When they do fix this they will need this fix anyways to read their own misformed ODF files
873 // again, so I guess it will be taken, too...
874 uno::Reference< beans::XPropertySet > xProps(mrxShape, uno::UNO_QUERY_THROW);
875 uno::Any aObjectTransform = xProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")));
876 drawing::HomogenMatrix3 aTransformMatrix;
877 aObjectTransform >>= aTransformMatrix;
878 basegfx::B2DHomMatrix aMatrix;
879
880 aMatrix.set(0, 0, aTransformMatrix.Line1.Column1);
881 aMatrix.set(0, 1, aTransformMatrix.Line1.Column2);
882 aMatrix.set(0, 2, aTransformMatrix.Line1.Column3);
883 aMatrix.set(1, 0, aTransformMatrix.Line2.Column1);
884 aMatrix.set(1, 1, aTransformMatrix.Line2.Column2);
885 aMatrix.set(1, 2, aTransformMatrix.Line2.Column3);
886 aMatrix.set(2, 0, aTransformMatrix.Line3.Column1);
887 aMatrix.set(2, 1, aTransformMatrix.Line3.Column2);
888 aMatrix.set(2, 2, aTransformMatrix.Line3.Column3);
889
890 basegfx::B2DVector aScale, aTranslate;
891 double fRotate, fShearX;
892
893 aMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
894
895 aRect.Width = basegfx::fround(fabs(aScale.getX()));
896 aRect.Height = basegfx::fround(fabs(aScale.getY()));
897 }
898
857 beans::PropertyValue aProp;
858 aProp.Name = EASGet( EAS_ViewBox );
859 aProp.Value <<= aRect;
860 mrCustomShapeGeometry.push_back( aProp );
861 }
862 break;
863 case EAS_text_rotate_angle :
864 GetDouble( mrCustomShapeGeometry, rValue, EAS_TextRotateAngle );

--- 531 unchanged lines hidden ---
899 beans::PropertyValue aProp;
900 aProp.Name = EASGet( EAS_ViewBox );
901 aProp.Value <<= aRect;
902 mrCustomShapeGeometry.push_back( aProp );
903 }
904 break;
905 case EAS_text_rotate_angle :
906 GetDouble( mrCustomShapeGeometry, rValue, EAS_TextRotateAngle );

--- 531 unchanged lines hidden ---