From 0a29c5bedda700a86b46e3c3cd9c9e1ce1d4f278 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 31 May 2012 13:23:45 +0000 Subject: Resolves: #i119287# exchanged hard attributes for OLE and GraphicObject ...with new default StyleSheet for these objects (cherry picked from commit 2868ea34151cfb623a6a8bf41862d430205d9784) Conflicts: sd/source/core/drawdoc4.cxx svx/source/sdr/contact/viewcontactofgraphic.cxx Change-Id: I4849101de2ac1da83c8fb0f2d68316774982d197 Resolves: #i119287# Adapted to get the needed style as default style for all SdrGrafObj and SDrOle2Objs. Checked various scenarios, works well. (cherry picked from commit bc85939149f7ae5b65343d7f27bf302a8e31d4b1) Conflicts: sd/source/core/drawdoc.cxx sd/source/ui/func/fuinsert.cxx sd/source/ui/view/sdview4.cxx Change-Id: I40a17216f5c11ebca073026f62f1e9ab9ddfd119 --- svx/source/sdr/contact/viewcontactofgraphic.cxx | 29 ++++++---------------- .../sdr/contact/viewcontactofsdrcaptionobj.cxx | 3 ++- svx/source/sdr/contact/viewcontactofsdrcircobj.cxx | 3 ++- svx/source/sdr/contact/viewcontactofsdrole2obj.cxx | 6 ++++- svx/source/sdr/contact/viewcontactofsdrpathobj.cxx | 3 ++- svx/source/sdr/contact/viewcontactofsdrrectobj.cxx | 3 ++- svx/source/sdr/primitive2d/sdrattributecreator.cxx | 9 +++++-- svx/source/sdr/properties/graphicproperties.cxx | 4 --- svx/source/sdr/properties/oleproperties.cxx | 4 --- svx/source/svdraw/svdmodel.cxx | 1 + svx/source/svdraw/svdograf.cxx | 20 +++++++++++++++ svx/source/svdraw/svdoole2.cxx | 22 ++++++++++++++++ 12 files changed, 70 insertions(+), 37 deletions(-) (limited to 'svx/source') diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx index 421a32bcee41..0a1082f51fa3 100644 --- a/svx/source/sdr/contact/viewcontactofgraphic.cxx +++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx @@ -297,10 +297,6 @@ namespace sdr { drawinglayer::primitive2d::Primitive2DSequence xRetval; const SfxItemSet& rItemSet = GetGrafObject().GetMergedItemSet(); - drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( - drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( - rItemSet, - GetGrafObject().getText(0))); // create and fill GraphicAttr GraphicAttr aLocalGrafInfo; @@ -317,25 +313,14 @@ namespace sdr aLocalGrafInfo.SetDrawMode(((SdrGrafModeItem&)rItemSet.Get(SDRATTR_GRAFMODE)).GetValue()); aLocalGrafInfo.SetCrop(rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom()); - if(aAttribute.isDefault() && 255L != aLocalGrafInfo.GetTransparency()) - { - // no fill, no line, no text (invisible), but the graphic content is visible. - // Create evtl. shadow for content which was not created by createNewSdrLineFillShadowTextAttribute yet - const drawinglayer::attribute::SdrShadowAttribute aShadow( - drawinglayer::primitive2d::createNewSdrShadowAttribute(rItemSet)); + // we have content if graphic is not completely transparent + const bool bHasContent(255L != aLocalGrafInfo.GetTransparency()); + drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( + drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( + rItemSet, + GetGrafObject().getText(0), + bHasContent)); - if(!aShadow.isDefault()) - { - // create new attribute set if indeed shadow is used - aAttribute = drawinglayer::attribute::SdrLineFillShadowTextAttribute( - aAttribute.getLine(), - aAttribute.getFill(), - aAttribute.getLineStartEnd(), - aShadow, - aAttribute.getFillFloatTransGradient(), - aAttribute.getText()); - } - } // take unrotated snap rect for position and size. Directly use model data, not getBoundRect() or getSnapRect() // which will use the primitive data we just create in the near future Rectangle rRectangle = GetGrafObject().GetGeoRect(); diff --git a/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx b/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx index 9076ba7d45a0..78e6c5e2c55d 100644 --- a/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx @@ -59,7 +59,8 @@ namespace sdr const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( rItemSet, - rCaptionObj.getText(0))); + rCaptionObj.getText(0), + false)); // take unrotated snap rect (direct model data) for position and size Rectangle rRectangle = rCaptionObj.GetGeoRect(); diff --git a/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx b/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx index 2b1f58c75d34..5289f5e3a734 100644 --- a/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx @@ -47,7 +47,8 @@ namespace sdr const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( rItemSet, - GetCircObj().getText(0))); + GetCircObj().getText(0), + false)); // take unrotated snap rect (direct model data) for position and size Rectangle aRectangle = GetCircObj().GetGeoRect(); diff --git a/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx index 358eda0b6dae..9aa5d07db16b 100644 --- a/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx @@ -88,10 +88,14 @@ namespace sdr // Prepare attribute settings, will be used soon anyways const SfxItemSet& rItemSet = GetOle2Obj().GetMergedItemSet(); + + // this may be refined more granular; if no content, attributes may get simpler + const bool bHasContent(true); const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( rItemSet, - GetOle2Obj().getText(0))); + GetOle2Obj().getText(0), + bHasContent)); drawinglayer::primitive2d::Primitive2DReference xContent; if(GetOle2Obj().IsChart()) diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx index a6c130b08337..f3cc4e2c4ac5 100644 --- a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx @@ -46,7 +46,8 @@ namespace sdr const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( rItemSet, - GetPathObj().getText(0))); + GetPathObj().getText(0), + false)); basegfx::B2DPolyPolygon aUnitPolyPolygon(GetPathObj().GetPathPoly()); Point aGridOff = GetPathObj().GetGridOffset(); // Hack for calc, transform position of object according diff --git a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx index 166c3d52e95b..b4088772039f 100644 --- a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx @@ -48,7 +48,8 @@ namespace sdr const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( rItemSet, - GetRectObj().getText(0))); + GetRectObj().getText(0), + false)); // take unrotated snap rect (direct model data) for position and size Rectangle rRectangle = GetRectObj().GetGeoRect(); diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx index 273db74e60c7..88fce3ce1f3b 100644 --- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx +++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx @@ -716,7 +716,8 @@ namespace drawinglayer attribute::SdrLineFillShadowTextAttribute createNewSdrLineFillShadowTextAttribute( const SfxItemSet& rSet, - const SdrText* pText) + const SdrText* pText, + bool bHasContent) { attribute::SdrLineAttribute aLine; attribute::SdrFillAttribute aFill; @@ -760,7 +761,11 @@ namespace drawinglayer } } - if(!aLine.isDefault() || !aFill.isDefault() || !aText.isDefault()) + // bHasContent is used from OLE and graphic objects. Normally a possible shadow + // depends on line, fill or text to be set, but for these objects it is possible + // to have none of these, but still content which needs to have a shadow (if set), + // so shadow needs to be tried + if(bHasContent || !aLine.isDefault() || !aFill.isDefault() || !aText.isDefault()) { // try shadow aShadow = createNewSdrShadowAttribute(rSet); diff --git a/svx/source/sdr/properties/graphicproperties.cxx b/svx/source/sdr/properties/graphicproperties.cxx index e8f74858a928..ad12924a1009 100644 --- a/svx/source/sdr/properties/graphicproperties.cxx +++ b/svx/source/sdr/properties/graphicproperties.cxx @@ -121,10 +121,6 @@ namespace sdr mpItemSet->Put( SdrGrafInvertItem( sal_False ) ); mpItemSet->Put( SdrGrafModeItem( GRAPHICDRAWMODE_STANDARD ) ); mpItemSet->Put( SdrGrafCropItem( 0, 0, 0, 0 ) ); - - // #i25616# - mpItemSet->Put( XFillStyleItem(XFILL_NONE) ); - mpItemSet->Put( XLineStyleItem(XLINE_NONE) ); } } // end of namespace properties } // end of namespace sdr diff --git a/svx/source/sdr/properties/oleproperties.cxx b/svx/source/sdr/properties/oleproperties.cxx index 2d8462ab3c56..02ab254a890e 100644 --- a/svx/source/sdr/properties/oleproperties.cxx +++ b/svx/source/sdr/properties/oleproperties.cxx @@ -55,10 +55,6 @@ namespace sdr // force ItemSet GetObjectItemSet(); - - // #i108221# - mpItemSet->Put( XFillStyleItem(XFILL_NONE) ); - mpItemSet->Put( XLineStyleItem(XLINE_NONE) ); } } // end of namespace properties } // end of namespace sdr diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 092544dae9cd..c5fe0532d178 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -128,6 +128,7 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe nProgressMax=0; nProgressOfs=0; pDefaultStyleSheet=NULL; + mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj = 0; pLinkManager=NULL; pUndoStack=NULL; pRedoStack=NULL; diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 78a8e2709a14..a0041ee8de1a 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -962,6 +962,26 @@ void SdrGrafObj::SetPage( SdrPage* pNewPage ) ImpLinkAbmeldung(); } + if(!pModel && !GetStyleSheet() && pNewPage->GetModel()) + { + // #i119287# Set default StyleSheet for SdrGrafObj here, it is different from 'Default'. This + // needs to be done before the style 'Default' is set from the :SetModel() call which is triggered + // from the following :SetPage(). + // TTTT: Needs to be moved in branch aw080 due to having a SdrModel from the beginning, is at this + // place for convenience currently (works in both versions, is not in the way) + SfxStyleSheet* pSheet = pNewPage->GetModel()->GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(); + + if(pSheet) + { + SetStyleSheet(pSheet, false); + } + else + { + SetMergedItem(XFillStyleItem(XFILL_NONE)); + SetMergedItem(XLineStyleItem(XLINE_NONE)); + } + } + SdrRectObj::SetPage( pNewPage ); if (!aFileName.isEmpty() && bInsert) diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index e3656a4ffa84..034f5b8b8b08 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -87,6 +87,8 @@ #include #include +#include + using namespace ::rtl; using namespace ::com::sun::star; @@ -1449,6 +1451,26 @@ void SdrOle2Obj::SetPage(SdrPage* pNewPage) if (bRemove && mpImpl->mbConnected ) Disconnect(); + if(!pModel && !GetStyleSheet() && pNewPage->GetModel()) + { + // #i119287# Set default StyleSheet for SdrGrafObj here, it is different from 'Default'. This + // needs to be done before the style 'Default' is set from the :SetModel() call which is triggered + // from the following :SetPage(). + // TTTT: Needs to be moved in branch aw080 due to having a SdrModel from the beginning, is at this + // place for convenience currently (works in both versions, is not in the way) + SfxStyleSheet* pSheet = pNewPage->GetModel()->GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(); + + if(pSheet) + { + SetStyleSheet(pSheet, false); + } + else + { + SetMergedItem(XFillStyleItem(XFILL_NONE)); + SetMergedItem(XLineStyleItem(XLINE_NONE)); + } + } + SdrRectObj::SetPage(pNewPage); if (bInsert && !mpImpl->mbConnected ) -- cgit