1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pglink.cxx,v $
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"
35 #include <svx/linkmgr.hxx>
40 #include "drawdoc.hxx"
43 /*************************************************************************
47 \************************************************************************/
49 SdPageLink::SdPageLink(SdPage
* pPg
, const String
& rFileName
,
50 const String
& rBookmarkName
) :
51 ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL
, FORMAT_FILE
),
54 pPage
->SetFileName(rFileName
);
55 pPage
->SetBookmarkName(rBookmarkName
);
59 /*************************************************************************
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
;
84 /**********************************************************************
85 * Nur Standardseiten duerfen gelinkt sein
86 * Die entsprechenden Notizseiten werden automatisch aktualisiert
87 **********************************************************************/
91 pLinkManager
->GetDisplayNames( this,0, &aFileName
, &aBookmarkName
,
93 pPage
->SetFileName(aFileName
);
94 pPage
->SetBookmarkName(aBookmarkName
);
96 SdDrawDocument
* pBookmarkDoc
= pDoc
->OpenBookmarkDoc(aFileName
);
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
);
111 aBookmarkList
.Insert(&aBookmarkName
);
112 USHORT nInsertPos
= pPage
->GetPageNum();
114 BOOL bReplace
= TRUE
;
115 BOOL bNoDialogs
= FALSE
;
118 if( pDoc
->pDocLockedInsertingLinks
)
120 // resolving links while loading pDoc
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();