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/ipclient.hxx>
22 #include <sfx2/viewsh.hxx>
28 #include <notxtfrm.hxx>
32 #include <IDocumentLinksAdministration.hxx>
33 #include <sfx2/linkmgr.hxx>
35 using namespace com::sun::star
;
37 SwFlyFrame
*SwFEShell::FindFlyFrame( const uno::Reference
< embed::XEmbeddedObject
>& xObj
) const
39 SwFlyFrame
*pFly
= GetSelectedFlyFrame();
40 if ( pFly
&& pFly
->Lower() && pFly
->Lower()->IsNoTextFrame() )
42 SwOLENode
*pNd
= static_cast<SwNoTextFrame
*>(pFly
->Lower())->GetNode()->GetOLENode();
43 if ( !pNd
|| pNd
->GetOLEObj().GetOleRef() != xObj
)
51 // No or wrong fly selected: we have to search.
54 sal_uLong nSttIdx
= GetNodes().GetEndOfAutotext().StartOfSectionIndex() + 1,
55 nEndIdx
= GetNodes().GetEndOfAutotext().GetIndex();
56 while( nSttIdx
< nEndIdx
&&
57 nullptr != (pStNd
= GetNodes()[ nSttIdx
]->GetStartNode()) )
59 SwNode
*pNd
= GetNodes()[ nSttIdx
+1 ];
60 if ( pNd
->IsOLENode() &&
61 static_cast<SwOLENode
*>(pNd
)->GetOLEObj().GetOleRef() == xObj
)
64 SwFrame
*pFrame
= static_cast<SwOLENode
*>(pNd
)->getLayoutFrame( GetLayout() );
66 pFly
= pFrame
->FindFlyFrame();
69 nSttIdx
= pStNd
->EndOfSectionIndex() + 1;
72 OSL_ENSURE( bExist
, "OLE-Object unknown and FlyFrame not found." );
77 OUString
SwFEShell::GetUniqueOLEName() const
79 return GetDoc()->GetUniqueOLEName();
82 OUString
SwFEShell::GetUniqueFrameName() const
84 return GetDoc()->GetUniqueFrameName();
87 OUString
SwFEShell::GetUniqueShapeName() const
89 return GetDoc()->GetUniqueShapeName();
92 bool SwFEShell::FinishOLEObj() // Server is terminated
94 SfxInPlaceClient
* pIPClient
= GetSfxViewShell()->GetIPClient();
98 bool bRet
= pIPClient
->IsObjectInPlaceActive();
101 if( CNT_OLE
== GetCntType() )
102 ClearAutomaticContour();
104 if( static_cast<SwOleClient
*>(pIPClient
)->IsCheckForOLEInCaption() !=
105 IsCheckForOLEInCaption() )
106 SetCheckForOLEInCaption( !IsCheckForOLEInCaption() );
108 // enable update of the link preview
109 comphelper::EmbeddedObjectContainer
& rEmbeddedObjectContainer
= GetDoc()->GetDocShell()->getEmbeddedObjectContainer();
110 const bool aUserAllowsLinkUpdate
= rEmbeddedObjectContainer
.getUserAllowsLinkUpdate();
111 rEmbeddedObjectContainer
.setUserAllowsLinkUpdate(true);
113 // leave UIActive state
114 pIPClient
->DeactivateObject();
116 // if we have more than one link let's update them too
117 sfx2::LinkManager
& rLinkManager
= GetDoc()->getIDocumentLinksAdministration().GetLinkManager();
118 if (rLinkManager
.GetLinks().size() > 1)
119 rLinkManager
.UpdateAllLinks(false, false, nullptr);
121 // return back original value of the "update of the link preview" flag
122 rEmbeddedObjectContainer
.setUserAllowsLinkUpdate(aUserAllowsLinkUpdate
);
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */