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 
36 using namespace com::sun::star;
37 
38 SwFlyFrame *SwFEShell::FindFlyFrame( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
39 {
40  SwFlyFrame *pFly = GetSelectedFlyFrame();
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;
55  sal_uLong nSttIdx = GetNodes().GetEndOfAutotext().StartOfSectionIndex() + 1,
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 
88 bool SwFEShell::FinishOLEObj() // Server is terminated
89 {
90  SfxInPlaceClient* pIPClient = GetSfxViewShell()->GetIPClient();
91  if ( !pIPClient )
92  return false;
93 
94  bool bRet = pIPClient->IsObjectInPlaceActive();
95  if( bRet )
96  {
97  if( CNT_OLE == GetCntType() )
98  ClearAutomaticContour();
99 
100  if( static_cast<SwOleClient*>(pIPClient)->IsCheckForOLEInCaption() !=
101  IsCheckForOLEInCaption() )
102  SetCheckForOLEInCaption( !IsCheckForOLEInCaption() );
103 
104  // enable update of the link preview
105  comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = GetDoc()->GetDocShell()->getEmbeddedObjectContainer();
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
113  sfx2::LinkManager& rLinkManager = GetDoc()->getIDocumentLinksAdministration().GetLinkManager();
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: */
Starts a section of nodes in the document model.
Definition: node.hxx:312
Base class of the Writer layout elements.
Definition: frame.hxx:315
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:823
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
sal_uLong StartOfSectionIndex() const
Definition: node.hxx:674
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
bool IsObjectInPlaceActive() const
sal_uIntPtr sal_uLong
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:909
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1112
bool IsOLENode() const
Definition: node.hxx:653
static SwNodePtr GetStartNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
Definition: docglbl.cxx:89
const SvBaseLinks & GetLinks() const
bool FinishOLEObj()
Shutdown server.
Definition: feflyole.cxx:88
const SwFrame * Lower() const
Definition: layfrm.hxx:101
#define CNT_OLE
Definition: editsh.hxx:131
OUString GetUniqueFrameName() const
Definition: feflyole.cxx:83
void DeactivateObject()
SAL_DLLPRIVATE SwFlyFrame * FindFlyFrame(const css::uno::Reference< css::embed::XEmbeddedObject > &) const
Definition: feflyole.cxx:38
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:678
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
void UpdateAllLinks(bool bAskUpdate, bool bUpdateGrfLinks, weld::Window *pParentWin)
bool IsNoTextFrame() const
Definition: frame.hxx:1239
OUString GetUniqueOLEName() const
Definition: feflyole.cxx:78
Base class of the Writer document model elements.
Definition: node.hxx:80