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