xref: /aoo42x/main/sw/source/core/frmedt/feflyole.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef _SFX_CLIENTSH_HXX
29cdf0e10cSrcweir #include <sfx2/ipclient.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
32cdf0e10cSrcweir #include <sfx2/app.hxx>
33cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
34cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <sot/exchange.hxx>
37cdf0e10cSrcweir #include <fmtcntnt.hxx>
38cdf0e10cSrcweir #include <fmtanchr.hxx>
39cdf0e10cSrcweir #include <fesh.hxx>
40cdf0e10cSrcweir #include <cntfrm.hxx>
41cdf0e10cSrcweir #include <frmfmt.hxx>
42cdf0e10cSrcweir #include <flyfrm.hxx>
43cdf0e10cSrcweir #include <pam.hxx>
44cdf0e10cSrcweir #include <doc.hxx>
45cdf0e10cSrcweir #include <ndtxt.hxx>
46cdf0e10cSrcweir #include <notxtfrm.hxx>
47cdf0e10cSrcweir #include <ndole.hxx>
48cdf0e10cSrcweir #include <swcli.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir using namespace com::sun::star;
51cdf0e10cSrcweir 
FindFlyFrm(const uno::Reference<embed::XEmbeddedObject> & xObj) const52cdf0e10cSrcweir SwFlyFrm *SwFEShell::FindFlyFrm( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	SwFlyFrm *pFly = FindFlyFrm();
55cdf0e10cSrcweir 	if ( pFly && pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
56cdf0e10cSrcweir 	{
57cdf0e10cSrcweir 		SwOLENode *pNd = ((SwNoTxtFrm*)pFly->Lower())->GetNode()->GetOLENode();
58cdf0e10cSrcweir         if ( !pNd || pNd->GetOLEObj().GetOleRef() != xObj )
59cdf0e10cSrcweir 			pFly = 0;
60cdf0e10cSrcweir 	}
61cdf0e10cSrcweir 	else
62cdf0e10cSrcweir 		pFly = 0;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	if ( !pFly )
65cdf0e10cSrcweir 	{
66cdf0e10cSrcweir 		//Kein Fly oder der falsche selektiert. Ergo muessen wir leider suchen.
67cdf0e10cSrcweir 		sal_Bool bExist = sal_False;
68cdf0e10cSrcweir 		SwStartNode *pStNd;
69cdf0e10cSrcweir 		sal_uLong nSttIdx = GetNodes().GetEndOfAutotext().StartOfSectionIndex() + 1,
70cdf0e10cSrcweir 			  nEndIdx = GetNodes().GetEndOfAutotext().GetIndex();
71cdf0e10cSrcweir 		while( nSttIdx < nEndIdx &&
72cdf0e10cSrcweir 				0 != (pStNd = GetNodes()[ nSttIdx ]->GetStartNode()) )
73cdf0e10cSrcweir 		{
74cdf0e10cSrcweir 			SwNode *pNd = GetNodes()[ nSttIdx+1 ];
75cdf0e10cSrcweir 			if ( pNd->IsOLENode() &&
76cdf0e10cSrcweir                  ((SwOLENode*)pNd)->GetOLEObj().GetOleRef() == xObj )
77cdf0e10cSrcweir 			{
78cdf0e10cSrcweir 				bExist = sal_True;
79cdf0e10cSrcweir 				SwFrm *pFrm = ((SwOLENode*)pNd)->getLayoutFrm( GetLayout() );
80cdf0e10cSrcweir 				if ( pFrm )
81cdf0e10cSrcweir 					pFly = pFrm->FindFlyFrm();
82cdf0e10cSrcweir 				break;
83cdf0e10cSrcweir 			}
84cdf0e10cSrcweir 			nSttIdx = pStNd->EndOfSectionIndex() + 1;
85cdf0e10cSrcweir 		}
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 		ASSERT( bExist, "OLE-Object unknown and FlyFrm not found." );
88cdf0e10cSrcweir 	}
89cdf0e10cSrcweir 	return pFly;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
GetUniqueOLEName() const93cdf0e10cSrcweir String SwFEShell::GetUniqueOLEName() const
94cdf0e10cSrcweir {
95cdf0e10cSrcweir 	return GetDoc()->GetUniqueOLEName();
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 
GetUniqueFrameName() const99cdf0e10cSrcweir String SwFEShell::GetUniqueFrameName() const
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	return GetDoc()->GetUniqueFrameName();
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
MakeObjVisible(const uno::Reference<embed::XEmbeddedObject> & xObj) const105cdf0e10cSrcweir void SwFEShell::MakeObjVisible( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     SwFlyFrm *pFly = FindFlyFrm( xObj );
108cdf0e10cSrcweir 	if ( pFly )
109cdf0e10cSrcweir 	{
110cdf0e10cSrcweir 		SwRect aTmp( pFly->Prt() );
111cdf0e10cSrcweir 		aTmp += pFly->Frm().Pos();
112cdf0e10cSrcweir 		if ( !aTmp.IsOver( VisArea() ) )
113cdf0e10cSrcweir 		{
114cdf0e10cSrcweir 			((SwFEShell*)this)->StartAction();
115cdf0e10cSrcweir 			((SwFEShell*)this)->MakeVisible( aTmp );
116cdf0e10cSrcweir 			((SwFEShell*)this)->EndAction();
117cdf0e10cSrcweir 		}
118cdf0e10cSrcweir 	}
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
FinishOLEObj()121cdf0e10cSrcweir sal_Bool SwFEShell::FinishOLEObj()						// Server wird beendet
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	SfxInPlaceClient* pIPClient = GetSfxViewShell()->GetIPClient();
124cdf0e10cSrcweir     if ( !pIPClient )
125cdf0e10cSrcweir         return sal_False;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     sal_Bool bRet = pIPClient->IsObjectInPlaceActive();
128cdf0e10cSrcweir 	if( bRet )
129cdf0e10cSrcweir 	{
130cdf0e10cSrcweir         uno::Reference < embed::XEmbeddedObject > xObj = pIPClient->GetObject();
131cdf0e10cSrcweir 		if( CNT_OLE == GetCntType() )
132cdf0e10cSrcweir 	        ClearAutomaticContour();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 		if( ((SwOleClient*)pIPClient)->IsCheckForOLEInCaption() !=
135cdf0e10cSrcweir 			IsCheckForOLEInCaption() )
136cdf0e10cSrcweir 			SetCheckForOLEInCaption( !IsCheckForOLEInCaption() );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         // leave UIActive state
139cdf0e10cSrcweir         pIPClient->DeactivateObject();
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir 	return bRet;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147