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 
32 using namespace com::sun::star;
33 
34 SwFlyFrame *SwFEShell::FindFlyFrame( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
35 {
36  SwFlyFrame *pFly = GetSelectedFlyFrame();
37  if ( pFly && pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
38  {
39  SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
40  if ( !pNd || pNd->GetOLEObj().GetOleRef() != xObj )
41  pFly = nullptr;
42  }
43  else
44  pFly = nullptr;
45 
46  if ( !pFly )
47  {
48  // No or wrong fly selected: we have to search.
49  bool bExist = false;
50  SwStartNode *pStNd;
51  sal_uLong nSttIdx = GetNodes().GetEndOfAutotext().StartOfSectionIndex() + 1,
52  nEndIdx = GetNodes().GetEndOfAutotext().GetIndex();
53  while( nSttIdx < nEndIdx &&
54  nullptr != (pStNd = GetNodes()[ nSttIdx ]->GetStartNode()) )
55  {
56  SwNode *pNd = GetNodes()[ nSttIdx+1 ];
57  if ( pNd->IsOLENode() &&
58  static_cast<SwOLENode*>(pNd)->GetOLEObj().GetOleRef() == xObj )
59  {
60  bExist = true;
61  SwFrame *pFrame = static_cast<SwOLENode*>(pNd)->getLayoutFrame( GetLayout() );
62  if ( pFrame )
63  pFly = pFrame->FindFlyFrame();
64  break;
65  }
66  nSttIdx = pStNd->EndOfSectionIndex() + 1;
67  }
68 
69  OSL_ENSURE( bExist, "OLE-Object unknown and FlyFrame not found." );
70  }
71  return pFly;
72 }
73 
75 {
76  return GetDoc()->GetUniqueOLEName();
77 }
78 
80 {
81  return GetDoc()->GetUniqueFrameName();
82 }
83 
85 {
86  return GetDoc()->GetUniqueShapeName();
87 }
88 
89 bool SwFEShell::FinishOLEObj() // Server is terminated
90 {
91  SfxInPlaceClient* pIPClient = GetSfxViewShell()->GetIPClient();
92  if ( !pIPClient )
93  return false;
94 
95  bool bRet = pIPClient->IsObjectInPlaceActive();
96  if( bRet )
97  {
98  if( CNT_OLE == GetCntType() )
99  ClearAutomaticContour();
100 
101  if( static_cast<SwOleClient*>(pIPClient)->IsCheckForOLEInCaption() !=
102  IsCheckForOLEInCaption() )
103  SetCheckForOLEInCaption( !IsCheckForOLEInCaption() );
104 
105  // leave UIActive state
106  pIPClient->DeactivateObject();
107  }
108  return bRet;
109 }
110 
111 /* 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:295
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:768
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:912
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1087
bool IsOLENode() const
Definition: node.hxx:652
static SwNodePtr GetStartNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
Definition: docglbl.cxx:87
bool FinishOLEObj()
Shutdown server.
Definition: feflyole.cxx:89
const SwFrame * Lower() const
Definition: layfrm.hxx:101
#define CNT_OLE
Definition: editsh.hxx:133
OUString GetUniqueFrameName() const
Definition: feflyole.cxx:79
void DeactivateObject()
SAL_DLLPRIVATE SwFlyFrame * FindFlyFrame(const css::uno::Reference< css::embed::XEmbeddedObject > &) const
Definition: feflyole.cxx:34
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
bool IsNoTextFrame() const
Definition: frame.hxx:1214
OUString GetUniqueShapeName() const
Definition: feflyole.cxx:84
OUString GetUniqueOLEName() const
Definition: feflyole.cxx:74
Base class of the Writer document model elements.
Definition: node.hxx:79