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