xref: /aoo41x/main/sw/source/core/docnode/swbaslnk.cxx (revision 172c67b2)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <hintids.hxx>
28cdf0e10cSrcweir #include <vcl/svapp.hxx>
29cdf0e10cSrcweir #include <vcl/outdev.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <osl/thread.hxx>
32cdf0e10cSrcweir #include <salhelper/condition.hxx>
33cdf0e10cSrcweir #include <comphelper/mediadescriptor.hxx>
34cdf0e10cSrcweir #include <sfx2/docfile.hxx>
35cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
36cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
37cdf0e10cSrcweir #include <sfx2/objsh.hxx>
38cdf0e10cSrcweir #include <editeng/boxitem.hxx>
39cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC
40cdf0e10cSrcweir #include <svx/svxids.hrc>		// fuer die EventIds
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
43cdf0e10cSrcweir #include <svtools/soerr.hxx>
44cdf0e10cSrcweir #include <fmtfsize.hxx>
45cdf0e10cSrcweir #include <fmtanchr.hxx>
46cdf0e10cSrcweir #include <frmatr.hxx>
47cdf0e10cSrcweir #include <frmfmt.hxx>
48cdf0e10cSrcweir #include <doc.hxx>
49cdf0e10cSrcweir #include <pam.hxx>
50cdf0e10cSrcweir #include <editsh.hxx>
51cdf0e10cSrcweir #include <swtable.hxx>
52cdf0e10cSrcweir #include <docary.hxx>
53cdf0e10cSrcweir #include <swevent.hxx>
54cdf0e10cSrcweir #include <swbaslnk.hxx>
55cdf0e10cSrcweir #include <swserv.hxx>
56cdf0e10cSrcweir #include <ndgrf.hxx>
57cdf0e10cSrcweir #include <ndole.hxx>
58cdf0e10cSrcweir #include <hints.hxx>
59cdf0e10cSrcweir #include <tabfrm.hxx>
60cdf0e10cSrcweir #include <cntfrm.hxx>
61cdf0e10cSrcweir #include <htmltbl.hxx>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir using namespace com::sun::star;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir sal_Bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir TYPEINIT1( SwBaseLink, ::sfx2::SvBaseLink );
68cdf0e10cSrcweir 
SV_IMPL_REF(SwServerObject)69cdf0e10cSrcweir SV_IMPL_REF( SwServerObject )
70cdf0e10cSrcweir 
71cdf0e10cSrcweir void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	//JP 4.7.2001: call fist all not SwNoTxtFrames, then the SwNoTxtFrames.
74cdf0e10cSrcweir 	//				The reason is, that in the SwNoTxtFrames the Graphic
75cdf0e10cSrcweir 	//				after a Paint will be swapped out! So all other "behind"
76cdf0e10cSrcweir 	//				them havent't a loaded Graphic. - #86501#
77cdf0e10cSrcweir 	rGrfNd.LockModify();
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	SwClientIter aIter( rGrfNd );   // TODO
80cdf0e10cSrcweir 	for( int n = 0; n < 2; ++n )
81cdf0e10cSrcweir 	{
82cdf0e10cSrcweir 		SwClient * pLast = aIter.GoStart();
83cdf0e10cSrcweir 		if( pLast ) 	// konnte zum Anfang gesprungen werden ??
84cdf0e10cSrcweir 		{
85cdf0e10cSrcweir 			do {
86cdf0e10cSrcweir 				if( (0 == n) ^ ( 0 != pLast->ISA( SwCntntFrm )) )
87cdf0e10cSrcweir 					pLast->ModifyNotification( &rItem, &rItem );
882f121198SMathias Bauer 			} while( 0 != ( pLast = ++aIter ));
89cdf0e10cSrcweir 		}
90cdf0e10cSrcweir 	}
91cdf0e10cSrcweir 	rGrfNd.UnlockModify();
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
DataChanged(const String & rMimeType,const uno::Any & rValue)95cdf0e10cSrcweir void SwBaseLink::DataChanged( const String& rMimeType,
96cdf0e10cSrcweir                             const uno::Any & rValue )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	if( !pCntntNode )
99cdf0e10cSrcweir 	{
100cdf0e10cSrcweir 		ASSERT(!this, "DataChanged ohne ContentNode" );
101cdf0e10cSrcweir 		return ;
102cdf0e10cSrcweir 	}
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	SwDoc* pDoc = pCntntNode->GetDoc();
105cdf0e10cSrcweir 	if( pDoc->IsInDtor() || ChkNoDataFlag() || bIgnoreDataChanged )
106cdf0e10cSrcweir 	{
107cdf0e10cSrcweir 		bIgnoreDataChanged = sal_False;
108cdf0e10cSrcweir 		return ;
109cdf0e10cSrcweir 	}
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	sal_uLong nFmt = SotExchange::GetFormatIdFromMimeType( rMimeType );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	if( pCntntNode->IsNoTxtNode() &&
114cdf0e10cSrcweir 		nFmt == sfx2::LinkManager::RegisterStatusInfoId() )
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir 		// nur eine Statusaenderung - Events bedienen ?
117cdf0e10cSrcweir 		::rtl::OUString sState;
118cdf0e10cSrcweir 		if( rValue.hasValue() && ( rValue >>= sState ))
119cdf0e10cSrcweir 		{
120cdf0e10cSrcweir 			sal_uInt16 nEvent = 0;
121cdf0e10cSrcweir 			switch( sState.toInt32() )
122cdf0e10cSrcweir 			{
123cdf0e10cSrcweir 			case sfx2::LinkManager::STATE_LOAD_OK:		nEvent = SVX_EVENT_IMAGE_LOAD;	break;
124cdf0e10cSrcweir 			case sfx2::LinkManager::STATE_LOAD_ERROR: 	nEvent = SVX_EVENT_IMAGE_ERROR;	break;
125cdf0e10cSrcweir 			case sfx2::LinkManager::STATE_LOAD_ABORT: 	nEvent = SVX_EVENT_IMAGE_ABORT;	break;
126cdf0e10cSrcweir 			}
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 			SwFrmFmt* pFmt;
129cdf0e10cSrcweir 			if( nEvent && 0 != ( pFmt = pCntntNode->GetFlyFmt() ))
130cdf0e10cSrcweir 			{
131cdf0e10cSrcweir 				SwCallMouseEvent aCallEvent;
132cdf0e10cSrcweir 				aCallEvent.Set( EVENT_OBJECT_IMAGE, pFmt );
133cdf0e10cSrcweir 				pDoc->CallEvent( nEvent, aCallEvent );
134cdf0e10cSrcweir 			}
135cdf0e10cSrcweir 		}
136cdf0e10cSrcweir 		return;			// das wars!
137cdf0e10cSrcweir 	}
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	sal_Bool bUpdate = sal_False;
140cdf0e10cSrcweir 	sal_Bool bGraphicArrived = sal_False;
141cdf0e10cSrcweir 	sal_Bool bGraphicPieceArrived = sal_False;
142cdf0e10cSrcweir 	sal_Bool bDontNotify = sal_False;
143cdf0e10cSrcweir 	Size aGrfSz, aFrmFmtSz;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	if( pCntntNode->IsGrfNode() )
146cdf0e10cSrcweir 	{
147*172c67b2SArmin Le Grand         SwGrfNode* pSwGrfNode = dynamic_cast< SwGrfNode* >(pCntntNode);
148*172c67b2SArmin Le Grand         OSL_ENSURE(pSwGrfNode, "Error, pSwGrfNode expected when node answers IsGrfNode() with true (!)");
149*172c67b2SArmin Le Grand 		const GraphicObject& rGrfObj = pSwGrfNode->GetGrfObj();
150cdf0e10cSrcweir 
151*172c67b2SArmin Le Grand 		bDontNotify = pSwGrfNode->IsFrameInPaint();
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 		bGraphicArrived = GetObj()->IsDataComplete();
154cdf0e10cSrcweir 		bGraphicPieceArrived = GetObj()->IsPending();
155*172c67b2SArmin Le Grand 		pSwGrfNode->SetGrafikArrived( bGraphicArrived );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		Graphic aGrf;
158cdf0e10cSrcweir 		if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGrf ) &&
159cdf0e10cSrcweir 			( GRAPHIC_DEFAULT != aGrf.GetType() ||
160cdf0e10cSrcweir 			  GRAPHIC_DEFAULT != rGrfObj.GetType() ) )
161cdf0e10cSrcweir 		{
162cdf0e10cSrcweir 			aGrfSz = ::GetGraphicSizeTwip( aGrf, 0 );
163*172c67b2SArmin Le Grand 			if( pSwGrfNode->IsChgTwipSizeFromPixel() )
164cdf0e10cSrcweir 			{
165cdf0e10cSrcweir 				const MapMode aMapTwip( MAP_TWIP );
166cdf0e10cSrcweir 				aFrmFmtSz =
167cdf0e10cSrcweir 					Application::GetDefaultDevice()->PixelToLogic(
168cdf0e10cSrcweir 						aGrf.GetSizePixel(), aMapTwip );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 			}
171cdf0e10cSrcweir 			else
172cdf0e10cSrcweir 			{
173cdf0e10cSrcweir 				aFrmFmtSz = aGrfSz;
174cdf0e10cSrcweir 			}
175*172c67b2SArmin Le Grand 			Size aSz( pSwGrfNode->GetTwipSize() );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 			if( bGraphicPieceArrived && GRAPHIC_DEFAULT != aGrf.GetType() &&
178cdf0e10cSrcweir 				( !aSz.Width() || !aSz.Height() ) )
179cdf0e10cSrcweir 			{
180cdf0e10cSrcweir 				// wenn nur ein Teil ankommt, aber die Groesse nicht
181cdf0e10cSrcweir 				// gesetzt ist, dann muss "unten" der Teil von
182cdf0e10cSrcweir 				// bGraphicArrived durchlaufen werden!
183cdf0e10cSrcweir 				// (ansonten wird die Grafik in deft. Size gepaintet)
184cdf0e10cSrcweir 				bGraphicArrived = sal_True;
185cdf0e10cSrcweir 				bGraphicPieceArrived = sal_False;
186cdf0e10cSrcweir 			}
187cdf0e10cSrcweir 
188*172c67b2SArmin Le Grand             pSwGrfNode->SetGraphic(aGrf, rGrfObj.GetLink());
189cdf0e10cSrcweir 			bUpdate = sal_True;
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 			// Bug 33999: damit der Node den Transparent-Status
192cdf0e10cSrcweir 			//		richtig gesetzt hat, ohne auf die Grafik
193cdf0e10cSrcweir 			//		zugreifen zu muessen (sonst erfolgt ein SwapIn!).
194cdf0e10cSrcweir 			if( bGraphicArrived )
195cdf0e10cSrcweir 			{
196cdf0e10cSrcweir 				// Bug #34735#: immer mit der korrekten Grafik-Size
197cdf0e10cSrcweir 				//				arbeiten
198cdf0e10cSrcweir 				if( aGrfSz.Height() && aGrfSz.Width() &&
199cdf0e10cSrcweir 					aSz.Height() && aSz.Width() &&
200cdf0e10cSrcweir 					aGrfSz != aSz )
201*172c67b2SArmin Le Grand 					pSwGrfNode->SetTwipSize( aGrfSz );
202cdf0e10cSrcweir 			}
203cdf0e10cSrcweir 		}
204cdf0e10cSrcweir 		if ( bUpdate && !bGraphicArrived && !bGraphicPieceArrived )
205*172c67b2SArmin Le Grand 			pSwGrfNode->SetTwipSize( Size(0,0) );
206cdf0e10cSrcweir 	}
207cdf0e10cSrcweir 	else if( pCntntNode->IsOLENode() )
208cdf0e10cSrcweir 		bUpdate = sal_True;
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	ViewShell *pSh = 0;
211cdf0e10cSrcweir 	SwEditShell* pESh = pDoc->GetEditShell( &pSh );
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	if ( bUpdate && bGraphicPieceArrived && !(bSwapIn || bDontNotify) )
214cdf0e10cSrcweir 	{
215cdf0e10cSrcweir 		//Hint ohne Actions verschicken, loest direktes Paint aus.
216cdf0e10cSrcweir 		if ( (!pSh || !pSh->ActionPend()) && (!pESh || !pESh->ActionPend()) )
217cdf0e10cSrcweir 		{
218cdf0e10cSrcweir 			SwMsgPoolItem aMsgHint( RES_GRAPHIC_PIECE_ARRIVED );
219cdf0e10cSrcweir 			pCntntNode->ModifyNotification( &aMsgHint, &aMsgHint );
220cdf0e10cSrcweir 			bUpdate = sal_False;
221cdf0e10cSrcweir 		}
222cdf0e10cSrcweir 	}
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	static sal_Bool bInNotifyLinks = sal_False;
225cdf0e10cSrcweir 	if( bUpdate && !bDontNotify && (!bSwapIn || bGraphicArrived) &&
226cdf0e10cSrcweir 		!bInNotifyLinks)
227cdf0e10cSrcweir 	{
228cdf0e10cSrcweir 		sal_Bool bLockView = sal_False;
229cdf0e10cSrcweir 		if( pSh )
230cdf0e10cSrcweir 		{
231cdf0e10cSrcweir 			bLockView = pSh->IsViewLocked();
232cdf0e10cSrcweir 			pSh->LockView( sal_True );
233cdf0e10cSrcweir 		}
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 		if( pESh )
236cdf0e10cSrcweir 			pESh->StartAllAction();
237cdf0e10cSrcweir 		else if( pSh )
238cdf0e10cSrcweir 			pSh->StartAction();
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 		SwMsgPoolItem aMsgHint( static_cast<sal_uInt16>(
241cdf0e10cSrcweir             bGraphicArrived ? RES_GRAPHIC_ARRIVED : RES_UPDATE_ATTR ) );
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 		if ( bGraphicArrived )
244cdf0e10cSrcweir 		{
245cdf0e10cSrcweir 			//Alle benachrichtigen, die am gleichen Link horchen.
246cdf0e10cSrcweir 			bInNotifyLinks = sal_True;
247cdf0e10cSrcweir 
248cdf0e10cSrcweir             const ::sfx2::SvBaseLinks& rLnks = pDoc->GetLinkManager().GetLinks();
249cdf0e10cSrcweir 			for( sal_uInt16 n = rLnks.Count(); n; )
250cdf0e10cSrcweir 			{
251cdf0e10cSrcweir                 ::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]);
252cdf0e10cSrcweir 				if( pLnk && OBJECT_CLIENT_GRF == pLnk->GetObjType() &&
253cdf0e10cSrcweir 					pLnk->ISA( SwBaseLink ) && pLnk->GetObj() == GetObj() )
254cdf0e10cSrcweir 				{
255cdf0e10cSrcweir 					SwBaseLink* pBLink = (SwBaseLink*)pLnk;
256cdf0e10cSrcweir 					SwGrfNode* pGrfNd = (SwGrfNode*)pBLink->pCntntNode;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 					if( pBLink != this &&
259cdf0e10cSrcweir 						( !bSwapIn ||
260cdf0e10cSrcweir 							GRAPHIC_DEFAULT == pGrfNd->GetGrfObj().GetType()))
261cdf0e10cSrcweir 					{
262cdf0e10cSrcweir 						pBLink->bIgnoreDataChanged = sal_False;
263cdf0e10cSrcweir 						pBLink->DataChanged( rMimeType, rValue );
264cdf0e10cSrcweir 						pBLink->bIgnoreDataChanged = sal_True;
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 						pGrfNd->SetGrafikArrived( ((SwGrfNode*)pCntntNode)->
267cdf0e10cSrcweir 													IsGrafikArrived() );
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 						// Fly der Grafik anpassen !
270cdf0e10cSrcweir 						if( !::SetGrfFlySize( aGrfSz, aFrmFmtSz, pGrfNd ) )
271cdf0e10cSrcweir 							::lcl_CallModify( *pGrfNd, aMsgHint );
272cdf0e10cSrcweir 					}
273cdf0e10cSrcweir 					else if( pBLink == this &&
274cdf0e10cSrcweir 							!::SetGrfFlySize( aGrfSz, aFrmFmtSz, pGrfNd ) )
275cdf0e10cSrcweir 						// Fly der Grafik anpassen !
276cdf0e10cSrcweir 						::lcl_CallModify( *pGrfNd, aMsgHint );
277cdf0e10cSrcweir 				}
278cdf0e10cSrcweir 			}
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 			bInNotifyLinks = sal_False;
281cdf0e10cSrcweir 		}
282cdf0e10cSrcweir 		else
283cdf0e10cSrcweir 		{
284cdf0e10cSrcweir 			pCntntNode->ModifyNotification( &aMsgHint, &aMsgHint );
285cdf0e10cSrcweir 		}
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 		if( pESh )
289cdf0e10cSrcweir 		{
290cdf0e10cSrcweir 			const sal_Bool bEndActionByVirDev = pESh->IsEndActionByVirDev();
291cdf0e10cSrcweir 			pESh->SetEndActionByVirDev( sal_True );
292cdf0e10cSrcweir 			pESh->EndAllAction();
293cdf0e10cSrcweir 			pESh->SetEndActionByVirDev( bEndActionByVirDev );
294cdf0e10cSrcweir 		}
295cdf0e10cSrcweir 		else if( pSh )
296cdf0e10cSrcweir 			pSh->EndAction();
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 		if( pSh && !bLockView )
299cdf0e10cSrcweir 			pSh->LockView( sal_False );
300cdf0e10cSrcweir 	}
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
SetGrfFlySize(const Size & rGrfSz,const Size & rFrmSz,SwGrfNode * pGrfNd)303cdf0e10cSrcweir sal_Bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
306cdf0e10cSrcweir 	ViewShell *pSh;
307cdf0e10cSrcweir 	CurrShell *pCurr = 0;
308cdf0e10cSrcweir 	if ( pGrfNd->GetDoc()->GetEditShell( &pSh ) )
309cdf0e10cSrcweir 		pCurr = new CurrShell( pSh );
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 	Size aSz = pGrfNd->GetTwipSize();
312cdf0e10cSrcweir 	if ( !(aSz.Width() && aSz.Height()) &&
313cdf0e10cSrcweir 			rGrfSz.Width() && rGrfSz.Height() )
314cdf0e10cSrcweir 	{
315cdf0e10cSrcweir 		SwFrmFmt* pFmt;
316cdf0e10cSrcweir 		if( pGrfNd->IsChgTwipSize() &&
317cdf0e10cSrcweir 			0 != (pFmt = pGrfNd->GetFlyFmt()) )
318cdf0e10cSrcweir 		{
319cdf0e10cSrcweir 			Size aCalcSz( aSz );
320cdf0e10cSrcweir 			if ( !aSz.Height() && aSz.Width() )
321cdf0e10cSrcweir 				//passende Hoehe ausrechnen.
322cdf0e10cSrcweir 				aCalcSz.Height() = rFrmSz.Height() *
323cdf0e10cSrcweir 						aSz.Width() / rFrmSz.Width();
324cdf0e10cSrcweir 			else if ( !aSz.Width() && aSz.Height() )
325cdf0e10cSrcweir 				//passende Breite ausrechnen
326cdf0e10cSrcweir 				aCalcSz.Width() = rFrmSz.Width() *
327cdf0e10cSrcweir 						aSz.Height() / rFrmSz.Height();
328cdf0e10cSrcweir 			else
329cdf0e10cSrcweir 				//Hoehe und Breite uebernehmen
330cdf0e10cSrcweir 				aCalcSz = rFrmSz;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 			const SvxBoxItem 	 &rBox = pFmt->GetBox();
333cdf0e10cSrcweir 			aCalcSz.Width() += rBox.CalcLineSpace(BOX_LINE_LEFT) +
334cdf0e10cSrcweir 							   rBox.CalcLineSpace(BOX_LINE_RIGHT);
335cdf0e10cSrcweir 			aCalcSz.Height()+= rBox.CalcLineSpace(BOX_LINE_TOP) +
336cdf0e10cSrcweir 							   rBox.CalcLineSpace(BOX_LINE_BOTTOM);
337cdf0e10cSrcweir 			const SwFmtFrmSize& rOldAttr = pFmt->GetFrmSize();
338cdf0e10cSrcweir 			if( rOldAttr.GetSize() != aCalcSz )
339cdf0e10cSrcweir 			{
340cdf0e10cSrcweir 				SwFmtFrmSize aAttr( rOldAttr  );
341cdf0e10cSrcweir 				aAttr.SetSize( aCalcSz );
342cdf0e10cSrcweir                 pFmt->SetFmtAttr( aAttr );
343cdf0e10cSrcweir 				bRet = sal_True;
344cdf0e10cSrcweir 			}
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 			if( !aSz.Width() )
347cdf0e10cSrcweir 			{
348cdf0e10cSrcweir 				// Wenn die Grafik in einer Tabelle verankert ist, muess
349cdf0e10cSrcweir 				// die Tabellen-Spalten neu berechnet werden
350cdf0e10cSrcweir 				const SwDoc *pDoc = pGrfNd->GetDoc();
351cdf0e10cSrcweir 				const SwPosition* pAPos = pFmt->GetAnchor().GetCntntAnchor();
352cdf0e10cSrcweir 				SwNode *pANd;
353cdf0e10cSrcweir 				SwTableNode *pTblNd;
354cdf0e10cSrcweir 				if( pAPos &&
355cdf0e10cSrcweir                     0 != (pANd = & pAPos->nNode.GetNode()) &&
356cdf0e10cSrcweir 					0 != (pTblNd = pANd->FindTableNode()) )
357cdf0e10cSrcweir 				{
358cdf0e10cSrcweir                     const sal_Bool bLastGrf = !pTblNd->GetTable().DecGrfsThatResize();
359cdf0e10cSrcweir 					SwHTMLTableLayout *pLayout =
360cdf0e10cSrcweir 						pTblNd->GetTable().GetHTMLTableLayout();
361cdf0e10cSrcweir 					if(	pLayout )
362cdf0e10cSrcweir 					{
363cdf0e10cSrcweir                         const sal_uInt16 nBrowseWidth =
364cdf0e10cSrcweir                                     pLayout->GetBrowseWidthByTable( *pDoc );
365cdf0e10cSrcweir                         if ( nBrowseWidth )
366cdf0e10cSrcweir                         {
367cdf0e10cSrcweir 							pLayout->Resize( nBrowseWidth, sal_True, sal_True,
368cdf0e10cSrcweir 											 bLastGrf ? HTMLTABLE_RESIZE_NOW
369cdf0e10cSrcweir 													  : 500 );
370cdf0e10cSrcweir                         }
371cdf0e10cSrcweir 					}
372cdf0e10cSrcweir 				}
373cdf0e10cSrcweir 			}
374cdf0e10cSrcweir 		}
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 		// SetTwipSize skaliert ggf. eine ImageMap neu und
377cdf0e10cSrcweir 		// braucht dazu das Frame-Format
378cdf0e10cSrcweir 		pGrfNd->SetTwipSize( rGrfSz );
379cdf0e10cSrcweir 	}
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	delete pCurr;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 	return bRet;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 
SwapIn(sal_Bool bWaitForData,sal_Bool bNativFormat)387cdf0e10cSrcweir sal_Bool SwBaseLink::SwapIn( sal_Bool bWaitForData, sal_Bool bNativFormat )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir 	bSwapIn = sal_True;
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 	sal_Bool bRes;
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 	if( !GetObj() && ( bNativFormat || ( !IsSynchron() && bWaitForData ) ))
394cdf0e10cSrcweir 	{
395cdf0e10cSrcweir 		AddNextRef();
396cdf0e10cSrcweir 		_GetRealObject();
397cdf0e10cSrcweir 		ReleaseRef();
398cdf0e10cSrcweir 	}
399cdf0e10cSrcweir 
400cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
401cdf0e10cSrcweir 	{
402cdf0e10cSrcweir 		String sGrfNm;
403cdf0e10cSrcweir 		if(GetLinkManager())
404cdf0e10cSrcweir 			GetLinkManager()->GetDisplayNames( this, 0, &sGrfNm, 0, 0 );
405cdf0e10cSrcweir 		int x = 0;
406cdf0e10cSrcweir         ++x;
407cdf0e10cSrcweir 	}
408cdf0e10cSrcweir #endif
409cdf0e10cSrcweir 
410cdf0e10cSrcweir     if( GetObj() )
411cdf0e10cSrcweir 	{
412cdf0e10cSrcweir         String aMimeType( SotExchange::GetFormatMimeType( GetContentType() ));
413cdf0e10cSrcweir         uno::Any aValue;
414cdf0e10cSrcweir 		GetObj()->GetData( aValue, aMimeType, !IsSynchron() && bWaitForData );
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 		if( bWaitForData && !GetObj() )
417cdf0e10cSrcweir 		{
418cdf0e10cSrcweir 			ASSERT( !this, "das SvxFileObject wurde in einem GetData geloescht!" );
419cdf0e10cSrcweir 			bRes = sal_False;
420cdf0e10cSrcweir 		}
421cdf0e10cSrcweir 		else if( 0 != ( bRes = aValue.hasValue() ) )
422cdf0e10cSrcweir 		{
423cdf0e10cSrcweir 			//JP 14.04.99: Bug 64820 - das Flag muss beim SwapIn natuerlich
424cdf0e10cSrcweir 			//				zurueckgesetzt werden. Die Daten sollen ja neu
425cdf0e10cSrcweir 			//				uebernommen werden
426cdf0e10cSrcweir 			bIgnoreDataChanged = sal_False;
427cdf0e10cSrcweir 			DataChanged( aMimeType, aValue );
428cdf0e10cSrcweir 		}
429cdf0e10cSrcweir 	}
430cdf0e10cSrcweir 	else if( !IsSynchron() && bWaitForData )
431cdf0e10cSrcweir 	{
432cdf0e10cSrcweir 		SetSynchron( sal_True );
433cdf0e10cSrcweir 		bRes = Update();
434cdf0e10cSrcweir 		SetSynchron( sal_False );
435cdf0e10cSrcweir 	}
436cdf0e10cSrcweir 	else
437cdf0e10cSrcweir 		bRes = Update();
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 	bSwapIn = sal_False;
440cdf0e10cSrcweir     return bRes;
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
Closed()443cdf0e10cSrcweir void SwBaseLink::Closed()
444cdf0e10cSrcweir {
445cdf0e10cSrcweir 	if( pCntntNode && !pCntntNode->GetDoc()->IsInDtor() )
446cdf0e10cSrcweir 	{
447cdf0e10cSrcweir 		// wir heben die Verbindung auf
448cdf0e10cSrcweir 		if( pCntntNode->IsGrfNode() )
449cdf0e10cSrcweir 			((SwGrfNode*)pCntntNode)->ReleaseLink();
450cdf0e10cSrcweir 	}
451cdf0e10cSrcweir 	SvBaseLink::Closed();
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
GetAnchor() const454cdf0e10cSrcweir const SwNode* SwBaseLink::GetAnchor() const
455cdf0e10cSrcweir {
456cdf0e10cSrcweir     if (pCntntNode)
457cdf0e10cSrcweir     {
458cdf0e10cSrcweir         SwFrmFmt *const pFmt = pCntntNode->GetFlyFmt();
459cdf0e10cSrcweir         if (pFmt)
460cdf0e10cSrcweir         {
461cdf0e10cSrcweir             const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
462cdf0e10cSrcweir             SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
463cdf0e10cSrcweir             if (pAPos &&
464cdf0e10cSrcweir                 ((FLY_AS_CHAR == rAnchor.GetAnchorId()) ||
465cdf0e10cSrcweir                  (FLY_AT_CHAR == rAnchor.GetAnchorId()) ||
466cdf0e10cSrcweir                  (FLY_AT_FLY  == rAnchor.GetAnchorId()) ||
467cdf0e10cSrcweir                  (FLY_AT_PARA == rAnchor.GetAnchorId())))
468cdf0e10cSrcweir             {
469cdf0e10cSrcweir                     return &pAPos->nNode.GetNode();
470cdf0e10cSrcweir             }
471cdf0e10cSrcweir             return 0;
472cdf0e10cSrcweir         }
473cdf0e10cSrcweir     }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 	ASSERT( !this, "GetAnchor nicht ueberlagert" );
476cdf0e10cSrcweir 	return 0;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir 
IsRecursion(const SwBaseLink * pChkLnk) const479cdf0e10cSrcweir sal_Bool SwBaseLink::IsRecursion( const SwBaseLink* pChkLnk ) const
480cdf0e10cSrcweir {
481cdf0e10cSrcweir 	SwServerObjectRef aRef( (SwServerObject*)GetObj() );
482cdf0e10cSrcweir 	if( aRef.Is() )
483cdf0e10cSrcweir 	{
484cdf0e10cSrcweir 		// es ist ein ServerObject, also frage nach allen darin
485cdf0e10cSrcweir 		// befindlichen Links, ob wir darin enthalten sind. Ansonsten
486cdf0e10cSrcweir 		// handelt es sich um eine Rekursion.
487cdf0e10cSrcweir 		return aRef->IsLinkInServer( pChkLnk );
488cdf0e10cSrcweir 	}
489cdf0e10cSrcweir 	return sal_False;
490cdf0e10cSrcweir }
491cdf0e10cSrcweir 
IsInRange(sal_uLong,sal_uLong,xub_StrLen,xub_StrLen) const492cdf0e10cSrcweir sal_Bool SwBaseLink::IsInRange( sal_uLong, sal_uLong, xub_StrLen, xub_StrLen ) const
493cdf0e10cSrcweir {
494cdf0e10cSrcweir 	// Grafik oder OLE-Links nicht,
495cdf0e10cSrcweir 	// Felder oder Sections haben eigene Ableitung!
496cdf0e10cSrcweir 	return sal_False;
497cdf0e10cSrcweir }
498cdf0e10cSrcweir 
~SwBaseLink()499cdf0e10cSrcweir SwBaseLink::~SwBaseLink()
500cdf0e10cSrcweir {
501cdf0e10cSrcweir }
502