xref: /aoo4110/main/sw/source/core/doc/notxtfrm.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24 
25 #include <hintids.hxx>
26 #include <tools/urlobj.hxx>
27 #include <vcl/print.hxx>
28 #include <vcl/virdev.hxx>
29 #include <vcl/svapp.hxx>
30 #include <svtools/imapobj.hxx>
31 #include <svtools/imap.hxx>
32 #include <svl/urihelper.hxx>
33 #include <svtools/soerr.hxx>
34 #include <sfx2/progress.hxx>
35 #include <sfx2/docfile.hxx>
36 #include <sfx2/printer.hxx>
37 #include <editeng/udlnitem.hxx>
38 #include <editeng/colritem.hxx>
39 #include <svx/xoutbmp.hxx>
40 #include <vcl/window.hxx>
41 #include <fmturl.hxx>
42 #include <fmtsrnd.hxx>
43 #include <frmfmt.hxx>
44 #include <swrect.hxx>
45 #include <fesh.hxx>
46 #include <doc.hxx>
47 #include <flyfrm.hxx>
48 #include <frmtool.hxx>
49 #include <viewopt.hxx>
50 #include <viewimp.hxx>
51 #include <pam.hxx>
52 #include <hints.hxx>
53 #include <rootfrm.hxx>
54 #include <dflyobj.hxx>
55 #include <pagefrm.hxx>
56 #include <notxtfrm.hxx>
57 #include <grfatr.hxx>
58 #include <charatr.hxx>
59 #include <fmtornt.hxx>
60 #include <ndnotxt.hxx>
61 #include <ndgrf.hxx>
62 #include <ndole.hxx>
63 #include <swregion.hxx>
64 #include <poolfmt.hxx>
65 #include <mdiexp.hxx>
66 #include <swwait.hxx>
67 #include <comcore.hrc>
68 #include <accessibilityoptions.hxx>
69 #include <com/sun/star/embed/EmbedMisc.hpp>
70 #include <com/sun/star/embed/EmbedStates.hpp>
71 #include <svtools/embedhlp.hxx>
72 #include <svx/charthelper.hxx>
73 #include <dview.hxx>
74 #include <basegfx/matrix/b2dhommatrix.hxx>
75 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
76 #include <basegfx/matrix/b2dhommatrixtools.hxx>
77 #include <drawinglayer/processor2d/processor2dtools.hxx>
78 #include <basegfx/matrix/b2dhommatrixtools.hxx>
79 #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
80 #include <vcl/pdfextoutdevdata.hxx>
81 #include <svtools/filter.hxx>
82 
83 using namespace com::sun::star;
84 
85 #define DEFTEXTSIZE  12
86 
87 extern void ClrContourCache( const SdrObject *pObj ); // TxtFly.Cxx
88 
89 
GetRealURL(const SwGrfNode & rNd,String & rTxt)90 inline sal_Bool GetRealURL( const SwGrfNode& rNd, String& rTxt )
91 {
92 	sal_Bool bRet = rNd.GetFileFilterNms( &rTxt, 0 );
93 	if( bRet )
94 		rTxt = URIHelper::removePassword( rTxt, INetURLObject::WAS_ENCODED,
95 			   							INetURLObject::DECODE_UNAMBIGUOUS);
96 	return bRet;
97 }
98 
lcl_PaintReplacement(const SwRect & rRect,const String & rText,const ViewShell & rSh,const SwNoTxtFrm * pFrm,sal_Bool bDefect)99 void lcl_PaintReplacement( const SwRect &rRect, const String &rText,
100 						   const ViewShell &rSh, const SwNoTxtFrm *pFrm,
101 						   sal_Bool bDefect )
102 {
103 	static Font *pFont = 0;
104 	if ( !pFont )
105 	{
106 		pFont = new Font();
107 		pFont->SetWeight( WEIGHT_BOLD );
108 		pFont->SetStyleName( aEmptyStr );
109 		pFont->SetName( String::CreateFromAscii(
110                             RTL_CONSTASCII_STRINGPARAM( "Arial Unicode" )));
111 		pFont->SetFamily( FAMILY_SWISS );
112 		pFont->SetTransparent( sal_True );
113 	}
114 
115 	Color aCol( COL_RED );
116 	FontUnderline eUnderline = UNDERLINE_NONE;
117 	const SwFmtURL &rURL = pFrm->FindFlyFrm()->GetFmt()->GetURL();
118 	if( rURL.GetURL().Len() || rURL.GetMap() )
119 	{
120 		sal_Bool bVisited = sal_False;
121 		if ( rURL.GetMap() )
122 		{
123 			ImageMap *pMap = (ImageMap*)rURL.GetMap();
124 			for( sal_uInt16 i = 0; i < pMap->GetIMapObjectCount(); i++ )
125 			{
126 				IMapObject *pObj = pMap->GetIMapObject( i );
127 				if( rSh.GetDoc()->IsVisitedURL( pObj->GetURL() ) )
128 				{
129 					bVisited = sal_True;
130 					break;
131 				}
132 			}
133 		}
134 		else if ( rURL.GetURL().Len() )
135 			bVisited = rSh.GetDoc()->IsVisitedURL( rURL.GetURL() );
136 
137 		SwFmt *pFmt = rSh.GetDoc()->GetFmtFromPool( static_cast<sal_uInt16>
138             (bVisited ? RES_POOLCHR_INET_VISIT : RES_POOLCHR_INET_NORMAL ) );
139 		aCol = pFmt->GetColor().GetValue();
140 		eUnderline = pFmt->GetUnderline().GetLineStyle();
141 	}
142 
143 	pFont->SetUnderline( eUnderline );
144 	pFont->SetColor( aCol );
145 
146     const BitmapEx& rBmp = ViewShell::GetReplacementBitmap( bDefect != sal_False );
147     Graphic::DrawEx( rSh.GetOut(), rText, *pFont, rBmp, rRect.Pos(), rRect.SSize() );
148 }
149 
150 /*************************************************************************
151 |*
152 |*	  SwGrfFrm::SwGrfFrm(ViewShell * const,SwGrfNode *)
153 |*
154 |*	  Beschreibung
155 |*	  Ersterstellung	JP 05.03.91
156 |*	  Letzte Aenderung	MA 03. Mar. 93
157 |*
158 *************************************************************************/
159 
160 
SwNoTxtFrm(SwNoTxtNode * const pNode,SwFrm * pSib)161 SwNoTxtFrm::SwNoTxtFrm(SwNoTxtNode * const pNode, SwFrm* pSib )
162 	: SwCntntFrm( pNode, pSib )
163 {
164 	InitCtor();
165 }
166 
167 // Initialisierung: z.Zt. Eintragen des Frames im Cache
168 
169 
InitCtor()170 void SwNoTxtFrm::InitCtor()
171 {
172     nType = FRMC_NOTXT;
173 	// Das Gewicht der Grafik ist 0, wenn sie noch nicht
174 	// gelesen ist, < 0, wenn ein Lesefehler auftrat und
175 	// Ersatzdarstellung angewendet werden musste und >0,
176 	// wenn sie zur Verfuegung steht.
177 	nWeight = 0;
178 }
179 
180 /*************************************************************************
181 |*
182 |*	  SwNoTxtNode::MakeFrm()
183 |*
184 |*	  Beschreibung
185 |*	  Ersterstellung	JP 05.03.91
186 |*	  Letzte Aenderung	MA 03. Mar. 93
187 |*
188 *************************************************************************/
189 
190 
MakeFrm(SwFrm * pSib)191 SwCntntFrm *SwNoTxtNode::MakeFrm( SwFrm* pSib )
192 {
193 	return new SwNoTxtFrm(this, pSib);
194 }
195 
196 /*************************************************************************
197 |*
198 |*	  SwNoTxtFrm::~SwNoTxtFrm()
199 |*
200 |*	  Beschreibung
201 |*	  Ersterstellung	JP 05.03.91
202 |*	  Letzte Aenderung	MA 30. Apr. 96
203 |*
204 *************************************************************************/
205 
~SwNoTxtFrm()206 SwNoTxtFrm::~SwNoTxtFrm()
207 {
208 	StopAnimation();
209 }
210 
211 /*************************************************************************
212 |*
213 |*	  void SwNoTxtFrm::Modify( SwHint * pOld, SwHint * pNew )
214 |*
215 |*	  Beschreibung
216 |*	  Ersterstellung	JP 05.03.91
217 |*	  Letzte Aenderung	JP 05.03.91
218 |*
219 *************************************************************************/
220 
SetOutDev(ViewShell * pSh,OutputDevice * pOut)221 void SetOutDev( ViewShell *pSh, OutputDevice *pOut )
222 {
223 	pSh->pOut = pOut;
224 }
225 
226 
227 
228 
lcl_ClearArea(const SwFrm & rFrm,OutputDevice & rOut,const SwRect & rPtArea,const SwRect & rGrfArea)229 void lcl_ClearArea( const SwFrm &rFrm,
230 					OutputDevice &rOut, const SwRect& rPtArea,
231 					const SwRect &rGrfArea )
232 {
233 	SwRegionRects aRegion( rPtArea, 4, 4 );
234 	aRegion -= rGrfArea;
235 
236 	if ( aRegion.Count() )
237 	{
238 		const SvxBrushItem *pItem; const Color *pCol; SwRect aOrigRect;
239 		if ( rFrm.GetBackgroundBrush( pItem, pCol, aOrigRect, sal_False ) )
240 			for( sal_uInt16 i = 0; i < aRegion.Count(); ++i )
241 				::DrawGraphic( pItem, &rOut, aOrigRect, aRegion[i] );
242 		else
243 		{
244             // OD 2004-04-23 #116347#
245             rOut.Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
246 			rOut.SetFillColor( rFrm.getRootFrm()->GetCurrShell()->Imp()->GetRetoucheColor());
247 			rOut.SetLineColor();
248 			for( sal_uInt16 i = 0; i < aRegion.Count(); ++i )
249 				rOut.DrawRect( aRegion[i].SVRect() );
250 			rOut.Pop();
251 		}
252 	}
253 }
254 
255 /*************************************************************************
256 |*
257 |*	  void SwNoTxtFrm::Paint()
258 |*
259 |*	  Beschreibung
260 |*	  Ersterstellung	JP 05.03.91
261 |*	  Letzte Aenderung	MA 10. Jan. 97
262 |*
263 *************************************************************************/
264 
Paint(SwRect const & rRect,SwPrintData const * const) const265 void SwNoTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
266 {
267 	if ( Frm().IsEmpty() )
268 		return;
269 
270 	const ViewShell* pSh = getRootFrm()->GetCurrShell();
271 	if( !pSh->GetViewOptions()->IsGraphic() )
272 	{
273 		StopAnimation();
274         // OD 10.01.2003 #i6467# - no paint of placeholder for page preview
275         if ( pSh->GetWin() && !pSh->IsPreView() )
276 		{
277 			const SwNoTxtNode* pNd = GetNode()->GetNoTxtNode();
278             String aTxt( pNd->GetTitle() );
279 			if ( !aTxt.Len() && pNd->IsGrfNode() )
280 				GetRealURL( *(SwGrfNode*)pNd, aTxt );
281 			if( !aTxt.Len() )
282 				aTxt = FindFlyFrm()->GetFmt()->GetName();
283 			lcl_PaintReplacement( Frm(), aTxt, *pSh, this, sal_False );
284 		}
285 		return;
286 	}
287 
288     if( pSh->GetAccessibilityOptions()->IsStopAnimatedGraphics() ||
289     // --> FME 2004-06-21 #i9684# Stop animation during printing/pdf export
290        !pSh->GetWin() )
291     // <--
292         StopAnimation();
293 
294 	SfxProgress::EnterLock(); //Keine Progress-Reschedules im Paint (SwapIn)
295 
296 	OutputDevice *pOut = pSh->GetOut();
297 	pOut->Push();
298 	sal_Bool bClip = sal_True;
299 	PolyPolygon aPoly;
300 
301     SwNoTxtNode& rNoTNd = *(SwNoTxtNode*)GetNode();
302 	SwGrfNode* pGrfNd = rNoTNd.GetGrfNode();
303     if( pGrfNd )
304 		pGrfNd->SetFrameInPaint( sal_True );
305 
306     // OD 16.04.2003 #i13147# - add 2nd parameter with value <sal_True> to
307     // method call <FindFlyFrm().GetContour(..)> to indicate that it is called
308     // for paint in order to avoid load of the intrinsic graphic.
309     if ( ( !pOut->GetConnectMetaFile() ||
310            !pSh->GetWin() ) &&
311          FindFlyFrm()->GetContour( aPoly, sal_True )
312        )
313 	{
314 		pOut->SetClipRegion( aPoly );
315 		bClip = sal_False;
316 	}
317 
318 	SwRect aOrigPaint( rRect );
319 	if ( HasAnimation() && pSh->GetWin() )
320 	{
321 		aOrigPaint = Frm(); aOrigPaint += Prt().Pos();
322 	}
323 
324 	SwRect aGrfArea( Frm() );
325 	SwRect aPaintArea( aGrfArea );
326 	aPaintArea._Intersection( aOrigPaint );
327 
328 	SwRect aNormal( Frm().Pos() + Prt().Pos(), Prt().SSize() );
329 	aNormal.Justify(); //Normalisiertes Rechteck fuer die Vergleiche
330 
331 	if( aPaintArea.IsOver( aNormal ) )
332 	{
333 		// berechne die 4 zu loeschenden Rechtecke
334 		if( pSh->GetWin() )
335 			::lcl_ClearArea( *this, *pSh->GetOut(), aPaintArea, aNormal );
336 
337 		// in der Schnittmenge vom PaintBereich und der Bitmap liegt
338 		// der absolut sichtbare Bereich vom Frame
339 		aPaintArea._Intersection( aNormal );
340 
341 		if ( bClip )
342 			pOut->IntersectClipRegion( aPaintArea.SVRect() );
343         /// OD 25.09.2002 #99739# - delete unused 3rd parameter
344         PaintPicture( pOut, aGrfArea );
345 	}
346 	else
347 		// wenn nicht sichtbar, loesche einfach den angegebenen Bereich
348 		lcl_ClearArea( *this, *pSh->GetOut(), aPaintArea, SwRect() );
349     if( pGrfNd )
350 		pGrfNd->SetFrameInPaint( sal_False );
351 
352 	pOut->Pop();
353 	SfxProgress::LeaveLock();
354 }
355 
356 /*************************************************************************
357 |*
358 |*    void lcl_CalcRect( Point & aPt, Size & aDim,
359 |*                   sal_uInt16 nMirror )
360 |*
361 |*    Beschreibung      Errechne die Position und die Groesse der Grafik im
362 |*                      Frame, entsprechen der aktuellen Grafik-Attribute
363 |*
364 |*    Parameter         Point&  die Position im Frame  ( auch Return-Wert )
365 |*                      Size&   die Groesse der Grafik ( auch Return-Wert )
366 |*                      MirrorGrf   akt. Spiegelungs-Attribut
367 |*    Ersterstellung    JP 04.03.91
368 |*    Letzte Aenderung  JP 31.08.94
369 |*
370 *************************************************************************/
371 
372 
lcl_CalcRect(Point & rPt,Size & rDim,sal_uInt16 nMirror)373 void lcl_CalcRect( Point& rPt, Size& rDim, sal_uInt16 nMirror )
374 {
375     if( nMirror == RES_MIRROR_GRAPH_VERT || nMirror == RES_MIRROR_GRAPH_BOTH )
376     {
377         rPt.X() += rDim.Width() -1;
378         rDim.Width() = -rDim.Width();
379     }
380 
381     if( nMirror == RES_MIRROR_GRAPH_HOR || nMirror == RES_MIRROR_GRAPH_BOTH )
382     {
383         rPt.Y() += rDim.Height() -1;
384         rDim.Height() = -rDim.Height();
385     }
386 }
387 
388 /*************************************************************************
389 |*
390 |*	  void SwNoTxtFrm::GetGrfArea()
391 |*
392 |*	  Beschreibung		Errechne die Position und die Groesse der Bitmap
393 |*						innerhalb des uebergebenem Rechtecks.
394 |*
395 |*	  Ersterstellung	JP 03.09.91
396 |*	  Letzte Aenderung	MA 11. Oct. 94
397 |*
398 *************************************************************************/
399 
GetGrfArea(SwRect & rRect,SwRect * pOrigRect,sal_Bool) const400 void SwNoTxtFrm::GetGrfArea( SwRect &rRect, SwRect* pOrigRect,
401 							 sal_Bool ) const
402 {
403     // JP 23.01.2001: currently only used for scaling, cropping and mirroring
404     // the contour of graphics!
405 	//					all other is handled by the GraphicObject
406 
407 	//In rRect wird das sichbare Rechteck der Grafik gesteckt.
408 	//In pOrigRect werden Pos+Size der Gesamtgrafik gesteck.
409 
410 	const SwAttrSet& rAttrSet = GetNode()->GetSwAttrSet();
411 	const SwCropGrf& rCrop = rAttrSet.GetCropGrf();
412     sal_uInt16 nMirror = rAttrSet.GetMirrorGrf().GetValue();
413 
414     if( rAttrSet.GetMirrorGrf().IsGrfToggle() )
415     {
416         if( !(FindPageFrm()->GetVirtPageNum() % 2) )
417         {
418             switch ( nMirror )
419             {
420                 case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_VERT; break;
421                 case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_DONT; break;
422                 case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_BOTH; break;
423                 default: nMirror = RES_MIRROR_GRAPH_HOR; break;
424             }
425         }
426     }
427 
428 	//Grafik wird vom Node eingelesen falls notwendig. Kann aber schiefgehen.
429 	long nLeftCrop, nRightCrop, nTopCrop, nBottomCrop;
430 	Size aOrigSz( ((SwNoTxtNode*)GetNode())->GetTwipSize() );
431 	if ( !aOrigSz.Width() )
432 	{
433 		aOrigSz.Width() = Prt().Width();
434 		nLeftCrop  = -rCrop.GetLeft();
435 		nRightCrop = -rCrop.GetRight();
436 	}
437 	else
438 	{
439 		nLeftCrop = Max( aOrigSz.Width() -
440 							(rCrop.GetRight() + rCrop.GetLeft()), long(1) );
441 		const double nScale = double(Prt().Width())  / double(nLeftCrop);
442 		nLeftCrop  = long(nScale * -rCrop.GetLeft() );
443 		nRightCrop = long(nScale * -rCrop.GetRight() );
444 	}
445 
446     // crop values have to be mirrored too
447     if( nMirror == RES_MIRROR_GRAPH_VERT || nMirror == RES_MIRROR_GRAPH_BOTH )
448     {
449         long nTmpCrop = nLeftCrop;
450         nLeftCrop = nRightCrop;
451         nRightCrop= nTmpCrop;
452     }
453 
454 	if( !aOrigSz.Height() )
455 	{
456 		aOrigSz.Height() = Prt().Height();
457 		nTopCrop   = -rCrop.GetTop();
458 		nBottomCrop= -rCrop.GetBottom();
459 	}
460 	else
461 	{
462 		nTopCrop = Max( aOrigSz.Height() - (rCrop.GetTop() + rCrop.GetBottom()), long(1) );
463 		const double nScale = double(Prt().Height()) / double(nTopCrop);
464 		nTopCrop   = long(nScale * -rCrop.GetTop() );
465 		nBottomCrop= long(nScale * -rCrop.GetBottom() );
466 	}
467 
468     // crop values have to be mirrored too
469     if( nMirror == RES_MIRROR_GRAPH_HOR || nMirror == RES_MIRROR_GRAPH_BOTH )
470     {
471         long nTmpCrop = nTopCrop;
472         nTopCrop   = nBottomCrop;
473         nBottomCrop= nTmpCrop;
474     }
475 
476 	Size  aVisSz( Prt().SSize() );
477 	Size  aGrfSz( aVisSz );
478 	Point aVisPt( Frm().Pos() + Prt().Pos() );
479 	Point aGrfPt( aVisPt );
480 
481 	//Erst das 'sichtbare' Rect einstellen.
482 	if ( nLeftCrop > 0 )
483 	{
484 		aVisPt.X() 	+= nLeftCrop;
485 		aVisSz.Width() -= nLeftCrop;
486 	}
487 	if ( nTopCrop > 0 )
488 	{
489 		aVisPt.Y() 	 += nTopCrop;
490 		aVisSz.Height() -= nTopCrop;
491 	}
492 	if ( nRightCrop > 0 )
493 		aVisSz.Width() -= nRightCrop;
494 	if ( nBottomCrop > 0 )
495 		aVisSz.Height() -= nBottomCrop;
496 
497 	rRect.Pos  ( aVisPt );
498 	rRect.SSize( aVisSz );
499 
500 	//Ggf. Die Gesamtgrafik berechnen
501 	if ( pOrigRect )
502 	{
503 		Size aTmpSz( aGrfSz );
504 		aGrfPt.X()    += nLeftCrop;
505 		aTmpSz.Width() -= nLeftCrop + nRightCrop;
506 		aGrfPt.Y()	    += nTopCrop;
507 		aTmpSz.Height()-= nTopCrop + nBottomCrop;
508 
509         if( RES_MIRROR_GRAPH_DONT != nMirror )
510             lcl_CalcRect( aGrfPt, aTmpSz, nMirror );
511 
512 		pOrigRect->Pos  ( aGrfPt );
513 		pOrigRect->SSize( aTmpSz );
514 	}
515 }
516 
517 /*************************************************************************
518 |*
519 |*	  Size SwNoTxtFrm::GetSize()
520 |*
521 |*	  Beschreibung		Gebe die Groesse des umgebenen FLys und
522 |*						damit die der Grafik zurueck.
523 |*	  Ersterstellung	JP 04.03.91
524 |*	  Letzte Aenderung	JP 31.08.94
525 |*
526 *************************************************************************/
527 
528 
GetSize() const529 const Size& SwNoTxtFrm::GetSize() const
530 {
531 	// gebe die Groesse des Frames zurueck
532 	const SwFrm *pFly = FindFlyFrm();
533 	if( !pFly )
534 		pFly = this;
535 	return pFly->Prt().SSize();
536 }
537 
538 /*************************************************************************
539 |*
540 |*	  SwNoTxtFrm::MakeAll()
541 |*
542 |*	  Ersterstellung	MA 29. Nov. 96
543 |*	  Letzte Aenderung	MA 29. Nov. 96
544 |*
545 *************************************************************************/
546 
547 
MakeAll()548 void SwNoTxtFrm::MakeAll()
549 {
550 	SwCntntNotify aNotify( this );
551 	SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
552 	const SwBorderAttrs &rAttrs = *aAccess.Get();
553 
554 	while ( !bValidPos || !bValidSize || !bValidPrtArea )
555 	{
556 		MakePos();
557 
558 		if ( !bValidSize )
559 			Frm().Width( GetUpper()->Prt().Width() );
560 
561 		MakePrtArea( rAttrs );
562 
563 		if ( !bValidSize )
564 		{	bValidSize = sal_True;
565 			Format();
566 		}
567 	}
568 }
569 
570 /*************************************************************************
571 |*
572 |*	  SwNoTxtFrm::Format()
573 |*
574 |*	  Beschreibung		Errechne die Groesse der Bitmap, wenn noetig
575 |*	  Ersterstellung	JP 11.03.91
576 |*	  Letzte Aenderung	MA 13. Mar. 96
577 |*
578 *************************************************************************/
579 
580 
Format(const SwBorderAttrs *)581 void SwNoTxtFrm::Format( const SwBorderAttrs * )
582 {
583 	const Size aNewSize( GetSize() );
584 
585 	// hat sich die Hoehe geaendert?
586 	SwTwips nChgHght = IsVertical() ?
587 		(SwTwips)(aNewSize.Width() - Prt().Width()) :
588 		(SwTwips)(aNewSize.Height() - Prt().Height());
589     if( nChgHght > 0)
590         Grow( nChgHght );
591 	else if( nChgHght < 0)
592         Shrink( Min(Prt().Height(), -nChgHght) );
593 }
594 
595 /*************************************************************************
596 |*
597 |*	  SwNoTxtFrm::GetCharRect()
598 |*
599 |*	  Beschreibung
600 |*	  Ersterstellung	SS 29-Apr-1991
601 |*	  Letzte Aenderung	MA 10. Oct. 94
602 |*
603 |*************************************************************************/
604 
605 
GetCharRect(SwRect & rRect,const SwPosition & rPos,SwCrsrMoveState * pCMS) const606 sal_Bool SwNoTxtFrm::GetCharRect( SwRect &rRect, const SwPosition& rPos,
607 							  SwCrsrMoveState *pCMS ) const
608 {
609 	if ( &rPos.nNode.GetNode() != (SwNode*)GetNode() )
610 		return sal_False;
611 
612 	Calc();
613 	SwRect aFrameRect( Frm() );
614 	rRect = aFrameRect;
615 	rRect.Pos( Frm().Pos() + Prt().Pos() );
616 	rRect.SSize( Prt().SSize() );
617 
618 	rRect.Justify();
619 
620 	// liegt die Bitmap ueberhaupt im sichtbaren Berich ?
621 	if( !aFrameRect.IsOver( rRect ) )
622 	{
623 		// wenn nicht dann steht der Cursor auf dem Frame
624 		rRect = aFrameRect;
625 		rRect.Width( 1 );
626 	}
627 	else
628 		rRect._Intersection( aFrameRect );
629 
630 	if ( pCMS )
631 	{
632 		if ( pCMS->bRealHeight )
633 		{
634 			pCMS->aRealHeight.Y() = rRect.Height();
635 			pCMS->aRealHeight.X() = 0;
636 		}
637 	}
638 
639 	return sal_True;
640 }
641 
642 
GetCrsrOfst(SwPosition * pPos,Point &,SwCrsrMoveState *) const643 sal_Bool SwNoTxtFrm::GetCrsrOfst(SwPosition* pPos, Point& ,
644                              SwCrsrMoveState* ) const
645 {
646 	SwCntntNode* pCNd = (SwCntntNode*)GetNode();
647 	pPos->nNode = *pCNd;
648 	pPos->nContent.Assign( pCNd, 0 );
649 	return sal_True;
650 }
651 
652 #define CLEARCACHE( pNd ) {\
653 	(pNd)->ReleaseGraphicFromCache();\
654 	SwFlyFrm* pFly = FindFlyFrm();\
655 	if( pFly && pFly->GetFmt()->GetSurround().IsContour() )\
656 	{\
657 		ClrContourCache( pFly->GetVirtDrawObj() );\
658 		pFly->NotifyBackground( FindPageFrm(), Prt(), PREP_FLY_ATTR_CHG );\
659 	}\
660 }
661 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)662 void SwNoTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
663 {
664 	sal_uInt16 nWhich = pNew ? pNew->Which() : pOld ? pOld->Which() : 0;
665 
666     // --> OD 2007-03-06 #i73788#
667     // no <SwCntntFrm::Modify(..)> for RES_LINKED_GRAPHIC_STREAM_ARRIVED
668     if ( RES_GRAPHIC_PIECE_ARRIVED != nWhich &&
669 		 RES_GRAPHIC_ARRIVED != nWhich &&
670          RES_GRF_REREAD_AND_INCACHE != nWhich &&
671          RES_LINKED_GRAPHIC_STREAM_ARRIVED != nWhich )
672     // <--
673     {
674 		SwCntntFrm::Modify( pOld, pNew );
675     }
676 
677 	sal_Bool bComplete = sal_True;
678 
679 	switch( nWhich )
680 	{
681 	case RES_OBJECTDYING:
682 		break;
683 
684 	case RES_GRF_REREAD_AND_INCACHE:
685 		if( ND_GRFNODE == GetNode()->GetNodeType() )
686 		{
687 			bComplete = sal_False;
688 			SwGrfNode* pNd = (SwGrfNode*) GetNode();
689 
690 			ViewShell *pVSh = 0;
691 			pNd->GetDoc()->GetEditShell( &pVSh );
692 			if( pVSh )
693 			{
694 				GraphicAttr aAttr;
695 				if( pNd->GetGrfObj().IsCached( pVSh->GetOut(), Point(),
696 							Prt().SSize(), &pNd->GetGraphicAttr( aAttr, this ) ))
697 				{
698 					ViewShell *pSh = pVSh;
699 					do {
700 						SET_CURR_SHELL( pSh );
701 						if( pSh->GetWin() )
702 						{
703 							if( pSh->IsPreView() )
704 								::RepaintPagePreview( pSh, Frm().SVRect() );
705 							else
706 								pSh->GetWin()->Invalidate( Frm().SVRect() );
707 						}
708 					} while( pVSh != (pSh = (ViewShell*)pSh->GetNext() ));
709 				}
710 				else
711 					pNd->SwapIn();
712 			}
713 		}
714 		break;
715 
716 	case RES_UPDATE_ATTR:
717 	case RES_FMT_CHG:
718 		CLEARCACHE( (SwGrfNode*) GetNode() )
719 		break;
720 
721 	case RES_ATTRSET_CHG:
722 		{
723 			sal_uInt16 n;
724 			for( n = RES_GRFATR_BEGIN; n < RES_GRFATR_END; ++n )
725 				if( SFX_ITEM_SET == ((SwAttrSetChg*)pOld)->GetChgSet()->
726 								GetItemState( n, sal_False ))
727 				{
728 					CLEARCACHE( (SwGrfNode*) GetNode() )
729 					break;
730 				}
731 			if( RES_GRFATR_END == n )			// not found
732 				return ;
733 		}
734 		break;
735 
736 	case RES_GRAPHIC_PIECE_ARRIVED:
737 	case RES_GRAPHIC_ARRIVED:
738     // --> OD 2007-03-06 #i73788#
739     // handle RES_LINKED_GRAPHIC_STREAM_ARRIVED as RES_GRAPHIC_ARRIVED
740     case RES_LINKED_GRAPHIC_STREAM_ARRIVED:
741     // <--
742 		if ( GetNode()->GetNodeType() == ND_GRFNODE )
743 		{
744 			bComplete = sal_False;
745 			SwGrfNode* pNd = (SwGrfNode*) GetNode();
746 
747 			CLEARCACHE( pNd )
748 
749 			SwRect aRect( Frm() );
750 
751 			ViewShell *pVSh = 0;
752 			pNd->GetDoc()->GetEditShell( &pVSh );
753             if( !pVSh )
754 				break;
755 
756 			ViewShell *pSh = pVSh;
757 			do {
758 				SET_CURR_SHELL( pSh );
759 				if( pSh->IsPreView() )
760 				{
761 					if( pSh->GetWin() )
762 						::RepaintPagePreview( pSh, aRect );
763 				}
764                 else if ( pSh->VisArea().IsOver( aRect ) &&
765                    OUTDEV_WINDOW == pSh->GetOut()->GetOutDevType() )
766 				{
767                     // OD 27.11.2002 #105519# - invalidate instead of painting
768                     pSh->GetWin()->Invalidate( aRect.SVRect() );
769 				}
770 
771 				pSh = (ViewShell *)pSh->GetNext();
772 			} while( pSh != pVSh );
773 		}
774 		break;
775 
776 	default:
777         if ( !pNew || !isGRFATR(nWhich) )
778 			return;
779 	}
780 
781 	if( bComplete )
782 	{
783 		InvalidatePrt();
784 		SetCompletePaint();
785 	}
786 }
787 
lcl_correctlyAlignRect(SwRect & rAlignedGrfArea,const SwRect & rInArea,OutputDevice * pOut)788 void lcl_correctlyAlignRect( SwRect& rAlignedGrfArea, const SwRect& rInArea, OutputDevice* pOut )
789 {
790 
791     if(!pOut)
792         return;
793     Rectangle aPxRect = pOut->LogicToPixel( rInArea.SVRect() );
794     Rectangle aNewPxRect( aPxRect );
795     while( aNewPxRect.Left() < aPxRect.Left() )
796     {
797         rAlignedGrfArea.Left( rAlignedGrfArea.Left()+1 );
798         aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
799     }
800     while( aNewPxRect.Top() < aPxRect.Top() )
801     {
802         rAlignedGrfArea.Top( rAlignedGrfArea.Top()+1 );
803         aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
804     }
805     while( aNewPxRect.Bottom() > aPxRect.Bottom() )
806     {
807         rAlignedGrfArea.Bottom( rAlignedGrfArea.Bottom()-1 );
808         aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
809     }
810     while( aNewPxRect.Right() > aPxRect.Right() )
811     {
812         rAlignedGrfArea.Right( rAlignedGrfArea.Right()-1 );
813         aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
814     }
815 }
816 
paintUsingPrimitivesHelper(OutputDevice & rOutputDevice,const drawinglayer::primitive2d::Primitive2DSequence & rSequence,const basegfx::B2DRange & rSourceRange,const basegfx::B2DRange & rTargetRange)817 bool paintUsingPrimitivesHelper(
818     OutputDevice& rOutputDevice,
819     const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
820     const basegfx::B2DRange& rSourceRange,
821     const basegfx::B2DRange& rTargetRange)
822 {
823     if(rSequence.hasElements() && !basegfx::fTools::equalZero(rSourceRange.getWidth()) && !basegfx::fTools::equalZero(rSourceRange.getHeight()))
824     {
825         if(!basegfx::fTools::equalZero(rTargetRange.getWidth()) && !basegfx::fTools::equalZero(rTargetRange.getHeight()))
826         {
827             // map graphic range to target range. This will e.g. automatically include
828             // tme mapping from 1/100th mm content to twips if needed when the target
829             // range is defined in twips
830             const basegfx::B2DHomMatrix aMappingTransform(
831                 basegfx::tools::createSourceRangeTargetRangeTransform(
832                     rSourceRange,
833                     rTargetRange));
834 
835             // Fill ViewInformation. Use MappingTransform here, so there is no need to
836             // embed the primitives to it. Use original TargetRange here so there is also
837             // no need to embed the primitives to a MaskPrimitive for cropping. This works
838             // only in this case where the graphic object cannot be rotated, though.
839             const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
840                 aMappingTransform,
841                 rOutputDevice.GetViewTransformation(),
842                 rTargetRange,
843                 0,
844                 0.0,
845                 uno::Sequence< beans::PropertyValue >());
846 
847             // get a primitive processor for rendering
848             drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createProcessor2DFromOutputDevice(
849                 rOutputDevice,
850                 aViewInformation2D);
851 
852             if(pProcessor2D)
853             {
854                 // render and cleanup
855                 pProcessor2D->process(rSequence);
856                 delete pProcessor2D;
857                 return true;
858             }
859         }
860     }
861 
862     return false;
863 }
864 
865 // Ausgabe der Grafik. Hier wird entweder eine QuickDraw-Bmp oder
866 // eine Grafik vorausgesetzt. Ist nichts davon vorhanden, wird
867 // eine Ersatzdarstellung ausgegeben.
868 /// OD 25.09.2002 #99739# - delete unused 3rd parameter.
869 /// OD 25.09.2002 #99739# - use aligned rectangle for drawing graphic.
870 /// OD 25.09.2002 #99739# - pixel-align coordinations for drawing graphic.
PaintPicture(OutputDevice * pOut,const SwRect & rGrfArea) const871 void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) const
872 {
873 	ViewShell* pShell = getRootFrm()->GetCurrShell();
874 
875 	SwNoTxtNode& rNoTNd = *(SwNoTxtNode*)GetNode();
876 	SwGrfNode* pGrfNd = rNoTNd.GetGrfNode();
877 	SwOLENode* pOLENd = rNoTNd.GetOLENode();
878 
879     const sal_Bool bPrn = pOut == rNoTNd.getIDocumentDeviceAccess()->getPrinter( false ) ||
880                           pOut->GetConnectMetaFile();
881 
882     const bool bIsChart = pOLENd && ChartHelper::IsChart( pOLENd->GetOLEObj().GetObject() );
883 
884     /// OD 25.09.2002 #99739# - calculate aligned rectangle from parameter <rGrfArea>.
885     ///     Use aligned rectangle <aAlignedGrfArea> instead of <rGrfArea> in
886     ///     the following code.
887     SwRect aAlignedGrfArea = rGrfArea;
888     ::SwAlignRect( aAlignedGrfArea,  pShell );
889 
890     if( !bIsChart )
891     {
892         /// OD 25.09.2002 #99739#
893         /// Because for drawing a graphic left-top-corner and size coordinations are
894         /// used, these coordinations have to be determined on pixel level.
895         ::SwAlignGrfRect( &aAlignedGrfArea, *pOut );
896     }
897     else //if( bIsChart )
898     {
899         //#i78025# charts own borders are not completely visible
900         //the above pixel correction is not correct - at least not for charts
901         //so a different pixel correction is choosen here
902         //this might be a good idea for all other OLE objects also,
903         //but as I cannot oversee the consequences I fix it only for charts for now
904         lcl_correctlyAlignRect( aAlignedGrfArea, rGrfArea, pOut );
905     }
906 
907     if( pGrfNd )
908 	{
909 		sal_Bool bForceSwap = sal_False, bContinue = sal_True;
910 		const GraphicObject& rGrfObj = pGrfNd->GetGrfObj();
911 
912 		GraphicAttr aGrfAttr;
913 		pGrfNd->GetGraphicAttr( aGrfAttr, this );
914 
915 		if( !bPrn )
916 		{
917             // --> OD 2007-01-02 #i73788#
918             if ( pGrfNd->IsLinkedInputStreamReady() )
919             {
920                 pGrfNd->UpdateLinkWithInputStream();
921             }
922             // <--
923             // --> OD 2008-01-30 #i85717#
924             // --> OD 2008-07-21 #i90395# - check, if asynchronous retrieval
925             // if input stream for the graphic is possible
926 //            else if( GRAPHIC_DEFAULT == rGrfObj.GetType() &&
927             else if ( ( rGrfObj.GetType() == GRAPHIC_DEFAULT ||
928                         rGrfObj.GetType() == GRAPHIC_NONE ) &&
929                       pGrfNd->IsLinkedFile() &&
930                       pGrfNd->IsAsyncRetrieveInputStreamPossible() )
931             // <--
932 			{
933 				Size aTmpSz;
934                 ::sfx2::SvLinkSource* pGrfObj = pGrfNd->GetLink()->GetObj();
935 				if( !pGrfObj ||
936 					!pGrfObj->IsDataComplete() ||
937 					!(aTmpSz = pGrfNd->GetTwipSize()).Width() ||
938 					!aTmpSz.Height() || !pGrfNd->GetAutoFmtLvl() )
939 				{
940                     // --> OD 2006-12-22 #i73788#
941                     pGrfNd->TriggerAsyncRetrieveInputStream();
942                     // <--
943 				}
944                 String aTxt( pGrfNd->GetTitle() );
945 				if ( !aTxt.Len() )
946 					GetRealURL( *pGrfNd, aTxt );
947                 ::lcl_PaintReplacement( aAlignedGrfArea, aTxt, *pShell, this, sal_False );
948 				bContinue = sal_False;
949 			}
950 		}
951 
952 		if( bContinue )
953 		{
954 			const sal_Bool bSwapped = rGrfObj.IsSwappedOut();
955 			const sal_Bool bSwappedIn = 0 != pGrfNd->SwapIn( bPrn );
956 			if( bSwappedIn && rGrfObj.GetGraphic().IsSupportedGraphic())
957 			{
958                 const sal_Bool bAnimate = rGrfObj.IsAnimated() &&
959                                          !pShell->IsPreView() &&
960                                          !pShell->GetAccessibilityOptions()->IsStopAnimatedGraphics() &&
961                 // --> FME 2004-06-21 #i9684# Stop animation during printing/pdf export
962                                           pShell->GetWin();
963                 // <--
964 
965 				if( bAnimate &&
966 					FindFlyFrm() != ::GetFlyFromMarked( 0, pShell ))
967 				{
968 					OutputDevice* pVout;
969 					if( pOut == pShell->GetOut() && SwRootFrm::FlushVout() )
970 						pVout = pOut, pOut = pShell->GetOut();
971 					else if( pShell->GetWin() &&
972 							 OUTDEV_VIRDEV == pOut->GetOutDevType() )
973 						pVout = pOut, pOut = pShell->GetWin();
974 					else
975 						pVout = 0;
976 
977                     ASSERT( OUTDEV_VIRDEV != pOut->GetOutDevType() ||
978                             pShell->GetViewOptions()->IsPDFExport(),
979                             "pOut sollte kein virtuelles Device sein" );
980 
981                     pGrfNd->StartGraphicAnimation(pOut, aAlignedGrfArea.Pos(),
982                                         aAlignedGrfArea.SSize(), long(this),
983 										0, GRFMGR_DRAW_STANDARD, pVout );
984 				}
985                 else
986                 {
987                     // unify using GraphicPrimitive2D
988                     // -> the primitive handles all crop and mirror stuff
989                     // -> the primitive renderer will create the needed pdf export data
990                     // -> if bitmap conent, it will be cached system-dependent
991                     const basegfx::B2DRange aTargetRange(
992                         aAlignedGrfArea.Left(), aAlignedGrfArea.Top(),
993                         aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
994                     const basegfx::B2DHomMatrix aTargetTransform(
995                         basegfx::tools::createScaleTranslateB2DHomMatrix(
996                             aTargetRange.getRange(),
997                             aTargetRange.getMinimum()));
998                     drawinglayer::primitive2d::Primitive2DSequence aContent(1);
999                     bool bDone(false);
1000 
1001                     // #i125171# The mechanism to get lossless jpegs into pdf is based on having the original
1002                     // file data (not the bitmap data) at the Graphic in the GfxLink (which has *nothing* to
1003                     // do with the graphic being linked). This works well for DrawingLayer GraphicObjects (linked
1004                     // and unlinked) but fails for linked Writer GraphicObjects. These have the URL in the
1005                     // GraphicObject, but no GfxLink with the original file data when it's a linked graphic.
1006                     // Since this blows up PDF size by a factor of 10 (the graphics get embedded as pixel maps
1007                     // then) it is okay to add this workarund: In the needed case, load the graphic in a way to
1008                     // get the GfxLink in the needed form and use that Graphic temporarily. Do this only when
1009                     // - we have PDF export
1010                     // - the GraphicObject is linked
1011                     // - the Graphic has no GfxLink
1012                     // - LosslessCompression is activated
1013                     // - it's indeed a jpeg graphic (could be checked by the url ending, but is more reliable to check later)
1014                     // In all other cases (normal repaint, print, etc...) use the available Graphic with the
1015                     // already loaded pixel graphic as before this change.
1016                     if(pOut->GetExtOutDevData() && rGrfObj.HasLink() && !rGrfObj.GetGraphic().IsLink())
1017                     {
1018                         const vcl::PDFExtOutDevData* pPDFExt = dynamic_cast< const vcl::PDFExtOutDevData* >(pOut->GetExtOutDevData());
1019 
1020                         if(pPDFExt && pPDFExt->GetIsLosslessCompression())
1021                         {
1022                             Graphic aTempGraphic;
1023                             INetURLObject aURL(rGrfObj.GetLink());
1024 
1025                             if(GRFILTER_OK == GraphicFilter::GetGraphicFilter()->ImportGraphic(aTempGraphic, aURL))
1026                             {
1027                                 if(aTempGraphic.IsLink() && GFX_LINK_TYPE_NATIVE_JPG == aTempGraphic.GetLink().GetType())
1028                                 {
1029                                     aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D(
1030                                         aTargetTransform,
1031                                         aTempGraphic,
1032                                         aGrfAttr);
1033                                     bDone = true;
1034                                 }
1035                             }
1036                         }
1037                     }
1038 
1039                     if(!bDone)
1040                     {
1041                         aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D(
1042                             aTargetTransform,
1043                             rGrfObj.GetGraphic(),
1044                             aGrfAttr);
1045                     }
1046 
1047                     paintUsingPrimitivesHelper(
1048                         *pOut,
1049                         aContent,
1050                         aTargetRange,
1051                         aTargetRange);
1052 
1053                     // need to reset the timer manually (was in original paints at GraphicManager)
1054                     rGrfObj.restartSwapOutTimer();
1055                 }
1056 			}
1057 			else
1058 			{
1059 				sal_uInt16 nResId = 0;
1060 				if( bSwappedIn )
1061 				{
1062 					if( GRAPHIC_NONE == rGrfObj.GetType() )
1063 						nResId = STR_COMCORE_READERROR;
1064 					else if ( !rGrfObj.GetGraphic().IsSupportedGraphic() )
1065 						nResId = STR_COMCORE_CANT_SHOW;
1066 				}
1067 				((SwNoTxtFrm*)this)->nWeight = -1;
1068 				String aText;
1069 				if ( !nResId &&
1070                      !(aText = pGrfNd->GetTitle()).Len() &&
1071 					 (!GetRealURL( *pGrfNd, aText ) || !aText.Len()))
1072 				{
1073 					nResId = STR_COMCORE_READERROR;
1074 				}
1075 				if ( nResId )
1076 					aText = SW_RESSTR( nResId );
1077 
1078                 ::lcl_PaintReplacement( aAlignedGrfArea, aText, *pShell, this, sal_True );
1079 			}
1080 
1081 			//Beim Drucken duerfen wir nicht die Grafiken sammeln...
1082 			if( bSwapped && bPrn )
1083 				bForceSwap = sal_True;
1084 		}
1085 		if( bForceSwap )
1086 			pGrfNd->SwapOut();
1087 	}
1088     else // bIsChart || pOLENd
1089     {
1090         // --> OD 2009-03-05 #i99665#
1091         // Adjust AntiAliasing mode at output device for chart OLE
1092         const sal_uInt16 nFormerAntialiasingAtOutput( pOut->GetAntialiasing() );
1093         if ( pOLENd->IsChart() &&
1094                 pShell->Imp()->GetDrawView()->IsAntiAliasing() )
1095         {
1096             const sal_uInt16 nAntialiasingForChartOLE =
1097                     nFormerAntialiasingAtOutput | ANTIALIASING_PIXELSNAPHAIRLINE;
1098             pOut->SetAntialiasing( nAntialiasingForChartOLE );
1099         }
1100         // <--
1101 
1102         bool bDone(false);
1103 
1104         if(bIsChart)
1105         {
1106             const uno::Reference< frame::XModel > aXModel(pOLENd->GetOLEObj().GetOleRef()->getComponent(), uno::UNO_QUERY);
1107 
1108             if(aXModel.is())
1109             {
1110                 basegfx::B2DRange aSourceRange;
1111 
1112                 const drawinglayer::primitive2d::Primitive2DSequence aSequence(
1113                     ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
1114                         aXModel,
1115                         aSourceRange));
1116 
1117                 if(aSequence.hasElements() && !aSourceRange.isEmpty())
1118                 {
1119                     const basegfx::B2DRange aTargetRange(
1120                         aAlignedGrfArea.Left(), aAlignedGrfArea.Top(),
1121                         aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
1122 
1123                     bDone = paintUsingPrimitivesHelper(
1124                         *pOut,
1125                         aSequence,
1126                         aSourceRange,
1127                         aTargetRange);
1128                 }
1129             }
1130         }
1131 
1132         if(!bDone && pOLENd)
1133 	    {
1134             Point aPosition(aAlignedGrfArea.Pos());
1135             Size aSize(aAlignedGrfArea.SSize());
1136 
1137             // Im BrowseModus gibt es nicht unbedingt einen Drucker und
1138             // damit kein JobSetup, also legen wir eines an ...
1139             const JobSetup* pJobSetup = pOLENd->getIDocumentDeviceAccess()->getJobsetup();
1140             sal_Bool bDummyJobSetup = 0 == pJobSetup;
1141             if( bDummyJobSetup )
1142                 pJobSetup = new JobSetup();
1143 
1144 		    // #i42323#
1145 		    // The reason for #114233# is gone, so i remove it again
1146             //TODO/LATER: is it a problem that the JopSetup isn't used?
1147             //xRef->DoDraw( pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), *pJobSetup );
1148 
1149             // get hi-contrast image, but never for printing
1150 		    Graphic* pGraphic = NULL;
1151             if (pOut && !bPrn && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1152 			    pGraphic = pOLENd->GetHCGraphic();
1153 
1154 		    // when it is not possible to get HC-representation, the original image should be used
1155 		    if ( !pGraphic )
1156            	    pGraphic = pOLENd->GetGraphic();
1157 
1158             if ( pGraphic && pGraphic->GetType() != GRAPHIC_NONE )
1159 		    {
1160 			    pGraphic->Draw( pOut, aPosition, aSize );
1161 
1162 			    // shade the representation if the object is activated outplace
1163 			    uno::Reference < embed::XEmbeddedObject > xObj = pOLENd->GetOLEObj().GetOleRef();
1164 			    if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::ACTIVE )
1165 			    {
1166 				    ::svt::EmbeddedObjectRef::DrawShading( Rectangle( aPosition, aSize ), pOut );
1167 			    }
1168 		    }
1169             else
1170                 ::svt::EmbeddedObjectRef::DrawPaintReplacement( Rectangle( aPosition, aSize ), pOLENd->GetOLEObj().GetCurrentPersistName(), pOut );
1171 
1172             if( bDummyJobSetup )
1173                 delete pJobSetup;  // ... und raeumen wieder auf.
1174 
1175             sal_Int64 nMiscStatus = pOLENd->GetOLEObj().GetOleRef()->getStatus( pOLENd->GetAspect() );
1176             if ( !bPrn && pShell->ISA( SwCrsrShell ) &&
1177                     nMiscStatus & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE )
1178             {
1179                 const SwFlyFrm *pFly = FindFlyFrm();
1180                 ASSERT( pFly, "OLE not in FlyFrm" );
1181                 ((SwFEShell*)pShell)->ConnectObj( pOLENd->GetOLEObj().GetObject(), pFly->Prt(), pFly->Frm());
1182             }
1183         }
1184 
1185         // --> OD 2009-03-05 #i99665#
1186         if ( pOLENd->IsChart() &&
1187                 pShell->Imp()->GetDrawView()->IsAntiAliasing() )
1188         {
1189             pOut->SetAntialiasing( nFormerAntialiasingAtOutput );
1190         }
1191         // <--
1192     }
1193 }
1194 
1195 
IsTransparent() const1196 sal_Bool SwNoTxtFrm::IsTransparent() const
1197 {
1198 	const ViewShell* pSh = getRootFrm()->GetCurrShell();
1199 	if ( !pSh || !pSh->GetViewOptions()->IsGraphic() )
1200 		return sal_True;
1201 
1202 	const SwGrfNode *pNd;
1203 	if( 0 != (pNd = GetNode()->GetGrfNode()) )
1204 		return pNd->IsTransparent();
1205 
1206 	//#29381# OLE sind immer Transparent.
1207 	return sal_True;
1208 }
1209 
1210 
StopAnimation(OutputDevice * pOut) const1211 void SwNoTxtFrm::StopAnimation( OutputDevice* pOut ) const
1212 {
1213 	//animierte Grafiken anhalten
1214 	const SwGrfNode* pGrfNd = dynamic_cast< const SwGrfNode* >(GetNode()->GetGrfNode());
1215 
1216     if( pGrfNd && pGrfNd->IsAnimated() )
1217     {
1218 		const_cast< SwGrfNode* >(pGrfNd)->StopGraphicAnimation( pOut, long(this) );
1219     }
1220 }
1221 
1222 
HasAnimation() const1223 sal_Bool SwNoTxtFrm::HasAnimation() const
1224 {
1225 	const SwGrfNode* pGrfNd = GetNode()->GetGrfNode();
1226 	return pGrfNd && pGrfNd->IsAnimated();
1227 }
1228 
1229 
1230 
1231