filter/inc/filter/msfilter/util.hxx | 2 filter/source/msfilter/util.cxx | 11 +++ sw/source/filter/ww8/ww8par6.cxx | 17 ----- sw/source/filter/ww8/ww8struc.hxx | 4 - writerfilter/source/rtftok/rtfdocumentimpl.cxx | 77 ++++++++++++++++++++++--- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 5 + writerfilter/source/rtftok/rtfsdrimport.cxx | 17 ----- 7 files changed, 95 insertions(+), 38 deletions(-)
New commits: commit c450ea69921001621a1114369b3508bfa69bd088 Author: Miklos Vajna <vmik...@suse.cz> Date: Mon May 7 09:32:48 2012 +0200 introduce msfilter::util::BGRToRGB to avoid copy&paste Change-Id: Ic3fa8865bf3862407867b5e4a438e3d9bc723e86 diff --git a/filter/inc/filter/msfilter/util.hxx b/filter/inc/filter/msfilter/util.hxx index 01ff373..2dc5fa7 100644 --- a/filter/inc/filter/msfilter/util.hxx +++ b/filter/inc/filter/msfilter/util.hxx @@ -41,6 +41,8 @@ namespace util { /// what the encoding is, but you know or can guess the language MSFILTER_DLLPUBLIC rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Locale &rLocale); +/// Convert a color in BGR format to RGB. +MSFILTER_DLLPUBLIC sal_uInt32 BGRToRGB(sal_uInt32 nColour); } } diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index 76fe07c..03df8af 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -51,6 +51,17 @@ rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Loc return RTL_TEXTENCODING_MS_1252; } +sal_uInt32 BGRToRGB(sal_uInt32 nColor) +{ + sal_uInt8 + r(static_cast<sal_uInt8>(nColor&0xFF)), + g(static_cast<sal_uInt8>(((nColor)>>8)&0xFF)), + b(static_cast<sal_uInt8>((nColor>>16)&0xFF)), + t(static_cast<sal_uInt8>((nColor>>24)&0xFF)); + nColor = (t<<24) + (r<<16) + (g<<8) + b; + return nColor; +} + } } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 8a71999..d0a94a1 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -3363,24 +3363,13 @@ void SwWW8ImplReader::Read_TxtColor( sal_uInt16, const sal_uInt8* pData, short n } } -sal_uInt32 wwUtility::BGRToRGB(sal_uInt32 nColor) -{ - sal_uInt8 - r(static_cast<sal_uInt8>(nColor&0xFF)), - g(static_cast<sal_uInt8>(((nColor)>>8)&0xFF)), - b(static_cast<sal_uInt8>((nColor>>16)&0xFF)), - t(static_cast<sal_uInt8>((nColor>>24)&0xFF)); - nColor = (t<<24) + (r<<16) + (g<<8) + b; - return nColor; -} - void SwWW8ImplReader::Read_TxtForeColor(sal_uInt16, const sal_uInt8* pData, short nLen) { if( nLen < 0 ) pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR ); else { - Color aColor(wwUtility::BGRToRGB(SVBT32ToUInt32(pData))); + Color aColor(msfilter::util::BGRToRGB(SVBT32ToUInt32(pData))); NewAttr(SvxColorItem(aColor, RES_CHRATR_COLOR)); if (pAktColl && pStyles) pStyles->bTxtColChanged = true; @@ -4663,9 +4652,9 @@ sal_uInt32 SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67) { (void) bVer67; // unused in non-debug OSL_ENSURE(bVer67 == false, "Impossible"); - sal_uInt32 nFore = wwUtility::BGRToRGB(SVBT32ToUInt32(rpData)); + sal_uInt32 nFore = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData)); rpData+=4; - sal_uInt32 nBack = wwUtility::BGRToRGB(SVBT32ToUInt32(rpData)); + sal_uInt32 nBack = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData)); rpData+=4; sal_uInt16 nIndex = SVBT16ToShort(rpData); rpData+=2; diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx index 3790ebf..98dff63 100644 --- a/sw/source/filter/ww8/ww8struc.hxx +++ b/sw/source/filter/ww8/ww8struc.hxx @@ -34,6 +34,7 @@ #include <sal/config.h> #include <editeng/borderline.hxx> +#include <filter/msfilter/util.hxx> #if defined OSL_BIGENDIAN || SAL_TYPES_ALIGNMENT4 > 2 || defined UNX # define __WW8_NEEDS_COPY @@ -978,8 +979,7 @@ struct SEPr namespace wwUtility { - sal_uInt32 BGRToRGB(sal_uInt32 nColour); - inline sal_uInt32 RGBToBGR(sal_uInt32 nColour) { return BGRToRGB(nColour); } + inline sal_uInt32 RGBToBGR(sal_uInt32 nColour) { return msfilter::util::BGRToRGB(nColour); } } #endif diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 01b1d00..4fc0453 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -35,6 +35,7 @@ #include <ooxml/resourceids.hxx> // NS_ooxml namespace #include <filter/msfilter/escherex.hxx> +#include <filter/msfilter/util.hxx> #include <rtfsdrimport.hxx> @@ -44,18 +45,6 @@ using rtl::OUString; using rtl::OUStringBuffer; using rtl::OUStringToOString; -// NEEDSWORK: wwUtility::BGRToRGB does the same. -static sal_uInt32 lcl_BGRToRGB(sal_uInt32 nColor) -{ - sal_uInt8 - r(static_cast<sal_uInt8>(nColor&0xFF)), - g(static_cast<sal_uInt8>(((nColor)>>8)&0xFF)), - b(static_cast<sal_uInt8>((nColor>>16)&0xFF)), - t(static_cast<sal_uInt8>((nColor>>24)&0xFF)); - nColor = (t<<24) + (r<<16) + (g<<8) + b; - return nColor; -} - namespace writerfilter { namespace rtftok { @@ -132,14 +121,14 @@ void RTFSdrImport::resolve(RTFShape& rShape) } else if (i->first == "fillColor" && xPropertySet.is()) { - aAny <<= lcl_BGRToRGB(i->second.toInt32()); + aAny <<= msfilter::util::BGRToRGB(i->second.toInt32()); xPropertySet->setPropertyValue("FillColor", aAny); } else if ( i->first == "fillBackColor" ) ; // Ignore: complementer of fillColor else if (i->first == "lineColor" && xPropertySet.is()) { - aAny <<= lcl_BGRToRGB(i->second.toInt32()); + aAny <<= msfilter::util::BGRToRGB(i->second.toInt32()); xPropertySet->setPropertyValue("LineColor", aAny); } else if ( i->first == "lineBackColor" ) commit 71bf95db0bf87424678ce62d526e14848cdafec7 Author: Miklos Vajna <vmik...@suse.cz> Date: Mon May 7 09:31:00 2012 +0200 implement RTF_DPFILLBGCR/G/B Change-Id: I Ie4df6921201b2be4e7d9aa3febd1dcdc1e3eef40 diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index be1d9bd..d8fa4c3 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2840,6 +2840,15 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) case RTF_DPLINECOB: m_aStates.top().aDrawingObject.nLineColorB = nParam; m_aStates.top().aDrawingObject.bHasLineColor = true; break; + case RTF_DPFILLBGCR: + m_aStates.top().aDrawingObject.nFillColorR = nParam; m_aStates.top().aDrawingObject.bHasFillColor = true; + break; + case RTF_DPFILLBGCG: + m_aStates.top().aDrawingObject.nFillColorG = nParam; m_aStates.top().aDrawingObject.bHasFillColor = true; + break; + case RTF_DPFILLBGCB: + m_aStates.top().aDrawingObject.nFillColorB = nParam; m_aStates.top().aDrawingObject.bHasFillColor = true; + break; default: SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle value '" << lcl_RtfToString(nKeyword) << "'"); aSkip.setParsed(false); @@ -3339,12 +3348,15 @@ int RTFDocumentImpl::popState() uno::Reference<drawing::XShape> xShape(rDrawing.xShape); xShape->setPosition(awt::Point(rDrawing.nLeft, rDrawing.nTop)); xShape->setSize(awt::Size(rDrawing.nRight, rDrawing.nBottom)); + uno::Reference<beans::XPropertySet> xPropertySet(rDrawing.xPropertySet); if (rDrawing.bHasLineColor) - { - uno::Reference<beans::XPropertySet> xPropertySet(rDrawing.xPropertySet); xPropertySet->setPropertyValue("LineColor", uno::makeAny(sal_uInt32((rDrawing.nLineColorR<<16) + (rDrawing.nLineColorG<<8) + rDrawing.nLineColorB))); - } + if (rDrawing.bHasFillColor) + xPropertySet->setPropertyValue("FillColor", uno::makeAny(sal_uInt32((rDrawing.nFillColorR<<16) + (rDrawing.nFillColorG<<8) + rDrawing.nFillColorB))); + else + // If there is no fill, the Word default is 100% transparency. + xPropertySet->setPropertyValue("FillTransparence", uno::makeAny(sal_Int32(100))); Mapper().startShape(xShape); Mapper().endShape(); @@ -3657,7 +3669,11 @@ RTFDrawingObject::RTFDrawingObject() : nLineColorR(0), nLineColorG(0), nLineColorB(0), - bHasLineColor(false) + bHasLineColor(false), + nFillColorR(0), + nFillColorG(0), + nFillColorB(0), + bHasFillColor(false) { } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index d516268..1c7b9ec 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -203,6 +203,8 @@ namespace writerfilter { std::vector<beans::PropertyValue> aPendingProperties; sal_uInt8 nLineColorR, nLineColorG, nLineColorB; bool bHasLineColor; + sal_uInt8 nFillColorR, nFillColorG, nFillColorB; + bool bHasFillColor; }; /// Stores the properties of a picture. commit 4485ff1b51c121627cf30ef219d48614a4de895b Author: Miklos Vajna <vmik...@suse.cz> Date: Mon May 7 09:30:47 2012 +0200 implement RTF_DPLINECOR/G/B Change-Id: I179472754f63559668ff918fd2a01331cd3c35bb diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index f23408a..be1d9bd 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2831,6 +2831,15 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().nInternalState = INTERNAL_BIN; m_aStates.top().nBinaryToRead = nParam; break; + case RTF_DPLINECOR: + m_aStates.top().aDrawingObject.nLineColorR = nParam; m_aStates.top().aDrawingObject.bHasLineColor = true; + break; + case RTF_DPLINECOG: + m_aStates.top().aDrawingObject.nLineColorG = nParam; m_aStates.top().aDrawingObject.bHasLineColor = true; + break; + case RTF_DPLINECOB: + m_aStates.top().aDrawingObject.nLineColorB = nParam; m_aStates.top().aDrawingObject.bHasLineColor = true; + break; default: SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle value '" << lcl_RtfToString(nKeyword) << "'"); aSkip.setParsed(false); @@ -3330,6 +3339,13 @@ int RTFDocumentImpl::popState() uno::Reference<drawing::XShape> xShape(rDrawing.xShape); xShape->setPosition(awt::Point(rDrawing.nLeft, rDrawing.nTop)); xShape->setSize(awt::Size(rDrawing.nRight, rDrawing.nBottom)); + + if (rDrawing.bHasLineColor) + { + uno::Reference<beans::XPropertySet> xPropertySet(rDrawing.xPropertySet); + xPropertySet->setPropertyValue("LineColor", uno::makeAny(sal_uInt32((rDrawing.nLineColorR<<16) + (rDrawing.nLineColorG<<8) + rDrawing.nLineColorB))); + } + Mapper().startShape(xShape); Mapper().endShape(); } @@ -3637,6 +3653,14 @@ RTFPicture::RTFPicture() { } +RTFDrawingObject::RTFDrawingObject() + : nLineColorR(0), + nLineColorG(0), + nLineColorB(0), + bHasLineColor(false) +{ +} + RTFFrame::RTFFrame(RTFParserState* pParserState) : m_pParserState(pParserState), nX(0), diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index d47ab1a..d516268 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -197,9 +197,12 @@ namespace writerfilter { class RTFDrawingObject : public RTFShape { public: + RTFDrawingObject(); uno::Reference<drawing::XShape> xShape; uno::Reference<beans::XPropertySet> xPropertySet; std::vector<beans::PropertyValue> aPendingProperties; + sal_uInt8 nLineColorR, nLineColorG, nLineColorB; + bool bHasLineColor; }; /// Stores the properties of a picture. commit 57be17df8f9d69761e648cd1ccd6d6f0084e569a Author: Miklos Vajna <vmik...@suse.cz> Date: Mon May 7 09:30:12 2012 +0200 rtftok: implement RTF_DPRECT Change-Id: Iffc00526bd780e19daccea226735b4c4e28bf9c6 diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index fa59904..f23408a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp> #include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/io/UnexpectedEOFException.hpp> #include <com/sun/star/text/XTextFrame.hpp> @@ -46,6 +47,7 @@ #include <svtools/grfmgr.hxx> #include <vcl/svapp.hxx> #include <filter/msfilter/util.hxx> +#include <filter/msfilter/escherex.hxx> #include <doctok/sprmids.hxx> // NS_sprm namespace #include <doctok/resourceids.hxx> // NS_rtf namespace @@ -2071,8 +2073,34 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTF_POSXR: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_right); break; case RTF_DPLINE: + case RTF_DPRECT: { - m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.drawing.LineShape"), uno::UNO_QUERY); + sal_Int32 nType = 0; + switch (nKeyword) + { + case RTF_DPLINE: + m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.drawing.LineShape"), uno::UNO_QUERY); + break; + case RTF_DPRECT: + nType = ESCHER_ShpInst_Rectangle; + break; + default: + break; + } + if (nType) + m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.drawing.CustomShape"), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier( m_xDstDoc, uno::UNO_QUERY); + if (xDrawSupplier.is()) + { + uno::Reference<drawing::XShapes> xShapes(xDrawSupplier->getDrawPage(), uno::UNO_QUERY); + if (xShapes.is()) + xShapes->add(m_aStates.top().aDrawingObject.xShape); + } + if (nType) + { + uno::Reference<drawing::XEnhancedCustomShapeDefaulter> xDefaulter(m_aStates.top().aDrawingObject.xShape, uno::UNO_QUERY); + xDefaulter->createCustomShapeDefaults(OUString::valueOf(nType)); + } m_aStates.top().aDrawingObject.xPropertySet.set(m_aStates.top().aDrawingObject.xShape, uno::UNO_QUERY); std::vector<beans::PropertyValue>& rPendingProperties = m_aStates.top().aDrawingObject.aPendingProperties; for (std::vector<beans::PropertyValue>::iterator i = rPendingProperties.begin(); i != rPendingProperties.end(); ++i) @@ -3302,13 +3330,6 @@ int RTFDocumentImpl::popState() uno::Reference<drawing::XShape> xShape(rDrawing.xShape); xShape->setPosition(awt::Point(rDrawing.nLeft, rDrawing.nTop)); xShape->setSize(awt::Size(rDrawing.nRight, rDrawing.nBottom)); - uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier( m_xDstDoc, uno::UNO_QUERY); - if ( xDrawSupplier.is() ) - { - uno::Reference< drawing::XShapes > xShapes( xDrawSupplier->getDrawPage(), uno::UNO_QUERY ); - if ( xShapes.is() ) - xShapes->add( xShape ); - } Mapper().startShape(xShape); Mapper().endShape(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits