1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: feflyole.cxx,v $
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>
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>
53 #include <notxtfrm.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
)
73 //Kein Fly oder der falsche selektiert. Ergo muessen wir leider suchen.
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
)
86 SwFrm
*pFrm
= ((SwOLENode
*)pNd
)->GetFrm();
88 pFly
= pFrm
->FindFlyFrm();
91 nSttIdx
= pStNd
->EndOfSectionIndex() + 1;
94 ASSERT( bExist
, "OLE-Object unknown and FlyFrm not found." );
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
);
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();
134 BOOL bRet
= pIPClient
->IsObjectInPlaceActive();
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();