diff options
author | os <os@openoffice.org> | 2010-09-23 15:51:45 +0200 |
---|---|---|
committer | os <os@openoffice.org> | 2010-09-23 15:51:45 +0200 |
commit | 0222f284c1646b2a467e1006e2c297643eb39448 (patch) | |
tree | f8e7390d3ce215761b9d3e018db6b4892a1a636c /sw | |
parent | 9fe0eea973982c11997051e271258301b955947a (diff) |
shape properties wzDescription and wzName support added
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unoframe.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/rtf/makefile.mk | 3 | ||||
-rw-r--r-- | sw/source/filter/rtf/rtffly.cxx | 23 | ||||
-rw-r--r-- | sw/source/filter/rtf/swparrtf.cxx | 19 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 46 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.hxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.hxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfsdrexport.cxx | 15 |
9 files changed, 97 insertions, 24 deletions
diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 65de34a4db7f..9323d209c19a 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -161,7 +161,7 @@ public: void ResetDescriptor(); //copy text from a given source PaM void SetSelection(SwPaM& rCopySource); - static SdrObject *GetOrCreateSdrObject( SwFlyFrmFmt *pFmt ); + static SW_DLLPUBLIC SdrObject *GetOrCreateSdrObject( SwFlyFrmFmt *pFmt ); }; /*-----------------20.02.98 11:28------------------- diff --git a/sw/source/filter/rtf/makefile.mk b/sw/source/filter/rtf/makefile.mk index e8e6a598ed50..405de430cf21 100644 --- a/sw/source/filter/rtf/makefile.mk +++ b/sw/source/filter/rtf/makefile.mk @@ -46,7 +46,8 @@ CDEFS=$(CDEFS) -Dmydebug EXCEPTIONSFILES= \ $(SLO)$/rtffly.obj \ $(SLO)$/rtfnum.obj \ - $(SLO)$/swparrtf.obj + $(SLO)$/swparrtf.obj \ + $(SLO)$/rtffld.obj SLOFILES = \ diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index 76adc1197305..5303ad26dcba 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -61,6 +61,7 @@ #include <txtflcnt.hxx> #include <fmtflcnt.hxx> #include <fltini.hxx> +#include <unoframe.hxx> #include <deque> #include <map> #include <utility> @@ -1293,7 +1294,7 @@ void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf, aFlySet.Put(aSurroundItem); } - SwFrmFmt* pFlyFmt = pDoc->Insert( *pPam, + SwFlyFrmFmt* pFlyFmt = pDoc->Insert( *pPam, rGrfNm, aEmptyStr, // Name der Graphic !! pGrf, &aFlySet, // Attribute fuer den FlyFrm @@ -1305,6 +1306,26 @@ void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf, _SetPictureSize( *pGrfNd, pPos->nNode, (SfxItemSet&)pFlyFmt->GetAttrSet(), pPicType ); + if( pPicType ) + { + PictPropertyNameValuePairs::const_iterator aIt = pPicType->aPropertyPairs.begin(); + PictPropertyNameValuePairs::const_iterator aEnd = pPicType->aPropertyPairs.end(); + while( aIt != aEnd) + { + if( aIt->first.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "wzDescription") )) + { + SwXFrame::GetOrCreateSdrObject( pFlyFmt ); + pDoc->SetFlyFrmDescription( *(pFlyFmt), aIt->second ); + } + else if( aIt->first.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "wzName") )) + { + SwXFrame::GetOrCreateSdrObject( pFlyFmt ); + pDoc->SetFlyFrmTitle( *(pFlyFmt), aIt->second ); + } + ++aIt; + } + } + } if( pGrfAttrSet ) diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 4ae4f4bc88b2..63f5debd521b 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -1376,6 +1376,7 @@ void SwRTFParser::ReadShapeObject() String shpTxt; bool bshpTxt=false; int txflTextFlow=0; + ::rtl::OUString sDescription, sName; while (level>0 && IsParserWorking()) @@ -1433,7 +1434,14 @@ void SwRTFParser::ReadShapeObject() { txflTextFlow=aToken.ToInt32(); } - + else if (sn.EqualsAscii("wzDescription")) + { + sDescription = aToken; + } + else if(sn.EqualsAscii("wzName")) + { + sName = aToken; + } } break; case RTF_PICT: @@ -1459,6 +1467,7 @@ void SwRTFParser::ReadShapeObject() } SkipToken(-1); + SdrObject* pSdrObject = 0; switch(shapeType) { case 202: /* Text Box */ @@ -1478,6 +1487,7 @@ void SwRTFParser::ReadShapeObject() const Rectangle aRect(FRound(aRange.getMinX()), FRound(aRange.getMinY()), FRound(aRange.getMaxX()), FRound(aRange.getMaxY())); SdrRectObj* pStroke = new SdrRectObj(aRect); + pSdrObject = pStroke; pStroke->SetSnapRect(aRect); pDoc->GetOrCreateDrawModel(); // create model InsertShpObject(pStroke, this->nZOrder++); @@ -1525,6 +1535,7 @@ void SwRTFParser::ReadShapeObject() aLine.append(aPointRightBottom); SdrPathObj* pStroke = new SdrPathObj(OBJ_PLIN, ::basegfx::B2DPolyPolygon(aLine)); + pSdrObject = pStroke; //pStroke->SetSnapRect(aRect); InsertShpObject(pStroke, this->nZOrder++); @@ -1545,11 +1556,17 @@ void SwRTFParser::ReadShapeObject() const Rectangle aRect(FRound(aRange.getMinX()), FRound(aRange.getMinY()), FRound(aRange.getMaxX()), FRound(aRange.getMaxY())); SdrRectObj* pStroke = new SdrGrafObj(aGrf); + pSdrObject = pStroke; pStroke->SetSnapRect(aRect); InsertShpObject(pStroke, this->nZOrder++); } } + if( pSdrObject ) + { + pSdrObject->SetDescription(sDescription); + pSdrObject->SetTitle(sName); + } } extern void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich, diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index c88e4df0788e..e7a36511d3d3 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -1457,7 +1457,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi } if ( pGrfNode ) - FlyFrameGraphic( *pGrfNode, rFrame.GetLayoutSize() ); + FlyFrameGraphic( dynamic_cast<const SwFlyFrmFmt*>( &rFrame.GetFrmFmt() ), *pGrfNode, rFrame.GetLayoutSize() ); break; case sw::Frame::eDrawing: { @@ -1694,7 +1694,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi { SwNodeIndex aIdx(*rFrmFmt.GetCntnt().GetCntntIdx(), 1); SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode(); - FlyFrameOLE(rOLENd, rFrame.GetLayoutSize()); + FlyFrameOLE(dynamic_cast<const SwFlyFrmFmt*>( &rFrmFmt ), rOLENd, rFrame.GetLayoutSize()); } } break; @@ -3107,9 +3107,23 @@ static OString WriteHex(OString sString) return aRet.makeStringAndClear(); } -static OString ExportPICT(const Size &rOrig, const Size &rRendered, const Size &rMapped, +void lcl_AppendSP( OStringBuffer& rBuffer, + const char cName[], + const ::rtl::OUString& rValue, + const RtfExport& rExport ) +{ + rBuffer.append( "{" OOO_STRING_SVTOOLS_RTF_SP "{" ); // "{\sp{" + rBuffer.append( OOO_STRING_SVTOOLS_RTF_SN " " );//" \sn " + rBuffer.append( cName ); //"PropName" + rBuffer.append( "}{" OOO_STRING_SVTOOLS_RTF_SV " " ); +// "}{ \sv " + rBuffer.append( rExport.OutString( rValue, rExport.eCurrentEncoding ) ); + rBuffer.append( "}}" ); +} + +static OString ExportPICT( const SwFlyFrmFmt* pFlyFrmFmt, const Size &rOrig, const Size &rRendered, const Size &rMapped, const SwCropGrf &rCr, const char *pBLIPType, const sal_uInt8 *pGraphicAry, - unsigned long nSize) + unsigned long nSize, const RtfExport& rExport ) { OStringBuffer aRet; bool bIsWMF = (const char *)pBLIPType == (const char *)OOO_STRING_SVTOOLS_RTF_WMETAFILE ? true : false; @@ -3117,6 +3131,18 @@ static OString ExportPICT(const Size &rOrig, const Size &rRendered, const Size & { aRet.append("{" OOO_STRING_SVTOOLS_RTF_PICT); + if( pFlyFrmFmt ) + { + String sDescription = pFlyFrmFmt->GetObjDescription(); + //write picture properties - wzDescription at first + //looks like: "{\*\picprop{\sp{\sn PropertyName}{\sv PropertyValue}}}" + aRet.append( "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_PICPROP );//"{\*\picprop + lcl_AppendSP( aRet, "wzDescription", sDescription, rExport ); + String sName = pFlyFrmFmt->GetObjTitle(); + lcl_AppendSP( aRet, "wzName", sName, rExport ); + aRet.append( "}" ); //"}" + } + long nXCroppedSize = rOrig.Width()-(rCr.GetLeft() + rCr.GetRight()); long nYCroppedSize = rOrig.Height()-(rCr.GetTop() + rCr.GetBottom()); /* #127543#: Graphic with a zero height or width, typically copied from webpages, caused @@ -3209,7 +3235,7 @@ void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode ) } } -void RtfAttributeOutput::FlyFrameOLE( SwOLENode& rOLENode, const Size& rSize ) +void RtfAttributeOutput::FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize ) { OSL_TRACE("%s", OSL_THIS_FUNC); @@ -3245,11 +3271,11 @@ void RtfAttributeOutput::FlyFrameOLE( SwOLENode& rOLENode, const Size& rSize ) nHeight-=nFontHeight/20; m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_DN).append(nHeight); m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT); - m_aRunText.append(ExportPICT(aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize)); + m_aRunText.append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport )); m_aRunText.append("}}}}"); } -void RtfAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize ) +void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode& rGrfNode, const Size& rSize ) { OSL_TRACE("%s", OSL_THIS_FUNC); @@ -3322,7 +3348,7 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT); if (pBLIPType) - m_aRunText.append(ExportPICT(aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize)); + m_aRunText.append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport)); else { aStream.Seek(0); @@ -3332,7 +3358,7 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& nSize = aStream.Tell(); pGraphicAry = (sal_uInt8*)aStream.GetData(); - m_aRunText.append(ExportPICT(aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize)); + m_aRunText.append(ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport )); } if (!bIsWMF) @@ -3346,7 +3372,7 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& nSize = aStream.Tell(); pGraphicAry = (sal_uInt8*)aStream.GetData(); - m_aRunText.append(ExportPICT(aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize)); + m_aRunText.append(ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport )); m_aRunText.append('}'); } diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index b9d02fcafc1c..c5522f22fbd6 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -45,6 +45,7 @@ class RtfExport; class SwGrfNode; class SwOLENode; class SdrObject; +class SwFlyFrmFmt; class RtfAttributeOutput : public AttributeOutputBase { @@ -429,8 +430,8 @@ protected: private: /// Output graphic fly frames. - void FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize ); - void FlyFrameOLE( SwOLENode& rOLENode, const Size& rSize ); + void FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode& rGrfNode, const Size& rSize ); + void FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize ); void FlyFrameOLEData( SwOLENode& rOLENode ); /* diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 1dd1d898f8af..cf49a3868476 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -920,7 +920,7 @@ OString RtfExport::OutChar(sal_Unicode c, int *pUCMode, rtl_TextEncoding eDestEn OString RtfExport::OutString(const String &rStr, rtl_TextEncoding eDestEnc) { OSL_TRACE("%s, rStr = '%s'", OSL_THIS_FUNC, - OUStringToOString( OUString( rStr ), eCurrentEncoding ).getStr()); + OUStringToOString( OUString( rStr ), eDestEnc ).getStr()); OStringBuffer aBuf; int nUCMode = 1; for (xub_StrLen n = 0; n < rStr.Len(); ++n) diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx index 8e56936efe91..f02ed41bf98e 100644 --- a/sw/source/filter/ww8/rtfexport.hxx +++ b/sw/source/filter/ww8/rtfexport.hxx @@ -170,9 +170,9 @@ public: SvStream& OutLong( long nVal ); void OutUnicode(const sal_Char *pToken, const String &rContent); void OutDateTime(const sal_Char* pStr, const util::DateTime& rDT ); - rtl::OString OutChar(sal_Unicode c, int *pUCMode, rtl_TextEncoding eDestEnc); - rtl::OString OutString(const String &rStr, rtl_TextEncoding eDestEnc); - rtl::OString OutHex(ULONG nHex, BYTE nLen); + static rtl::OString OutChar(sal_Unicode c, int *pUCMode, rtl_TextEncoding eDestEnc); + static rtl::OString OutString(const String &rStr, rtl_TextEncoding eDestEnc); + static rtl::OString OutHex(ULONG nHex, BYTE nLen); void OutPageDescription( const SwPageDesc& rPgDsc, BOOL bWriteReset, BOOL bCheckForFirstPage ); void OutContent( const SwNode& rNode ); diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index c4ad956ae71f..519def72403f 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -447,6 +447,13 @@ void RtfSdrExport::AddShapeAttribute( sal_Int32 /*nAttribute*/, const rtl::OStri extern const char* pShapeTypes[]; +void lcl_AppendSP( ::rtl::OStringBuffer& rRunText, const char cName[], const ::rtl::OString& rValue) +{ + rRunText.append('{').append(OOO_STRING_SVTOOLS_RTF_SP) + .append('{').append(OOO_STRING_SVTOOLS_RTF_SN " ").append(cName).append('}') + .append('{').append(OOO_STRING_SVTOOLS_RTF_SV " ").append(rValue).append('}') + .append('}'); +} sal_Int32 RtfSdrExport::StartShape() { OSL_TRACE("%s", OSL_THIS_FUNC); @@ -466,10 +473,10 @@ sal_Int32 RtfSdrExport::StartShape() m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE); for(std::map<OString,OString>::reverse_iterator i = m_aShapeProps.rbegin(); i != m_aShapeProps.rend(); i++) - m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SP) - .append('{').append(OOO_STRING_SVTOOLS_RTF_SN " ").append((*i).first).append('}') - .append('{').append(OOO_STRING_SVTOOLS_RTF_SV " ").append((*i).second).append('}') - .append('}'); + lcl_AppendSP(m_rAttrOutput.RunText(), (*i).first, (*i).second ); + + lcl_AppendSP(m_rAttrOutput.RunText(), "wzDescription", RtfExport::OutString( m_pSdrObject->GetDescription(), m_rExport.eCurrentEncoding)); + lcl_AppendSP(m_rAttrOutput.RunText(), "wzName", RtfExport::OutString( m_pSdrObject->GetTitle(), m_rExport.eCurrentEncoding)); // now check if we have some text const SdrTextObj* pTxtObj = PTR_CAST(SdrTextObj, m_pSdrObject); |