oox/source/shape/WpsContext.cxx | 33 +++++++++++++++++++++++++--- sw/qa/extras/ooxmlimport/data/tdf87924.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 8 ++++++ sw/source/uibase/shells/textsh.cxx | 13 +++++------ 4 files changed, 44 insertions(+), 10 deletions(-)
New commits: commit dbfed66eebde65f5844a0f1a2cfe548ad4eda962 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Aug 3 09:19:17 2015 +0200 tdf#87924 DOCX import: rot=90 and vert=vert270 means no text rotation If the shape is rotated 90 degrees clockwise and the text is further rotated 270 degrees clockwise that means we shouldn't do anything with the text and the result will be correct. Change-Id: I7c65319258136288520bd24fa2bf8e3c598b0878 diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index a22d6b8..9616e0b 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -13,6 +13,9 @@ #include <drawingml/shapestylecontext.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/drawing/HomogenMatrix3.hpp> +#include <basegfx/tuple/b2dtuple.hxx> +#include <svx/svdtrans.hxx> #include <boost/optional.hpp> @@ -76,9 +79,33 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken } else { - comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry")); - aCustomShapeGeometry["TextPreRotateAngle"] = uno::makeAny(sal_Int32(-270)); - xPropertySet->setPropertyValue("CustomShapeGeometry", uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList())); + // Get the existing rotation of the shape. + drawing::HomogenMatrix3 aMatrix; + xPropertySet->getPropertyValue("Transformation") >>= aMatrix; + basegfx::B2DHomMatrix aTransformation; + aTransformation.set(0, 0, aMatrix.Line1.Column1); + aTransformation.set(0, 1, aMatrix.Line1.Column2); + aTransformation.set(0, 2, aMatrix.Line1.Column3); + aTransformation.set(1, 0, aMatrix.Line1.Column1); + aTransformation.set(1, 1, aMatrix.Line2.Column2); + aTransformation.set(1, 2, aMatrix.Line3.Column3); + aTransformation.set(2, 0, aMatrix.Line1.Column1); + aTransformation.set(2, 1, aMatrix.Line2.Column2); + aTransformation.set(2, 2, aMatrix.Line3.Column3); + basegfx::B2DTuple aScale; + basegfx::B2DTuple aTranslate; + double fRotate = 0; + double fShearX = 0; + aTransformation.decompose(aScale, aTranslate, fRotate, fShearX); + + // If the text is not rotated the way the shape wants it already, set the angle. + const sal_Int32 nRotation = -270; + if (basegfx::rad2deg(fRotate) != NormAngle360(nRotation * 100) / 100) + { + comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry")); + aCustomShapeGeometry["TextPreRotateAngle"] = uno::makeAny(nRotation); + xPropertySet->setPropertyValue("CustomShapeGeometry", uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList())); + } } } diff --git a/sw/qa/extras/ooxmlimport/data/tdf87924.docx b/sw/qa/extras/ooxmlimport/data/tdf87924.docx new file mode 100644 index 0000000..5265d66 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf87924.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 4a8d1a9..820d6f5 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2758,6 +2758,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf86374, "tdf86374.docx") CPPUNIT_ASSERT_EQUAL(text::SizeType::MIN, getProperty<sal_Int16>(xTableRows->getByIndex(0), "SizeType")); } +DECLARE_OOXMLIMPORT_TEST(testTdf87924, "tdf87924.docx") +{ + uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY); + comphelper::SequenceAsHashMap aGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry")); + // This was -270, the text rotation angle was set when it should not be rotated. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aGeometry["TextPreRotateAngle"].get<sal_Int32>()); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); commit 53e535821344549c2a1f5adf3d1bdbc2a0582492 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Aug 3 09:02:30 2015 +0200 sw: boost::scoped_ptr -> std::unique_ptr in textsh Change-Id: I60eb5e1bca50d0e35f0bec63f0e274bee68fc5f7 diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index 39d60ed..b479261 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -116,7 +116,6 @@ using namespace ::com::sun::star; #include <unomid.h> #include <IDocumentDrawModelAccess.hxx> #include <drawdoc.hxx> -#include <boost/scoped_ptr.hpp> SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell) @@ -578,10 +577,10 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "Dialog creation failed!"); - boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateFrmTabDialog("FrameDialog", - GetView().GetViewFrame(), - &GetView().GetViewFrame()->GetWindow(), - aSet, true)); + std::unique_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateFrmTabDialog("FrameDialog", + GetView().GetViewFrame(), + &GetView().GetViewFrame()->GetWindow(), + aSet, true)); OSL_ENSURE(pDlg, "Dialog creation failed!"); if(pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet()) { @@ -631,7 +630,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "Dialog creation failed!"); - boost::scoped_ptr<VclAbstractDialog> pColDlg(pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_COLUMN)); + std::unique_ptr<VclAbstractDialog> pColDlg(pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_COLUMN)); OSL_ENSURE(pColDlg, "Dialog creation failed!"); pColDlg->Execute(); } @@ -1034,7 +1033,7 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq ) aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont.GetFamilyName() ) ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact->CreateSfxDialog( GetView().GetWindow(), aAllSet, + std::unique_ptr<SfxAbstractDialog> pDlg(pFact->CreateSfxDialog( GetView().GetWindow(), aAllSet, GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP )); if( RET_OK == pDlg->Execute() ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits