1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir #include <hintids.hxx> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <tools/urlobj.hxx> 34*cdf0e10cSrcweir #include <vcl/graph.hxx> 35*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 36*cdf0e10cSrcweir #include <sot/formats.hxx> 37*cdf0e10cSrcweir #include <svl/eitem.hxx> 38*cdf0e10cSrcweir #include <svl/stritem.hxx> 39*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 40*cdf0e10cSrcweir #include <svtools/filter.hxx> 41*cdf0e10cSrcweir #include <svtools/imap.hxx> 42*cdf0e10cSrcweir #include <svtools/inetimg.hxx> 43*cdf0e10cSrcweir #include <svtools/transfer.hxx> 44*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 45*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 46*cdf0e10cSrcweir #include <svx/xoutbmp.hxx> 47*cdf0e10cSrcweir #include <svx/gallery.hxx> 48*cdf0e10cSrcweir #include <editeng/brshitem.hxx> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #include <swunodef.hxx> 52*cdf0e10cSrcweir #include <frmatr.hxx> 53*cdf0e10cSrcweir #include <fmturl.hxx> 54*cdf0e10cSrcweir #include <fmtinfmt.hxx> 55*cdf0e10cSrcweir #include <docsh.hxx> 56*cdf0e10cSrcweir #include <view.hxx> 57*cdf0e10cSrcweir #include <wrtsh.hxx> 58*cdf0e10cSrcweir #include <viewopt.hxx> 59*cdf0e10cSrcweir #include <swmodule.hxx> 60*cdf0e10cSrcweir #include <romenu.hxx> 61*cdf0e10cSrcweir #include <pagedesc.hxx> 62*cdf0e10cSrcweir #include <modcfg.hxx> 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #include <cmdid.h> 65*cdf0e10cSrcweir #include <helpid.h> 66*cdf0e10cSrcweir #include <docvw.hrc> 67*cdf0e10cSrcweir #include <docvw.hrc> 68*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker.hpp> 69*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp> 70*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> 71*cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx> 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 74*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 75*cdf0e10cSrcweir using namespace ::com::sun::star; 76*cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs; 77*cdf0e10cSrcweir using namespace ::sfx2; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir SwReadOnlyPopup::~SwReadOnlyPopup() 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir String *pDel = (String*)aThemeList.First(); 82*cdf0e10cSrcweir while ( pDel ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir delete pDel; 85*cdf0e10cSrcweir pDel = (String*)aThemeList.Next(); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir delete pImageMap; 88*cdf0e10cSrcweir delete pTargetURL; 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir void SwReadOnlyPopup::Check( sal_uInt16 nMID, sal_uInt16 nSID, SfxDispatcher &rDis ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir SfxPoolItem *_pItem = 0; 96*cdf0e10cSrcweir SfxItemState eState = rDis.GetBindings()->QueryState( nSID, _pItem ); 97*cdf0e10cSrcweir if (eState >= SFX_ITEM_AVAILABLE) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir EnableItem( nMID, sal_True ); 100*cdf0e10cSrcweir if (_pItem) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir CheckItem ( nMID, !_pItem->ISA(SfxVoidItem) && 103*cdf0e10cSrcweir _pItem->ISA(SfxBoolItem) && 104*cdf0e10cSrcweir ((SfxBoolItem*)_pItem)->GetValue()); 105*cdf0e10cSrcweir //remove full screen entry when not in full screen mode 106*cdf0e10cSrcweir if(SID_WIN_FULLSCREEN == nSID && !IsItemChecked(SID_WIN_FULLSCREEN) ) 107*cdf0e10cSrcweir EnableItem(nMID, sal_False); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir else 111*cdf0e10cSrcweir EnableItem( nMID, sal_False ); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir delete _pItem; 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir SwReadOnlyPopup::SwReadOnlyPopup( const Point &rDPos, SwView &rV ) : 118*cdf0e10cSrcweir PopupMenu( SW_RES(MN_READONLY_POPUP) ), 119*cdf0e10cSrcweir rView ( rV ), 120*cdf0e10cSrcweir rDocPos( rDPos ), 121*cdf0e10cSrcweir pImageMap( 0 ), 122*cdf0e10cSrcweir pTargetURL( 0 ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir bGrfToGalleryAsLnk = SW_MOD()->GetModuleConfig()->IsGrfToGalleryAsLnk(); 125*cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell(); 126*cdf0e10cSrcweir rSh.IsURLGrfAtPos( rDocPos, &sURL, &sTargetFrameName, &sDescription ); 127*cdf0e10cSrcweir if ( !sURL.Len() ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR ); 130*cdf0e10cSrcweir if( rSh.GetContentAtPos( rDocPos, aCntntAtPos, sal_False)) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir SwFmtINetFmt &rIItem = *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr; 133*cdf0e10cSrcweir sURL = rIItem.GetValue(); 134*cdf0e10cSrcweir sTargetFrameName = rIItem.GetTargetFrame(); 135*cdf0e10cSrcweir sDescription = aCntntAtPos.sStr; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir sal_Bool bLink = sal_False; 140*cdf0e10cSrcweir const Graphic *pGrf; 141*cdf0e10cSrcweir if ( 0 == (pGrf = rSh.GetGrfAtPos( rDocPos, sGrfName, bLink )) ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir EnableItem( MN_READONLY_SAVEGRAPHIC, sal_False ); 144*cdf0e10cSrcweir EnableItem( MN_READONLY_COPYGRAPHIC, sal_False ); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir else 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir aGraphic = *pGrf; 149*cdf0e10cSrcweir const SwFrmFmt* pGrfFmt = rSh.GetFmtFromObj( rDocPos ); 150*cdf0e10cSrcweir const SfxPoolItem* pURLItem; 151*cdf0e10cSrcweir if( pGrfFmt && SFX_ITEM_SET == pGrfFmt->GetItemState( 152*cdf0e10cSrcweir RES_URL, sal_True, &pURLItem )) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir const SwFmtURL& rURL = *(SwFmtURL*)pURLItem; 155*cdf0e10cSrcweir if( rURL.GetMap() ) 156*cdf0e10cSrcweir pImageMap = new ImageMap( *rURL.GetMap() ); 157*cdf0e10cSrcweir else if( rURL.GetURL().Len() ) 158*cdf0e10cSrcweir pTargetURL = new INetImage( bLink ? sGrfName : aEmptyStr, 159*cdf0e10cSrcweir rURL.GetURL(), 160*cdf0e10cSrcweir rURL.GetTargetFrameName(), 161*cdf0e10cSrcweir aEmptyStr, Size() ); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir sal_Bool bEnableGraphicToGallery; 166*cdf0e10cSrcweir if ( sal_True == (bEnableGraphicToGallery = bLink) ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir GalleryExplorer::FillThemeList( aThemeList ); 169*cdf0e10cSrcweir if ( aThemeList.Count() ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir PopupMenu *pMenu = GetPopupMenu(MN_READONLY_GRAPHICTOGALLERY); 172*cdf0e10cSrcweir pMenu->CheckItem( MN_READONLY_TOGALLERYLINK, bGrfToGalleryAsLnk ); 173*cdf0e10cSrcweir pMenu->CheckItem( MN_READONLY_TOGALLERYCOPY, !bGrfToGalleryAsLnk ); 174*cdf0e10cSrcweir for ( sal_uInt16 i=0; i < aThemeList.Count(); ++i ) 175*cdf0e10cSrcweir pMenu->InsertItem( MN_READONLY_GRAPHICTOGALLERY+i + 3, 176*cdf0e10cSrcweir *(String*)aThemeList.GetObject( i ) ); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir else 179*cdf0e10cSrcweir bEnableGraphicToGallery = sal_False; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir EnableItem( MN_READONLY_GRAPHICTOGALLERY, bEnableGraphicToGallery ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir SfxViewFrame * pVFrame = rV.GetViewFrame(); 184*cdf0e10cSrcweir SfxDispatcher &rDis = *pVFrame->GetDispatcher(); 185*cdf0e10cSrcweir const SwPageDesc &rDesc = rSh.GetPageDesc( rSh.GetCurPageDesc() ); 186*cdf0e10cSrcweir pItem = &rDesc.GetMaster().GetBackground(); 187*cdf0e10cSrcweir sal_Bool bEnableBackGallery = sal_False, 188*cdf0e10cSrcweir bEnableBack = sal_False; 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir if ( GPOS_NONE != pItem->GetGraphicPos() ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir bEnableBack = sal_True; 193*cdf0e10cSrcweir if ( pItem->GetGraphicLink() ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir if ( !aThemeList.Count() ) 196*cdf0e10cSrcweir GalleryExplorer::FillThemeList( aThemeList ); 197*cdf0e10cSrcweir if ( aThemeList.Count() ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir PopupMenu *pMenu = GetPopupMenu(MN_READONLY_BACKGROUNDTOGALLERY); 200*cdf0e10cSrcweir pMenu->CheckItem( MN_READONLY_TOGALLERYLINK, bGrfToGalleryAsLnk ); 201*cdf0e10cSrcweir pMenu->CheckItem( MN_READONLY_TOGALLERYCOPY, !bGrfToGalleryAsLnk ); 202*cdf0e10cSrcweir bEnableBackGallery = sal_True; 203*cdf0e10cSrcweir for ( sal_uInt16 i=0; i < aThemeList.Count(); ++i ) 204*cdf0e10cSrcweir pMenu->InsertItem( MN_READONLY_BACKGROUNDTOGALLERY+i + 3, 205*cdf0e10cSrcweir *(String*)aThemeList.GetObject( i ) ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir EnableItem( MN_READONLY_SAVEBACKGROUND, bEnableBack ); 210*cdf0e10cSrcweir EnableItem( MN_READONLY_BACKGROUNDTOGALLERY, bEnableBackGallery ); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir if ( !rSh.GetViewOptions()->IsGraphic() ) 213*cdf0e10cSrcweir CheckItem( MN_READONLY_GRAPHICOFF ); 214*cdf0e10cSrcweir else 215*cdf0e10cSrcweir EnableItem( MN_READONLY_LOADGRAPHIC, sal_False ); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir sal_Bool bReloadFrame = 0 != rSh.GetView().GetViewFrame()->GetFrame().GetParentFrame(); 218*cdf0e10cSrcweir EnableItem( MN_READONLY_RELOAD_FRAME, 219*cdf0e10cSrcweir bReloadFrame ); 220*cdf0e10cSrcweir EnableItem( MN_READONLY_RELOAD, !bReloadFrame); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir Check( MN_READONLY_EDITDOC, SID_EDITDOC, rDis ); 223*cdf0e10cSrcweir Check( MN_READONLY_SELECTION_MODE, FN_READONLY_SELECTION_MODE, rDis ); 224*cdf0e10cSrcweir Check( MN_READONLY_SOURCEVIEW, SID_SOURCEVIEW, rDis ); 225*cdf0e10cSrcweir Check( MN_READONLY_BROWSE_BACKWARD, SID_BROWSE_BACKWARD,rDis ); 226*cdf0e10cSrcweir Check( MN_READONLY_BROWSE_FORWARD, SID_BROWSE_FORWARD, rDis ); 227*cdf0e10cSrcweir #ifdef WNT 228*cdf0e10cSrcweir Check( MN_READONLY_PLUGINOFF, SID_PLUGINS_ACTIVE, rDis ); 229*cdf0e10cSrcweir #endif 230*cdf0e10cSrcweir Check( MN_READONLY_OPENURL, SID_OPENDOC, rDis ); 231*cdf0e10cSrcweir Check( MN_READONLY_OPENURLNEW, SID_OPENDOC, rDis ); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir SfxPoolItem* pState; 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir SfxItemState eState = pVFrame->GetBindings().QueryState( SID_COPY, pState ); 236*cdf0e10cSrcweir Check( MN_READONLY_COPY, SID_COPY, rDis ); 237*cdf0e10cSrcweir if(eState < SFX_ITEM_AVAILABLE) 238*cdf0e10cSrcweir EnableItem( MN_READONLY_COPY, sal_False ); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir eState = pVFrame->GetBindings().QueryState( SID_EDITDOC, pState ); 241*cdf0e10cSrcweir if ( 242*cdf0e10cSrcweir eState < SFX_ITEM_DEFAULT || 243*cdf0e10cSrcweir (rSh.IsGlobalDoc() && rView.GetDocShell()->IsReadOnlyUI()) 244*cdf0e10cSrcweir ) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir EnableItem( MN_READONLY_EDITDOC, sal_False ); 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir if ( !sURL.Len() ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir EnableItem( MN_READONLY_OPENURL, sal_False ); 252*cdf0e10cSrcweir EnableItem( MN_READONLY_OPENURLNEW, sal_False ); 253*cdf0e10cSrcweir EnableItem( MN_READONLY_COPYLINK, sal_False ); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir Check( SID_WIN_FULLSCREEN, SID_WIN_FULLSCREEN, rDis ); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir RemoveDisabledEntries( sal_True, sal_True ); 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir void SwReadOnlyPopup::Execute( Window* pWin, const Point &rPixPos ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir sal_uInt16 nId = PopupMenu::Execute( 263*cdf0e10cSrcweir pWin, 264*cdf0e10cSrcweir rPixPos ); 265*cdf0e10cSrcweir Execute(pWin, nId); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir /*-- 17.03.2004 13:06:18--------------------------------------------------- 269*cdf0e10cSrcweir execute the resulting ID only - necessary to support XContextMenuInterception 270*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 271*cdf0e10cSrcweir void SwReadOnlyPopup::Execute( Window* pWin, sal_uInt16 nId ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell(); 274*cdf0e10cSrcweir SfxDispatcher &rDis = *rView.GetViewFrame()->GetDispatcher(); 275*cdf0e10cSrcweir if ( nId >= MN_READONLY_GRAPHICTOGALLERY ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir String sTmp; 278*cdf0e10cSrcweir sal_uInt16 nSaveId; 279*cdf0e10cSrcweir if ( nId >= MN_READONLY_BACKGROUNDTOGALLERY ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir nId -= MN_READONLY_BACKGROUNDTOGALLERY+3; 282*cdf0e10cSrcweir nSaveId = MN_READONLY_SAVEBACKGROUND; 283*cdf0e10cSrcweir sTmp = *pItem->GetGraphicLink(); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir else 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir nId -= MN_READONLY_GRAPHICTOGALLERY+3; 288*cdf0e10cSrcweir nSaveId = MN_READONLY_SAVEGRAPHIC; 289*cdf0e10cSrcweir sTmp = sGrfName; 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir if ( !bGrfToGalleryAsLnk ) 292*cdf0e10cSrcweir sTmp = SaveGraphic( nSaveId ); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir if ( sTmp.Len() ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir String sThemeName( *(String*)aThemeList.GetObject( nId )); 297*cdf0e10cSrcweir GalleryExplorer::InsertURL( sThemeName, sTmp ); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir return; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir TransferDataContainer* pClipCntnr = 0; 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir sal_uInt16 nExecId = USHRT_MAX; 305*cdf0e10cSrcweir sal_uInt16 nFilter = USHRT_MAX; 306*cdf0e10cSrcweir switch( nId ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir case SID_WIN_FULLSCREEN : nExecId = SID_WIN_FULLSCREEN; break; 309*cdf0e10cSrcweir case MN_READONLY_OPENURL: nFilter = URLLOAD_NOFILTER; break; 310*cdf0e10cSrcweir case MN_READONLY_OPENURLNEW: nFilter = URLLOAD_NEWVIEW; break; 311*cdf0e10cSrcweir case MN_READONLY_COPY: nExecId = SID_COPY; break; 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir case MN_READONLY_EDITDOC: nExecId = SID_EDITDOC; break; 314*cdf0e10cSrcweir case MN_READONLY_SELECTION_MODE: nExecId = FN_READONLY_SELECTION_MODE; break; 315*cdf0e10cSrcweir case MN_READONLY_RELOAD: 316*cdf0e10cSrcweir case MN_READONLY_RELOAD_FRAME: 317*cdf0e10cSrcweir rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(SID_RELOAD); 318*cdf0e10cSrcweir break; 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir case MN_READONLY_BROWSE_BACKWARD: nExecId = SID_BROWSE_BACKWARD;break; 321*cdf0e10cSrcweir case MN_READONLY_BROWSE_FORWARD: nExecId = SID_BROWSE_FORWARD; break; 322*cdf0e10cSrcweir case MN_READONLY_SOURCEVIEW: nExecId = SID_SOURCEVIEW; break; 323*cdf0e10cSrcweir case MN_READONLY_SAVEGRAPHIC: 324*cdf0e10cSrcweir case MN_READONLY_SAVEBACKGROUND: 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir SaveGraphic( nId ); 327*cdf0e10cSrcweir break; 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir case MN_READONLY_COPYLINK: 330*cdf0e10cSrcweir pClipCntnr = new TransferDataContainer; 331*cdf0e10cSrcweir pClipCntnr->CopyString( sURL ); 332*cdf0e10cSrcweir break; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir case MN_READONLY_COPYGRAPHIC: 335*cdf0e10cSrcweir pClipCntnr = new TransferDataContainer; 336*cdf0e10cSrcweir pClipCntnr->CopyGraphic( aGraphic ); 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir if( pImageMap ) 339*cdf0e10cSrcweir pClipCntnr->CopyImageMap( *pImageMap ); 340*cdf0e10cSrcweir if( pTargetURL ) 341*cdf0e10cSrcweir pClipCntnr->CopyINetImage( *pTargetURL ); 342*cdf0e10cSrcweir break; 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir case MN_READONLY_LOADGRAPHIC: 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir sal_Bool bModified = rSh.IsModified(); 347*cdf0e10cSrcweir SwViewOption aOpt( *rSh.GetViewOptions() ); 348*cdf0e10cSrcweir aOpt.SetGraphic( sal_True ); 349*cdf0e10cSrcweir rSh.ApplyViewOptions( aOpt ); 350*cdf0e10cSrcweir if(!bModified) 351*cdf0e10cSrcweir rSh.ResetModified(); 352*cdf0e10cSrcweir break; 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir case MN_READONLY_GRAPHICOFF: nExecId = FN_VIEW_GRAPHIC; break; 355*cdf0e10cSrcweir #ifdef WNT 356*cdf0e10cSrcweir case MN_READONLY_PLUGINOFF: nExecId = SID_PLUGINS_ACTIVE; break; 357*cdf0e10cSrcweir #endif 358*cdf0e10cSrcweir case MN_READONLY_TOGALLERYLINK: 359*cdf0e10cSrcweir SW_MOD()->GetModuleConfig()->SetGrfToGalleryAsLnk( sal_True ); 360*cdf0e10cSrcweir break; 361*cdf0e10cSrcweir case MN_READONLY_TOGALLERYCOPY: 362*cdf0e10cSrcweir SW_MOD()->GetModuleConfig()->SetGrfToGalleryAsLnk( sal_False ); 363*cdf0e10cSrcweir break; 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir default: //forward the id to the SfxBindings 366*cdf0e10cSrcweir nExecId = nId; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir if( USHRT_MAX != nExecId ) 369*cdf0e10cSrcweir rDis.GetBindings()->Execute( nExecId ); 370*cdf0e10cSrcweir if( USHRT_MAX != nFilter ) 371*cdf0e10cSrcweir ::LoadURL( sURL, &rSh, nFilter, &sTargetFrameName); 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir if( pClipCntnr ) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir STAR_REFERENCE( datatransfer::XTransferable ) xRef( pClipCntnr ); 376*cdf0e10cSrcweir if( pClipCntnr->HasAnyData() ) 377*cdf0e10cSrcweir pClipCntnr->CopyToClipboard( pWin ); 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir static void lcl_GetPreferedExtension( String &rExt, const Graphic &rGrf ) 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir // dann ggfs. ueber die native-Info der Grafik den "besten" 383*cdf0e10cSrcweir // Filter vorschlagen 384*cdf0e10cSrcweir const sal_Char* pExt = "png"; 385*cdf0e10cSrcweir switch( const_cast<Graphic&>(rGrf).GetLink().GetType() ) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_GIF: pExt = "gif"; break; 388*cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_TIF: pExt = "tif"; break; 389*cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_WMF: pExt = "wmf"; break; 390*cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_MET: pExt = "met"; break; 391*cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_PCT: pExt = "pct"; break; 392*cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_JPG: pExt = "jpg"; break; 393*cdf0e10cSrcweir default:; //prevent warning 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir rExt.AssignAscii( pExt ); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir String SwReadOnlyPopup::SaveGraphic( sal_uInt16 nId ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir //Namen der Grafik herausfischen. 403*cdf0e10cSrcweir String aName; 404*cdf0e10cSrcweir if ( MN_READONLY_SAVEBACKGROUND == nId ) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir if ( pItem->GetGraphicLink() ) 407*cdf0e10cSrcweir sGrfName = *pItem->GetGraphicLink(); 408*cdf0e10cSrcweir ((SvxBrushItem*)pItem)->SetDoneLink( Link() ); 409*cdf0e10cSrcweir const Graphic *pGrf = pItem->GetGraphic(); 410*cdf0e10cSrcweir if ( pGrf ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir aGraphic = *pGrf; 413*cdf0e10cSrcweir if ( pItem->GetGraphicLink() ) 414*cdf0e10cSrcweir sGrfName = *pItem->GetGraphicLink(); 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir else 417*cdf0e10cSrcweir return aEmptyStr; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir return ExportGraphic( aGraphic, sGrfName ); 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir String ExportGraphic( const Graphic &rGraphic, const String &rGrfName ) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir SvtPathOptions aPathOpt; 425*cdf0e10cSrcweir String sGrfPath( aPathOpt.GetGraphicPath() ); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, 0 ); 428*cdf0e10cSrcweir Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker(); 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir // aExpDlg.SetHelpId(HID_FILEDLG_ROMENU); 431*cdf0e10cSrcweir INetURLObject aPath; 432*cdf0e10cSrcweir aPath.SetSmartURL( sGrfPath ); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir //Namen der Grafik herausfischen. 435*cdf0e10cSrcweir String aName = rGrfName; 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir aDlgHelper.SetTitle( SW_RESSTR(STR_EXPORT_GRAFIK_TITLE)); 438*cdf0e10cSrcweir aDlgHelper.SetDisplayDirectory( aPath.GetMainURL(INetURLObject::DECODE_TO_IURI) ); 439*cdf0e10cSrcweir INetURLObject aURL; 440*cdf0e10cSrcweir aURL.SetSmartURL( aName ); 441*cdf0e10cSrcweir aDlgHelper.SetFileName( aURL.GetName() ); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir GraphicFilter& rGF = *GraphicFilter::GetGraphicFilter(); 444*cdf0e10cSrcweir const sal_uInt16 nCount = rGF.GetExportFormatCount(); 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir String aExt( aURL.GetExtension() ); 447*cdf0e10cSrcweir if( !aExt.Len() ) 448*cdf0e10cSrcweir lcl_GetPreferedExtension( aExt, rGraphic ); 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir aExt.ToLowerAscii(); 451*cdf0e10cSrcweir sal_uInt16 nDfltFilter = USHRT_MAX; 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; i++ ) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir xFltMgr->appendFilter( rGF.GetExportFormatName( i ), rGF.GetExportWildcard( i ) ); 458*cdf0e10cSrcweir if ( COMPARE_EQUAL == aExt.CompareIgnoreCaseToAscii(rGF.GetExportFormatShortName( i ).ToLowerAscii() )) 459*cdf0e10cSrcweir nDfltFilter = i; 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir if ( USHRT_MAX == nDfltFilter ) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir //"falsche" Extension? 464*cdf0e10cSrcweir lcl_GetPreferedExtension( aExt, rGraphic ); 465*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; ++i ) 466*cdf0e10cSrcweir if ( aExt == rGF.GetExportFormatShortName( i ).ToLowerAscii() ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir nDfltFilter = i; 469*cdf0e10cSrcweir break; 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir if( USHRT_MAX != nDfltFilter ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir xFltMgr->setCurrentFilter( rGF.GetExportFormatName( nDfltFilter ) ) ; 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir if( aDlgHelper.Execute() == ERRCODE_NONE ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir String sPath( xFP->getFiles().getConstArray()[0] ); 480*cdf0e10cSrcweir //verwendeten Pfad merken - bitte nicht wieder wegoptimieren! 481*cdf0e10cSrcweir aPath.SetSmartURL( sPath); 482*cdf0e10cSrcweir sGrfPath = aPath.GetPath(); 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir if( rGrfName.Len() && 485*cdf0e10cSrcweir nDfltFilter == rGF.GetExportFormatNumber( xFltMgr->getCurrentFilter())) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir //Versuchen die Originalgrafik zu speichern. 488*cdf0e10cSrcweir SfxMedium aIn( rGrfName, STREAM_READ | STREAM_NOCREATE, 489*cdf0e10cSrcweir sal_True ); 490*cdf0e10cSrcweir if( aIn.GetInStream() && !aIn.GetInStream()->GetError() ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir SfxMedium aOut( sPath, STREAM_WRITE | STREAM_SHARE_DENYNONE, 493*cdf0e10cSrcweir sal_False); 494*cdf0e10cSrcweir if( aOut.GetOutStream() && !aOut.GetOutStream()->GetError()) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir *aOut.GetOutStream() << *aIn.GetInStream(); 497*cdf0e10cSrcweir if ( 0 == aIn.GetError() ) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir aOut.Close(); 500*cdf0e10cSrcweir aOut.Commit(); 501*cdf0e10cSrcweir if ( 0 == aOut.GetError() ) 502*cdf0e10cSrcweir return sPath; 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir sal_uInt16 nFilter; 509*cdf0e10cSrcweir if ( xFltMgr->getCurrentFilter().getLength() && rGF.GetExportFormatCount() ) 510*cdf0e10cSrcweir nFilter = rGF.GetExportFormatNumber( xFltMgr->getCurrentFilter() ); 511*cdf0e10cSrcweir else 512*cdf0e10cSrcweir nFilter = GRFILTER_FORMAT_DONTKNOW; 513*cdf0e10cSrcweir String aFilter( rGF.GetExportFormatShortName( nFilter ) ); 514*cdf0e10cSrcweir XOutBitmap::WriteGraphic( rGraphic, sPath, aFilter, 515*cdf0e10cSrcweir XOUTBMP_DONT_EXPAND_FILENAME|XOUTBMP_DONT_ADD_EXTENSION ); 516*cdf0e10cSrcweir return sPath; 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir return aEmptyStr; 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir 524