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>
23 #include <osl/diagnose.h>
29 #include <notxtfrm.hxx>
33 #include <IDocumentLinksAdministration.hxx>
34 #include <sfx2/linkmgr.hxx>
36 using namespace com::sun::star
;
38 SwFlyFrame
*SwFEShell::FindFlyFrame( const uno::Reference
< embed::XEmbeddedObject
>& xObj
) const
40 SwFlyFrame
*pFly
= GetSelectedFlyFrame();
41 if ( pFly
&& pFly
->Lower() && pFly
->Lower()->IsNoTextFrame() )
43 SwOLENode
*pNd
= static_cast<SwNoTextFrame
*>(pFly
->Lower())->GetNode()->GetOLENode();
44 if ( !pNd
|| pNd
->GetOLEObj().GetOleRef() != xObj
)
52 // No or wrong fly selected: we have to search.
55 SwNodeOffset nSttIdx
= GetNodes().GetEndOfAutotext().StartOfSectionIndex() + 1,
56 nEndIdx
= GetNodes().GetEndOfAutotext().GetIndex();
57 while( nSttIdx
< nEndIdx
&&
58 nullptr != (pStNd
= GetNodes()[ nSttIdx
]->GetStartNode()) )
60 SwNode
*pNd
= GetNodes()[ nSttIdx
+1 ];
61 if ( pNd
->IsOLENode() &&
62 static_cast<SwOLENode
*>(pNd
)->GetOLEObj().GetOleRef() == xObj
)
65 SwFrame
*pFrame
= static_cast<SwOLENode
*>(pNd
)->getLayoutFrame( GetLayout() );
67 pFly
= pFrame
->FindFlyFrame();
70 nSttIdx
= pStNd
->EndOfSectionIndex() + 1;
73 OSL_ENSURE( bExist
, "OLE-Object unknown and FlyFrame not found." );
78 OUString
SwFEShell::GetUniqueOLEName() const
80 return GetDoc()->GetUniqueOLEName();
83 OUString
SwFEShell::GetUniqueFrameName() const
85 return GetDoc()->GetUniqueFrameName();
88 bool SwFEShell::FinishOLEObj() // Server is terminated
90 SfxInPlaceClient
* pIPClient
= GetSfxViewShell()->GetIPClient();
94 bool bRet
= pIPClient
->IsObjectInPlaceActive();
97 if( CNT_OLE
== GetCntType() )
98 ClearAutomaticContour();
100 if( static_cast<SwOleClient
*>(pIPClient
)->IsCheckForOLEInCaption() !=
101 IsCheckForOLEInCaption() )
102 SetCheckForOLEInCaption( !IsCheckForOLEInCaption() );
104 // enable update of the link preview
105 comphelper::EmbeddedObjectContainer
& rEmbeddedObjectContainer
= GetDoc()->GetDocShell()->getEmbeddedObjectContainer();
106 const bool aUserAllowsLinkUpdate
= rEmbeddedObjectContainer
.getUserAllowsLinkUpdate();
107 rEmbeddedObjectContainer
.setUserAllowsLinkUpdate(true);
109 // leave UIActive state
110 pIPClient
->DeactivateObject();
112 // if we have more than one link let's update them too
113 sfx2::LinkManager
& rLinkManager
= GetDoc()->getIDocumentLinksAdministration().GetLinkManager();
114 if (rLinkManager
.GetLinks().size() > 1)
115 rLinkManager
.UpdateAllLinks(false, false, nullptr);
117 // return back original value of the "update of the link preview" flag
118 rEmbeddedObjectContainer
.setUserAllowsLinkUpdate(aUserAllowsLinkUpdate
);
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */