From 1bdc4768e277ada3d227516b6d9a00a411a1294f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 10 Apr 2013 18:43:50 +0200 Subject: fix new-style RTF frame default internal margin values Change-Id: I1a4819905f0fc2e8dbbcf7d9570785ad4384dc39 --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 2 +- writerfilter/source/rtftok/rtfsdrimport.cxx | 24 +++++++++++++----------- writerfilter/source/rtftok/rtfsdrimport.hxx | 8 ++++++-- 3 files changed, 20 insertions(+), 14 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index ed142bd9bbe5..f1268f546d50 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2561,7 +2561,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTF_DPTXBX: { m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.text.TextFrame"), uno::UNO_QUERY); - std::vector aDefaults = m_pSdrImport->getTextFrameDefaults(); + std::vector aDefaults = m_pSdrImport->getTextFrameDefaults(false); for (size_t i = 0; i < aDefaults.size(); ++i) m_aStates.top().aDrawingObject.aPendingProperties.push_back(aDefaults[i]); } diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index b0399f601225..9fbd3c21df78 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -75,7 +75,7 @@ void RTFSdrImport::createShape(OUString aStr, uno::Reference& x xPropertySet.set(xShape, uno::UNO_QUERY); } -std::vector RTFSdrImport::getTextFrameDefaults() +std::vector RTFSdrImport::getTextFrameDefaults(bool bNew) { std::vector aRet; beans::PropertyValue aPropertyValue; @@ -86,20 +86,24 @@ std::vector RTFSdrImport::getTextFrameDefaults() aPropertyValue.Name = "VertOrient"; aPropertyValue.Value <<= text::VertOrientation::NONE; aRet.push_back(aPropertyValue); - aPropertyValue.Name = "BackColorTransparency"; - aPropertyValue.Value <<= sal_Int32(100); - aRet.push_back(aPropertyValue); + if (!bNew) + { + aPropertyValue.Name = "BackColorTransparency"; + aPropertyValue.Value <<= sal_Int32(100); + aRet.push_back(aPropertyValue); + } + // See the spec, new-style frame default margins are specified in EMUs. aPropertyValue.Name = "LeftBorderDistance"; - aPropertyValue.Value <<= sal_Int32(0); + aPropertyValue.Value <<= sal_Int32(bNew ? (91440 / 360) : 0); aRet.push_back(aPropertyValue); aPropertyValue.Name = "RightBorderDistance"; - aPropertyValue.Value <<= sal_Int32(0); + aPropertyValue.Value <<= sal_Int32(bNew ? (91440 / 360) : 0); aRet.push_back(aPropertyValue); aPropertyValue.Name = "TopBorderDistance"; - aPropertyValue.Value <<= sal_Int32(0); + aPropertyValue.Value <<= sal_Int32(bNew ? (45720 / 360) : 0); aRet.push_back(aPropertyValue); aPropertyValue.Name = "BottomBorderDistance"; - aPropertyValue.Value <<= sal_Int32(0); + aPropertyValue.Value <<= sal_Int32(bNew ? (45720 / 360) : 0); aRet.push_back(aPropertyValue); aPropertyValue.Name = "SizeType"; aPropertyValue.Value <<= text::SizeType::FIX; @@ -161,7 +165,7 @@ void RTFSdrImport::resolve(RTFShape& rShape) { createShape("com.sun.star.text.TextFrame", xShape, xPropertySet); bTextFrame = true; - std::vector aDefaults = getTextFrameDefaults(); + std::vector aDefaults = getTextFrameDefaults(true); for (size_t j = 0; j < aDefaults.size(); ++j) xPropertySet->setPropertyValue(aDefaults[j].Name, aDefaults[j].Value); } @@ -205,8 +209,6 @@ void RTFSdrImport::resolve(RTFShape& rShape) // fillType will decide, possible it'll be the start color of a gradient. aFillModel.moColor.set(OUString("#") + OStringToOUString(msfilter::util::ConvertColor(aAny.get()), RTL_TEXTENCODING_UTF8)); - - xPropertySet->setPropertyValue("BackColorTransparency", uno::makeAny(sal_Int32(0))); } else if ( i->first == "fillBackColor" ) // fillType will decide, possible it'll be the end color of a gradient. diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx b/writerfilter/source/rtftok/rtfsdrimport.hxx index 6c39fbce8365..984f28790c58 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.hxx +++ b/writerfilter/source/rtftok/rtfsdrimport.hxx @@ -43,8 +43,12 @@ namespace writerfilter { void resolve(RTFShape& rShape); void resolveDhgt(uno::Reference xPropertySet, sal_Int32 nZOrder); void resolveFLine(uno::Reference xPropertySet, sal_Int32 nFLine); - /// These are the default in Word, but not in Writer. - std::vector getTextFrameDefaults(); + /** + * These are the default in Word, but not in Writer. + * + * @param bNew if the frame is new-style or old-style. + */ + std::vector getTextFrameDefaults(bool bNew); private: void createShape(OUString aService, uno::Reference& xShape, uno::Reference& xPropertySet); -- cgit