1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 #ifndef _SVXLINK_HXX 28 #include <sfx2/linkmgr.hxx> 29 #endif 30 31 #include "pglink.hxx" 32 #include "sdpage.hxx" 33 #include "drawdoc.hxx" 34 35 36 /************************************************************************* 37 |* 38 |* Ctor 39 |* 40 \************************************************************************/ 41 42 SdPageLink::SdPageLink(SdPage* pPg, const String& rFileName, 43 const String& rBookmarkName) : 44 ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, FORMAT_FILE), 45 pPage(pPg) 46 { 47 pPage->SetFileName(rFileName); 48 pPage->SetBookmarkName(rBookmarkName); 49 } 50 51 52 /************************************************************************* 53 |* 54 |* Dtor 55 |* 56 \************************************************************************/ 57 58 59 SdPageLink::~SdPageLink() 60 { 61 } 62 63 /************************************************************************* 64 |* 65 |* Daten haben sich geaendert 66 |* 67 \************************************************************************/ 68 69 void SdPageLink::DataChanged( const String& , 70 const ::com::sun::star::uno::Any& ) 71 { 72 SdDrawDocument* pDoc = (SdDrawDocument*) pPage->GetModel(); 73 sfx2::LinkManager* pLinkManager = pDoc!=NULL ? pDoc->GetLinkManager() : NULL; 74 75 if (pLinkManager) 76 { 77 /********************************************************************** 78 * Nur Standardseiten duerfen gelinkt sein 79 * Die entsprechenden Notizseiten werden automatisch aktualisiert 80 **********************************************************************/ 81 String aFileName; 82 String aBookmarkName; 83 String aFilterName; 84 pLinkManager->GetDisplayNames( this,0, &aFileName, &aBookmarkName, 85 &aFilterName); 86 pPage->SetFileName(aFileName); 87 pPage->SetBookmarkName(aBookmarkName); 88 89 SdDrawDocument* pBookmarkDoc = pDoc->OpenBookmarkDoc(aFileName); 90 91 if (pBookmarkDoc) 92 { 93 /****************************************************************** 94 * Die gelinkte Seite wird im Model replaced 95 ******************************************************************/ 96 if (aBookmarkName.Len() == 0) 97 { 98 // Kein Seitenname angegeben: es wird die erste Seite genommen 99 aBookmarkName = pBookmarkDoc->GetSdPage(0, PK_STANDARD)->GetName(); 100 pPage->SetBookmarkName(aBookmarkName); 101 } 102 103 List aBookmarkList; 104 aBookmarkList.Insert(&aBookmarkName); 105 sal_uInt16 nInsertPos = pPage->GetPageNum(); 106 sal_Bool bLink = sal_True; 107 sal_Bool bReplace = sal_True; 108 sal_Bool bNoDialogs = sal_False; 109 sal_Bool bCopy = sal_False; 110 111 if( pDoc->pDocLockedInsertingLinks ) 112 { 113 // resolving links while loading pDoc 114 bNoDialogs = sal_True; 115 bCopy = sal_True; 116 } 117 118 pDoc->InsertBookmarkAsPage(&aBookmarkList, NULL, bLink, bReplace, 119 nInsertPos, bNoDialogs, NULL, bCopy, sal_True, sal_True); 120 121 if( !pDoc->pDocLockedInsertingLinks ) 122 pDoc->CloseBookmarkDoc(); 123 } 124 } 125 } 126 127 /************************************************************************* 128 |* 129 |* Link an oder abmelden 130 |* 131 \************************************************************************/ 132 133 void SdPageLink::Closed() 134 { 135 // Die Verbindung wird aufgehoben 136 pPage->SetFileName(String()); 137 pPage->SetBookmarkName(String()); 138 139 SvBaseLink::Closed(); 140 } 141 142 143 144