LibreOffice Module sw (master) 1
feflyole.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
21#include <sfx2/ipclient.hxx>
22#include <sfx2/viewsh.hxx>
23#include <osl/diagnose.h>
24
25#include <fesh.hxx>
26#include <cntfrm.hxx>
27#include <flyfrm.hxx>
28#include <doc.hxx>
29#include <notxtfrm.hxx>
30#include <ndole.hxx>
31#include <swcli.hxx>
32#include <docsh.hxx>
34#include <sfx2/linkmgr.hxx>
35
36using namespace com::sun::star;
37
38SwFlyFrame *SwFEShell::FindFlyFrame( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
39{
41 if ( pFly && pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
42 {
43 SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
44 if ( !pNd || pNd->GetOLEObj().GetOleRef() != xObj )
45 pFly = nullptr;
46 }
47 else
48 pFly = nullptr;
49
50 if ( !pFly )
51 {
52 // No or wrong fly selected: we have to search.
53 bool bExist = false;
54 SwStartNode *pStNd;
56 nEndIdx = GetNodes().GetEndOfAutotext().GetIndex();
57 while( nSttIdx < nEndIdx &&
58 nullptr != (pStNd = GetNodes()[ nSttIdx ]->GetStartNode()) )
59 {
60 SwNode *pNd = GetNodes()[ nSttIdx+1 ];
61 if ( pNd->IsOLENode() &&
62 static_cast<SwOLENode*>(pNd)->GetOLEObj().GetOleRef() == xObj )
63 {
64 bExist = true;
65 SwFrame *pFrame = static_cast<SwOLENode*>(pNd)->getLayoutFrame( GetLayout() );
66 if ( pFrame )
67 pFly = pFrame->FindFlyFrame();
68 break;
69 }
70 nSttIdx = pStNd->EndOfSectionIndex() + 1;
71 }
72
73 OSL_ENSURE( bExist, "OLE-Object unknown and FlyFrame not found." );
74 }
75 return pFly;
76}
77
79{
80 return GetDoc()->GetUniqueOLEName();
81}
82
84{
85 return GetDoc()->GetUniqueFrameName();
86}
87
88bool SwFEShell::FinishOLEObj() // Server is terminated
89{
91 if ( !pIPClient )
92 return false;
93
94 bool bRet = pIPClient->IsObjectInPlaceActive();
95 if( bRet )
96 {
97 if( CNT_OLE == GetCntType() )
99
100 if( static_cast<SwOleClient*>(pIPClient)->IsCheckForOLEInCaption() !=
103
104 // enable update of the link preview
106 const bool aUserAllowsLinkUpdate = rEmbeddedObjectContainer.getUserAllowsLinkUpdate();
107 rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
108
109 // leave UIActive state
110 pIPClient->DeactivateObject();
111
112 // if we have more than one link let's update them too
114 if (rLinkManager.GetLinks().size() > 1)
115 rLinkManager.UpdateAllLinks(false, false, nullptr);
116
117 // return back original value of the "update of the link preview" flag
118 rEmbeddedObjectContainer.setUserAllowsLinkUpdate(aUserAllowsLinkUpdate);
119 }
120 return bRet;
121}
122
123/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sfx2::LinkManager & GetLinkManager()=0
bool IsObjectInPlaceActive() const
void DeactivateObject()
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
SfxInPlaceClient * GetIPClient() const
OUString GetUniqueOLEName() const
Definition: doclay.cxx:1400
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
Definition: doc.cxx:274
OUString GetUniqueFrameName() const
Definition: doclay.cxx:1405
SwDocShell * GetDocShell()
Definition: doc.hxx:1370
sal_uInt16 GetCntType() const
Determine form of content. Return Type at CurrentCursor->SPoint.
Definition: edws.cxx:126
void ClearAutomaticContour()
If there's an automatic, not manipulated polygon at the selected notxtnode, it has to be deleted,...
Definition: editsh.cxx:336
SwFlyFrame * GetSelectedFlyFrame() const
Definition: fefly1.cxx:277
void SetCheckForOLEInCaption(bool bFlag)
Definition: fesh.hxx:461
OUString GetUniqueFrameName() const
Definition: feflyole.cxx:83
bool IsCheckForOLEInCaption() const
Check resize of OLE-Object.
Definition: fesh.hxx:460
OUString GetUniqueOLEName() const
Definition: feflyole.cxx:78
SAL_DLLPRIVATE SwFlyFrame * FindFlyFrame(const css::uno::Reference< css::embed::XEmbeddedObject > &) const
Definition: feflyole.cxx:38
bool FinishOLEObj()
Shutdown server.
Definition: feflyole.cxx:88
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
Base class of the Writer layout elements.
Definition: frame.hxx:315
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1117
bool IsNoTextFrame() const
Definition: frame.hxx:1244
const SwFrame * Lower() const
Definition: layfrm.hxx:101
Base class of the Writer document model elements.
Definition: node.hxx:98
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodeOffset StartOfSectionIndex() const
Definition: node.hxx:687
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:165
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:691
bool IsOLENode() const
Definition: node.hxx:193
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:158
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:116
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:1012
Starts a section of nodes in the document model.
Definition: node.hxx:348
const SwNodes & GetNodes() const
Definition: viewsh.cxx:2181
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2163
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:470
void UpdateAllLinks(bool bAskUpdate, bool bUpdateGrfLinks, weld::Window *pParentWin)
const SvBaseLinks & GetLinks() const
static SwNode * GetStartNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
Definition: docglbl.cxx:89
#define CNT_OLE
Definition: editsh.hxx:133
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:1043