LibreOffice Module sd (master) 1
pglink.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sfx2/linkmgr.hxx>
21
22#include <pglink.hxx>
23#include <sdpage.hxx>
24#include <drawdoc.hxx>
25
26/*************************************************************************
27|*
28|* Ctor
29|*
30\************************************************************************/
31
32SdPageLink::SdPageLink(SdPage* pPg, const OUString& rFileName,
33 const OUString& rBookmarkName) :
35 pPage(pPg)
36{
37 pPage->SetFileName(rFileName);
38 pPage->SetBookmarkName(rBookmarkName);
39}
40
41/*************************************************************************
42|*
43|* Dtor
44|*
45\************************************************************************/
46
48{
49}
50
51/*************************************************************************
52|*
53|* Date have changed
54|*
55\************************************************************************/
56
58 const OUString&, const css::uno::Any& )
59{
60 SdDrawDocument* pDoc = static_cast<SdDrawDocument*>( &pPage->getSdrModelFromSdrPage() );
61 sfx2::LinkManager* pLinkManager = pDoc!=nullptr ? pDoc->GetLinkManager() : nullptr;
62
63 if (pLinkManager)
64 {
65 /**********************************************************************
66 * Only standard pages are allowed to be linked
67 * The corresponding note pages are updated automatically
68 **********************************************************************/
69 OUString aFileName;
70 OUString aBookmarkName;
71 OUString aFilterName;
72 sfx2::LinkManager::GetDisplayNames( this,nullptr, &aFileName, &aBookmarkName,
73 &aFilterName);
74 pPage->SetFileName(aFileName);
75 pPage->SetBookmarkName(aBookmarkName);
76
77 SdDrawDocument* pBookmarkDoc = pDoc->OpenBookmarkDoc(aFileName);
78
79 if (pBookmarkDoc)
80 {
81 /******************************************************************
82 * the linked page is replaced in the model
83 ******************************************************************/
84 if (aBookmarkName.isEmpty())
85 {
86 // no page name specified: we assume it is the first page
87 aBookmarkName = pBookmarkDoc->GetSdPage(0, PageKind::Standard)->GetName();
88 pPage->SetBookmarkName(aBookmarkName);
89 }
90
91 std::vector<OUString> aBookmarkList { aBookmarkName };
92 sal_uInt16 nInsertPos = pPage->GetPageNum();
93 bool bNoDialogs = false;
94 bool bCopy = false;
95
97 {
98 // resolving links while loading pDoc
99 bNoDialogs = true;
100 bCopy = true;
101 }
102
103 pDoc->InsertBookmarkAsPage(aBookmarkList, nullptr, true/*bLink*/, true/*bReplace*/,
104 nInsertPos, bNoDialogs, nullptr, bCopy, true, true);
105
107 pDoc->CloseBookmarkDoc();
108 }
109 }
110 return SUCCESS;
111}
112
113/*************************************************************************
114|*
115|* Connect or disconnect link
116|*
117\************************************************************************/
118
120{
121 // the connection is closed
122 pPage->SetFileName(OUString());
123 pPage->SetBookmarkName(OUString());
124
125 SvBaseLink::Closed();
126}
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE bool InsertBookmarkAsPage(const std::vector< OUString > &rBookmarkList, std::vector< OUString > *pExchangeList, bool bLink, bool bReplace, sal_uInt16 nPgPos, bool bNoDialogs, ::sd::DrawDocShell *pBookmarkDocSh, bool bCopy, bool bMergeMasterPages, bool bPreservePageNames)
Insert pages into this document.
Definition: drawdoc3.cxx:375
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
Definition: drawdoc2.cxx:207
SdDrawDocument * OpenBookmarkDoc(const OUString &rBookmarkFile)
Definition: drawdoc3.cxx:256
static SAL_DLLPRIVATE SdDrawDocument * s_pDocLockedInsertingLinks
static to prevent recursions while resolving links
Definition: drawdoc.hxx:491
void CloseBookmarkDoc()
Definition: drawdoc3.cxx:1129
void SetBookmarkName(const OUString &aName)
Definition: sdpage.hxx:259
void SetFileName(const OUString &aName)
Definition: sdpage.hxx:257
const OUString & GetName() const
Definition: sdpage.cxx:2505
sfx2::LinkManager * GetLinkManager()
sal_uInt16 GetPageNum() const
SdrModel & getSdrModelFromSdrPage() const
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
SotClipboardFormatId
SfxLinkUpdateMode