SvxBrushItem: Improve Referer from member to GetGraphic[Object] parameter
Change-Id: I034132c315b74d0ea5e03b7d5f7cc225a6c8164e
This commit is contained in:
parent
a1115a5983
commit
c1f416feda
@ -843,7 +843,7 @@ sal_Bool SvxBackgroundTabPage::FillItemSet( SfxItemSet& rCoreSet )
|
||||
SvxBrushItem aTmpBrush(nWhich);
|
||||
if ( bIsLink )
|
||||
{
|
||||
aTmpBrush = SvxBrushItem( aBgdGraphicPath, ""/*TODO?*/,
|
||||
aTmpBrush = SvxBrushItem( aBgdGraphicPath,
|
||||
aBgdGraphicFilter,
|
||||
eNewPos,
|
||||
nWhich );
|
||||
@ -881,7 +881,7 @@ sal_Bool SvxBackgroundTabPage::FillItemSet( SfxItemSet& rCoreSet )
|
||||
SvxBrushItem* pTmpBrush = 0;
|
||||
if ( m_pBtnLink->IsChecked() )
|
||||
{
|
||||
pTmpBrush = new SvxBrushItem( aBgdGraphicPath, ""/*TODO?*/,
|
||||
pTmpBrush = new SvxBrushItem( aBgdGraphicPath,
|
||||
aBgdGraphicFilter,
|
||||
GetGraphicPosition_Impl(),
|
||||
nWhich );
|
||||
@ -1665,7 +1665,7 @@ IMPL_LINK( SvxBackgroundTabPage, TblDestinationHdl_Impl, ListBox*, pBox )
|
||||
bIsGraphicValid = LoadLinkedGraphic_Impl();
|
||||
|
||||
if ( bIsLink )
|
||||
*pActItem = SvxBrushItem( aBgdGraphicPath, ""/*TODO?*/,
|
||||
*pActItem = SvxBrushItem( aBgdGraphicPath,
|
||||
aBgdGraphicFilter,
|
||||
eNewPos,
|
||||
pActItem->Which() );
|
||||
@ -1746,7 +1746,7 @@ IMPL_LINK( SvxBackgroundTabPage, ParaDestinationHdl_Impl, ListBox*, pBox )
|
||||
bIsGraphicValid = LoadLinkedGraphic_Impl();
|
||||
|
||||
if ( bIsLink )
|
||||
*pActItem = SvxBrushItem( aBgdGraphicPath, ""/*TODO?*/,
|
||||
*pActItem = SvxBrushItem( aBgdGraphicPath,
|
||||
aBgdGraphicFilter,
|
||||
eNewPos,
|
||||
pActItem->Which() );
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <tools/shl.hxx>
|
||||
#include <svl/eitem.hxx>
|
||||
#include <svl/stritem.hxx>
|
||||
#include <sfx2/app.hxx>
|
||||
#include <sfx2/module.hxx>
|
||||
#include <sfx2/sfxsids.hrc>
|
||||
@ -206,7 +207,13 @@ void SvxGrfCropPage::Reset( const SfxItemSet &rSet )
|
||||
sal_Bool bFound = sal_False;
|
||||
if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, sal_False, &pItem ) )
|
||||
{
|
||||
const Graphic* pGrf = ((SvxBrushItem*)pItem)->GetGraphic();
|
||||
OUString referer;
|
||||
SfxStringItem const * it = static_cast<SfxStringItem const *>(
|
||||
rSet.GetItem(SID_REFERER));
|
||||
if (it != 0) {
|
||||
referer = it->GetValue();
|
||||
}
|
||||
const Graphic* pGrf = ((SvxBrushItem*)pItem)->GetGraphic(referer);
|
||||
if( pGrf ) {
|
||||
aOrigSize = GetGrfOrigSize( *pGrf );
|
||||
if (pGrf->GetType() == GRAPHIC_BITMAP && aOrigSize.Width() && aOrigSize.Height()) {
|
||||
@ -353,7 +360,13 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet)
|
||||
aGraphicName != rBrush.GetGraphicLink() )
|
||||
aGraphicName = rBrush.GetGraphicLink();
|
||||
|
||||
const Graphic* pGrf = rBrush.GetGraphic();
|
||||
OUString referer;
|
||||
SfxStringItem const * it = static_cast<SfxStringItem const *>(
|
||||
rSet.GetItem(SID_REFERER));
|
||||
if (it != 0) {
|
||||
referer = it->GetValue();
|
||||
}
|
||||
const Graphic* pGrf = rBrush.GetGraphic(referer);
|
||||
if( pGrf )
|
||||
{
|
||||
aExampleWN.SetGraphic( *pGrf );
|
||||
|
@ -266,7 +266,7 @@ void SvxLineTabPage::InitSymbols(MenuButton* pButton)
|
||||
pUIName = &aPhysicalName;
|
||||
}
|
||||
|
||||
SvxBrushItem* pBrushItem = new SvxBrushItem(*it, ""/*TODO?*/, aEmptyStr, GPOS_AREA, SID_ATTR_BRUSH);
|
||||
SvxBrushItem* pBrushItem = new SvxBrushItem(*it, aEmptyStr, GPOS_AREA, SID_ATTR_BRUSH);
|
||||
pBrushItem->SetDoneLink(STATIC_LINK(this, SvxLineTabPage, GraphicArrivedHdl_Impl));
|
||||
|
||||
SvxBmpItemInfo* pInfo = new SvxBmpItemInfo();
|
||||
|
@ -3410,7 +3410,7 @@ SvxBrushItem::SvxBrushItem( const GraphicObject& rGraphicObj,
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
SvxBrushItem::SvxBrushItem(
|
||||
const OUString& rLink, const OUString& rReferer, const OUString& rFilter,
|
||||
const OUString& rLink, const OUString& rFilter,
|
||||
SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
|
||||
|
||||
SfxPoolItem( _nWhich ),
|
||||
@ -3419,7 +3419,6 @@ SvxBrushItem::SvxBrushItem(
|
||||
nShadingValue ( ShadingPattern::CLEAR ),
|
||||
pImpl ( new SvxBrushItem_Impl( NULL ) ),
|
||||
maStrLink ( rLink ),
|
||||
maReferer ( rReferer ),
|
||||
maStrFilter ( rFilter ),
|
||||
eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
|
||||
bLoadAgain ( sal_True )
|
||||
@ -3822,13 +3821,11 @@ SvxBrushItem& SvxBrushItem::operator=( const SvxBrushItem& rItem )
|
||||
|
||||
DELETEZ( pImpl->pGraphicObject );
|
||||
maStrLink = "";
|
||||
maReferer = "";
|
||||
maStrFilter = "";
|
||||
|
||||
if ( GPOS_NONE != eGraphicPos )
|
||||
{
|
||||
maStrLink = rItem.maStrLink;
|
||||
maReferer = rItem.maReferer;
|
||||
maStrFilter = rItem.maStrFilter;
|
||||
if ( rItem.pImpl->pGraphicObject )
|
||||
{
|
||||
@ -3856,7 +3853,7 @@ int SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const
|
||||
{
|
||||
if ( GPOS_NONE != eGraphicPos )
|
||||
{
|
||||
bEqual = maStrLink == rCmp.maStrLink && maReferer == rCmp.maReferer;
|
||||
bEqual = maStrLink == rCmp.maStrLink;
|
||||
|
||||
if ( bEqual )
|
||||
{
|
||||
@ -3942,12 +3939,12 @@ void SvxBrushItem::PurgeMedium() const
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
const GraphicObject* SvxBrushItem::GetGraphicObject() const
|
||||
const GraphicObject* SvxBrushItem::GetGraphicObject(OUString const & referer) const
|
||||
{
|
||||
if ( bLoadAgain && !maStrLink.isEmpty() && !pImpl->pGraphicObject )
|
||||
// when graphics already loaded, use as a cache
|
||||
{
|
||||
if (SvtSecurityOptions().isUntrustedReferer(maReferer)) {
|
||||
if (SvtSecurityOptions().isUntrustedReferer(referer)) {
|
||||
return 0;
|
||||
}
|
||||
pImpl->pStream = utl::UcbStreamHelper::CreateStream( maStrLink, STREAM_STD_READ );
|
||||
@ -3982,9 +3979,9 @@ const GraphicObject* SvxBrushItem::GetGraphicObject() const
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
const Graphic* SvxBrushItem::GetGraphic() const
|
||||
const Graphic* SvxBrushItem::GetGraphic(OUString const & referer) const
|
||||
{
|
||||
const GraphicObject* pGrafObj = GetGraphicObject();
|
||||
const GraphicObject* pGrafObj = GetGraphicObject(referer);
|
||||
return( pGrafObj ? &( pGrafObj->GetGraphic() ) : NULL );
|
||||
}
|
||||
|
||||
@ -3998,7 +3995,6 @@ void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew )
|
||||
{
|
||||
DELETEZ( pImpl->pGraphicObject );
|
||||
maStrLink = "";
|
||||
maReferer = "";
|
||||
maStrFilter = "";
|
||||
}
|
||||
else
|
||||
|
@ -424,7 +424,7 @@ void SvxNumberFormat::SetGraphic( const OUString& rName )
|
||||
return ;
|
||||
|
||||
delete pGraphicBrush;
|
||||
pGraphicBrush = new SvxBrushItem( rName, ""/*TODO?*/, "", GPOS_AREA, 0 );
|
||||
pGraphicBrush = new SvxBrushItem( rName, "", GPOS_AREA, 0 );
|
||||
pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
|
||||
if( eVertOrient == text::VertOrientation::NONE )
|
||||
eVertOrient = text::VertOrientation::TOP;
|
||||
|
@ -51,7 +51,6 @@ class EDITENG_DLLPUBLIC SvxBrushItem : public SfxPoolItem
|
||||
sal_Int32 nShadingValue;
|
||||
SvxBrushItem_Impl* pImpl;
|
||||
OUString maStrLink;
|
||||
OUString maReferer;
|
||||
OUString maStrFilter;
|
||||
SvxGraphicPosition eGraphicPos;
|
||||
sal_Bool bLoadAgain;
|
||||
@ -72,7 +71,7 @@ public:
|
||||
SvxGraphicPosition ePos, sal_uInt16 nWhich );
|
||||
SvxBrushItem( const GraphicObject& rGraphicObj,
|
||||
SvxGraphicPosition ePos, sal_uInt16 nWhich );
|
||||
SvxBrushItem( const OUString& rLink, const OUString& rReferer, const OUString& rFilter,
|
||||
SvxBrushItem( const OUString& rLink, const OUString& rFilter,
|
||||
SvxGraphicPosition ePos, sal_uInt16 nWhich );
|
||||
SvxBrushItem( const SvxBrushItem& );
|
||||
SvxBrushItem( const CntWallpaperItem&, sal_uInt16 nWhich );
|
||||
@ -106,8 +105,8 @@ public:
|
||||
void PurgeMedium() const;
|
||||
|
||||
sal_uInt32 GetShadingValue() const { return nShadingValue; }
|
||||
const Graphic* GetGraphic() const;
|
||||
const GraphicObject* GetGraphicObject() const;
|
||||
const Graphic* GetGraphic(OUString const & referer = OUString()/*TODO*/) const;
|
||||
const GraphicObject* GetGraphicObject(OUString const & referer = OUString()/*TODO*/) const;
|
||||
OUString GetGraphicLink() const { return maStrLink; }
|
||||
OUString GetGraphicFilter() const { return maStrFilter; }
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <vcl/lazydelete.hxx>
|
||||
#include <vcl/gradient.hxx>
|
||||
#include <sfx2/docfile.hxx>
|
||||
#include <sfx2/progress.hxx>
|
||||
#include <editeng/brushitem.hxx>
|
||||
#include <editeng/opaqitem.hxx>
|
||||
@ -1835,7 +1836,12 @@ void DrawGraphic( const SvxBrushItem *pBrush,
|
||||
else
|
||||
((SvxBrushItem*)pBrush)->SetDoneLink( STATIC_LINK(
|
||||
rSh.GetDoc(), SwDoc, BackgroundDone ) );
|
||||
const Graphic* pGrf = pBrush->GetGraphic();
|
||||
OUString referer;
|
||||
SfxObjectShell * sh = rSh.GetDoc()->GetPersist();
|
||||
if (sh != 0 && sh->HasName()) {
|
||||
referer = sh->GetMedium()->GetName();
|
||||
}
|
||||
const Graphic* pGrf = pBrush->GetGraphic(referer);
|
||||
if( pGrf && GRAPHIC_NONE != pGrf->GetType() )
|
||||
{
|
||||
ePos = pBrush->GetGraphicPos();
|
||||
@ -7137,7 +7143,15 @@ const Color& SwPageFrm::GetDrawBackgrdColor() const
|
||||
|
||||
if ( GetBackgroundBrush( pBrushItem, pFillStyleItem, pFillGradientItem, pDummyColor, aDummyRect, true) )
|
||||
{
|
||||
const Graphic* pGraphic = pBrushItem->GetGraphic();
|
||||
OUString referer;
|
||||
SwViewShell * sh1 = getRootFrm()->GetCurrShell();
|
||||
if (sh1 != 0) {
|
||||
SfxObjectShell * sh2 = sh1->GetDoc()->GetPersist();
|
||||
if (sh2 != 0 && sh2->HasName()) {
|
||||
referer = sh2->GetMedium()->GetName();
|
||||
}
|
||||
}
|
||||
const Graphic* pGraphic = pBrushItem->GetGraphic(referer);
|
||||
|
||||
if(pGraphic)
|
||||
{
|
||||
|
@ -1991,7 +1991,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
|
||||
pSetBrush = new SvxBrushItem(*pOrigBrush);
|
||||
}
|
||||
else
|
||||
pSetBrush = new SvxBrushItem(aEmptyOUStr, ""/*TODO?*/, aEmptyOUStr, GPOS_AREA, RES_BACKGROUND);
|
||||
pSetBrush = new SvxBrushItem(aEmptyOUStr, aEmptyOUStr, GPOS_AREA, RES_BACKGROUND);
|
||||
}
|
||||
pSetBrush->PutValue( pData->aVal, MID_GRAPHIC_URL );
|
||||
}
|
||||
@ -2010,7 +2010,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
|
||||
pSetBrush = new SvxBrushItem(*pOrigBrush);
|
||||
}
|
||||
else
|
||||
pSetBrush = new SvxBrushItem(aEmptyOUStr, ""/*TODO?*/, aEmptyOUStr, GPOS_AREA, RES_BACKGROUND);
|
||||
pSetBrush = new SvxBrushItem(aEmptyOUStr, aEmptyOUStr, GPOS_AREA, RES_BACKGROUND);
|
||||
}
|
||||
|
||||
BitmapEx aBmp = VCLUnoHelper::GetBitmap( *pBitmap );
|
||||
|
@ -2445,7 +2445,13 @@ void SwGrfExtPage::ActivatePage(const SfxItemSet& rSet)
|
||||
aGrfName = aNewGrfName = rBrush.GetGraphicLink();
|
||||
m_pConnectED->SetText( aNewGrfName );
|
||||
}
|
||||
const Graphic* pGrf = rBrush.GetGraphic();
|
||||
OUString referer;
|
||||
SfxStringItem const * it = static_cast<SfxStringItem const *>(
|
||||
rSet.GetItem(SID_REFERER));
|
||||
if (it != 0) {
|
||||
referer = it->GetValue();
|
||||
}
|
||||
const Graphic* pGrf = rBrush.GetGraphic(referer);
|
||||
if( pGrf )
|
||||
m_pBmpWin->SetGraphic( *pGrf );
|
||||
}
|
||||
@ -2499,7 +2505,7 @@ sal_Bool SwGrfExtPage::FillItemSet( SfxItemSet &rSet )
|
||||
{
|
||||
bModified = sal_True;
|
||||
aGrfName = m_pConnectED->GetText();
|
||||
rSet.Put( SvxBrushItem( aGrfName, ""/*TODO?*/, aFilterName, GPOS_LT,
|
||||
rSet.Put( SvxBrushItem( aGrfName, aFilterName, GPOS_LT,
|
||||
SID_ATTR_GRAF_GRAPHIC ));
|
||||
}
|
||||
return bModified;
|
||||
|
@ -209,6 +209,7 @@ void SwGrfShell::Execute(SfxRequest &rReq)
|
||||
SID_DOCFRAME, SID_DOCFRAME,
|
||||
SID_HTML_MODE, SID_HTML_MODE,
|
||||
FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME,
|
||||
SID_REFERER, SID_REFERER,
|
||||
0);
|
||||
|
||||
sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
|
||||
@ -262,17 +263,11 @@ void SwGrfShell::Execute(SfxRequest &rReq)
|
||||
rSh.GetGrfNms( &sGrfNm, &sFilterNm );
|
||||
if( !sGrfNm.isEmpty() )
|
||||
{
|
||||
OUString sReferer;
|
||||
SfxObjectShell * sh = rSh.GetDoc()->GetPersist();
|
||||
if (sh != 0 && sh->HasName())
|
||||
{
|
||||
sReferer = sh->GetMedium()->GetName();
|
||||
}
|
||||
aSet.Put( SvxBrushItem( INetURLObject::decode( sGrfNm,
|
||||
INET_HEX_ESCAPE,
|
||||
INetURLObject::DECODE_UNAMBIGUOUS,
|
||||
RTL_TEXTENCODING_UTF8 ),
|
||||
sReferer, sFilterNm, GPOS_LT,
|
||||
sFilterNm, GPOS_LT,
|
||||
SID_ATTR_GRAF_GRAPHIC ));
|
||||
}
|
||||
else
|
||||
@ -301,6 +296,13 @@ void SwGrfShell::Execute(SfxRequest &rReq)
|
||||
|
||||
aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame()));
|
||||
|
||||
SfxObjectShell * sh = rSh.GetDoc()->GetPersist();
|
||||
if (sh != 0 && sh->HasName())
|
||||
{
|
||||
aSet.Put(
|
||||
SfxStringItem(SID_REFERER, sh->GetMedium()->GetName()));
|
||||
}
|
||||
|
||||
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
|
||||
OSL_ENSURE(pFact, "no dialog factory!");
|
||||
SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog("PictureDialog",
|
||||
|
Loading…
x
Reference in New Issue
Block a user