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