summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-11-14 17:25:30 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-11-14 17:25:47 +0100
commitc1f416feda0ef4ef215ca587b9bac03659b48c7a (patch)
tree034acd437ef021c2580682b38bd5a8361618ce93
parenta1115a5983e126f872c6d7f14aef8ce5bba4010a (diff)
SvxBrushItem: Improve Referer from member to GetGraphic[Object] parameter
Change-Id: I034132c315b74d0ea5e03b7d5f7cc225a6c8164e
-rw-r--r--cui/source/tabpages/backgrnd.cxx8
-rw-r--r--cui/source/tabpages/grfpage.cxx17
-rw-r--r--cui/source/tabpages/tpline.cxx2
-rw-r--r--editeng/source/items/frmitems.cxx16
-rw-r--r--editeng/source/items/numitem.cxx2
-rw-r--r--include/editeng/brushitem.hxx7
-rw-r--r--sw/source/core/layout/paintfrm.cxx18
-rw-r--r--sw/source/core/unocore/unosett.cxx4
-rw-r--r--sw/source/ui/frmdlg/frmpage.cxx10
-rw-r--r--sw/source/ui/shells/grfsh.cxx16
10 files changed, 65 insertions, 35 deletions
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 7948b6ca5066..e1e598ddb6a6 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -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() );
diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx
index 1a41bde3560f..1365ce5c7815 100644
--- a/cui/source/tabpages/grfpage.cxx
+++ b/cui/source/tabpages/grfpage.cxx
@@ -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 );
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index a5a9cdc752fb..458b6b920d93 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -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();
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 4cb76d7e5569..020488cb9846 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -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
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index e4a9bb996092..2dca4a74d332 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -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;
diff --git a/include/editeng/brushitem.hxx b/include/editeng/brushitem.hxx
index 4ef5bfd4615c..10339ac9c7dd 100644
--- a/include/editeng/brushitem.hxx
+++ b/include/editeng/brushitem.hxx
@@ -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; }
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 9c0d1296a350..83c87aa279fe 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -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)
{
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 9aae7dbb790a..cea2d9e26b84 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -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 );
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index b6a06690c66c..de476b5ef73c 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -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;
diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx
index c6dadbfbbe35..949c7e639701 100644
--- a/sw/source/ui/shells/grfsh.cxx
+++ b/sw/source/ui/shells/grfsh.cxx
@@ -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",