merge the formfield patch from ooo-build
[ooovba.git] / sd / source / core / pglink.cxx
blob55791efc6a067c2be376784a6dc30839997efe56
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pglink.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #ifndef _SVXLINK_HXX
35 #include <svx/linkmgr.hxx>
36 #endif
38 #include "pglink.hxx"
39 #include "sdpage.hxx"
40 #include "drawdoc.hxx"
43 /*************************************************************************
45 |* Ctor
47 \************************************************************************/
49 SdPageLink::SdPageLink(SdPage* pPg, const String& rFileName,
50 const String& rBookmarkName) :
51 ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, FORMAT_FILE),
52 pPage(pPg)
54 pPage->SetFileName(rFileName);
55 pPage->SetBookmarkName(rBookmarkName);
59 /*************************************************************************
61 |* Dtor
63 \************************************************************************/
66 SdPageLink::~SdPageLink()
70 /*************************************************************************
72 |* Daten haben sich geaendert
74 \************************************************************************/
76 void SdPageLink::DataChanged( const String& ,
77 const ::com::sun::star::uno::Any& )
79 SdDrawDocument* pDoc = (SdDrawDocument*) pPage->GetModel();
80 SvxLinkManager* pLinkManager = pDoc!=NULL ? pDoc->GetLinkManager() : NULL;
82 if (pLinkManager)
84 /**********************************************************************
85 * Nur Standardseiten duerfen gelinkt sein
86 * Die entsprechenden Notizseiten werden automatisch aktualisiert
87 **********************************************************************/
88 String aFileName;
89 String aBookmarkName;
90 String aFilterName;
91 pLinkManager->GetDisplayNames( this,0, &aFileName, &aBookmarkName,
92 &aFilterName);
93 pPage->SetFileName(aFileName);
94 pPage->SetBookmarkName(aBookmarkName);
96 SdDrawDocument* pBookmarkDoc = pDoc->OpenBookmarkDoc(aFileName);
98 if (pBookmarkDoc)
100 /******************************************************************
101 * Die gelinkte Seite wird im Model replaced
102 ******************************************************************/
103 if (aBookmarkName.Len() == 0)
105 // Kein Seitenname angegeben: es wird die erste Seite genommen
106 aBookmarkName = pBookmarkDoc->GetSdPage(0, PK_STANDARD)->GetName();
107 pPage->SetBookmarkName(aBookmarkName);
110 List aBookmarkList;
111 aBookmarkList.Insert(&aBookmarkName);
112 USHORT nInsertPos = pPage->GetPageNum();
113 BOOL bLink = TRUE;
114 BOOL bReplace = TRUE;
115 BOOL bNoDialogs = FALSE;
116 BOOL bCopy = FALSE;
118 if( pDoc->pDocLockedInsertingLinks )
120 // resolving links while loading pDoc
121 bNoDialogs = TRUE;
122 bCopy = TRUE;
125 pDoc->InsertBookmarkAsPage(&aBookmarkList, NULL, bLink, bReplace,
126 nInsertPos, bNoDialogs, NULL, bCopy, TRUE, TRUE);
128 if( !pDoc->pDocLockedInsertingLinks )
129 pDoc->CloseBookmarkDoc();
134 /*************************************************************************
136 |* Link an oder abmelden
138 \************************************************************************/
140 void SdPageLink::Closed()
142 // Die Verbindung wird aufgehoben
143 pPage->SetFileName(String());
144 pPage->SetBookmarkName(String());
146 SvBaseLink::Closed();