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