From 710128334ee6f2dd538a67d2ecaf2d7b07bb6868 Mon Sep 17 00:00:00 2001 From: ka Date: Fri, 4 Feb 2011 14:49:25 +0100 Subject: ka102: SVG import implementation --- svx/inc/svx/svdograf.hxx | 1 + svx/source/dialog/_bmpmask.cxx | 3 +++ svx/source/gallery2/galtheme.cxx | 1 + svx/source/svdraw/svdedtv.cxx | 6 +++++- svx/source/svdraw/svdfmtf.cxx | 25 +++++++++++++++++++++++-- svx/source/svdraw/svdfmtf.hxx | 1 + svx/source/svdraw/svdograf.cxx | 18 ++++++++++++------ svx/source/xml/xmlgrhlp.cxx | 9 +++++---- 8 files changed, 51 insertions(+), 13 deletions(-) (limited to 'svx') diff --git a/svx/inc/svx/svdograf.hxx b/svx/inc/svx/svdograf.hxx index 1eba8822402a..c76c77ec325a 100644 --- a/svx/inc/svx/svdograf.hxx +++ b/svx/inc/svx/svdograf.hxx @@ -148,6 +148,7 @@ public: // Keep ATM for SD. sal_Bool IsAnimated() const; sal_Bool IsEPS() const; + sal_Bool IsRenderGraphic() const; sal_Bool IsSwappedOut() const; const MapMode& GetGrafPrefMapMode() const; diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx index d010109d34b3..71b50a93f894 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -1001,6 +1001,9 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) default: { + OSL_ENSURE( pAction->GetType() != META_RENDERGRAPHIC_ACTION, + "META_RENDERGRAPHIC_ACTION currently not supported at masking" ); + pAction->Duplicate(); aMtf.AddAction( pAction ); } diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index 730c1179a07e..9e34e463c805 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -901,6 +901,7 @@ BOOL GalleryTheme::InsertGraphic( const Graphic& rGraphic, ULONG nInsertPos ) case( GFX_LINK_TYPE_NATIVE_WMF ): nExportFormat = CVT_WMF; break; case( GFX_LINK_TYPE_NATIVE_MET ): nExportFormat = CVT_MET; break; case( GFX_LINK_TYPE_NATIVE_PCT ): nExportFormat = CVT_PCT; break; + case( GFX_LINK_TYPE_NATIVE_SVG ): nExportFormat = CVT_SVG; break; default: break; } diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index d2c1e7bc52ef..05d7c7711430 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -644,8 +644,12 @@ void SdrEditView::CheckPossibilities() BOOL bGraf=HAS_BASE(SdrGrafObj,pObj); BOOL bOle2=HAS_BASE(SdrOle2Obj,pObj); - if( bGraf && ((SdrGrafObj*)pObj)->HasGDIMetaFile() && !((SdrGrafObj*)pObj)->IsEPS() ) + if( bGraf && + ((SdrGrafObj*)pObj)->HasGDIMetaFile() && + !( ((SdrGrafObj*)pObj)->IsEPS() || ((SdrGrafObj*)pObj)->IsRenderGraphic() ) ) + { bImportMtfPossible = TRUE; + } if (bOle2) bImportMtfPossible=((SdrOle2Obj*)pObj)->GetObjRef().is(); diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index f10610317578..cf282aab3dc7 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -195,7 +195,7 @@ ULONG ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, case META_POP_ACTION : DoAction((MetaPopAction &)*pAct); break; case META_HATCH_ACTION : DoAction((MetaHatchAction &)*pAct); break; case META_COMMENT_ACTION : DoAction((MetaCommentAction &)*pAct, pMtf); break; - + case META_RENDERGRAPHIC_ACTION : DoAction((MetaRenderGraphicAction &)*pAct); break; } if(pProgrInfo != NULL) @@ -272,7 +272,7 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, FASTBOOL bForceText { bNoLine = FALSE; bNoFill = FALSE; FASTBOOL bLine=TRUE && !bForceTextAttr; - FASTBOOL bFill=pObj==NULL || pObj->IsClosedObj() && !bForceTextAttr; + FASTBOOL bFill=pObj==NULL || ( pObj->IsClosedObj() && !bForceTextAttr ); FASTBOOL bText=bForceTextAttr || (pObj!=NULL && pObj->GetOutlinerParaObject()!=NULL); if ( bLine ) @@ -1025,4 +1025,25 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM } } +//////////////////////////////////////////////////////////////////////////////////////////////////// + +void ImpSdrGDIMetaFileImport::DoAction(MetaRenderGraphicAction& rAct) +{ + GDIMetaFile aMtf; + const ::vcl::RenderGraphic& rRenderGraphic = rAct.GetRenderGraphic(); + Rectangle aRect( rAct.GetPoint(), rAct.GetSize() ); + const Point aPos; + const Size aPrefSize( rRenderGraphic.GetPrefSize() ); + + aRect.Right()++; aRect.Bottom()++; + + aMtf.SetPrefMapMode( rRenderGraphic.GetPrefMapMode() ); + aMtf.SetPrefSize( aPrefSize ); + aMtf.AddAction( new MetaRenderGraphicAction( aPos, aPrefSize, rRenderGraphic ) ); + aMtf.WindStart(); + + SdrGrafObj* pGraf=new SdrGrafObj( aMtf, aRect ); + InsertObj( pGraf ); +} + // eof diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx index 2562b81efa8d..494e43dbadfc 100644 --- a/svx/source/svdraw/svdfmtf.hxx +++ b/svx/source/svdraw/svdfmtf.hxx @@ -140,6 +140,7 @@ protected: void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); } void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); } void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf); + void DoAction(MetaRenderGraphicAction& rAct); void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct ); void SetAttributes(SdrObject* pObj, FASTBOOL bForceTextAttr=FALSE); diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index b299d4c7a2ef..e95e3bf5296e 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -504,6 +504,11 @@ sal_Bool SdrGrafObj::IsEPS() const return pGraphic->IsEPS(); } +sal_Bool SdrGrafObj::IsRenderGraphic() const +{ + return pGraphic->IsRenderGraphic(); +} + sal_Bool SdrGrafObj::IsSwappedOut() const { return mbIsPreview ? sal_True : pGraphic->IsSwappedOut(); @@ -658,6 +663,7 @@ void SdrGrafObj::ReleaseGraphicLink() void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const { FASTBOOL bAnim = pGraphic->IsAnimated(); + FASTBOOL bRenderGraphic = pGraphic->HasRenderGraphic(); FASTBOOL bNoPresGrf = ( pGraphic->GetType() != GRAPHIC_NONE ) && !bEmptyPresObj; rInfo.bResizeFreeAllowed = aGeo.nDrehWink % 9000 == 0 || @@ -665,11 +671,11 @@ void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const aGeo.nDrehWink % 27000 == 0; rInfo.bResizePropAllowed = TRUE; - rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim; - rInfo.bRotate90Allowed = bNoPresGrf && !bAnim; - rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim; - rInfo.bMirror45Allowed = bNoPresGrf && !bAnim; - rInfo.bMirror90Allowed = !bEmptyPresObj; + rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bRotate90Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirror45Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirror90Allowed = !bEmptyPresObj && !bRenderGraphic; rInfo.bTransparenceAllowed = FALSE; rInfo.bGradientAllowed = FALSE; rInfo.bShearAllowed = FALSE; @@ -677,7 +683,7 @@ void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const rInfo.bCanConvToPath = FALSE; rInfo.bCanConvToPathLineToArea = FALSE; rInfo.bCanConvToPolyLineToArea = FALSE; - rInfo.bCanConvToPoly = !IsEPS(); + rInfo.bCanConvToPoly = !IsEPS() && !bRenderGraphic; rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary()); } diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index a1a7565f314d..548224991b19 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -153,7 +153,7 @@ SvXMLGraphicInputStream::SvXMLGraphicInputStream( const ::rtl::OUString& rGraphi { pStm->SetVersion( SOFFICE_FILEFORMAT_8 ); pStm->SetCompressMode( COMPRESSMODE_ZBITMAP ); - ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm ); + ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC ); bRet = ( pStm->GetError() == 0 ); } } @@ -543,7 +543,8 @@ String SvXMLGraphicHelper::ImplGetGraphicMimeType( const String& rFileName ) con { "gif", "image/gif" }, { "png", "image/png" }, { "jpg", "image/jpeg" }, - { "tif", "image/tiff" } + { "tif", "image/tiff" }, + { "svg", "image/svg+xml" } }; String aMimeType; @@ -648,7 +649,7 @@ sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureSt pStream->Write( rLink.GetData(), rLink.GetDataSize() ); } else - rMtf.Write( *pStream ); + rMtf.Write( *pStream, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC ); bRet = ( pStream->GetError() == 0 ); } @@ -728,6 +729,7 @@ void SvXMLGraphicHelper::ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, s case( GFX_LINK_TYPE_NATIVE_WMF ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".wmf" ) ); break; case( GFX_LINK_TYPE_NATIVE_MET ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".met" ) ); break; case( GFX_LINK_TYPE_NATIVE_PCT ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".pct" ) ); break; + case( GFX_LINK_TYPE_NATIVE_SVG ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".svg" ) ); break; default: aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".grf" ) ); @@ -1160,4 +1162,3 @@ Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicExportHelper_getSupportedServic } } // namespace svx - -- cgit From 591982d2f398724a74383338dd2268d05423130c Mon Sep 17 00:00:00 2001 From: ka Date: Mon, 7 Feb 2011 03:31:27 +0100 Subject: ka102: disable graphic attributes in case of RenderGraphic content --- svx/inc/svx/svdograf.hxx | 2 +- svx/source/svdraw/svdograf.cxx | 5 ++ svx/source/tbxctrls/grafctrl.cxx | 146 ++++++++++++++++++++++++--------------- 3 files changed, 98 insertions(+), 55 deletions(-) (limited to 'svx') diff --git a/svx/inc/svx/svdograf.hxx b/svx/inc/svx/svdograf.hxx index c76c77ec325a..fa095261c3b2 100644 --- a/svx/inc/svx/svdograf.hxx +++ b/svx/inc/svx/svdograf.hxx @@ -149,6 +149,7 @@ public: sal_Bool IsAnimated() const; sal_Bool IsEPS() const; sal_Bool IsRenderGraphic() const; + sal_Bool HasRenderGraphic() const; sal_Bool IsSwappedOut() const; const MapMode& GetGrafPrefMapMode() const; @@ -226,4 +227,3 @@ public: }; #endif //_SVDOGRAF_HXX - diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index e95e3bf5296e..fd7545dea0c4 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -509,6 +509,11 @@ sal_Bool SdrGrafObj::IsRenderGraphic() const return pGraphic->IsRenderGraphic(); } +sal_Bool SdrGrafObj::HasRenderGraphic() const +{ + return pGraphic->HasRenderGraphic(); +} + sal_Bool SdrGrafObj::IsSwappedOut() const { return mbIsPreview ? sal_True : pGraphic->IsSwappedOut(); diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx index 9f8c023c3b3d..e60e9ae27e47 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -856,10 +856,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView ) { SfxItemPool& rPool = rView.GetModel()->GetItemPool(); SfxItemSet aSet( rPool, SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST ); - - const bool bUndo = rView.IsUndoEnabled(); - - String aUndoStr; + String aUndoStr; + const bool bUndo = rView.IsUndoEnabled(); if( bUndo ) { @@ -1140,6 +1138,28 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) SfxItemSet aAttrSet( rPool ); SfxWhichIter aIter( rSet ); USHORT nWhich = aIter.FirstWhich(); + const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); + bool bEnableColors = true; + bool bEnableTransparency = true; + bool bEnableCrop = ( 1 == rMarkList.GetMarkCount() ); + + for( int i = 0, nCount = rMarkList.GetMarkCount(); i < nCount; ++i ) + { + SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( i )->GetMarkedSdrObj() ); + + if( !pGrafObj || + ( pGrafObj->GetGraphicType() == GRAPHIC_NONE ) || + ( pGrafObj->GetGraphicType() == GRAPHIC_DEFAULT ) || + pGrafObj->HasRenderGraphic() ) + { + bEnableColors = bEnableTransparency = bEnableCrop = false; + break; + } + else if( bEnableTransparency && ( pGrafObj->HasGDIMetaFile() || pGrafObj->IsAnimated() ) ) + { + bEnableTransparency = false; + } + } rView.GetAttributes( aAttrSet ); @@ -1153,8 +1173,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFMODE ) ) { - rSet.Put( SfxUInt16Item( nSlotId, - sal::static_int_cast< UINT16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxUInt16Item( nSlotId, + sal::static_int_cast< UINT16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_MODE ); + } } } break; @@ -1163,8 +1190,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFRED ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_RED ); + } } } break; @@ -1173,8 +1207,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGREEN ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_GREEN ); + } } } break; @@ -1183,8 +1224,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFBLUE ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_BLUE ); + } } } break; @@ -1193,8 +1241,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFLUMINANCE ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_LUMINANCE ); + } } } break; @@ -1203,8 +1258,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFCONTRAST ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_CONTRAST ); + } } } break; @@ -1213,8 +1275,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGAMMA ) ) { - rSet.Put( SfxUInt32Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxUInt32Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_GAMMA ); + } } } break; @@ -1223,53 +1292,22 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFTRANSPARENCE ) ) { - const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); - BOOL bEnable = TRUE; - - for( USHORT i = 0, nCount = (USHORT) rMarkList.GetMarkCount(); - ( i < nCount ) && bEnable; i++ ) + if( bEnableTransparency ) { - SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - - if( !pObj || !pObj->ISA( SdrGrafObj ) || - ( (SdrGrafObj*) pObj )->HasGDIMetaFile() || - ( (SdrGrafObj*) pObj )->IsAnimated() ) - { - bEnable = FALSE; - } - } - - if( bEnable ) rSet.Put( SfxUInt16Item( nSlotId, ITEMVALUE( aAttrSet, SDRATTR_GRAFTRANSPARENCE, SdrGrafTransparenceItem ) ) ); + } else + { rSet.DisableItem( SID_ATTR_GRAF_TRANSPARENCE ); + } } } break; case( SID_ATTR_GRAF_CROP ): { - const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); - BOOL bDisable = TRUE; - - if( 1 == rMarkList.GetMarkCount() ) - { - SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - - if( pObj && pObj->ISA( SdrGrafObj ) ) - { - SdrGrafObj* pGrafObj = (SdrGrafObj*) pObj; - - if( ( pGrafObj->GetGraphicType() != GRAPHIC_NONE ) && - ( pGrafObj->GetGraphicType() != GRAPHIC_DEFAULT ) ) - { - bDisable = FALSE; - } - } - } - - if( bDisable ) + if( !bEnableCrop ) rSet.DisableItem( nSlotId ); } break; -- cgit