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 
24 #include <fesh.hxx>
25 #include <cntfrm.hxx>
26 #include <flyfrm.hxx>
27 #include <doc.hxx>
28 #include <notxtfrm.hxx>
29 #include <ndole.hxx>
30 #include <swcli.hxx>
31 #include <docsh.hxx>
33 #include <sfx2/linkmgr.hxx>
34 
35 using namespace com::sun::star;
36 
37 SwFlyFrame *SwFEShell::FindFlyFrame( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
38 {
39  SwFlyFrame *pFly = GetSelectedFlyFrame();
40  if ( pFly && pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
41  {
42  SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
43  if ( !pNd || pNd->GetOLEObj().GetOleRef() != xObj )
44  pFly = nullptr;
45  }
46  else
47  pFly = nullptr;
48 
49  if ( !pFly )
50  {
51  // No or wrong fly selected: we have to search.
52  bool bExist = false;
53  SwStartNode *pStNd;
54  sal_uLong nSttIdx = GetNodes().GetEndOfAutotext().StartOfSectionIndex() + 1,
55  nEndIdx = GetNodes().GetEndOfAutotext().GetIndex();
56  while( nSttIdx < nEndIdx &&
57  nullptr != (pStNd = GetNodes()[ nSttIdx ]->GetStartNode()) )
58  {
59  SwNode *pNd = GetNodes()[ nSttIdx+1 ];
60  if ( pNd->IsOLENode() &&
61  static_cast<SwOLENode*>(pNd)->GetOLEObj().GetOleRef() == xObj )
62  {
63  bExist = true;
64  SwFrame *pFrame = static_cast<SwOLENode*>(pNd)->getLayoutFrame( GetLayout() );
65  if ( pFrame )
66  pFly = pFrame->FindFlyFrame();
67  break;
68  }
69  nSttIdx = pStNd->EndOfSectionIndex() + 1;
70  }
71 
72  OSL_ENSURE( bExist, "OLE-Object unknown and FlyFrame not found." );
73  }
74  return pFly;
75 }
76 
78 {
79  return GetDoc()->GetUniqueOLEName();
80 }
81 
83 {
84  return GetDoc()->GetUniqueFrameName();
85 }
86 
88 {
89  return GetDoc()->GetUniqueShapeName();
90 }
91 
92 bool SwFEShell::FinishOLEObj() // Server is terminated
93 {
94  SfxInPlaceClient* pIPClient = GetSfxViewShell()->GetIPClient();
95  if ( !pIPClient )
96  return false;
97 
98  bool bRet = pIPClient->IsObjectInPlaceActive();
99  if( bRet )
100  {
101  if( CNT_OLE == GetCntType() )
102  ClearAutomaticContour();
103 
104  if( static_cast<SwOleClient*>(pIPClient)->IsCheckForOLEInCaption() !=
105  IsCheckForOLEInCaption() )
106  SetCheckForOLEInCaption( !IsCheckForOLEInCaption() );
107 
108  // enable update of the link preview
109  comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = GetDoc()->GetDocShell()->getEmbeddedObjectContainer();
110  const bool aUserAllowsLinkUpdate = rEmbeddedObjectContainer.getUserAllowsLinkUpdate();
111  rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
112 
113  // leave UIActive state
114  pIPClient->DeactivateObject();
115 
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);
120 
121  // return back original value of the "update of the link preview" flag
122  rEmbeddedObjectContainer.setUserAllowsLinkUpdate(aUserAllowsLinkUpdate);
123  }
124  return bRet;
125 }
126 
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Starts a section of nodes in the document model.
Definition: node.hxx:303
Base class of the Writer layout elements.
Definition: frame.hxx:297
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:816
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
sal_uLong StartOfSectionIndex() const
Definition: node.hxx:673
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:913
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1089
bool IsOLENode() const
Definition: node.hxx:652
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:92
const SwFrame * Lower() const
Definition: layfrm.hxx:101
#define CNT_OLE
Definition: editsh.hxx:131
OUString GetUniqueFrameName() const
Definition: feflyole.cxx:82
void DeactivateObject()
SAL_DLLPRIVATE SwFlyFrame * FindFlyFrame(const css::uno::Reference< css::embed::XEmbeddedObject > &) const
Definition: feflyole.cxx:37
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
void UpdateAllLinks(bool bAskUpdate, bool bUpdateGrfLinks, weld::Window *pParentWin)
bool IsNoTextFrame() const
Definition: frame.hxx:1216
OUString GetUniqueShapeName() const
Definition: feflyole.cxx:87
OUString GetUniqueOLEName() const
Definition: feflyole.cxx:77
Base class of the Writer document model elements.
Definition: node.hxx:79