Update ooo320-m1
[ooovba.git] / sw / source / core / frmedt / feflyole.cxx
blobd4771187955612d924e0512c9f42fe34bd730086
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: feflyole.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <com/sun/star/embed/EmbedStates.hpp>
35 #ifndef _SFX_CLIENTSH_HXX
36 #include <sfx2/ipclient.hxx>
37 #endif
38 #include <sfx2/viewsh.hxx>
39 #include <sfx2/app.hxx>
40 #include <svtools/moduleoptions.hxx>
41 #include <sfx2/viewfrm.hxx>
43 #include <sot/exchange.hxx>
44 #include <fmtcntnt.hxx>
45 #include <fmtanchr.hxx>
46 #include <fesh.hxx>
47 #include <cntfrm.hxx>
48 #include <frmfmt.hxx>
49 #include <flyfrm.hxx>
50 #include <pam.hxx>
51 #include <doc.hxx>
52 #include <ndtxt.hxx>
53 #include <notxtfrm.hxx>
54 #include <ndole.hxx>
55 #include <swcli.hxx>
57 using namespace com::sun::star;
59 SwFlyFrm *SwFEShell::FindFlyFrm( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
61 SwFlyFrm *pFly = FindFlyFrm();
62 if ( pFly && pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
64 SwOLENode *pNd = ((SwNoTxtFrm*)pFly->Lower())->GetNode()->GetOLENode();
65 if ( !pNd || pNd->GetOLEObj().GetOleRef() != xObj )
66 pFly = 0;
68 else
69 pFly = 0;
71 if ( !pFly )
73 //Kein Fly oder der falsche selektiert. Ergo muessen wir leider suchen.
74 BOOL bExist = FALSE;
75 SwStartNode *pStNd;
76 ULONG nSttIdx = GetNodes().GetEndOfAutotext().StartOfSectionIndex() + 1,
77 nEndIdx = GetNodes().GetEndOfAutotext().GetIndex();
78 while( nSttIdx < nEndIdx &&
79 0 != (pStNd = GetNodes()[ nSttIdx ]->GetStartNode()) )
81 SwNode *pNd = GetNodes()[ nSttIdx+1 ];
82 if ( pNd->IsOLENode() &&
83 ((SwOLENode*)pNd)->GetOLEObj().GetOleRef() == xObj )
85 bExist = TRUE;
86 SwFrm *pFrm = ((SwOLENode*)pNd)->GetFrm();
87 if ( pFrm )
88 pFly = pFrm->FindFlyFrm();
89 break;
91 nSttIdx = pStNd->EndOfSectionIndex() + 1;
94 ASSERT( bExist, "OLE-Object unknown and FlyFrm not found." );
96 return pFly;
100 String SwFEShell::GetUniqueOLEName() const
102 return GetDoc()->GetUniqueOLEName();
106 String SwFEShell::GetUniqueFrameName() const
108 return GetDoc()->GetUniqueFrameName();
112 void SwFEShell::MakeObjVisible( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
114 SwFlyFrm *pFly = FindFlyFrm( xObj );
115 if ( pFly )
117 SwRect aTmp( pFly->Prt() );
118 aTmp += pFly->Frm().Pos();
119 if ( !aTmp.IsOver( VisArea() ) )
121 ((SwFEShell*)this)->StartAction();
122 ((SwFEShell*)this)->MakeVisible( aTmp );
123 ((SwFEShell*)this)->EndAction();
128 BOOL SwFEShell::FinishOLEObj() // Server wird beendet
130 SfxInPlaceClient* pIPClient = GetSfxViewShell()->GetIPClient();
131 if ( !pIPClient )
132 return FALSE;
134 BOOL bRet = pIPClient->IsObjectInPlaceActive();
135 if( bRet )
137 uno::Reference < embed::XEmbeddedObject > xObj = pIPClient->GetObject();
138 if( CNT_OLE == GetCntType() )
139 ClearAutomaticContour();
141 if( ((SwOleClient*)pIPClient)->IsCheckForOLEInCaption() !=
142 IsCheckForOLEInCaption() )
143 SetCheckForOLEInCaption( !IsCheckForOLEInCaption() );
145 // leave UIActive state
146 pIPClient->DeactivateObject();
148 return bRet;