1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <sfx2/linkmgr.hxx>
25 #include "drawdoc.hxx"
28 /*************************************************************************
32 \************************************************************************/
34 SdPageLink::SdPageLink(SdPage
* pPg
, const String
& rFileName
,
35 const String
& rBookmarkName
) :
36 ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL
, FORMAT_FILE
),
39 pPage
->SetFileName(rFileName
);
40 pPage
->SetBookmarkName(rBookmarkName
);
44 /*************************************************************************
48 \************************************************************************/
51 SdPageLink::~SdPageLink()
55 /*************************************************************************
59 \************************************************************************/
61 ::sfx2::SvBaseLink::UpdateResult
SdPageLink::DataChanged(
62 const String
&, const ::com::sun::star::uno::Any
& )
64 SdDrawDocument
* pDoc
= (SdDrawDocument
*) pPage
->GetModel();
65 sfx2::LinkManager
* pLinkManager
= pDoc
!=NULL
? pDoc
->GetLinkManager() : NULL
;
69 /**********************************************************************
70 * Only standard pages are allowed to be linked
71 * The corresponding note pages are updated automaticly
72 **********************************************************************/
76 pLinkManager
->GetDisplayNames( this,0, &aFileName
, &aBookmarkName
,
78 pPage
->SetFileName(aFileName
);
79 pPage
->SetBookmarkName(aBookmarkName
);
81 SdDrawDocument
* pBookmarkDoc
= pDoc
->OpenBookmarkDoc(aFileName
);
85 /******************************************************************
86 * the linked page is replaced in the model
87 ******************************************************************/
88 if (aBookmarkName
.Len() == 0)
90 // no page name specified: we assume it is the first page
91 aBookmarkName
= pBookmarkDoc
->GetSdPage(0, PK_STANDARD
)->GetName();
92 pPage
->SetBookmarkName(aBookmarkName
);
95 std::vector
<OUString
> aBookmarkList
;
96 aBookmarkList
.push_back(aBookmarkName
);
97 sal_uInt16 nInsertPos
= pPage
->GetPageNum();
98 sal_Bool bLink
= sal_True
;
99 sal_Bool bReplace
= sal_True
;
100 sal_Bool bNoDialogs
= sal_False
;
101 sal_Bool bCopy
= sal_False
;
103 if( pDoc
->pDocLockedInsertingLinks
)
105 // resolving links while loading pDoc
106 bNoDialogs
= sal_True
;
110 pDoc
->InsertBookmarkAsPage(aBookmarkList
, NULL
, bLink
, bReplace
,
111 nInsertPos
, bNoDialogs
, NULL
, bCopy
, sal_True
, sal_True
);
113 if( !pDoc
->pDocLockedInsertingLinks
)
114 pDoc
->CloseBookmarkDoc();
120 /*************************************************************************
122 |* Connect or disconnect link
124 \************************************************************************/
126 void SdPageLink::Closed()
128 // the connection is closed
129 pPage
->SetFileName(String());
130 pPage
->SetBookmarkName(String());
132 SvBaseLink::Closed();
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */