xref: /aoo41x/main/sw/source/core/layout/paintfrm.cxx (revision 22ea211e)
1efeef26fSAndrew Rist /**************************************************************
20272ccd2Smseidel  *
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
100272ccd2Smseidel  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
120272ccd2Smseidel  *
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.
190272ccd2Smseidel  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #include <vcl/sound.hxx>
30cdf0e10cSrcweir #include <tools/poly.hxx>
31cdf0e10cSrcweir #define _SVSTDARR_LONGS
32cdf0e10cSrcweir #include <svl/svstdarr.hxx>
33cdf0e10cSrcweir #include <svx/xoutbmp.hxx>
34cdf0e10cSrcweir #include <sfx2/progress.hxx>
35cdf0e10cSrcweir #include <editeng/brshitem.hxx>
36cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
37cdf0e10cSrcweir #include <editeng/prntitem.hxx>
38cdf0e10cSrcweir #include <editeng/boxitem.hxx>
39cdf0e10cSrcweir #include <editeng/shaditem.hxx>
40cdf0e10cSrcweir #include <svx/framelink.hxx>
41cdf0e10cSrcweir #include <vcl/graph.hxx>
42cdf0e10cSrcweir #include <svx/svdpagv.hxx>
43cdf0e10cSrcweir #include <hintids.hxx>
44cdf0e10cSrcweir #include <tgrditem.hxx>
45cdf0e10cSrcweir #include <switerator.hxx>
46cdf0e10cSrcweir #include <fmtsrnd.hxx>
47cdf0e10cSrcweir #include <fmtclds.hxx>
48cdf0e10cSrcweir #include <tools/shl.hxx>
49cdf0e10cSrcweir #include <comcore.hrc>
50cdf0e10cSrcweir #include <swmodule.hxx>
51cdf0e10cSrcweir #include <rootfrm.hxx>
52cdf0e10cSrcweir #include <pagefrm.hxx>
53cdf0e10cSrcweir #include <cntfrm.hxx>
54cdf0e10cSrcweir #include <viewsh.hxx>
55cdf0e10cSrcweir #include <section.hxx>
56cdf0e10cSrcweir #include <sectfrm.hxx>
57cdf0e10cSrcweir #include <doc.hxx>
58cdf0e10cSrcweir #include <viewimp.hxx>
59cdf0e10cSrcweir #include <dflyobj.hxx>
60cdf0e10cSrcweir #include <flyfrm.hxx>
61cdf0e10cSrcweir #include <frmtool.hxx>
62cdf0e10cSrcweir #include <viewopt.hxx>
63cdf0e10cSrcweir #include <dview.hxx>
64cdf0e10cSrcweir #include <dcontact.hxx>
65cdf0e10cSrcweir #include <txtfrm.hxx>
66cdf0e10cSrcweir #include <ftnfrm.hxx>
67cdf0e10cSrcweir #include <tabfrm.hxx>
68cdf0e10cSrcweir #include <rowfrm.hxx>
69cdf0e10cSrcweir #include <cellfrm.hxx>
70cdf0e10cSrcweir #include <notxtfrm.hxx>
71cdf0e10cSrcweir #include <swregion.hxx>
72cdf0e10cSrcweir #include <layact.hxx>
73cdf0e10cSrcweir #include <pagedesc.hxx>
74cdf0e10cSrcweir #include <ptqueue.hxx>
75cdf0e10cSrcweir #include <noteurl.hxx>
76cdf0e10cSrcweir #include <virtoutp.hxx>
77cdf0e10cSrcweir #include <lineinfo.hxx>
78cdf0e10cSrcweir #include <dbg_lay.hxx>
79cdf0e10cSrcweir #include <accessibilityoptions.hxx>
80cdf0e10cSrcweir #include <docsh.hxx>
81cdf0e10cSrcweir #include <swtable.hxx>
82cdf0e10cSrcweir #include <svx/svdogrp.hxx>
83cdf0e10cSrcweir #include <sortedobjs.hxx>
84cdf0e10cSrcweir #include <EnhancedPDFExportHelper.hxx>
85cdf0e10cSrcweir // <--
86cdf0e10cSrcweir // --> OD #i76669#
87cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
88cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx>
89cdf0e10cSrcweir #include <svx/sdr/contact/viewcontact.hxx>
90cdf0e10cSrcweir // <--
91cdf0e10cSrcweir 
92cdf0e10cSrcweir #include <ndole.hxx>
9378d93489SArmin Le Grand #include <svx/charthelper.hxx>
94cdf0e10cSrcweir #include <PostItMgr.hxx>
95cdf0e10cSrcweir #include <tools/color.hxx>
96cdf0e10cSrcweir #include <vcl/svapp.hxx>
97cdf0e10cSrcweir 
98cdf0e10cSrcweir #define COL_NOTES_SIDEPANE					RGB_COLORDATA(230,230,230)
99cdf0e10cSrcweir #define COL_NOTES_SIDEPANE_BORDER			RGB_COLORDATA(200,200,200)
100cdf0e10cSrcweir #define COL_NOTES_SIDEPANE_SCROLLAREA		RGB_COLORDATA(230,230,220)
101cdf0e10cSrcweir 
102cdf0e10cSrcweir using namespace ::com::sun::star;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir #define GETOBJSHELL()		((SfxObjectShell*)rSh.GetDoc()->GetDocShell())
105cdf0e10cSrcweir 
106cdf0e10cSrcweir //Tabellenhilfslinien an?
107cdf0e10cSrcweir #define IS_SUBS_TABLE \
108cdf0e10cSrcweir     (pGlobalShell->GetViewOptions()->IsTable() && \
109cdf0e10cSrcweir     !pGlobalShell->GetViewOptions()->IsPagePreview()&&\
110cdf0e10cSrcweir     !pGlobalShell->GetViewOptions()->IsReadonly()&&\
111cdf0e10cSrcweir     !pGlobalShell->GetViewOptions()->IsFormView() &&\
112cdf0e10cSrcweir      SwViewOption::IsTableBoundaries())
113cdf0e10cSrcweir //sonstige Hilfslinien an?
114cdf0e10cSrcweir #define IS_SUBS (!pGlobalShell->GetViewOptions()->IsPagePreview() && \
115cdf0e10cSrcweir         !pGlobalShell->GetViewOptions()->IsReadonly() && \
116cdf0e10cSrcweir         !pGlobalShell->GetViewOptions()->IsFormView() &&\
117cdf0e10cSrcweir          SwViewOption::IsDocBoundaries())
118cdf0e10cSrcweir //Hilfslinien fuer Bereiche
119cdf0e10cSrcweir #define IS_SUBS_SECTION (!pGlobalShell->GetViewOptions()->IsPagePreview() && \
120cdf0e10cSrcweir                          !pGlobalShell->GetViewOptions()->IsReadonly()&&\
121cdf0e10cSrcweir                          !pGlobalShell->GetViewOptions()->IsFormView() &&\
122cdf0e10cSrcweir                           SwViewOption::IsSectionBoundaries())
123cdf0e10cSrcweir #define IS_SUBS_FLYS (!pGlobalShell->GetViewOptions()->IsPagePreview() && \
124cdf0e10cSrcweir                       !pGlobalShell->GetViewOptions()->IsReadonly()&&\
125cdf0e10cSrcweir                       !pGlobalShell->GetViewOptions()->IsFormView() &&\
126cdf0e10cSrcweir                        SwViewOption::IsObjectBoundaries())
127cdf0e10cSrcweir 
128cdf0e10cSrcweir #define SW_MAXBORDERCACHE 20
129cdf0e10cSrcweir 
130cdf0e10cSrcweir //Klassendeklarationen. Hier weil sie eben nur in diesem File benoetigt
131cdf0e10cSrcweir //werden.
132cdf0e10cSrcweir 
133cdf0e10cSrcweir #define SUBCOL_PAGE     0x01    //Helplines of the page
134cdf0e10cSrcweir #define SUBCOL_BREAK    0x02    //Helpline for a page or column break
135cdf0e10cSrcweir #define SUBCOL_TAB      0x08    //Helplines inside tables
136cdf0e10cSrcweir #define SUBCOL_FLY      0x10    //Helplines inside fly frames
137cdf0e10cSrcweir #define SUBCOL_SECT     0x20    //Helplines inside sections
138cdf0e10cSrcweir 
139cdf0e10cSrcweir //----- Klassen zum Sammeln von Umrandungen und Hilfslinien ---
140cdf0e10cSrcweir class SwLineRect : public SwRect
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	const Color	   *pColor;
143cdf0e10cSrcweir 	const SwTabFrm *pTab;
144cdf0e10cSrcweir 		  sal_uInt8		nSubColor;  //Hilfslinien einfaerben
145cdf0e10cSrcweir 		  sal_Bool		bPainted;	//schon gepaintet?
146cdf0e10cSrcweir 		  sal_uInt8		nLock;		//Um die Linien zum Hell-Layer abzugrenzen.
147cdf0e10cSrcweir public:
148cdf0e10cSrcweir 	SwLineRect( const SwRect &rRect, const Color *pCol,
149cdf0e10cSrcweir                 const SwTabFrm *pT , const sal_uInt8 nSCol );
150cdf0e10cSrcweir 
GetColor() const151cdf0e10cSrcweir 	const Color			*GetColor() const { return pColor;}
GetTab() const152cdf0e10cSrcweir 	const SwTabFrm		*GetTab()	const { return pTab;  }
SetPainted()153cdf0e10cSrcweir 	void  SetPainted()					  { bPainted = sal_True; }
Lock(sal_Bool bLock)154cdf0e10cSrcweir 	void  Lock( sal_Bool bLock )			  { if ( bLock )
155cdf0e10cSrcweir 												++nLock;
156cdf0e10cSrcweir 											else if ( nLock )
157cdf0e10cSrcweir 												--nLock;
158cdf0e10cSrcweir 										  }
IsPainted() const159cdf0e10cSrcweir 	sal_Bool  IsPainted()				const { return bPainted; }
IsLocked() const160cdf0e10cSrcweir 	sal_Bool  IsLocked()				const { return nLock != 0;  }
GetSubColor() const161cdf0e10cSrcweir 	sal_uInt8  GetSubColor()				const { return nSubColor;}
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	sal_Bool MakeUnion( const SwRect &rRect );
164cdf0e10cSrcweir };
165cdf0e10cSrcweir 
166cdf0e10cSrcweir SV_DECL_VARARR( SwLRects, SwLineRect, 100, 100 )
167cdf0e10cSrcweir 
168cdf0e10cSrcweir class SwLineRects : public SwLRects
169cdf0e10cSrcweir {
170089ea224Smseidel 	sal_uInt16 nLastCount;	// unnuetze Durchlaeufe im PaintLines verhindern.
171cdf0e10cSrcweir public:
SwLineRects()172cdf0e10cSrcweir 	SwLineRects() : nLastCount( 0 ) {}
173cdf0e10cSrcweir 	void AddLineRect( const SwRect& rRect,	const Color *pColor,
174cdf0e10cSrcweir                       const SwTabFrm *pTab, const sal_uInt8 nSCol );
175cdf0e10cSrcweir 	void ConnectEdges( OutputDevice *pOut );
176cdf0e10cSrcweir 	void PaintLines  ( OutputDevice *pOut );
177cdf0e10cSrcweir 	void LockLines( sal_Bool bLock );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     /// OD 13.08.2002 - correct type of function
Free() const180cdf0e10cSrcweir     sal_uInt16 Free() const { return nFree; }
181cdf0e10cSrcweir };
182cdf0e10cSrcweir 
183cdf0e10cSrcweir class SwSubsRects : public SwLineRects
184cdf0e10cSrcweir {
185cdf0e10cSrcweir 	void RemoveSuperfluousSubsidiaryLines( const SwLineRects &rRects ); //;-)
186cdf0e10cSrcweir public:
187cdf0e10cSrcweir 	void PaintSubsidiary( OutputDevice *pOut, const SwLineRects *pRects );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 	inline void Ins( const SwRect &rRect, const sal_uInt8 nSCol );
190cdf0e10cSrcweir };
191cdf0e10cSrcweir 
192cdf0e10cSrcweir //----------------- End Klassen Umrandungen ----------------------
193cdf0e10cSrcweir 
194cdf0e10cSrcweir static ViewShell *pGlobalShell = 0;
195cdf0e10cSrcweir 
196089ea224Smseidel //Wenn durchsichtige FlyInCnts im PaintBackground gepaintet werden so soll der
197cdf0e10cSrcweir //Hintergrund nicht mehr retouchiert werden.
198cdf0e10cSrcweir //static sal_Bool bLockFlyBackground = sal_False;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir //Wenn vom Fly ein Metafile abgezogen wird, so soll nur der FlyInhalt und vor
201cdf0e10cSrcweir //nur hintergrund vom FlyInhalt gepaintet werden.
202cdf0e10cSrcweir static sal_Bool bFlyMetafile = sal_False;
203cdf0e10cSrcweir static OutputDevice *pFlyMetafileOut = 0;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir //Die Retouche fuer Durchsichtige Flys wird vom Hintergrund der Flys
206cdf0e10cSrcweir //erledigt. Dabei darf der Fly selbst natuerlich nicht ausgespart werden.
207cdf0e10cSrcweir //siehe PaintBackground und lcl_SubtractFlys()
208cdf0e10cSrcweir static SwFlyFrm *pRetoucheFly  = 0;
209cdf0e10cSrcweir static SwFlyFrm *pRetoucheFly2 = 0;
210cdf0e10cSrcweir 
211cdf0e10cSrcweir //Groesse eines Pixel und die Haelfte davon. Wird jeweils bei Eintritt in
212cdf0e10cSrcweir //SwRootFrm::Paint neu gesetzt.
213cdf0e10cSrcweir static long nPixelSzW = 0, nPixelSzH = 0;
214cdf0e10cSrcweir static long nHalfPixelSzW = 0, nHalfPixelSzH = 0;
215cdf0e10cSrcweir static long nMinDistPixelW = 0, nMinDistPixelH = 0;
216cdf0e10cSrcweir 
217cdf0e10cSrcweir //Aktueller Zoomfaktor
218cdf0e10cSrcweir static double aScaleX = 1.0;
219cdf0e10cSrcweir static double aScaleY = 1.0;
220cdf0e10cSrcweir static double aMinDistScale = 0.73;
221cdf0e10cSrcweir static double aEdgeScale = 0.5;
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 
224cdf0e10cSrcweir //In pLines werden Umrandungen waehrend des Paint gesammelt und soweit
225cdf0e10cSrcweir //moeglich zusammengefasst.
226cdf0e10cSrcweir //In pSubsLines werden Hilfslinien gesammelt und zusammengefasst. Diese
227cdf0e10cSrcweir //werden vor der Ausgabe mit pLines abgeglichen, so dass moeglichst keine
228cdf0e10cSrcweir //Umrandungen von den Hilfslinen verdeckt werden.
229089ea224Smseidel //bTablines ist waehrend des Paints einer Tabelle sal_True.
230cdf0e10cSrcweir static SwLineRects *pLines = 0;
231cdf0e10cSrcweir static SwSubsRects *pSubsLines = 0;
232cdf0e10cSrcweir // OD 18.11.2002 #99672# - global variable for sub-lines of body, header, footer,
233cdf0e10cSrcweir // section and footnote frames.
234cdf0e10cSrcweir static SwSubsRects *pSpecSubsLines = 0;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir static SfxProgress *pProgress = 0;
237cdf0e10cSrcweir 
238cdf0e10cSrcweir static SwFlyFrm *pFlyOnlyDraw = 0;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir //Damit die Flys auch fuer den Hack richtig gepaintet werden koennen.
241cdf0e10cSrcweir static sal_Bool bTableHack = sal_False;
242cdf0e10cSrcweir 
243cdf0e10cSrcweir //Um das teure Ermitteln der RetoucheColor zu optimieren
244cdf0e10cSrcweir Color aGlobalRetoucheColor;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir //Statics fuer Umrandungsalignment setzen.
247cdf0e10cSrcweir // OD 05.05.2003 #107169# - adjustment for 'small' twip-to-pixel relations:
248cdf0e10cSrcweir // For 'small' twip-to-pixel relations (less then 2:1)
249cdf0e10cSrcweir // values of <nHalfPixelSzW> and <nHalfPixelSzH> are set to ZERO.
SwCalcPixStatics(OutputDevice * pOut)250cdf0e10cSrcweir void SwCalcPixStatics( OutputDevice *pOut )
251cdf0e10cSrcweir {
252cdf0e10cSrcweir     // OD 30.04.2003 #107169# - determine 'small' twip-to-pixel relation
253cdf0e10cSrcweir     sal_Bool bSmallTwipToPxRelW = sal_False;
254cdf0e10cSrcweir     sal_Bool bSmallTwipToPxRelH = sal_False;
255cdf0e10cSrcweir     {
256cdf0e10cSrcweir         Size aCheckTwipToPxRelSz( pOut->PixelToLogic( Size( 100, 100 )) );
257cdf0e10cSrcweir         if ( (aCheckTwipToPxRelSz.Width()/100.0) < 2.0 )
258cdf0e10cSrcweir         {
259cdf0e10cSrcweir             bSmallTwipToPxRelW = sal_True;
260cdf0e10cSrcweir         }
261cdf0e10cSrcweir         if ( (aCheckTwipToPxRelSz.Height()/100.0) < 2.0 )
262cdf0e10cSrcweir         {
263cdf0e10cSrcweir             bSmallTwipToPxRelH = sal_True;
264cdf0e10cSrcweir         }
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     Size aSz( pOut->PixelToLogic( Size( 1,1 )) );
268cdf0e10cSrcweir 
269cdf0e10cSrcweir     nPixelSzW = aSz.Width();
270cdf0e10cSrcweir     if( !nPixelSzW )
271cdf0e10cSrcweir         nPixelSzW = 1;
272cdf0e10cSrcweir     nPixelSzH = aSz.Height();
273cdf0e10cSrcweir     if( !nPixelSzH )
274cdf0e10cSrcweir         nPixelSzH = 1;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     // OD 06.05.2003 #107169# - consider 'small' twip-to-pixel relations
277cdf0e10cSrcweir     if ( !bSmallTwipToPxRelW )
278cdf0e10cSrcweir     {
279cdf0e10cSrcweir         nHalfPixelSzW = nPixelSzW / 2 + 1;
280cdf0e10cSrcweir     }
281cdf0e10cSrcweir     else
282cdf0e10cSrcweir     {
283cdf0e10cSrcweir         nHalfPixelSzW = 0;
284cdf0e10cSrcweir     }
285cdf0e10cSrcweir     // OD 06.05.2003 #107169# - consider 'small' twip-to-pixel relations
286cdf0e10cSrcweir     if ( !bSmallTwipToPxRelH )
287cdf0e10cSrcweir     {
288cdf0e10cSrcweir         nHalfPixelSzH = nPixelSzH / 2 + 1;
289cdf0e10cSrcweir     }
290cdf0e10cSrcweir     else
291cdf0e10cSrcweir     {
292cdf0e10cSrcweir         nHalfPixelSzH = 0;
293cdf0e10cSrcweir     }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir     nMinDistPixelW = nPixelSzW * 2 + 1;
296cdf0e10cSrcweir 	nMinDistPixelH = nPixelSzH * 2 + 1;
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 	const MapMode &rMap = pOut->GetMapMode();
299cdf0e10cSrcweir 	aScaleX = rMap.GetScaleX();
300cdf0e10cSrcweir 	aScaleY = rMap.GetScaleY();
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir //Zum Sichern der statics, damit das Paint (quasi) reentrant wird.
304cdf0e10cSrcweir class SwSavePaintStatics
305cdf0e10cSrcweir {
306cdf0e10cSrcweir 	sal_Bool			bSFlyMetafile,
307cdf0e10cSrcweir                         bSPageOnly;
308cdf0e10cSrcweir 	ViewShell		   *pSGlobalShell;
309cdf0e10cSrcweir 	OutputDevice	   *pSFlyMetafileOut;
310cdf0e10cSrcweir 	SwFlyFrm		   *pSRetoucheFly,
311cdf0e10cSrcweir 					   *pSRetoucheFly2,
312cdf0e10cSrcweir 					   *pSFlyOnlyDraw;
313cdf0e10cSrcweir 	SwLineRects		   *pSLines;
314cdf0e10cSrcweir 	SwSubsRects		   *pSSubsLines;
315cdf0e10cSrcweir     // --> OD 2005-07-04 #123196#
316cdf0e10cSrcweir     SwSubsRects*        pSSpecSubsLines;
317cdf0e10cSrcweir     // <--
318cdf0e10cSrcweir 	SfxProgress		   *pSProgress;
319cdf0e10cSrcweir 	long				nSPixelSzW,
320cdf0e10cSrcweir 						nSPixelSzH,
321cdf0e10cSrcweir 						nSHalfPixelSzW,
322cdf0e10cSrcweir 						nSHalfPixelSzH,
323cdf0e10cSrcweir 						nSMinDistPixelW,
324cdf0e10cSrcweir 						nSMinDistPixelH;
325cdf0e10cSrcweir 	Color				aSGlobalRetoucheColor;
326cdf0e10cSrcweir 	double				aSScaleX,
327cdf0e10cSrcweir 						aSScaleY;
328cdf0e10cSrcweir public:
329cdf0e10cSrcweir 	SwSavePaintStatics();
330cdf0e10cSrcweir 	~SwSavePaintStatics();
331cdf0e10cSrcweir };
332cdf0e10cSrcweir 
SwSavePaintStatics()333cdf0e10cSrcweir SwSavePaintStatics::SwSavePaintStatics() :
334cdf0e10cSrcweir 	bSFlyMetafile       ( bFlyMetafile      ),
335cdf0e10cSrcweir     pSGlobalShell       ( pGlobalShell      ),
336cdf0e10cSrcweir 	pSFlyMetafileOut    ( pFlyMetafileOut   ),
337cdf0e10cSrcweir 	pSRetoucheFly       ( pRetoucheFly      ),
338cdf0e10cSrcweir 	pSRetoucheFly2      ( pRetoucheFly2     ),
339cdf0e10cSrcweir 	pSFlyOnlyDraw       ( pFlyOnlyDraw      ),
340cdf0e10cSrcweir 	pSLines             ( pLines            ),
341cdf0e10cSrcweir 	pSSubsLines         ( pSubsLines        ),
342cdf0e10cSrcweir     // --> OD 2005-07-04 #123196#
343cdf0e10cSrcweir     pSSpecSubsLines     ( pSpecSubsLines    ),
344cdf0e10cSrcweir     // <--
345cdf0e10cSrcweir 	pSProgress          ( pProgress         ),
346cdf0e10cSrcweir 	nSPixelSzW          ( nPixelSzW         ),
347cdf0e10cSrcweir 	nSPixelSzH          ( nPixelSzH         ),
348cdf0e10cSrcweir 	nSHalfPixelSzW      ( nHalfPixelSzW     ),
349cdf0e10cSrcweir 	nSHalfPixelSzH      ( nHalfPixelSzH     ),
350cdf0e10cSrcweir 	nSMinDistPixelW     ( nMinDistPixelW    ),
351cdf0e10cSrcweir 	nSMinDistPixelH     ( nMinDistPixelH    ),
352cdf0e10cSrcweir 	aSGlobalRetoucheColor( aGlobalRetoucheColor ),
353cdf0e10cSrcweir 	aSScaleX            ( aScaleX           ),
354cdf0e10cSrcweir     aSScaleY            ( aScaleY           )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir     bFlyMetafile = sal_False;
357cdf0e10cSrcweir 	pFlyMetafileOut = 0;
358cdf0e10cSrcweir 	pRetoucheFly  = 0;
359cdf0e10cSrcweir 	pRetoucheFly2 = 0;
360cdf0e10cSrcweir 	nPixelSzW = nPixelSzH =
361cdf0e10cSrcweir 	nHalfPixelSzW = nHalfPixelSzH =
362cdf0e10cSrcweir 	nMinDistPixelW = nMinDistPixelH = 0;
363cdf0e10cSrcweir 	aScaleX = aScaleY = 1.0;
364cdf0e10cSrcweir 	aMinDistScale = 0.73;
365cdf0e10cSrcweir 	aEdgeScale = 0.5;
366cdf0e10cSrcweir 	pLines = 0;
367cdf0e10cSrcweir 	pSubsLines = 0;
368cdf0e10cSrcweir     // --> OD 2005-07-04 #123196#
369cdf0e10cSrcweir     pSpecSubsLines = 0L;
370cdf0e10cSrcweir     // <--
371cdf0e10cSrcweir 	pProgress = 0;
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
~SwSavePaintStatics()374cdf0e10cSrcweir SwSavePaintStatics::~SwSavePaintStatics()
375cdf0e10cSrcweir {
376cdf0e10cSrcweir 	pGlobalShell	   = pSGlobalShell;
377cdf0e10cSrcweir 	bFlyMetafile       = bSFlyMetafile;
378cdf0e10cSrcweir     pFlyMetafileOut    = pSFlyMetafileOut;
379cdf0e10cSrcweir 	pRetoucheFly       = pSRetoucheFly;
380cdf0e10cSrcweir 	pRetoucheFly2      = pSRetoucheFly2;
381cdf0e10cSrcweir 	pFlyOnlyDraw       = pSFlyOnlyDraw;
382cdf0e10cSrcweir 	pLines             = pSLines;
383cdf0e10cSrcweir 	pSubsLines         = pSSubsLines;
384cdf0e10cSrcweir     // --> OD 2005-07-04 #123196#
385cdf0e10cSrcweir     pSpecSubsLines     = pSSpecSubsLines;
386cdf0e10cSrcweir     // <--
387cdf0e10cSrcweir     pProgress          = pSProgress;
388cdf0e10cSrcweir 	nPixelSzW          = nSPixelSzW;
389cdf0e10cSrcweir 	nPixelSzH          = nSPixelSzH;
390cdf0e10cSrcweir 	nHalfPixelSzW      = nSHalfPixelSzW;
391cdf0e10cSrcweir 	nHalfPixelSzH      = nSHalfPixelSzH;
392cdf0e10cSrcweir 	nMinDistPixelW     = nSMinDistPixelW;
393cdf0e10cSrcweir 	nMinDistPixelH     = nSMinDistPixelH;
394cdf0e10cSrcweir 	aGlobalRetoucheColor = aSGlobalRetoucheColor;
395cdf0e10cSrcweir 	aScaleX            = aSScaleX;
396cdf0e10cSrcweir 	aScaleY            = aSScaleY;
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir //----------------- Implementierungen fuer Tabellenumrandung --------------
400cdf0e10cSrcweir 
401cdf0e10cSrcweir SV_IMPL_VARARR( SwLRects, SwLineRect );
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 
SwLineRect(const SwRect & rRect,const Color * pCol,const SwTabFrm * pT,const sal_uInt8 nSCol)404cdf0e10cSrcweir SwLineRect::SwLineRect( const SwRect &rRect, const Color *pCol,
405cdf0e10cSrcweir 						const SwTabFrm *pT, const sal_uInt8 nSCol ) :
406cdf0e10cSrcweir 	SwRect( rRect ),
407cdf0e10cSrcweir 	pColor( pCol ),
408cdf0e10cSrcweir 	pTab( pT ),
409cdf0e10cSrcweir     nSubColor( nSCol ),
410cdf0e10cSrcweir     bPainted( sal_False ),
411cdf0e10cSrcweir     nLock( 0 )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
MakeUnion(const SwRect & rRect)415cdf0e10cSrcweir sal_Bool SwLineRect::MakeUnion( const SwRect &rRect )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir 	//Es wurde bereits ausserhalb geprueft, ob die Rechtecke die gleiche
418cdf0e10cSrcweir 	//Ausrichtung (horizontal bzw. vertikal), Farbe usw. besitzen.
419cdf0e10cSrcweir 	if ( Height() > Width() ) //Vertikale Linie
420cdf0e10cSrcweir 	{
421cdf0e10cSrcweir 		if ( Left()  == rRect.Left() && Width() == rRect.Width() )
422cdf0e10cSrcweir 		{
423cdf0e10cSrcweir 			//Zusammenfassen wenn kein Luecke zwischen den Linien ist.
424cdf0e10cSrcweir 			const long nAdd = nPixelSzW + nHalfPixelSzW;
425cdf0e10cSrcweir 			if ( Bottom() + nAdd >= rRect.Top() &&
426cdf0e10cSrcweir 				 Top()	  - nAdd <= rRect.Bottom()	)
427cdf0e10cSrcweir 			{
428cdf0e10cSrcweir 				Bottom( Max( Bottom(), rRect.Bottom() ) );
429cdf0e10cSrcweir 				Top   ( Min( Top(),	   rRect.Top()	  ) );
430cdf0e10cSrcweir 				return sal_True;
431cdf0e10cSrcweir 			}
432cdf0e10cSrcweir 		}
433cdf0e10cSrcweir 	}
434cdf0e10cSrcweir 	else
435cdf0e10cSrcweir 	{
436cdf0e10cSrcweir 		if ( Top()	== rRect.Top() && Height() == rRect.Height() )
437cdf0e10cSrcweir 		{
438cdf0e10cSrcweir 			//Zusammenfassen wenn kein Luecke zwischen den Linien ist.
439cdf0e10cSrcweir 			const long nAdd = nPixelSzW + nHalfPixelSzW;
440cdf0e10cSrcweir 			if ( Right() + nAdd >= rRect.Left() &&
441cdf0e10cSrcweir                  Left()  - nAdd <= rRect.Right() )
442cdf0e10cSrcweir 			{
443cdf0e10cSrcweir 				Right( Max( Right(), rRect.Right() ) );
444cdf0e10cSrcweir 				Left ( Min( Left(),  rRect.Left()  ) );
445cdf0e10cSrcweir 				return sal_True;
446cdf0e10cSrcweir 			}
447cdf0e10cSrcweir 		}
448cdf0e10cSrcweir 	}
449cdf0e10cSrcweir 	return sal_False;
450cdf0e10cSrcweir }
451cdf0e10cSrcweir 
AddLineRect(const SwRect & rRect,const Color * pCol,const SwTabFrm * pTab,const sal_uInt8 nSCol)452cdf0e10cSrcweir void SwLineRects::AddLineRect( const SwRect &rRect, const Color *pCol,
453cdf0e10cSrcweir 							   const SwTabFrm *pTab, const sal_uInt8 nSCol )
454cdf0e10cSrcweir {
455cdf0e10cSrcweir 	//Rueckwaerts durch, weil Linien die zusammengefasst werden koennen i.d.R.
456cdf0e10cSrcweir 	//im gleichen Kontext gepaintet werden.
457cdf0e10cSrcweir 	for ( sal_uInt16 i = Count(); i ; )
458cdf0e10cSrcweir 	{
459cdf0e10cSrcweir 		SwLineRect &rLRect = operator[](--i);
460cdf0e10cSrcweir 		//Pruefen von Ausrichtung, Farbe, Tabelle.
461cdf0e10cSrcweir 		if ( rLRect.GetTab() == pTab &&
462cdf0e10cSrcweir 			 !rLRect.IsPainted() && rLRect.GetSubColor() == nSCol &&
463cdf0e10cSrcweir 			 (rLRect.Height() > rLRect.Width()) == (rRect.Height() > rRect.Width()) &&
464cdf0e10cSrcweir 			 ((!rLRect.GetColor() && !pCol) ||
465cdf0e10cSrcweir 			  (rLRect.GetColor() && pCol && *rLRect.GetColor() == *pCol)) )
466cdf0e10cSrcweir 		{
467cdf0e10cSrcweir 			if ( rLRect.MakeUnion( rRect ) )
468cdf0e10cSrcweir 				return;
469cdf0e10cSrcweir 		}
470cdf0e10cSrcweir 	}
471cdf0e10cSrcweir 	Insert( SwLineRect( rRect, pCol, pTab, nSCol ), Count() );
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
ConnectEdges(OutputDevice * pOut)474cdf0e10cSrcweir void SwLineRects::ConnectEdges( OutputDevice *pOut )
475cdf0e10cSrcweir {
476cdf0e10cSrcweir 	if ( pOut->GetOutDevType() != OUTDEV_PRINTER )
477cdf0e10cSrcweir 	{
478cdf0e10cSrcweir 		//Fuer einen zu kleinen Zoom arbeite ich nicht.
479cdf0e10cSrcweir 		if ( aScaleX < aEdgeScale || aScaleY < aEdgeScale )
480cdf0e10cSrcweir 			return;
481cdf0e10cSrcweir 	}
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	static const long nAdd = 20;
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	SvPtrarr   aCheck( 64, 64 );
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 	for ( int i = 0; i < (int)Count(); ++i )
488cdf0e10cSrcweir 	{
489cdf0e10cSrcweir 		SwLineRect &rL1 = operator[](sal_uInt16(i));
490cdf0e10cSrcweir 		if ( !rL1.GetTab() || rL1.IsPainted() || rL1.IsLocked() )
491cdf0e10cSrcweir 			continue;
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 		aCheck.Remove( 0, aCheck.Count() );
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 		const sal_Bool bVert = rL1.Height() > rL1.Width();
496cdf0e10cSrcweir 		long nL1a, nL1b, nL1c, nL1d;
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 		if ( bVert )
499cdf0e10cSrcweir         {
500cdf0e10cSrcweir             nL1a = rL1.Top();   nL1b = rL1.Left();
501cdf0e10cSrcweir 			nL1c = rL1.Right(); nL1d = rL1.Bottom();
502cdf0e10cSrcweir 		}
503cdf0e10cSrcweir 		else
504cdf0e10cSrcweir         {
505cdf0e10cSrcweir             nL1a = rL1.Left();   nL1b = rL1.Top();
506cdf0e10cSrcweir 			nL1c = rL1.Bottom(); nL1d = rL1.Right();
507cdf0e10cSrcweir 		}
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 		//Alle moeglicherweise mit i1 zu verbindenden Linien einsammeln.
510cdf0e10cSrcweir 		for ( sal_uInt16 i2 = 0; i2 < Count(); ++i2 )
511cdf0e10cSrcweir 		{
512cdf0e10cSrcweir 			SwLineRect &rL2 = operator[](i2);
513cdf0e10cSrcweir 			if ( rL2.GetTab() != rL1.GetTab() ||
514cdf0e10cSrcweir 				 rL2.IsPainted() 			  ||
515cdf0e10cSrcweir 				 rL2.IsLocked()				  ||
516cdf0e10cSrcweir 				 (bVert == (rL2.Height() > rL2.Width())) )
517cdf0e10cSrcweir 				continue;
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 			long nL2a, nL2b, nL2c, nL2d;
520cdf0e10cSrcweir 			if ( bVert )
521cdf0e10cSrcweir             {
522cdf0e10cSrcweir                 nL2a = rL2.Top();   nL2b = rL2.Left();
523cdf0e10cSrcweir 				nL2c = rL2.Right(); nL2d = rL2.Bottom();
524cdf0e10cSrcweir 			}
525cdf0e10cSrcweir 			else
526cdf0e10cSrcweir             {
527cdf0e10cSrcweir                 nL2a = rL2.Left();   nL2b = rL2.Top();
528cdf0e10cSrcweir 				nL2c = rL2.Bottom(); nL2d = rL2.Right();
529cdf0e10cSrcweir 			}
530cdf0e10cSrcweir 
531cdf0e10cSrcweir 			if ( (nL1a - nAdd < nL2d && nL1d + nAdd > nL2a) &&
532cdf0e10cSrcweir 				  ((nL1b >	nL2b && nL1c		< nL2c) ||
533cdf0e10cSrcweir 				   (nL1c >= nL2c && nL1b - nAdd < nL2c) ||
534cdf0e10cSrcweir 				   (nL1b <= nL2b && nL1c + nAdd > nL2b)) )
535cdf0e10cSrcweir 			{
536cdf0e10cSrcweir 				SwLineRect *pMSC = &rL2;
537cdf0e10cSrcweir 				aCheck.Insert( pMSC, aCheck.Count() );
538cdf0e10cSrcweir 			}
539cdf0e10cSrcweir 		}
540cdf0e10cSrcweir 		if ( aCheck.Count() < 2 )
541cdf0e10cSrcweir 			continue;
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 		sal_Bool bRemove = sal_False;
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 		//Fuer jede Linie jede alle folgenden checken.
546cdf0e10cSrcweir 		for ( sal_uInt16 k = 0; !bRemove && k < aCheck.Count(); ++k )
547cdf0e10cSrcweir 		{
548cdf0e10cSrcweir 			SwLineRect &rR1 = (SwLineRect&)*(SwLineRect*)aCheck[k];
549cdf0e10cSrcweir 
550cdf0e10cSrcweir 			for ( sal_uInt16 k2 = k+1; !bRemove && k2 < aCheck.Count(); ++k2 )
551cdf0e10cSrcweir 			{
552cdf0e10cSrcweir 				SwLineRect &rR2 = (SwLineRect&)*(SwLineRect*)aCheck[k2];
553cdf0e10cSrcweir 				if ( bVert )
554cdf0e10cSrcweir 				{
555cdf0e10cSrcweir 					SwLineRect *pLA = 0;
556cdf0e10cSrcweir                     SwLineRect *pLB = 0;
557cdf0e10cSrcweir 					if ( rR1.Top() < rR2.Top() )
558cdf0e10cSrcweir 					{
559cdf0e10cSrcweir 						pLA = &rR1; pLB = &rR2;
560cdf0e10cSrcweir 					}
561cdf0e10cSrcweir 					else if ( rR1.Top() > rR2.Top() )
562cdf0e10cSrcweir 					{
563cdf0e10cSrcweir 						pLA = &rR2; pLB = &rR1;
564cdf0e10cSrcweir 					}
565cdf0e10cSrcweir 					//beschreiben k1 und k2 eine Doppellinie?
566cdf0e10cSrcweir 					if ( pLA && pLA->Bottom() + 60 > pLB->Top() )
567cdf0e10cSrcweir 					{
568cdf0e10cSrcweir 						if ( rL1.Top() < pLA->Top() )
569cdf0e10cSrcweir 						{
570cdf0e10cSrcweir 							if ( rL1.Bottom() == pLA->Bottom() )
571cdf0e10cSrcweir 								continue;	//kleiner Irrtum (woher?)
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 							SwRect aIns( rL1 );
574cdf0e10cSrcweir 							aIns.Bottom( pLA->Bottom() );
575cdf0e10cSrcweir 							if ( !rL1.IsInside( aIns ) )
576cdf0e10cSrcweir 								continue;
577cdf0e10cSrcweir                             const sal_uInt16 nTmpFree = Free();
578cdf0e10cSrcweir 							Insert( SwLineRect( aIns, rL1.GetColor(),
579cdf0e10cSrcweir                                         rL1.GetTab(), SUBCOL_TAB ), Count() );
580cdf0e10cSrcweir                             if ( !nTmpFree )
581cdf0e10cSrcweir 							{
582cdf0e10cSrcweir 								--i;
583cdf0e10cSrcweir 								k = aCheck.Count();
584cdf0e10cSrcweir 								break;
585cdf0e10cSrcweir 							}
586cdf0e10cSrcweir 						}
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 						if ( rL1.Bottom() > pLB->Bottom() )
589cdf0e10cSrcweir 							rL1.Top( pLB->Top() );	//i1 nach oben verlaengern
590cdf0e10cSrcweir 						else
591cdf0e10cSrcweir 							bRemove = sal_True;			//abbrechen, i1 entfernen
592cdf0e10cSrcweir 					}
593cdf0e10cSrcweir 				}
594cdf0e10cSrcweir 				else
595cdf0e10cSrcweir 				{
596cdf0e10cSrcweir 					SwLineRect *pLA = 0;
597cdf0e10cSrcweir                     SwLineRect *pLB = 0;
598cdf0e10cSrcweir 					if ( rR1.Left() < rR2.Left() )
599cdf0e10cSrcweir 					{
600cdf0e10cSrcweir 						pLA = &rR1; pLB = &rR2;
601cdf0e10cSrcweir 					}
602cdf0e10cSrcweir 					else if ( rR1.Left() > rR2.Left() )
603cdf0e10cSrcweir 					{
604cdf0e10cSrcweir 						pLA = &rR2; pLB = &rR1;
605cdf0e10cSrcweir 					}
606cdf0e10cSrcweir 					//Liegt eine 'doppellinie' vor?
607cdf0e10cSrcweir 					if ( pLA && pLA->Right() + 60 > pLB->Left() )
608cdf0e10cSrcweir 					{
609cdf0e10cSrcweir 						if ( rL1.Left() < pLA->Left() )
610cdf0e10cSrcweir 						{
611cdf0e10cSrcweir 							if ( rL1.Right() == pLA->Right() )
612cdf0e10cSrcweir 								continue;	//kleiner irrtum
613cdf0e10cSrcweir 
614cdf0e10cSrcweir 							SwRect aIns( rL1 );
615cdf0e10cSrcweir 							aIns.Right( pLA->Right() );
616cdf0e10cSrcweir 							if ( !rL1.IsInside( aIns ) )
617cdf0e10cSrcweir 								continue;
618cdf0e10cSrcweir                             const sal_uInt16 nTmpFree = Free();
619cdf0e10cSrcweir 							Insert( SwLineRect( aIns, rL1.GetColor(),
620cdf0e10cSrcweir                                         rL1.GetTab(), SUBCOL_TAB ), Count() );
621cdf0e10cSrcweir                             if ( !nTmpFree )
622cdf0e10cSrcweir 							{
623cdf0e10cSrcweir 								--i;
624cdf0e10cSrcweir 								k = aCheck.Count();
625cdf0e10cSrcweir 								break;
626cdf0e10cSrcweir 							}
627cdf0e10cSrcweir 						}
628cdf0e10cSrcweir 						if ( rL1.Right() > pLB->Right() )
629cdf0e10cSrcweir 							rL1.Left( pLB->Left() );
630cdf0e10cSrcweir 						else
631cdf0e10cSrcweir 							bRemove = sal_True;
632cdf0e10cSrcweir 					}
633cdf0e10cSrcweir 				}
634cdf0e10cSrcweir 			}
635cdf0e10cSrcweir 		}
636cdf0e10cSrcweir 		if ( bRemove )
637cdf0e10cSrcweir 		{
638cdf0e10cSrcweir 			Remove( static_cast<sal_uInt16>(i), 1 );
639cdf0e10cSrcweir 			--i;			//keinen auslassen!
640cdf0e10cSrcweir 		}
641cdf0e10cSrcweir 	}
642cdf0e10cSrcweir }
643cdf0e10cSrcweir 
Ins(const SwRect & rRect,const sal_uInt8 nSCol)644cdf0e10cSrcweir inline void SwSubsRects::Ins( const SwRect &rRect, const sal_uInt8 nSCol )
645cdf0e10cSrcweir {
646cdf0e10cSrcweir 	//Linien die kuerzer als die breiteste Linienbreite sind werden
647cdf0e10cSrcweir 	//nicht aufgenommen.
648cdf0e10cSrcweir 	if ( rRect.Height() > DEF_LINE_WIDTH_4 || rRect.Width() > DEF_LINE_WIDTH_4 )
649cdf0e10cSrcweir 		Insert( SwLineRect( rRect, 0, 0, nSCol ), Count());
650cdf0e10cSrcweir }
651cdf0e10cSrcweir 
RemoveSuperfluousSubsidiaryLines(const SwLineRects & rRects)652cdf0e10cSrcweir void SwSubsRects::RemoveSuperfluousSubsidiaryLines( const SwLineRects &rRects )
653cdf0e10cSrcweir {
654cdf0e10cSrcweir 	//Alle Hilfslinien, die sich mit irgendwelchen Umrandungen decken werden
655cdf0e10cSrcweir 	//entfernt bzw. zerstueckelt..
656cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < Count(); ++i )
657cdf0e10cSrcweir 	{
658cdf0e10cSrcweir         // OD 18.11.2002 #99672# - get a copy instead of a reference, because
659cdf0e10cSrcweir         // an <insert> may destroy the object due to a necessary array resize.
660cdf0e10cSrcweir         const SwLineRect aSubsLineRect = SwLineRect( operator[](i) );
661cdf0e10cSrcweir 
662cdf0e10cSrcweir         // OD 19.12.2002 #106318# - add condition <aSubsLineRect.IsLocked()>
663cdf0e10cSrcweir         // in order to consider only border lines, which are *not* locked.
664cdf0e10cSrcweir         if ( aSubsLineRect.IsPainted() ||
665cdf0e10cSrcweir              aSubsLineRect.IsLocked() )
666cdf0e10cSrcweir 			continue;
667cdf0e10cSrcweir 
668cdf0e10cSrcweir         const bool bVerticalSubs = aSubsLineRect.Height() > aSubsLineRect.Width();
669cdf0e10cSrcweir         SwRect aSubsRect( aSubsLineRect );
670cdf0e10cSrcweir         if ( bVerticalSubs )
671cdf0e10cSrcweir 		{
672cdf0e10cSrcweir             aSubsRect.Left  ( aSubsRect.Left()  - (nPixelSzW+nHalfPixelSzW) );
673cdf0e10cSrcweir             aSubsRect.Right ( aSubsRect.Right() + (nPixelSzW+nHalfPixelSzW) );
674cdf0e10cSrcweir 		}
675cdf0e10cSrcweir 		else
676cdf0e10cSrcweir 		{
677cdf0e10cSrcweir             aSubsRect.Top   ( aSubsRect.Top()    - (nPixelSzH+nHalfPixelSzH) );
678cdf0e10cSrcweir             aSubsRect.Bottom( aSubsRect.Bottom() + (nPixelSzH+nHalfPixelSzH) );
679cdf0e10cSrcweir 		}
680cdf0e10cSrcweir 		for ( sal_uInt16 k = 0; k < rRects.Count(); ++k )
681cdf0e10cSrcweir 		{
682cdf0e10cSrcweir 			SwLineRect &rLine = rRects[k];
683cdf0e10cSrcweir 
684cdf0e10cSrcweir             // OD 20.12.2002 #106318# - do *not* consider painted or locked
685cdf0e10cSrcweir             // border lines.
686cdf0e10cSrcweir             // OD 20.01.2003 #i1837# - locked border lines have to be considered.
687cdf0e10cSrcweir             if ( rLine.IsLocked () )
688cdf0e10cSrcweir                 continue;
689cdf0e10cSrcweir 
690cdf0e10cSrcweir             if ( (!bVerticalSubs == (rLine.Height() > rLine.Width())) ) //gleiche Ausrichtung?
691cdf0e10cSrcweir 				continue;
692cdf0e10cSrcweir 
693cdf0e10cSrcweir             if ( aSubsRect.IsOver( rLine ) )
694cdf0e10cSrcweir 			{
695cdf0e10cSrcweir                 if ( bVerticalSubs ) //Vertikal?
696cdf0e10cSrcweir 				{
697cdf0e10cSrcweir                     if ( aSubsRect.Left()  <= rLine.Right() &&
698cdf0e10cSrcweir                          aSubsRect.Right() >= rLine.Left() )
699cdf0e10cSrcweir 					{
700cdf0e10cSrcweir 						long nTmp = rLine.Top()-(nPixelSzH+1);
701cdf0e10cSrcweir                         if ( aSubsLineRect.Top() < nTmp )
702cdf0e10cSrcweir 						{
703cdf0e10cSrcweir                             SwRect aNewSubsRect( aSubsLineRect );
704cdf0e10cSrcweir                             aNewSubsRect.Bottom( nTmp );
705cdf0e10cSrcweir                             Insert( SwLineRect( aNewSubsRect, 0, 0,
706cdf0e10cSrcweir                                                 aSubsLineRect.GetSubColor() ), Count());
707cdf0e10cSrcweir 						}
708cdf0e10cSrcweir 						nTmp = rLine.Bottom()+nPixelSzH+1;
709cdf0e10cSrcweir                         if ( aSubsLineRect.Bottom() > nTmp )
710cdf0e10cSrcweir 						{
711cdf0e10cSrcweir                             SwRect aNewSubsRect( aSubsLineRect );
712cdf0e10cSrcweir                             aNewSubsRect.Top( nTmp );
713cdf0e10cSrcweir                             Insert( SwLineRect( aNewSubsRect, 0, 0,
714cdf0e10cSrcweir                                                 aSubsLineRect.GetSubColor() ), Count());
715cdf0e10cSrcweir 						}
716cdf0e10cSrcweir 						Remove( i, 1 );
717cdf0e10cSrcweir 						--i;
718cdf0e10cSrcweir 						break;
719cdf0e10cSrcweir 					}
720cdf0e10cSrcweir 				}
721cdf0e10cSrcweir 				else									//Horizontal
722cdf0e10cSrcweir 				{
723cdf0e10cSrcweir                     if ( aSubsRect.Top() <= rLine.Bottom() &&
724cdf0e10cSrcweir                          aSubsRect.Bottom() >= rLine.Top() )
725cdf0e10cSrcweir 					{
726cdf0e10cSrcweir 						long nTmp = rLine.Left()-(nPixelSzW+1);
727cdf0e10cSrcweir                         if ( aSubsLineRect.Left() < nTmp )
728cdf0e10cSrcweir 						{
729cdf0e10cSrcweir                             SwRect aNewSubsRect( aSubsLineRect );
730cdf0e10cSrcweir                             aNewSubsRect.Right( nTmp );
731cdf0e10cSrcweir                             Insert( SwLineRect( aNewSubsRect, 0, 0,
732cdf0e10cSrcweir                                                 aSubsLineRect.GetSubColor() ), Count());
733cdf0e10cSrcweir 						}
734cdf0e10cSrcweir 						nTmp = rLine.Right()+nPixelSzW+1;
735cdf0e10cSrcweir                         if ( aSubsLineRect.Right() > nTmp )
736cdf0e10cSrcweir 						{
737cdf0e10cSrcweir                             SwRect aNewSubsRect( aSubsLineRect );
738cdf0e10cSrcweir                             aNewSubsRect.Left( nTmp );
739cdf0e10cSrcweir                             Insert( SwLineRect( aNewSubsRect, 0, 0,
740cdf0e10cSrcweir                                                 aSubsLineRect.GetSubColor() ), Count());
741cdf0e10cSrcweir 						}
742cdf0e10cSrcweir 						Remove( i, 1 );
743cdf0e10cSrcweir 						--i;
744cdf0e10cSrcweir 						break;
745cdf0e10cSrcweir 					}
746cdf0e10cSrcweir 				}
747cdf0e10cSrcweir 			}
748cdf0e10cSrcweir 		}
749cdf0e10cSrcweir 	}
750cdf0e10cSrcweir }
751cdf0e10cSrcweir 
LockLines(sal_Bool bLock)752cdf0e10cSrcweir void SwLineRects::LockLines( sal_Bool bLock )
753cdf0e10cSrcweir {
754cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < Count(); ++i )
755cdf0e10cSrcweir 		operator[](i).Lock( bLock );
756cdf0e10cSrcweir }
757cdf0e10cSrcweir 
PaintLines(OutputDevice * pOut)758cdf0e10cSrcweir void SwLineRects::PaintLines( OutputDevice *pOut )
759cdf0e10cSrcweir {
760cdf0e10cSrcweir 	//Painten der Umrandungen. Leider muessen wir zweimal durch.
761cdf0e10cSrcweir 	//Einmal fuer die innenliegenden und einmal fuer die Aussenkanten
762cdf0e10cSrcweir 	//der Tabellen.
763cdf0e10cSrcweir 	if ( Count() != nLastCount )
764cdf0e10cSrcweir 	{
765cdf0e10cSrcweir         // --> FME 2004-06-24 #i16816# tagged pdf support
766cdf0e10cSrcweir         SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pOut );
767cdf0e10cSrcweir         // <--
768cdf0e10cSrcweir 
769cdf0e10cSrcweir         // OD 2004-04-23 #116347#
770cdf0e10cSrcweir         pOut->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
771cdf0e10cSrcweir         pOut->SetLineColor();
772cdf0e10cSrcweir 		ConnectEdges( pOut );
773cdf0e10cSrcweir 		const Color *pLast = 0;
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 		sal_Bool bPaint2nd = sal_False;
776cdf0e10cSrcweir 		sal_uInt16 nMinCount = Count();
777cdf0e10cSrcweir 		sal_uInt16 i;
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 		for ( i = 0; i < Count(); ++i )
780cdf0e10cSrcweir 		{
781cdf0e10cSrcweir 			SwLineRect &rLRect = operator[](i);
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 			if ( rLRect.IsPainted() )
784cdf0e10cSrcweir 				continue;
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 			if ( rLRect.IsLocked() )
787cdf0e10cSrcweir 			{
788cdf0e10cSrcweir 				nMinCount = Min( nMinCount, i );
789cdf0e10cSrcweir 				continue;
790cdf0e10cSrcweir 			}
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 			//Jetzt malen oder erst in der zweiten Runde?
793cdf0e10cSrcweir 			sal_Bool bPaint = sal_True;
794cdf0e10cSrcweir 			if ( rLRect.GetTab() )
795cdf0e10cSrcweir 			{
796cdf0e10cSrcweir 				if ( rLRect.Height() > rLRect.Width() )
797cdf0e10cSrcweir 				{
798cdf0e10cSrcweir 					//Senkrechte Kante, ueberlappt sie mit der TabellenKante?
799cdf0e10cSrcweir 					SwTwips nLLeft	= rLRect.Left()  - 30,
800cdf0e10cSrcweir 							nLRight = rLRect.Right() + 30,
801cdf0e10cSrcweir 							nTLeft	= rLRect.GetTab()->Frm().Left() + rLRect.GetTab()->Prt().Left(),
802cdf0e10cSrcweir 							nTRight = rLRect.GetTab()->Frm().Left() + rLRect.GetTab()->Prt().Right();
803cdf0e10cSrcweir 					if ( (nTLeft >= nLLeft && nTLeft <= nLRight) ||
804cdf0e10cSrcweir 						 (nTRight>= nLLeft && nTRight<= nLRight) )
805cdf0e10cSrcweir 						bPaint = sal_False;
806cdf0e10cSrcweir 				}
807cdf0e10cSrcweir 				else
808cdf0e10cSrcweir 				{	//Waagerechte Kante, ueberlappt sie mit der Tabellenkante?
809cdf0e10cSrcweir 					SwTwips nLTop	 = rLRect.Top()    - 30,
810cdf0e10cSrcweir 							nLBottom = rLRect.Bottom() + 30,
811cdf0e10cSrcweir 							nTTop	 = rLRect.GetTab()->Frm().Top()  + rLRect.GetTab()->Prt().Top(),
812cdf0e10cSrcweir 							nTBottom = rLRect.GetTab()->Frm().Top()  + rLRect.GetTab()->Prt().Bottom();
813cdf0e10cSrcweir 					if ( (nTTop    >= nLTop && nTTop	  <= nLBottom) ||
814cdf0e10cSrcweir 						 (nTBottom >= nLTop && nTBottom <= nLBottom) )
815cdf0e10cSrcweir 						bPaint = sal_False;
816cdf0e10cSrcweir 				}
817cdf0e10cSrcweir 			}
818cdf0e10cSrcweir 			if ( bPaint )
819cdf0e10cSrcweir 			{
820cdf0e10cSrcweir                 if ( !pLast || *pLast != *rLRect.GetColor() )
821cdf0e10cSrcweir 				{
822cdf0e10cSrcweir 					pLast = rLRect.GetColor();
823cdf0e10cSrcweir 
824cdf0e10cSrcweir                     sal_uLong nOldDrawMode = pOut->GetDrawMode();
825cdf0e10cSrcweir                     if( pGlobalShell->GetWin() &&
826cdf0e10cSrcweir                         Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
827cdf0e10cSrcweir                         pOut->SetDrawMode( 0 );
828cdf0e10cSrcweir 
829cdf0e10cSrcweir 					pOut->SetFillColor( *pLast );
830cdf0e10cSrcweir                     pOut->SetDrawMode( nOldDrawMode );
831cdf0e10cSrcweir 				}
832cdf0e10cSrcweir                 if( !rLRect.IsEmpty() )
833cdf0e10cSrcweir                     pOut->DrawRect( rLRect.SVRect() );
834cdf0e10cSrcweir 				rLRect.SetPainted();
835cdf0e10cSrcweir 			}
836cdf0e10cSrcweir 			else
837cdf0e10cSrcweir 				bPaint2nd = sal_True;
838cdf0e10cSrcweir 		}
839cdf0e10cSrcweir 		if ( bPaint2nd )
840cdf0e10cSrcweir 			for ( i = 0; i < Count(); ++i )
841cdf0e10cSrcweir 			{
842cdf0e10cSrcweir 				SwLineRect &rLRect = operator[](i);
843cdf0e10cSrcweir 				if ( rLRect.IsPainted() )
844cdf0e10cSrcweir 					continue;
845cdf0e10cSrcweir 
846cdf0e10cSrcweir 				if ( rLRect.IsLocked() )
847cdf0e10cSrcweir 				{
848cdf0e10cSrcweir 					nMinCount = Min( nMinCount, i );
849cdf0e10cSrcweir 					continue;
850cdf0e10cSrcweir 				}
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 				if ( !pLast || *pLast != *rLRect.GetColor() )
853cdf0e10cSrcweir 				{
854cdf0e10cSrcweir 					pLast = rLRect.GetColor();
855cdf0e10cSrcweir 
856cdf0e10cSrcweir                     sal_uLong nOldDrawMode = pOut->GetDrawMode();
857cdf0e10cSrcweir                     if( pGlobalShell->GetWin() &&
858cdf0e10cSrcweir                         Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
859cdf0e10cSrcweir                     {
860cdf0e10cSrcweir                         pOut->SetDrawMode( 0 );
861cdf0e10cSrcweir                     }
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 					pOut->SetFillColor( *pLast );
864cdf0e10cSrcweir                     pOut->SetDrawMode( nOldDrawMode );
865cdf0e10cSrcweir 				}
866cdf0e10cSrcweir                 if( !rLRect.IsEmpty() )
867cdf0e10cSrcweir                     pOut->DrawRect( rLRect.SVRect() );
868cdf0e10cSrcweir 				rLRect.SetPainted();
869cdf0e10cSrcweir 			}
870cdf0e10cSrcweir 		nLastCount = nMinCount;
871cdf0e10cSrcweir 		pOut->Pop();
872cdf0e10cSrcweir 	}
873cdf0e10cSrcweir }
874cdf0e10cSrcweir 
PaintSubsidiary(OutputDevice * pOut,const SwLineRects * pRects)875cdf0e10cSrcweir void SwSubsRects::PaintSubsidiary( OutputDevice *pOut,
876cdf0e10cSrcweir 								   const SwLineRects *pRects )
877cdf0e10cSrcweir {
878cdf0e10cSrcweir 	if ( Count() )
879cdf0e10cSrcweir 	{
880cdf0e10cSrcweir         // --> FME 2004-06-24 #i16816# tagged pdf support
881cdf0e10cSrcweir         SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pOut );
882cdf0e10cSrcweir         // <--
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 		//Alle Hilfslinien, die sich fast decken entfernen (Tabellen)
885cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < Count(); ++i )
886cdf0e10cSrcweir 		{
887cdf0e10cSrcweir 			SwLineRect &rLi = operator[](i);
888cdf0e10cSrcweir             const bool bVerticalSubs = rLi.Height() > rLi.Width();
889cdf0e10cSrcweir 
890cdf0e10cSrcweir 			for ( sal_uInt16 k = i+1; k < Count(); ++k )
891cdf0e10cSrcweir 			{
892cdf0e10cSrcweir 				SwLineRect &rLk = operator[](k);
893cdf0e10cSrcweir 				if ( rLi.SSize() == rLk.SSize() )
894cdf0e10cSrcweir 				{
895cdf0e10cSrcweir                     if ( (bVerticalSubs == (rLk.Height() > rLk.Width())) )
896cdf0e10cSrcweir 					{
897cdf0e10cSrcweir                         if ( bVerticalSubs )
898cdf0e10cSrcweir 						{
899cdf0e10cSrcweir 							long nLi = rLi.Right();
900cdf0e10cSrcweir 							long nLk = rLk.Right();
901cdf0e10cSrcweir 							if ( rLi.Top() == rLk.Top() &&
902cdf0e10cSrcweir 								 ((nLi < rLk.Left() && nLi+21 > rLk.Left()) ||
903cdf0e10cSrcweir 								  (nLk < rLi.Left() && nLk+21 > rLi.Left())))
904cdf0e10cSrcweir 							{
905cdf0e10cSrcweir 								Remove( k, 1 );
906cdf0e10cSrcweir 								//Nicht mit der inneren Schleife weiter, weil
907cdf0e10cSrcweir 								//das Array schrumpfen koennte!
908cdf0e10cSrcweir 								--i; k = Count();
909cdf0e10cSrcweir 							}
910cdf0e10cSrcweir 						}
911cdf0e10cSrcweir 						else
912cdf0e10cSrcweir 						{
913cdf0e10cSrcweir 							long nLi = rLi.Bottom();
914cdf0e10cSrcweir 							long nLk = rLk.Bottom();
915cdf0e10cSrcweir 							if ( rLi.Left() == rLk.Left() &&
916cdf0e10cSrcweir 								 ((nLi < rLk.Top() && nLi+21 > rLk.Top()) ||
917cdf0e10cSrcweir 								  (nLk < rLi.Top() && nLk+21 > rLi.Top())))
918cdf0e10cSrcweir 							{
919cdf0e10cSrcweir 								Remove( k, 1 );
920cdf0e10cSrcweir 								--i; k = Count();
921cdf0e10cSrcweir 							}
922cdf0e10cSrcweir 						}
923cdf0e10cSrcweir 					}
924cdf0e10cSrcweir 				}
925cdf0e10cSrcweir 			}
926cdf0e10cSrcweir 		}
927cdf0e10cSrcweir 
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 		if ( pRects && pRects->Count() )
930cdf0e10cSrcweir 			RemoveSuperfluousSubsidiaryLines( *pRects );
931cdf0e10cSrcweir 
932cdf0e10cSrcweir 		if ( Count() )
933cdf0e10cSrcweir 		{
934cdf0e10cSrcweir             // OD 2004-04-23 #116347#
935cdf0e10cSrcweir             pOut->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
936cdf0e10cSrcweir             pOut->SetLineColor();
937cdf0e10cSrcweir 
938cdf0e10cSrcweir             // OD 14.01.2003 #106660# - reset draw mode in high contrast
939cdf0e10cSrcweir             // mode in order to get fill color set at output device.
940cdf0e10cSrcweir             // Recover draw mode after draw of lines.
941cdf0e10cSrcweir             // Necessary for the subsidiary lines painted by the fly frames.
942cdf0e10cSrcweir             sal_uLong nOldDrawMode = pOut->GetDrawMode();
943cdf0e10cSrcweir             if( pGlobalShell->GetWin() &&
944cdf0e10cSrcweir                 Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
945cdf0e10cSrcweir             {
946cdf0e10cSrcweir                 pOut->SetDrawMode( 0 );
947cdf0e10cSrcweir             }
948cdf0e10cSrcweir 
949cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < Count(); ++i )
950cdf0e10cSrcweir 			{
951cdf0e10cSrcweir 				SwLineRect &rLRect = operator[](i);
952cdf0e10cSrcweir                 // OD 19.12.2002 #106318# - add condition <!rLRect.IsLocked()>
953cdf0e10cSrcweir                 // to prevent paint of locked subsidiary lines.
954cdf0e10cSrcweir                 if ( !rLRect.IsPainted() &&
955cdf0e10cSrcweir                      !rLRect.IsLocked() )
956cdf0e10cSrcweir 				{
957cdf0e10cSrcweir                     const Color *pCol = 0;
958cdf0e10cSrcweir 					switch ( rLRect.GetSubColor() )
959cdf0e10cSrcweir 					{
960cdf0e10cSrcweir                         case SUBCOL_PAGE: pCol = &SwViewOption::GetDocBoundariesColor(); break;
961cdf0e10cSrcweir                         case SUBCOL_FLY: pCol = &SwViewOption::GetObjectBoundariesColor(); break;
962cdf0e10cSrcweir                         case SUBCOL_TAB: pCol = &SwViewOption::GetTableBoundariesColor(); break;
963cdf0e10cSrcweir                         case SUBCOL_SECT: pCol = &SwViewOption::GetSectionBoundColor(); break;
964cdf0e10cSrcweir                         case SUBCOL_BREAK:    pCol = &SwViewOption::GetPageBreakColor(); break;
965cdf0e10cSrcweir 					}
966cdf0e10cSrcweir 
967cdf0e10cSrcweir                     if ( pOut->GetFillColor() != *pCol )
968cdf0e10cSrcweir                         pOut->SetFillColor( *pCol );
969cdf0e10cSrcweir                     pOut->DrawRect( rLRect.SVRect() );
970cdf0e10cSrcweir 
971cdf0e10cSrcweir                     rLRect.SetPainted();
972cdf0e10cSrcweir 				}
973cdf0e10cSrcweir 			}
974cdf0e10cSrcweir 
975cdf0e10cSrcweir             // OD 14.01.2003 #106660# - recovering draw mode
976cdf0e10cSrcweir             pOut->SetDrawMode( nOldDrawMode );
977cdf0e10cSrcweir 
978cdf0e10cSrcweir             pOut->Pop();
979cdf0e10cSrcweir 		}
980cdf0e10cSrcweir 	}
981cdf0e10cSrcweir }
982cdf0e10cSrcweir 
983cdf0e10cSrcweir //-------------------------------------------------------------------------
984cdf0e10cSrcweir //Diverse Functions die in diesem File so verwendet werden.
985cdf0e10cSrcweir 
986cdf0e10cSrcweir // OD 20.02.2003 - Note: function <SwAlignRect(..)> also used outside this file.
987cdf0e10cSrcweir // OD 29.04.2003 #107169# - correction: adjust rectangle on pixel level in order
988cdf0e10cSrcweir //          to assure, that the border 'leaves its original pixel', if it has to.
989cdf0e10cSrcweir //          No prior adjustments for odd relation between pixel and twip.
SwAlignRect(SwRect & rRect,ViewShell * pSh)990cdf0e10cSrcweir void MA_FASTCALL SwAlignRect( SwRect &rRect, ViewShell *pSh )
991cdf0e10cSrcweir {
992cdf0e10cSrcweir     if( !rRect.HasArea() )
993cdf0e10cSrcweir         return;
994cdf0e10cSrcweir 
995cdf0e10cSrcweir     // OD 03.09.2002 #102450#
996cdf0e10cSrcweir     // Assure that view shell (parameter <pSh>) exists, if the output device
997cdf0e10cSrcweir     // is taken from this view shell --> no output device, no alignment.
998cdf0e10cSrcweir     // Output device taken from view shell <pSh>, if <bFlyMetafile> not set.
999cdf0e10cSrcweir     if ( !bFlyMetafile && !pSh )
1000cdf0e10cSrcweir     {
1001cdf0e10cSrcweir         return;
1002cdf0e10cSrcweir     }
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir     const OutputDevice *pOut = bFlyMetafile ?
1005cdf0e10cSrcweir 						pFlyMetafileOut : pSh->GetOut();
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir     // OD 28.04.2003 #107169# - hold original rectangle in pixel
1008cdf0e10cSrcweir     const Rectangle aOrgPxRect = pOut->LogicToPixel( rRect.SVRect() );
1009cdf0e10cSrcweir     // OD 29.04.2003 #107169# - determine pixel-center rectangle in twip
1010cdf0e10cSrcweir     const SwRect aPxCenterRect( pOut->PixelToLogic( aOrgPxRect ) );
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir     // OD 06.05.2003 #107169# - perform adjustments on pixel level.
1013cdf0e10cSrcweir     SwRect aAlignedPxRect( aOrgPxRect );
1014cdf0e10cSrcweir     if ( rRect.Top() > aPxCenterRect.Top() )
1015cdf0e10cSrcweir     {
1016cdf0e10cSrcweir         // 'leave pixel overlapping on top'
1017cdf0e10cSrcweir         aAlignedPxRect.Top( aAlignedPxRect.Top() + 1 );
1018cdf0e10cSrcweir     }
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir     if ( rRect.Bottom() < aPxCenterRect.Bottom() )
1021cdf0e10cSrcweir     {
1022cdf0e10cSrcweir         // 'leave pixel overlapping on bottom'
1023cdf0e10cSrcweir         aAlignedPxRect.Bottom( aAlignedPxRect.Bottom() - 1 );
1024cdf0e10cSrcweir     }
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir     if ( rRect.Left() > aPxCenterRect.Left() )
1027cdf0e10cSrcweir     {
1028cdf0e10cSrcweir         // 'leave pixel overlapping on left'
1029cdf0e10cSrcweir         aAlignedPxRect.Left( aAlignedPxRect.Left() + 1 );
1030cdf0e10cSrcweir     }
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir     if ( rRect.Right() < aPxCenterRect.Right() )
1033cdf0e10cSrcweir     {
1034cdf0e10cSrcweir         // 'leave pixel overlapping on right'
1035cdf0e10cSrcweir         aAlignedPxRect.Right( aAlignedPxRect.Right() - 1 );
1036cdf0e10cSrcweir     }
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir     // OD 11.10.2002 #103636# - consider negative width/height
1039cdf0e10cSrcweir     // check, if aligned SwRect has negative width/height.
1040cdf0e10cSrcweir     // If Yes, adjust it to width/height = 0 twip.
1041cdf0e10cSrcweir     // NOTE: A SwRect with negative width/height can occur, if the width/height
1042cdf0e10cSrcweir     //     of the given SwRect in twip was less than a pixel in twip and that
1043cdf0e10cSrcweir     //     the alignment calculates that the aligned SwRect should not contain
1044cdf0e10cSrcweir     //     the pixels the width/height is on.
1045cdf0e10cSrcweir     if ( aAlignedPxRect.Width() < 0 )
1046cdf0e10cSrcweir     {
1047cdf0e10cSrcweir         aAlignedPxRect.Width(0);
1048cdf0e10cSrcweir     }
1049cdf0e10cSrcweir     if ( aAlignedPxRect.Height() < 0 )
1050cdf0e10cSrcweir     {
1051cdf0e10cSrcweir         aAlignedPxRect.Height(0);
1052cdf0e10cSrcweir     }
1053cdf0e10cSrcweir     // OD 30.04.2003 #107169# - consider zero width/height
1054cdf0e10cSrcweir     // For converting a rectangle from pixel to logic it needs a width/height.
1055cdf0e10cSrcweir     // Thus, set width/height to one, if it's zero and correct this on the twip
1056cdf0e10cSrcweir     // level after the conversion.
1057cdf0e10cSrcweir     sal_Bool bZeroWidth = sal_False;
1058cdf0e10cSrcweir     if ( aAlignedPxRect.Width() == 0 )
1059cdf0e10cSrcweir     {
1060cdf0e10cSrcweir         aAlignedPxRect.Width(1);
1061cdf0e10cSrcweir         bZeroWidth = sal_True;
1062cdf0e10cSrcweir     }
1063cdf0e10cSrcweir     sal_Bool bZeroHeight = sal_False;
1064cdf0e10cSrcweir     if ( aAlignedPxRect.Height() == 0 )
1065cdf0e10cSrcweir     {
1066cdf0e10cSrcweir         aAlignedPxRect.Height(1);
1067cdf0e10cSrcweir         bZeroHeight = sal_True;
1068cdf0e10cSrcweir     }
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir     rRect = pOut->PixelToLogic( aAlignedPxRect.SVRect() );
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir     // OD 30.04.2003 #107169# - consider zero width/height and adjust calculated
1073cdf0e10cSrcweir     // aligned twip rectangle.
1074cdf0e10cSrcweir     // OD 19.05.2003 #109667# - reset width/height to zero; previous negative
1075cdf0e10cSrcweir     // width/height haven't to be considered.
1076cdf0e10cSrcweir     if ( bZeroWidth )
1077cdf0e10cSrcweir     {
1078cdf0e10cSrcweir         rRect.Width(0);
1079cdf0e10cSrcweir     }
1080cdf0e10cSrcweir     if ( bZeroHeight )
1081cdf0e10cSrcweir     {
1082cdf0e10cSrcweir         rRect.Height(0);
1083cdf0e10cSrcweir     }
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir /** OD 19.05.2003 #109667# - helper method for twip adjustments on pixel base
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir     method compares the x- or y-pixel position of two twip-point. If the x-/y-pixel
1089cdf0e10cSrcweir     positions are the same, the x-/y-pixel position of the second twip point is
1090cdf0e10cSrcweir     adjusted by a given amount of pixels.
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir     @author OD
1093cdf0e10cSrcweir */
lcl_CompPxPosAndAdjustPos(const OutputDevice & _rOut,const Point & _rRefPt,Point & _rCompPt,const sal_Bool _bChkXPos,const sal_Int8 _nPxAdjustment)1094cdf0e10cSrcweir void lcl_CompPxPosAndAdjustPos( const OutputDevice&  _rOut,
1095cdf0e10cSrcweir                                 const Point&         _rRefPt,
1096cdf0e10cSrcweir                                 Point&               _rCompPt,
1097cdf0e10cSrcweir                                 const sal_Bool       _bChkXPos,
1098cdf0e10cSrcweir                                 const sal_Int8       _nPxAdjustment )
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir     const Point aRefPxPt = _rOut.LogicToPixel( _rRefPt );
1101cdf0e10cSrcweir     Point aCompPxPt = _rOut.LogicToPixel( _rCompPt );
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir     if ( _bChkXPos )
1104cdf0e10cSrcweir     {
1105cdf0e10cSrcweir         if ( aCompPxPt.X() == aRefPxPt.X() )
1106cdf0e10cSrcweir         {
1107cdf0e10cSrcweir             aCompPxPt.X() += _nPxAdjustment ;
1108cdf0e10cSrcweir             const Point aAdjustedCompPt = _rOut.PixelToLogic( aCompPxPt );
1109cdf0e10cSrcweir             _rCompPt.X() = aAdjustedCompPt.X();
1110cdf0e10cSrcweir         }
1111cdf0e10cSrcweir     }
1112cdf0e10cSrcweir     else
1113cdf0e10cSrcweir     {
1114cdf0e10cSrcweir         if ( aCompPxPt.Y() == aRefPxPt.Y() )
1115cdf0e10cSrcweir         {
1116cdf0e10cSrcweir             aCompPxPt.Y() += _nPxAdjustment ;
1117cdf0e10cSrcweir             const Point aAdjustedCompPt = _rOut.PixelToLogic( aCompPxPt );
1118cdf0e10cSrcweir             _rCompPt.Y() = aAdjustedCompPt.Y();
1119cdf0e10cSrcweir         }
1120cdf0e10cSrcweir     }
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir /** OD 25.09.2002 #99739# - method to pixel-align rectangle for drawing graphic object
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir     Because for drawing a graphic left-top-corner and size coordinations are
1126cdf0e10cSrcweir     used, these coordinations have to be determined on pixel level.
1127cdf0e10cSrcweir     Thus, convert rectangle to pixel and then convert left-top-corner and
1128cdf0e10cSrcweir     size of pixel rectangle back to logic.
1129cdf0e10cSrcweir     This calculation is necessary, because there exists a different between
1130cdf0e10cSrcweir     the convert from logic to pixel of a normal rectangle with its left-top-
1131cdf0e10cSrcweir     and right-bottom-corner and the same convert of the same rectangle
1132cdf0e10cSrcweir     with left-top-corner and size.
1133cdf0e10cSrcweir     Call this method before each <GraphicObject.Draw(...)>
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir     @author OD
1136cdf0e10cSrcweir */
SwAlignGrfRect(SwRect * pGrfRect,const OutputDevice & rOut)1137cdf0e10cSrcweir void SwAlignGrfRect( SwRect *pGrfRect, const OutputDevice &rOut )
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir     Rectangle aPxRect = rOut.LogicToPixel( pGrfRect->SVRect() );
1140cdf0e10cSrcweir     pGrfRect->Pos( rOut.PixelToLogic( aPxRect.TopLeft() ) );
1141cdf0e10cSrcweir     pGrfRect->SSize( rOut.PixelToLogic( aPxRect.GetSize() ) );
1142cdf0e10cSrcweir }
1143cdf0e10cSrcweir 
lcl_AlignWidth(const long nWidth)1144cdf0e10cSrcweir long MA_FASTCALL lcl_AlignWidth( const long nWidth )
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir     if ( nWidth )
1147cdf0e10cSrcweir 	{
1148cdf0e10cSrcweir 		const long nW = nWidth % nPixelSzW;
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir 		if ( !nW || nW > nHalfPixelSzW )
1151cdf0e10cSrcweir 			return Max(1L, nWidth - nHalfPixelSzW);
1152cdf0e10cSrcweir 	}
1153cdf0e10cSrcweir 	return nWidth;
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir 
lcl_AlignHeight(const long nHeight)1156cdf0e10cSrcweir long MA_FASTCALL lcl_AlignHeight( const long nHeight )
1157cdf0e10cSrcweir {
1158cdf0e10cSrcweir 	if ( nHeight )
1159cdf0e10cSrcweir 	{
1160cdf0e10cSrcweir 		const long nH = nHeight % nPixelSzH;
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir 		if ( !nH || nH > nHalfPixelSzH )
1163cdf0e10cSrcweir 			return Max(1L, nHeight - nHalfPixelSzH);
1164cdf0e10cSrcweir 	}
1165cdf0e10cSrcweir 	return nHeight;
1166cdf0e10cSrcweir }
1167cdf0e10cSrcweir 
lcl_MinHeightDist(const long nDist)1168cdf0e10cSrcweir long MA_FASTCALL lcl_MinHeightDist( const long nDist )
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir 	if ( aScaleX < aMinDistScale || aScaleY < aMinDistScale )
1171cdf0e10cSrcweir 		return nDist;
1172cdf0e10cSrcweir 	return ::lcl_AlignHeight( Max( nDist, nMinDistPixelH ));
1173cdf0e10cSrcweir }
1174cdf0e10cSrcweir 
lcl_MinWidthDist(const long nDist)1175cdf0e10cSrcweir long MA_FASTCALL lcl_MinWidthDist( const long nDist )
1176cdf0e10cSrcweir {
1177cdf0e10cSrcweir 	if ( aScaleX < aMinDistScale || aScaleY < aMinDistScale )
1178cdf0e10cSrcweir 		return nDist;
1179cdf0e10cSrcweir 	return ::lcl_AlignWidth( Max( nDist, nMinDistPixelW ));
1180cdf0e10cSrcweir }
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir //Ermittelt PrtArea plus Umrandung plus Schatten.
lcl_CalcBorderRect(SwRect & rRect,const SwFrm * pFrm,const SwBorderAttrs & rAttrs,const sal_Bool bShadow)1184cdf0e10cSrcweir void MA_FASTCALL lcl_CalcBorderRect( SwRect &rRect, const SwFrm *pFrm,
1185cdf0e10cSrcweir 										const SwBorderAttrs &rAttrs,
1186cdf0e10cSrcweir                                         const sal_Bool bShadow )
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir     // OD 23.01.2003 #106386# - special handling for cell frames.
1189cdf0e10cSrcweir     // The printing area of a cell frame is completely enclosed in the frame area
1190cdf0e10cSrcweir     // and a cell frame has no shadow. Thus, for cell frames the calculated
1191cdf0e10cSrcweir     // area equals the frame area.
1192cdf0e10cSrcweir     // Notes: Borders of cell frames in R2L text direction will switch its side
1193cdf0e10cSrcweir     //        - left border is painted on the right; right border on the left.
1194cdf0e10cSrcweir     //        See <lcl_PaintLeftLine> and <lcl_PaintRightLine>.
1195cdf0e10cSrcweir     if( pFrm->IsSctFrm() )
1196cdf0e10cSrcweir     {
1197cdf0e10cSrcweir 		rRect = pFrm->Prt();
1198cdf0e10cSrcweir 		rRect.Pos() += pFrm->Frm().Pos();
1199cdf0e10cSrcweir     }
1200cdf0e10cSrcweir     else if ( pFrm->IsCellFrm() )
1201cdf0e10cSrcweir 		rRect = pFrm->Frm();
1202cdf0e10cSrcweir 	else
1203cdf0e10cSrcweir 	{
1204cdf0e10cSrcweir 		rRect = pFrm->Prt();
1205cdf0e10cSrcweir 		rRect.Pos() += pFrm->Frm().Pos();
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir 		if ( rAttrs.IsLine() || rAttrs.IsBorderDist() ||
1208cdf0e10cSrcweir 		 	(bShadow && rAttrs.GetShadow().GetLocation() != SVX_SHADOW_NONE) )
1209cdf0e10cSrcweir 		{
1210cdf0e10cSrcweir             //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
1211cdf0e10cSrcweir             SwRectFn fnRect = pFrm->IsVertical() ? ( pFrm->IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir 			const SvxBoxItem &rBox = rAttrs.GetBox();
1214cdf0e10cSrcweir             const sal_Bool bTop = 0 != (pFrm->*fnRect->fnGetTopMargin)();
1215cdf0e10cSrcweir 			if ( bTop )
1216cdf0e10cSrcweir 			{
1217cdf0e10cSrcweir                 SwTwips nDiff = rBox.GetTop() ?
1218cdf0e10cSrcweir                     rBox.CalcLineSpace( BOX_LINE_TOP ) :
1219cdf0e10cSrcweir                     ( rAttrs.IsBorderDist() ?
1220cdf0e10cSrcweir                       // OD 23.01.2003 #106386# - increase of distance by
1221cdf0e10cSrcweir                       // one twip is incorrect.
1222cdf0e10cSrcweir                       rBox.GetDistance( BOX_LINE_TOP ) : 0 );
1223cdf0e10cSrcweir                 if( nDiff )
1224cdf0e10cSrcweir                     (rRect.*fnRect->fnSubTop)( nDiff );
1225cdf0e10cSrcweir 			}
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir             const sal_Bool bBottom = 0 != (pFrm->*fnRect->fnGetBottomMargin)();
1228cdf0e10cSrcweir 			if ( bBottom )
1229cdf0e10cSrcweir 			{
1230cdf0e10cSrcweir                 SwTwips nDiff = 0;
1231cdf0e10cSrcweir                 // --> collapsing borders FME 2005-05-27 #i29550#
1232cdf0e10cSrcweir                 if ( pFrm->IsTabFrm() &&
1233cdf0e10cSrcweir                      ((SwTabFrm*)pFrm)->IsCollapsingBorders() )
1234cdf0e10cSrcweir                 {
1235cdf0e10cSrcweir                     // For collapsing borders, we have to add the height of
1236cdf0e10cSrcweir                     // the height of the last line
1237cdf0e10cSrcweir                     nDiff = ((SwTabFrm*)pFrm)->GetBottomLineSize();
1238cdf0e10cSrcweir                 }
1239cdf0e10cSrcweir                 // <-- collapsing
1240cdf0e10cSrcweir                 else
1241cdf0e10cSrcweir                 {
1242cdf0e10cSrcweir                     nDiff = rBox.GetBottom() ?
1243cdf0e10cSrcweir                     rBox.CalcLineSpace( BOX_LINE_BOTTOM ) :
1244cdf0e10cSrcweir                     ( rAttrs.IsBorderDist() ?
1245cdf0e10cSrcweir                       // OD 23.01.2003 #106386# - increase of distance by
1246cdf0e10cSrcweir                       // one twip is incorrect.
1247cdf0e10cSrcweir                       rBox.GetDistance( BOX_LINE_BOTTOM ) : 0 );
1248cdf0e10cSrcweir                 }
1249cdf0e10cSrcweir                 if( nDiff )
1250cdf0e10cSrcweir                     (rRect.*fnRect->fnAddBottom)( nDiff );
1251cdf0e10cSrcweir 			}
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir             if ( rBox.GetLeft() )
1254cdf0e10cSrcweir                 (rRect.*fnRect->fnSubLeft)( rBox.CalcLineSpace( BOX_LINE_LEFT ) );
1255cdf0e10cSrcweir 			else if ( rAttrs.IsBorderDist() )
1256cdf0e10cSrcweir                  // OD 23.01.2003 #106386# - increase of distance by one twip is incorrect.
1257cdf0e10cSrcweir                 (rRect.*fnRect->fnSubLeft)( rBox.GetDistance( BOX_LINE_LEFT ) );
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir 			if ( rBox.GetRight() )
1260cdf0e10cSrcweir                 (rRect.*fnRect->fnAddRight)( rBox.CalcLineSpace( BOX_LINE_RIGHT ) );
1261cdf0e10cSrcweir 			else if ( rAttrs.IsBorderDist() )
1262cdf0e10cSrcweir                  // OD 23.01.2003 #106386# - increase of distance by one twip is incorrect.
1263cdf0e10cSrcweir                 (rRect.*fnRect->fnAddRight)( rBox.GetDistance( BOX_LINE_RIGHT ) );
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir 			if ( bShadow && rAttrs.GetShadow().GetLocation() != SVX_SHADOW_NONE )
1266cdf0e10cSrcweir 			{
1267cdf0e10cSrcweir 				const SvxShadowItem &rShadow = rAttrs.GetShadow();
1268cdf0e10cSrcweir 				if ( bTop )
1269cdf0e10cSrcweir                     (rRect.*fnRect->fnSubTop)(rShadow.CalcShadowSpace(SHADOW_TOP));
1270cdf0e10cSrcweir                 (rRect.*fnRect->fnSubLeft)(rShadow.CalcShadowSpace(SHADOW_LEFT));
1271cdf0e10cSrcweir 				if ( bBottom )
1272cdf0e10cSrcweir                     (rRect.*fnRect->fnAddBottom)
1273cdf0e10cSrcweir                                     (rShadow.CalcShadowSpace( SHADOW_BOTTOM ));
1274cdf0e10cSrcweir                 (rRect.*fnRect->fnAddRight)(rShadow.CalcShadowSpace(SHADOW_RIGHT));
1275cdf0e10cSrcweir 			}
1276cdf0e10cSrcweir 		}
1277cdf0e10cSrcweir 	}
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir 	::SwAlignRect( rRect, pGlobalShell );
1280cdf0e10cSrcweir }
1281cdf0e10cSrcweir 
lcl_ExtendLeftAndRight(SwRect & _rRect,const SwFrm & _rFrm,const SwBorderAttrs & _rAttrs,const SwRectFn & _rRectFn)1282cdf0e10cSrcweir void MA_FASTCALL lcl_ExtendLeftAndRight( SwRect&                _rRect,
1283cdf0e10cSrcweir                                          const SwFrm&           _rFrm,
1284cdf0e10cSrcweir                                          const SwBorderAttrs&   _rAttrs,
1285cdf0e10cSrcweir                                          const SwRectFn&        _rRectFn )
1286cdf0e10cSrcweir {
1287cdf0e10cSrcweir     // OD 21.05.2003 #108789# - extend left/right border/shadow rectangle to
1288cdf0e10cSrcweir     // bottom of previous frame/to top of next frame, if border/shadow is joined
1289cdf0e10cSrcweir     // with previous/next frame.
1290cdf0e10cSrcweir     if ( _rAttrs.JoinedWithPrev( _rFrm ) )
1291cdf0e10cSrcweir 	{
1292cdf0e10cSrcweir         const SwFrm* pPrevFrm = _rFrm.GetPrev();
1293cdf0e10cSrcweir         (_rRect.*_rRectFn->fnSetTop)( (pPrevFrm->*_rRectFn->fnGetPrtBottom)() );
1294cdf0e10cSrcweir 	}
1295cdf0e10cSrcweir     if ( _rAttrs.JoinedWithNext( _rFrm ) )
1296cdf0e10cSrcweir 	{
1297cdf0e10cSrcweir         const SwFrm* pNextFrm = _rFrm.GetNext();
1298cdf0e10cSrcweir         (_rRect.*_rRectFn->fnSetBottom)( (pNextFrm->*_rRectFn->fnGetPrtTop)() );
1299cdf0e10cSrcweir 	}
1300cdf0e10cSrcweir }
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir 
lcl_SubtractFlys(const SwFrm * pFrm,const SwPageFrm * pPage,const SwRect & rRect,SwRegionRects & rRegion)1303cdf0e10cSrcweir void MA_FASTCALL lcl_SubtractFlys( const SwFrm *pFrm, const SwPageFrm *pPage,
1304cdf0e10cSrcweir 						   const SwRect &rRect, SwRegionRects &rRegion )
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir     const SwSortedObjs& rObjs = *pPage->GetSortedObjs();
1307cdf0e10cSrcweir     const SwFlyFrm* pSelfFly = pFrm->IsInFly() ? pFrm->FindFlyFrm() : pRetoucheFly2;
1308cdf0e10cSrcweir 	if ( !pRetoucheFly )
1309cdf0e10cSrcweir 		pRetoucheFly = pRetoucheFly2;
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir 	for ( sal_uInt16 j = 0; (j < rObjs.Count()) && rRegion.Count(); ++j )
1312cdf0e10cSrcweir 	{
1313cdf0e10cSrcweir         const SwAnchoredObject* pAnchoredObj = rObjs[j];
1314cdf0e10cSrcweir         const SdrObject* pSdrObj = pAnchoredObj->GetDrawObj();
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir         // OD 2004-01-15 #110582# - do not consider invisible objects
1317cdf0e10cSrcweir         if ( !pPage->GetFmt()->GetDoc()->IsVisibleLayerId( pSdrObj->GetLayer() ) )
1318cdf0e10cSrcweir             continue;
1319cdf0e10cSrcweir 
1320cdf0e10cSrcweir         if ( !pAnchoredObj->ISA(SwFlyFrm) )
1321cdf0e10cSrcweir             continue;
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir         const SwFlyFrm *pFly = static_cast<const SwFlyFrm*>(pAnchoredObj);
1324cdf0e10cSrcweir 
1325cdf0e10cSrcweir 		if ( pSelfFly == pFly || pRetoucheFly == pFly || !rRect.IsOver( pFly->Frm() ) )
1326cdf0e10cSrcweir 			continue;
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir 		if ( !pFly->GetFmt()->GetPrint().GetValue() &&
1329cdf0e10cSrcweir 				(OUTDEV_PRINTER == pGlobalShell->GetOut()->GetOutDevType() ||
1330cdf0e10cSrcweir 				pGlobalShell->IsPreView()))
1331cdf0e10cSrcweir 			continue;
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir         const sal_Bool bLowerOfSelf = pSelfFly && pFly->IsLowerOf( pSelfFly ) ?
1334cdf0e10cSrcweir 											sal_True : sal_False;
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir 		//Bei zeichengebundenem Fly nur diejenigen betrachten, in denen er
1337cdf0e10cSrcweir 		//nicht selbst verankert ist.
1338cdf0e10cSrcweir 		//#33429# Warum nur bei zeichengebundenen? Es macht doch nie Sinn
1339cdf0e10cSrcweir 		//Rahmen abzuziehen in denen er selbst verankert ist oder?
1340cdf0e10cSrcweir         if ( pSelfFly && pSelfFly->IsLowerOf( pFly ) )
1341cdf0e10cSrcweir 			continue;
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir 		//#57194# Und warum gilt das nicht analog fuer den RetoucheFly?
1344cdf0e10cSrcweir         if ( pRetoucheFly && pRetoucheFly->IsLowerOf( pFly ) )
1345cdf0e10cSrcweir 			continue;
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir #ifdef DBG_UTIL
1349cdf0e10cSrcweir 		//Flys, die innerhalb des eigenen verankert sind, muessen eine
1350cdf0e10cSrcweir 		//groessere OrdNum haben oder Zeichengebunden sein.
1351cdf0e10cSrcweir 		if ( pSelfFly && bLowerOfSelf )
1352cdf0e10cSrcweir 		{
1353cdf0e10cSrcweir 			ASSERT( pFly->IsFlyInCntFrm() ||
1354cdf0e10cSrcweir                     pSdrObj->GetOrdNumDirect() > pSelfFly->GetVirtDrawObj()->GetOrdNumDirect(),
1355cdf0e10cSrcweir 					"Fly with wrong z-Order" );
1356cdf0e10cSrcweir 		}
1357cdf0e10cSrcweir #endif
1358cdf0e10cSrcweir 
1359cdf0e10cSrcweir 		sal_Bool bStopOnHell = sal_True;
1360cdf0e10cSrcweir 		if ( pSelfFly )
1361cdf0e10cSrcweir 		{
1362cdf0e10cSrcweir 			const SdrObject *pTmp = pSelfFly->GetVirtDrawObj();
1363cdf0e10cSrcweir             if ( pSdrObj->GetLayer() == pTmp->GetLayer() )
1364cdf0e10cSrcweir 			{
1365cdf0e10cSrcweir                 if ( pSdrObj->GetOrdNumDirect() < pTmp->GetOrdNumDirect() )
1366cdf0e10cSrcweir 					//Im gleichen Layer werden nur obenliegende beachtet.
1367cdf0e10cSrcweir 					continue;
1368cdf0e10cSrcweir 			}
1369cdf0e10cSrcweir 			else
1370cdf0e10cSrcweir 			{
1371cdf0e10cSrcweir 				if ( !bLowerOfSelf && !pFly->GetFmt()->GetOpaque().GetValue() )
1372cdf0e10cSrcweir 					//Aus anderem Layer interessieren uns nur nicht transparente
1373cdf0e10cSrcweir 					//oder innenliegende
1374cdf0e10cSrcweir 					continue;
1375cdf0e10cSrcweir 				bStopOnHell = sal_False;
1376cdf0e10cSrcweir 			}
1377cdf0e10cSrcweir 		}
1378cdf0e10cSrcweir 		if ( pRetoucheFly )
1379cdf0e10cSrcweir 		{
1380cdf0e10cSrcweir 			const SdrObject *pTmp = pRetoucheFly->GetVirtDrawObj();
1381cdf0e10cSrcweir             if ( pSdrObj->GetLayer() == pTmp->GetLayer() )
1382cdf0e10cSrcweir 			{
1383cdf0e10cSrcweir                 if ( pSdrObj->GetOrdNumDirect() < pTmp->GetOrdNumDirect() )
1384cdf0e10cSrcweir 					//Im gleichen Layer werden nur obenliegende beachtet.
1385cdf0e10cSrcweir 					continue;
1386cdf0e10cSrcweir 			}
1387cdf0e10cSrcweir 			else
1388cdf0e10cSrcweir 			{
1389cdf0e10cSrcweir                 if ( !pFly->IsLowerOf( pRetoucheFly ) && !pFly->GetFmt()->GetOpaque().GetValue() )
1390cdf0e10cSrcweir 					//Aus anderem Layer interessieren uns nur nicht transparente
1391cdf0e10cSrcweir 					//oder innenliegende
1392cdf0e10cSrcweir 					continue;
1393cdf0e10cSrcweir 				bStopOnHell = sal_False;
1394cdf0e10cSrcweir 			}
1395cdf0e10cSrcweir 		}
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir 		//Wenn der Inhalt des Fly Transparent ist, wird er nicht abgezogen, es sei denn
1398cdf0e10cSrcweir 		//er steht im Hell-Layer (#31941#)
1399cdf0e10cSrcweir         const IDocumentDrawModelAccess* pIDDMA = pFly->GetFmt()->getIDocumentDrawModelAccess();
1400cdf0e10cSrcweir         sal_Bool bHell = pSdrObj->GetLayer() == pIDDMA->GetHellId();
1401cdf0e10cSrcweir 		if ( (bStopOnHell && bHell) ||
1402cdf0e10cSrcweir              /// OD 05.08.2002 - change internal order of condition
1403cdf0e10cSrcweir              ///    first check "!bHell", then "..->Lower()" and "..->IsNoTxtFrm()"
1404cdf0e10cSrcweir              ///    have not to be performed, if frame is in "Hell"
1405cdf0e10cSrcweir              ( !bHell && pFly->Lower() && pFly->Lower()->IsNoTxtFrm() &&
1406cdf0e10cSrcweir                ( ((SwNoTxtFrm*)pFly->Lower())->IsTransparent() ||
1407cdf0e10cSrcweir                  ((SwNoTxtFrm*)pFly->Lower())->HasAnimation() ||
1408cdf0e10cSrcweir                  pFly->GetFmt()->GetSurround().IsContour()
1409cdf0e10cSrcweir                )
1410cdf0e10cSrcweir              )
1411cdf0e10cSrcweir            )
1412cdf0e10cSrcweir 			continue;
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir         // OD 08.10.2002 #103898#
1415cdf0e10cSrcweir         // Own if-statements for transparent background/shadow of fly frames
1416cdf0e10cSrcweir         // (#99657#) in order to handle special conditions.
1417cdf0e10cSrcweir         if ( pFly->IsBackgroundTransparent() )
1418cdf0e10cSrcweir         {
1419cdf0e10cSrcweir             // Background <pFly> is transparent drawn. Thus normally, its region
1420cdf0e10cSrcweir             // have not to be substracted from given region.
1421cdf0e10cSrcweir             // But, if method is called for a fly frame and
1422cdf0e10cSrcweir             // <pFly> is a direct lower of this fly frame and
1423cdf0e10cSrcweir             // <pFly> inherites its transparent background brush from its parent,
1424cdf0e10cSrcweir             // then <pFly> frame area have to be subtracted from given region.
1425cdf0e10cSrcweir             // NOTE: Because in Status Quo transparent backgrounds can only be
1426cdf0e10cSrcweir             //     assigned to fly frames, the handle of this special case
1427cdf0e10cSrcweir             //     avoids drawing of transparent areas more than once, if
1428cdf0e10cSrcweir             //     a fly frame inherites a transparent background from its
1429cdf0e10cSrcweir             //     parent fly frame.
1430cdf0e10cSrcweir             if ( pFrm->IsFlyFrm() &&
1431cdf0e10cSrcweir                  (pFly->GetAnchorFrm()->FindFlyFrm() == pFrm) &&
1432cdf0e10cSrcweir                  static_cast<const SwFlyFrmFmt*>(pFly->GetFmt())->IsBackgroundBrushInherited()
1433cdf0e10cSrcweir                )
1434cdf0e10cSrcweir             {
1435cdf0e10cSrcweir                 SwRect aRect;
1436cdf0e10cSrcweir                 SwBorderAttrAccess aAccess( SwFrm::GetCache(), (SwFrm*)pFly );
1437cdf0e10cSrcweir                 const SwBorderAttrs &rAttrs = *aAccess.Get();
1438cdf0e10cSrcweir                 ::lcl_CalcBorderRect( aRect, pFly, rAttrs, sal_True );
1439cdf0e10cSrcweir                 rRegion -= aRect;
1440cdf0e10cSrcweir                 continue;
1441cdf0e10cSrcweir             }
1442cdf0e10cSrcweir             else
1443cdf0e10cSrcweir             {
1444cdf0e10cSrcweir                 continue;
1445cdf0e10cSrcweir             }
1446cdf0e10cSrcweir         }
1447cdf0e10cSrcweir         if ( pFly->IsShadowTransparent() )
1448cdf0e10cSrcweir         {
1449cdf0e10cSrcweir             continue;
1450cdf0e10cSrcweir         }
1451cdf0e10cSrcweir 
1452cdf0e10cSrcweir         if ( bHell && pFly->GetAnchorFrm()->IsInFly() )
1453cdf0e10cSrcweir 		{
1454cdf0e10cSrcweir 			//Damit die Umrandung nicht vom Hintergrund des anderen Flys
1455cdf0e10cSrcweir 			//zerlegt wird.
1456cdf0e10cSrcweir 			SwRect aRect;
1457cdf0e10cSrcweir 			SwBorderAttrAccess aAccess( SwFrm::GetCache(), (SwFrm*)pFly );
1458cdf0e10cSrcweir 			const SwBorderAttrs &rAttrs = *aAccess.Get();
1459cdf0e10cSrcweir 			::lcl_CalcBorderRect( aRect, pFly, rAttrs, sal_True );
1460cdf0e10cSrcweir 			rRegion -= aRect;
1461cdf0e10cSrcweir 		}
1462cdf0e10cSrcweir 		else
1463cdf0e10cSrcweir 		{
1464cdf0e10cSrcweir 			SwRect aRect( pFly->Prt() );
1465cdf0e10cSrcweir 			aRect += pFly->Frm().Pos();
1466cdf0e10cSrcweir 			rRegion -= aRect;
1467cdf0e10cSrcweir 		}
1468cdf0e10cSrcweir 	}
1469cdf0e10cSrcweir 	if ( pRetoucheFly == pRetoucheFly2 )
1470cdf0e10cSrcweir 		pRetoucheFly = 0;
1471cdf0e10cSrcweir }
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir // --> OD 2008-05-16 #i84659# - no longer needed
1474cdf0e10cSrcweir //inline sal_Bool IsShortCut( const SwRect &rRect, const SwRect &rFrmRect )
1475cdf0e10cSrcweir //{
1476cdf0e10cSrcweir //    //Wenn der Frm vollstaendig rechts neben bzw. unter dem
1477cdf0e10cSrcweir //    //Rect sitzt ist's genug mit Painten.
1478cdf0e10cSrcweir //        return rFrmRect.Top() > rRect.Bottom();
1479cdf0e10cSrcweir //        // PAGES01 || (rFrmRect.Left() > rRect.Right()) );
1480cdf0e10cSrcweir //}
1481cdf0e10cSrcweir // <--
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir //---------------- Ausgabe fuer das BrushItem ----------------
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir /** lcl_DrawGraphicBackgrd - local help method to draw a background for a graphic
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir     OD 17.10.2002 #103876#
1488cdf0e10cSrcweir     Under certain circumstances we have to draw a background for a graphic.
1489cdf0e10cSrcweir     This method takes care of the conditions and draws the background with the
1490cdf0e10cSrcweir     corresponding color.
1491cdf0e10cSrcweir     Method introduced for bug fix #103876# in order to optimize drawing tiled
1492cdf0e10cSrcweir     background graphics. Previously, this code was integrated in method
1493cdf0e10cSrcweir     <lcl_DrawGraphic>.
1494cdf0e10cSrcweir     Method implemented as a inline, checking the conditions and calling method
1495cdf0e10cSrcweir     method <lcl_implDrawGraphicBackgrd(..)> for the intrinsic drawing.
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir     @author OD
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir     @param _rBackgrdBrush
1500cdf0e10cSrcweir     background brush contain the color the background has to be drawn.
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir     @param _pOut
1503cdf0e10cSrcweir     output device the background has to be drawn in.
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir     @param _rPaintRect
1506cdf0e10cSrcweir     paint retangle in the output device, which has to be drawn with the background.
1507cdf0e10cSrcweir     rectangle have to be aligned by method ::SwAlignRect
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir     @param _rGraphicObj
1510cdf0e10cSrcweir     graphic object, for which the background has to be drawn. Used for checking
1511cdf0e10cSrcweir     the transparency of its bitmap, its type and if the graphic is drawn transparent
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir     @param _bNumberingGraphic
1514cdf0e10cSrcweir     boolean indicating that graphic is used as a numbering.
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir     @param _bBackgrdAlreadyDrawn
1517cdf0e10cSrcweir     boolean (optional; default: false) indicating, if the background is already drawn.
1518cdf0e10cSrcweir */
lcl_implDrawGraphicBackgrd(const SvxBrushItem & _rBackgrdBrush,OutputDevice * _pOut,const SwRect & _rAlignedPaintRect,const GraphicObject & _rGraphicObj)1519cdf0e10cSrcweir void lcl_implDrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush,
1520cdf0e10cSrcweir                                  OutputDevice* _pOut,
1521cdf0e10cSrcweir                                  const SwRect& _rAlignedPaintRect,
1522cdf0e10cSrcweir                                  const GraphicObject& _rGraphicObj )
1523cdf0e10cSrcweir {
1524cdf0e10cSrcweir     /// determine color of background
1525cdf0e10cSrcweir     ///     If color of background brush is not "no fill"/"auto fill" or
1526cdf0e10cSrcweir     ///     <bFlyMetafile> is set, use color of background brush, otherwise
1527cdf0e10cSrcweir     ///     use global retouche color.
1528cdf0e10cSrcweir     const Color aColor( ( (_rBackgrdBrush.GetColor() != COL_TRANSPARENT) || bFlyMetafile )
1529cdf0e10cSrcweir                         ? _rBackgrdBrush.GetColor()
1530cdf0e10cSrcweir                         : aGlobalRetoucheColor );
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir     /// determine, if background color have to be drawn transparent
1533cdf0e10cSrcweir     /// and calculate transparency percent value
1534cdf0e10cSrcweir     sal_Int8 nTransparencyPercent = 0;
1535cdf0e10cSrcweir     bool bDrawTransparent = false;
1536cdf0e10cSrcweir     if ( aColor.GetTransparency() != 0 )
1537cdf0e10cSrcweir     ///     background color is transparent --> draw transparent.
1538cdf0e10cSrcweir     {
1539cdf0e10cSrcweir         bDrawTransparent = true;
1540cdf0e10cSrcweir         nTransparencyPercent = (aColor.GetTransparency()*100 + 0x7F)/0xFF;
1541cdf0e10cSrcweir     }
1542cdf0e10cSrcweir     else if ( (_rGraphicObj.GetAttr().GetTransparency() != 0) &&
1543cdf0e10cSrcweir                 (_rBackgrdBrush.GetColor() == COL_TRANSPARENT) )
1544cdf0e10cSrcweir     ///     graphic is drawn transparent and background color is
1545cdf0e10cSrcweir     ///     "no fill"/"auto fill" --> draw transparent
1546cdf0e10cSrcweir     {
1547cdf0e10cSrcweir         bDrawTransparent = true;
1548cdf0e10cSrcweir         nTransparencyPercent = (_rGraphicObj.GetAttr().GetTransparency()*100 + 0x7F)/0xFF;
1549cdf0e10cSrcweir     }
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir     if ( bDrawTransparent )
1552cdf0e10cSrcweir     {
1553cdf0e10cSrcweir         /// draw background transparent
1554cdf0e10cSrcweir         if( _pOut->GetFillColor() != aColor.GetRGBColor() )
1555cdf0e10cSrcweir             _pOut->SetFillColor( aColor.GetRGBColor() );
1556cdf0e10cSrcweir         PolyPolygon aPoly( _rAlignedPaintRect.SVRect() );
1557cdf0e10cSrcweir         _pOut->DrawTransparent( aPoly, nTransparencyPercent );
1558cdf0e10cSrcweir     }
1559cdf0e10cSrcweir     else
1560cdf0e10cSrcweir     {
1561cdf0e10cSrcweir         /// draw background opaque
1562cdf0e10cSrcweir         if ( _pOut->GetFillColor() != aColor )
1563cdf0e10cSrcweir             _pOut->SetFillColor( aColor );
1564cdf0e10cSrcweir         _pOut->DrawRect( _rAlignedPaintRect.SVRect() );
1565cdf0e10cSrcweir     }
1566cdf0e10cSrcweir }
1567cdf0e10cSrcweir 
lcl_DrawGraphicBackgrd(const SvxBrushItem & _rBackgrdBrush,OutputDevice * _pOut,const SwRect & _rAlignedPaintRect,const GraphicObject & _rGraphicObj,bool _bNumberingGraphic,bool _bBackgrdAlreadyDrawn=false)1568cdf0e10cSrcweir inline void lcl_DrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush,
1569cdf0e10cSrcweir                                     OutputDevice* _pOut,
1570cdf0e10cSrcweir                                     const SwRect& _rAlignedPaintRect,
1571cdf0e10cSrcweir                                     const GraphicObject& _rGraphicObj,
1572cdf0e10cSrcweir                                     bool _bNumberingGraphic,
1573cdf0e10cSrcweir                                     bool _bBackgrdAlreadyDrawn = false )
1574cdf0e10cSrcweir {
1575cdf0e10cSrcweir     /// draw background with background color, if
1576cdf0e10cSrcweir     ///     (1) graphic is not used as a numbering AND
1577cdf0e10cSrcweir     ///     (2) background is not already drawn AND
1578cdf0e10cSrcweir     ///     (3) intrinsic graphic is transparent OR intrinsic graphic doesn't exists
1579cdf0e10cSrcweir     if ( !_bNumberingGraphic &&
1580cdf0e10cSrcweir          !_bBackgrdAlreadyDrawn &&
1581cdf0e10cSrcweir          ( _rGraphicObj.IsTransparent() || _rGraphicObj.GetType() == GRAPHIC_NONE  )
1582cdf0e10cSrcweir        )
1583cdf0e10cSrcweir     {
1584cdf0e10cSrcweir         lcl_implDrawGraphicBackgrd( _rBackgrdBrush, _pOut, _rAlignedPaintRect, _rGraphicObj );
1585cdf0e10cSrcweir     }
1586cdf0e10cSrcweir }
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir /// OD 06.08.2002 #99657# - Note: the transparency of the background graphic
1589cdf0e10cSrcweir ///     is saved in SvxBrushItem.GetGraphicObject(<shell>).GetAttr().Set/GetTransparency()
1590cdf0e10cSrcweir ///     and is considered in the drawing of the graphic.
1591cdf0e10cSrcweir ///     Thus, to provide transparent background graphic for text frames nothing
1592cdf0e10cSrcweir ///     has to be coded.
1593cdf0e10cSrcweir /// OD 25.09.2002 #99739# - use align rectangle for drawing graphic
1594cdf0e10cSrcweir /// OD 25.09.2002 #99739# - pixel-align coordinations for drawing graphic.
1595cdf0e10cSrcweir /// OD 17.10.2002 #103876# - outsource code for drawing background of the graphic
1596cdf0e10cSrcweir ///     with a background color in method <lcl_DrawGraphicBackgrd>
1597cdf0e10cSrcweir ///     Also, change type of <bGrfNum> and <bClip> from <sal_Bool> to <bool>.
lcl_DrawGraphic(const SvxBrushItem & rBrush,OutputDevice * pOut,ViewShell & rSh,const SwRect & rGrf,const SwRect & rOut,bool bClip,bool bGrfNum,bool bBackgrdAlreadyDrawn=false)1598cdf0e10cSrcweir void lcl_DrawGraphic( const SvxBrushItem& rBrush, OutputDevice *pOut,
1599cdf0e10cSrcweir 					  ViewShell &rSh, const SwRect &rGrf, const SwRect &rOut,
1600cdf0e10cSrcweir                       bool bClip, bool bGrfNum,
1601cdf0e10cSrcweir                       bool bBackgrdAlreadyDrawn = false )
1602cdf0e10cSrcweir                       /// OD 02.09.2002 #99657#
1603cdf0e10cSrcweir                       /// add parameter <bBackgrdAlreadyDrawn> to indicate
1604cdf0e10cSrcweir                       /// that the background is already drawn.
1605cdf0e10cSrcweir {
1606cdf0e10cSrcweir     /// OD 25.09.2002 #99739# - calculate align rectangle from parameter <rGrf>
1607cdf0e10cSrcweir     ///     and use aligned rectangle <aAlignedGrfRect> in the following code
1608cdf0e10cSrcweir     SwRect aAlignedGrfRect = rGrf;
1609cdf0e10cSrcweir     ::SwAlignRect( aAlignedGrfRect, &rSh );
1610cdf0e10cSrcweir 
1611cdf0e10cSrcweir     /// OD 17.10.2002 #103876# - change type from <sal_Bool> to <bool>.
1612cdf0e10cSrcweir     const bool bNotInside = bClip && !rOut.IsInside( aAlignedGrfRect );
1613cdf0e10cSrcweir 	if ( bNotInside )
1614cdf0e10cSrcweir 	{
1615cdf0e10cSrcweir 		pOut->Push( PUSH_CLIPREGION );
1616cdf0e10cSrcweir 		pOut->IntersectClipRegion( rOut.SVRect() );
1617cdf0e10cSrcweir 	}
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir 	//Hier kein Link, wir wollen die Grafik synchron laden!
1620cdf0e10cSrcweir     ((SvxBrushItem&)rBrush).SetDoneLink( Link() );
1621cdf0e10cSrcweir 	GraphicObject *pGrf = (GraphicObject*)rBrush.GetGraphicObject();
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir     /// OD 17.10.2002 #103876# - outsourcing drawing of background with a background color.
1624cdf0e10cSrcweir     ::lcl_DrawGraphicBackgrd( rBrush, pOut, aAlignedGrfRect, *pGrf, bGrfNum, bBackgrdAlreadyDrawn );
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir     /// OD 25.09.2002 #99739# -
1627cdf0e10cSrcweir     /// Because for drawing a graphic left-top-corner and size coordinations are
1628cdf0e10cSrcweir     /// used, these coordinations have to be determined on pixel level.
1629cdf0e10cSrcweir     ::SwAlignGrfRect( &aAlignedGrfRect, *pOut );
1630cdf0e10cSrcweir     pGrf->DrawWithPDFHandling( *pOut, aAlignedGrfRect.Pos(), aAlignedGrfRect.SSize() );
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir 	if ( bNotInside )
1633cdf0e10cSrcweir 		pOut->Pop();
1634cdf0e10cSrcweir } // end of method <lcl_DrawGraphic>
1635cdf0e10cSrcweir 
DrawGraphic(const SvxBrushItem * pBrush,OutputDevice * pOutDev,const SwRect & rOrg,const SwRect & rOut,const sal_uInt8 nGrfNum,const sal_Bool bConsiderBackgroundTransparency)1636cdf0e10cSrcweir void MA_FASTCALL DrawGraphic( const SvxBrushItem *pBrush,
1637cdf0e10cSrcweir                               OutputDevice *pOutDev,
1638cdf0e10cSrcweir                               const SwRect &rOrg,
1639cdf0e10cSrcweir                               const SwRect &rOut,
1640cdf0e10cSrcweir                               const sal_uInt8 nGrfNum,
1641cdf0e10cSrcweir                               const sal_Bool bConsiderBackgroundTransparency )
1642cdf0e10cSrcweir     /// OD 05.08.2002 #99657# - add 6th parameter to indicate that method should
1643cdf0e10cSrcweir     ///   consider background transparency, saved in the color of the brush item
1644cdf0e10cSrcweir {
1645cdf0e10cSrcweir     ViewShell &rSh = *pGlobalShell;
1646cdf0e10cSrcweir     /// OD 17.10.2002 #103876# - change type from <sal_Bool> to <bool>
1647cdf0e10cSrcweir     bool bReplaceGrfNum = GRFNUM_REPLACE == nGrfNum;
1648cdf0e10cSrcweir     bool bGrfNum = GRFNUM_NO != nGrfNum;
1649cdf0e10cSrcweir 	Size aGrfSize;
1650cdf0e10cSrcweir 	SvxGraphicPosition ePos = GPOS_NONE;
1651cdf0e10cSrcweir 	if( pBrush && !bReplaceGrfNum )
1652cdf0e10cSrcweir 	{
1653cdf0e10cSrcweir 		if( rSh.GetViewOptions()->IsGraphic() )
1654cdf0e10cSrcweir 		{
1655cdf0e10cSrcweir             //#125488#: load graphic directly in PDF import
1656cdf0e10cSrcweir             // --> OD 2006-08-25 #i68953# - also during print load graphic directly.
1657cdf0e10cSrcweir             if ( (rSh).GetViewOptions()->IsPDFExport() ||
1658cdf0e10cSrcweir                  rSh.GetOut()->GetOutDevType() == OUTDEV_PRINTER )
1659cdf0e10cSrcweir             // <--
1660cdf0e10cSrcweir             {
1661cdf0e10cSrcweir                 ((SvxBrushItem*)pBrush)->PurgeMedium();
1662cdf0e10cSrcweir                 ((SvxBrushItem*)pBrush)->SetDoneLink( Link() );
1663cdf0e10cSrcweir             }
1664cdf0e10cSrcweir             else
1665cdf0e10cSrcweir                 ((SvxBrushItem*)pBrush)->SetDoneLink( STATIC_LINK(
1666cdf0e10cSrcweir                                     rSh.GetDoc(), SwDoc, BackgroundDone ) );
1667cdf0e10cSrcweir             //SfxObjectShell &rObjSh = *GETOBJSHELL();
1668cdf0e10cSrcweir 			const Graphic* pGrf = pBrush->GetGraphic();
1669cdf0e10cSrcweir 			if( pGrf && GRAPHIC_NONE != pGrf->GetType() )
1670cdf0e10cSrcweir 			{
1671cdf0e10cSrcweir 				ePos = pBrush->GetGraphicPos();
1672cdf0e10cSrcweir 				if( pGrf->IsSupportedGraphic() )
1673cdf0e10cSrcweir 					// don't the use the specific output device! Bug 94802
1674cdf0e10cSrcweir                     aGrfSize = ::GetGraphicSizeTwip( *pGrf, 0 );
1675cdf0e10cSrcweir 			}
1676cdf0e10cSrcweir 		}
1677cdf0e10cSrcweir 		else
1678cdf0e10cSrcweir 			bReplaceGrfNum = bGrfNum;
1679cdf0e10cSrcweir 	}
1680cdf0e10cSrcweir 
1681cdf0e10cSrcweir 	SwRect aGrf;
1682cdf0e10cSrcweir 	aGrf.SSize( aGrfSize );
1683cdf0e10cSrcweir 	sal_Bool bDraw = sal_True;
1684cdf0e10cSrcweir 	sal_Bool bRetouche = sal_True;
1685cdf0e10cSrcweir 	switch ( ePos )
1686cdf0e10cSrcweir 	{
1687cdf0e10cSrcweir 	case GPOS_LT:
1688cdf0e10cSrcweir 		aGrf.Pos() = rOrg.Pos();
1689cdf0e10cSrcweir 		break;
1690cdf0e10cSrcweir 
1691cdf0e10cSrcweir 	case GPOS_MT:
1692cdf0e10cSrcweir 		aGrf.Pos().Y() = rOrg.Top();
1693cdf0e10cSrcweir 		aGrf.Pos().X() = rOrg.Left() + rOrg.Width()/2 - aGrfSize.Width()/2;
1694cdf0e10cSrcweir 		break;
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir 	case GPOS_RT:
1697cdf0e10cSrcweir 		aGrf.Pos().Y() = rOrg.Top();
1698cdf0e10cSrcweir 		aGrf.Pos().X() = rOrg.Right() - aGrfSize.Width();
1699cdf0e10cSrcweir 		break;
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir 	case GPOS_LM:
1702cdf0e10cSrcweir 		aGrf.Pos().Y() = rOrg.Top() + rOrg.Height()/2 - aGrfSize.Height()/2;
1703cdf0e10cSrcweir 		aGrf.Pos().X() = rOrg.Left();
1704cdf0e10cSrcweir 		break;
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir 	case GPOS_MM:
1707cdf0e10cSrcweir 		aGrf.Pos().Y() = rOrg.Top() + rOrg.Height()/2 - aGrfSize.Height()/2;
1708cdf0e10cSrcweir 		aGrf.Pos().X() = rOrg.Left() + rOrg.Width()/2 - aGrfSize.Width()/2;
1709cdf0e10cSrcweir 		break;
1710cdf0e10cSrcweir 
1711cdf0e10cSrcweir 	case GPOS_RM:
1712cdf0e10cSrcweir 		aGrf.Pos().Y() = rOrg.Top() + rOrg.Height()/2 - aGrfSize.Height()/2;
1713cdf0e10cSrcweir 		aGrf.Pos().X() = rOrg.Right() - aGrfSize.Width();
1714cdf0e10cSrcweir 		break;
1715cdf0e10cSrcweir 
1716cdf0e10cSrcweir 	case GPOS_LB:
1717cdf0e10cSrcweir 		aGrf.Pos().Y() = rOrg.Bottom() - aGrfSize.Height();
1718cdf0e10cSrcweir 		aGrf.Pos().X() = rOrg.Left();
1719cdf0e10cSrcweir 		break;
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir 	case GPOS_MB:
1722cdf0e10cSrcweir 		aGrf.Pos().Y() = rOrg.Bottom() - aGrfSize.Height();
1723cdf0e10cSrcweir 		aGrf.Pos().X() = rOrg.Left() + rOrg.Width()/2 - aGrfSize.Width()/2;
1724cdf0e10cSrcweir 		break;
1725cdf0e10cSrcweir 
1726cdf0e10cSrcweir 	case GPOS_RB:
1727cdf0e10cSrcweir 		aGrf.Pos().Y() = rOrg.Bottom() - aGrfSize.Height();
1728cdf0e10cSrcweir 		aGrf.Pos().X() = rOrg.Right() - aGrfSize.Width();
1729cdf0e10cSrcweir 		break;
1730cdf0e10cSrcweir 
1731cdf0e10cSrcweir 	case GPOS_AREA:
1732cdf0e10cSrcweir 		aGrf = rOrg;
1733cdf0e10cSrcweir         /// OD 05.09.2002 #102912#
1734cdf0e10cSrcweir         /// In spite the fact that the background graphic have to fill the complete
1735cdf0e10cSrcweir         /// area, it has been checked, if the graphic will completely fill out
1736cdf0e10cSrcweir         /// the region to be painted <rOut> and thus, nothing has to be retouched.
1737cdf0e10cSrcweir         /// For example, this is the case for a fly frame without a background
1738cdf0e10cSrcweir         /// brush positioned on the border of the page and inherited the
1739cdf0e10cSrcweir         /// background brush from the page.
1740cdf0e10cSrcweir         bRetouche = !rOut.IsInside( aGrf );
1741cdf0e10cSrcweir 		break;
1742cdf0e10cSrcweir 
1743cdf0e10cSrcweir 	case GPOS_TILED:
1744cdf0e10cSrcweir 		{
1745cdf0e10cSrcweir             // OD 17.10.2002 #103876# - draw background of tiled graphic
1746cdf0e10cSrcweir             // before drawing tiled graphic in loop
1747cdf0e10cSrcweir             // determine graphic object
1748cdf0e10cSrcweir             GraphicObject* pGraphicObj = const_cast< GraphicObject* >(pBrush->GetGraphicObject());
1749cdf0e10cSrcweir             // calculate aligned paint rectangle
1750cdf0e10cSrcweir             SwRect aAlignedPaintRect = rOut;
1751cdf0e10cSrcweir             ::SwAlignRect( aAlignedPaintRect, &rSh );
1752cdf0e10cSrcweir             // OD 25.10.2002 #103876# - draw background color for aligned paint rectangle
1753cdf0e10cSrcweir             lcl_DrawGraphicBackgrd( *pBrush, pOutDev, aAlignedPaintRect, *pGraphicObj, bGrfNum );
1754cdf0e10cSrcweir 
1755cdf0e10cSrcweir             // set left-top-corner of background graphic to left-top-corner of the
1756cdf0e10cSrcweir             // area, from which the background brush is determined.
1757cdf0e10cSrcweir             aGrf.Pos() = rOrg.Pos();
1758cdf0e10cSrcweir             // setup clipping at output device
1759cdf0e10cSrcweir             pOutDev->Push( PUSH_CLIPREGION );
1760cdf0e10cSrcweir             pOutDev->IntersectClipRegion( rOut.SVRect() );
1761cdf0e10cSrcweir             // OD 28.10.2002 #103876# - use new method <GraphicObject::DrawTiled(::)>
1762cdf0e10cSrcweir             {
1763cdf0e10cSrcweir                 // calculate paint offset
1764cdf0e10cSrcweir                 Point aPaintOffset( aAlignedPaintRect.Pos() - aGrf.Pos() );
1765cdf0e10cSrcweir                 // draw background graphic tiled for aligned paint rectangle
1766cdf0e10cSrcweir                 // --> OD 2005-02-15 #i42643# - apply fix #104004# for Calc
1767cdf0e10cSrcweir                 // also for Writer - see /sc/source/view/printfun.cxx
1768cdf0e10cSrcweir                 // For PDF export, every draw operation for bitmaps takes a
1769cdf0e10cSrcweir                 // noticeable amount of place (~50 characters). Thus, optimize
1770cdf0e10cSrcweir                 // between tile bitmap size and number of drawing operations here.
1771cdf0e10cSrcweir                 //
1772cdf0e10cSrcweir                 //                  A_out
1773cdf0e10cSrcweir                 // n_chars = k1 *  ---------- + k2 * A_bitmap
1774cdf0e10cSrcweir                 //                  A_bitmap
1775cdf0e10cSrcweir                 //
1776cdf0e10cSrcweir                 // minimum n_chars is obtained for (derive for  A_bitmap,
1777cdf0e10cSrcweir                 // set to 0, take positive solution):
1778cdf0e10cSrcweir                 //                   k1
1779cdf0e10cSrcweir                 // A_bitmap = Sqrt( ---- A_out )
1780cdf0e10cSrcweir                 //                   k2
1781cdf0e10cSrcweir                 //
1782cdf0e10cSrcweir                 // where k1 is the number of chars per draw operation, and
1783cdf0e10cSrcweir                 // k2 is the number of chars per bitmap pixel.
1784cdf0e10cSrcweir                 // This is approximately 50 and 7 for current PDF writer, respectively.
1785cdf0e10cSrcweir                 //
1786cdf0e10cSrcweir                 const double    k1( 50 );
1787cdf0e10cSrcweir                 const double    k2( 7 );
1788cdf0e10cSrcweir                 const Size      aSize( aAlignedPaintRect.SSize() );
1789cdf0e10cSrcweir                 const double    Abitmap( k1/k2 * static_cast<double>(aSize.Width())*aSize.Height() );
1790cdf0e10cSrcweir 
1791cdf0e10cSrcweir                 pGraphicObj->DrawTiled( pOutDev,
1792cdf0e10cSrcweir                                         aAlignedPaintRect.SVRect(),
1793cdf0e10cSrcweir                                         aGrf.SSize(),
1794cdf0e10cSrcweir                                         Size( aPaintOffset.X(), aPaintOffset.Y() ),
1795cdf0e10cSrcweir                                         NULL, GRFMGR_DRAW_STANDARD,
1796cdf0e10cSrcweir                                         ::std::max( 128, static_cast<int>( sqrt(sqrt( Abitmap)) + .5 ) ) );
1797cdf0e10cSrcweir                 // <--
1798cdf0e10cSrcweir             }
1799cdf0e10cSrcweir             // reset clipping at output device
1800cdf0e10cSrcweir             pOutDev->Pop();
1801cdf0e10cSrcweir             // set <bDraw> and <bRetouche> to false, indicating that background
1802cdf0e10cSrcweir             // graphic and background are already drawn.
1803cdf0e10cSrcweir             bDraw = bRetouche = sal_False;
1804cdf0e10cSrcweir 		}
1805cdf0e10cSrcweir 		break;
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir 	case GPOS_NONE:
1808cdf0e10cSrcweir 		bDraw = sal_False;
1809cdf0e10cSrcweir 		break;
1810cdf0e10cSrcweir 
1811cdf0e10cSrcweir     default: ASSERT( !pOutDev, "new Graphic position?" );
1812cdf0e10cSrcweir 	}
1813cdf0e10cSrcweir 
1814cdf0e10cSrcweir     /// OD 02.09.2002 #99657#
1815cdf0e10cSrcweir     /// init variable <bGrfBackgrdAlreadDrawn> to indicate, if background of
1816cdf0e10cSrcweir     /// graphic is already drawn or not.
1817cdf0e10cSrcweir     bool bGrfBackgrdAlreadyDrawn = false;
1818cdf0e10cSrcweir 	if ( bRetouche )
1819cdf0e10cSrcweir 	{
1820cdf0e10cSrcweir         // OD 2004-04-23 #116347#
1821cdf0e10cSrcweir         pOutDev->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
1822cdf0e10cSrcweir         pOutDev->SetLineColor();
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir         // OD 07.08.2002 #99657# #GetTransChg#
1825cdf0e10cSrcweir         //     check, if a existing background graphic (not filling the complete
1826cdf0e10cSrcweir         //     background) is transparent drawn and the background color is
1827cdf0e10cSrcweir         //     "no fill" respectively "auto fill", if background transparency
1828cdf0e10cSrcweir         //     has to be considered.
1829cdf0e10cSrcweir         //     If YES, memorise transparency of background graphic.
1830cdf0e10cSrcweir         //     check also, if background graphic bitmap is transparent.
1831cdf0e10cSrcweir         bool bTransparentGrfWithNoFillBackgrd = false;
1832cdf0e10cSrcweir         sal_Int32 nGrfTransparency = 0;
1833cdf0e10cSrcweir         bool bGrfIsTransparent = false;
1834cdf0e10cSrcweir         if ( (ePos != GPOS_NONE) &&
1835cdf0e10cSrcweir              (ePos != GPOS_TILED) && (ePos != GPOS_AREA)
1836cdf0e10cSrcweir            )
1837cdf0e10cSrcweir         {
1838cdf0e10cSrcweir             GraphicObject *pGrf = (GraphicObject*)pBrush->GetGraphicObject();
1839cdf0e10cSrcweir             if ( bConsiderBackgroundTransparency )
1840cdf0e10cSrcweir             {
1841cdf0e10cSrcweir                 GraphicAttr pGrfAttr = pGrf->GetAttr();
1842cdf0e10cSrcweir                 if ( (pGrfAttr.GetTransparency() != 0) &&
1843cdf0e10cSrcweir                      ( pBrush && (pBrush->GetColor() == COL_TRANSPARENT) )
1844cdf0e10cSrcweir                    )
1845cdf0e10cSrcweir                 {
1846cdf0e10cSrcweir                     bTransparentGrfWithNoFillBackgrd = true;
1847cdf0e10cSrcweir                     nGrfTransparency = pGrfAttr.GetTransparency();
1848cdf0e10cSrcweir                 }
1849cdf0e10cSrcweir             }
1850cdf0e10cSrcweir             if ( pGrf->IsTransparent() )
1851cdf0e10cSrcweir             {
1852cdf0e10cSrcweir                 bGrfIsTransparent = true;
1853cdf0e10cSrcweir             }
1854cdf0e10cSrcweir         }
1855cdf0e10cSrcweir 
1856cdf0e10cSrcweir         /// OD 06.08.2002 #99657# #GetTransChg# - to get color of brush,
1857cdf0e10cSrcweir         ///     check background color against COL_TRANSPARENT ("no fill"/"auto fill")
1858cdf0e10cSrcweir         ///     instead of checking, if transparency is not set.
1859cdf0e10cSrcweir         const Color aColor( pBrush &&
1860cdf0e10cSrcweir                             ( !(pBrush->GetColor() == COL_TRANSPARENT) ||
1861cdf0e10cSrcweir                               bFlyMetafile )
1862cdf0e10cSrcweir                     ? pBrush->GetColor()
1863cdf0e10cSrcweir                     : aGlobalRetoucheColor );
1864cdf0e10cSrcweir 
1865cdf0e10cSrcweir         /// OD 08.08.2002 #99657# - determine, if background region have to be
1866cdf0e10cSrcweir         ///     drawn transparent.
1867cdf0e10cSrcweir         ///     background region has to be drawn transparent, if
1868cdf0e10cSrcweir         ///         background transparency have to be considered
1869cdf0e10cSrcweir         ///     AND
1870cdf0e10cSrcweir         ///       ( background color is transparent OR
1871cdf0e10cSrcweir         ///         background graphic is transparent and background color is "no fill"
1872cdf0e10cSrcweir         ///       )
1873cdf0e10cSrcweir         sal_Bool bDrawTransparent = bConsiderBackgroundTransparency &&
1874cdf0e10cSrcweir                                 ( ( aColor.GetTransparency() != 0) ||
1875cdf0e10cSrcweir                                     bTransparentGrfWithNoFillBackgrd );
1876cdf0e10cSrcweir 
1877cdf0e10cSrcweir         // --> OD 2008-06-02 #i75614#
1878cdf0e10cSrcweir         // reset draw mode in high contrast mode in order to get fill color set
1879cdf0e10cSrcweir         const sal_uLong nOldDrawMode = pOutDev->GetDrawMode();
1880cdf0e10cSrcweir         if ( pGlobalShell->GetWin() &&
1881cdf0e10cSrcweir              Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1882cdf0e10cSrcweir         {
1883cdf0e10cSrcweir             pOutDev->SetDrawMode( 0 );
1884cdf0e10cSrcweir         }
1885cdf0e10cSrcweir         // <--
1886cdf0e10cSrcweir 
1887cdf0e10cSrcweir         /// OD 06.08.2002 #99657# - if background region have to be drawn
1888cdf0e10cSrcweir         ///     transparent, set only the RGB values of the background color as
1889cdf0e10cSrcweir         ///     the fill color for the output device.
1890cdf0e10cSrcweir         if ( bDrawTransparent )
1891cdf0e10cSrcweir         {
1892cdf0e10cSrcweir             if( pOutDev->GetFillColor() != aColor.GetRGBColor() )
1893cdf0e10cSrcweir                 pOutDev->SetFillColor( aColor.GetRGBColor() );
1894cdf0e10cSrcweir         }
1895cdf0e10cSrcweir         else
1896cdf0e10cSrcweir         {
1897cdf0e10cSrcweir             if( pOutDev->GetFillColor() != aColor )
1898cdf0e10cSrcweir                 pOutDev->SetFillColor( aColor );
1899cdf0e10cSrcweir         }
1900cdf0e10cSrcweir 
1901cdf0e10cSrcweir         // --> OD 2008-06-02 #i75614#
1902cdf0e10cSrcweir         // restore draw mode
1903cdf0e10cSrcweir         pOutDev->SetDrawMode( nOldDrawMode );
1904cdf0e10cSrcweir         // <--
1905cdf0e10cSrcweir 
1906cdf0e10cSrcweir         /// OD 02.09.2002 #99657#
1907cdf0e10cSrcweir         if ( bDrawTransparent )
1908cdf0e10cSrcweir         {
1909cdf0e10cSrcweir             /// background region have to be drawn transparent.
1910cdf0e10cSrcweir             /// Thus, create a poly-polygon from the region and draw it with
1911cdf0e10cSrcweir             /// the corresponding transparency precent.
1912cdf0e10cSrcweir             PolyPolygon aDrawPoly( rOut.SVRect() );
1913cdf0e10cSrcweir             if ( aGrf.HasArea() )
1914cdf0e10cSrcweir             {
1915cdf0e10cSrcweir                 if ( !bGrfIsTransparent )
1916cdf0e10cSrcweir                 {
1917cdf0e10cSrcweir                     /// substract area of background graphic from draw area
1918cdf0e10cSrcweir                     /// OD 08.10.2002 #103898# - consider only that part of the
1919cdf0e10cSrcweir                     ///     graphic area that is overlapping with draw area.
1920cdf0e10cSrcweir                     SwRect aTmpGrf = aGrf;
1921cdf0e10cSrcweir                     aTmpGrf.Intersection( rOut );
1922cdf0e10cSrcweir                     if ( aTmpGrf.HasArea() )
1923cdf0e10cSrcweir                     {
1924cdf0e10cSrcweir                         Polygon aGrfPoly( aTmpGrf.SVRect() );
1925cdf0e10cSrcweir                         aDrawPoly.Insert( aGrfPoly );
1926cdf0e10cSrcweir                     }
1927cdf0e10cSrcweir                 }
1928cdf0e10cSrcweir                 else
1929cdf0e10cSrcweir                     bGrfBackgrdAlreadyDrawn = true;
1930cdf0e10cSrcweir             }
1931cdf0e10cSrcweir             /// calculate transparency percent:
1932cdf0e10cSrcweir             /// ( <transparency value[0x01..0xFF]>*100 + 0x7F ) / 0xFF
1933cdf0e10cSrcweir             /// If there is a background graphic with a background color "no fill"/"auto fill",
1934cdf0e10cSrcweir             /// the transparency value is taken from the background graphic,
1935cdf0e10cSrcweir             /// otherwise take the transparency value from the color.
1936cdf0e10cSrcweir             sal_Int8 nTransparencyPercent = static_cast<sal_Int8>(
1937cdf0e10cSrcweir               (( bTransparentGrfWithNoFillBackgrd ? nGrfTransparency : aColor.GetTransparency()
1938cdf0e10cSrcweir                )*100 + 0x7F)/0xFF);
1939cdf0e10cSrcweir             /// draw poly-polygon transparent
1940cdf0e10cSrcweir             pOutDev->DrawTransparent( aDrawPoly, nTransparencyPercent );
1941cdf0e10cSrcweir         }
1942cdf0e10cSrcweir         else
1943cdf0e10cSrcweir         {
1944cdf0e10cSrcweir             SwRegionRects aRegion( rOut, 4 );
1945cdf0e10cSrcweir             if ( !bGrfIsTransparent )
1946cdf0e10cSrcweir                 aRegion -= aGrf;
1947cdf0e10cSrcweir             else
1948cdf0e10cSrcweir                 bGrfBackgrdAlreadyDrawn = true;
1949cdf0e10cSrcweir             /// loop rectangles of background region, which has to be drawn
1950cdf0e10cSrcweir             for( sal_uInt16 i = 0; i < aRegion.Count(); ++i )
1951cdf0e10cSrcweir             {
1952cdf0e10cSrcweir                 pOutDev->DrawRect( aRegion[i].SVRect() );
1953cdf0e10cSrcweir             }
1954cdf0e10cSrcweir         }
1955cdf0e10cSrcweir        pOutDev ->Pop();
1956cdf0e10cSrcweir 	}
1957cdf0e10cSrcweir 
1958cdf0e10cSrcweir     if( bDraw && aGrf.IsOver( rOut ) )
1959cdf0e10cSrcweir         /// OD 02.09.2002 #99657#
1960cdf0e10cSrcweir         /// add parameter <bGrfBackgrdAlreadyDrawn>
1961cdf0e10cSrcweir         lcl_DrawGraphic( *pBrush, pOutDev, rSh, aGrf, rOut, true, bGrfNum,
1962cdf0e10cSrcweir                          bGrfBackgrdAlreadyDrawn );
1963cdf0e10cSrcweir 
1964cdf0e10cSrcweir 	if( bReplaceGrfNum )
1965cdf0e10cSrcweir 	{
1966cdf0e10cSrcweir         const BitmapEx& rBmp = ViewShell::GetReplacementBitmap( false );
1967cdf0e10cSrcweir         Font aTmp( pOutDev->GetFont() );
1968cdf0e10cSrcweir         Graphic::DrawEx( pOutDev, aEmptyStr, aTmp, rBmp, rOrg.Pos(), rOrg.SSize() );
1969cdf0e10cSrcweir 	}
1970cdf0e10cSrcweir }
1971cdf0e10cSrcweir 
1972cdf0e10cSrcweir //------------------------------------------------------------------------
1973cdf0e10cSrcweir 
1974cdf0e10cSrcweir /** local help method for SwRootFrm::Paint(..) - Adjust given rectangle to pixel size
1975cdf0e10cSrcweir 
1976cdf0e10cSrcweir     By OD at 27.09.2002 for #103636#
1977cdf0e10cSrcweir     In order to avoid paint errors caused by multiple alignments - e.g. method
1978cdf0e10cSrcweir     ::SwAlignRect(..) - and other changes to the rectangle to be painted,
1979cdf0e10cSrcweir     this method is called for the rectangle to be painted in order to
1980cdf0e10cSrcweir     adjust it to the pixel it is overlapping.
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir     @author OD
1983cdf0e10cSrcweir */
lcl_AdjustRectToPixelSize(SwRect & io_aSwRect,const OutputDevice & aOut)1984cdf0e10cSrcweir void lcl_AdjustRectToPixelSize( SwRect& io_aSwRect, const OutputDevice &aOut )
1985cdf0e10cSrcweir {
1986cdf0e10cSrcweir     /// local constant object of class <Size> to determine number of Twips
1987cdf0e10cSrcweir     /// representing a pixel.
1988cdf0e10cSrcweir     const Size aTwipToPxSize( aOut.PixelToLogic( Size( 1,1 )) );
1989cdf0e10cSrcweir 
1990cdf0e10cSrcweir     /// local object of class <Rectangle> in Twip coordinates
1991cdf0e10cSrcweir     /// calculated from given rectangle aligned to pixel centers.
1992cdf0e10cSrcweir     const Rectangle aPxCenterRect = aOut.PixelToLogic(
1993cdf0e10cSrcweir             aOut.LogicToPixel( io_aSwRect.SVRect() ) );
1994cdf0e10cSrcweir 
1995cdf0e10cSrcweir     /// local constant object of class <Rectangle> representing given rectangle
1996cdf0e10cSrcweir     /// in pixel.
1997cdf0e10cSrcweir     const Rectangle aOrgPxRect = aOut.LogicToPixel( io_aSwRect.SVRect() );
1998cdf0e10cSrcweir 
1999cdf0e10cSrcweir     /// calculate adjusted rectangle from pixel centered rectangle.
2000cdf0e10cSrcweir     /// Due to rounding differences <aPxCenterRect> doesn't exactly represents
2001cdf0e10cSrcweir     /// the Twip-centers. Thus, adjust borders by half of pixel width/height plus 1.
2002cdf0e10cSrcweir     /// Afterwards, adjust calculated Twip-positions of the all borders.
2003cdf0e10cSrcweir     Rectangle aSizedRect = aPxCenterRect;
2004cdf0e10cSrcweir     aSizedRect.Left() -= (aTwipToPxSize.Width()/2 + 1);
2005cdf0e10cSrcweir     aSizedRect.Right() += (aTwipToPxSize.Width()/2 + 1);
2006cdf0e10cSrcweir     aSizedRect.Top() -= (aTwipToPxSize.Height()/2 + 1);
2007cdf0e10cSrcweir     aSizedRect.Bottom() += (aTwipToPxSize.Height()/2 + 1);
2008cdf0e10cSrcweir 
2009cdf0e10cSrcweir     /// adjust left()
2010cdf0e10cSrcweir     while ( (aOut.LogicToPixel(aSizedRect)).Left() < aOrgPxRect.Left() )
2011cdf0e10cSrcweir     {
2012cdf0e10cSrcweir         ++aSizedRect.Left();
2013cdf0e10cSrcweir     }
2014cdf0e10cSrcweir     /// adjust right()
2015cdf0e10cSrcweir     while ( (aOut.LogicToPixel(aSizedRect)).Right() > aOrgPxRect.Right() )
2016cdf0e10cSrcweir     {
2017cdf0e10cSrcweir         --aSizedRect.Right();
2018cdf0e10cSrcweir     }
2019cdf0e10cSrcweir     /// adjust top()
2020cdf0e10cSrcweir     while ( (aOut.LogicToPixel(aSizedRect)).Top() < aOrgPxRect.Top() )
2021cdf0e10cSrcweir     {
2022cdf0e10cSrcweir         ++aSizedRect.Top();
2023cdf0e10cSrcweir     }
2024cdf0e10cSrcweir     /// adjust bottom()
2025cdf0e10cSrcweir     while ( (aOut.LogicToPixel(aSizedRect)).Bottom() > aOrgPxRect.Bottom() )
2026cdf0e10cSrcweir     {
2027cdf0e10cSrcweir         --aSizedRect.Bottom();
2028cdf0e10cSrcweir     }
2029cdf0e10cSrcweir 
2030cdf0e10cSrcweir     io_aSwRect = SwRect( aSizedRect );
2031cdf0e10cSrcweir 
2032cdf0e10cSrcweir #ifdef DBG_UTIL
2033cdf0e10cSrcweir     Rectangle aTestOrgPxRect = aOut.LogicToPixel( io_aSwRect.SVRect() );
2034cdf0e10cSrcweir     Rectangle aTestNewPxRect = aOut.LogicToPixel( aSizedRect );
2035cdf0e10cSrcweir     ASSERT( aTestOrgPxRect == aTestNewPxRect,
2036cdf0e10cSrcweir             "Error in lcl_AlignRectToPixelSize(..): Adjusted rectangle has incorrect position or size");
2037cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2038cdf0e10cSrcweir     Rectangle aTestNewRect( aSizedRect );
2039cdf0e10cSrcweir     /// check Left()
2040cdf0e10cSrcweir     --aSizedRect.Left();
2041cdf0e10cSrcweir     aTestNewPxRect = aOut.LogicToPixel( aSizedRect );
2042cdf0e10cSrcweir     ASSERT( aTestOrgPxRect.Left() >= (aTestNewPxRect.Left()+1),
2043cdf0e10cSrcweir             "Error in lcl_AlignRectToPixelSize(..): Left() not correct adjusted");
2044cdf0e10cSrcweir     ++aSizedRect.Left();
2045cdf0e10cSrcweir     /// check Right()
2046cdf0e10cSrcweir     ++aSizedRect.Right();
2047cdf0e10cSrcweir     aTestNewPxRect = aOut.LogicToPixel( aSizedRect );
2048cdf0e10cSrcweir     ASSERT( aTestOrgPxRect.Right() <= (aTestNewPxRect.Right()-1),
2049cdf0e10cSrcweir             "Error in lcl_AlignRectToPixelSize(..): Right() not correct adjusted");
2050cdf0e10cSrcweir     --aSizedRect.Right();
2051cdf0e10cSrcweir     /// check Top()
2052cdf0e10cSrcweir     --aSizedRect.Top();
2053cdf0e10cSrcweir     aTestNewPxRect = aOut.LogicToPixel( aSizedRect );
2054cdf0e10cSrcweir     ASSERT( aTestOrgPxRect.Top() >= (aTestNewPxRect.Top()+1),
2055cdf0e10cSrcweir             "Error in lcl_AlignRectToPixelSize(..): Top() not correct adjusted");
2056cdf0e10cSrcweir     ++aSizedRect.Top();
2057cdf0e10cSrcweir     /// check Bottom()
2058cdf0e10cSrcweir     ++aSizedRect.Bottom();
2059cdf0e10cSrcweir     aTestNewPxRect = aOut.LogicToPixel( aSizedRect );
2060cdf0e10cSrcweir     ASSERT( aTestOrgPxRect.Bottom() <= (aTestNewPxRect.Bottom()-1),
2061cdf0e10cSrcweir             "Error in lcl_AlignRectToPixelSize(..): Bottom() not correct adjusted");
2062cdf0e10cSrcweir     --aSizedRect.Bottom();
2063cdf0e10cSrcweir #endif
2064cdf0e10cSrcweir #endif
2065cdf0e10cSrcweir }
2066cdf0e10cSrcweir 
2067cdf0e10cSrcweir 
2068cdf0e10cSrcweir //
2069cdf0e10cSrcweir // FUNCTIONS USED FOR COLLAPSING TABLE BORDER LINES START
2070cdf0e10cSrcweir //
2071cdf0e10cSrcweir 
2072cdf0e10cSrcweir struct SwLineEntry
2073cdf0e10cSrcweir {
2074cdf0e10cSrcweir     SwTwips mnKey;
2075cdf0e10cSrcweir     SwTwips mnStartPos;
2076cdf0e10cSrcweir     SwTwips mnEndPos;
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir     svx::frame::Style maAttribute;
2079cdf0e10cSrcweir 
2080cdf0e10cSrcweir     enum OverlapType { NO_OVERLAP, OVERLAP1, OVERLAP2, OVERLAP3 };
2081cdf0e10cSrcweir 
2082cdf0e10cSrcweir public:
2083cdf0e10cSrcweir     SwLineEntry( SwTwips nKey,
2084cdf0e10cSrcweir                  SwTwips nStartPos,
2085cdf0e10cSrcweir                  SwTwips nEndPos,
2086cdf0e10cSrcweir                  const svx::frame::Style& rAttribute );
2087cdf0e10cSrcweir 
2088cdf0e10cSrcweir     OverlapType Overlaps( const SwLineEntry& rComp ) const;
2089cdf0e10cSrcweir };
2090cdf0e10cSrcweir 
SwLineEntry(SwTwips nKey,SwTwips nStartPos,SwTwips nEndPos,const svx::frame::Style & rAttribute)2091cdf0e10cSrcweir SwLineEntry::SwLineEntry( SwTwips nKey,
2092cdf0e10cSrcweir                           SwTwips nStartPos,
2093cdf0e10cSrcweir                           SwTwips nEndPos,
2094cdf0e10cSrcweir                           const svx::frame::Style& rAttribute )
2095cdf0e10cSrcweir     :   mnKey( nKey ),
2096cdf0e10cSrcweir         mnStartPos( nStartPos ),
2097cdf0e10cSrcweir         mnEndPos( nEndPos ),
2098cdf0e10cSrcweir         maAttribute( rAttribute )
2099cdf0e10cSrcweir {
2100cdf0e10cSrcweir }
2101cdf0e10cSrcweir 
2102cdf0e10cSrcweir /*
2103cdf0e10cSrcweir 
2104cdf0e10cSrcweir  1. ----------    rOld
2105cdf0e10cSrcweir        ---------- rNew
2106cdf0e10cSrcweir 
2107cdf0e10cSrcweir  2. ----------    rOld
2108cdf0e10cSrcweir     ------------- rNew
2109cdf0e10cSrcweir 
2110cdf0e10cSrcweir  3.    -------    rOld
2111cdf0e10cSrcweir     ------------- rNew
2112cdf0e10cSrcweir 
2113cdf0e10cSrcweir  4. ------------- rOld
2114cdf0e10cSrcweir        ---------- rNew
2115cdf0e10cSrcweir 
2116cdf0e10cSrcweir  5. ----------    rOld
2117cdf0e10cSrcweir        ----       rNew
2118cdf0e10cSrcweir 
2119cdf0e10cSrcweir  6. ----------    rOld
2120cdf0e10cSrcweir     ----------    rNew
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir  7. ------------- rOld
2123cdf0e10cSrcweir     ----------    rNew
2124cdf0e10cSrcweir 
2125cdf0e10cSrcweir  8.    ---------- rOld
2126cdf0e10cSrcweir     ------------- rNew
2127cdf0e10cSrcweir 
2128cdf0e10cSrcweir  9.    ---------- rOld
2129cdf0e10cSrcweir     ----------    rNew
2130cdf0e10cSrcweir */
2131cdf0e10cSrcweir 
Overlaps(const SwLineEntry & rNew) const2132cdf0e10cSrcweir SwLineEntry::OverlapType SwLineEntry::Overlaps( const SwLineEntry& rNew )  const
2133cdf0e10cSrcweir {
2134cdf0e10cSrcweir     SwLineEntry::OverlapType eRet = OVERLAP3;
2135cdf0e10cSrcweir 
2136cdf0e10cSrcweir     if ( mnStartPos >= rNew.mnEndPos || mnEndPos <= rNew.mnStartPos )
2137cdf0e10cSrcweir         eRet = NO_OVERLAP;
2138cdf0e10cSrcweir 
2139cdf0e10cSrcweir     // 1, 2, 3
2140cdf0e10cSrcweir     else if ( mnEndPos < rNew.mnEndPos )
2141cdf0e10cSrcweir         eRet = OVERLAP1;
2142cdf0e10cSrcweir 
2143cdf0e10cSrcweir     // 4, 5, 6, 7
2144cdf0e10cSrcweir     else if ( mnStartPos <= rNew.mnStartPos && mnEndPos >= rNew.mnEndPos )
2145cdf0e10cSrcweir         eRet = OVERLAP2;
2146cdf0e10cSrcweir 
2147cdf0e10cSrcweir     // 8, 9
2148cdf0e10cSrcweir     return eRet;
2149cdf0e10cSrcweir }
2150cdf0e10cSrcweir 
2151cdf0e10cSrcweir struct lt_SwLineEntry
2152cdf0e10cSrcweir {
operator ()lt_SwLineEntry2153cdf0e10cSrcweir     bool operator()( const SwLineEntry& e1, const SwLineEntry& e2 ) const
2154cdf0e10cSrcweir     {
2155cdf0e10cSrcweir         return e1.mnStartPos < e2.mnStartPos;
2156cdf0e10cSrcweir     }
2157cdf0e10cSrcweir };
2158cdf0e10cSrcweir 
2159cdf0e10cSrcweir typedef std::set< SwLineEntry, lt_SwLineEntry > SwLineEntrySet;
2160cdf0e10cSrcweir typedef std::set< SwLineEntry, lt_SwLineEntry >::iterator SwLineEntrySetIter;
2161cdf0e10cSrcweir typedef std::set< SwLineEntry, lt_SwLineEntry >::const_iterator SwLineEntrySetConstIter;
2162cdf0e10cSrcweir typedef std::map< SwTwips, SwLineEntrySet > SwLineEntryMap;
2163cdf0e10cSrcweir typedef std::map< SwTwips, SwLineEntrySet >::iterator SwLineEntryMapIter;
2164cdf0e10cSrcweir typedef std::map< SwTwips, SwLineEntrySet >::const_iterator SwLineEntryMapConstIter;
2165cdf0e10cSrcweir 
2166cdf0e10cSrcweir class SwTabFrmPainter
2167cdf0e10cSrcweir {
2168cdf0e10cSrcweir     SwLineEntryMap maVertLines;
2169cdf0e10cSrcweir     SwLineEntryMap maHoriLines;
2170cdf0e10cSrcweir     const SwTabFrm& mrTabFrm;
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir     void Insert( SwLineEntry&, bool bHori );
2173cdf0e10cSrcweir     void Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem );
2174cdf0e10cSrcweir     void HandleFrame( const SwLayoutFrm& rFrm );
2175cdf0e10cSrcweir     void FindStylesForLine( const Point&,
2176cdf0e10cSrcweir                             const Point&,
2177cdf0e10cSrcweir                             svx::frame::Style*,
2178cdf0e10cSrcweir                             bool bHori ) const;
2179cdf0e10cSrcweir 
2180cdf0e10cSrcweir public:
2181cdf0e10cSrcweir     SwTabFrmPainter( const SwTabFrm& rTabFrm );
2182cdf0e10cSrcweir 
2183cdf0e10cSrcweir     void PaintLines( OutputDevice& rDev, const SwRect& rRect ) const;
2184cdf0e10cSrcweir };
2185cdf0e10cSrcweir 
SwTabFrmPainter(const SwTabFrm & rTabFrm)2186cdf0e10cSrcweir SwTabFrmPainter::SwTabFrmPainter( const SwTabFrm& rTabFrm )
2187cdf0e10cSrcweir     : mrTabFrm( rTabFrm )
2188cdf0e10cSrcweir {
2189cdf0e10cSrcweir     HandleFrame( rTabFrm );
2190cdf0e10cSrcweir }
2191cdf0e10cSrcweir 
HandleFrame(const SwLayoutFrm & rLayoutFrm)2192cdf0e10cSrcweir void SwTabFrmPainter::HandleFrame( const SwLayoutFrm& rLayoutFrm )
2193cdf0e10cSrcweir {
2194cdf0e10cSrcweir     // Add border lines of cell frames. Skip covered cells. Skip cells
2195cdf0e10cSrcweir     // in special row span row, which do not have a negative row span:
2196cdf0e10cSrcweir     if ( rLayoutFrm.IsCellFrm() && !rLayoutFrm.IsCoveredCell() )
2197cdf0e10cSrcweir     {
2198cdf0e10cSrcweir         const SwCellFrm* pThisCell = static_cast<const SwCellFrm*>(&rLayoutFrm);
2199cdf0e10cSrcweir         const SwRowFrm* pRowFrm = static_cast<const SwRowFrm*>(pThisCell->GetUpper());
2200cdf0e10cSrcweir         const long nRowSpan = pThisCell->GetTabBox()->getRowSpan();
2201cdf0e10cSrcweir         if ( !pRowFrm->IsRowSpanLine() || nRowSpan > 1 || nRowSpan < -1 )
2202cdf0e10cSrcweir         {
2203cdf0e10cSrcweir             SwBorderAttrAccess aAccess( SwFrm::GetCache(), &rLayoutFrm );
2204cdf0e10cSrcweir             const SwBorderAttrs& rAttrs = *aAccess.Get();
2205cdf0e10cSrcweir             const SvxBoxItem& rBox = rAttrs.GetBox();
2206cdf0e10cSrcweir             Insert( rLayoutFrm, rBox );
2207cdf0e10cSrcweir         }
2208cdf0e10cSrcweir     }
2209cdf0e10cSrcweir 
2210cdf0e10cSrcweir     // Recurse into lower layout frames, but do not recurse into lower tabframes.
2211cdf0e10cSrcweir     const SwFrm* pLower = rLayoutFrm.Lower();
2212cdf0e10cSrcweir     while ( pLower )
2213cdf0e10cSrcweir     {
2214cdf0e10cSrcweir         const SwLayoutFrm* pLowerLayFrm = dynamic_cast<const SwLayoutFrm*>(pLower);
2215cdf0e10cSrcweir         if ( pLowerLayFrm && !pLowerLayFrm->IsTabFrm() )
2216cdf0e10cSrcweir             HandleFrame( *pLowerLayFrm );
2217cdf0e10cSrcweir 
2218cdf0e10cSrcweir         pLower = pLower->GetNext();
2219cdf0e10cSrcweir     }
2220cdf0e10cSrcweir }
2221cdf0e10cSrcweir 
PaintLines(OutputDevice & rDev,const SwRect & rRect) const2222cdf0e10cSrcweir void SwTabFrmPainter::PaintLines( OutputDevice& rDev, const SwRect& rRect ) const
2223cdf0e10cSrcweir {
2224cdf0e10cSrcweir     // --> FME 2004-06-24 #i16816# tagged pdf support
2225cdf0e10cSrcweir     SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, rDev );
2226cdf0e10cSrcweir     // <--
2227cdf0e10cSrcweir 
2228cdf0e10cSrcweir     const SwFrm* pTmpFrm = &mrTabFrm;
2229cdf0e10cSrcweir     const bool bVert = pTmpFrm->IsVertical();
2230cdf0e10cSrcweir 
2231cdf0e10cSrcweir     SwLineEntryMapConstIter aIter = maHoriLines.begin();
2232cdf0e10cSrcweir     bool bHori = true;
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir     // color for subsidiary lines:
2235cdf0e10cSrcweir     const Color& rCol( SwViewOption::GetTableBoundariesColor() );
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir     // high contrast mode:
2238cdf0e10cSrcweir     // overrides the color of non-subsidiary lines.
2239cdf0e10cSrcweir     const Color* pHCColor = 0;
2240cdf0e10cSrcweir     sal_uLong nOldDrawMode = rDev.GetDrawMode();
2241cdf0e10cSrcweir     if( pGlobalShell->GetWin() &&
2242cdf0e10cSrcweir         Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
2243cdf0e10cSrcweir     {
2244cdf0e10cSrcweir         pHCColor = &SwViewOption::GetFontColor();
2245cdf0e10cSrcweir         rDev.SetDrawMode( 0 );
2246cdf0e10cSrcweir     }
2247cdf0e10cSrcweir 
2248cdf0e10cSrcweir     // set clip region:
2249cdf0e10cSrcweir     rDev.Push( PUSH_CLIPREGION );
2250cdf0e10cSrcweir     Size aSize( rRect.SSize() );
2251cdf0e10cSrcweir     // Hack! Necessary, because the layout is not pixel aligned!
2252cdf0e10cSrcweir     aSize.Width() += nPixelSzW; aSize.Height() += nPixelSzH;
2253cdf0e10cSrcweir     rDev.SetClipRegion( Rectangle( rRect.Pos(), aSize ) );
2254cdf0e10cSrcweir 
2255cdf0e10cSrcweir     // The following stuff if necessary to have the new table borders fit
2256cdf0e10cSrcweir     // into a ::SwAlignRect adjusted world.
2257cdf0e10cSrcweir     const SwTwips nTwipXCorr =  bVert ? 0 : Max( 0L, nHalfPixelSzW - 2 );    // 1 < 2 < 3 ;-)
2258cdf0e10cSrcweir     const SwTwips nTwipYCorr = !bVert ? 0 : Max( 0L, nHalfPixelSzW - 2 );    // 1 < 2 < 3 ;-)
2259cdf0e10cSrcweir     const SwFrm* pUpper = mrTabFrm.GetUpper();
2260cdf0e10cSrcweir     SwRect aUpper( pUpper->Prt() );
2261cdf0e10cSrcweir     aUpper.Pos() += pUpper->Frm().Pos();
2262cdf0e10cSrcweir     SwRect aUpperAligned( aUpper );
2263cdf0e10cSrcweir     ::SwAlignRect( aUpperAligned, pGlobalShell );
2264cdf0e10cSrcweir 
2265cdf0e10cSrcweir     while ( true )
2266cdf0e10cSrcweir     {
2267cdf0e10cSrcweir         if ( bHori && aIter == maHoriLines.end() )
2268cdf0e10cSrcweir         {
2269cdf0e10cSrcweir             aIter = maVertLines.begin();
2270cdf0e10cSrcweir             bHori = false;
2271cdf0e10cSrcweir         }
2272cdf0e10cSrcweir 
2273cdf0e10cSrcweir         if ( !bHori && aIter == maVertLines.end() )
2274cdf0e10cSrcweir             break;
2275cdf0e10cSrcweir 
2276cdf0e10cSrcweir         const SwLineEntrySet& rEntrySet = (*aIter).second;
227724b62240SHerbert Dürr         SwLineEntrySetConstIter aSetIter = rEntrySet.begin();
2278cdf0e10cSrcweir         while ( aSetIter != rEntrySet.end() )
2279cdf0e10cSrcweir         {
2280cdf0e10cSrcweir             const SwLineEntry& rEntry = *aSetIter;
2281cdf0e10cSrcweir             const svx::frame::Style& rEntryStyle( (*aSetIter).maAttribute );
2282cdf0e10cSrcweir 
2283cdf0e10cSrcweir             Point aStart, aEnd;
2284cdf0e10cSrcweir             if ( bHori )
2285cdf0e10cSrcweir             {
2286cdf0e10cSrcweir                 aStart.X() = rEntry.mnStartPos;
2287cdf0e10cSrcweir                 aStart.Y() = rEntry.mnKey;
2288cdf0e10cSrcweir                 aEnd.X() = rEntry.mnEndPos;
2289cdf0e10cSrcweir                 aEnd.Y() = rEntry.mnKey;
2290cdf0e10cSrcweir             }
2291cdf0e10cSrcweir             else
2292cdf0e10cSrcweir             {
2293cdf0e10cSrcweir                 aStart.X() = rEntry.mnKey;
2294cdf0e10cSrcweir                 aStart.Y() = rEntry.mnStartPos;
2295cdf0e10cSrcweir                 aEnd.X() = rEntry.mnKey;
2296cdf0e10cSrcweir                 aEnd.Y() = rEntry.mnEndPos;
2297cdf0e10cSrcweir             }
2298cdf0e10cSrcweir 
2299cdf0e10cSrcweir             SwRect aRepaintRect( aStart, aEnd );
2300cdf0e10cSrcweir 
2301cdf0e10cSrcweir             // the repaint rectangle has to be moved a bit for the centered lines:
2302cdf0e10cSrcweir             SwTwips nRepaintRectSize = !rEntryStyle.GetWidth() ? 1 : rEntryStyle.GetWidth();
2303cdf0e10cSrcweir             if ( bHori )
2304cdf0e10cSrcweir             {
2305cdf0e10cSrcweir                 aRepaintRect.Height( 2 * nRepaintRectSize );
2306cdf0e10cSrcweir                 aRepaintRect.Pos().Y() -= nRepaintRectSize;
2307cdf0e10cSrcweir             }
2308cdf0e10cSrcweir             else
2309cdf0e10cSrcweir             {
2310cdf0e10cSrcweir                 aRepaintRect.Width( 2 * nRepaintRectSize );
2311cdf0e10cSrcweir                 aRepaintRect.Pos().X() -= nRepaintRectSize;
2312cdf0e10cSrcweir             }
2313cdf0e10cSrcweir 
2314cdf0e10cSrcweir             if ( rRect.IsOver( aRepaintRect ) )
2315cdf0e10cSrcweir             {
2316cdf0e10cSrcweir                 svx::frame::Style aStyles[ 7 ];
2317cdf0e10cSrcweir                 aStyles[ 0 ] = rEntryStyle;
2318cdf0e10cSrcweir                 FindStylesForLine( aStart, aEnd, aStyles, bHori );
2319cdf0e10cSrcweir 
2320cdf0e10cSrcweir                 // subsidiary lines
2321cdf0e10cSrcweir                 const Color* pTmpColor = 0;
2322cdf0e10cSrcweir                 if ( 0 == aStyles[ 0 ].GetWidth() )
2323cdf0e10cSrcweir                 {
2324cdf0e10cSrcweir                     if ( IS_SUBS_TABLE && pGlobalShell->GetWin() )
2325cdf0e10cSrcweir                         aStyles[ 0 ].Set( rCol, 1, 0, 0 );
2326cdf0e10cSrcweir                 }
2327cdf0e10cSrcweir                 else
2328cdf0e10cSrcweir                     pTmpColor = pHCColor;
2329cdf0e10cSrcweir 
2330cdf0e10cSrcweir                 // The line sizes stored in the line style have to be adjusted as well.
2331cdf0e10cSrcweir                 // This will guarantee that lines with the same twip size will have the
2332cdf0e10cSrcweir                 // same pixel size.
2333cdf0e10cSrcweir                 for ( int i = 0; i < 7; ++i )
2334cdf0e10cSrcweir                 {
2335cdf0e10cSrcweir                     sal_uInt16 nPrim = aStyles[ i ].Prim();
2336cdf0e10cSrcweir                     sal_uInt16 nDist = aStyles[ i ].Dist();
2337cdf0e10cSrcweir                     sal_uInt16 nSecn = aStyles[ i ].Secn();
2338cdf0e10cSrcweir 
2339cdf0e10cSrcweir                     if ( nPrim > 0 )
2340cdf0e10cSrcweir                         nPrim = (sal_uInt16)( Max( 1L, nPixelSzH * ( nPrim / nPixelSzH ) ) );
2341cdf0e10cSrcweir                     if ( nDist > 0 )
2342cdf0e10cSrcweir                         nDist = (sal_uInt16)( Max( 1L, nPixelSzH * ( nDist / nPixelSzH ) ) );
2343cdf0e10cSrcweir                     if ( nSecn > 0 )
2344cdf0e10cSrcweir                         nSecn = (sal_uInt16)( Max( 1L, nPixelSzH * ( nSecn / nPixelSzH ) ) );
2345cdf0e10cSrcweir 
2346cdf0e10cSrcweir                     aStyles[ i ].Set( nPrim, nDist, nSecn );
2347cdf0e10cSrcweir                 }
2348cdf0e10cSrcweir 
2349cdf0e10cSrcweir                 // The (twip) positions will be adjusted to meet these requirements:
2350cdf0e10cSrcweir                 // 1. The y coordinates are located in the middle of the pixel grid
2351cdf0e10cSrcweir                 // 2. The x coordinated are located at the beginning of the pixel grid
2352cdf0e10cSrcweir                 // This is done, because the horizontal lines are painted "at beginning",
2353cdf0e10cSrcweir                 // whereas the vertical lines are painted "centered". By making the line
2354cdf0e10cSrcweir                 // sizes a multiple of one pixel size, we can assure, that all lines having
2355cdf0e10cSrcweir                 // the same twip size have the same pixel size, independent of their position
2356cdf0e10cSrcweir                 // on the screen.
2357cdf0e10cSrcweir                 Point aPaintStart = rDev.PixelToLogic( rDev.LogicToPixel( aStart ) );
2358cdf0e10cSrcweir                 Point aPaintEnd = rDev.PixelToLogic( rDev.LogicToPixel( aEnd ) );
2359cdf0e10cSrcweir 
2360cdf0e10cSrcweir                 if( pGlobalShell->GetWin() )
2361cdf0e10cSrcweir                 {
2362cdf0e10cSrcweir                     // The table borders do not use SwAlignRect, but all the other frames do.
2363cdf0e10cSrcweir                     // Therefore we tweak the outer borders a bit to achieve that the outer
2364cdf0e10cSrcweir                     // borders match the subsidiary lines of the upper:
2365cdf0e10cSrcweir                     if ( aStart.X() == aUpper.Left() )
2366cdf0e10cSrcweir                         aPaintStart.X() = aUpperAligned.Left();
2367cdf0e10cSrcweir                     else if ( aStart.X() == aUpper._Right() )
2368cdf0e10cSrcweir                         aPaintStart.X() = aUpperAligned._Right();
2369cdf0e10cSrcweir                     if ( aStart.Y() == aUpper.Top() )
2370cdf0e10cSrcweir                         aPaintStart.Y() = aUpperAligned.Top();
2371cdf0e10cSrcweir                     else if ( aStart.Y() == aUpper._Bottom() )
2372cdf0e10cSrcweir                         aPaintStart.Y() = aUpperAligned._Bottom();
2373cdf0e10cSrcweir 
2374cdf0e10cSrcweir                     if ( aEnd.X() == aUpper.Left() )
2375cdf0e10cSrcweir                         aPaintEnd.X() = aUpperAligned.Left();
2376cdf0e10cSrcweir                     else if ( aEnd.X() == aUpper._Right() )
2377cdf0e10cSrcweir                         aPaintEnd.X() = aUpperAligned._Right();
2378cdf0e10cSrcweir                     if ( aEnd.Y() == aUpper.Top() )
2379cdf0e10cSrcweir                         aPaintEnd.Y() = aUpperAligned.Top();
2380cdf0e10cSrcweir                     else if ( aEnd.Y() == aUpper._Bottom() )
2381cdf0e10cSrcweir                         aPaintEnd.Y() = aUpperAligned._Bottom();
2382cdf0e10cSrcweir                 }
2383cdf0e10cSrcweir 
2384cdf0e10cSrcweir                 aPaintStart.X() -= nTwipXCorr; // nHalfPixelSzW - 2 to assure that we do not leave the pixel
2385cdf0e10cSrcweir                 aPaintEnd.X()   -= nTwipXCorr;
2386cdf0e10cSrcweir                 aPaintStart.Y() -= nTwipYCorr;
2387cdf0e10cSrcweir                 aPaintEnd.Y()   -= nTwipYCorr;
2388cdf0e10cSrcweir 
2389cdf0e10cSrcweir                 // Here comes the painting stuff: Thank you, DR, great job!!!
2390cdf0e10cSrcweir                 if ( bHori )
2391cdf0e10cSrcweir                 {
2392cdf0e10cSrcweir                     svx::frame::DrawHorFrameBorder
2393cdf0e10cSrcweir                     (
2394cdf0e10cSrcweir                         rDev,
2395cdf0e10cSrcweir                         aPaintStart,
2396cdf0e10cSrcweir                         aPaintEnd,
2397cdf0e10cSrcweir                         aStyles[ 0 ],   // current style
2398cdf0e10cSrcweir                         aStyles[ 1 ],   // aLFromT
2399cdf0e10cSrcweir                         aStyles[ 2 ],   // aLFromL
2400cdf0e10cSrcweir                         aStyles[ 3 ],   // aLFromB
2401cdf0e10cSrcweir                         aStyles[ 4 ],   // aRFromT
2402cdf0e10cSrcweir                         aStyles[ 5 ],   // aRFromR
2403cdf0e10cSrcweir                         aStyles[ 6 ],   // aRFromB
2404cdf0e10cSrcweir                         pTmpColor
2405cdf0e10cSrcweir                     );
2406cdf0e10cSrcweir                 }
2407cdf0e10cSrcweir                 else
2408cdf0e10cSrcweir                 {
2409cdf0e10cSrcweir                     svx::frame::DrawVerFrameBorder
2410cdf0e10cSrcweir                     (
2411cdf0e10cSrcweir                         rDev,
2412cdf0e10cSrcweir                         aPaintStart,
2413cdf0e10cSrcweir                         aPaintEnd,
2414cdf0e10cSrcweir                         aStyles[ 0 ],   // current style
2415cdf0e10cSrcweir                         aStyles[ 1 ],   // aTFromL
2416cdf0e10cSrcweir                         aStyles[ 2 ],   // aTFromT
2417cdf0e10cSrcweir                         aStyles[ 3 ],   // aTFromR
2418cdf0e10cSrcweir                         aStyles[ 4 ],   // aBFromL
2419cdf0e10cSrcweir                         aStyles[ 5 ],   // aBFromB
2420cdf0e10cSrcweir                         aStyles[ 6 ],   // aBFromR
2421cdf0e10cSrcweir                         pTmpColor
2422cdf0e10cSrcweir                     );
2423cdf0e10cSrcweir                 }
2424cdf0e10cSrcweir             }
2425cdf0e10cSrcweir 
2426cdf0e10cSrcweir             ++aSetIter;
2427cdf0e10cSrcweir         }
2428cdf0e10cSrcweir 
2429cdf0e10cSrcweir         ++aIter;
2430cdf0e10cSrcweir     }
2431cdf0e10cSrcweir 
2432cdf0e10cSrcweir     // restore output device:
2433cdf0e10cSrcweir     rDev.Pop();
2434cdf0e10cSrcweir     rDev.SetDrawMode( nOldDrawMode );
2435cdf0e10cSrcweir }
2436cdf0e10cSrcweir 
2437cdf0e10cSrcweir // Finds the lines that join the line defined by (StartPoint, EndPoint) in either
2438cdf0e10cSrcweir // StartPoint or Endpoint. The styles of these lines are required for DR's magic
2439cdf0e10cSrcweir // line painting functions.
FindStylesForLine(const Point & rStartPoint,const Point & rEndPoint,svx::frame::Style * pStyles,bool bHori) const2440cdf0e10cSrcweir void SwTabFrmPainter::FindStylesForLine( const Point& rStartPoint,
2441cdf0e10cSrcweir                                          const Point& rEndPoint,
2442cdf0e10cSrcweir                                          svx::frame::Style* pStyles,
2443cdf0e10cSrcweir                                          bool bHori ) const
2444cdf0e10cSrcweir {
2445cdf0e10cSrcweir     // pStyles[ 1 ] = bHori ? aLFromT : TFromL
2446cdf0e10cSrcweir     // pStyles[ 2 ] = bHori ? aLFromL : TFromT,
2447cdf0e10cSrcweir     // pStyles[ 3 ] = bHori ? aLFromB : TFromR,
2448cdf0e10cSrcweir     // pStyles[ 4 ] = bHori ? aRFromT : BFromL,
2449cdf0e10cSrcweir     // pStyles[ 5 ] = bHori ? aRFromR : BFromB,
2450cdf0e10cSrcweir     // pStyles[ 6 ] = bHori ? aRFromB : BFromR,
2451cdf0e10cSrcweir 
2452cdf0e10cSrcweir     SwLineEntryMapConstIter aMapIter = maVertLines.find( rStartPoint.X() );
2453cdf0e10cSrcweir     ASSERT( aMapIter != maVertLines.end(), "FindStylesForLine: Error" )
2454cdf0e10cSrcweir     const SwLineEntrySet& rVertSet = (*aMapIter).second;
2455cdf0e10cSrcweir     SwLineEntrySetConstIter aIter = rVertSet.begin();
2456cdf0e10cSrcweir 
2457cdf0e10cSrcweir     while ( aIter != rVertSet.end() )
2458cdf0e10cSrcweir     {
2459cdf0e10cSrcweir         const SwLineEntry& rEntry = *aIter;
2460cdf0e10cSrcweir         if ( bHori )
2461cdf0e10cSrcweir         {
2462cdf0e10cSrcweir             if ( rStartPoint.Y() == rEntry.mnStartPos )
2463cdf0e10cSrcweir                 pStyles[ 3 ] = rEntry.maAttribute;
2464cdf0e10cSrcweir             else if ( rStartPoint.Y() == rEntry.mnEndPos )
2465cdf0e10cSrcweir                 pStyles[ 1 ] = rEntry.maAttribute;
2466cdf0e10cSrcweir         }
2467cdf0e10cSrcweir         else
2468cdf0e10cSrcweir         {
2469cdf0e10cSrcweir             if ( rStartPoint.Y() == rEntry.mnEndPos )
2470cdf0e10cSrcweir                 pStyles[ 2 ] = rEntry.maAttribute;
2471cdf0e10cSrcweir             else if ( rEndPoint.Y() == rEntry.mnStartPos )
2472cdf0e10cSrcweir                 pStyles[ 5 ] = rEntry.maAttribute;
2473cdf0e10cSrcweir         }
2474cdf0e10cSrcweir         ++aIter;
2475cdf0e10cSrcweir     }
2476cdf0e10cSrcweir 
2477cdf0e10cSrcweir     aMapIter = maHoriLines.find( rStartPoint.Y() );
2478cdf0e10cSrcweir     ASSERT( aMapIter != maHoriLines.end(), "FindStylesForLine: Error" )
2479cdf0e10cSrcweir     const SwLineEntrySet& rHoriSet = (*aMapIter).second;
2480cdf0e10cSrcweir     aIter = rHoriSet.begin();
2481cdf0e10cSrcweir 
2482cdf0e10cSrcweir     while ( aIter != rHoriSet.end() )
2483cdf0e10cSrcweir     {
2484cdf0e10cSrcweir         const SwLineEntry& rEntry = *aIter;
2485cdf0e10cSrcweir         if ( bHori )
2486cdf0e10cSrcweir         {
2487cdf0e10cSrcweir             if ( rStartPoint.X() == rEntry.mnEndPos )
2488cdf0e10cSrcweir                 pStyles[ 2 ] = rEntry.maAttribute;
2489cdf0e10cSrcweir             else if ( rEndPoint.X() == rEntry.mnStartPos )
2490cdf0e10cSrcweir                 pStyles[ 5 ] = rEntry.maAttribute;
2491cdf0e10cSrcweir         }
2492cdf0e10cSrcweir         else
2493cdf0e10cSrcweir         {
2494cdf0e10cSrcweir             if ( rStartPoint.X() == rEntry.mnEndPos )
2495cdf0e10cSrcweir                 pStyles[ 1 ] = rEntry.maAttribute;
2496cdf0e10cSrcweir             else if ( rStartPoint.X() == rEntry.mnStartPos )
2497cdf0e10cSrcweir                 pStyles[ 3 ] = rEntry.maAttribute;
2498cdf0e10cSrcweir         }
2499cdf0e10cSrcweir         ++aIter;
2500cdf0e10cSrcweir     }
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir     if ( bHori )
2503cdf0e10cSrcweir     {
2504cdf0e10cSrcweir         aMapIter = maVertLines.find( rEndPoint.X() );
2505cdf0e10cSrcweir         ASSERT( aMapIter != maVertLines.end(), "FindStylesForLine: Error" )
2506cdf0e10cSrcweir         const SwLineEntrySet& rVertSet2 = (*aMapIter).second;
2507cdf0e10cSrcweir         aIter = rVertSet2.begin();
2508cdf0e10cSrcweir 
2509cdf0e10cSrcweir         while ( aIter != rVertSet2.end() )
2510cdf0e10cSrcweir         {
2511cdf0e10cSrcweir             const SwLineEntry& rEntry = *aIter;
2512cdf0e10cSrcweir             if ( rEndPoint.Y() == rEntry.mnStartPos )
2513cdf0e10cSrcweir                 pStyles[ 6 ] = rEntry.maAttribute;
2514cdf0e10cSrcweir             else if ( rEndPoint.Y() == rEntry.mnEndPos )
2515cdf0e10cSrcweir                 pStyles[ 4 ] = rEntry.maAttribute;
2516cdf0e10cSrcweir             ++aIter;
2517cdf0e10cSrcweir         }
2518cdf0e10cSrcweir     }
2519cdf0e10cSrcweir     else
2520cdf0e10cSrcweir     {
2521cdf0e10cSrcweir         aMapIter = maHoriLines.find( rEndPoint.Y() );
2522cdf0e10cSrcweir         ASSERT( aMapIter != maHoriLines.end(), "FindStylesForLine: Error" )
2523cdf0e10cSrcweir         const SwLineEntrySet& rHoriSet2 = (*aMapIter).second;
2524cdf0e10cSrcweir         aIter = rHoriSet2.begin();
2525cdf0e10cSrcweir 
2526cdf0e10cSrcweir         while ( aIter != rHoriSet2.end() )
2527cdf0e10cSrcweir         {
2528cdf0e10cSrcweir             const SwLineEntry& rEntry = *aIter;
2529cdf0e10cSrcweir             if ( rEndPoint.X() == rEntry.mnEndPos )
2530cdf0e10cSrcweir                 pStyles[ 4 ] = rEntry.maAttribute;
2531cdf0e10cSrcweir             else if ( rEndPoint.X() == rEntry.mnStartPos )
2532cdf0e10cSrcweir                 pStyles[ 6 ] = rEntry.maAttribute;
2533cdf0e10cSrcweir             ++aIter;
2534cdf0e10cSrcweir         }
2535cdf0e10cSrcweir     }
2536cdf0e10cSrcweir }
2537cdf0e10cSrcweir 
Insert(const SwFrm & rFrm,const SvxBoxItem & rBoxItem)2538cdf0e10cSrcweir void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
2539cdf0e10cSrcweir {
2540cdf0e10cSrcweir     std::vector< const SwFrm* > aTestVec;
2541cdf0e10cSrcweir     aTestVec.push_back( &rFrm );
2542cdf0e10cSrcweir     aTestVec.push_back( &rFrm );
2543cdf0e10cSrcweir     aTestVec.push_back( &rFrm );
2544cdf0e10cSrcweir 
2545cdf0e10cSrcweir     // build 4 line entries for the 4 borders:
2546cdf0e10cSrcweir     SwRect aBorderRect = rFrm.Frm();
2547cdf0e10cSrcweir     if ( rFrm.IsTabFrm() )
2548cdf0e10cSrcweir     {
2549cdf0e10cSrcweir         aBorderRect = rFrm.Prt();
2550cdf0e10cSrcweir         aBorderRect.Pos() += rFrm.Frm().Pos();
2551cdf0e10cSrcweir     }
2552cdf0e10cSrcweir 
2553cdf0e10cSrcweir     const SwTwips nLeft   = aBorderRect._Left();
2554cdf0e10cSrcweir     const SwTwips nRight  = aBorderRect._Right();
2555cdf0e10cSrcweir     const SwTwips nTop    = aBorderRect._Top();
2556cdf0e10cSrcweir     const SwTwips nBottom = aBorderRect._Bottom();
2557cdf0e10cSrcweir 
2558cdf0e10cSrcweir     svx::frame::Style aL( rBoxItem.GetLeft() );
2559cdf0e10cSrcweir     svx::frame::Style aR( rBoxItem.GetRight() );
2560cdf0e10cSrcweir     svx::frame::Style aT( rBoxItem.GetTop() );
2561cdf0e10cSrcweir     svx::frame::Style aB( rBoxItem.GetBottom() );
2562cdf0e10cSrcweir 
2563cdf0e10cSrcweir     aR.MirrorSelf();
2564cdf0e10cSrcweir     aB.MirrorSelf();
2565cdf0e10cSrcweir 
2566cdf0e10cSrcweir     bool bVert = mrTabFrm.IsVertical();
2567cdf0e10cSrcweir     bool bR2L  = mrTabFrm.IsRightToLeft();
2568cdf0e10cSrcweir 
2569cdf0e10cSrcweir     aL.SetRefMode( svx::frame::REFMODE_CENTERED );
2570cdf0e10cSrcweir     aR.SetRefMode( svx::frame::REFMODE_CENTERED );
2571cdf0e10cSrcweir     aT.SetRefMode( !bVert ? svx::frame::REFMODE_BEGIN : svx::frame::REFMODE_END );
2572cdf0e10cSrcweir     aB.SetRefMode( !bVert ? svx::frame::REFMODE_BEGIN : svx::frame::REFMODE_END );
2573cdf0e10cSrcweir 
2574cdf0e10cSrcweir     SwLineEntry aLeft  ( nLeft,   nTop,  nBottom, bVert ? aB : ( bR2L ? aR : aL ) );
2575cdf0e10cSrcweir     SwLineEntry aRight ( nRight,  nTop,  nBottom, bVert ? aT : ( bR2L ? aL : aR ) );
2576cdf0e10cSrcweir     SwLineEntry aTop   ( nTop,    nLeft, nRight,  bVert ? aL : aT );
2577cdf0e10cSrcweir     SwLineEntry aBottom( nBottom, nLeft, nRight,  bVert ? aR : aB );
2578cdf0e10cSrcweir 
2579cdf0e10cSrcweir     Insert( aLeft, false );
2580cdf0e10cSrcweir     Insert( aRight, false );
2581cdf0e10cSrcweir     Insert( aTop, true );
2582cdf0e10cSrcweir     Insert( aBottom, true );
2583cdf0e10cSrcweir 
2584cdf0e10cSrcweir     const SwRowFrm* pThisRowFrm = dynamic_cast<const SwRowFrm*>(rFrm.GetUpper());
2585cdf0e10cSrcweir 
2586cdf0e10cSrcweir     // special case: #i9860#
2587cdf0e10cSrcweir     // first line in follow table without repeated headlines
2588cdf0e10cSrcweir     if ( pThisRowFrm &&
2589cdf0e10cSrcweir          pThisRowFrm->GetUpper() == &mrTabFrm &&
2590cdf0e10cSrcweir          mrTabFrm.IsFollow() &&
2591cdf0e10cSrcweir         !mrTabFrm.GetTable()->GetRowsToRepeat() &&
2592cdf0e10cSrcweir         (!pThisRowFrm->GetPrev() || static_cast<const SwRowFrm*>(pThisRowFrm->GetPrev())->IsRowSpanLine()) &&
2593cdf0e10cSrcweir         !rBoxItem.GetTop() &&
2594cdf0e10cSrcweir          rBoxItem.GetBottom() )
2595cdf0e10cSrcweir     {
2596cdf0e10cSrcweir         SwLineEntry aFollowTop( !bVert ? nTop : nRight, !bVert ? nLeft : nTop, !bVert ? nRight : nBottom, aB );
2597cdf0e10cSrcweir         Insert( aFollowTop, !bVert );
2598cdf0e10cSrcweir     }
2599cdf0e10cSrcweir }
2600cdf0e10cSrcweir 
Insert(SwLineEntry & rNew,bool bHori)2601cdf0e10cSrcweir void SwTabFrmPainter::Insert( SwLineEntry& rNew, bool bHori )
2602cdf0e10cSrcweir {
2603cdf0e10cSrcweir     // get all lines from structure, that have key entry of pLE
2604cdf0e10cSrcweir     SwLineEntryMap* pLine2 = bHori ? &maHoriLines : &maVertLines;
2605cdf0e10cSrcweir     const SwTwips nKey = rNew.mnKey;
2606cdf0e10cSrcweir     SwLineEntryMapIter aMapIter = pLine2->find( nKey );
2607cdf0e10cSrcweir 
2608cdf0e10cSrcweir     SwLineEntrySet* pLineSet = aMapIter != pLine2->end() ? &((*aMapIter).second) : 0;
2609cdf0e10cSrcweir     if ( !pLineSet )
2610cdf0e10cSrcweir     {
2611cdf0e10cSrcweir         SwLineEntrySet aNewSet;
2612cdf0e10cSrcweir         (*pLine2)[ nKey ] = aNewSet;
2613cdf0e10cSrcweir         pLineSet = &(*pLine2)[ nKey ];
2614cdf0e10cSrcweir     }
2615cdf0e10cSrcweir     SwLineEntrySetIter aIter = pLineSet->begin();
2616cdf0e10cSrcweir 
2617cdf0e10cSrcweir     while ( pLineSet && aIter != pLineSet->end() && rNew.mnStartPos < rNew.mnEndPos )
2618cdf0e10cSrcweir     {
2619cdf0e10cSrcweir         const SwLineEntry& rOld = *aIter;
2620cdf0e10cSrcweir         const SwLineEntry::OverlapType nOverlapType = rOld.Overlaps( rNew );
2621cdf0e10cSrcweir 
2622cdf0e10cSrcweir         const svx::frame::Style& rOldAttr = rOld.maAttribute;
2623cdf0e10cSrcweir         const svx::frame::Style& rNewAttr = rNew.maAttribute;
2624cdf0e10cSrcweir         const svx::frame::Style& rCmpAttr = rNewAttr > rOldAttr ? rNewAttr : rOldAttr;
2625cdf0e10cSrcweir 
2626cdf0e10cSrcweir         if ( SwLineEntry::OVERLAP1 == nOverlapType )
2627cdf0e10cSrcweir         {
2628cdf0e10cSrcweir             ASSERT( rNew.mnStartPos >= rOld.mnStartPos, "Overlap type 3? How this?" )
2629cdf0e10cSrcweir 
2630cdf0e10cSrcweir             // new left segment
2631cdf0e10cSrcweir             const SwLineEntry aLeft( nKey, rOld.mnStartPos, rNew.mnStartPos, rOldAttr );
2632cdf0e10cSrcweir 
2633cdf0e10cSrcweir             // new middle segment
2634cdf0e10cSrcweir             const SwLineEntry aMiddle( nKey, rNew.mnStartPos, rOld.mnEndPos, rCmpAttr );
2635cdf0e10cSrcweir 
2636cdf0e10cSrcweir             // new right segment
2637cdf0e10cSrcweir             rNew.mnStartPos = rOld.mnEndPos;
2638cdf0e10cSrcweir 
2639cdf0e10cSrcweir             // update current lines set
2640cdf0e10cSrcweir             pLineSet->erase( aIter );
2641cdf0e10cSrcweir             if ( aLeft.mnStartPos   < aLeft.mnEndPos   ) pLineSet->insert( aLeft );
2642cdf0e10cSrcweir             if ( aMiddle.mnStartPos < aMiddle.mnEndPos ) pLineSet->insert( aMiddle );
2643cdf0e10cSrcweir 
2644cdf0e10cSrcweir             aIter = pLineSet->begin();
2645cdf0e10cSrcweir 
2646cdf0e10cSrcweir             continue; // start over
2647cdf0e10cSrcweir         }
2648cdf0e10cSrcweir         else if ( SwLineEntry::OVERLAP2 == nOverlapType )
2649cdf0e10cSrcweir         {
2650cdf0e10cSrcweir             // new left segment
2651cdf0e10cSrcweir             const SwLineEntry aLeft( nKey, rOld.mnStartPos, rNew.mnStartPos, rOldAttr );
2652cdf0e10cSrcweir 
2653cdf0e10cSrcweir             // new middle segment
2654cdf0e10cSrcweir             const SwLineEntry aMiddle( nKey, rNew.mnStartPos, rNew.mnEndPos, rCmpAttr );
2655cdf0e10cSrcweir 
2656cdf0e10cSrcweir             // new right segment
2657cdf0e10cSrcweir             const SwLineEntry aRight( nKey, rNew.mnEndPos, rOld.mnEndPos, rOldAttr );
2658cdf0e10cSrcweir 
2659cdf0e10cSrcweir             // update current lines set
2660cdf0e10cSrcweir             pLineSet->erase( aIter );
2661cdf0e10cSrcweir             if ( aLeft.mnStartPos < aLeft.mnEndPos ) pLineSet->insert( aLeft );
2662cdf0e10cSrcweir             if ( aMiddle.mnStartPos < aMiddle.mnEndPos ) pLineSet->insert( aMiddle );
2663cdf0e10cSrcweir             if ( aRight.mnStartPos < aRight.mnEndPos ) pLineSet->insert( aRight );
2664cdf0e10cSrcweir 
2665cdf0e10cSrcweir             rNew.mnStartPos = rNew.mnEndPos; // rNew should not be inserted!
2666cdf0e10cSrcweir 
2667cdf0e10cSrcweir             break; // we are finished
2668cdf0e10cSrcweir         }
2669cdf0e10cSrcweir         else if ( SwLineEntry::OVERLAP3 == nOverlapType )
2670cdf0e10cSrcweir         {
2671cdf0e10cSrcweir             // new left segment
2672cdf0e10cSrcweir             const SwLineEntry aLeft( nKey, rNew.mnStartPos, rOld.mnStartPos, rNewAttr );
2673cdf0e10cSrcweir 
2674cdf0e10cSrcweir             // new middle segment
2675cdf0e10cSrcweir             const SwLineEntry aMiddle( nKey, rOld.mnStartPos, rNew.mnEndPos, rCmpAttr );
2676cdf0e10cSrcweir 
2677cdf0e10cSrcweir             // new right segment
2678cdf0e10cSrcweir             const SwLineEntry aRight( nKey, rNew.mnEndPos, rOld.mnEndPos, rOldAttr );
2679cdf0e10cSrcweir 
2680cdf0e10cSrcweir             // update current lines set
2681cdf0e10cSrcweir             pLineSet->erase( aIter );
2682cdf0e10cSrcweir             if ( aLeft.mnStartPos < aLeft.mnEndPos ) pLineSet->insert( aLeft );
2683cdf0e10cSrcweir             if ( aMiddle.mnStartPos < aMiddle.mnEndPos ) pLineSet->insert( aMiddle );
2684cdf0e10cSrcweir             if ( aRight.mnStartPos < aRight.mnEndPos ) pLineSet->insert( aRight );
2685cdf0e10cSrcweir 
2686cdf0e10cSrcweir             rNew.mnStartPos = rNew.mnEndPos; // rNew should not be inserted!
2687cdf0e10cSrcweir 
2688cdf0e10cSrcweir             break; // we are finished
2689cdf0e10cSrcweir         }
2690cdf0e10cSrcweir 
2691cdf0e10cSrcweir         ++aIter;
2692cdf0e10cSrcweir     }
2693cdf0e10cSrcweir 
2694cdf0e10cSrcweir     if ( rNew.mnStartPos < rNew.mnEndPos ) // insert rest
2695cdf0e10cSrcweir         pLineSet->insert( rNew );
2696cdf0e10cSrcweir }
2697cdf0e10cSrcweir 
2698cdf0e10cSrcweir //
2699cdf0e10cSrcweir // FUNCTIONS USED FOR COLLAPSING TABLE BORDER LINES END
2700cdf0e10cSrcweir //
2701cdf0e10cSrcweir 
2702cdf0e10cSrcweir // --> OD #i76669#
2703cdf0e10cSrcweir namespace
2704cdf0e10cSrcweir {
2705cdf0e10cSrcweir     class SwViewObjectContactRedirector : public ::sdr::contact::ViewObjectContactRedirector
2706cdf0e10cSrcweir     {
2707cdf0e10cSrcweir         private:
2708cdf0e10cSrcweir             const ViewShell& mrViewShell;
2709cdf0e10cSrcweir 
2710cdf0e10cSrcweir         public:
SwViewObjectContactRedirector(const ViewShell & rSh)2711cdf0e10cSrcweir             SwViewObjectContactRedirector( const ViewShell& rSh )
2712cdf0e10cSrcweir                 : mrViewShell( rSh )
2713cdf0e10cSrcweir             {};
2714cdf0e10cSrcweir 
~SwViewObjectContactRedirector()2715cdf0e10cSrcweir             virtual ~SwViewObjectContactRedirector()
2716cdf0e10cSrcweir             {}
2717cdf0e10cSrcweir 
createRedirectedPrimitive2DSequence(const sdr::contact::ViewObjectContact & rOriginal,const sdr::contact::DisplayInfo & rDisplayInfo)2718cdf0e10cSrcweir             virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
2719cdf0e10cSrcweir                                     const sdr::contact::ViewObjectContact& rOriginal,
2720cdf0e10cSrcweir                                     const sdr::contact::DisplayInfo& rDisplayInfo)
2721cdf0e10cSrcweir             {
2722cdf0e10cSrcweir                 sal_Bool bPaint( sal_True );
2723cdf0e10cSrcweir 
2724cdf0e10cSrcweir                 SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
2725cdf0e10cSrcweir                 if ( pObj )
2726cdf0e10cSrcweir                 {
2727cdf0e10cSrcweir                     bPaint = SwFlyFrm::IsPaint( pObj, &mrViewShell );
2728cdf0e10cSrcweir                 }
2729cdf0e10cSrcweir 
2730cdf0e10cSrcweir                 if ( !bPaint )
2731cdf0e10cSrcweir                 {
2732cdf0e10cSrcweir                     return drawinglayer::primitive2d::Primitive2DSequence();
2733cdf0e10cSrcweir                 }
2734cdf0e10cSrcweir 
2735cdf0e10cSrcweir                 return sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
2736cdf0e10cSrcweir                                                         rOriginal, rDisplayInfo );
2737cdf0e10cSrcweir             }
2738cdf0e10cSrcweir     };
27390272ccd2Smseidel 
27400272ccd2Smseidel } // end of anonymous namespace
2741cdf0e10cSrcweir // <--
2742cdf0e10cSrcweir 
2743cdf0e10cSrcweir /*************************************************************************
2744cdf0e10cSrcweir |*
2745cdf0e10cSrcweir |*	SwRootFrm::Paint()
2746cdf0e10cSrcweir |*
2747cdf0e10cSrcweir |*	Beschreibung
2748cdf0e10cSrcweir |*		Fuer jede sichtbare Seite, die von Rect ber?hrt wird einmal Painten.
2749cdf0e10cSrcweir |*		1. Umrandungen und Hintergruende Painten.
2750cdf0e10cSrcweir |*		2. Den Draw Layer (Ramen und Zeichenobjekte) der unter dem Dokument
2751cdf0e10cSrcweir |* 		   liegt painten (Hoelle).
2752cdf0e10cSrcweir |*		3. Den Dokumentinhalt (Text) Painten.
2753cdf0e10cSrcweir |*		4. Den Drawlayer der ueber dem Dokuemnt liegt painten.
2754cdf0e10cSrcweir |*
2755cdf0e10cSrcweir |*	Ersterstellung		MA 01. Jun. 92
2756cdf0e10cSrcweir |*	Letzte Aenderung	MA 10. Oct. 97
2757cdf0e10cSrcweir |*
2758cdf0e10cSrcweir |*************************************************************************/
2759cdf0e10cSrcweir 
2760cdf0e10cSrcweir void
Paint(SwRect const & rRect,SwPrintData const * const pPrintData) const2761cdf0e10cSrcweir SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
2762cdf0e10cSrcweir {
2763cdf0e10cSrcweir     ASSERT( Lower() && Lower()->IsPageFrm(), "Lower der Root keine Seite." );
2764cdf0e10cSrcweir 
2765cdf0e10cSrcweir 	PROTOCOL( this, PROT_FILE_INIT, 0, 0)
2766cdf0e10cSrcweir 
2767cdf0e10cSrcweir 	sal_Bool bResetRootPaint = sal_False;
2768cdf0e10cSrcweir 	ViewShell *pSh = pCurrShell;
2769cdf0e10cSrcweir 
2770cdf0e10cSrcweir 	if ( pSh->GetWin() )
2771cdf0e10cSrcweir 	{
2772cdf0e10cSrcweir 		if ( pSh->GetOut() == pSh->GetWin() && !pSh->GetWin()->IsVisible() )
2773cdf0e10cSrcweir 		{
2774cdf0e10cSrcweir 			return;
2775cdf0e10cSrcweir 		}
2776cdf0e10cSrcweir 		if ( SwRootFrm::bInPaint )
2777cdf0e10cSrcweir 		{
2778cdf0e10cSrcweir 			SwPaintQueue::Add( pSh, rRect );
2779cdf0e10cSrcweir 			return;
2780cdf0e10cSrcweir 		}
2781cdf0e10cSrcweir 	}
2782cdf0e10cSrcweir 	else
2783cdf0e10cSrcweir 		SwRootFrm::bInPaint = bResetRootPaint = sal_True;
2784cdf0e10cSrcweir 
2785cdf0e10cSrcweir 	SwSavePaintStatics *pStatics = 0;
2786cdf0e10cSrcweir 	if ( pGlobalShell )
2787cdf0e10cSrcweir 		pStatics = new SwSavePaintStatics();
2788cdf0e10cSrcweir 	pGlobalShell = pSh;
2789cdf0e10cSrcweir 
2790cdf0e10cSrcweir     if( !pSh->GetWin() )
2791cdf0e10cSrcweir 		pProgress = SfxProgress::GetActiveProgress( (SfxObjectShell*) pSh->GetDoc()->GetDocShell() );
2792cdf0e10cSrcweir 
2793cdf0e10cSrcweir 	::SwCalcPixStatics( pSh->GetOut() );
2794cdf0e10cSrcweir 	aGlobalRetoucheColor = pSh->Imp()->GetRetoucheColor();
2795cdf0e10cSrcweir 
2796cdf0e10cSrcweir 	//Ggf. eine Action ausloesen um klare Verhaeltnisse zu schaffen.
2797cdf0e10cSrcweir 	//Durch diesen Kunstgriff kann in allen Paints davon ausgegangen werden,
2798cdf0e10cSrcweir 	//das alle Werte gueltigt sind - keine Probleme, keine Sonderbehandlung(en).
2799cdf0e10cSrcweir     // --> OD 2008-10-07 #i92745#
2800cdf0e10cSrcweir     // Extend check on certain states of the 'current' <ViewShell> instance to
2801cdf0e10cSrcweir     // all existing <ViewShell> instances.
2802cdf0e10cSrcweir     bool bPerformLayoutAction( true );
2803cdf0e10cSrcweir     {
2804cdf0e10cSrcweir         ViewShell* pTmpViewShell = pSh;
2805cdf0e10cSrcweir         do {
2806cdf0e10cSrcweir             if ( pTmpViewShell->IsInEndAction() ||
2807cdf0e10cSrcweir                  pTmpViewShell->IsPaintInProgress() ||
2808cdf0e10cSrcweir                  ( pTmpViewShell->Imp()->IsAction() &&
2809cdf0e10cSrcweir                    pTmpViewShell->Imp()->GetLayAction().IsActionInProgress() ) )
2810cdf0e10cSrcweir             {
2811cdf0e10cSrcweir                 bPerformLayoutAction = false;
2812cdf0e10cSrcweir             }
2813cdf0e10cSrcweir 
2814cdf0e10cSrcweir             pTmpViewShell = static_cast<ViewShell*>(pTmpViewShell->GetNext());
2815cdf0e10cSrcweir         } while ( bPerformLayoutAction && pTmpViewShell != pSh );
2816cdf0e10cSrcweir     }
2817cdf0e10cSrcweir     if ( bPerformLayoutAction )
2818cdf0e10cSrcweir     // <--
2819cdf0e10cSrcweir     {
2820cdf0e10cSrcweir 		((SwRootFrm*)this)->ResetTurbo();
2821cdf0e10cSrcweir 		SwLayAction aAction( (SwRootFrm*)this, pSh->Imp() );
2822cdf0e10cSrcweir 		aAction.SetPaint( sal_False );
2823cdf0e10cSrcweir 		aAction.SetComplete( sal_False );
2824cdf0e10cSrcweir 		aAction.SetReschedule( pProgress ? sal_True : sal_False );
2825cdf0e10cSrcweir 		aAction.Action();
2826cdf0e10cSrcweir 		((SwRootFrm*)this)->ResetTurboFlag();
2827cdf0e10cSrcweir 		if ( !pSh->ActionPend() )
2828cdf0e10cSrcweir             pSh->Imp()->DelRegion();
2829cdf0e10cSrcweir 	}
2830cdf0e10cSrcweir 
2831cdf0e10cSrcweir 	SwRect aRect( rRect );
2832cdf0e10cSrcweir     aRect.Intersection( pSh->VisArea() );
2833cdf0e10cSrcweir 
2834cdf0e10cSrcweir     const sal_Bool bExtraData = ::IsExtraData( GetFmt()->GetDoc() );
2835cdf0e10cSrcweir 
2836cdf0e10cSrcweir 	pLines = new SwLineRects;	//Sammler fuer Umrandungen.
2837cdf0e10cSrcweir 
2838cdf0e10cSrcweir     // #104289#. During painting, something (OLE) can
2839cdf0e10cSrcweir     // load the linguistic, which in turn can cause a reformat
2840cdf0e10cSrcweir     // of the document. Dangerous! We better set this flag to
2841cdf0e10cSrcweir     // avoid the reformat.
2842cdf0e10cSrcweir     const sal_Bool bOldAction = IsCallbackActionEnabled();
2843cdf0e10cSrcweir     ((SwRootFrm*)this)->SetCallbackActionEnabled( sal_False );
2844cdf0e10cSrcweir 
2845cdf0e10cSrcweir 	const SwPageFrm *pPage = pSh->Imp()->GetFirstVisPage();
2846cdf0e10cSrcweir 
2847cdf0e10cSrcweir     const bool bBookMode = pGlobalShell->GetViewOptions()->IsViewLayoutBookMode();
2848cdf0e10cSrcweir     if ( bBookMode && pPage->GetPrev() && static_cast<const SwPageFrm*>(pPage->GetPrev())->IsEmptyPage() )
2849cdf0e10cSrcweir         pPage = static_cast<const SwPageFrm*>(pPage->GetPrev());
2850cdf0e10cSrcweir 
2851cdf0e10cSrcweir     const bool bLTR = IsLeftToRightViewLayout();
2852cdf0e10cSrcweir 
2853cdf0e10cSrcweir 	// #i68597#
2854cdf0e10cSrcweir 	const bool bGridPainting(pSh->GetWin() && pSh->Imp()->HasDrawView() && pSh->Imp()->GetDrawView()->IsGridVisible());
2855cdf0e10cSrcweir 
2856cdf0e10cSrcweir     // --> OD #i76669#
2857cdf0e10cSrcweir     SwViewObjectContactRedirector aSwRedirector( *pSh );
2858cdf0e10cSrcweir     // <--
2859cdf0e10cSrcweir 
2860cdf0e10cSrcweir     while ( pPage )
2861cdf0e10cSrcweir     {
2862120ba445Smseidel         const bool bPaintRightShadow =  !bBookMode || (pPage == Lower()) || (!bLTR && !pPage->OnRightPage()) || (bLTR && pPage->OnRightPage());
2863cdf0e10cSrcweir         const bool bRightSidebar = pPage->SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT;
2864cdf0e10cSrcweir 
2865cdf0e10cSrcweir         if ( !pPage->IsEmptyPage() )
2866cdf0e10cSrcweir         {
2867cdf0e10cSrcweir             SwRect aPaintRect;
2868cdf0e10cSrcweir             SwPageFrm::GetBorderAndShadowBoundRect( pPage->Frm(), pSh, aPaintRect, bRightSidebar );
2869cdf0e10cSrcweir 
2870cdf0e10cSrcweir             if ( aRect.IsOver( aPaintRect ) )
2871cdf0e10cSrcweir             {
2872cdf0e10cSrcweir                 if ( pSh->GetWin() )
2873cdf0e10cSrcweir                 {
2874cdf0e10cSrcweir                     pSubsLines = new SwSubsRects;
2875cdf0e10cSrcweir                     pSpecSubsLines = new SwSubsRects;
2876cdf0e10cSrcweir                 }
2877cdf0e10cSrcweir 
2878cdf0e10cSrcweir                 aPaintRect._Intersection( aRect );
2879cdf0e10cSrcweir 
2880cdf0e10cSrcweir                 // --> OD 2007-11-14 #i82616#
2881cdf0e10cSrcweir                 // Invalidate area for extra data (line numbers or change tracking
2882cdf0e10cSrcweir                 // marks), if painting on a window and the paint is trigger by an
2883cdf0e10cSrcweir                 // end action. The inefficient and simple enlargement of the
2884cdf0e10cSrcweir                 // paint area is replaced by this invalidation.
2885cdf0e10cSrcweir                 if ( bExtraData &&
2886cdf0e10cSrcweir                      pSh->GetWin() && pSh->IsInEndAction() )
2887cdf0e10cSrcweir                 {
2888cdf0e10cSrcweir                     // enlarge paint rectangle to complete page width, subtract
2889cdf0e10cSrcweir                     // current paint area and invalidate the resulting region.
2890cdf0e10cSrcweir                     SWRECTFN( pPage )
2891cdf0e10cSrcweir                     SwRect aPageRectTemp( aPaintRect );
2892cdf0e10cSrcweir                     (aPageRectTemp.*fnRect->fnSetLeftAndWidth)(
2893cdf0e10cSrcweir                          (pPage->Frm().*fnRect->fnGetLeft)(),
2894cdf0e10cSrcweir                          (pPage->Frm().*fnRect->fnGetWidth)() );
2895cdf0e10cSrcweir                     aPageRectTemp._Intersection( pSh->VisArea() );
2896cdf0e10cSrcweir                     Region aPageRectRegion( aPageRectTemp.SVRect() );
2897cdf0e10cSrcweir                     aPageRectRegion.Exclude( aPaintRect.SVRect() );
2898cdf0e10cSrcweir                     pSh->GetWin()->Invalidate( aPageRectRegion, INVALIDATE_CHILDREN );
2899cdf0e10cSrcweir                 }
2900cdf0e10cSrcweir                 // <--
2901cdf0e10cSrcweir 
2902cdf0e10cSrcweir                 // --> OD 2007-08-20 #i80793#
2903cdf0e10cSrcweir                 // enlarge paint rectangle for objects overlapping the same pixel
2904cdf0e10cSrcweir                 // in all cases and before the DrawingLayer overlay is initialized.
2905cdf0e10cSrcweir                 lcl_AdjustRectToPixelSize( aPaintRect, *(pSh->GetOut()) );
2906cdf0e10cSrcweir                 // <--
2907cdf0e10cSrcweir 
2908cdf0e10cSrcweir                 // #i68597#
2909cdf0e10cSrcweir                 // moved paint pre-process for DrawingLayer overlay here since the above
2910cdf0e10cSrcweir                 // code dependent from bExtraData may expand the PaintRect
2911cdf0e10cSrcweir                 {
2912cdf0e10cSrcweir                     // #i75172# if called from ViewShell::ImplEndAction it sould no longer
2913cdf0e10cSrcweir                     // really be used but handled by ViewShell::ImplEndAction already
2914cdf0e10cSrcweir                     const Region aDLRegion(aPaintRect.SVRect());
2915cdf0e10cSrcweir                     pSh->DLPrePaint2(aDLRegion);
2916cdf0e10cSrcweir                 }
2917cdf0e10cSrcweir 
2918cdf0e10cSrcweir                 if(OUTDEV_WINDOW == pGlobalShell->GetOut()->GetOutDevType())
2919cdf0e10cSrcweir                 {
2920cdf0e10cSrcweir                     /// OD 27.09.2002 #103636# - changed method SwLayVout::Enter(..)
2921cdf0e10cSrcweir                     /// 2nd parameter is no longer <const> and will be set to the
2922cdf0e10cSrcweir                     /// rectangle the virtual output device is calculated from <aPaintRect>,
2923cdf0e10cSrcweir                     /// if the virtual output is used.
2924cdf0e10cSrcweir                     pVout->Enter( pSh, aPaintRect, !bNoVirDev );
2925cdf0e10cSrcweir 
2926cdf0e10cSrcweir                     /// OD 27.09.2002 #103636# - adjust paint rectangle to pixel size
2927cdf0e10cSrcweir                     /// Thus, all objects overlapping on pixel level with the unadjusted
2928cdf0e10cSrcweir                     /// paint rectangle will be considered in the paint.
2929cdf0e10cSrcweir                     lcl_AdjustRectToPixelSize( aPaintRect, *(pSh->GetOut()) );
2930cdf0e10cSrcweir                 }
2931cdf0e10cSrcweir 
2932cdf0e10cSrcweir                 // maybe this can be put in the above scope. Since we are not sure, just leave it ATM
2933cdf0e10cSrcweir                 pVout->SetOrgRect( aPaintRect );
2934cdf0e10cSrcweir 
2935cdf0e10cSrcweir                 /// OD 29.08.2002 #102450#
2936cdf0e10cSrcweir                 /// determine background color of page for <PaintLayer> method
2937cdf0e10cSrcweir                 /// calls, paint <hell> or <heaven>
2938cdf0e10cSrcweir                 const Color aPageBackgrdColor = pPage->GetDrawBackgrdColor();
2939cdf0e10cSrcweir 
2940cdf0e10cSrcweir                 pPage->PaintBaBo( aPaintRect, pPage, sal_True );
2941cdf0e10cSrcweir 
2942cdf0e10cSrcweir                 if ( pSh->Imp()->HasDrawView() )
2943cdf0e10cSrcweir                 {
2944cdf0e10cSrcweir                     pLines->LockLines( sal_True );
2945cdf0e10cSrcweir                     const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess();
29460272ccd2Smseidel                     pSh->Imp()->PaintLayer( pIDDMA->GetHellId(),
29470272ccd2Smseidel                                             pPrintData,
2948cdf0e10cSrcweir                                             aPaintRect,
29490272ccd2Smseidel                                             &aPageBackgrdColor,
2950cdf0e10cSrcweir                                             (pPage->IsRightToLeft() ? true : false),
2951cdf0e10cSrcweir                                             &aSwRedirector );
2952cdf0e10cSrcweir                     pLines->PaintLines( pSh->GetOut() );
2953cdf0e10cSrcweir                     pLines->LockLines( sal_False );
2954cdf0e10cSrcweir                 }
2955cdf0e10cSrcweir 
2956cdf0e10cSrcweir                 if( pSh->GetWin() )
2957cdf0e10cSrcweir                 {
2958cdf0e10cSrcweir                     // collect sub-lines
2959cdf0e10cSrcweir                     pPage->RefreshSubsidiary( aPaintRect );
2960cdf0e10cSrcweir                     // paint special sub-lines
2961cdf0e10cSrcweir                     pSpecSubsLines->PaintSubsidiary( pSh->GetOut(), NULL );
2962cdf0e10cSrcweir                 }
2963cdf0e10cSrcweir 
2964cdf0e10cSrcweir                 pPage->Paint( aPaintRect );
2965cdf0e10cSrcweir 
2966cdf0e10cSrcweir                 // no paint of page border and shadow, if writer is in place mode.
2967cdf0e10cSrcweir                 if( pSh->GetWin() && pSh->GetDoc()->GetDocShell() &&
2968cdf0e10cSrcweir                     !pSh->GetDoc()->GetDocShell()->IsInPlaceActive() )
2969cdf0e10cSrcweir                 {
2970cdf0e10cSrcweir                     SwPageFrm::PaintBorderAndShadow( pPage->Frm(), pSh, bPaintRightShadow, bRightSidebar );
2971cdf0e10cSrcweir                     SwPageFrm::PaintNotesSidebar( pPage->Frm(), pSh, pPage->GetPhyPageNum(), bRightSidebar);
2972cdf0e10cSrcweir                 }
2973cdf0e10cSrcweir 
2974cdf0e10cSrcweir                 pLines->PaintLines( pSh->GetOut() );
2975cdf0e10cSrcweir 
2976cdf0e10cSrcweir                 if ( pSh->Imp()->HasDrawView() )
2977cdf0e10cSrcweir                 {
2978cdf0e10cSrcweir                     /// OD 29.08.2002 #102450# - add 3rd parameter
2979cdf0e10cSrcweir                     // OD 09.12.2002 #103045# - add 4th parameter for horizontal text direction.
29800272ccd2Smseidel                     pSh->Imp()->PaintLayer( pSh->GetDoc()->GetHeavenId(),
29810272ccd2Smseidel                                             pPrintData,
2982cdf0e10cSrcweir                                             aPaintRect,
2983cdf0e10cSrcweir                                             &aPageBackgrdColor,
2984cdf0e10cSrcweir                                             (pPage->IsRightToLeft() ? true : false),
2985cdf0e10cSrcweir                                             &aSwRedirector );
2986cdf0e10cSrcweir                 }
2987cdf0e10cSrcweir 
2988cdf0e10cSrcweir                 if ( bExtraData )
2989cdf0e10cSrcweir                     pPage->RefreshExtraData( aPaintRect );
2990cdf0e10cSrcweir 
2991cdf0e10cSrcweir                 if ( pSh->GetWin() )
2992cdf0e10cSrcweir                 {
2993cdf0e10cSrcweir                     pSubsLines->PaintSubsidiary( pSh->GetOut(), pLines );
2994cdf0e10cSrcweir                     DELETEZ( pSubsLines );
2995cdf0e10cSrcweir                     DELETEZ( pSpecSubsLines );
2996cdf0e10cSrcweir                 }
2997cdf0e10cSrcweir                 pVout->Leave();
2998cdf0e10cSrcweir 
2999cdf0e10cSrcweir                 // #i68597#
3000cdf0e10cSrcweir                 // needed to move grid painting inside Begin/EndDrawLayer bounds and to change
3001cdf0e10cSrcweir                 // output rect for it accordingly
3002cdf0e10cSrcweir                 if(bGridPainting)
3003cdf0e10cSrcweir                 {
3004cdf0e10cSrcweir                     SdrPaintView* pPaintView = pSh->Imp()->GetDrawView();
3005cdf0e10cSrcweir                     SdrPageView* pPageView = pPaintView->GetSdrPageView();
3006cdf0e10cSrcweir                     pPageView->DrawPageViewGrid(*pSh->GetOut(), aPaintRect.SVRect(), SwViewOption::GetTextGridColor() );
3007cdf0e10cSrcweir                 }
3008cdf0e10cSrcweir 
3009cdf0e10cSrcweir                 // #i68597#
3010cdf0e10cSrcweir                 // moved paint post-process for DrawingLayer overlay here, see above
3011cdf0e10cSrcweir                 {
3012cdf0e10cSrcweir                     pSh->DLPostPaint2(true);
3013cdf0e10cSrcweir                 }
3014cdf0e10cSrcweir             }
3015cdf0e10cSrcweir         }
3016cdf0e10cSrcweir         else if ( bBookMode && pSh->GetWin() && !pSh->GetDoc()->GetDocShell()->IsInPlaceActive() )
3017cdf0e10cSrcweir         {
3018cdf0e10cSrcweir             // paint empty page
3019cdf0e10cSrcweir             SwRect aPaintRect;
3020cdf0e10cSrcweir             SwRect aEmptyPageRect( pPage->Frm() );
3021cdf0e10cSrcweir 
3022cdf0e10cSrcweir             // code from vprint.cxx
3023cdf0e10cSrcweir             const SwPageFrm& rFormatPage = pPage->GetFormatPage();
3024cdf0e10cSrcweir             aEmptyPageRect.SSize() = rFormatPage.Frm().SSize();
3025cdf0e10cSrcweir 
3026cdf0e10cSrcweir             SwPageFrm::GetBorderAndShadowBoundRect( aEmptyPageRect, pSh, aPaintRect, bRightSidebar );
3027cdf0e10cSrcweir             aPaintRect._Intersection( aRect );
3028cdf0e10cSrcweir 
3029cdf0e10cSrcweir             if ( aRect.IsOver( aEmptyPageRect ) )
3030cdf0e10cSrcweir             {
3031cdf0e10cSrcweir                 // #i75172# if called from ViewShell::ImplEndAction it sould no longer
3032cdf0e10cSrcweir                 // really be used but handled by ViewShell::ImplEndAction already
3033cdf0e10cSrcweir                 {
3034cdf0e10cSrcweir                     const Region aDLRegion(aPaintRect.SVRect());
3035cdf0e10cSrcweir                     pSh->DLPrePaint2(aDLRegion);
3036cdf0e10cSrcweir                 }
3037cdf0e10cSrcweir 
3038cdf0e10cSrcweir                 if( pSh->GetOut()->GetFillColor() != aGlobalRetoucheColor )
3039cdf0e10cSrcweir                     pSh->GetOut()->SetFillColor( aGlobalRetoucheColor );
3040cdf0e10cSrcweir 
3041cdf0e10cSrcweir                 pSh->GetOut()->SetLineColor(); // OD 20.02.2003 #107369# - no line color
3042cdf0e10cSrcweir                 // OD 20.02.2003 #107369# - use aligned page rectangle
3043cdf0e10cSrcweir                 {
3044cdf0e10cSrcweir                     SwRect aTmpPageRect( aEmptyPageRect );
3045cdf0e10cSrcweir                     ::SwAlignRect( aTmpPageRect, pSh );
3046cdf0e10cSrcweir                     aEmptyPageRect = aTmpPageRect;
3047cdf0e10cSrcweir                 }
3048cdf0e10cSrcweir 
3049cdf0e10cSrcweir                 pSh->GetOut()->DrawRect( aEmptyPageRect.SVRect() );
3050cdf0e10cSrcweir 
3051cdf0e10cSrcweir                 // paint empty page text
3052cdf0e10cSrcweir                 const Font& rEmptyPageFont = SwPageFrm::GetEmptyPageFont();
3053cdf0e10cSrcweir                 const Font aOldFont( pSh->GetOut()->GetFont() );
3054cdf0e10cSrcweir 
3055cdf0e10cSrcweir                 pSh->GetOut()->SetFont( rEmptyPageFont );
3056cdf0e10cSrcweir                 pSh->GetOut()->DrawText( aEmptyPageRect.SVRect(), SW_RESSTR( STR_EMPTYPAGE ),
3057cdf0e10cSrcweir                                     TEXT_DRAW_VCENTER |
3058cdf0e10cSrcweir                                     TEXT_DRAW_CENTER |
3059cdf0e10cSrcweir                                     TEXT_DRAW_CLIP );
3060cdf0e10cSrcweir 
3061cdf0e10cSrcweir                 pSh->GetOut()->SetFont( aOldFont );
3062cdf0e10cSrcweir                 // paint shadow and border for empty page
3063cdf0e10cSrcweir                 // OD 19.02.2003 #107369# - use new method to paint page border and
3064cdf0e10cSrcweir                 // shadow
3065cdf0e10cSrcweir                 SwPageFrm::PaintBorderAndShadow( aEmptyPageRect, pSh, bPaintRightShadow, bRightSidebar );
3066cdf0e10cSrcweir                 SwPageFrm::PaintNotesSidebar( aEmptyPageRect, pSh, pPage->GetPhyPageNum(), bRightSidebar);
3067cdf0e10cSrcweir 
3068cdf0e10cSrcweir                 {
3069cdf0e10cSrcweir                     pSh->DLPostPaint2(true);
3070cdf0e10cSrcweir                 }
3071cdf0e10cSrcweir             }
3072cdf0e10cSrcweir         }
3073cdf0e10cSrcweir 
3074cdf0e10cSrcweir         ASSERT( !pPage->GetNext() || pPage->GetNext()->IsPageFrm(),
3075cdf0e10cSrcweir                 "Nachbar von Seite keine Seite." );
3076cdf0e10cSrcweir         pPage = (SwPageFrm*)pPage->GetNext();
3077cdf0e10cSrcweir     }
3078cdf0e10cSrcweir 
3079cdf0e10cSrcweir     DELETEZ( pLines );
3080cdf0e10cSrcweir 
3081cdf0e10cSrcweir #ifdef FRANK_TEST
3082cdf0e10cSrcweir 	if ( pSh->GetWin() )
3083cdf0e10cSrcweir     {
3084cdf0e10cSrcweir         Rectangle aRect( aFrm.SVRect() );
3085cdf0e10cSrcweir         pSh->GetWin()->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
3086cdf0e10cSrcweir         pSh->GetWin()->SetFillColor();
3087cdf0e10cSrcweir         pSh->GetWin()->SetLineColor( COL_LIGHTRED );
3088cdf0e10cSrcweir         pSh->GetWin()->DrawRect( aRect );
3089cdf0e10cSrcweir         pSh->GetWin()->Pop();
3090cdf0e10cSrcweir     }
3091cdf0e10cSrcweir #endif
3092cdf0e10cSrcweir 
3093cdf0e10cSrcweir 	if ( bResetRootPaint )
3094cdf0e10cSrcweir 		SwRootFrm::bInPaint = sal_False;
3095cdf0e10cSrcweir 	if ( pStatics )
3096cdf0e10cSrcweir 		delete pStatics;
3097cdf0e10cSrcweir 	else
3098cdf0e10cSrcweir 	{
3099cdf0e10cSrcweir 		pProgress = 0;
3100cdf0e10cSrcweir 		pGlobalShell = 0;
3101cdf0e10cSrcweir 	}
3102cdf0e10cSrcweir 
3103cdf0e10cSrcweir     ((SwRootFrm*)this)->SetCallbackActionEnabled( bOldAction );
3104cdf0e10cSrcweir }
3105cdf0e10cSrcweir 
3106cdf0e10cSrcweir #ifdef LONG_TABLE_HACK
3107cdf0e10cSrcweir 
3108cdf0e10cSrcweir /*************************************************************************
3109cdf0e10cSrcweir |*
3110cdf0e10cSrcweir |*	SwRootFrm::HackPrepareLongTblPaint()
3111cdf0e10cSrcweir |*
3112cdf0e10cSrcweir |*	Ersterstellung		MA 27. Sep. 96
3113cdf0e10cSrcweir |*	Letzte Aenderung	MA 18. Nov. 97
3114cdf0e10cSrcweir |*
3115cdf0e10cSrcweir |*************************************************************************/
3116cdf0e10cSrcweir 
HackPrepareLongTblPaint(int nMode)3117cdf0e10cSrcweir void SwRootFrm::HackPrepareLongTblPaint( int nMode )
3118cdf0e10cSrcweir {
3119cdf0e10cSrcweir 	switch ( nMode )
3120cdf0e10cSrcweir 	{
3121cdf0e10cSrcweir 		case HACK_TABLEMODE_INIT       : ASSERT( !pLines, "HackPrepare: already prepared" );
3122cdf0e10cSrcweir 										 pLines = new SwLineRects;
3123cdf0e10cSrcweir 										 ASSERT( !pGlobalShell, "old GlobalShell lost" );
3124cdf0e10cSrcweir 										 pGlobalShell = GetCurrShell();
3125cdf0e10cSrcweir 										 bTableHack = sal_True;
3126cdf0e10cSrcweir 										 break;
3127cdf0e10cSrcweir 		case HACK_TABLEMODE_LOCKLINES  : pLines->LockLines( sal_True ); break;
3128cdf0e10cSrcweir 		case HACK_TABLEMODE_PAINTLINES : pLines->PaintLines( GetShell()->GetOut() );
3129cdf0e10cSrcweir 										 break;
3130cdf0e10cSrcweir 		case HACK_TABLEMODE_UNLOCKLINES: pLines->LockLines( sal_False ); break;
3131cdf0e10cSrcweir 		case HACK_TABLEMODE_EXIT       : pLines->PaintLines( GetCurrShell()->GetOut() );
3132cdf0e10cSrcweir 										 DELETEZ( pLines );
3133cdf0e10cSrcweir 										 pGlobalShell = 0;
3134cdf0e10cSrcweir 										 bTableHack = sal_False;
3135cdf0e10cSrcweir 										 break;
3136cdf0e10cSrcweir 	}
3137cdf0e10cSrcweir }
3138cdf0e10cSrcweir 
3139cdf0e10cSrcweir #endif
3140cdf0e10cSrcweir 
3141cdf0e10cSrcweir 
3142cdf0e10cSrcweir /*************************************************************************
3143cdf0e10cSrcweir |*
3144cdf0e10cSrcweir |*	SwLayoutFrm::Paint()
3145cdf0e10cSrcweir |*
3146cdf0e10cSrcweir |*	Ersterstellung		MA 19. May. 92
3147cdf0e10cSrcweir |*	Letzte Aenderung	MA 19. Apr. 95
3148cdf0e10cSrcweir |*
3149cdf0e10cSrcweir |*************************************************************************/
3150cdf0e10cSrcweir 
lcl_EmergencyFormatFtnCont(SwFtnContFrm * pCont)3151cdf0e10cSrcweir void MA_FASTCALL lcl_EmergencyFormatFtnCont( SwFtnContFrm *pCont )
3152cdf0e10cSrcweir {
3153cdf0e10cSrcweir 	//Es kann sein, dass der Cont vernichtet wird.
3154cdf0e10cSrcweir 	SwCntntFrm *pCnt = pCont->ContainsCntnt();
3155cdf0e10cSrcweir 	while ( pCnt && pCnt->IsInFtn() )
3156cdf0e10cSrcweir 	{
3157cdf0e10cSrcweir 		pCnt->Calc();
3158cdf0e10cSrcweir 		pCnt = pCnt->GetNextCntntFrm();
3159cdf0e10cSrcweir 	}
3160cdf0e10cSrcweir }
3161cdf0e10cSrcweir 
3162cdf0e10cSrcweir class SwShortCut
3163cdf0e10cSrcweir {
3164cdf0e10cSrcweir     SwRectDist fnCheck;
3165cdf0e10cSrcweir     long nLimit;
3166cdf0e10cSrcweir public:
3167cdf0e10cSrcweir     SwShortCut( const SwFrm& rFrm, const SwRect& rRect );
Stop(const SwRect & rRect) const3168cdf0e10cSrcweir     sal_Bool Stop( const SwRect& rRect ) const
3169cdf0e10cSrcweir         { return (rRect.*fnCheck)( nLimit ) > 0; }
3170cdf0e10cSrcweir };
3171cdf0e10cSrcweir 
SwShortCut(const SwFrm & rFrm,const SwRect & rRect)3172cdf0e10cSrcweir SwShortCut::SwShortCut( const SwFrm& rFrm, const SwRect& rRect )
3173cdf0e10cSrcweir {
3174cdf0e10cSrcweir     sal_Bool bVert = rFrm.IsVertical();
3175cdf0e10cSrcweir     sal_Bool bR2L = rFrm.IsRightToLeft();
3176cdf0e10cSrcweir     if( rFrm.IsNeighbourFrm() && bVert == bR2L )
3177cdf0e10cSrcweir     {
3178cdf0e10cSrcweir         if( bVert )
3179cdf0e10cSrcweir         {
3180cdf0e10cSrcweir             fnCheck = &SwRect::GetBottomDistance;
3181cdf0e10cSrcweir             nLimit = rRect.Top();
3182cdf0e10cSrcweir         }
3183cdf0e10cSrcweir         else
3184cdf0e10cSrcweir         {
3185cdf0e10cSrcweir             fnCheck = &SwRect::GetLeftDistance;
3186cdf0e10cSrcweir             nLimit = rRect.Left() + rRect.Width();
3187cdf0e10cSrcweir         }
3188cdf0e10cSrcweir     }
3189cdf0e10cSrcweir     else if( bVert == rFrm.IsNeighbourFrm() )
3190cdf0e10cSrcweir     {
3191cdf0e10cSrcweir         fnCheck = &SwRect::GetTopDistance;
3192cdf0e10cSrcweir         nLimit = rRect.Top() + rRect.Height();
3193cdf0e10cSrcweir     }
3194cdf0e10cSrcweir     else
3195cdf0e10cSrcweir     {
3196cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
3197cdf0e10cSrcweir         if ( rFrm.IsVertLR() )
3198cdf0e10cSrcweir 	    {
3199cdf0e10cSrcweir            	fnCheck = &SwRect::GetLeftDistance;
3200cdf0e10cSrcweir            	nLimit = rRect.Right();
3201cdf0e10cSrcweir         }
3202cdf0e10cSrcweir         else
3203cdf0e10cSrcweir         {
3204cdf0e10cSrcweir         	fnCheck = &SwRect::GetRightDistance;
3205cdf0e10cSrcweir         	nLimit = rRect.Left();
3206cdf0e10cSrcweir         }
3207cdf0e10cSrcweir     }
3208cdf0e10cSrcweir }
3209cdf0e10cSrcweir 
Paint(SwRect const & rRect,SwPrintData const * const) const3210cdf0e10cSrcweir void SwLayoutFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
3211cdf0e10cSrcweir {
3212cdf0e10cSrcweir     ViewShell *pSh = getRootFrm()->GetCurrShell();
3213cdf0e10cSrcweir 
3214cdf0e10cSrcweir     // --> FME 2004-06-24 #i16816# tagged pdf support
3215cdf0e10cSrcweir     Frm_Info aFrmInfo( *this );
3216cdf0e10cSrcweir     SwTaggedPDFHelper aTaggedPDFHelper( 0, &aFrmInfo, 0, *pSh->GetOut() );
3217cdf0e10cSrcweir     // <--
3218cdf0e10cSrcweir 
3219cdf0e10cSrcweir 	const SwFrm *pFrm = Lower();
3220cdf0e10cSrcweir 	if ( !pFrm )
3221cdf0e10cSrcweir 		return;
3222cdf0e10cSrcweir 
3223cdf0e10cSrcweir     SwShortCut aShortCut( *pFrm, rRect );
3224cdf0e10cSrcweir 	sal_Bool bCnt;
3225cdf0e10cSrcweir 	if ( sal_True == (bCnt = pFrm->IsCntntFrm()) )
3226cdf0e10cSrcweir 		pFrm->Calc();
3227cdf0e10cSrcweir 
3228cdf0e10cSrcweir 	if ( pFrm->IsFtnContFrm() )
3229cdf0e10cSrcweir     {
3230cdf0e10cSrcweir         ::lcl_EmergencyFormatFtnCont( (SwFtnContFrm*)pFrm );
3231cdf0e10cSrcweir 		pFrm = Lower();
3232cdf0e10cSrcweir 	}
3233cdf0e10cSrcweir 
3234cdf0e10cSrcweir 	const SwPageFrm *pPage = 0;
3235cdf0e10cSrcweir 	const sal_Bool bWin   = pGlobalShell->GetWin() ? sal_True : sal_False;
3236cdf0e10cSrcweir 
3237cdf0e10cSrcweir 	while ( IsAnLower( pFrm ) )
3238cdf0e10cSrcweir 	{
3239cdf0e10cSrcweir         SwRect aPaintRect( pFrm->PaintArea() );
3240cdf0e10cSrcweir         if( aShortCut.Stop( aPaintRect ) )
3241cdf0e10cSrcweir 			break;
3242cdf0e10cSrcweir 		if ( bCnt && pProgress )
3243cdf0e10cSrcweir 			pProgress->Reschedule();
3244cdf0e10cSrcweir 
3245cdf0e10cSrcweir 		//Wenn ein Frm es explizit will muss retouchiert werden.
3246cdf0e10cSrcweir 		//Erst die Retouche, denn selbige koennte die aligned'en Raender
3247cdf0e10cSrcweir 		//plaetten.
3248cdf0e10cSrcweir 		if ( pFrm->IsRetouche() )
3249cdf0e10cSrcweir 		{
3250cdf0e10cSrcweir 			if ( pFrm->IsRetoucheFrm() && bWin && !pFrm->GetNext() )
3251cdf0e10cSrcweir 			{	if ( !pPage )
3252cdf0e10cSrcweir 					pPage = FindPageFrm();
3253cdf0e10cSrcweir                pFrm->Retouche( pPage, rRect );
3254cdf0e10cSrcweir 			}
3255cdf0e10cSrcweir 			pFrm->ResetRetouche();
3256cdf0e10cSrcweir 		}
3257cdf0e10cSrcweir 
3258cdf0e10cSrcweir         if ( rRect.IsOver( aPaintRect ) )
3259cdf0e10cSrcweir 		{
3260cdf0e10cSrcweir 			if ( bCnt && pFrm->IsCompletePaint() &&
3261cdf0e10cSrcweir 				 !rRect.IsInside( aPaintRect ) && GetpApp()->AnyInput( INPUT_KEYBOARD ) )
3262cdf0e10cSrcweir 			{
3263cdf0e10cSrcweir 				//fix(8104): Es kann vorkommen, dass die Verarbeitung nicht
3264cdf0e10cSrcweir 				//vollstaendig war, aber trotzdem Teile des Absatzes gepaintet
3265cdf0e10cSrcweir 				//werden. In der Folge werden dann evtl. wiederum andere Teile
3266cdf0e10cSrcweir 				//des Absatzes garnicht mehr gepaintet. Einziger Ausweg scheint
3267cdf0e10cSrcweir 				//hier ein Invalidieren der Windows zu sein.
3268cdf0e10cSrcweir 				//Um es nicht alzu Heftig werden zu lassen versuche ich hier
3269cdf0e10cSrcweir 				//das Rechteck zu begrenzen indem der gewuenschte Teil gepaintet
3270cdf0e10cSrcweir 				//und nur die uebrigen Absatzanteile invalidiert werden.
3271cdf0e10cSrcweir 				if ( aPaintRect.Left()	== rRect.Left() &&
3272cdf0e10cSrcweir 					 aPaintRect.Right() == rRect.Right() )
3273cdf0e10cSrcweir 				{
3274cdf0e10cSrcweir 					aPaintRect.Bottom( rRect.Top() - 1 );
3275cdf0e10cSrcweir 					if ( aPaintRect.Height() > 0 )
3276cdf0e10cSrcweir 						pGlobalShell->InvalidateWindows(aPaintRect);
3277cdf0e10cSrcweir 					aPaintRect.Top( rRect.Bottom() + 1 );
3278cdf0e10cSrcweir 					aPaintRect.Bottom( pFrm->Frm().Bottom() );
3279cdf0e10cSrcweir 					if ( aPaintRect.Height() > 0 )
3280cdf0e10cSrcweir 						pGlobalShell->InvalidateWindows(aPaintRect);
3281cdf0e10cSrcweir 					aPaintRect.Top( pFrm->Frm().Top() );
3282cdf0e10cSrcweir 					aPaintRect.Bottom( pFrm->Frm().Bottom() );
3283cdf0e10cSrcweir 				}
3284cdf0e10cSrcweir 				else
3285cdf0e10cSrcweir 				{
3286cdf0e10cSrcweir 					pGlobalShell->InvalidateWindows( aPaintRect );
3287cdf0e10cSrcweir 					pFrm = pFrm->GetNext();
3288cdf0e10cSrcweir 					if ( pFrm && (sal_True == (bCnt = pFrm->IsCntntFrm())) )
3289cdf0e10cSrcweir 						pFrm->Calc();
3290cdf0e10cSrcweir 					continue;
3291cdf0e10cSrcweir 				}
3292cdf0e10cSrcweir 			}
3293cdf0e10cSrcweir 			pFrm->ResetCompletePaint();
3294cdf0e10cSrcweir 			aPaintRect._Intersection( rRect );
3295cdf0e10cSrcweir 
3296cdf0e10cSrcweir             pFrm->Paint( aPaintRect );
3297cdf0e10cSrcweir 
3298cdf0e10cSrcweir             if ( Lower() && Lower()->IsColumnFrm() )
3299cdf0e10cSrcweir 			{
3300cdf0e10cSrcweir 				//Ggf. die Spaltentrennlinien malen. Fuer den Seitenbody ist
3301cdf0e10cSrcweir 				//nicht der Upper sondern die Seite Zustaendig.
3302cdf0e10cSrcweir 				const SwFrmFmt *pFmt = GetUpper() && GetUpper()->IsPageFrm()
3303cdf0e10cSrcweir 											? GetUpper()->GetFmt()
3304cdf0e10cSrcweir 											: GetFmt();
3305cdf0e10cSrcweir 				const SwFmtCol &rCol = pFmt->GetCol();
3306cdf0e10cSrcweir 				if ( rCol.GetLineAdj() != COLADJ_NONE )
3307cdf0e10cSrcweir 				{
3308cdf0e10cSrcweir 					if ( !pPage )
3309cdf0e10cSrcweir 						pPage = pFrm->FindPageFrm();
3310cdf0e10cSrcweir 
3311cdf0e10cSrcweir                     PaintColLines( aPaintRect, rCol, pPage );
3312cdf0e10cSrcweir                 }
3313cdf0e10cSrcweir 			}
3314cdf0e10cSrcweir         }
3315cdf0e10cSrcweir 		if ( !bCnt && pFrm->GetNext() && pFrm->GetNext()->IsFtnContFrm() )
3316cdf0e10cSrcweir 			::lcl_EmergencyFormatFtnCont( (SwFtnContFrm*)pFrm->GetNext() );
3317cdf0e10cSrcweir 
3318cdf0e10cSrcweir 		pFrm = pFrm->GetNext();
3319cdf0e10cSrcweir 		if ( pFrm && (sal_True == (bCnt = pFrm->IsCntntFrm())) )
3320cdf0e10cSrcweir 			pFrm->Calc();
3321cdf0e10cSrcweir 	}
3322cdf0e10cSrcweir }
3323cdf0e10cSrcweir 
3324cdf0e10cSrcweir 
3325cdf0e10cSrcweir /** FlyFrm::IsBackgroundTransparent - for feature #99657#
3326cdf0e10cSrcweir 
3327cdf0e10cSrcweir     OD 12.08.2002
3328cdf0e10cSrcweir     determines, if background of fly frame has to be drawn transparent
3329cdf0e10cSrcweir     declaration found in /core/inc/flyfrm.cxx
3330cdf0e10cSrcweir     OD 08.10.2002 #103898# - If the background of the fly frame itself is not
3331cdf0e10cSrcweir     transparent and the background is inherited from its parent/grandparent,
3332cdf0e10cSrcweir     the background brush, used for drawing, has to be investigated for transparency.
3333cdf0e10cSrcweir 
3334cdf0e10cSrcweir     @author OD
3335cdf0e10cSrcweir 
3336cdf0e10cSrcweir     @return true, if background is transparent drawn.
3337cdf0e10cSrcweir */
IsBackgroundTransparent() const3338cdf0e10cSrcweir sal_Bool SwFlyFrm::IsBackgroundTransparent() const
3339cdf0e10cSrcweir {
3340cdf0e10cSrcweir     sal_Bool bBackgroundTransparent = GetFmt()->IsBackgroundTransparent();
3341cdf0e10cSrcweir     if ( !bBackgroundTransparent &&
3342cdf0e10cSrcweir          static_cast<const SwFlyFrmFmt*>(GetFmt())->IsBackgroundBrushInherited() )
3343cdf0e10cSrcweir     {
3344cdf0e10cSrcweir         const SvxBrushItem* pBackgrdBrush = 0;
3345cdf0e10cSrcweir         const Color* pSectionTOXColor = 0;
3346cdf0e10cSrcweir         SwRect aDummyRect;
3347cdf0e10cSrcweir         if ( GetBackgroundBrush( pBackgrdBrush, pSectionTOXColor, aDummyRect, false) )
3348cdf0e10cSrcweir         {
3349cdf0e10cSrcweir             if ( pSectionTOXColor &&
3350cdf0e10cSrcweir                  (pSectionTOXColor->GetTransparency() != 0) &&
3351cdf0e10cSrcweir                  (pSectionTOXColor->GetColor() != COL_TRANSPARENT) )
3352cdf0e10cSrcweir             {
3353cdf0e10cSrcweir                 bBackgroundTransparent = sal_True;
3354cdf0e10cSrcweir             }
3355cdf0e10cSrcweir             else if ( pBackgrdBrush )
3356cdf0e10cSrcweir             {
3357cdf0e10cSrcweir                 if ( (pBackgrdBrush->GetColor().GetTransparency() != 0) &&
3358cdf0e10cSrcweir                      (pBackgrdBrush->GetColor() != COL_TRANSPARENT) )
3359cdf0e10cSrcweir                 {
3360cdf0e10cSrcweir                     bBackgroundTransparent = sal_True;
3361cdf0e10cSrcweir                 }
3362cdf0e10cSrcweir                 else
3363cdf0e10cSrcweir                 {
3364cdf0e10cSrcweir                     const GraphicObject *pTmpGrf =
3365cdf0e10cSrcweir                             static_cast<const GraphicObject*>(pBackgrdBrush->GetGraphicObject());
3366cdf0e10cSrcweir                     if ( (pTmpGrf) &&
3367cdf0e10cSrcweir                          (pTmpGrf->GetAttr().GetTransparency() != 0)
3368cdf0e10cSrcweir                        )
3369cdf0e10cSrcweir                     {
3370cdf0e10cSrcweir                         bBackgroundTransparent = sal_True;
3371cdf0e10cSrcweir                     }
3372cdf0e10cSrcweir                 }
3373cdf0e10cSrcweir             }
3374cdf0e10cSrcweir         }
3375cdf0e10cSrcweir     }
3376cdf0e10cSrcweir 
3377cdf0e10cSrcweir     return bBackgroundTransparent;
3378cdf0e10cSrcweir };
3379cdf0e10cSrcweir 
3380cdf0e10cSrcweir /** FlyFrm::IsShadowTransparent - for feature #99657#
3381cdf0e10cSrcweir 
3382cdf0e10cSrcweir     OD 13.08.2002
3383cdf0e10cSrcweir     determine, if shadow color of fly frame has to be drawn transparent
3384cdf0e10cSrcweir     declaration found in /core/inc/flyfrm.cxx
3385cdf0e10cSrcweir 
3386cdf0e10cSrcweir     @author OD
3387cdf0e10cSrcweir 
3388cdf0e10cSrcweir     @return true, if shadow color is transparent.
3389cdf0e10cSrcweir */
IsShadowTransparent() const3390cdf0e10cSrcweir sal_Bool SwFlyFrm::IsShadowTransparent() const
3391cdf0e10cSrcweir {
3392cdf0e10cSrcweir     return GetFmt()->IsShadowTransparent();
3393cdf0e10cSrcweir };
3394cdf0e10cSrcweir 
3395cdf0e10cSrcweir /*************************************************************************
3396cdf0e10cSrcweir |*
3397cdf0e10cSrcweir |*	SwFlyFrm::IsPaint()
3398cdf0e10cSrcweir |*
3399cdf0e10cSrcweir |*	Ersterstellung		MA 16. Jan. 97
3400cdf0e10cSrcweir |*	Letzte Aenderung	MA 16. Jan. 97
3401cdf0e10cSrcweir |*
3402cdf0e10cSrcweir |*************************************************************************/
3403cdf0e10cSrcweir 
IsPaint(SdrObject * pObj,const ViewShell * pSh)3404cdf0e10cSrcweir sal_Bool SwFlyFrm::IsPaint( SdrObject *pObj, const ViewShell *pSh )
3405cdf0e10cSrcweir {
3406cdf0e10cSrcweir 	SdrObjUserCall *pUserCall;
3407cdf0e10cSrcweir 
3408cdf0e10cSrcweir 	if ( 0 == ( pUserCall = GetUserCall(pObj) ) )
3409cdf0e10cSrcweir 		return sal_True;
3410cdf0e10cSrcweir 
3411cdf0e10cSrcweir 	//Attributabhaengig nicht fuer Drucker oder PreView painten
3412cdf0e10cSrcweir 	sal_Bool bPaint =  pFlyOnlyDraw ||
3413cdf0e10cSrcweir 					   ((SwContact*)pUserCall)->GetFmt()->GetPrint().GetValue();
3414cdf0e10cSrcweir 	if ( !bPaint )
3415cdf0e10cSrcweir 		bPaint = pSh->GetWin() && !pSh->IsPreView();
3416cdf0e10cSrcweir 
3417cdf0e10cSrcweir 	if ( bPaint )
3418cdf0e10cSrcweir 	{
3419cdf0e10cSrcweir 		//Das Paint kann evtl. von von uebergeordneten Flys verhindert werden.
3420cdf0e10cSrcweir         SwFrm *pAnch = 0;
342173916cc0SMichael Stahl         // --> OD #i117962#
342273916cc0SMichael Stahl         if ( pObj->ISA(SwFlyDrawObj) )
342373916cc0SMichael Stahl         {
34240272ccd2Smseidel             bPaint = false;
342573916cc0SMichael Stahl         }
342673916cc0SMichael Stahl         // <--
342773916cc0SMichael Stahl         else if ( pObj->ISA(SwVirtFlyDrawObj) )
3428cdf0e10cSrcweir 		{
3429cdf0e10cSrcweir 			SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
3430cdf0e10cSrcweir 			if ( pFlyOnlyDraw && pFlyOnlyDraw == pFly )
3431cdf0e10cSrcweir 				return sal_True;
3432cdf0e10cSrcweir 
3433cdf0e10cSrcweir 			//Die Anzeige eines Zwischenstadiums vermeiden, Flys die nicht mit
3434cdf0e10cSrcweir 			//der Seite auf der sie verankert sind ueberlappen werden auch
3435cdf0e10cSrcweir 			//nicht gepaintet.
3436cdf0e10cSrcweir 			//HACK: Ausnahme: Drucken von Rahmen in Tabellen, diese koennen
3437cdf0e10cSrcweir 			//bei uebergrossen Tabellen (HTML) schon mal auserhalb der Seite
3438cdf0e10cSrcweir 			//stehen.
3439cdf0e10cSrcweir 			SwPageFrm *pPage = pFly->FindPageFrm();
3440cdf0e10cSrcweir 			if ( pPage )
3441cdf0e10cSrcweir 			{
3442cdf0e10cSrcweir 				if ( pPage->Frm().IsOver( pFly->Frm() ) )
3443cdf0e10cSrcweir                     pAnch = pFly->AnchorFrm();
3444cdf0e10cSrcweir 				else if ( bTableHack &&
3445cdf0e10cSrcweir                           pFly->Frm().Top() >= pFly->GetAnchorFrm()->Frm().Top() &&
3446cdf0e10cSrcweir                           pFly->Frm().Top() < pFly->GetAnchorFrm()->Frm().Bottom() &&
3447cdf0e10cSrcweir                           long(pSh->GetOut()) ==
3448cdf0e10cSrcweir                           long(pSh->getIDocumentDeviceAccess()->getPrinter( false ) ) )
3449cdf0e10cSrcweir 				{
3450cdf0e10cSrcweir                     pAnch = pFly->AnchorFrm();
3451cdf0e10cSrcweir 				}
3452cdf0e10cSrcweir 			}
3453cdf0e10cSrcweir 
3454cdf0e10cSrcweir 		}
3455cdf0e10cSrcweir 		else
3456cdf0e10cSrcweir 		{
3457cdf0e10cSrcweir             // OD 13.10.2003 #i19919# - consider 'virtual' drawing objects
3458cdf0e10cSrcweir             // OD 2004-03-29 #i26791#
3459cdf0e10cSrcweir             pAnch = ((SwDrawContact*)pUserCall)->GetAnchorFrm( pObj );
3460cdf0e10cSrcweir 			if ( pAnch )
3461cdf0e10cSrcweir 			{
3462cdf0e10cSrcweir 				if ( !pAnch->GetValidPosFlag() )
3463cdf0e10cSrcweir 					pAnch = 0;
3464cdf0e10cSrcweir                 else if ( long(pSh->GetOut()) == long(pSh->getIDocumentDeviceAccess()->getPrinter( false )))
3465cdf0e10cSrcweir 				{
3466cdf0e10cSrcweir 					//HACK: fuer das Drucken muessen wir ein paar Objekte
3467cdf0e10cSrcweir 					//weglassen, da diese sonst doppelt gedruckt werden.
3468cdf0e10cSrcweir 					//Die Objekte sollen gedruckt werden, wenn der TableHack
3469cdf0e10cSrcweir 					//gerade greift. In der Folge duerfen sie nicht gedruckt werden
3470cdf0e10cSrcweir 					//wenn sie mit der Seite dran sind, ueber der sie von der
3471cdf0e10cSrcweir 					//Position her gerade schweben.
3472cdf0e10cSrcweir                     const SwPageFrm *pPage = pAnch->FindPageFrm();
3473cdf0e10cSrcweir 					if ( !bTableHack &&
3474cdf0e10cSrcweir 						 !pPage->Frm().IsOver( pObj->GetCurrentBoundRect() ) )
3475cdf0e10cSrcweir 						pAnch = 0;
3476cdf0e10cSrcweir 				}
3477cdf0e10cSrcweir 			}
3478cdf0e10cSrcweir             else
3479cdf0e10cSrcweir             {
3480cdf0e10cSrcweir                 // OD 02.07.2003 #108784# - debug assert
3481cdf0e10cSrcweir                 if ( !pObj->ISA(SdrObjGroup) )
3482cdf0e10cSrcweir                 {
3483cdf0e10cSrcweir                     ASSERT( false, "<SwFlyFrm::IsPaint(..)> - paint of drawing object without anchor frame!?" );
3484cdf0e10cSrcweir                 }
3485cdf0e10cSrcweir             }
3486cdf0e10cSrcweir 		}
3487cdf0e10cSrcweir 		if ( pAnch )
3488cdf0e10cSrcweir 		{
3489cdf0e10cSrcweir 			if ( pAnch->IsInFly() )
3490cdf0e10cSrcweir 				bPaint = SwFlyFrm::IsPaint( pAnch->FindFlyFrm()->GetVirtDrawObj(),
3491cdf0e10cSrcweir 											pSh );
3492cdf0e10cSrcweir 			else if ( pFlyOnlyDraw )
3493cdf0e10cSrcweir 				bPaint = sal_False;
3494cdf0e10cSrcweir 		}
3495cdf0e10cSrcweir 		else
3496cdf0e10cSrcweir 			bPaint = sal_False;
3497cdf0e10cSrcweir 	}
3498cdf0e10cSrcweir 	return bPaint;
3499cdf0e10cSrcweir }
3500cdf0e10cSrcweir 
3501cdf0e10cSrcweir /*************************************************************************
3502cdf0e10cSrcweir |*  SwCellFrm::Paint( const SwRect& ) const
3503cdf0e10cSrcweir |*************************************************************************/
Paint(SwRect const & rRect,SwPrintData const * const) const3504cdf0e10cSrcweir void SwCellFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
3505cdf0e10cSrcweir {
3506cdf0e10cSrcweir     if ( GetLayoutRowSpan() >= 1 )
3507cdf0e10cSrcweir         SwLayoutFrm::Paint( rRect );
3508cdf0e10cSrcweir }
3509cdf0e10cSrcweir 
3510cdf0e10cSrcweir /*************************************************************************
3511cdf0e10cSrcweir |*
3512cdf0e10cSrcweir |*	SwFlyFrm::Paint()
3513cdf0e10cSrcweir |*
3514cdf0e10cSrcweir |*	Ersterstellung		MA ??
3515cdf0e10cSrcweir |*	Letzte Aenderung	MA 16. Jan. 97
3516cdf0e10cSrcweir |*
3517cdf0e10cSrcweir |*************************************************************************/
3518cdf0e10cSrcweir 
3519cdf0e10cSrcweir //Weiter unten definiert
3520cdf0e10cSrcweir void MA_FASTCALL lcl_PaintLowerBorders( const SwLayoutFrm *pLay,
3521cdf0e10cSrcweir 							   const SwRect &rRect, const SwPageFrm *pPage );
3522cdf0e10cSrcweir 
Paint(SwRect const & rRect,SwPrintData const * const) const3523cdf0e10cSrcweir void SwFlyFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
3524cdf0e10cSrcweir {
3525cb65df5dSJürgen Schmidt 	//begin:optimize thumbnail generate and store procedure to improve odt saving performance, i120030
3526cb65df5dSJürgen Schmidt 	ViewShell *pShell = getRootFrm()->GetCurrShell();
3527cb65df5dSJürgen Schmidt 	if (pShell && pShell->GetDoc() && pShell->GetDoc()->GetDocShell())
3528cb65df5dSJürgen Schmidt 	{
3529cb65df5dSJürgen Schmidt 		sal_Bool bInGenerateThumbnail = pShell->GetDoc()->GetDocShell()->IsInGenerateAndStoreThumbnail();
3530cb65df5dSJürgen Schmidt 		if (bInGenerateThumbnail)
3531cb65df5dSJürgen Schmidt 		{
3532cb65df5dSJürgen Schmidt 			SwRect aVisRect = pShell->VisArea();
3533cb65df5dSJürgen Schmidt 			if (!aVisRect.IsOver(Frm()))
3534cb65df5dSJürgen Schmidt 				return;
3535cb65df5dSJürgen Schmidt 		}
3536cb65df5dSJürgen Schmidt 	}
3537cb65df5dSJürgen Schmidt 	//end:i120030
3538cb65df5dSJürgen Schmidt 
3539cdf0e10cSrcweir     //wegen der Ueberlappung von Rahmen und Zeichenobjekten muessen die
3540cdf0e10cSrcweir 	//Flys ihre Umrandung (und die der Innenliegenden) direkt ausgeben.
3541cdf0e10cSrcweir 	//z.B. #33066#
3542cdf0e10cSrcweir 	pLines->LockLines(sal_True);
3543cdf0e10cSrcweir 
3544cdf0e10cSrcweir     SwRect aRect( rRect );
3545cdf0e10cSrcweir 	aRect._Intersection( Frm() );
3546cdf0e10cSrcweir 
3547cdf0e10cSrcweir     OutputDevice* pOut = pGlobalShell->GetOut();
3548cdf0e10cSrcweir 	pOut->Push( PUSH_CLIPREGION );
3549cdf0e10cSrcweir 	pOut->SetClipRegion();
3550cdf0e10cSrcweir     const SwPageFrm* pPage = FindPageFrm();
3551cdf0e10cSrcweir 
3552cdf0e10cSrcweir 	const SwNoTxtFrm *pNoTxt = Lower() && Lower()->IsNoTxtFrm()
3553cdf0e10cSrcweir 												? (SwNoTxtFrm*)Lower() : 0;
3554cdf0e10cSrcweir 
3555cdf0e10cSrcweir     bool bIsChart = false; //#i102950# don't paint additional borders for charts
3556cdf0e10cSrcweir     //check whether we have a chart
3557cdf0e10cSrcweir     if(pNoTxt)
3558cdf0e10cSrcweir     {
3559cdf0e10cSrcweir         const SwNoTxtNode* pNoTNd = dynamic_cast<const SwNoTxtNode*>(pNoTxt->GetNode());
3560cdf0e10cSrcweir         if( pNoTNd )
3561cdf0e10cSrcweir         {
3562cdf0e10cSrcweir             SwOLENode* pOLENd = const_cast<SwOLENode*>(pNoTNd->GetOLENode());
356378d93489SArmin Le Grand             if( pOLENd && ChartHelper::IsChart( pOLENd->GetOLEObj().GetObject() ) )
3564cdf0e10cSrcweir                 bIsChart = true;
3565cdf0e10cSrcweir         }
3566cdf0e10cSrcweir     }
3567cdf0e10cSrcweir 
3568cdf0e10cSrcweir 	{
3569cdf0e10cSrcweir         bool bContour = GetFmt()->GetSurround().IsContour();
3570cdf0e10cSrcweir 		PolyPolygon aPoly;
3571cdf0e10cSrcweir 		if ( bContour )
3572cdf0e10cSrcweir         {
3573cdf0e10cSrcweir             // OD 16.04.2003 #i13147# - add 2nd parameter with value <sal_True>
3574cdf0e10cSrcweir             // to indicate that method is called for paint in order to avoid
3575cdf0e10cSrcweir             // load of the intrinsic graphic.
3576cdf0e10cSrcweir             bContour = GetContour( aPoly, sal_True );
3577cdf0e10cSrcweir         }
3578cdf0e10cSrcweir 
3579cdf0e10cSrcweir         // --> OD 2005-06-08 #i47804# - distinguish complete background paint
3580cdf0e10cSrcweir         // and margin paint.
3581cdf0e10cSrcweir         // paint complete background for Writer text fly frames
3582cdf0e10cSrcweir         bool bPaintCompleteBack( !pNoTxt );
3583cdf0e10cSrcweir         // <--
3584cdf0e10cSrcweir         // paint complete background for transparent graphic and contour,
3585cdf0e10cSrcweir         // if own background color exists.
3586cdf0e10cSrcweir         const bool bIsGraphicTransparent = pNoTxt ? pNoTxt->IsTransparent() : false;
3587cdf0e10cSrcweir         if ( !bPaintCompleteBack &&
3588cdf0e10cSrcweir              ( bIsGraphicTransparent|| bContour ) )
3589cdf0e10cSrcweir 		{
3590cdf0e10cSrcweir 			const SvxBrushItem &rBack = GetFmt()->GetBackground();
3591cdf0e10cSrcweir             // OD 07.08.2002 #99657# #GetTransChg#
3592cdf0e10cSrcweir             //     to determine, if background has to be painted, by checking, if
3593cdf0e10cSrcweir             //     background color is not COL_TRANSPARENT ("no fill"/"auto fill")
3594cdf0e10cSrcweir             //     or a background graphic exists.
3595cdf0e10cSrcweir             bPaintCompleteBack = !(rBack.GetColor() == COL_TRANSPARENT) ||
3596cdf0e10cSrcweir                                  rBack.GetGraphicPos() != GPOS_NONE;
3597cdf0e10cSrcweir 		}
3598cdf0e10cSrcweir         // paint of margin needed.
3599cdf0e10cSrcweir         const bool bPaintMarginOnly( !bPaintCompleteBack &&
3600cdf0e10cSrcweir                                      Prt().SSize() != Frm().SSize() );
3601cdf0e10cSrcweir 
3602cdf0e10cSrcweir         // --> OD 2005-06-08 #i47804# - paint background of parent fly frame
3603cdf0e10cSrcweir         // for transparent graphics in layer Hell, if parent fly frame isn't
3604cdf0e10cSrcweir         // in layer Hell. It's only painted the intersection between the
3605cdf0e10cSrcweir         // parent fly frame area and the paint area <aRect>
3606cdf0e10cSrcweir         const IDocumentDrawModelAccess* pIDDMA = GetFmt()->getIDocumentDrawModelAccess();
3607cdf0e10cSrcweir 
3608cdf0e10cSrcweir         if ( bIsGraphicTransparent &&
3609cdf0e10cSrcweir             GetVirtDrawObj()->GetLayer() == pIDDMA->GetHellId() &&
3610cdf0e10cSrcweir             GetAnchorFrm()->FindFlyFrm() )
3611cdf0e10cSrcweir         {
3612cdf0e10cSrcweir             const SwFlyFrm* pParentFlyFrm = GetAnchorFrm()->FindFlyFrm();
3613cdf0e10cSrcweir             if ( pParentFlyFrm->GetDrawObj()->GetLayer() !=
3614cdf0e10cSrcweir                                             pIDDMA->GetHellId() )
3615cdf0e10cSrcweir             {
3616cdf0e10cSrcweir                 SwFlyFrm* pOldRet = pRetoucheFly2;
3617cdf0e10cSrcweir                 pRetoucheFly2 = const_cast<SwFlyFrm*>(this);
3618cdf0e10cSrcweir 
3619cdf0e10cSrcweir                 SwBorderAttrAccess aAccess( SwFrm::GetCache(), pParentFlyFrm );
3620cdf0e10cSrcweir                 const SwBorderAttrs &rAttrs = *aAccess.Get();
3621cdf0e10cSrcweir                 SwRect aPaintRect( aRect );
3622cdf0e10cSrcweir                 aPaintRect._Intersection( pParentFlyFrm->Frm() );
3623cdf0e10cSrcweir                 pParentFlyFrm->PaintBackground( aPaintRect, pPage, rAttrs, sal_False, sal_False );
3624cdf0e10cSrcweir 
3625cdf0e10cSrcweir                 pRetoucheFly2 = pOldRet;
3626cdf0e10cSrcweir             }
3627cdf0e10cSrcweir         }
3628cdf0e10cSrcweir 
3629cdf0e10cSrcweir         if ( bPaintCompleteBack || bPaintMarginOnly )
3630cdf0e10cSrcweir 		{
3631cdf0e10cSrcweir 			//#24926# JP 01.02.96, PaintBaBo in teilen hier, damit PaintBorder
3632cdf0e10cSrcweir 			//das orig. Rect bekommt, aber PaintBackground das begrenzte.
3633cdf0e10cSrcweir 
3634cdf0e10cSrcweir             // OD 2004-04-23 #116347#
3635cdf0e10cSrcweir             pOut->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
3636cdf0e10cSrcweir             pOut->SetLineColor();
3637cdf0e10cSrcweir 
3638cdf0e10cSrcweir 			pPage = FindPageFrm();
3639cdf0e10cSrcweir 
3640cdf0e10cSrcweir 			SwBorderAttrAccess aAccess( SwFrm::GetCache(), (SwFrm*)this );
3641cdf0e10cSrcweir 			const SwBorderAttrs &rAttrs = *aAccess.Get();
3642cdf0e10cSrcweir 
3643cdf0e10cSrcweir             // OD 06.08.2002 #99657# - paint border before painting background
3644cdf0e10cSrcweir             // paint border
3645cdf0e10cSrcweir             {
3646cdf0e10cSrcweir                 SwRect aTmp( rRect );
3647cdf0e10cSrcweir                 PaintBorder( aTmp, pPage, rAttrs );
3648cdf0e10cSrcweir             }
3649cdf0e10cSrcweir 
3650cdf0e10cSrcweir             // paint background
3651cdf0e10cSrcweir             {
3652cdf0e10cSrcweir                 SwRegionRects aRegion( aRect );
3653cdf0e10cSrcweir                 // --> OD 2007-12-13 #i80822#
3654cdf0e10cSrcweir                 // suppress painting of background in printing area for
3655cdf0e10cSrcweir                 // non-transparent graphics.
3656cdf0e10cSrcweir //                if ( bPaintMarginOnly )
3657cdf0e10cSrcweir                 if ( bPaintMarginOnly ||
3658cdf0e10cSrcweir                      ( pNoTxt && !bIsGraphicTransparent ) )
3659cdf0e10cSrcweir                 // <--
3660cdf0e10cSrcweir                 {
3661cdf0e10cSrcweir                     //Was wir eigentlich Painten wollen ist der schmale Streifen
3662cdf0e10cSrcweir                     //zwischen PrtArea und aeusserer Umrandung.
3663cdf0e10cSrcweir                     SwRect aTmp( Prt() ); aTmp += Frm().Pos();
3664cdf0e10cSrcweir                     aRegion -= aTmp;
3665cdf0e10cSrcweir                 }
3666cdf0e10cSrcweir                 if ( bContour )
3667cdf0e10cSrcweir                 {
3668cdf0e10cSrcweir                     pOut->Push();
3669cdf0e10cSrcweir                     // --> OD 2007-12-13 #i80822#
3670cdf0e10cSrcweir                     // apply clip region under the same conditions, which are
3671cdf0e10cSrcweir                     // used in <SwNoTxtFrm::Paint(..)> to set the clip region
3672cdf0e10cSrcweir                     // for painting the graphic/OLE. Thus, the clip region is
3673cdf0e10cSrcweir                     // also applied for the PDF export.
3674cdf0e10cSrcweir //                    if ( !pOut->GetConnectMetaFile() || pOut->GetOutDevType() == OUTDEV_PRINTER )
3675cdf0e10cSrcweir                 	ViewShell *pSh = getRootFrm()->GetCurrShell();
3676cdf0e10cSrcweir                     if ( !pOut->GetConnectMetaFile() || !pSh || !pSh->GetWin() )
3677cdf0e10cSrcweir                     // <--
3678cdf0e10cSrcweir                     {
3679cdf0e10cSrcweir                         pOut->SetClipRegion( aPoly );
3680cdf0e10cSrcweir                     }
3681cdf0e10cSrcweir                     for ( sal_uInt16 i = 0; i < aRegion.Count(); ++i )
3682cdf0e10cSrcweir                         PaintBackground( aRegion[i], pPage, rAttrs, sal_False, sal_True );
3683cdf0e10cSrcweir                     pOut->Pop();
3684cdf0e10cSrcweir                 }
3685cdf0e10cSrcweir                 else
3686cdf0e10cSrcweir                     for ( sal_uInt16 i = 0; i < aRegion.Count(); ++i )
3687cdf0e10cSrcweir                         PaintBackground( aRegion[i], pPage, rAttrs, sal_False, sal_True );
3688cdf0e10cSrcweir             }
3689cdf0e10cSrcweir 
3690cdf0e10cSrcweir 			pOut->Pop();
3691cdf0e10cSrcweir 		}
3692cdf0e10cSrcweir 	}
3693cdf0e10cSrcweir 
3694cdf0e10cSrcweir     // OD 19.12.2002 #106318# - fly frame will paint it's subsidiary lines and
3695cdf0e10cSrcweir     // the subsidiary lines of its lowers on its own, due to overlapping with
3696cdf0e10cSrcweir     // other fly frames or other objects.
3697cdf0e10cSrcweir     if( pGlobalShell->GetWin()
3698cdf0e10cSrcweir         && !bIsChart ) //#i102950# don't paint additional borders for charts
3699cdf0e10cSrcweir     {
3700cdf0e10cSrcweir         bool bSubsLineRectsCreated;
3701cdf0e10cSrcweir         if ( pSubsLines )
3702cdf0e10cSrcweir         {
3703cdf0e10cSrcweir             // Lock already existing subsidiary lines
3704cdf0e10cSrcweir             pSubsLines->LockLines( sal_True );
3705cdf0e10cSrcweir             bSubsLineRectsCreated = false;
3706cdf0e10cSrcweir         }
3707cdf0e10cSrcweir         else
3708cdf0e10cSrcweir         {
3709cdf0e10cSrcweir             // create new subsidiardy lines
3710cdf0e10cSrcweir             pSubsLines = new SwSubsRects;
3711cdf0e10cSrcweir             bSubsLineRectsCreated = true;
3712cdf0e10cSrcweir         }
3713cdf0e10cSrcweir 
3714cdf0e10cSrcweir         bool bSpecSubsLineRectsCreated;
3715cdf0e10cSrcweir         if ( pSpecSubsLines )
3716cdf0e10cSrcweir         {
3717cdf0e10cSrcweir             // Lock already existing special subsidiary lines
3718cdf0e10cSrcweir             pSpecSubsLines->LockLines( sal_True );
3719cdf0e10cSrcweir             bSpecSubsLineRectsCreated = false;
3720cdf0e10cSrcweir         }
3721cdf0e10cSrcweir         else
3722cdf0e10cSrcweir         {
3723cdf0e10cSrcweir             // create new special subsidiardy lines
3724cdf0e10cSrcweir             pSpecSubsLines = new SwSubsRects;
3725cdf0e10cSrcweir             bSpecSubsLineRectsCreated = true;
3726cdf0e10cSrcweir         }
3727cdf0e10cSrcweir         // Add subsidiary lines of fly frame and its lowers
3728cdf0e10cSrcweir         RefreshLaySubsidiary( pPage, aRect );
3729cdf0e10cSrcweir         // paint subsidiary lines of fly frame and its lowers
3730cdf0e10cSrcweir         pSpecSubsLines->PaintSubsidiary( pOut, NULL );
3731cdf0e10cSrcweir         pSubsLines->PaintSubsidiary( pOut, pLines );
3732cdf0e10cSrcweir         if ( !bSubsLineRectsCreated )
3733cdf0e10cSrcweir             // unlock subsidiary lines
3734cdf0e10cSrcweir             pSubsLines->LockLines( sal_False );
3735cdf0e10cSrcweir         else
3736cdf0e10cSrcweir             // delete created subsidiary lines container
3737cdf0e10cSrcweir             DELETEZ( pSubsLines );
3738cdf0e10cSrcweir 
3739cdf0e10cSrcweir         if ( !bSpecSubsLineRectsCreated )
3740cdf0e10cSrcweir             // unlock special subsidiary lines
3741cdf0e10cSrcweir             pSpecSubsLines->LockLines( sal_False );
3742cdf0e10cSrcweir         else
3743cdf0e10cSrcweir         {
3744cdf0e10cSrcweir             // delete created special subsidiary lines container
3745cdf0e10cSrcweir             DELETEZ( pSpecSubsLines );
3746cdf0e10cSrcweir         }
3747cdf0e10cSrcweir     }
3748cdf0e10cSrcweir 
3749cdf0e10cSrcweir     SwLayoutFrm::Paint( aRect );
3750cdf0e10cSrcweir 
3751cdf0e10cSrcweir     Validate();
3752cdf0e10cSrcweir 
3753cdf0e10cSrcweir     // OD 19.12.2002 #106318# - first paint lines added by fly frame paint
3754cdf0e10cSrcweir     // and then unlock other lines.
3755cdf0e10cSrcweir     pLines->PaintLines( pOut );
3756cdf0e10cSrcweir     pLines->LockLines( sal_False );
3757cdf0e10cSrcweir 
3758cdf0e10cSrcweir     pOut->Pop();
3759cdf0e10cSrcweir 
3760cdf0e10cSrcweir 	if ( pProgress && pNoTxt )
3761cdf0e10cSrcweir 		pProgress->Reschedule();
3762cdf0e10cSrcweir }
3763cdf0e10cSrcweir /*************************************************************************
3764cdf0e10cSrcweir |*
3765cdf0e10cSrcweir |*	  SwTabFrm::Paint()
3766cdf0e10cSrcweir |*
3767cdf0e10cSrcweir |*	  Ersterstellung	MA 11. May. 93
3768cdf0e10cSrcweir |*	  Letzte Aenderung	MA 23. Mar. 95
3769cdf0e10cSrcweir |*
3770cdf0e10cSrcweir |*************************************************************************/
3771cdf0e10cSrcweir 
Paint(SwRect const & rRect,SwPrintData const * const) const3772cdf0e10cSrcweir void SwTabFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
3773cdf0e10cSrcweir {
3774cdf0e10cSrcweir     if ( pGlobalShell->GetViewOptions()->IsTable() )
3775cdf0e10cSrcweir     {
3776cdf0e10cSrcweir         // --> collapsing borders FME 2005-05-27 #i29550#
3777cdf0e10cSrcweir         if ( IsCollapsingBorders() )
3778cdf0e10cSrcweir         {
3779cdf0e10cSrcweir             SwBorderAttrAccess aAccess( SwFrm::GetCache(), (SwFrm*)this );
3780cdf0e10cSrcweir             const SwBorderAttrs &rAttrs = *aAccess.Get();
3781cdf0e10cSrcweir 
3782cdf0e10cSrcweir             // paint shadow
3783cdf0e10cSrcweir             if ( rAttrs.GetShadow().GetLocation() != SVX_SHADOW_NONE )
3784cdf0e10cSrcweir             {
3785cdf0e10cSrcweir                 SwRect aRect;
3786cdf0e10cSrcweir                 ::lcl_CalcBorderRect( aRect, this, rAttrs, sal_True );
3787cdf0e10cSrcweir                 PaintShadow( rRect, aRect, rAttrs );
3788cdf0e10cSrcweir             }
3789cdf0e10cSrcweir 
3790cdf0e10cSrcweir             // paint lines
3791cdf0e10cSrcweir             SwTabFrmPainter aHelper( *this );
3792cdf0e10cSrcweir             aHelper.PaintLines( *pGlobalShell->GetOut(), rRect );
3793cdf0e10cSrcweir         }
3794cdf0e10cSrcweir         // <-- collapsing
3795cdf0e10cSrcweir 
3796cdf0e10cSrcweir 		SwLayoutFrm::Paint( rRect );
3797cdf0e10cSrcweir     }
3798cdf0e10cSrcweir     // OD 10.01.2003 #i6467# - no light grey rectangle for page preview
3799cdf0e10cSrcweir     else if ( pGlobalShell->GetWin() && !pGlobalShell->IsPreView() )
3800cdf0e10cSrcweir 	{
3801cdf0e10cSrcweir         // OD 10.01.2003 #i6467# - intersect output rectangle with table frame
3802cdf0e10cSrcweir         SwRect aTabRect( Prt() );
3803cdf0e10cSrcweir         aTabRect.Pos() += Frm().Pos();
3804cdf0e10cSrcweir         SwRect aTabOutRect( rRect );
3805cdf0e10cSrcweir         aTabOutRect.Intersection( aTabRect );
3806cdf0e10cSrcweir         pGlobalShell->GetViewOptions()->
3807cdf0e10cSrcweir                 DrawRect( pGlobalShell->GetOut(), aTabOutRect, COL_LIGHTGRAY );
3808cdf0e10cSrcweir 	}
3809cdf0e10cSrcweir 	((SwTabFrm*)this)->ResetComplete();
3810cdf0e10cSrcweir }
3811cdf0e10cSrcweir 
3812cdf0e10cSrcweir /*************************************************************************
3813cdf0e10cSrcweir |*
3814cdf0e10cSrcweir |*	SwFrm::PaintShadow()
3815cdf0e10cSrcweir |*
3816cdf0e10cSrcweir |*	Beschreibung		Malt einen Schatten wenns das FrmFormat fordert.
3817cdf0e10cSrcweir |* 		Der Schatten wird immer an den auesseren Rand des OutRect gemalt.
3818cdf0e10cSrcweir |* 		Das OutRect wird ggf. so verkleinert, dass auf diesem das
3819cdf0e10cSrcweir |* 		malen der Umrandung stattfinden kann.
3820cdf0e10cSrcweir |*	Ersterstellung		MA 21. Dec. 92
3821cdf0e10cSrcweir |*	Letzte Aenderung	MA 29. May. 97
3822cdf0e10cSrcweir |*
3823cdf0e10cSrcweir |*************************************************************************/
3824cdf0e10cSrcweir /// OD 23.08.2002 #99657#
3825cdf0e10cSrcweir ///     draw full shadow rectangle for frames with transparent drawn backgrounds.
PaintShadow(const SwRect & rRect,SwRect & rOutRect,const SwBorderAttrs & rAttrs) const3826cdf0e10cSrcweir void SwFrm::PaintShadow( const SwRect& rRect, SwRect& rOutRect,
3827cdf0e10cSrcweir                          const SwBorderAttrs &rAttrs ) const
3828cdf0e10cSrcweir {
3829cdf0e10cSrcweir 	const SvxShadowItem &rShadow = rAttrs.GetShadow();
3830cdf0e10cSrcweir 	const long nWidth  = ::lcl_AlignWidth ( rShadow.GetWidth() );
3831cdf0e10cSrcweir 	const long nHeight = ::lcl_AlignHeight( rShadow.GetWidth() );
3832cdf0e10cSrcweir 
3833cdf0e10cSrcweir 	SwRects aRegion( 2, 2 );
3834cdf0e10cSrcweir 	SwRect aOut( rOutRect );
3835cdf0e10cSrcweir 
3836cdf0e10cSrcweir 	const sal_Bool bCnt	   = IsCntntFrm();
3837cdf0e10cSrcweir     const sal_Bool bTop    = !bCnt || rAttrs.GetTopLine  ( *(this) ) ? sal_True : sal_False;
3838cdf0e10cSrcweir     const sal_Bool bBottom = !bCnt || rAttrs.GetBottomLine( *(this) ) ? sal_True : sal_False;
3839cdf0e10cSrcweir 
3840cdf0e10cSrcweir     SvxShadowLocation eLoc = rShadow.GetLocation();
3841cdf0e10cSrcweir 
3842cdf0e10cSrcweir     SWRECTFN( this )
3843cdf0e10cSrcweir     if( IsVertical() )
3844cdf0e10cSrcweir     {
3845cdf0e10cSrcweir         switch( eLoc )
3846cdf0e10cSrcweir         {
3847cdf0e10cSrcweir             case SVX_SHADOW_BOTTOMRIGHT: eLoc = SVX_SHADOW_BOTTOMLEFT;  break;
3848cdf0e10cSrcweir             case SVX_SHADOW_TOPLEFT:     eLoc = SVX_SHADOW_TOPRIGHT;    break;
3849cdf0e10cSrcweir             case SVX_SHADOW_TOPRIGHT:    eLoc = SVX_SHADOW_BOTTOMRIGHT; break;
3850cdf0e10cSrcweir             case SVX_SHADOW_BOTTOMLEFT:  eLoc = SVX_SHADOW_TOPLEFT;     break;
3851cdf0e10cSrcweir             default: break;
3852cdf0e10cSrcweir         }
3853cdf0e10cSrcweir     }
3854cdf0e10cSrcweir 
3855cdf0e10cSrcweir     /// OD 23.08.2002 #99657# - determine, if full shadow rectangle have to
3856cdf0e10cSrcweir     ///     be drawn or only two shadow rectangles beside the frame.
3857cdf0e10cSrcweir     ///     draw full shadow rectangle, if frame background is drawn transparent.
3858cdf0e10cSrcweir     ///     Status Quo:
3859cdf0e10cSrcweir     ///         SwLayoutFrm can have transparent drawn backgrounds. Thus,
3860cdf0e10cSrcweir     ///         "asked" their frame format.
3861cdf0e10cSrcweir     sal_Bool bDrawFullShadowRectangle =
3862cdf0e10cSrcweir             ( IsLayoutFrm() &&
3863cdf0e10cSrcweir               (static_cast<const SwLayoutFrm*>(this))->GetFmt()->IsBackgroundTransparent()
3864cdf0e10cSrcweir             );
3865cdf0e10cSrcweir     switch ( eLoc )
3866cdf0e10cSrcweir 	{
3867cdf0e10cSrcweir 		case SVX_SHADOW_BOTTOMRIGHT:
3868cdf0e10cSrcweir 			{
3869cdf0e10cSrcweir                 if ( bDrawFullShadowRectangle )
3870cdf0e10cSrcweir                 {
3871cdf0e10cSrcweir                     /// OD 06.08.2002 #99657# - draw full shadow rectangle
3872cdf0e10cSrcweir                     aOut.Top( aOut.Top() + nHeight );
3873cdf0e10cSrcweir                     aOut.Left( aOut.Left() + nWidth );
3874cdf0e10cSrcweir                     aRegion.Insert( aOut, aRegion.Count() );
3875cdf0e10cSrcweir                 }
3876cdf0e10cSrcweir                 else
3877cdf0e10cSrcweir                 {
3878cdf0e10cSrcweir                     aOut.Top ( aOut.Bottom() - nHeight );
3879cdf0e10cSrcweir                     aOut.Left( aOut.Left()   + nWidth );
3880cdf0e10cSrcweir                     if ( bBottom )
3881cdf0e10cSrcweir                         aRegion.Insert( aOut, aRegion.Count() );
3882cdf0e10cSrcweir                     aOut.Left( aOut.Right()   - nWidth );
3883cdf0e10cSrcweir                     aOut.Top ( rOutRect.Top() + nHeight );
3884cdf0e10cSrcweir                     if ( bBottom )
3885cdf0e10cSrcweir                         aOut.Bottom( aOut.Bottom() - nHeight );
3886cdf0e10cSrcweir                     if ( bCnt && (!bTop || !bBottom) )
3887cdf0e10cSrcweir                         ::lcl_ExtendLeftAndRight( aOut, *(this), rAttrs, fnRect );
3888cdf0e10cSrcweir                     aRegion.Insert( aOut, aRegion.Count() );
3889cdf0e10cSrcweir                 }
3890cdf0e10cSrcweir 
3891cdf0e10cSrcweir 				rOutRect.Right ( rOutRect.Right() - nWidth );
3892cdf0e10cSrcweir 				rOutRect.Bottom( rOutRect.Bottom()- nHeight );
3893cdf0e10cSrcweir 			}
3894cdf0e10cSrcweir 			break;
3895cdf0e10cSrcweir 		case SVX_SHADOW_TOPLEFT:
3896cdf0e10cSrcweir 			{
3897cdf0e10cSrcweir                 if ( bDrawFullShadowRectangle )
3898cdf0e10cSrcweir                 {
3899cdf0e10cSrcweir                     /// OD 06.08.2002 #99657# - draw full shadow rectangle
3900cdf0e10cSrcweir                     aOut.Bottom( aOut.Bottom() - nHeight );
3901cdf0e10cSrcweir                     aOut.Right( aOut.Right() - nWidth );
3902cdf0e10cSrcweir                     aRegion.Insert( aOut, aRegion.Count() );
3903cdf0e10cSrcweir                 }
3904cdf0e10cSrcweir                 else
3905cdf0e10cSrcweir                 {
3906cdf0e10cSrcweir                     aOut.Bottom( aOut.Top()   + nHeight );
3907cdf0e10cSrcweir                     aOut.Right ( aOut.Right() - nWidth );
3908cdf0e10cSrcweir                     if ( bTop )
3909cdf0e10cSrcweir                         aRegion.Insert( aOut, aRegion.Count() );
3910cdf0e10cSrcweir                     aOut.Right ( aOut.Left() + nWidth );
3911cdf0e10cSrcweir                     aOut.Bottom( rOutRect.Bottom() - nHeight );
3912cdf0e10cSrcweir                     if ( bTop )
3913cdf0e10cSrcweir                         aOut.Top( aOut.Top() + nHeight );
3914cdf0e10cSrcweir                     if ( bCnt && (!bBottom || !bTop) )
3915cdf0e10cSrcweir                         ::lcl_ExtendLeftAndRight( aOut, *(this), rAttrs, fnRect );
3916cdf0e10cSrcweir                     aRegion.Insert( aOut, aRegion.Count() );
3917cdf0e10cSrcweir                 }
3918cdf0e10cSrcweir 
3919cdf0e10cSrcweir 				rOutRect.Left( rOutRect.Left() + nWidth );
3920cdf0e10cSrcweir 				rOutRect.Top(  rOutRect.Top() + nHeight );
3921cdf0e10cSrcweir 			}
3922cdf0e10cSrcweir 			break;
3923cdf0e10cSrcweir 		case SVX_SHADOW_TOPRIGHT:
3924cdf0e10cSrcweir 			{
3925cdf0e10cSrcweir                 if ( bDrawFullShadowRectangle )
3926cdf0e10cSrcweir                 {
3927cdf0e10cSrcweir                     /// OD 06.08.2002 #99657# - draw full shadow rectangle
3928cdf0e10cSrcweir                     aOut.Bottom( aOut.Bottom() - nHeight);
3929cdf0e10cSrcweir                     aOut.Left( aOut.Left() + nWidth );
3930cdf0e10cSrcweir                     aRegion.Insert( aOut, aRegion.Count() );
3931cdf0e10cSrcweir                 }
3932cdf0e10cSrcweir                 else
3933cdf0e10cSrcweir                 {
3934cdf0e10cSrcweir                     aOut.Bottom( aOut.Top() + nHeight );
3935cdf0e10cSrcweir                     aOut.Left (  aOut.Left()+ nWidth );
3936cdf0e10cSrcweir                     if ( bTop )
3937cdf0e10cSrcweir                         aRegion.Insert( aOut, aRegion.Count() );
3938cdf0e10cSrcweir                     aOut.Left  ( aOut.Right() - nWidth );
3939cdf0e10cSrcweir                     aOut.Bottom( rOutRect.Bottom() - nHeight );
3940cdf0e10cSrcweir                     if ( bTop )
3941cdf0e10cSrcweir                         aOut.Top( aOut.Top() + nHeight );
3942cdf0e10cSrcweir                     if ( bCnt && (!bBottom || bTop) )
3943cdf0e10cSrcweir                         ::lcl_ExtendLeftAndRight( aOut, *(this), rAttrs, fnRect );
3944cdf0e10cSrcweir                     aRegion.Insert( aOut, aRegion.Count() );
3945cdf0e10cSrcweir                 }
3946cdf0e10cSrcweir 
3947cdf0e10cSrcweir                 rOutRect.Right( rOutRect.Right() - nWidth );
3948cdf0e10cSrcweir 				rOutRect.Top( rOutRect.Top() + nHeight );
3949cdf0e10cSrcweir 			}
3950cdf0e10cSrcweir 			break;
3951cdf0e10cSrcweir 		case SVX_SHADOW_BOTTOMLEFT:
3952cdf0e10cSrcweir 			{
3953cdf0e10cSrcweir                 if ( bDrawFullShadowRectangle )
3954cdf0e10cSrcweir                 {
3955cdf0e10cSrcweir                     /// OD 06.08.2002 #99657# - draw full shadow rectangle
3956cdf0e10cSrcweir                     aOut.Top( aOut.Top() + nHeight );
3957cdf0e10cSrcweir                     aOut.Right( aOut.Right() - nWidth );
3958cdf0e10cSrcweir                     aRegion.Insert( aOut, aRegion.Count() );
3959cdf0e10cSrcweir                 }
3960cdf0e10cSrcweir                 else
3961cdf0e10cSrcweir                 {
3962cdf0e10cSrcweir                     aOut.Top  ( aOut.Bottom()- nHeight );
3963cdf0e10cSrcweir                     aOut.Right( aOut.Right() - nWidth );
3964cdf0e10cSrcweir                     if ( bBottom )
3965cdf0e10cSrcweir                         aRegion.Insert( aOut, aRegion.Count() );
3966cdf0e10cSrcweir                     aOut.Right( aOut.Left() + nWidth );
3967cdf0e10cSrcweir                     aOut.Top( rOutRect.Top() + nHeight );
3968cdf0e10cSrcweir                     if ( bBottom )
3969cdf0e10cSrcweir                         aOut.Bottom( aOut.Bottom() - nHeight );
3970cdf0e10cSrcweir                     if ( bCnt && (!bTop || !bBottom) )
3971cdf0e10cSrcweir                         ::lcl_ExtendLeftAndRight( aOut, *(this), rAttrs, fnRect );
3972cdf0e10cSrcweir                     aRegion.Insert( aOut, aRegion.Count() );
3973cdf0e10cSrcweir                 }
3974cdf0e10cSrcweir 
3975cdf0e10cSrcweir 				rOutRect.Left( rOutRect.Left() + nWidth );
3976cdf0e10cSrcweir 				rOutRect.Bottom( rOutRect.Bottom() - nHeight );
3977cdf0e10cSrcweir 			}
3978cdf0e10cSrcweir 			break;
3979cdf0e10cSrcweir         default:
3980cdf0e10cSrcweir             ASSERT( !this, "new ShadowLocation() ?" )
3981cdf0e10cSrcweir             break;
3982cdf0e10cSrcweir     }
3983cdf0e10cSrcweir 
3984cdf0e10cSrcweir 	OutputDevice *pOut = pGlobalShell->GetOut();
3985cdf0e10cSrcweir 
3986cdf0e10cSrcweir     sal_uLong nOldDrawMode = pOut->GetDrawMode();
3987cdf0e10cSrcweir     Color aShadowColor( rShadow.GetColor() );
3988cdf0e10cSrcweir     if( aRegion.Count() && pGlobalShell->GetWin() &&
3989cdf0e10cSrcweir         Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
3990cdf0e10cSrcweir     {
3991cdf0e10cSrcweir         // Is heigh contrast mode, the output device has already set the
3992cdf0e10cSrcweir         // DRAWMODE_SETTINGSFILL flag. This causes the SetFillColor function
3993cdf0e10cSrcweir         // to ignore the setting of a new color. Therefore we have to reset
3994cdf0e10cSrcweir         // the drawing mode
3995cdf0e10cSrcweir         pOut->SetDrawMode( 0 );
3996cdf0e10cSrcweir         aShadowColor = SwViewOption::GetFontColor();
3997cdf0e10cSrcweir     }
3998cdf0e10cSrcweir 
3999cdf0e10cSrcweir     if ( pOut->GetFillColor() != aShadowColor )
4000cdf0e10cSrcweir         pOut->SetFillColor( aShadowColor );
4001cdf0e10cSrcweir 
4002cdf0e10cSrcweir     pOut->SetDrawMode( nOldDrawMode );
4003cdf0e10cSrcweir 
4004cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < aRegion.Count(); ++i )
4005cdf0e10cSrcweir 	{
4006cdf0e10cSrcweir 		SwRect &rOut = aRegion[i];
4007cdf0e10cSrcweir 		aOut = rOut;
4008cdf0e10cSrcweir         // OD 30.09.2002 #103636# - no SwAlign of shadow rectangle
4009cdf0e10cSrcweir         // no alignment necessary, because (1) <rRect> is already aligned
4010cdf0e10cSrcweir         // and because (2) paint of border and background will occur later.
4011cdf0e10cSrcweir         // Thus, (1) assures that no conflicts with neighbour object will occure
4012cdf0e10cSrcweir         // and (2) assures that border and background is not affected by the
4013cdf0e10cSrcweir         // shadow paint.
4014cdf0e10cSrcweir         /*
4015cdf0e10cSrcweir         ::SwAlignRect( aOut, pGlobalShell );
4016cdf0e10cSrcweir         */
4017cdf0e10cSrcweir 		if ( rRect.IsOver( aOut ) && aOut.Height() > 0 && aOut.Width() > 0 )
4018cdf0e10cSrcweir 		{
4019cdf0e10cSrcweir 			aOut._Intersection( rRect );
4020cdf0e10cSrcweir 			pOut->DrawRect( aOut.SVRect() );
4021cdf0e10cSrcweir 		}
4022cdf0e10cSrcweir 	}
4023cdf0e10cSrcweir }
4024cdf0e10cSrcweir 
4025cdf0e10cSrcweir /*************************************************************************
4026cdf0e10cSrcweir |*
4027cdf0e10cSrcweir |*	SwFrm::PaintBorderLine()
4028cdf0e10cSrcweir |*
4029cdf0e10cSrcweir |*	Ersterstellung		MA 22. Dec. 92
4030cdf0e10cSrcweir |*	Letzte Aenderung	MA 22. Jan. 95
4031cdf0e10cSrcweir |*
4032cdf0e10cSrcweir |*************************************************************************/
4033cdf0e10cSrcweir 
PaintBorderLine(const SwRect & rRect,const SwRect & rOutRect,const SwPageFrm * pPage,const Color * pColor) const4034cdf0e10cSrcweir void SwFrm::PaintBorderLine( const SwRect& rRect,
4035cdf0e10cSrcweir 							 const SwRect& rOutRect,
4036cdf0e10cSrcweir 							 const SwPageFrm *pPage,
4037cdf0e10cSrcweir 							 const Color *pColor ) const
4038cdf0e10cSrcweir {
4039cdf0e10cSrcweir 	if ( !rOutRect.IsOver( rRect ) )
4040cdf0e10cSrcweir 		return;
4041cdf0e10cSrcweir 
4042cdf0e10cSrcweir 	SwRect aOut( rOutRect );
4043cdf0e10cSrcweir 	aOut._Intersection( rRect );
4044cdf0e10cSrcweir 
4045cdf0e10cSrcweir 	const SwTabFrm *pTab = IsCellFrm() ? FindTabFrm() : 0;
4046cdf0e10cSrcweir     sal_uInt8 nSubCol = ( IsCellFrm() || IsRowFrm() ) ? SUBCOL_TAB :
4047cdf0e10cSrcweir                    ( IsInSct() ? SUBCOL_SECT :
4048cdf0e10cSrcweir                    ( IsInFly() ? SUBCOL_FLY : SUBCOL_PAGE ) );
4049cdf0e10cSrcweir     if( pColor && pGlobalShell->GetWin() &&
4050cdf0e10cSrcweir         Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
4051cdf0e10cSrcweir     {
4052cdf0e10cSrcweir         pColor = &SwViewOption::GetFontColor();
4053cdf0e10cSrcweir     }
4054cdf0e10cSrcweir 
4055cdf0e10cSrcweir 	if ( pPage->GetSortedObjs() )
4056cdf0e10cSrcweir 	{
4057cdf0e10cSrcweir 		SwRegionRects aRegion( aOut, 4, 1 );
4058cdf0e10cSrcweir 		::lcl_SubtractFlys( this, pPage, aOut, aRegion );
4059cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < aRegion.Count(); ++i )
4060cdf0e10cSrcweir             pLines->AddLineRect( aRegion[i], pColor, pTab, nSubCol );
4061cdf0e10cSrcweir 	}
4062cdf0e10cSrcweir 	else
4063cdf0e10cSrcweir         pLines->AddLineRect( aOut, pColor, pTab, nSubCol );
4064cdf0e10cSrcweir }
4065cdf0e10cSrcweir 
4066cdf0e10cSrcweir /*************************************************************************
4067cdf0e10cSrcweir |*
4068cdf0e10cSrcweir |*	SwFrm::PaintBorderLines()
4069cdf0e10cSrcweir |*
4070cdf0e10cSrcweir |*	Beschreibung		Nur alle Linien einfach oder alle Linien doppelt!!!!
4071cdf0e10cSrcweir |*	Ersterstellung		MA 22. Dec. 92
4072cdf0e10cSrcweir |*	Letzte Aenderung	MA 22. Mar. 95
4073cdf0e10cSrcweir |*
4074cdf0e10cSrcweir |*************************************************************************/
4075cdf0e10cSrcweir 
4076cdf0e10cSrcweir // OD 29.04.2003 #107169# - method called for left and right border rectangles.
4077cdf0e10cSrcweir // For a printer output device perform adjustment for non-overlapping top and
4078cdf0e10cSrcweir // bottom border rectangles. Thus, add parameter <_bPrtOutputDev> to indicate
4079cdf0e10cSrcweir // printer output device.
4080cdf0e10cSrcweir // NOTE: For printer output device left/right border rectangle <_iorRect>
4081cdf0e10cSrcweir //       has to be already non-overlapping the outer top/bottom border rectangle.
lcl_SubTopBottom(SwRect & _iorRect,const SvxBoxItem & _rBox,const SwBorderAttrs & _rAttrs,const SwFrm & _rFrm,const SwRectFn & _rRectFn,const sal_Bool _bPrtOutputDev)4082cdf0e10cSrcweir void MA_FASTCALL lcl_SubTopBottom( SwRect&              _iorRect,
4083cdf0e10cSrcweir                                    const SvxBoxItem&    _rBox,
4084cdf0e10cSrcweir                                    const SwBorderAttrs& _rAttrs,
4085cdf0e10cSrcweir                                    const SwFrm&         _rFrm,
4086cdf0e10cSrcweir                                    const SwRectFn&      _rRectFn,
4087cdf0e10cSrcweir                                    const sal_Bool       _bPrtOutputDev )
4088cdf0e10cSrcweir {
4089cdf0e10cSrcweir     const sal_Bool bCnt = _rFrm.IsCntntFrm();
4090cdf0e10cSrcweir     if ( _rBox.GetTop() && _rBox.GetTop()->GetInWidth() &&
4091cdf0e10cSrcweir          ( !bCnt || _rAttrs.GetTopLine( _rFrm ) )
4092cdf0e10cSrcweir        )
4093cdf0e10cSrcweir 	{
4094cdf0e10cSrcweir         // substract distance between outer and inner line.
4095cdf0e10cSrcweir         SwTwips nDist = ::lcl_MinHeightDist( _rBox.GetTop()->GetDistance() );
4096cdf0e10cSrcweir         // OD 19.05.2003 #109667# - non-overlapping border rectangles:
4097cdf0e10cSrcweir         // adjust x-/y-position, if inner top line is a hair line (width = 1)
4098cdf0e10cSrcweir         sal_Bool bIsInnerTopLineHairline = sal_False;
4099cdf0e10cSrcweir         if ( !_bPrtOutputDev )
4100cdf0e10cSrcweir         {
4101cdf0e10cSrcweir             // additionally substract width of top outer line
4102cdf0e10cSrcweir             // --> left/right inner/outer line doesn't overlap top outer line.
4103cdf0e10cSrcweir             nDist += ::lcl_AlignHeight( _rBox.GetTop()->GetOutWidth() );
4104cdf0e10cSrcweir         }
4105cdf0e10cSrcweir         else
4106cdf0e10cSrcweir         {
4107cdf0e10cSrcweir             // OD 29.04.2003 #107169# - additionally substract width of top inner line
4108cdf0e10cSrcweir             // --> left/right inner/outer line doesn't overlap top inner line.
4109cdf0e10cSrcweir             nDist += ::lcl_AlignHeight( _rBox.GetTop()->GetInWidth() );
4110cdf0e10cSrcweir             bIsInnerTopLineHairline = _rBox.GetTop()->GetInWidth() == 1;
4111cdf0e10cSrcweir         }
4112cdf0e10cSrcweir         (_iorRect.*_rRectFn->fnSubTop)( -nDist );
4113cdf0e10cSrcweir         // OD 19.05.2003 #109667# - adjust calculated border top, if inner top line
4114cdf0e10cSrcweir         // is a hair line
4115cdf0e10cSrcweir         if ( bIsInnerTopLineHairline )
4116cdf0e10cSrcweir         {
4117cdf0e10cSrcweir             if ( _rFrm.IsVertical() )
4118cdf0e10cSrcweir             {
4119cdf0e10cSrcweir                 // right of border rectangle has to be checked and adjusted
4120cdf0e10cSrcweir                 Point aCompPt( _iorRect.Right(), 0 );
4121cdf0e10cSrcweir                 Point aRefPt( aCompPt.X() + 1, aCompPt.Y() );
4122cdf0e10cSrcweir                 lcl_CompPxPosAndAdjustPos( *(pGlobalShell->GetOut()),
4123cdf0e10cSrcweir                                           aRefPt, aCompPt,
4124cdf0e10cSrcweir                                           sal_True, -1 );
4125cdf0e10cSrcweir                 _iorRect.Right( aCompPt.X() );
4126cdf0e10cSrcweir             }
4127cdf0e10cSrcweir             else
4128cdf0e10cSrcweir             {
4129cdf0e10cSrcweir                 // top of border rectangle has to be checked and adjusted
4130cdf0e10cSrcweir                 Point aCompPt( 0, _iorRect.Top() );
4131cdf0e10cSrcweir                 Point aRefPt( aCompPt.X(), aCompPt.Y() - 1 );
4132cdf0e10cSrcweir                 lcl_CompPxPosAndAdjustPos( *(pGlobalShell->GetOut()),
4133cdf0e10cSrcweir                                           aRefPt, aCompPt,
4134cdf0e10cSrcweir                                           sal_False, +1 );
4135cdf0e10cSrcweir                 _iorRect.Top( aCompPt.Y() );
4136cdf0e10cSrcweir             }
4137cdf0e10cSrcweir         }
4138cdf0e10cSrcweir 	}
4139cdf0e10cSrcweir 
4140cdf0e10cSrcweir     if ( _rBox.GetBottom() && _rBox.GetBottom()->GetInWidth() &&
4141cdf0e10cSrcweir          ( !bCnt || _rAttrs.GetBottomLine( _rFrm ) )
4142cdf0e10cSrcweir        )
4143cdf0e10cSrcweir 	{
4144cdf0e10cSrcweir         // substract distance between outer and inner line.
4145cdf0e10cSrcweir         SwTwips nDist = ::lcl_MinHeightDist( _rBox.GetBottom()->GetDistance() );
4146cdf0e10cSrcweir         // OD 19.05.2003 #109667# - non-overlapping border rectangles:
4147cdf0e10cSrcweir         // adjust x-/y-position, if inner bottom line is a hair line (width = 1)
4148cdf0e10cSrcweir         sal_Bool bIsInnerBottomLineHairline = sal_False;
4149cdf0e10cSrcweir         if ( !_bPrtOutputDev )
4150cdf0e10cSrcweir         {
4151cdf0e10cSrcweir             // additionally substract width of bottom outer line
4152cdf0e10cSrcweir             // --> left/right inner/outer line doesn't overlap bottom outer line.
4153cdf0e10cSrcweir             nDist += ::lcl_AlignHeight( _rBox.GetBottom()->GetOutWidth() );
4154cdf0e10cSrcweir         }
4155cdf0e10cSrcweir         else
4156cdf0e10cSrcweir         {
4157cdf0e10cSrcweir             // OD 29.04.2003 #107169# - additionally substract width of bottom inner line
4158cdf0e10cSrcweir             // --> left/right inner/outer line doesn't overlap bottom inner line.
4159cdf0e10cSrcweir             nDist += ::lcl_AlignHeight( _rBox.GetBottom()->GetInWidth() );
4160cdf0e10cSrcweir             bIsInnerBottomLineHairline = _rBox.GetBottom()->GetInWidth() == 1;
4161cdf0e10cSrcweir         }
4162cdf0e10cSrcweir         (_iorRect.*_rRectFn->fnAddBottom)( -nDist );
4163cdf0e10cSrcweir         // OD 19.05.2003 #109667# - adjust calculated border bottom, if inner
4164cdf0e10cSrcweir         // bottom line is a hair line.
4165cdf0e10cSrcweir         if ( bIsInnerBottomLineHairline )
4166cdf0e10cSrcweir         {
4167cdf0e10cSrcweir             if ( _rFrm.IsVertical() )
4168cdf0e10cSrcweir             {
4169cdf0e10cSrcweir                 // left of border rectangle has to be checked and adjusted
4170cdf0e10cSrcweir                 Point aCompPt( _iorRect.Left(), 0 );
4171cdf0e10cSrcweir                 Point aRefPt( aCompPt.X() - 1, aCompPt.Y() );
4172cdf0e10cSrcweir                 lcl_CompPxPosAndAdjustPos( *(pGlobalShell->GetOut()),
4173cdf0e10cSrcweir                                           aRefPt, aCompPt,
4174cdf0e10cSrcweir                                           sal_True, +1 );
4175cdf0e10cSrcweir                 _iorRect.Left( aCompPt.X() );
4176cdf0e10cSrcweir             }
4177cdf0e10cSrcweir             else
4178cdf0e10cSrcweir             {
4179cdf0e10cSrcweir                 // bottom of border rectangle has to be checked and adjusted
4180cdf0e10cSrcweir                 Point aCompPt( 0, _iorRect.Bottom() );
4181cdf0e10cSrcweir                 Point aRefPt( aCompPt.X(), aCompPt.Y() + 1 );
4182cdf0e10cSrcweir                 lcl_CompPxPosAndAdjustPos( *(pGlobalShell->GetOut()),
4183cdf0e10cSrcweir                                           aRefPt, aCompPt,
4184cdf0e10cSrcweir                                           sal_False, -1 );
4185cdf0e10cSrcweir                 _iorRect.Bottom( aCompPt.Y() );
4186cdf0e10cSrcweir             }
4187cdf0e10cSrcweir         }
4188cdf0e10cSrcweir 	}
4189cdf0e10cSrcweir }
4190cdf0e10cSrcweir 
4191cdf0e10cSrcweir // method called for top and bottom border rectangles.
lcl_SubLeftRight(SwRect & rRect,const SvxBoxItem & rBox,const SwRectFn & rRectFn)4192cdf0e10cSrcweir void MA_FASTCALL lcl_SubLeftRight( SwRect&           rRect,
4193cdf0e10cSrcweir                                    const SvxBoxItem& rBox,
4194cdf0e10cSrcweir                                    const SwRectFn&   rRectFn )
4195cdf0e10cSrcweir {
4196cdf0e10cSrcweir 	if ( rBox.GetLeft() && rBox.GetLeft()->GetInWidth() )
4197cdf0e10cSrcweir 	{
4198cdf0e10cSrcweir         const long nDist = ::lcl_MinWidthDist( rBox.GetLeft()->GetDistance() )
4199cdf0e10cSrcweir                            + ::lcl_AlignWidth( rBox.GetLeft()->GetOutWidth() );
4200cdf0e10cSrcweir         (rRect.*rRectFn->fnSubLeft)( -nDist );
4201cdf0e10cSrcweir 	}
4202cdf0e10cSrcweir 
4203cdf0e10cSrcweir 	if ( rBox.GetRight() && rBox.GetRight()->GetInWidth() )
4204cdf0e10cSrcweir 	{
4205cdf0e10cSrcweir         const long nDist = ::lcl_MinWidthDist( rBox.GetRight()->GetDistance() )
4206cdf0e10cSrcweir                            + ::lcl_AlignWidth( rBox.GetRight()->GetOutWidth() );
4207cdf0e10cSrcweir         (rRect.*rRectFn->fnAddRight)( -nDist );
4208cdf0e10cSrcweir 	}
4209cdf0e10cSrcweir }
4210cdf0e10cSrcweir 
4211cdf0e10cSrcweir // OD 19.05.2003 #109667# - merge <lcl_PaintLeftLine> and <lcl_PaintRightLine>
4212cdf0e10cSrcweir // into new method <lcl_PaintLeftRightLine(..)>
lcl_PaintLeftRightLine(const sal_Bool _bLeft,const SwFrm & _rFrm,const SwPageFrm & _rPage,const SwRect & _rOutRect,const SwRect & _rRect,const SwBorderAttrs & _rAttrs,const SwRectFn & _rRectFn)4213cdf0e10cSrcweir void lcl_PaintLeftRightLine( const sal_Bool         _bLeft,
4214cdf0e10cSrcweir                              const SwFrm&           _rFrm,
4215cdf0e10cSrcweir                              const SwPageFrm&       _rPage,
4216cdf0e10cSrcweir                              const SwRect&          _rOutRect,
4217cdf0e10cSrcweir                              const SwRect&          _rRect,
4218cdf0e10cSrcweir                              const SwBorderAttrs&   _rAttrs,
4219cdf0e10cSrcweir                              const SwRectFn&        _rRectFn )
4220cdf0e10cSrcweir {
4221cdf0e10cSrcweir     const SvxBoxItem& rBox = _rAttrs.GetBox();
4222cdf0e10cSrcweir     const sal_Bool bR2L = _rFrm.IsCellFrm() && _rFrm.IsRightToLeft();
4223cdf0e10cSrcweir     const SvxBorderLine* pLeftRightBorder = 0;
4224cdf0e10cSrcweir     if ( _bLeft )
4225cdf0e10cSrcweir     {
4226cdf0e10cSrcweir         pLeftRightBorder = bR2L ? rBox.GetRight() : rBox.GetLeft();
4227cdf0e10cSrcweir     }
4228cdf0e10cSrcweir     else
4229cdf0e10cSrcweir     {
4230cdf0e10cSrcweir         pLeftRightBorder = bR2L ? rBox.GetLeft() : rBox.GetRight();
4231cdf0e10cSrcweir     }
4232cdf0e10cSrcweir     // OD 06.05.2003 #107169# - init boolean indicating printer output device.
4233cdf0e10cSrcweir     const sal_Bool bPrtOutputDev =
4234cdf0e10cSrcweir             ( OUTDEV_PRINTER == pGlobalShell->GetOut()->GetOutDevType() );
4235cdf0e10cSrcweir 
4236cdf0e10cSrcweir     if ( !pLeftRightBorder )
4237cdf0e10cSrcweir     {
4238cdf0e10cSrcweir         return;
4239cdf0e10cSrcweir     }
4240cdf0e10cSrcweir 
4241cdf0e10cSrcweir     SwRect aRect( _rOutRect );
4242cdf0e10cSrcweir     if ( _bLeft )
4243cdf0e10cSrcweir     {
4244cdf0e10cSrcweir         (aRect.*_rRectFn->fnAddRight)( ::lcl_AlignWidth( pLeftRightBorder->GetOutWidth() ) -
4245cdf0e10cSrcweir                                        (aRect.*_rRectFn->fnGetWidth)() );
4246cdf0e10cSrcweir     }
4247cdf0e10cSrcweir     else
4248cdf0e10cSrcweir     {
4249cdf0e10cSrcweir         (aRect.*_rRectFn->fnSubLeft)( ::lcl_AlignWidth( pLeftRightBorder->GetOutWidth() ) -
4250cdf0e10cSrcweir                                       (aRect.*_rRectFn->fnGetWidth)() );
4251cdf0e10cSrcweir     }
4252cdf0e10cSrcweir 
4253cdf0e10cSrcweir     const sal_Bool bCnt = _rFrm.IsCntntFrm();
4254cdf0e10cSrcweir 
4255cdf0e10cSrcweir     if ( bCnt )
4256cdf0e10cSrcweir     {
4257cdf0e10cSrcweir         ::lcl_ExtendLeftAndRight( aRect, _rFrm, _rAttrs, _rRectFn );
4258cdf0e10cSrcweir     }
4259cdf0e10cSrcweir 
4260cdf0e10cSrcweir     // OD 06.05.2003 #107169# - adjustments for printer output device
4261cdf0e10cSrcweir     if ( bPrtOutputDev )
4262cdf0e10cSrcweir     {
4263cdf0e10cSrcweir         // substract width of outer top line.
4264cdf0e10cSrcweir         if ( rBox.GetTop() && (!bCnt || _rAttrs.GetTopLine( _rFrm )) )
4265cdf0e10cSrcweir         {
4266cdf0e10cSrcweir             long nDist = ::lcl_AlignHeight( rBox.GetTop()->GetOutWidth() );
4267cdf0e10cSrcweir             (aRect.*_rRectFn->fnSubTop)( -nDist );
4268cdf0e10cSrcweir             // OD 19.05.2003 #109667# - If outer top line is hair line, calculated
4269cdf0e10cSrcweir             // top has to be adjusted.
4270cdf0e10cSrcweir             if ( nDist == 1 )
4271cdf0e10cSrcweir             {
4272cdf0e10cSrcweir                 if ( _rFrm.IsVertical() )
4273cdf0e10cSrcweir                 {
4274cdf0e10cSrcweir                     // right of border rectangle has to be checked and adjusted
4275cdf0e10cSrcweir                     Point aCompPt( aRect.Right(), 0 );
4276cdf0e10cSrcweir                     Point aRefPt( aCompPt.X() + 1, aCompPt.Y() );
4277cdf0e10cSrcweir                     lcl_CompPxPosAndAdjustPos( *(pGlobalShell->GetOut()),
4278cdf0e10cSrcweir                                               aRefPt, aCompPt,
4279cdf0e10cSrcweir                                               sal_True, -1 );
4280cdf0e10cSrcweir                     aRect.Right( aCompPt.X() );
4281cdf0e10cSrcweir                 }
4282cdf0e10cSrcweir                 else
4283cdf0e10cSrcweir                 {
4284cdf0e10cSrcweir                     // top of border rectangle has to be checked and adjusted
4285cdf0e10cSrcweir                     Point aCompPt( 0, aRect.Top() );
4286cdf0e10cSrcweir                     Point aRefPt( aCompPt.X(), aCompPt.Y() - 1 );
4287cdf0e10cSrcweir                     lcl_CompPxPosAndAdjustPos( *(pGlobalShell->GetOut()),
4288cdf0e10cSrcweir                                               aRefPt, aCompPt,
4289cdf0e10cSrcweir                                               sal_False, +1 );
4290cdf0e10cSrcweir                     aRect.Top( aCompPt.Y() );
4291cdf0e10cSrcweir                 }
4292cdf0e10cSrcweir             }
4293cdf0e10cSrcweir         }
4294cdf0e10cSrcweir         // substract width of outer bottom line.
4295cdf0e10cSrcweir         if ( rBox.GetBottom() && (!bCnt || _rAttrs.GetBottomLine( _rFrm )) )
4296cdf0e10cSrcweir         {
4297cdf0e10cSrcweir             long nDist = ::lcl_AlignHeight( rBox.GetBottom()->GetOutWidth());
4298cdf0e10cSrcweir             (aRect.*_rRectFn->fnAddBottom)( -nDist );
4299cdf0e10cSrcweir             // OD 19.05.2003 #109667# - If outer bottom line is hair line, calculated
4300cdf0e10cSrcweir             // top has to be adjusted.
4301cdf0e10cSrcweir             if ( nDist == 1 )
4302cdf0e10cSrcweir             {
4303cdf0e10cSrcweir                 if ( _rFrm.IsVertical() )
4304cdf0e10cSrcweir                 {
4305cdf0e10cSrcweir                     // left of border rectangle has to be checked and adjusted
4306cdf0e10cSrcweir                     Point aCompPt( aRect.Left(), 0 );
4307cdf0e10cSrcweir                     Point aRefPt( aCompPt.X() - 1, aCompPt.Y() );
4308cdf0e10cSrcweir                     lcl_CompPxPosAndAdjustPos( *(pGlobalShell->GetOut()),
4309cdf0e10cSrcweir                                               aRefPt, aCompPt,
4310cdf0e10cSrcweir                                               sal_True, +1 );
4311cdf0e10cSrcweir                     aRect.Left( aCompPt.X() );
4312cdf0e10cSrcweir                 }
4313cdf0e10cSrcweir                 else
4314cdf0e10cSrcweir                 {
4315cdf0e10cSrcweir                     // bottom of border rectangle has to be checked and adjusted
4316cdf0e10cSrcweir                     Point aCompPt( 0, aRect.Bottom() );
4317cdf0e10cSrcweir                     Point aRefPt( aCompPt.X(), aCompPt.Y() + 1 );
4318cdf0e10cSrcweir                     lcl_CompPxPosAndAdjustPos( *(pGlobalShell->GetOut()),
4319cdf0e10cSrcweir                                               aRefPt, aCompPt,
4320cdf0e10cSrcweir                                               sal_False, -1 );
4321cdf0e10cSrcweir                     aRect.Bottom( aCompPt.Y() );
4322cdf0e10cSrcweir                 }
4323cdf0e10cSrcweir             }
4324cdf0e10cSrcweir         }
4325cdf0e10cSrcweir     }
4326cdf0e10cSrcweir 
4327cdf0e10cSrcweir     if ( !pLeftRightBorder->GetInWidth() )
4328cdf0e10cSrcweir     {
4329cdf0e10cSrcweir         // OD 06.05.2003 #107169# - add 6th parameter
4330cdf0e10cSrcweir         ::lcl_SubTopBottom( aRect, rBox, _rAttrs, _rFrm, _rRectFn, bPrtOutputDev );
4331cdf0e10cSrcweir     }
4332cdf0e10cSrcweir 
4333cdf0e10cSrcweir     // OD 29.04.2003 #107169# - paint SwAligned-rectangle
4334cdf0e10cSrcweir     {
4335cdf0e10cSrcweir         SwRect aPaintRect( aRect );
4336cdf0e10cSrcweir         ::SwAlignRect( aPaintRect, _rFrm.getRootFrm()->GetCurrShell() );
4337cdf0e10cSrcweir         // if <SwAlignRect> reveals rectangle with no width, adjust rectangle
4338cdf0e10cSrcweir         // to the prior left postion with width of one twip.
4339cdf0e10cSrcweir         if ( (aPaintRect.*_rRectFn->fnGetWidth)() == 0 )
4340cdf0e10cSrcweir         {
4341cdf0e10cSrcweir             if ( _bLeft )
4342cdf0e10cSrcweir             {
4343cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnSetLeft)( (aRect.*_rRectFn->fnGetLeft)() );
4344cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnSetRight)( (aRect.*_rRectFn->fnGetLeft)() );
4345cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnAddRight)( 1 );
4346cdf0e10cSrcweir             }
4347cdf0e10cSrcweir             else
4348cdf0e10cSrcweir             {
4349cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnSetLeft)( (aRect.*_rRectFn->fnGetRight)() - 1 );
4350cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnSetRight)( (aRect.*_rRectFn->fnGetRight)() - 1 );
4351cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnAddRight)( 1 );
4352cdf0e10cSrcweir             }
4353cdf0e10cSrcweir         }
4354cdf0e10cSrcweir         _rFrm.PaintBorderLine( _rRect, aPaintRect, &_rPage, &pLeftRightBorder->GetColor() );
4355cdf0e10cSrcweir     }
4356cdf0e10cSrcweir 
4357cdf0e10cSrcweir     if ( pLeftRightBorder->GetInWidth() )
4358cdf0e10cSrcweir     {
4359cdf0e10cSrcweir         const long nDist = ::lcl_MinWidthDist( pLeftRightBorder->GetDistance() );
4360cdf0e10cSrcweir         long nWidth = ::lcl_AlignWidth( pLeftRightBorder->GetInWidth() );
4361cdf0e10cSrcweir         if ( _bLeft )
4362cdf0e10cSrcweir         {
4363cdf0e10cSrcweir             (aRect.*_rRectFn->fnAddRight)( nDist + nWidth );
4364cdf0e10cSrcweir             (aRect.*_rRectFn->fnSubLeft)( nWidth - (aRect.*_rRectFn->fnGetWidth)() );
4365cdf0e10cSrcweir         }
4366cdf0e10cSrcweir         else
4367cdf0e10cSrcweir         {
4368cdf0e10cSrcweir             (aRect.*_rRectFn->fnSubLeft)( nDist + nWidth );
4369cdf0e10cSrcweir             (aRect.*_rRectFn->fnAddRight)( nWidth - (aRect.*_rRectFn->fnGetWidth)() );
4370cdf0e10cSrcweir         }
4371cdf0e10cSrcweir         // OD 06.05.2003 #107169# - add 6th parameter
4372cdf0e10cSrcweir         ::lcl_SubTopBottom( aRect, rBox, _rAttrs, _rFrm, _rRectFn, bPrtOutputDev );
4373cdf0e10cSrcweir         // OD 29.04.2003 #107169# - paint SwAligned-rectangle
4374cdf0e10cSrcweir         {
4375cdf0e10cSrcweir             SwRect aPaintRect( aRect );
4376cdf0e10cSrcweir             ::SwAlignRect( aPaintRect, _rFrm.getRootFrm()->GetCurrShell() );
4377cdf0e10cSrcweir             // if <SwAlignRect> reveals rectangle with no width, adjust
4378cdf0e10cSrcweir             // rectangle to the prior left postion with width of one twip.
4379cdf0e10cSrcweir             if ( (aPaintRect.*_rRectFn->fnGetWidth)() == 0 )
4380cdf0e10cSrcweir             {
4381cdf0e10cSrcweir                 if ( _bLeft )
4382cdf0e10cSrcweir                 {
4383cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnSetLeft)( (aRect.*_rRectFn->fnGetLeft)() );
4384cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnSetRight)( (aRect.*_rRectFn->fnGetLeft)() );
4385cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnAddRight)( 1 );
4386cdf0e10cSrcweir                 }
4387cdf0e10cSrcweir                 else
4388cdf0e10cSrcweir                 {
4389cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnSetLeft)( (aRect.*_rRectFn->fnGetRight)() - 1 );
4390cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnSetRight)( (aRect.*_rRectFn->fnGetRight)() - 1 );
4391cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnAddRight)( 1 );
4392cdf0e10cSrcweir                 }
4393cdf0e10cSrcweir             }
4394cdf0e10cSrcweir             _rFrm.PaintBorderLine( _rRect, aPaintRect, &_rPage, &pLeftRightBorder->GetColor() );
4395cdf0e10cSrcweir         }
4396cdf0e10cSrcweir     }
4397cdf0e10cSrcweir }
4398cdf0e10cSrcweir 
4399cdf0e10cSrcweir // OD 19.05.2003 #109667# - merge <lcl_PaintTopLine> and <lcl_PaintBottomLine>
4400cdf0e10cSrcweir // into <lcl_PaintTopLine>
lcl_PaintTopBottomLine(const sal_Bool _bTop,const SwFrm & _rFrm,const SwPageFrm & _rPage,const SwRect & _rOutRect,const SwRect & _rRect,const SwBorderAttrs & _rAttrs,const SwRectFn & _rRectFn)4401cdf0e10cSrcweir void lcl_PaintTopBottomLine( const sal_Bool         _bTop,
4402cdf0e10cSrcweir                              const SwFrm&           _rFrm,
4403cdf0e10cSrcweir                              const SwPageFrm&       _rPage,
4404cdf0e10cSrcweir                              const SwRect&          _rOutRect,
4405cdf0e10cSrcweir                              const SwRect&          _rRect,
4406cdf0e10cSrcweir                              const SwBorderAttrs&   _rAttrs,
4407cdf0e10cSrcweir                              const SwRectFn&        _rRectFn )
4408cdf0e10cSrcweir {
4409cdf0e10cSrcweir     const SvxBoxItem& rBox = _rAttrs.GetBox();
4410cdf0e10cSrcweir     const SvxBorderLine* pTopBottomBorder = 0;
4411cdf0e10cSrcweir     if ( _bTop )
4412cdf0e10cSrcweir     {
4413cdf0e10cSrcweir         pTopBottomBorder = rBox.GetTop();
4414cdf0e10cSrcweir     }
4415cdf0e10cSrcweir     else
4416cdf0e10cSrcweir     {
4417cdf0e10cSrcweir         pTopBottomBorder = rBox.GetBottom();
4418cdf0e10cSrcweir     }
4419cdf0e10cSrcweir 
4420cdf0e10cSrcweir     if ( !pTopBottomBorder )
4421cdf0e10cSrcweir     {
4422cdf0e10cSrcweir 		return;
4423cdf0e10cSrcweir     }
4424cdf0e10cSrcweir 
4425cdf0e10cSrcweir     SwRect aRect( _rOutRect );
4426cdf0e10cSrcweir     if ( _bTop )
4427cdf0e10cSrcweir     {
4428cdf0e10cSrcweir         (aRect.*_rRectFn->fnAddBottom)( ::lcl_AlignHeight( pTopBottomBorder->GetOutWidth() ) -
4429cdf0e10cSrcweir                                         (aRect.*_rRectFn->fnGetHeight)() );
4430cdf0e10cSrcweir     }
4431cdf0e10cSrcweir     else
4432cdf0e10cSrcweir     {
4433cdf0e10cSrcweir         (aRect.*_rRectFn->fnSubTop)( ::lcl_AlignHeight( pTopBottomBorder->GetOutWidth() ) -
4434cdf0e10cSrcweir                                      (aRect.*_rRectFn->fnGetHeight)() );
4435cdf0e10cSrcweir     }
4436cdf0e10cSrcweir 
4437cdf0e10cSrcweir     // OD 29.04.2003 #107169# - paint SwAligned-rectangle
4438cdf0e10cSrcweir     {
4439cdf0e10cSrcweir         SwRect aPaintRect( aRect );
4440cdf0e10cSrcweir         ::SwAlignRect( aPaintRect, _rFrm.getRootFrm()->GetCurrShell() );
4441cdf0e10cSrcweir         // if <SwAlignRect> reveals rectangle with no width, adjust rectangle
4442cdf0e10cSrcweir         // to the prior top postion with width of one twip.
4443cdf0e10cSrcweir         if ( (aPaintRect.*_rRectFn->fnGetHeight)() == 0 )
4444cdf0e10cSrcweir         {
4445cdf0e10cSrcweir             if ( _bTop )
4446cdf0e10cSrcweir             {
4447cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnSetTop)( (aRect.*_rRectFn->fnGetTop)() );
4448cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnSetBottom)( (aRect.*_rRectFn->fnGetTop)() );
4449cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnAddBottom)( 1 );
4450cdf0e10cSrcweir             }
4451cdf0e10cSrcweir             else
4452cdf0e10cSrcweir             {
4453cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnSetTop)( (aRect.*_rRectFn->fnGetBottom)() - 1 );
4454cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnSetBottom)( (aRect.*_rRectFn->fnGetBottom)() - 1 );
4455cdf0e10cSrcweir                 (aPaintRect.*_rRectFn->fnAddBottom)( 1 );
4456cdf0e10cSrcweir             }
4457cdf0e10cSrcweir         }
4458cdf0e10cSrcweir         _rFrm.PaintBorderLine( _rRect, aPaintRect, &_rPage, &pTopBottomBorder->GetColor() );
4459cdf0e10cSrcweir     }
4460cdf0e10cSrcweir 
4461cdf0e10cSrcweir     if ( pTopBottomBorder->GetInWidth() )
4462cdf0e10cSrcweir 	{
4463cdf0e10cSrcweir         const long nDist = ::lcl_MinHeightDist( pTopBottomBorder->GetDistance() );
4464cdf0e10cSrcweir         const long nHeight = ::lcl_AlignHeight( pTopBottomBorder->GetInWidth() );
4465cdf0e10cSrcweir         if ( _bTop )
4466cdf0e10cSrcweir         {
4467cdf0e10cSrcweir             (aRect.*_rRectFn->fnAddBottom)( nDist + nHeight );
4468cdf0e10cSrcweir             (aRect.*_rRectFn->fnSubTop)( nHeight - (aRect.*_rRectFn->fnGetHeight)() );
4469cdf0e10cSrcweir         }
4470cdf0e10cSrcweir         else
4471cdf0e10cSrcweir         {
4472cdf0e10cSrcweir             (aRect.*_rRectFn->fnSubTop)( nDist + nHeight );
4473cdf0e10cSrcweir             (aRect.*_rRectFn->fnAddBottom)( nHeight -(aRect.*_rRectFn->fnGetHeight)() );
4474cdf0e10cSrcweir         }
4475cdf0e10cSrcweir         ::lcl_SubLeftRight( aRect, rBox, _rRectFn );
4476cdf0e10cSrcweir         // OD 29.04.2003 #107169# - paint SwAligned-rectangle
4477cdf0e10cSrcweir         {
4478cdf0e10cSrcweir             SwRect aPaintRect( aRect );
4479cdf0e10cSrcweir             ::SwAlignRect( aPaintRect, _rFrm.getRootFrm()->GetCurrShell() );
4480cdf0e10cSrcweir             // if <SwAlignRect> reveals rectangle with no width, adjust
4481cdf0e10cSrcweir             // rectangle to the prior top postion with width of one twip.
4482cdf0e10cSrcweir             if ( (aPaintRect.*_rRectFn->fnGetHeight)() == 0 )
4483cdf0e10cSrcweir             {
4484cdf0e10cSrcweir                 if ( _bTop )
4485cdf0e10cSrcweir                 {
4486cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnSetTop)( (aRect.*_rRectFn->fnGetTop)() );
4487cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnSetBottom)( (aRect.*_rRectFn->fnGetTop)() );
4488cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnAddBottom)( 1 );
4489cdf0e10cSrcweir                 }
4490cdf0e10cSrcweir                 else
4491cdf0e10cSrcweir                 {
4492cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnSetTop)( (aRect.*_rRectFn->fnGetBottom)() - 1 );
4493cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnSetBottom)( (aRect.*_rRectFn->fnGetBottom)() - 1 );
4494cdf0e10cSrcweir                     (aPaintRect.*_rRectFn->fnAddBottom)( 1 );
4495cdf0e10cSrcweir                 }
4496cdf0e10cSrcweir             }
4497cdf0e10cSrcweir             _rFrm.PaintBorderLine( _rRect, aPaintRect, &_rPage, &pTopBottomBorder->GetColor() );
4498cdf0e10cSrcweir         }
4499cdf0e10cSrcweir 	}
4500cdf0e10cSrcweir }
4501cdf0e10cSrcweir 
4502cdf0e10cSrcweir 
4503cdf0e10cSrcweir /*************************************************************************
4504cdf0e10cSrcweir |*
4505cdf0e10cSrcweir |*  const SwFrm* lcl_HasNextCell( const SwFrm& rFrm )
4506cdf0e10cSrcweir |*
4507cdf0e10cSrcweir |* No comment. #i15844#
4508cdf0e10cSrcweir |*
4509cdf0e10cSrcweir |*************************************************************************/
4510cdf0e10cSrcweir 
lcl_HasNextCell(const SwFrm & rFrm)4511cdf0e10cSrcweir const SwFrm* lcl_HasNextCell( const SwFrm& rFrm )
4512cdf0e10cSrcweir {
4513cdf0e10cSrcweir     ASSERT( rFrm.IsCellFrm(),
4514cdf0e10cSrcweir             "lcl_HasNextCell( const SwFrm& rFrm ) should be called with SwCellFrm" )
4515cdf0e10cSrcweir 
4516cdf0e10cSrcweir     const SwFrm* pTmpFrm = &rFrm;
4517cdf0e10cSrcweir     do
4518cdf0e10cSrcweir     {
4519cdf0e10cSrcweir         if ( pTmpFrm->GetNext() )
4520cdf0e10cSrcweir             return pTmpFrm->GetNext();
4521cdf0e10cSrcweir 
4522cdf0e10cSrcweir         pTmpFrm = pTmpFrm->GetUpper()->GetUpper();
4523cdf0e10cSrcweir     }
4524cdf0e10cSrcweir     while ( pTmpFrm->IsCellFrm() );
4525cdf0e10cSrcweir 
4526cdf0e10cSrcweir     return 0;
4527cdf0e10cSrcweir }
4528cdf0e10cSrcweir 
4529cdf0e10cSrcweir 
4530cdf0e10cSrcweir /*************************************************************************
4531cdf0e10cSrcweir |*
4532cdf0e10cSrcweir |*	SwFrm::PaintBorder()
4533cdf0e10cSrcweir |*
4534cdf0e10cSrcweir |*	Beschreibung		Malt Schatten und Umrandung
4535cdf0e10cSrcweir |*	Ersterstellung		MA 23.01.92
4536cdf0e10cSrcweir |*	Letzte Aenderung	MA 29. Jul. 96
4537cdf0e10cSrcweir |*
4538cdf0e10cSrcweir |*************************************************************************/
4539cdf0e10cSrcweir 
4540cdf0e10cSrcweir /** local method to determine cell frame, from which the border attributes
4541cdf0e10cSrcweir     for paint of top/bottom border has to be used.
4542cdf0e10cSrcweir 
4543cdf0e10cSrcweir     OD 21.02.2003 #b4779636#, #107692#
4544cdf0e10cSrcweir 
4545cdf0e10cSrcweir     @author OD
4546cdf0e10cSrcweir 
4547cdf0e10cSrcweir 
4548cdf0e10cSrcweir     @param _pCellFrm
4549cdf0e10cSrcweir     input parameter - constant pointer to cell frame for which the cell frame
4550cdf0e10cSrcweir     for the border attributes has to be determined.
4551cdf0e10cSrcweir 
4552cdf0e10cSrcweir     @param _rCellBorderAttrs
4553cdf0e10cSrcweir     input parameter - constant reference to the border attributes of cell frame
4554cdf0e10cSrcweir     <_pCellFrm>.
4555cdf0e10cSrcweir 
4556cdf0e10cSrcweir     @param _bTop
4557cdf0e10cSrcweir     input parameter - boolean, that controls, if cell frame for top border or
4558cdf0e10cSrcweir     for bottom border has to be determined.
4559cdf0e10cSrcweir 
4560cdf0e10cSrcweir     @return constant pointer to cell frame, for which the border attributes has
4561cdf0e10cSrcweir     to be used
4562cdf0e10cSrcweir */
lcl_GetCellFrmForBorderAttrs(const SwFrm * _pCellFrm,const SwBorderAttrs & _rCellBorderAttrs,const bool _bTop)4563cdf0e10cSrcweir const SwFrm* lcl_GetCellFrmForBorderAttrs( const SwFrm*         _pCellFrm,
4564cdf0e10cSrcweir                                            const SwBorderAttrs& _rCellBorderAttrs,
4565cdf0e10cSrcweir                                            const bool           _bTop )
4566cdf0e10cSrcweir {
4567cdf0e10cSrcweir     ASSERT( _pCellFrm, "No cell frame available, dying soon" )
4568cdf0e10cSrcweir 
4569cdf0e10cSrcweir     // determine, if cell frame is at bottom/top border of a table frame and
4570cdf0e10cSrcweir     // the table frame has/is a follow.
4571cdf0e10cSrcweir     const SwFrm* pTmpFrm = _pCellFrm;
4572cdf0e10cSrcweir     bool bCellAtBorder = true;
4573cdf0e10cSrcweir     bool bCellAtLeftBorder = !_pCellFrm->GetPrev();
4574cdf0e10cSrcweir     bool bCellAtRightBorder = !_pCellFrm->GetNext();
4575cdf0e10cSrcweir     while( !pTmpFrm->IsRowFrm() || !pTmpFrm->GetUpper()->IsTabFrm() )
4576cdf0e10cSrcweir     {
4577cdf0e10cSrcweir         pTmpFrm = pTmpFrm->GetUpper();
4578cdf0e10cSrcweir         if ( pTmpFrm->IsRowFrm() &&
4579cdf0e10cSrcweir              (_bTop ? pTmpFrm->GetPrev() : pTmpFrm->GetNext())
4580cdf0e10cSrcweir            )
4581cdf0e10cSrcweir         {
4582cdf0e10cSrcweir             bCellAtBorder = false;
4583cdf0e10cSrcweir         }
4584cdf0e10cSrcweir         if ( pTmpFrm->IsCellFrm() )
4585cdf0e10cSrcweir         {
4586cdf0e10cSrcweir             if ( pTmpFrm->GetPrev() )
4587cdf0e10cSrcweir             {
4588cdf0e10cSrcweir                 bCellAtLeftBorder = false;
4589cdf0e10cSrcweir             }
4590cdf0e10cSrcweir             if ( pTmpFrm->GetNext() )
4591cdf0e10cSrcweir             {
4592cdf0e10cSrcweir                 bCellAtRightBorder = false;
4593cdf0e10cSrcweir             }
4594cdf0e10cSrcweir         }
4595cdf0e10cSrcweir     }
4596cdf0e10cSrcweir     ASSERT( pTmpFrm && pTmpFrm->IsRowFrm(), "No RowFrm available" );
4597cdf0e10cSrcweir 
4598cdf0e10cSrcweir     const SwLayoutFrm* pParentRowFrm = static_cast<const SwLayoutFrm*>(pTmpFrm);
4599cdf0e10cSrcweir     const SwTabFrm* pParentTabFrm =
4600cdf0e10cSrcweir             static_cast<const SwTabFrm*>(pParentRowFrm->GetUpper());
4601cdf0e10cSrcweir 
4602cdf0e10cSrcweir     const bool bCellNeedsAttribute = bCellAtBorder &&
4603cdf0e10cSrcweir                                      ( _bTop ?
4604cdf0e10cSrcweir                                       // bCellInFirstRowWithMaster
4605cdf0e10cSrcweir                                        ( !pParentRowFrm->GetPrev() &&
4606cdf0e10cSrcweir                                          pParentTabFrm->IsFollow() &&
4607cdf0e10cSrcweir                                          0 == pParentTabFrm->GetTable()->GetRowsToRepeat() ) :
4608cdf0e10cSrcweir                                       // bCellInLastRowWithFollow
4609cdf0e10cSrcweir                                        ( !pParentRowFrm->GetNext() &&
4610cdf0e10cSrcweir                                          pParentTabFrm->GetFollow() )
4611cdf0e10cSrcweir                                      );
4612cdf0e10cSrcweir 
4613cdf0e10cSrcweir     const SwFrm* pRet = _pCellFrm;
4614cdf0e10cSrcweir     if ( bCellNeedsAttribute )
4615cdf0e10cSrcweir     {
4616cdf0e10cSrcweir         // determine, if cell frame has no borders inside the table.
4617cdf0e10cSrcweir         const SwFrm* pNextCell = 0;
4618cdf0e10cSrcweir         bool bNoBordersInside = false;
4619cdf0e10cSrcweir 
4620cdf0e10cSrcweir         if ( bCellAtLeftBorder && ( 0 != ( pNextCell = lcl_HasNextCell( *_pCellFrm ) ) ) )
4621cdf0e10cSrcweir         {
4622cdf0e10cSrcweir             SwBorderAttrAccess aAccess( SwFrm::GetCache(), pNextCell );
4623cdf0e10cSrcweir             const SwBorderAttrs &rBorderAttrs = *aAccess.Get();
4624cdf0e10cSrcweir             const SvxBoxItem& rBorderBox = rBorderAttrs.GetBox();
4625cdf0e10cSrcweir             bCellAtRightBorder = !lcl_HasNextCell( *pNextCell );
4626cdf0e10cSrcweir             bNoBordersInside =
4627cdf0e10cSrcweir                 ( !rBorderBox.GetTop()    || !pParentRowFrm->GetPrev() ) &&
4628cdf0e10cSrcweir                   !rBorderBox.GetLeft() &&
4629cdf0e10cSrcweir                 ( !rBorderBox.GetRight()  || bCellAtRightBorder ) &&
4630cdf0e10cSrcweir                 ( !rBorderBox.GetBottom() || !pParentRowFrm->GetNext() );
4631cdf0e10cSrcweir         }
4632cdf0e10cSrcweir         else
4633cdf0e10cSrcweir         {
4634cdf0e10cSrcweir             const SvxBoxItem& rBorderBox = _rCellBorderAttrs.GetBox();
4635cdf0e10cSrcweir             bNoBordersInside =
4636cdf0e10cSrcweir                 ( !rBorderBox.GetTop()    || !pParentRowFrm->GetPrev() ) &&
4637cdf0e10cSrcweir                 ( !rBorderBox.GetLeft()   || bCellAtLeftBorder ) &&
4638cdf0e10cSrcweir                 ( !rBorderBox.GetRight()  || bCellAtRightBorder ) &&
4639cdf0e10cSrcweir                 ( !rBorderBox.GetBottom() || !pParentRowFrm->GetNext() );
4640cdf0e10cSrcweir         }
4641cdf0e10cSrcweir 
4642cdf0e10cSrcweir         if ( bNoBordersInside )
4643cdf0e10cSrcweir         {
4644cdf0e10cSrcweir             if ( _bTop && !_rCellBorderAttrs.GetBox().GetTop() )
4645cdf0e10cSrcweir             {
4646cdf0e10cSrcweir                 // #b4779636#-hack:
4647cdf0e10cSrcweir                 // Cell frame has no top border and no border inside the table, but
4648cdf0e10cSrcweir                 // it is at the top border of a table frame, which is a follow.
4649cdf0e10cSrcweir                 // Thus, use border attributes of cell frame in first row of complete table.
4650cdf0e10cSrcweir                 // First, determine first table frame of complete table.
4651cdf0e10cSrcweir                 SwTabFrm* pMasterTabFrm = pParentTabFrm->FindMaster( true );
4652cdf0e10cSrcweir                 // determine first row of complete table.
4653cdf0e10cSrcweir                 const SwFrm* pFirstRow = pMasterTabFrm->GetLower();
4654cdf0e10cSrcweir                 // return first cell in first row
4655cdf0e10cSrcweir                 SwFrm* pLowerCell = const_cast<SwFrm*>(pFirstRow->GetLower());
4656cdf0e10cSrcweir                 while ( !pLowerCell->IsCellFrm() ||
4657cdf0e10cSrcweir                         ( pLowerCell->GetLower() && pLowerCell->GetLower()->IsRowFrm() )
4658cdf0e10cSrcweir                       )
4659cdf0e10cSrcweir                 {
4660cdf0e10cSrcweir                     pLowerCell = pLowerCell->GetLower();
4661cdf0e10cSrcweir                 }
4662cdf0e10cSrcweir                 ASSERT( pLowerCell && pLowerCell->IsCellFrm(), "No CellFrm available" );
4663cdf0e10cSrcweir                 pRet = pLowerCell;
4664cdf0e10cSrcweir             }
4665cdf0e10cSrcweir             else if ( !_bTop && !_rCellBorderAttrs.GetBox().GetBottom() )
4666cdf0e10cSrcweir             {
4667cdf0e10cSrcweir                 // #b4779636#-hack:
4668cdf0e10cSrcweir                 // Cell frame has no bottom border and no border inside the table,
4669cdf0e10cSrcweir                 // but it is at the bottom border of a table frame, which has a follow.
4670cdf0e10cSrcweir                 // Thus, use border attributes of cell frame in last row of complete table.
4671cdf0e10cSrcweir                 // First, determine last table frame of complete table.
4672cdf0e10cSrcweir                 SwTabFrm* pLastTabFrm = const_cast<SwTabFrm*>(pParentTabFrm->GetFollow());
4673cdf0e10cSrcweir                 while ( pLastTabFrm->GetFollow() )
4674cdf0e10cSrcweir                 {
4675cdf0e10cSrcweir                     pLastTabFrm = pLastTabFrm->GetFollow();
4676cdf0e10cSrcweir                 }
4677cdf0e10cSrcweir                 // determine last row of complete table.
4678cdf0e10cSrcweir                 SwFrm* pLastRow = pLastTabFrm->GetLastLower();
4679cdf0e10cSrcweir                 // return first bottom border cell in last row
4680cdf0e10cSrcweir                 SwFrm* pLowerCell = const_cast<SwFrm*>(pLastRow->GetLower());
4681cdf0e10cSrcweir                 while ( !pLowerCell->IsCellFrm() ||
4682cdf0e10cSrcweir                         ( pLowerCell->GetLower() && pLowerCell->GetLower()->IsRowFrm() )
4683cdf0e10cSrcweir                       )
4684cdf0e10cSrcweir                 {
4685cdf0e10cSrcweir                     if ( pLowerCell->IsRowFrm() )
4686cdf0e10cSrcweir                     {
4687cdf0e10cSrcweir                         while ( pLowerCell->GetNext() )
4688cdf0e10cSrcweir                         {
4689cdf0e10cSrcweir                             pLowerCell = pLowerCell->GetNext();
4690cdf0e10cSrcweir                         }
4691cdf0e10cSrcweir                     }
4692cdf0e10cSrcweir                     pLowerCell = pLowerCell->GetLower();
4693cdf0e10cSrcweir                 }
4694cdf0e10cSrcweir                 ASSERT( pLowerCell && pLowerCell->IsCellFrm(), "No CellFrm available" );
4695cdf0e10cSrcweir                 pRet = pLowerCell;
4696cdf0e10cSrcweir             }
4697cdf0e10cSrcweir         }
4698cdf0e10cSrcweir     }
4699cdf0e10cSrcweir 
4700cdf0e10cSrcweir     return pRet;
4701cdf0e10cSrcweir }
4702cdf0e10cSrcweir 
PaintBorder(const SwRect & rRect,const SwPageFrm * pPage,const SwBorderAttrs & rAttrs) const4703cdf0e10cSrcweir void SwFrm::PaintBorder( const SwRect& rRect, const SwPageFrm *pPage,
4704cdf0e10cSrcweir 						 const SwBorderAttrs &rAttrs ) const
4705cdf0e10cSrcweir {
4706cdf0e10cSrcweir     //fuer (Row,Body,Ftn,Root,Column,NoTxt) gibt's hier nix zu tun
4707cdf0e10cSrcweir     if ( (GetType() & 0x90C5) || (Prt().SSize() == Frm().SSize()) )
4708cdf0e10cSrcweir         return;
4709cdf0e10cSrcweir 
4710cdf0e10cSrcweir 	if ( (GetType() & 0x2000) && 	//Cell
4711cdf0e10cSrcweir 		 !pGlobalShell->GetViewOptions()->IsTable() )
4712cdf0e10cSrcweir 		return;
4713cdf0e10cSrcweir 
4714cdf0e10cSrcweir     // --> collapsing borders FME 2005-05-27 #i29550#
4715cdf0e10cSrcweir     if ( IsTabFrm() || IsCellFrm() || IsRowFrm() )
4716cdf0e10cSrcweir     {
4717cdf0e10cSrcweir         const SwTabFrm* pTabFrm = FindTabFrm();
4718cdf0e10cSrcweir         if ( pTabFrm->IsCollapsingBorders() )
4719cdf0e10cSrcweir             return;
4720cdf0e10cSrcweir 
4721cdf0e10cSrcweir         if ( pTabFrm->GetTable()->IsNewModel() && ( !IsCellFrm() || IsCoveredCell() ) )
4722cdf0e10cSrcweir             return;
4723cdf0e10cSrcweir     }
4724cdf0e10cSrcweir     // <--
4725cdf0e10cSrcweir 
4726cdf0e10cSrcweir     const bool bLine = rAttrs.IsLine() ? true : false;
4727cdf0e10cSrcweir     const bool bShadow = rAttrs.GetShadow().GetLocation() != SVX_SHADOW_NONE;
4728cdf0e10cSrcweir 
4729cdf0e10cSrcweir     // OD 24.02.2003 #b4779636#, #107692# - flag to control,
4730cdf0e10cSrcweir     // if #b4779636#-hack has to be used.
4731cdf0e10cSrcweir     const bool bb4779636HackActive = true;
4732cdf0e10cSrcweir     // OD 21.02.2003 #b4779636#, #107692#
4733cdf0e10cSrcweir     const SwFrm* pCellFrmForBottomBorderAttrs = 0;
4734cdf0e10cSrcweir     const SwFrm* pCellFrmForTopBorderAttrs = 0;
4735cdf0e10cSrcweir     bool         bFoundCellForTopOrBorderAttrs = false;
4736cdf0e10cSrcweir     if ( bb4779636HackActive && IsCellFrm() )
4737cdf0e10cSrcweir     {
4738cdf0e10cSrcweir         pCellFrmForBottomBorderAttrs = lcl_GetCellFrmForBorderAttrs( this, rAttrs, false );
4739cdf0e10cSrcweir         if ( pCellFrmForBottomBorderAttrs != this )
4740cdf0e10cSrcweir             bFoundCellForTopOrBorderAttrs = true;
4741cdf0e10cSrcweir         pCellFrmForTopBorderAttrs = lcl_GetCellFrmForBorderAttrs( this, rAttrs, true );
4742cdf0e10cSrcweir         if ( pCellFrmForTopBorderAttrs != this )
4743cdf0e10cSrcweir             bFoundCellForTopOrBorderAttrs = true;
4744cdf0e10cSrcweir     }
4745cdf0e10cSrcweir 
4746cdf0e10cSrcweir     // OD 24.02.2003 #b4779636#, #107692# - add condition <bFoundCellForTopOrBorderAttrs>
4747cdf0e10cSrcweir     // for #b4779636#-hack
4748cdf0e10cSrcweir     if ( bLine || bShadow || bFoundCellForTopOrBorderAttrs )
4749cdf0e10cSrcweir 	{
4750cdf0e10cSrcweir 		//Wenn das Rechteck vollstandig innerhalb der PrtArea liegt,
4751089ea224Smseidel 		//so braucht kein Rand gepaintet werden.
4752cdf0e10cSrcweir 		//Fuer die PrtArea muss der Aligned'e Wert zugrunde gelegt werden,
4753cdf0e10cSrcweir 		//anderfalls wuerden u.U. Teile nicht verarbeitet.
4754cdf0e10cSrcweir 		SwRect aRect( Prt() );
4755cdf0e10cSrcweir 		aRect += Frm().Pos();
4756cdf0e10cSrcweir 		::SwAlignRect( aRect, pGlobalShell );
4757cdf0e10cSrcweir         // OD 27.09.2002 #103636# - new local boolean variable in order to
4758cdf0e10cSrcweir         // suspend border paint under special cases - see below.
4759cdf0e10cSrcweir         // NOTE: This is a fix for the implementation of feature #99657#.
4760cdf0e10cSrcweir         bool bDrawOnlyShadowForTransparentFrame = false;
4761cdf0e10cSrcweir         if ( aRect.IsInside( rRect ) )
4762cdf0e10cSrcweir         {
4763cdf0e10cSrcweir             // OD 27.09.2002 #103636# - paint shadow, if background is transparent.
4764cdf0e10cSrcweir             // Because of introduced transparent background for fly frame #99657#,
4765cdf0e10cSrcweir             // the shadow have to be drawn if the background is transparent,
4766cdf0e10cSrcweir             // in spite the fact that the paint rectangle <rRect> lies fully
4767cdf0e10cSrcweir             // in the printing area.
4768cdf0e10cSrcweir             // NOTE to chosen solution:
4769cdf0e10cSrcweir             //     On transparent background, continue processing, but suspend
4770cdf0e10cSrcweir             //     drawing of border by setting <bDrawOnlyShadowForTransparentFrame>
4771cdf0e10cSrcweir             //     to true.
4772cdf0e10cSrcweir             if ( IsLayoutFrm() &&
4773cdf0e10cSrcweir                  static_cast<const SwLayoutFrm*>(this)->GetFmt()->IsBackgroundTransparent() )
4774cdf0e10cSrcweir             {
4775cdf0e10cSrcweir                  bDrawOnlyShadowForTransparentFrame = true;
4776cdf0e10cSrcweir             }
4777cdf0e10cSrcweir             else
4778cdf0e10cSrcweir             {
4779cdf0e10cSrcweir                 return;
4780cdf0e10cSrcweir             }
4781cdf0e10cSrcweir         }
4782cdf0e10cSrcweir 
4783cdf0e10cSrcweir 		if ( !pPage )
4784cdf0e10cSrcweir 			pPage = FindPageFrm();
4785cdf0e10cSrcweir 
4786cdf0e10cSrcweir 		::lcl_CalcBorderRect( aRect, this, rAttrs, sal_True );
4787cdf0e10cSrcweir 		rAttrs.SetGetCacheLine( sal_True );
4788cdf0e10cSrcweir 		if ( bShadow )
4789cdf0e10cSrcweir             PaintShadow( rRect, aRect, rAttrs );
4790cdf0e10cSrcweir         // OD 27.09.2002 #103636# - suspend drawing of border
4791cdf0e10cSrcweir         // add condition < NOT bDrawOnlyShadowForTransparentFrame > - see above
4792cdf0e10cSrcweir         // OD 24.02.2003 #b4779636#, #107692# - add condition <bFoundCellForTopOrBorderAttrs>
4793cdf0e10cSrcweir         // for #b4779636#-hack.
4794cdf0e10cSrcweir         if ( ( bLine || bFoundCellForTopOrBorderAttrs ) &&
4795cdf0e10cSrcweir              !bDrawOnlyShadowForTransparentFrame )
4796cdf0e10cSrcweir 		{
4797cdf0e10cSrcweir             const SwFrm* pDirRefFrm = IsCellFrm() ? FindTabFrm() : this;
4798cdf0e10cSrcweir             SWRECTFN( pDirRefFrm )
4799cdf0e10cSrcweir             // OD 19.05.2003 #109667# - use new method <lcl_PaintLeftRightLine(..)>
4800cdf0e10cSrcweir             //::lcl_PaintLeftLine  ( this, pPage, aRect, rRect, rAttrs, fnRect );
4801cdf0e10cSrcweir             //::lcl_PaintRightLine ( this, pPage, aRect, rRect, rAttrs, fnRect );
4802cdf0e10cSrcweir             ::lcl_PaintLeftRightLine ( sal_True, *(this), *(pPage), aRect, rRect, rAttrs, fnRect );
4803cdf0e10cSrcweir             ::lcl_PaintLeftRightLine ( sal_False, *(this), *(pPage), aRect, rRect, rAttrs, fnRect );
4804cdf0e10cSrcweir             if ( !IsCntntFrm() || rAttrs.GetTopLine( *(this) ) )
4805cdf0e10cSrcweir             {
4806cdf0e10cSrcweir                 // OD 21.02.2003 #b4779636#, #107692# -
4807cdf0e10cSrcweir                 // #b4779636#-hack: If another cell frame for top border
4808cdf0e10cSrcweir                 // paint is found, paint its top border.
4809cdf0e10cSrcweir                 if ( IsCellFrm() && pCellFrmForTopBorderAttrs != this )
4810cdf0e10cSrcweir                 {
4811cdf0e10cSrcweir                     SwBorderAttrAccess aAccess( SwFrm::GetCache(),
4812cdf0e10cSrcweir                                                 pCellFrmForTopBorderAttrs );
4813cdf0e10cSrcweir                     const SwBorderAttrs &rTopAttrs = *aAccess.Get();
4814cdf0e10cSrcweir                     // OD 19.05.2003 #109667# - use new method <lcl_PaintTopBottomLine(..)>
4815cdf0e10cSrcweir                     //::lcl_PaintTopLine( this, pPage, aRect, rRect, rTopAttrs, fnRect );
4816cdf0e10cSrcweir                     ::lcl_PaintTopBottomLine( sal_True, *(this), *(pPage), aRect, rRect, rTopAttrs, fnRect );
4817cdf0e10cSrcweir                 }
4818cdf0e10cSrcweir                 else
4819cdf0e10cSrcweir                 {
4820cdf0e10cSrcweir                     // OD 19.05.2003 #109667# - use new method <lcl_PaintTopBottomLine(..)>
4821cdf0e10cSrcweir                     //::lcl_PaintTopLine( this, pPage, aRect, rRect, rAttrs, fnRect );
4822cdf0e10cSrcweir                     ::lcl_PaintTopBottomLine( sal_True, *(this), *(pPage), aRect, rRect, rAttrs, fnRect );
4823cdf0e10cSrcweir                 }
4824cdf0e10cSrcweir             }
4825cdf0e10cSrcweir             if ( !IsCntntFrm() || rAttrs.GetBottomLine( *(this) ) )
4826cdf0e10cSrcweir             {
4827cdf0e10cSrcweir                 // OD 21.02.2003 #b4779636#, #107692# -
4828cdf0e10cSrcweir                 // #b4779636#-hack: If another cell frame for bottom border
4829cdf0e10cSrcweir                 // paint is found, paint its bottom border.
4830cdf0e10cSrcweir                 if ( IsCellFrm() && pCellFrmForBottomBorderAttrs != this )
4831cdf0e10cSrcweir                 {
4832cdf0e10cSrcweir                     SwBorderAttrAccess aAccess( SwFrm::GetCache(),
4833cdf0e10cSrcweir                                                 pCellFrmForBottomBorderAttrs );
4834cdf0e10cSrcweir                     const SwBorderAttrs &rBottomAttrs = *aAccess.Get();
4835cdf0e10cSrcweir                     // OD 19.05.2003 #109667# - use new method <lcl_PaintTopBottomLine(..)>
4836cdf0e10cSrcweir                     //::lcl_PaintBottomLine(this, pPage, aRect, rRect, rBottomAttrs, fnRect);
4837cdf0e10cSrcweir                     ::lcl_PaintTopBottomLine(sal_False, *(this), *(pPage), aRect, rRect, rBottomAttrs, fnRect);
4838cdf0e10cSrcweir                 }
4839cdf0e10cSrcweir                 else
4840cdf0e10cSrcweir                 {
4841cdf0e10cSrcweir                     // OD 19.05.2003 #109667# - use new method <lcl_PaintTopBottomLine(..)>
4842cdf0e10cSrcweir                     //::lcl_PaintBottomLine(this, pPage, aRect, rRect, rAttrs, fnRect);
4843cdf0e10cSrcweir                     ::lcl_PaintTopBottomLine(sal_False, *(this), *(pPage), aRect, rRect, rAttrs, fnRect);
4844cdf0e10cSrcweir                 }
4845cdf0e10cSrcweir             }
4846cdf0e10cSrcweir 		}
4847cdf0e10cSrcweir 		rAttrs.SetGetCacheLine( sal_False );
4848cdf0e10cSrcweir 	}
4849cdf0e10cSrcweir }
4850cdf0e10cSrcweir /*************************************************************************
4851cdf0e10cSrcweir |*
4852cdf0e10cSrcweir |*	SwFtnContFrm::PaintBorder()
4853cdf0e10cSrcweir |*
4854cdf0e10cSrcweir |*	Beschreibung		Spezialimplementierung wg. der Fussnotenlinie.
4855cdf0e10cSrcweir |* 		Derzeit braucht nur der obere Rand beruecksichtigt werden.
4856cdf0e10cSrcweir |* 		Auf andere Linien und Schatten wird verzichtet.
4857cdf0e10cSrcweir |*	Ersterstellung		MA 27. Feb. 93
4858cdf0e10cSrcweir |*	Letzte Aenderung	MA 08. Sep. 93
4859cdf0e10cSrcweir |*
4860cdf0e10cSrcweir |*************************************************************************/
4861cdf0e10cSrcweir 
PaintBorder(const SwRect & rRect,const SwPageFrm * pPage,const SwBorderAttrs &) const4862cdf0e10cSrcweir void SwFtnContFrm::PaintBorder( const SwRect& rRect, const SwPageFrm *pPage,
4863cdf0e10cSrcweir 								const SwBorderAttrs & ) const
4864cdf0e10cSrcweir {
4865cdf0e10cSrcweir 	//Wenn das Rechteck vollstandig innerhalb der PrtArea liegt, so gibt es
4866cdf0e10cSrcweir 	//keinen Rand zu painten.
4867cdf0e10cSrcweir 	SwRect aRect( Prt() );
4868cdf0e10cSrcweir 	aRect.Pos() += Frm().Pos();
4869cdf0e10cSrcweir 	if ( !aRect.IsInside( rRect ) )
4870cdf0e10cSrcweir 		PaintLine( rRect, pPage );
4871cdf0e10cSrcweir }
4872cdf0e10cSrcweir /*************************************************************************
4873cdf0e10cSrcweir |*
4874cdf0e10cSrcweir |*	SwFtnContFrm::PaintLine()
4875cdf0e10cSrcweir |*
4876cdf0e10cSrcweir |*	Beschreibung		Fussnotenline malen.
4877cdf0e10cSrcweir |*	Ersterstellung		MA 02. Mar. 93
4878cdf0e10cSrcweir |*	Letzte Aenderung	MA 28. Mar. 94
4879cdf0e10cSrcweir |*
4880cdf0e10cSrcweir |*************************************************************************/
4881cdf0e10cSrcweir 
PaintLine(const SwRect & rRect,const SwPageFrm * pPage) const4882cdf0e10cSrcweir void SwFtnContFrm::PaintLine( const SwRect& rRect,
4883cdf0e10cSrcweir 							  const SwPageFrm *pPage ) const
4884cdf0e10cSrcweir {
4885cdf0e10cSrcweir 	//Laenge der Linie ergibt sich aus der prozentualen Angabe am PageDesc.
4886cdf0e10cSrcweir 	//Die Position ist ebenfalls am PageDesc angegeben.
4887cdf0e10cSrcweir 	//Der Pen steht direkt im PageDesc.
4888cdf0e10cSrcweir 
4889cdf0e10cSrcweir 	if ( !pPage )
4890cdf0e10cSrcweir 		pPage = FindPageFrm();
4891cdf0e10cSrcweir 	const SwPageFtnInfo &rInf = pPage->GetPageDesc()->GetFtnInfo();
4892cdf0e10cSrcweir 
4893cdf0e10cSrcweir     SWRECTFN( this )
4894cdf0e10cSrcweir     SwTwips nPrtWidth = (Prt().*fnRect->fnGetWidth)();
4895cdf0e10cSrcweir     Fraction aFract( nPrtWidth, 1 );
4896cdf0e10cSrcweir 	const SwTwips nWidth = (long)(aFract *= rInf.GetWidth());
4897cdf0e10cSrcweir 
4898cdf0e10cSrcweir     SwTwips nX = (this->*fnRect->fnGetPrtLeft)();
4899cdf0e10cSrcweir 	switch ( rInf.GetAdj() )
4900cdf0e10cSrcweir 	{
4901cdf0e10cSrcweir 		case FTNADJ_CENTER:
4902cdf0e10cSrcweir             nX += nPrtWidth/2 - nWidth/2; break;
4903cdf0e10cSrcweir 		case FTNADJ_RIGHT:
4904cdf0e10cSrcweir             nX += nPrtWidth - nWidth; break;
4905cdf0e10cSrcweir 		case FTNADJ_LEFT:
4906cdf0e10cSrcweir 			/* do nothing */; break;
4907cdf0e10cSrcweir 		default:
4908cdf0e10cSrcweir 			ASSERT( !this, "Neues Adjustment fuer Fussnotenlinie?" );
4909cdf0e10cSrcweir 	}
4910cdf0e10cSrcweir     SwTwips nLineWidth = rInf.GetLineWidth();
4911cdf0e10cSrcweir     const SwRect aLineRect = bVert ?
4912cdf0e10cSrcweir         SwRect( Point(Frm().Left()+Frm().Width()-rInf.GetTopDist()-nLineWidth,
4913cdf0e10cSrcweir                       nX), Size( nLineWidth, nWidth ) )
4914cdf0e10cSrcweir             : SwRect( Point( nX, Frm().Pos().Y() + rInf.GetTopDist() ),
4915cdf0e10cSrcweir                             Size( nWidth, rInf.GetLineWidth()));
4916cdf0e10cSrcweir 	if ( aLineRect.HasArea() )
4917cdf0e10cSrcweir 		PaintBorderLine( rRect, aLineRect , pPage, &rInf.GetLineColor() );
4918cdf0e10cSrcweir }
4919cdf0e10cSrcweir 
4920cdf0e10cSrcweir /*************************************************************************
4921cdf0e10cSrcweir |*
4922cdf0e10cSrcweir |*	SwLayoutFrm::PaintColLines()
4923cdf0e10cSrcweir |*
4924cdf0e10cSrcweir |*	Beschreibung		Painted die Trennlinien fuer die innenliegenden
4925cdf0e10cSrcweir |* 						Spalten.
4926cdf0e10cSrcweir |*	Ersterstellung		MA 21. Jun. 93
4927cdf0e10cSrcweir |*	Letzte Aenderung	MA 28. Mar. 94
4928cdf0e10cSrcweir |*
4929cdf0e10cSrcweir |*************************************************************************/
4930cdf0e10cSrcweir 
PaintColLines(const SwRect & rRect,const SwFmtCol & rFmtCol,const SwPageFrm * pPage) const4931cdf0e10cSrcweir void SwLayoutFrm::PaintColLines( const SwRect &rRect, const SwFmtCol &rFmtCol,
4932cdf0e10cSrcweir 								 const SwPageFrm *pPage ) const
4933cdf0e10cSrcweir {
4934cdf0e10cSrcweir 	const SwFrm *pCol = Lower();
4935cdf0e10cSrcweir 	if ( !pCol || !pCol->IsColumnFrm() )
4936cdf0e10cSrcweir 		return;
4937cdf0e10cSrcweir 	//Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
4938cdf0e10cSrcweir     SwRectFn fnRect = pCol->IsVertical() ? ( pCol->IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
4939cdf0e10cSrcweir 
4940cdf0e10cSrcweir     SwRect aLineRect = Prt();
4941cdf0e10cSrcweir     aLineRect += Frm().Pos();
4942cdf0e10cSrcweir 
4943cdf0e10cSrcweir     SwTwips nTop = ((aLineRect.*fnRect->fnGetHeight)()*rFmtCol.GetLineHeight())
4944cdf0e10cSrcweir                    / 100 - (aLineRect.*fnRect->fnGetHeight)();
4945cdf0e10cSrcweir     SwTwips nBottom = 0;
4946cdf0e10cSrcweir 
4947cdf0e10cSrcweir 	switch ( rFmtCol.GetLineAdj() )
4948cdf0e10cSrcweir 	{
4949cdf0e10cSrcweir 		case COLADJ_CENTER:
4950cdf0e10cSrcweir             nBottom = nTop / 2; nTop -= nBottom; break;
4951cdf0e10cSrcweir 		case COLADJ_TOP:
4952cdf0e10cSrcweir             nBottom = nTop; nTop = 0; break;
4953cdf0e10cSrcweir 		case COLADJ_BOTTOM:
4954cdf0e10cSrcweir             break;
4955cdf0e10cSrcweir 		default:
4956cdf0e10cSrcweir 			ASSERT( !this, "Neues Adjustment fuer Spaltenlinie?" );
4957cdf0e10cSrcweir 	}
4958cdf0e10cSrcweir 
4959cdf0e10cSrcweir     if( nTop )
4960cdf0e10cSrcweir         (aLineRect.*fnRect->fnSubTop)( nTop );
4961cdf0e10cSrcweir     if( nBottom )
4962cdf0e10cSrcweir         (aLineRect.*fnRect->fnAddBottom)( nBottom );
4963cdf0e10cSrcweir 
4964cdf0e10cSrcweir     SwTwips nPenHalf = rFmtCol.GetLineWidth();
4965cdf0e10cSrcweir     (aLineRect.*fnRect->fnSetWidth)( nPenHalf );
4966cdf0e10cSrcweir     nPenHalf /= 2;
4967cdf0e10cSrcweir 
4968cdf0e10cSrcweir     //Damit uns nichts verlorengeht muessen wir hier etwas grosszuegiger sein.
4969cdf0e10cSrcweir 	SwRect aRect( rRect );
4970cdf0e10cSrcweir     (aRect.*fnRect->fnSubLeft)( nPenHalf + nPixelSzW );
4971cdf0e10cSrcweir     (aRect.*fnRect->fnAddRight)( nPenHalf + nPixelSzW );
4972cdf0e10cSrcweir     SwRectGet fnGetX = IsRightToLeft() ? fnRect->fnGetLeft : fnRect->fnGetRight;
4973cdf0e10cSrcweir 	while ( pCol->GetNext() )
4974cdf0e10cSrcweir 	{
4975cdf0e10cSrcweir         (aLineRect.*fnRect->fnSetPosX)
4976cdf0e10cSrcweir             ( (pCol->Frm().*fnGetX)() - nPenHalf );
4977cdf0e10cSrcweir 		if ( aRect.IsOver( aLineRect ) )
4978cdf0e10cSrcweir             PaintBorderLine( aRect, aLineRect , pPage, &rFmtCol.GetLineColor());
4979cdf0e10cSrcweir 		pCol = pCol->GetNext();
4980cdf0e10cSrcweir 	}
4981cdf0e10cSrcweir }
4982cdf0e10cSrcweir 
PaintGrid(OutputDevice * pOut,SwRect & rRect) const4983cdf0e10cSrcweir void SwPageFrm::PaintGrid( OutputDevice* pOut, SwRect &rRect ) const
4984cdf0e10cSrcweir {
4985cdf0e10cSrcweir     if( !bHasGrid || pRetoucheFly || pRetoucheFly2 )
4986cdf0e10cSrcweir         return;
4987cdf0e10cSrcweir     GETGRID( this )
4988cdf0e10cSrcweir     if( pGrid && ( OUTDEV_PRINTER != pOut->GetOutDevType() ?
4989cdf0e10cSrcweir         pGrid->GetDisplayGrid() : pGrid->GetPrintGrid() ) )
4990cdf0e10cSrcweir     {
4991cdf0e10cSrcweir         const SwLayoutFrm* pBody = FindBodyCont();
4992cdf0e10cSrcweir         if( pBody )
4993cdf0e10cSrcweir         {
4994cdf0e10cSrcweir             SwRect aGrid( pBody->Prt() );
4995cdf0e10cSrcweir             aGrid += pBody->Frm().Pos();
4996cdf0e10cSrcweir 
4997cdf0e10cSrcweir             SwRect aInter( aGrid );
4998cdf0e10cSrcweir             aInter.Intersection( rRect );
4999cdf0e10cSrcweir             if( aInter.HasArea() )
5000cdf0e10cSrcweir             {
5001cdf0e10cSrcweir                 sal_Bool bGrid = pGrid->GetRubyTextBelow();
5002cdf0e10cSrcweir                 sal_Bool bCell = GRID_LINES_CHARS == pGrid->GetGridType();
5003cdf0e10cSrcweir                 long nGrid = pGrid->GetBaseHeight();
5004cdf0e10cSrcweir 				const SwDoc* pDoc = GetFmt()->GetDoc();
5005cdf0e10cSrcweir                 long nGridWidth = GETGRIDWIDTH(pGrid,pDoc); //for textgrid refactor
5006cdf0e10cSrcweir                 long nRuby = pGrid->GetRubyHeight();
5007cdf0e10cSrcweir                 long nSum = nGrid + nRuby;
5008cdf0e10cSrcweir                 const Color *pCol = &pGrid->GetColor();
5009cdf0e10cSrcweir 
5010cdf0e10cSrcweir                 SwTwips nRight = aInter.Left() + aInter.Width();
5011cdf0e10cSrcweir                 SwTwips nBottom = aInter.Top() + aInter.Height();
5012cdf0e10cSrcweir                 if( IsVertical() )
5013cdf0e10cSrcweir                 {
5014cdf0e10cSrcweir                     SwTwips nOrig = aGrid.Left() + aGrid.Width();
5015cdf0e10cSrcweir                     SwTwips nY = nOrig + nSum *
5016cdf0e10cSrcweir                                  ( ( nOrig - aInter.Left() ) / nSum );
5017cdf0e10cSrcweir                     SwRect aTmp( Point( nY, aInter.Top() ),
5018cdf0e10cSrcweir                                 Size( 1, aInter.Height() ) );
5019cdf0e10cSrcweir                     SwTwips nX = aGrid.Top() + nGrid *
5020cdf0e10cSrcweir                                 ( ( aInter.Top() - aGrid.Top() )/ nGrid );
5021cdf0e10cSrcweir                     if( nX < aInter.Top() )
5022cdf0e10cSrcweir                         nX += nGrid;
5023cdf0e10cSrcweir                     SwTwips nGridBottom = aGrid.Top() + aGrid.Height();
5024cdf0e10cSrcweir                     sal_Bool bLeft = aGrid.Top() >= aInter.Top();
5025cdf0e10cSrcweir                     sal_Bool bRight = nGridBottom <= nBottom;
5026cdf0e10cSrcweir                     sal_Bool bBorder = bLeft || bRight;
5027cdf0e10cSrcweir                     while( nY > nRight )
5028cdf0e10cSrcweir                     {
5029cdf0e10cSrcweir                         aTmp.Pos().X() = nY;
5030cdf0e10cSrcweir                         if( bGrid )
5031cdf0e10cSrcweir                         {
5032cdf0e10cSrcweir                             nY -= nGrid;
5033cdf0e10cSrcweir                             SwTwips nPosY = Max( aInter.Left(), nY );
5034cdf0e10cSrcweir                             SwTwips nHeight = Min(nRight, aTmp.Pos().X())-nPosY;
5035cdf0e10cSrcweir                             if( nHeight > 0 )
5036cdf0e10cSrcweir                             {
5037cdf0e10cSrcweir                                 if( bCell )
5038cdf0e10cSrcweir                                 {
5039cdf0e10cSrcweir                                     SwRect aVert( Point( nPosY, nX ),
5040cdf0e10cSrcweir                                                 Size( nHeight, 1 ) );
5041cdf0e10cSrcweir                                     while( aVert.Top() <= nBottom )
5042cdf0e10cSrcweir                                     {
5043cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5044cdf0e10cSrcweir                                         aVert.Pos().Y() += nGrid;
5045cdf0e10cSrcweir                                     }
5046cdf0e10cSrcweir                                 }
5047cdf0e10cSrcweir                                 else if( bBorder )
5048cdf0e10cSrcweir                                 {
5049cdf0e10cSrcweir                                     SwRect aVert( Point( nPosY, aGrid.Top() ),
5050cdf0e10cSrcweir                                                   Size( nHeight, 1 ) );
5051cdf0e10cSrcweir                                     if( bLeft )
5052cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5053cdf0e10cSrcweir                                     if( bRight )
5054cdf0e10cSrcweir                                     {
5055cdf0e10cSrcweir                                         aVert.Pos().Y() = nGridBottom;
5056cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5057cdf0e10cSrcweir                                     }
5058cdf0e10cSrcweir                                 }
5059cdf0e10cSrcweir                             }
5060cdf0e10cSrcweir                         }
5061cdf0e10cSrcweir                         else
5062cdf0e10cSrcweir                         {
5063cdf0e10cSrcweir                             nY -= nRuby;
5064cdf0e10cSrcweir                             if( bBorder )
5065cdf0e10cSrcweir                             {
5066cdf0e10cSrcweir                                 SwTwips nPos = Max( aInter.Left(), nY );
5067cdf0e10cSrcweir                                 SwTwips nW = Min(nRight, aTmp.Pos().X()) - nPos;
5068cdf0e10cSrcweir                                 SwRect aVert( Point( nPos, aGrid.Top() ),
5069cdf0e10cSrcweir                                               Size( nW, 1 ) );
5070cdf0e10cSrcweir                                 if( nW > 0 )
5071cdf0e10cSrcweir                                 {
5072cdf0e10cSrcweir                                     if( bLeft )
5073cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5074cdf0e10cSrcweir                                     if( bRight )
5075cdf0e10cSrcweir                                     {
5076cdf0e10cSrcweir                                         aVert.Pos().Y() = nGridBottom;
5077cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5078cdf0e10cSrcweir                                     }
5079cdf0e10cSrcweir                                 }
5080cdf0e10cSrcweir                             }
5081cdf0e10cSrcweir                         }
5082cdf0e10cSrcweir                         bGrid = !bGrid;
5083cdf0e10cSrcweir                     }
5084cdf0e10cSrcweir                     while( nY >= aInter.Left() )
5085cdf0e10cSrcweir                     {
5086cdf0e10cSrcweir                         aTmp.Pos().X() = nY;
5087cdf0e10cSrcweir                         PaintBorderLine( rRect, aTmp, this, pCol);
5088cdf0e10cSrcweir                         if( bGrid )
5089cdf0e10cSrcweir                         {
5090cdf0e10cSrcweir                             nY -= nGrid;
5091cdf0e10cSrcweir                             SwTwips nHeight = aTmp.Pos().X()
5092cdf0e10cSrcweir                                               - Max(aInter.Left(), nY );
5093cdf0e10cSrcweir                             if( nHeight > 0 )
5094cdf0e10cSrcweir                             {
5095cdf0e10cSrcweir                                 if( bCell )
5096cdf0e10cSrcweir                                 {
5097cdf0e10cSrcweir                                     SwRect aVert( Point(aTmp.Pos().X()-nHeight,
5098cdf0e10cSrcweir                                                   nX ), Size( nHeight, 1 ) );
5099cdf0e10cSrcweir                                     while( aVert.Top() <= nBottom )
5100cdf0e10cSrcweir                                     {
5101cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5102cdf0e10cSrcweir                                         aVert.Pos().Y() += nGrid;
5103cdf0e10cSrcweir                                     }
5104cdf0e10cSrcweir                                 }
5105cdf0e10cSrcweir                                 else if( bBorder )
5106cdf0e10cSrcweir                                 {
5107cdf0e10cSrcweir                                     SwRect aVert( Point(aTmp.Pos().X()-nHeight,
5108cdf0e10cSrcweir                                             aGrid.Top() ), Size( nHeight, 1 ) );
5109cdf0e10cSrcweir                                     if( bLeft )
5110cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5111cdf0e10cSrcweir                                     if( bRight )
5112cdf0e10cSrcweir                                     {
5113cdf0e10cSrcweir                                         aVert.Pos().Y() = nGridBottom;
5114cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5115cdf0e10cSrcweir                                     }
5116cdf0e10cSrcweir                                 }
5117cdf0e10cSrcweir                             }
5118cdf0e10cSrcweir                         }
5119cdf0e10cSrcweir                         else
5120cdf0e10cSrcweir                         {
5121cdf0e10cSrcweir                             nY -= nRuby;
5122cdf0e10cSrcweir                             if( bBorder )
5123cdf0e10cSrcweir                             {
5124cdf0e10cSrcweir                                 SwTwips nPos = Max( aInter.Left(), nY );
5125cdf0e10cSrcweir                                 SwTwips nW = Min(nRight, aTmp.Pos().X()) - nPos;
5126cdf0e10cSrcweir                                 SwRect aVert( Point( nPos, aGrid.Top() ),
5127cdf0e10cSrcweir                                               Size( nW, 1 ) );
5128cdf0e10cSrcweir                                 if( nW > 0 )
5129cdf0e10cSrcweir                                 {
5130cdf0e10cSrcweir                                     if( bLeft )
5131cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5132cdf0e10cSrcweir                                     if( bRight )
5133cdf0e10cSrcweir                                     {
5134cdf0e10cSrcweir                                         aVert.Pos().Y() = nGridBottom;
5135cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5136cdf0e10cSrcweir                                     }
5137cdf0e10cSrcweir                                 }
5138cdf0e10cSrcweir                             }
5139cdf0e10cSrcweir                         }
5140cdf0e10cSrcweir                         bGrid = !bGrid;
5141cdf0e10cSrcweir                     }
5142cdf0e10cSrcweir                 }
5143cdf0e10cSrcweir                 else
5144cdf0e10cSrcweir                 {
5145cdf0e10cSrcweir                     SwTwips nOrig = aGrid.Top();
5146cdf0e10cSrcweir                     SwTwips nY = nOrig + nSum *( (aInter.Top()-nOrig)/nSum );
5147cdf0e10cSrcweir                     SwRect aTmp( Point( aInter.Left(), nY ),
5148cdf0e10cSrcweir                                 Size( aInter.Width(), 1 ) );
5149cdf0e10cSrcweir                     //for textgrid refactor
5150cdf0e10cSrcweir                     SwTwips nX = aGrid.Left() + nGridWidth *
5151cdf0e10cSrcweir                         ( ( aInter.Left() - aGrid.Left() )/ nGridWidth );
5152cdf0e10cSrcweir                     if( nX < aInter.Left() )
5153cdf0e10cSrcweir                         nX += nGridWidth;
5154cdf0e10cSrcweir                     SwTwips nGridRight = aGrid.Left() + aGrid.Width();
5155cdf0e10cSrcweir                     sal_Bool bLeft = aGrid.Left() >= aInter.Left();
5156cdf0e10cSrcweir                     sal_Bool bRight = nGridRight <= nRight;
5157cdf0e10cSrcweir                     sal_Bool bBorder = bLeft || bRight;
5158cdf0e10cSrcweir                     while( nY < aInter.Top() )
5159cdf0e10cSrcweir                     {
5160cdf0e10cSrcweir                         aTmp.Pos().Y() = nY;
5161cdf0e10cSrcweir                         if( bGrid )
5162cdf0e10cSrcweir                         {
5163cdf0e10cSrcweir                             nY += nGrid;
5164cdf0e10cSrcweir                             SwTwips nPosY = Max( aInter.Top(), aTmp.Pos().Y() );
5165cdf0e10cSrcweir                             SwTwips nHeight = Min(nBottom, nY ) - nPosY;
5166cdf0e10cSrcweir                             if( nHeight )
5167cdf0e10cSrcweir                             {
5168cdf0e10cSrcweir                                 if( bCell )
5169cdf0e10cSrcweir                                 {
5170cdf0e10cSrcweir                                     SwRect aVert( Point( nX, nPosY ),
5171cdf0e10cSrcweir                                                 Size( 1, nHeight ) );
5172cdf0e10cSrcweir                                     while( aVert.Left() <= nRight )
5173cdf0e10cSrcweir                                     {
5174cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5175cdf0e10cSrcweir                                         aVert.Pos().X() += nGridWidth;	//for textgrid refactor
5176cdf0e10cSrcweir                                     }
5177cdf0e10cSrcweir                                 }
5178cdf0e10cSrcweir                                 else if ( bBorder )
5179cdf0e10cSrcweir                                 {
5180cdf0e10cSrcweir                                     SwRect aVert( Point( aGrid.Left(), nPosY ),
5181cdf0e10cSrcweir                                                 Size( 1, nHeight ) );
5182cdf0e10cSrcweir                                     if( bLeft )
5183cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5184cdf0e10cSrcweir                                     if( bRight )
5185cdf0e10cSrcweir                                     {
5186cdf0e10cSrcweir                                         aVert.Pos().X() = nGridRight;
5187cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5188cdf0e10cSrcweir                                     }
5189cdf0e10cSrcweir                                 }
5190cdf0e10cSrcweir                             }
5191cdf0e10cSrcweir                         }
5192cdf0e10cSrcweir                         else
5193cdf0e10cSrcweir                         {
5194cdf0e10cSrcweir                             nY += nRuby;
5195cdf0e10cSrcweir                             if( bBorder )
5196cdf0e10cSrcweir                             {
5197cdf0e10cSrcweir                                 SwTwips nPos = Max(aInter.Top(),aTmp.Pos().Y());
5198cdf0e10cSrcweir                                 SwTwips nH = Min( nBottom, nY ) - nPos;
5199cdf0e10cSrcweir                                 SwRect aVert( Point( aGrid.Left(), nPos ),
5200cdf0e10cSrcweir                                             Size( 1, nH ) );
5201cdf0e10cSrcweir                                 if( nH > 0 )
5202cdf0e10cSrcweir                                 {
5203cdf0e10cSrcweir                                     if( bLeft )
5204cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5205cdf0e10cSrcweir                                     if( bRight )
5206cdf0e10cSrcweir                                     {
5207cdf0e10cSrcweir                                         aVert.Pos().X() = nGridRight;
5208cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5209cdf0e10cSrcweir                                     }
5210cdf0e10cSrcweir                                 }
5211cdf0e10cSrcweir                             }
5212cdf0e10cSrcweir                         }
5213cdf0e10cSrcweir                         bGrid = !bGrid;
5214cdf0e10cSrcweir                     }
5215cdf0e10cSrcweir                     while( nY <= nBottom )
5216cdf0e10cSrcweir                     {
5217cdf0e10cSrcweir                         aTmp.Pos().Y() = nY;
5218cdf0e10cSrcweir                         PaintBorderLine( rRect, aTmp, this, pCol);
5219cdf0e10cSrcweir                         if( bGrid )
5220cdf0e10cSrcweir                         {
5221cdf0e10cSrcweir                             nY += nGrid;
5222cdf0e10cSrcweir                             SwTwips nHeight = Min(nBottom, nY) - aTmp.Pos().Y();
5223cdf0e10cSrcweir                             if( nHeight )
5224cdf0e10cSrcweir                             {
5225cdf0e10cSrcweir                                 if( bCell )
5226cdf0e10cSrcweir                                 {
5227cdf0e10cSrcweir                                     SwRect aVert( Point( nX, aTmp.Pos().Y() ),
5228cdf0e10cSrcweir                                                 Size( 1, nHeight ) );
5229cdf0e10cSrcweir                                     while( aVert.Left() <= nRight )
5230cdf0e10cSrcweir                                     {
5231cdf0e10cSrcweir                                         PaintBorderLine( rRect, aVert, this, pCol);
5232cdf0e10cSrcweir                                         aVert.Pos().X() += nGridWidth;	//for textgrid refactor
5233cdf0e10cSrcweir                                     }
5234cdf0e10cSrcweir                                 }
5235cdf0e10cSrcweir                                 else if( bBorder )
5236cdf0e10cSrcweir                                 {
5237cdf0e10cSrcweir                                     SwRect aVert( Point( aGrid.Left(),
5238cdf0e10cSrcweir                                         aTmp.Pos().Y() ), Size( 1, nHeight ) );
5239cdf0e10cSrcweir                                     if( bLeft )
5240cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5241cdf0e10cSrcweir                                     if( bRight )
5242cdf0e10cSrcweir                                     {
5243cdf0e10cSrcweir                                         aVert.Pos().X() = nGridRight;
5244cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5245cdf0e10cSrcweir                                     }
5246cdf0e10cSrcweir                                 }
5247cdf0e10cSrcweir                             }
5248cdf0e10cSrcweir                         }
5249cdf0e10cSrcweir                         else
5250cdf0e10cSrcweir                         {
5251cdf0e10cSrcweir                             nY += nRuby;
5252cdf0e10cSrcweir                             if( bBorder )
5253cdf0e10cSrcweir                             {
5254cdf0e10cSrcweir                                 SwTwips nPos = Max(aInter.Top(),aTmp.Pos().Y());
5255cdf0e10cSrcweir                                 SwTwips nH = Min( nBottom, nY ) - nPos;
5256cdf0e10cSrcweir                                 SwRect aVert( Point( aGrid.Left(), nPos ),
5257cdf0e10cSrcweir                                             Size( 1, nH ) );
5258cdf0e10cSrcweir                                 if( nH > 0 )
5259cdf0e10cSrcweir                                 {
5260cdf0e10cSrcweir                                     if( bLeft )
5261cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5262cdf0e10cSrcweir                                     if( bRight )
5263cdf0e10cSrcweir                                     {
5264cdf0e10cSrcweir                                         aVert.Pos().X() = nGridRight;
5265cdf0e10cSrcweir                                         PaintBorderLine(rRect,aVert,this,pCol);
5266cdf0e10cSrcweir                                     }
5267cdf0e10cSrcweir                                 }
5268cdf0e10cSrcweir                             }
5269cdf0e10cSrcweir                         }
5270cdf0e10cSrcweir                         bGrid = !bGrid;
5271cdf0e10cSrcweir                     }
5272cdf0e10cSrcweir                 }
5273cdf0e10cSrcweir             }
5274cdf0e10cSrcweir         }
5275cdf0e10cSrcweir     }
5276cdf0e10cSrcweir }
5277cdf0e10cSrcweir 
5278cdf0e10cSrcweir /** paint margin area of a page
5279cdf0e10cSrcweir 
5280cdf0e10cSrcweir     OD 20.11.2002 for #104598#:
5281cdf0e10cSrcweir     implement paint of margin area; margin area will be painted for a
5282cdf0e10cSrcweir     view shell with a window and if the document is not in online layout.
5283cdf0e10cSrcweir 
5284cdf0e10cSrcweir     @author OD
5285cdf0e10cSrcweir 
5286cdf0e10cSrcweir     @param _rOutputRect
5287cdf0e10cSrcweir     input parameter - constant instance reference of the rectangle, for
5288cdf0e10cSrcweir     which an output has to be generated.
5289cdf0e10cSrcweir 
5290cdf0e10cSrcweir     @param _pViewShell
5291cdf0e10cSrcweir     input parameter - instance of the view shell, on which the output
5292cdf0e10cSrcweir     has to be generated.
5293cdf0e10cSrcweir */
PaintMarginArea(const SwRect & _rOutputRect,ViewShell * _pViewShell) const5294cdf0e10cSrcweir void SwPageFrm::PaintMarginArea( const SwRect& _rOutputRect,
5295cdf0e10cSrcweir                                  ViewShell* _pViewShell ) const
5296cdf0e10cSrcweir {
5297cdf0e10cSrcweir     if (  _pViewShell->GetWin() &&
5298cdf0e10cSrcweir          !_pViewShell->GetViewOptions()->getBrowseMode() )
5299cdf0e10cSrcweir     {
5300cdf0e10cSrcweir         SwRect aPgPrtRect( Prt() );
5301cdf0e10cSrcweir         aPgPrtRect.Pos() += Frm().Pos();
5302cdf0e10cSrcweir         if ( !aPgPrtRect.IsInside( _rOutputRect ) )
5303cdf0e10cSrcweir         {
5304cdf0e10cSrcweir             SwRect aPgRect = Frm();
5305cdf0e10cSrcweir             aPgRect._Intersection( _rOutputRect );
5306cdf0e10cSrcweir             SwRegionRects aPgRegion( aPgRect );
5307cdf0e10cSrcweir             aPgRegion -= aPgPrtRect;
5308cdf0e10cSrcweir             const SwPageFrm* pPage = static_cast<const SwPageFrm*>(this);
5309cdf0e10cSrcweir             if ( pPage->GetSortedObjs() )
5310cdf0e10cSrcweir                 ::lcl_SubtractFlys( this, pPage, aPgRect, aPgRegion );
5311cdf0e10cSrcweir             if ( aPgRegion.Count() )
5312cdf0e10cSrcweir             {
5313cdf0e10cSrcweir                 OutputDevice *pOut = _pViewShell->GetOut();
5314cdf0e10cSrcweir                 if ( pOut->GetFillColor() != aGlobalRetoucheColor )
5315cdf0e10cSrcweir                     pOut->SetFillColor( aGlobalRetoucheColor );
5316cdf0e10cSrcweir 				for ( sal_uInt16 i = 0; i < aPgRegion.Count(); ++i )
5317cdf0e10cSrcweir                 {
5318cdf0e10cSrcweir                     if ( 1 < aPgRegion.Count() )
5319cdf0e10cSrcweir                     {
5320cdf0e10cSrcweir                         ::SwAlignRect( aPgRegion[i], pGlobalShell );
5321cdf0e10cSrcweir                         if( !aPgRegion[i].HasArea() )
5322cdf0e10cSrcweir                             continue;
5323cdf0e10cSrcweir                     }
5324cdf0e10cSrcweir 					pOut->DrawRect(aPgRegion[i].SVRect());
5325cdf0e10cSrcweir                 }
5326cdf0e10cSrcweir             }
5327cdf0e10cSrcweir         }
5328cdf0e10cSrcweir     }
5329cdf0e10cSrcweir }
5330cdf0e10cSrcweir 
5331cdf0e10cSrcweir // ----------------------------------------------------------------------
5332cdf0e10cSrcweir //
5333cdf0e10cSrcweir // const SwPageFrm::mnBorderPxWidth, const SwPageFrm::mnShadowPxWidth
5334cdf0e10cSrcweir // SwPageFrm::GetBorderRect (..), SwPageFrm::GetRightShadowRect(..),
5335cdf0e10cSrcweir // SwPageFrm::GetBottomShadowRect(..),
5336cdf0e10cSrcweir // SwPageFrm::PaintBorderAndShadow(..),
5337cdf0e10cSrcweir // SwPageFrm::GetBorderAndShadowBoundRect(..)
5338cdf0e10cSrcweir //
5339cdf0e10cSrcweir // OD 12.02.2003 for #i9719# and #105645#
5340cdf0e10cSrcweir // ----------------------------------------------------------------------
5341cdf0e10cSrcweir 
5342cdf0e10cSrcweir const sal_Int8 SwPageFrm::mnBorderPxWidth = 1;
5343cdf0e10cSrcweir const sal_Int8 SwPageFrm::mnShadowPxWidth = 2;
5344cdf0e10cSrcweir 
5345cdf0e10cSrcweir /** determine rectangle for page border
5346cdf0e10cSrcweir 
5347cdf0e10cSrcweir     OD 12.02.2003 for #i9719# and #105645#
5348cdf0e10cSrcweir 
5349cdf0e10cSrcweir     @author OD
5350cdf0e10cSrcweir */
GetBorderRect(const SwRect & _rPageRect,ViewShell * _pViewShell,SwRect & _orBorderRect,bool bRightSidebar)5351cdf0e10cSrcweir /*static*/ void SwPageFrm::GetBorderRect( const SwRect& _rPageRect,
5352cdf0e10cSrcweir                                           ViewShell*    _pViewShell,
5353cdf0e10cSrcweir                                           SwRect& _orBorderRect,
5354cdf0e10cSrcweir                                           bool bRightSidebar )
5355cdf0e10cSrcweir {
5356cdf0e10cSrcweir     SwRect aAlignedPageRect( _rPageRect );
5357cdf0e10cSrcweir     ::SwAlignRect( aAlignedPageRect, _pViewShell );
5358cdf0e10cSrcweir     Rectangle aBorderPxRect =
5359cdf0e10cSrcweir             _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() );
5360cdf0e10cSrcweir 
5361cdf0e10cSrcweir 	aBorderPxRect.Left() = aBorderPxRect.Left() - mnBorderPxWidth;
5362cdf0e10cSrcweir     aBorderPxRect.Top() = aBorderPxRect.Top() - mnBorderPxWidth;
5363cdf0e10cSrcweir     aBorderPxRect.Right() = aBorderPxRect.Right() + mnBorderPxWidth;
5364cdf0e10cSrcweir     aBorderPxRect.Bottom() = aBorderPxRect.Bottom() + mnBorderPxWidth;
5365cdf0e10cSrcweir 
5366cdf0e10cSrcweir 	AddSidebarBorders(aBorderPxRect,_pViewShell, bRightSidebar, true);
5367cdf0e10cSrcweir 
5368cdf0e10cSrcweir     _orBorderRect =
5369cdf0e10cSrcweir             SwRect( _pViewShell->GetOut()->PixelToLogic( aBorderPxRect ) );
5370cdf0e10cSrcweir }
5371cdf0e10cSrcweir 
5372cdf0e10cSrcweir /** determine rectangle for right page shadow
5373cdf0e10cSrcweir 
5374cdf0e10cSrcweir     OD 12.02.2003 for #i9719# and #105645#
5375cdf0e10cSrcweir 
5376cdf0e10cSrcweir     @author OD
5377cdf0e10cSrcweir */
GetRightShadowRect(const SwRect & _rPageRect,ViewShell * _pViewShell,SwRect & _orRightShadowRect,bool bRightSidebar)5378cdf0e10cSrcweir /*static*/ void SwPageFrm::GetRightShadowRect( const SwRect& _rPageRect,
5379cdf0e10cSrcweir                                                ViewShell*    _pViewShell,
5380cdf0e10cSrcweir                                                SwRect&       _orRightShadowRect,
5381cdf0e10cSrcweir                                                bool bRightSidebar )
5382cdf0e10cSrcweir {
5383cdf0e10cSrcweir     SwRect aAlignedPageRect( _rPageRect );
5384cdf0e10cSrcweir     ::SwAlignRect( aAlignedPageRect, _pViewShell );
5385cdf0e10cSrcweir     Rectangle aPagePxRect =
5386cdf0e10cSrcweir             _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() );
5387cdf0e10cSrcweir 
5388cdf0e10cSrcweir     Rectangle aRightShadowPxRect(
5389cdf0e10cSrcweir                     aPagePxRect.Right() + mnShadowPxWidth,
5390cdf0e10cSrcweir                     aPagePxRect.Top() + 1,
5391cdf0e10cSrcweir                     aPagePxRect.Right() + mnBorderPxWidth + mnShadowPxWidth,
5392cdf0e10cSrcweir                     aPagePxRect.Bottom() + mnBorderPxWidth + mnShadowPxWidth );
5393cdf0e10cSrcweir 
5394cdf0e10cSrcweir     if ( bRightSidebar )
5395cdf0e10cSrcweir 	    AddSidebarBorders(aRightShadowPxRect,_pViewShell, bRightSidebar, true);
5396cdf0e10cSrcweir 
5397cdf0e10cSrcweir     _orRightShadowRect =
5398cdf0e10cSrcweir             SwRect( _pViewShell->GetOut()->PixelToLogic( aRightShadowPxRect ) );
5399cdf0e10cSrcweir }
5400cdf0e10cSrcweir 
5401cdf0e10cSrcweir /** determine rectangle for bottom page shadow
5402cdf0e10cSrcweir 
5403cdf0e10cSrcweir     OD 12.02.2003 for #i9719# and #105645#
5404cdf0e10cSrcweir 
5405cdf0e10cSrcweir     @author OD
5406cdf0e10cSrcweir */
GetBottomShadowRect(const SwRect & _rPageRect,ViewShell * _pViewShell,SwRect & _orBottomShadowRect,bool bRightSidebar)5407cdf0e10cSrcweir /*static*/ void SwPageFrm::GetBottomShadowRect( const SwRect& _rPageRect,
5408cdf0e10cSrcweir                                                 ViewShell*    _pViewShell,
5409cdf0e10cSrcweir                                                 SwRect&       _orBottomShadowRect,
5410cdf0e10cSrcweir                                                 bool bRightSidebar )
5411cdf0e10cSrcweir {
5412cdf0e10cSrcweir     SwRect aAlignedPageRect( _rPageRect );
5413cdf0e10cSrcweir     ::SwAlignRect( aAlignedPageRect, _pViewShell );
5414cdf0e10cSrcweir     Rectangle aPagePxRect =
5415cdf0e10cSrcweir             _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() );
5416cdf0e10cSrcweir 
5417cdf0e10cSrcweir     Rectangle aBottomShadowPxRect(
5418cdf0e10cSrcweir                     aPagePxRect.Left() + 1,
5419cdf0e10cSrcweir                     aPagePxRect.Bottom() + mnShadowPxWidth,
5420cdf0e10cSrcweir                     aPagePxRect.Right() + mnBorderPxWidth + mnShadowPxWidth,
5421cdf0e10cSrcweir                     aPagePxRect.Bottom() + mnBorderPxWidth + mnShadowPxWidth );
5422cdf0e10cSrcweir 
5423cdf0e10cSrcweir 	AddSidebarBorders(aBottomShadowPxRect,_pViewShell, bRightSidebar, true);
5424cdf0e10cSrcweir 
5425cdf0e10cSrcweir     _orBottomShadowRect =
5426cdf0e10cSrcweir             SwRect( _pViewShell->GetOut()->PixelToLogic( aBottomShadowPxRect ) );
5427cdf0e10cSrcweir }
5428cdf0e10cSrcweir 
5429cdf0e10cSrcweir /** paint page border and shadow
5430cdf0e10cSrcweir 
5431cdf0e10cSrcweir     OD 12.02.2003 for #i9719# and #105645#
5432cdf0e10cSrcweir     implement paint of page border and shadow
5433cdf0e10cSrcweir 
5434cdf0e10cSrcweir     @author OD
5435cdf0e10cSrcweir */
PaintBorderAndShadow(const SwRect & _rPageRect,ViewShell * _pViewShell,bool bPaintRightShadow,bool bRightSidebar)5436cdf0e10cSrcweir /*static*/ void SwPageFrm::PaintBorderAndShadow( const SwRect& _rPageRect,
5437cdf0e10cSrcweir                                                  ViewShell*    _pViewShell,
5438cdf0e10cSrcweir                                                  bool bPaintRightShadow,
5439cdf0e10cSrcweir                                                  bool bRightSidebar )
5440cdf0e10cSrcweir {
5441cdf0e10cSrcweir     // --> FME 2004-06-24 #i16816# tagged pdf support
5442cdf0e10cSrcweir     SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *_pViewShell->GetOut() );
5443cdf0e10cSrcweir     // <--
5444cdf0e10cSrcweir 
5445cdf0e10cSrcweir     // get color for page border and shadow paint
5446cdf0e10cSrcweir     const Color& rColor = SwViewOption::GetFontColor();
5447cdf0e10cSrcweir 
5448cdf0e10cSrcweir     // save current fill and line color of output device
5449cdf0e10cSrcweir     Color aFill( _pViewShell->GetOut()->GetFillColor() );
5450cdf0e10cSrcweir     Color aLine( _pViewShell->GetOut()->GetLineColor() );
5451cdf0e10cSrcweir 
5452cdf0e10cSrcweir     // paint page border
5453cdf0e10cSrcweir     _pViewShell->GetOut()->SetFillColor(); // OD 20.02.2003 #107369# - no fill color
5454cdf0e10cSrcweir     _pViewShell->GetOut()->SetLineColor( rColor );
5455cdf0e10cSrcweir     SwRect aPaintRect;
5456cdf0e10cSrcweir     SwPageFrm::GetBorderRect( _rPageRect, _pViewShell, aPaintRect, bRightSidebar );
5457cdf0e10cSrcweir     _pViewShell->GetOut()->DrawRect( aPaintRect.SVRect() );
5458cdf0e10cSrcweir 
54590272ccd2Smseidel 	// paint right shadow
54600272ccd2Smseidel //	if ( bPaintRightShadow )
54610272ccd2Smseidel //	{
54620272ccd2Smseidel //		_pViewShell->GetOut()->SetFillColor( rColor );
54630272ccd2Smseidel //		SwPageFrm::GetRightShadowRect( _rPageRect, _pViewShell, aPaintRect, bRightSidebar );
54640272ccd2Smseidel //		_pViewShell->GetOut()->DrawRect( aPaintRect.SVRect() );
54650272ccd2Smseidel //	}
5466cdf0e10cSrcweir 
54670272ccd2Smseidel 	// paint bottom shadow
54680272ccd2Smseidel //	SwPageFrm::GetBottomShadowRect( _rPageRect, _pViewShell, aPaintRect, bRightSidebar );
54690272ccd2Smseidel //	_pViewShell->GetOut()->DrawRect( aPaintRect.SVRect() );
5470cdf0e10cSrcweir 
54710272ccd2Smseidel //	_pViewShell->GetOut()->SetFillColor( aFill );
54720272ccd2Smseidel //	_pViewShell->GetOut()->SetLineColor( aLine );
5473cdf0e10cSrcweir }
5474cdf0e10cSrcweir 
5475cdf0e10cSrcweir //mod #i6193# paint sidebar for notes
5476cdf0e10cSrcweir //IMPORTANT: if you change the rects here, also change SwPostItMgr::ScrollbarHit
PaintNotesSidebar(const SwRect & _rPageRect,ViewShell * _pViewShell,sal_uInt16 nPageNum,bool bRight)5477cdf0e10cSrcweir /*static*/void SwPageFrm::PaintNotesSidebar(const SwRect& _rPageRect, ViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight)
5478cdf0e10cSrcweir {
5479*22ea211eSmseidel 	//TODO: cut out scrollbar area and arrows out of sidepane rect, otherwise it could flicker when pressing arrow buttons
5480cdf0e10cSrcweir     if (!_pViewShell )
5481cdf0e10cSrcweir         return;
5482cdf0e10cSrcweir 
5483cdf0e10cSrcweir     SwRect aPageRect( _rPageRect );
5484cdf0e10cSrcweir     SwAlignRect( aPageRect, _pViewShell );
5485cdf0e10cSrcweir 
5486cdf0e10cSrcweir     const SwPostItMgr *pMgr = _pViewShell->GetPostItMgr();
5487cdf0e10cSrcweir     if (pMgr && pMgr->ShowNotes() && pMgr->HasNotes())  // do not show anything in print preview
5488cdf0e10cSrcweir 	{
5489cdf0e10cSrcweir         sal_Int32 nScrollerHeight = pMgr->GetSidebarScrollerHeight();
5490cdf0e10cSrcweir         const Rectangle &aVisRect = _pViewShell->VisArea().SVRect();
5491cdf0e10cSrcweir         //draw border and sidepane
5492cdf0e10cSrcweir         _pViewShell->GetOut()->SetLineColor();
5493cdf0e10cSrcweir         if (!bRight)
5494cdf0e10cSrcweir         {
5495cdf0e10cSrcweir             _pViewShell->GetOut()->SetFillColor(COL_NOTES_SIDEPANE_BORDER);
5496cdf0e10cSrcweir             _pViewShell->GetOut()->DrawRect(Rectangle(Point(aPageRect.Left()-pMgr->GetSidebarBorderWidth(),aPageRect.Top()),Size(pMgr->GetSidebarBorderWidth(),aPageRect.Height())))    ;
5497cdf0e10cSrcweir             if (Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
5498cdf0e10cSrcweir                 _pViewShell->GetOut()->SetFillColor(COL_BLACK);
5499cdf0e10cSrcweir             else
5500cdf0e10cSrcweir                 _pViewShell->GetOut()->SetFillColor(COL_NOTES_SIDEPANE);
5501cdf0e10cSrcweir             _pViewShell->GetOut()->DrawRect(Rectangle(Point(aPageRect.Left()-pMgr->GetSidebarWidth()-pMgr->GetSidebarBorderWidth(),aPageRect.Top()),Size(pMgr->GetSidebarWidth(),aPageRect.Height())))  ;
5502cdf0e10cSrcweir         }
5503cdf0e10cSrcweir         else
5504cdf0e10cSrcweir         {
5505cdf0e10cSrcweir             _pViewShell->GetOut()->SetFillColor(COL_NOTES_SIDEPANE_BORDER);
5506cdf0e10cSrcweir             SwRect aSidebarBorder(aPageRect.TopRight(),Size(pMgr->GetSidebarBorderWidth(),aPageRect.Height()));
5507cdf0e10cSrcweir             _pViewShell->GetOut()->DrawRect(aSidebarBorder.SVRect());
5508cdf0e10cSrcweir             if (Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
5509cdf0e10cSrcweir                 _pViewShell->GetOut()->SetFillColor(COL_BLACK);
5510cdf0e10cSrcweir             else
5511cdf0e10cSrcweir                 _pViewShell->GetOut()->SetFillColor(COL_NOTES_SIDEPANE);
5512cdf0e10cSrcweir             SwRect aSidebar(Point(aPageRect.Right()+pMgr->GetSidebarBorderWidth(),aPageRect.Top()),Size(pMgr->GetSidebarWidth(),aPageRect.Height()));
5513cdf0e10cSrcweir             _pViewShell->GetOut()->DrawRect(aSidebar.SVRect());
5514cdf0e10cSrcweir         }
5515cdf0e10cSrcweir         if (pMgr->ShowScrollbar(nPageNum))
5516cdf0e10cSrcweir         {
5517cdf0e10cSrcweir             // draw scrollbar area and arrows
5518cdf0e10cSrcweir             Point aPointBottom;
5519cdf0e10cSrcweir             Point aPointTop;
5520cdf0e10cSrcweir             aPointBottom = !bRight ? Point(aPageRect.Left() - pMgr->GetSidebarWidth() - pMgr->GetSidebarBorderWidth() + _pViewShell->GetOut()->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- _pViewShell->GetOut()->PixelToLogic(Size(0,2+pMgr->GetSidebarScrollerHeight())).Height()) :
5521cdf0e10cSrcweir                                     Point(aPageRect.Right() + pMgr->GetSidebarBorderWidth() + _pViewShell->GetOut()->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- _pViewShell->GetOut()->PixelToLogic(Size(0,2+pMgr->GetSidebarScrollerHeight())).Height());
5522cdf0e10cSrcweir             aPointTop = !bRight ?    Point(aPageRect.Left() - pMgr->GetSidebarWidth() + _pViewShell->GetOut()->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + _pViewShell->GetOut()->PixelToLogic(Size(0,2)).Height()) :
5523cdf0e10cSrcweir                                 Point(aPageRect.Right() + pMgr->GetSidebarBorderWidth() + _pViewShell->GetOut()->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + _pViewShell->GetOut()->PixelToLogic(Size(0,2)).Height());
5524cdf0e10cSrcweir             Size aSize(pMgr->GetSidebarWidth() - _pViewShell->GetOut()->PixelToLogic(Size(4,0)).Width(), _pViewShell->GetOut()->PixelToLogic(Size(0,nScrollerHeight)).Height()) ;
5525cdf0e10cSrcweir             Rectangle aRectBottom(aPointBottom,aSize);
5526cdf0e10cSrcweir             Rectangle aRectTop(aPointTop,aSize);
5527cdf0e10cSrcweir 
5528cdf0e10cSrcweir             if (aRectBottom.IsOver(aVisRect))
5529cdf0e10cSrcweir             {
5530cdf0e10cSrcweir 
5531cdf0e10cSrcweir                 if (Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
5532cdf0e10cSrcweir                 {
5533cdf0e10cSrcweir                     _pViewShell->GetOut()->SetLineColor(COL_WHITE);
5534cdf0e10cSrcweir                     _pViewShell->GetOut()->SetFillColor(COL_BLACK);
5535cdf0e10cSrcweir                 }
5536cdf0e10cSrcweir                 else
5537cdf0e10cSrcweir                 {
5538cdf0e10cSrcweir                     _pViewShell->GetOut()->SetLineColor(COL_BLACK);
5539cdf0e10cSrcweir                     _pViewShell->GetOut()->SetFillColor(COL_NOTES_SIDEPANE_SCROLLAREA);
5540cdf0e10cSrcweir                 }
5541cdf0e10cSrcweir                 _pViewShell->GetOut()->DrawRect(aRectBottom);
5542cdf0e10cSrcweir                 _pViewShell->GetOut()->DrawLine(aPointBottom + Point(pMgr->GetSidebarWidth()/3,0), aPointBottom + Point(pMgr->GetSidebarWidth()/3 , _pViewShell->GetOut()->PixelToLogic(Size(0,nScrollerHeight)).Height()));
5543cdf0e10cSrcweir 
5544cdf0e10cSrcweir                 _pViewShell->GetOut()->SetLineColor();
5545cdf0e10cSrcweir                 Point aMiddleFirst(aPointBottom + Point(pMgr->GetSidebarWidth()/6,_pViewShell->GetOut()->PixelToLogic(Size(0,nScrollerHeight)).Height()/2));
5546cdf0e10cSrcweir                 Point aMiddleSecond(aPointBottom + Point(pMgr->GetSidebarWidth()/3*2,_pViewShell->GetOut()->PixelToLogic(Size(0,nScrollerHeight)).Height()/2));
5547cdf0e10cSrcweir                 PaintNotesSidebarArrows(aMiddleFirst,aMiddleSecond,_pViewShell,pMgr->GetArrowColor(KEY_PAGEUP,nPageNum), pMgr->GetArrowColor(KEY_PAGEDOWN,nPageNum));
5548cdf0e10cSrcweir             }
5549cdf0e10cSrcweir             if (aRectTop.IsOver(aVisRect))
5550cdf0e10cSrcweir             {
5551cdf0e10cSrcweir                 if (Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
5552cdf0e10cSrcweir                 {
5553cdf0e10cSrcweir                     _pViewShell->GetOut()->SetLineColor(COL_WHITE);
5554cdf0e10cSrcweir                     _pViewShell->GetOut()->SetFillColor(COL_BLACK);
5555cdf0e10cSrcweir                 }
5556cdf0e10cSrcweir                 else
5557cdf0e10cSrcweir                 {
5558cdf0e10cSrcweir                     _pViewShell->GetOut()->SetLineColor(COL_BLACK);
5559cdf0e10cSrcweir                     _pViewShell->GetOut()->SetFillColor(COL_NOTES_SIDEPANE_SCROLLAREA);
5560cdf0e10cSrcweir                 }
5561cdf0e10cSrcweir                 _pViewShell->GetOut()->DrawRect(aRectTop);
5562cdf0e10cSrcweir                 _pViewShell->GetOut()->DrawLine(aPointTop + Point(pMgr->GetSidebarWidth()/3*2,0), aPointTop + Point(pMgr->GetSidebarWidth()/3*2 , _pViewShell->GetOut()->PixelToLogic(Size(0,nScrollerHeight)).Height()));
5563cdf0e10cSrcweir 
5564cdf0e10cSrcweir                 _pViewShell->GetOut()->SetLineColor();
5565cdf0e10cSrcweir                 Point aMiddleFirst(aPointTop + Point(pMgr->GetSidebarWidth()/3,_pViewShell->GetOut()->PixelToLogic(Size(0,nScrollerHeight)).Height()/2));
5566cdf0e10cSrcweir                 Point aMiddleSecond(aPointTop + Point(pMgr->GetSidebarWidth()/6*5,_pViewShell->GetOut()->PixelToLogic(Size(0,nScrollerHeight)).Height()/2));
5567cdf0e10cSrcweir                 PaintNotesSidebarArrows(aMiddleFirst,aMiddleSecond,_pViewShell, pMgr->GetArrowColor(KEY_PAGEUP,nPageNum), pMgr->GetArrowColor(KEY_PAGEDOWN,nPageNum));
5568cdf0e10cSrcweir             }
5569cdf0e10cSrcweir         }
5570cdf0e10cSrcweir     }
5571cdf0e10cSrcweir }
5572cdf0e10cSrcweir 
PaintNotesSidebarArrows(const Point & aMiddleFirst,const Point & aMiddleSecond,ViewShell * _pViewShell,const Color aColorUp,const Color aColorDown)5573cdf0e10cSrcweir /*static*/ void SwPageFrm::PaintNotesSidebarArrows(const Point &aMiddleFirst, const Point &aMiddleSecond, ViewShell* _pViewShell, const Color aColorUp, const Color aColorDown)
5574cdf0e10cSrcweir {
5575cdf0e10cSrcweir 	Polygon aTriangleUp(3);
5576cdf0e10cSrcweir 	Polygon aTriangleDown(3);
5577cdf0e10cSrcweir 
5578cdf0e10cSrcweir 	aTriangleUp.SetPoint(aMiddleFirst + Point(0,_pViewShell->GetOut()->PixelToLogic(Size(0,-3)).Height()),0);
5579cdf0e10cSrcweir 	aTriangleUp.SetPoint(aMiddleFirst + Point(_pViewShell->GetOut()->PixelToLogic(Size(-3,0)).Width(),_pViewShell->GetOut()->PixelToLogic(Size(0,3)).Height()),1);
5580cdf0e10cSrcweir 	aTriangleUp.SetPoint(aMiddleFirst + Point(_pViewShell->GetOut()->PixelToLogic(Size(3,0)).Width(),_pViewShell->GetOut()->PixelToLogic(Size(0,3)).Height()),2);
5581cdf0e10cSrcweir 
5582cdf0e10cSrcweir 	aTriangleDown.SetPoint(aMiddleSecond + Point(_pViewShell->GetOut()->PixelToLogic(Size(-3,0)).Width(),_pViewShell->GetOut()->PixelToLogic(Size(0,-3)).Height()),0);
5583cdf0e10cSrcweir 	aTriangleDown.SetPoint(aMiddleSecond + Point(_pViewShell->GetOut()->PixelToLogic(Size(+3,0)).Width(),_pViewShell->GetOut()->PixelToLogic(Size(0,-3)).Height()),1);
5584cdf0e10cSrcweir 	aTriangleDown.SetPoint(aMiddleSecond + Point(0,_pViewShell->GetOut()->PixelToLogic(Size(0,3)).Height()),2);
5585cdf0e10cSrcweir 
5586cdf0e10cSrcweir 	_pViewShell->GetOut()->SetFillColor(aColorUp);
5587cdf0e10cSrcweir 	_pViewShell->GetOut()->DrawPolygon(aTriangleUp);
5588cdf0e10cSrcweir 	_pViewShell->GetOut()->SetFillColor(aColorDown);
5589cdf0e10cSrcweir 	_pViewShell->GetOut()->DrawPolygon(aTriangleDown);
5590cdf0e10cSrcweir }
5591cdf0e10cSrcweir 
5592cdf0e10cSrcweir /** get bound rectangle of border and shadow for repaints
5593cdf0e10cSrcweir 
5594cdf0e10cSrcweir     OD 12.02.2003 for #i9719# and #105645#
5595cdf0e10cSrcweir 
5596cdf0e10cSrcweir     author OD
5597cdf0e10cSrcweir */
GetBorderAndShadowBoundRect(const SwRect & _rPageRect,ViewShell * _pViewShell,SwRect & _orBorderAndShadowBoundRect,bool bRightSidebar)5598cdf0e10cSrcweir /*static*/ void SwPageFrm::GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
5599cdf0e10cSrcweir                                                         ViewShell*    _pViewShell,
5600cdf0e10cSrcweir                                                         SwRect& _orBorderAndShadowBoundRect,
5601cdf0e10cSrcweir                                                         bool bRightSidebar )
5602cdf0e10cSrcweir {
5603cdf0e10cSrcweir     SwRect aTmpRect;
5604cdf0e10cSrcweir     SwPageFrm::GetBorderRect( _rPageRect, _pViewShell, _orBorderAndShadowBoundRect, bRightSidebar );
5605cdf0e10cSrcweir     SwPageFrm::GetRightShadowRect( _rPageRect, _pViewShell, aTmpRect, bRightSidebar );
5606cdf0e10cSrcweir     _orBorderAndShadowBoundRect.Union( aTmpRect );
5607cdf0e10cSrcweir     SwPageFrm::GetBottomShadowRect( _rPageRect, _pViewShell, aTmpRect, bRightSidebar );
5608cdf0e10cSrcweir     _orBorderAndShadowBoundRect.Union( aTmpRect );
5609cdf0e10cSrcweir 
5610cdf0e10cSrcweir 	AddSidebarBorders(_orBorderAndShadowBoundRect, _pViewShell, bRightSidebar, false);
5611cdf0e10cSrcweir }
5612cdf0e10cSrcweir 
AddSidebarBorders(SwRect & aRect,ViewShell * _pViewShell,bool bRightSidebar,bool bPx)5613cdf0e10cSrcweir /*static*/ void SwPageFrm::AddSidebarBorders(SwRect &aRect, ViewShell* _pViewShell, bool bRightSidebar, bool bPx)
5614cdf0e10cSrcweir {
5615cdf0e10cSrcweir     const SwPostItMgr *pMgr = _pViewShell ? _pViewShell->GetPostItMgr() : 0;
5616cdf0e10cSrcweir     if (pMgr && pMgr->ShowNotes() && pMgr->HasNotes())
5617cdf0e10cSrcweir     {
5618cdf0e10cSrcweir         if (!bRightSidebar)
5619cdf0e10cSrcweir             aRect.SetLeftAndWidth(aRect.Left() - pMgr->GetSidebarWidth(bPx) - pMgr->GetSidebarBorderWidth(bPx), aRect.Width() + pMgr->GetSidebarWidth(bPx) + pMgr->GetSidebarBorderWidth(bPx));
5620cdf0e10cSrcweir         else
5621cdf0e10cSrcweir             aRect.AddRight(pMgr->GetSidebarWidth(bPx) + pMgr->GetSidebarBorderWidth(bPx));
5622cdf0e10cSrcweir     }
5623cdf0e10cSrcweir }
5624cdf0e10cSrcweir 
AddSidebarBorders(Rectangle & aRect,ViewShell * _pViewShell,bool bRightSidebar,bool bPx)5625cdf0e10cSrcweir /*static*/ void SwPageFrm::AddSidebarBorders(Rectangle &aRect, ViewShell* _pViewShell, bool bRightSidebar, bool bPx)
5626cdf0e10cSrcweir {
5627cdf0e10cSrcweir     const SwPostItMgr *pMgr = _pViewShell ? _pViewShell->GetPostItMgr() : 0;
5628cdf0e10cSrcweir     if (pMgr && pMgr->ShowNotes() && pMgr->HasNotes())
5629cdf0e10cSrcweir     {
5630cdf0e10cSrcweir         if (!bRightSidebar)
5631cdf0e10cSrcweir             aRect.Left() -= (pMgr->GetSidebarWidth(bPx) + pMgr->GetSidebarBorderWidth(bPx));
5632cdf0e10cSrcweir         else
5633cdf0e10cSrcweir             aRect.Right() += pMgr->GetSidebarWidth(bPx) + pMgr->GetSidebarBorderWidth(bPx);
5634cdf0e10cSrcweir     }
5635cdf0e10cSrcweir }
5636cdf0e10cSrcweir 
GetSidebarBorderWidth(const ViewShell * _pViewShell)5637cdf0e10cSrcweir /*static*/ SwTwips SwPageFrm::GetSidebarBorderWidth( const ViewShell* _pViewShell )
5638cdf0e10cSrcweir {
5639cdf0e10cSrcweir     const SwPostItMgr* pPostItMgr = _pViewShell ? _pViewShell->GetPostItMgr() : 0;
5640cdf0e10cSrcweir     const SwTwips nRet = pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ? pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() : 0;
5641cdf0e10cSrcweir     return nRet;
5642cdf0e10cSrcweir }
5643cdf0e10cSrcweir 
5644cdf0e10cSrcweir /*************************************************************************
5645cdf0e10cSrcweir |*
5646cdf0e10cSrcweir |*	SwFrm::PaintBaBo()
5647cdf0e10cSrcweir |*
5648cdf0e10cSrcweir |*	Ersterstellung		MA 22. Oct. 93
5649cdf0e10cSrcweir |*	Letzte Aenderung	MA 19. Jun. 96
5650cdf0e10cSrcweir |*
5651cdf0e10cSrcweir |*************************************************************************/
5652cdf0e10cSrcweir 
PaintBaBo(const SwRect & rRect,const SwPageFrm * pPage,const sal_Bool bLowerBorder) const5653cdf0e10cSrcweir void SwFrm::PaintBaBo( const SwRect& rRect, const SwPageFrm *pPage,
5654cdf0e10cSrcweir 					   const sal_Bool bLowerBorder ) const
5655cdf0e10cSrcweir {
5656cdf0e10cSrcweir 	if ( !pPage )
5657cdf0e10cSrcweir 		pPage = FindPageFrm();
5658cdf0e10cSrcweir 
5659cdf0e10cSrcweir 	OutputDevice *pOut = pGlobalShell->GetOut();
5660cdf0e10cSrcweir 
5661cdf0e10cSrcweir     // --> FME 2004-06-24 #i16816# tagged pdf support
5662cdf0e10cSrcweir     SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pOut );
5663cdf0e10cSrcweir     // <--
5664cdf0e10cSrcweir 
5665cdf0e10cSrcweir     // OD 2004-04-23 #116347#
5666cdf0e10cSrcweir     pOut->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
5667cdf0e10cSrcweir     pOut->SetLineColor();
5668cdf0e10cSrcweir 
5669cdf0e10cSrcweir 	SwBorderAttrAccess aAccess( SwFrm::GetCache(), (SwFrm*)this );
5670cdf0e10cSrcweir 	const SwBorderAttrs &rAttrs = *aAccess.Get();
5671cdf0e10cSrcweir 
5672cdf0e10cSrcweir     // OD 20.11.2002 #104598# - take care of page margin area
5673cdf0e10cSrcweir     // Note: code move from <SwFrm::PaintBackground(..)> to new method
5674cdf0e10cSrcweir     // <SwPageFrm::Paintmargin(..)>.
5675cdf0e10cSrcweir     if ( IsPageFrm() )
5676cdf0e10cSrcweir     {
5677cdf0e10cSrcweir         static_cast<const SwPageFrm*>(this)->PaintMarginArea( rRect, pGlobalShell );
5678cdf0e10cSrcweir     }
5679cdf0e10cSrcweir 
5680cdf0e10cSrcweir     // OD 06.08.2002 #99657# - paint border before painting background
5681cdf0e10cSrcweir     // paint grid for page frame and paint border
5682cdf0e10cSrcweir     {
5683cdf0e10cSrcweir         SwRect aRect( rRect );
5684cdf0e10cSrcweir         if( IsPageFrm() )
5685cdf0e10cSrcweir             ((SwPageFrm*)this)->PaintGrid( pOut, aRect );
5686cdf0e10cSrcweir         PaintBorder( aRect, pPage, rAttrs );
5687cdf0e10cSrcweir     }
5688cdf0e10cSrcweir 
5689cdf0e10cSrcweir     // paint background
5690cdf0e10cSrcweir     {
5691cdf0e10cSrcweir         PaintBackground( rRect, pPage, rAttrs, sal_False, bLowerBorder );
5692cdf0e10cSrcweir     }
5693cdf0e10cSrcweir 
5694cdf0e10cSrcweir 	pOut->Pop();
5695cdf0e10cSrcweir }
5696cdf0e10cSrcweir 
5697cdf0e10cSrcweir /*************************************************************************
5698cdf0e10cSrcweir |*
5699cdf0e10cSrcweir |*	SwFrm::PaintBackground()
5700cdf0e10cSrcweir |*
5701cdf0e10cSrcweir |*	Ersterstellung		MA 04. Jan. 93
5702cdf0e10cSrcweir |*	Letzte Aenderung	MA 06. Feb. 97
5703cdf0e10cSrcweir |*
5704cdf0e10cSrcweir |*************************************************************************/
5705cdf0e10cSrcweir /// OD 05.09.2002 #102912#
5706cdf0e10cSrcweir /// Do not paint background for fly frames without a background brush by
5707cdf0e10cSrcweir /// calling <PaintBaBo> at the page or at the fly frame its anchored
PaintBackground(const SwRect & rRect,const SwPageFrm * pPage,const SwBorderAttrs & rAttrs,const sal_Bool bLowerMode,const sal_Bool bLowerBorder) const5708cdf0e10cSrcweir void SwFrm::PaintBackground( const SwRect &rRect, const SwPageFrm *pPage,
5709cdf0e10cSrcweir 						 	 const SwBorderAttrs & rAttrs,
5710cdf0e10cSrcweir 							 const sal_Bool bLowerMode,
5711cdf0e10cSrcweir 							 const sal_Bool bLowerBorder ) const
5712cdf0e10cSrcweir {
5713cdf0e10cSrcweir     // OD 20.01.2003 #i1837# - no paint of table background, if corresponding
5714cdf0e10cSrcweir     // option is *not* set.
5715cdf0e10cSrcweir     if( IsTabFrm() &&
5716cdf0e10cSrcweir         !pGlobalShell->GetViewOptions()->IsTable() )
5717cdf0e10cSrcweir     {
5718cdf0e10cSrcweir         return;
5719cdf0e10cSrcweir     }
5720cdf0e10cSrcweir 
5721cdf0e10cSrcweir 	// nothing to do for covered table cells:
5722cdf0e10cSrcweir 	if( IsCellFrm() && IsCoveredCell() )
5723cdf0e10cSrcweir 		return;
5724cdf0e10cSrcweir 
5725cdf0e10cSrcweir     ViewShell *pSh = pGlobalShell;
5726cdf0e10cSrcweir 
5727cdf0e10cSrcweir     // --> FME 2004-06-24 #i16816# tagged pdf support
5728cdf0e10cSrcweir     SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pSh->GetOut() );
5729cdf0e10cSrcweir     // <--
5730cdf0e10cSrcweir 
5731cdf0e10cSrcweir     const SvxBrushItem* pItem;
5732cdf0e10cSrcweir     /// OD 05.09.2002 #102912#
5733cdf0e10cSrcweir     /// temporary background brush for a fly frame without a background brush
5734cdf0e10cSrcweir     SvxBrushItem* pTmpBackBrush = 0;
5735cdf0e10cSrcweir     const Color* pCol;
5736cdf0e10cSrcweir 	SwRect aOrigBackRect;
5737cdf0e10cSrcweir 	const sal_Bool bPageFrm = IsPageFrm();
5738cdf0e10cSrcweir 	sal_Bool bLowMode = sal_True;
5739cdf0e10cSrcweir 
5740cdf0e10cSrcweir     sal_Bool bBack = GetBackgroundBrush( pItem, pCol, aOrigBackRect, bLowerMode );
5741cdf0e10cSrcweir     //- Ausgabe wenn ein eigener Hintergrund mitgebracht wird.
5742cdf0e10cSrcweir     bool bNoFlyBackground = !bFlyMetafile && !bBack && IsFlyFrm();
5743cdf0e10cSrcweir     if ( bNoFlyBackground )
5744cdf0e10cSrcweir     {
5745cdf0e10cSrcweir         // OD 05.09.2002 #102912# - Fly frame has no background.
5746cdf0e10cSrcweir         // Try to find background brush at parents, if previous call of
5747cdf0e10cSrcweir         // <GetBackgroundBrush> disabled this option with the parameter <bLowerMode>
5748cdf0e10cSrcweir         if ( bLowerMode )
5749cdf0e10cSrcweir         {
5750cdf0e10cSrcweir             bBack = GetBackgroundBrush( pItem, pCol, aOrigBackRect, false );
5751cdf0e10cSrcweir         }
5752cdf0e10cSrcweir         // If still no background found for the fly frame, initialize the
5753cdf0e10cSrcweir         // background brush <pItem> with global retouche color and set <bBack>
5754cdf0e10cSrcweir         // to sal_True, that fly frame will paint its background using this color.
5755cdf0e10cSrcweir         if ( !bBack )
5756cdf0e10cSrcweir         {
5757cdf0e10cSrcweir             // OD 10.01.2003 #i6467# - on print output, pdf output and
5758cdf0e10cSrcweir             // in embedded mode not editing color COL_WHITE is used instead of
5759cdf0e10cSrcweir             // the global retouche color.
5760cdf0e10cSrcweir             if ( pSh->GetOut()->GetOutDevType() == OUTDEV_PRINTER ||
5761cdf0e10cSrcweir                  pSh->GetViewOptions()->IsPDFExport() ||
5762cdf0e10cSrcweir                  ( pSh->GetDoc()->GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED &&
5763cdf0e10cSrcweir                    !pSh->GetDoc()->GetDocShell()->IsInPlaceActive()
5764cdf0e10cSrcweir                  )
5765cdf0e10cSrcweir                )
5766cdf0e10cSrcweir             {
5767cdf0e10cSrcweir                 pTmpBackBrush = new SvxBrushItem( Color( COL_WHITE ), RES_BACKGROUND );
5768cdf0e10cSrcweir             }
5769cdf0e10cSrcweir             else
5770cdf0e10cSrcweir             {
5771cdf0e10cSrcweir                 pTmpBackBrush = new SvxBrushItem( aGlobalRetoucheColor, RES_BACKGROUND);
5772cdf0e10cSrcweir             }
5773cdf0e10cSrcweir             pItem = pTmpBackBrush;
5774cdf0e10cSrcweir             bBack = true;
5775cdf0e10cSrcweir         }
5776cdf0e10cSrcweir     }
5777cdf0e10cSrcweir 
5778cdf0e10cSrcweir 	SwRect aPaintRect( Frm() );
5779cdf0e10cSrcweir 	if( IsTxtFrm() || IsSctFrm() )
5780cdf0e10cSrcweir 		aPaintRect = UnionFrm( sal_True );
5781cdf0e10cSrcweir 
5782cdf0e10cSrcweir 	if ( aPaintRect.IsOver( rRect ) )
5783cdf0e10cSrcweir 	{
5784cdf0e10cSrcweir         if ( bBack || bPageFrm || !bLowerMode )
5785cdf0e10cSrcweir         {
5786cdf0e10cSrcweir             const sal_Bool bBrowse = pSh->GetViewOptions()->getBrowseMode();
5787cdf0e10cSrcweir             SwRect aRect;
5788cdf0e10cSrcweir             if ( (bPageFrm && bBrowse) ||
5789cdf0e10cSrcweir                  (IsTxtFrm() && Prt().SSize() == Frm().SSize()) )
5790cdf0e10cSrcweir             {
5791cdf0e10cSrcweir                 aRect = Frm();
5792cdf0e10cSrcweir                 ::SwAlignRect( aRect, pGlobalShell );
5793cdf0e10cSrcweir             }
5794cdf0e10cSrcweir             else
5795cdf0e10cSrcweir             {
5796cdf0e10cSrcweir                 ::lcl_CalcBorderRect( aRect, this, rAttrs, sal_False );
5797cdf0e10cSrcweir                 if ( (IsTxtFrm() || IsTabFrm()) && GetPrev() )
5798cdf0e10cSrcweir                 {
5799cdf0e10cSrcweir                     if ( GetPrev()->GetAttrSet()->GetBackground() ==
5800cdf0e10cSrcweir                          GetAttrSet()->GetBackground() )
5801cdf0e10cSrcweir                     {
5802cdf0e10cSrcweir                         aRect.Top( Frm().Top() );
5803cdf0e10cSrcweir                     }
5804cdf0e10cSrcweir                 }
5805cdf0e10cSrcweir             }
5806cdf0e10cSrcweir             aRect.Intersection( rRect );
5807cdf0e10cSrcweir 
5808cdf0e10cSrcweir             OutputDevice *pOut = pSh->GetOut();
5809cdf0e10cSrcweir 
5810cdf0e10cSrcweir             if ( aRect.HasArea() )
5811cdf0e10cSrcweir             {
5812cdf0e10cSrcweir                 SvxBrushItem* pNewItem = 0;
5813cdf0e10cSrcweir                 SwRegionRects aRegion( aRect );
5814cdf0e10cSrcweir                 if( pCol )
5815cdf0e10cSrcweir                 {
5816cdf0e10cSrcweir                     pNewItem = new SvxBrushItem( *pCol, RES_BACKGROUND );
5817cdf0e10cSrcweir                     pItem = pNewItem;
5818cdf0e10cSrcweir                 }
5819cdf0e10cSrcweir                 if ( pPage->GetSortedObjs() )
5820cdf0e10cSrcweir                     ::lcl_SubtractFlys( this, pPage, aRect, aRegion );
5821cdf0e10cSrcweir 
5822cdf0e10cSrcweir                 {
5823cdf0e10cSrcweir                     /// OD 06.08.2002 #99657# - determine, if background transparency
5824cdf0e10cSrcweir                     ///     have to be considered for drawing.
5825cdf0e10cSrcweir                     ///     --> Status Quo: background transparency have to be
5826cdf0e10cSrcweir                     ///        considered for fly frames
5827cdf0e10cSrcweir                     const sal_Bool bConsiderBackgroundTransparency = IsFlyFrm();
5828cdf0e10cSrcweir                     for ( sal_uInt16 i = 0; i < aRegion.Count(); ++i )
5829cdf0e10cSrcweir                     {
5830cdf0e10cSrcweir                         if ( 1 < aRegion.Count() )
5831cdf0e10cSrcweir                         {
5832cdf0e10cSrcweir                             ::SwAlignRect( aRegion[i], pGlobalShell );
5833cdf0e10cSrcweir                             if( !aRegion[i].HasArea() )
5834cdf0e10cSrcweir                                 continue;
5835cdf0e10cSrcweir                         }
5836cdf0e10cSrcweir                         /// OD 06.08.2002 #99657# - add 6th parameter to indicate, if
5837cdf0e10cSrcweir                         ///     background transparency have to be considered
5838cdf0e10cSrcweir                         ///     Set missing 5th parameter to the default value GRFNUM_NO
5839cdf0e10cSrcweir                         ///         - see declaration in /core/inc/frmtool.hxx.
5840cdf0e10cSrcweir                         ::DrawGraphic( pItem, pOut, aOrigBackRect, aRegion[i], GRFNUM_NO,
5841cdf0e10cSrcweir                                 bConsiderBackgroundTransparency );
5842cdf0e10cSrcweir                     }
5843cdf0e10cSrcweir                 }
5844cdf0e10cSrcweir                 if( pCol )
5845cdf0e10cSrcweir                     delete pNewItem;
5846cdf0e10cSrcweir             }
5847cdf0e10cSrcweir         }
5848cdf0e10cSrcweir         else
5849cdf0e10cSrcweir             bLowMode = bLowerMode ? sal_True : sal_False;
5850cdf0e10cSrcweir 	}
5851cdf0e10cSrcweir 
5852cdf0e10cSrcweir     /// OD 05.09.2002 #102912#
5853cdf0e10cSrcweir     /// delete temporary background brush.
5854cdf0e10cSrcweir     delete pTmpBackBrush;
5855cdf0e10cSrcweir 
5856cdf0e10cSrcweir     //Jetzt noch Lower und dessen Nachbarn.
5857cdf0e10cSrcweir 	//Wenn ein Frn dabei die Kette verlaesst also nicht mehr Lower von mir ist
5858cdf0e10cSrcweir 	//so hoert der Spass auf.
5859cdf0e10cSrcweir 	const SwFrm *pFrm = GetLower();
5860cdf0e10cSrcweir     if ( pFrm )
5861cdf0e10cSrcweir 	{
5862cdf0e10cSrcweir 		SwRect aFrmRect;
5863cdf0e10cSrcweir 		SwRect aRect( PaintArea() );
5864cdf0e10cSrcweir 		aRect._Intersection( rRect );
5865cdf0e10cSrcweir 		SwRect aBorderRect( aRect );
5866cdf0e10cSrcweir         SwShortCut aShortCut( *pFrm, aBorderRect );
5867cdf0e10cSrcweir 		do
5868cdf0e10cSrcweir 		{   if ( pProgress )
5869cdf0e10cSrcweir 				pProgress->Reschedule();
5870cdf0e10cSrcweir 
5871cdf0e10cSrcweir 			aFrmRect = pFrm->PaintArea();
5872cdf0e10cSrcweir 			if ( aFrmRect.IsOver( aBorderRect ) )
5873cdf0e10cSrcweir 			{
5874cdf0e10cSrcweir 				SwBorderAttrAccess aAccess( SwFrm::GetCache(), (SwFrm*)pFrm );
5875cdf0e10cSrcweir                 const SwBorderAttrs &rTmpAttrs = *aAccess.Get();
5876cdf0e10cSrcweir                 /// OD 06.08.2002 #99657# - paint border before painting background
5877cdf0e10cSrcweir                 if ( bLowerBorder )
5878cdf0e10cSrcweir                     pFrm->PaintBorder( aBorderRect, pPage, rTmpAttrs );
5879cdf0e10cSrcweir 				if ( ( pFrm->IsLayoutFrm() && bLowerBorder ) ||
5880cdf0e10cSrcweir 					 aFrmRect.IsOver( aRect ) )
5881cdf0e10cSrcweir                     pFrm->PaintBackground( aRect, pPage, rTmpAttrs, bLowMode,
5882cdf0e10cSrcweir 										   bLowerBorder );
5883cdf0e10cSrcweir 			}
5884cdf0e10cSrcweir 			pFrm = pFrm->GetNext();
5885cdf0e10cSrcweir 		} while ( pFrm && pFrm->GetUpper() == this &&
5886cdf0e10cSrcweir                   !aShortCut.Stop( aFrmRect ) );
5887cdf0e10cSrcweir 	}
5888cdf0e10cSrcweir }
5889cdf0e10cSrcweir 
5890cdf0e10cSrcweir /*************************************************************************
5891cdf0e10cSrcweir |*
5892cdf0e10cSrcweir |*	SwPageFrm::RefreshSubsidiary()
5893cdf0e10cSrcweir |*
5894cdf0e10cSrcweir |*	Beschreibung		Erneuert alle Hilfslinien der Seite.
5895cdf0e10cSrcweir |*	Ersterstellung		MA 04. Nov. 92
5896cdf0e10cSrcweir |*	Letzte Aenderung	MA 10. May. 95
5897cdf0e10cSrcweir |*
5898cdf0e10cSrcweir |*************************************************************************/
5899cdf0e10cSrcweir 
RefreshSubsidiary(const SwRect & rRect) const5900cdf0e10cSrcweir void SwPageFrm::RefreshSubsidiary( const SwRect &rRect ) const
5901cdf0e10cSrcweir {
5902cdf0e10cSrcweir     if ( IS_SUBS || IS_SUBS_TABLE || IS_SUBS_SECTION || IS_SUBS_FLYS )
5903cdf0e10cSrcweir 	{
5904cdf0e10cSrcweir 		SwRect aRect( rRect );
5905cdf0e10cSrcweir         // OD 18.02.2003 #104989# - Not necessary and incorrect alignment of
5906cdf0e10cSrcweir         // the output rectangle.
5907cdf0e10cSrcweir         //::SwAlignRect( aRect, pGlobalShell );
5908cdf0e10cSrcweir 		if ( aRect.HasArea() )
5909cdf0e10cSrcweir 		{
5910cdf0e10cSrcweir 			//Beim Paint ueber die Root wird das Array von dort gesteuert.
5911cdf0e10cSrcweir 			//Anderfalls kuemmern wir uns selbst darum.
5912cdf0e10cSrcweir 			sal_Bool bDelSubs = sal_False;
5913cdf0e10cSrcweir 			if ( !pSubsLines )
5914cdf0e10cSrcweir 			{
5915cdf0e10cSrcweir 				pSubsLines = new SwSubsRects;
5916cdf0e10cSrcweir                 // OD 20.12.2002 #106318# - create container for special subsidiary lines
5917cdf0e10cSrcweir                 pSpecSubsLines = new SwSubsRects;
5918cdf0e10cSrcweir                 bDelSubs = sal_True;
5919cdf0e10cSrcweir 			}
5920cdf0e10cSrcweir 
5921cdf0e10cSrcweir 			RefreshLaySubsidiary( this, aRect );
5922cdf0e10cSrcweir 
5923cdf0e10cSrcweir             if ( bDelSubs )
5924cdf0e10cSrcweir 			{
5925cdf0e10cSrcweir                 // OD 20.12.2002 #106318# - paint special subsidiary lines
5926cdf0e10cSrcweir                 // and delete its container
5927cdf0e10cSrcweir                 pSpecSubsLines->PaintSubsidiary( pGlobalShell->GetOut(), NULL );
5928cdf0e10cSrcweir                 DELETEZ( pSpecSubsLines );
5929cdf0e10cSrcweir 
5930cdf0e10cSrcweir                 pSubsLines->PaintSubsidiary( pGlobalShell->GetOut(), pLines );
5931cdf0e10cSrcweir 				DELETEZ( pSubsLines );
5932cdf0e10cSrcweir 			}
5933cdf0e10cSrcweir 		}
5934cdf0e10cSrcweir 	}
5935cdf0e10cSrcweir }
5936cdf0e10cSrcweir 
5937cdf0e10cSrcweir /*************************************************************************
5938cdf0e10cSrcweir |*
5939cdf0e10cSrcweir |*	SwLayoutFrm::RefreshLaySubsidiary()
5940cdf0e10cSrcweir |*
5941cdf0e10cSrcweir |*	Ersterstellung		MA 04. Nov. 92
5942cdf0e10cSrcweir |*	Letzte Aenderung	MA 22. Jan. 95
5943cdf0e10cSrcweir |*
5944cdf0e10cSrcweir |*************************************************************************/
RefreshLaySubsidiary(const SwPageFrm * pPage,const SwRect & rRect) const5945cdf0e10cSrcweir void SwLayoutFrm::RefreshLaySubsidiary( const SwPageFrm *pPage,
5946cdf0e10cSrcweir                                         const SwRect &rRect ) const
5947cdf0e10cSrcweir {
5948cdf0e10cSrcweir 	const sal_Bool bNoLowerColumn = !Lower() || !Lower()->IsColumnFrm();
5949cdf0e10cSrcweir 	const sal_Bool bSubsOpt	  = IS_SUBS;
5950cdf0e10cSrcweir     const sal_Bool bSubsTable = ((GetType() & (FRM_ROW | FRM_CELL)) && IS_SUBS_TABLE);
5951cdf0e10cSrcweir     const sal_Bool bSubsOther = (GetType() & (FRM_HEADER | FRM_FOOTER | FRM_FTN )) && bSubsOpt;
5952cdf0e10cSrcweir 	const sal_Bool bSubsSect  = IsSctFrm() &&
5953cdf0e10cSrcweir 								bNoLowerColumn &&
5954cdf0e10cSrcweir 								IS_SUBS_SECTION;
5955cdf0e10cSrcweir     const sal_Bool bSubsFly   = IS_SUBS_FLYS &&
5956cdf0e10cSrcweir                                 (GetType() & FRM_FLY) &&
5957cdf0e10cSrcweir                                 bNoLowerColumn &&
5958cdf0e10cSrcweir 								(!Lower() || !Lower()->IsNoTxtFrm() ||
5959cdf0e10cSrcweir 								 !((SwNoTxtFrm*)Lower())->HasAnimation());
5960cdf0e10cSrcweir 	sal_Bool bSubsBody = sal_False;
5961cdf0e10cSrcweir 	if ( GetType() & FRM_BODY )
5962cdf0e10cSrcweir 	{
5963cdf0e10cSrcweir 		if ( IsPageBodyFrm() )
5964cdf0e10cSrcweir 			bSubsBody = bSubsOpt && bNoLowerColumn;									//nur ohne Spalten
5965cdf0e10cSrcweir         else    //Spaltenbody
5966cdf0e10cSrcweir 		{
5967cdf0e10cSrcweir 			if ( GetUpper()->GetUpper()->IsSctFrm() )
5968cdf0e10cSrcweir 				bSubsBody = IS_SUBS_SECTION;
5969cdf0e10cSrcweir 			else
5970cdf0e10cSrcweir 				bSubsBody = bSubsOpt;
5971cdf0e10cSrcweir 		}
5972cdf0e10cSrcweir 	}
5973cdf0e10cSrcweir 
5974cdf0e10cSrcweir 	if ( bSubsOther || bSubsSect  || bSubsBody || bSubsTable || bSubsFly )
5975cdf0e10cSrcweir 		PaintSubsidiaryLines( pPage, rRect );
5976cdf0e10cSrcweir 
5977cdf0e10cSrcweir     const SwFrm *pLow = Lower();
5978cdf0e10cSrcweir     if( !pLow )
5979cdf0e10cSrcweir         return;
5980cdf0e10cSrcweir     SwShortCut aShortCut( *pLow, rRect );
5981cdf0e10cSrcweir     while( pLow && !aShortCut.Stop( pLow->Frm() ) )
5982cdf0e10cSrcweir     {
5983cdf0e10cSrcweir         if ( pLow->Frm().IsOver( rRect ) && pLow->Frm().HasArea() )
5984cdf0e10cSrcweir         {
5985cdf0e10cSrcweir             if ( pLow->IsLayoutFrm() )
5986cdf0e10cSrcweir                 ((const SwLayoutFrm*)pLow)->RefreshLaySubsidiary( pPage, rRect);
5987cdf0e10cSrcweir             else if ( pLow->GetDrawObjs() )
5988cdf0e10cSrcweir             {
5989cdf0e10cSrcweir                 const SwSortedObjs& rObjs = *(pLow->GetDrawObjs());
5990cdf0e10cSrcweir                 for ( sal_uInt32 i = 0; i < rObjs.Count(); ++i )
5991cdf0e10cSrcweir                 {
5992cdf0e10cSrcweir                     const SwAnchoredObject* pAnchoredObj = rObjs[i];
5993cdf0e10cSrcweir                     if ( pPage->GetFmt()->GetDoc()->IsVisibleLayerId(
5994cdf0e10cSrcweir                                     pAnchoredObj->GetDrawObj()->GetLayer() ) &&
5995cdf0e10cSrcweir                          pAnchoredObj->ISA(SwFlyFrm) )
5996cdf0e10cSrcweir                     {
5997cdf0e10cSrcweir                         const SwFlyFrm *pFly =
5998cdf0e10cSrcweir                                     static_cast<const SwFlyFrm*>(pAnchoredObj);
5999cdf0e10cSrcweir                         if ( pFly->IsFlyInCntFrm() && pFly->Frm().IsOver( rRect ) )
6000cdf0e10cSrcweir                         {
6001cdf0e10cSrcweir                             if ( !pFly->Lower() || !pFly->Lower()->IsNoTxtFrm() ||
6002cdf0e10cSrcweir                                  !((SwNoTxtFrm*)pFly->Lower())->HasAnimation())
6003cdf0e10cSrcweir                                 pFly->RefreshLaySubsidiary( pPage, rRect );
6004cdf0e10cSrcweir                         }
6005cdf0e10cSrcweir                     }
6006cdf0e10cSrcweir                 }
6007cdf0e10cSrcweir             }
6008cdf0e10cSrcweir         }
6009cdf0e10cSrcweir         pLow = pLow->GetNext();
6010cdf0e10cSrcweir     }
6011cdf0e10cSrcweir }
6012cdf0e10cSrcweir 
6013cdf0e10cSrcweir /*************************************************************************
6014cdf0e10cSrcweir |*
6015cdf0e10cSrcweir |*	SwLayoutFrm::PaintSubsidiaryLines()
6016cdf0e10cSrcweir |*
6017cdf0e10cSrcweir |*	Beschreibung		Hilfslinien um die PrtAreas malen
6018cdf0e10cSrcweir |* 		Nur die LayoutFrm's die direkt Cntnt enthalten.
6019cdf0e10cSrcweir |*	Ersterstellung		MA 21. May. 92
6020cdf0e10cSrcweir |*	Letzte Aenderung	MA 22. Jan. 95
6021cdf0e10cSrcweir |*
6022cdf0e10cSrcweir |*************************************************************************/
6023cdf0e10cSrcweir 
6024cdf0e10cSrcweir //Malt die angegebene Linie, achtet darauf, dass keine Flys uebermalt werden.
6025cdf0e10cSrcweir 
6026cdf0e10cSrcweir typedef long Size::* SizePtr;
6027cdf0e10cSrcweir typedef long Point::* PointPtr;
6028cdf0e10cSrcweir 
6029cdf0e10cSrcweir PointPtr pX = &Point::nA;
6030cdf0e10cSrcweir PointPtr pY = &Point::nB;
6031cdf0e10cSrcweir SizePtr pWidth = &Size::nA;
6032cdf0e10cSrcweir SizePtr pHeight = &Size::nB;
6033cdf0e10cSrcweir 
6034cdf0e10cSrcweir // OD 18.11.2002 #99672# - new parameter <_pSubsLines>
lcl_RefreshLine(const SwLayoutFrm * pLay,const SwPageFrm * pPage,const Point & rP1,const Point & rP2,const sal_uInt8 nSubColor,SwLineRects * _pSubsLines)6035cdf0e10cSrcweir void MA_FASTCALL lcl_RefreshLine( const SwLayoutFrm *pLay,
6036cdf0e10cSrcweir                                   const SwPageFrm *pPage,
6037cdf0e10cSrcweir                                   const Point &rP1,
6038cdf0e10cSrcweir                                   const Point &rP2,
6039cdf0e10cSrcweir                                   const sal_uInt8 nSubColor,
6040cdf0e10cSrcweir                                   SwLineRects* _pSubsLines )
6041cdf0e10cSrcweir {
6042cdf0e10cSrcweir 	//In welche Richtung gehts? Kann nur Horizontal oder Vertikal sein.
6043cdf0e10cSrcweir 	ASSERT( ((rP1.X() == rP2.X()) || (rP1.Y() == rP2.Y())),
6044cdf0e10cSrcweir 			"Schraege Hilfslinien sind nicht erlaubt." );
6045cdf0e10cSrcweir     const PointPtr pDirPt = rP1.X() == rP2.X() ? pY : pX;
6046cdf0e10cSrcweir     const PointPtr pOthPt = pDirPt == pX ? pY : pX;
6047cdf0e10cSrcweir     const SizePtr pDirSz = pDirPt == pX ? pWidth : pHeight;
6048cdf0e10cSrcweir     const SizePtr pOthSz = pDirSz == pWidth ? pHeight : pWidth;
6049cdf0e10cSrcweir 	Point aP1( rP1 ),
6050cdf0e10cSrcweir 		  aP2( rP2 );
6051cdf0e10cSrcweir 
6052cdf0e10cSrcweir 	while ( aP1.*pDirPt < aP2.*pDirPt )
6053cdf0e10cSrcweir 	{	//Der Startpunkt wird jetzt, falls er in einem Fly sitzt, direkt
6054cdf0e10cSrcweir 		//hinter den Fly gesetzt.
6055cdf0e10cSrcweir 		//Wenn der Endpunkt in einem Fly sitzt oder zwischen Start und Endpunkt
6056cdf0e10cSrcweir 		//ein Fly sitzt, so wird der Endpunkt eben an den Start herangezogen.
6057cdf0e10cSrcweir 		//Auf diese art und weise wird eine Portion nach der anderen
6058cdf0e10cSrcweir 		//ausgegeben.
6059cdf0e10cSrcweir 
6060cdf0e10cSrcweir 		//Wenn ich selbst ein Fly bin, weiche ich nur denjenigen Flys aus,
6061cdf0e10cSrcweir 		//die 'ueber' mir sitzen; d.h. die in dem Array hinter mir stehen.
6062cdf0e10cSrcweir 		//Auch wenn ich in einem Fly sitze oder in einem Fly im Fly usw. weiche
6063cdf0e10cSrcweir 		//ich keinem dieser Flys aus.
6064cdf0e10cSrcweir 		SwOrderIter aIter( pPage );
6065cdf0e10cSrcweir 		const SwFlyFrm *pMyFly = pLay->FindFlyFrm();
6066cdf0e10cSrcweir 		if ( pMyFly )
6067cdf0e10cSrcweir 		{
6068cdf0e10cSrcweir 			aIter.Current( pMyFly->GetVirtDrawObj() );
6069cdf0e10cSrcweir             while ( 0 != (pMyFly = pMyFly->GetAnchorFrm()->FindFlyFrm()) )
6070cdf0e10cSrcweir 			{
6071cdf0e10cSrcweir 				if ( aIter()->GetOrdNum() > pMyFly->GetVirtDrawObj()->GetOrdNum() )
6072cdf0e10cSrcweir 					aIter.Current( pMyFly->GetVirtDrawObj() );
6073cdf0e10cSrcweir 			}
6074cdf0e10cSrcweir 		}
6075cdf0e10cSrcweir 		else
6076cdf0e10cSrcweir 			aIter.Bottom();
6077cdf0e10cSrcweir 
6078cdf0e10cSrcweir 		while ( aIter() )
6079cdf0e10cSrcweir 		{
6080cdf0e10cSrcweir 			const SwVirtFlyDrawObj *pObj = (SwVirtFlyDrawObj*)aIter();
6081cdf0e10cSrcweir 			const SwFlyFrm *pFly = pObj ? pObj->GetFlyFrm() : 0;
6082cdf0e10cSrcweir 
6083cdf0e10cSrcweir 			//Mir selbst weiche ich natuerlich nicht aus. Auch wenn ich
6084cdf0e10cSrcweir 			//_in_ dem Fly sitze weiche ich nicht aus.
6085cdf0e10cSrcweir 			if ( !pFly || (pFly == pLay || pFly->IsAnLower( pLay )) )
6086cdf0e10cSrcweir             {
6087cdf0e10cSrcweir                 aIter.Next();
6088cdf0e10cSrcweir 				continue;
6089cdf0e10cSrcweir 			}
6090cdf0e10cSrcweir 
6091cdf0e10cSrcweir             // OD 19.12.2002 #106318# - do *not* consider fly frames with
6092cdf0e10cSrcweir             // a transparent background.
6093cdf0e10cSrcweir             // OD 2004-02-12 #110582#-2 - do *not* consider fly frame, which
6094cdf0e10cSrcweir             // belongs to a invisible layer
6095cdf0e10cSrcweir             if ( pFly->IsBackgroundTransparent() ||
6096cdf0e10cSrcweir                  !pFly->GetFmt()->GetDoc()->IsVisibleLayerId( pObj->GetLayer() ) )
6097cdf0e10cSrcweir             {
6098cdf0e10cSrcweir                 aIter.Next();
6099cdf0e10cSrcweir                 continue;
6100cdf0e10cSrcweir             }
6101cdf0e10cSrcweir 
6102cdf0e10cSrcweir 			//Sitzt das Obj auf der Linie
6103cdf0e10cSrcweir 			const Rectangle &rBound = pObj->GetCurrentBoundRect();
6104cdf0e10cSrcweir 			const Point aDrPt( rBound.TopLeft() );
6105cdf0e10cSrcweir 			const Size  aDrSz( rBound.GetSize() );
6106cdf0e10cSrcweir 			if ( rP1.*pOthPt >= aDrPt.*pOthPt &&
6107cdf0e10cSrcweir 				 rP1.*pOthPt <= (aDrPt.*pOthPt + aDrSz.*pOthSz) )
6108cdf0e10cSrcweir 			{
6109cdf0e10cSrcweir 				if ( aP1.*pDirPt >= aDrPt.*pDirPt &&
6110cdf0e10cSrcweir 			  	  	 aP1.*pDirPt <= (aDrPt.*pDirPt + aDrSz.*pDirSz) )
6111cdf0e10cSrcweir 					aP1.*pDirPt = aDrPt.*pDirPt + aDrSz.*pDirSz;
6112cdf0e10cSrcweir 
6113cdf0e10cSrcweir 				if ( aP2.*pDirPt >= aDrPt.*pDirPt &&
6114cdf0e10cSrcweir 					 aP1.*pDirPt < (aDrPt.*pDirPt - 1) )
6115cdf0e10cSrcweir 					aP2.*pDirPt = aDrPt.*pDirPt - 1;
6116cdf0e10cSrcweir 			}
6117cdf0e10cSrcweir 			aIter.Next();
6118cdf0e10cSrcweir 		}
6119cdf0e10cSrcweir 
6120cdf0e10cSrcweir 		if ( aP1.*pDirPt < aP2.*pDirPt )
6121cdf0e10cSrcweir 		{
6122cdf0e10cSrcweir 			SwRect aRect( aP1, aP2 );
6123cdf0e10cSrcweir             // OD 18.11.2002 #99672# - use parameter <_pSubsLines> instead of
6124cdf0e10cSrcweir             // global variable <pSubsLines>.
6125cdf0e10cSrcweir             _pSubsLines->AddLineRect( aRect, 0, 0, nSubColor );
6126cdf0e10cSrcweir 		}
6127cdf0e10cSrcweir 		aP1 = aP2;
6128cdf0e10cSrcweir 		aP1.*pDirPt += 1;
6129cdf0e10cSrcweir 		aP2 = rP2;
6130cdf0e10cSrcweir 	}
6131cdf0e10cSrcweir }
6132cdf0e10cSrcweir 
PaintSubsidiaryLines(const SwPageFrm * pPage,const SwRect & rRect) const6133cdf0e10cSrcweir void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
6134cdf0e10cSrcweir 										const SwRect &rRect ) const
6135cdf0e10cSrcweir {
6136cdf0e10cSrcweir     bool bNewTableModel = false;
6137cdf0e10cSrcweir 
6138cdf0e10cSrcweir     // --> collapsing borders FME 2005-05-27 #i29550#
6139cdf0e10cSrcweir     if ( IsTabFrm() || IsCellFrm() || IsRowFrm() )
6140cdf0e10cSrcweir     {
6141cdf0e10cSrcweir         const SwTabFrm* pTabFrm = FindTabFrm();
6142cdf0e10cSrcweir         if ( pTabFrm->IsCollapsingBorders() )
6143cdf0e10cSrcweir             return;
6144cdf0e10cSrcweir 
6145cdf0e10cSrcweir         bNewTableModel = pTabFrm->GetTable()->IsNewModel();
6146cdf0e10cSrcweir         // in the new table model, we have an early return for all cell-related
6147cdf0e10cSrcweir         // frames, except from non-covered table cells
6148cdf0e10cSrcweir         if ( bNewTableModel )
6149cdf0e10cSrcweir             if ( IsTabFrm() ||
6150cdf0e10cSrcweir                  IsRowFrm() ||
6151cdf0e10cSrcweir                  ( IsCellFrm() && IsCoveredCell() ) )
6152cdf0e10cSrcweir                 return;
6153cdf0e10cSrcweir     }
6154cdf0e10cSrcweir     // <-- collapsing
6155cdf0e10cSrcweir 
6156cdf0e10cSrcweir     const bool bFlys = pPage->GetSortedObjs() ? true : false;
6157cdf0e10cSrcweir 
6158cdf0e10cSrcweir     const bool bCell = IsCellFrm() ? true : false;
6159cdf0e10cSrcweir     // use frame area for cells
6160cdf0e10cSrcweir     // OD 13.02.2003 #i3662# - for section use also frame area
6161cdf0e10cSrcweir     const bool bUseFrmArea = bCell || IsSctFrm();
6162cdf0e10cSrcweir     SwRect aOriginal( bUseFrmArea ? Frm() : Prt() );
6163cdf0e10cSrcweir     if ( !bUseFrmArea )
6164cdf0e10cSrcweir         aOriginal.Pos() += Frm().Pos();
6165cdf0e10cSrcweir 
6166cdf0e10cSrcweir     // OD 13.02.2003 #i3662# - enlarge top of column body frame's printing area
6167cdf0e10cSrcweir     // in sections to top of section frame.
6168cdf0e10cSrcweir     const bool bColBodyInSection = IsBodyFrm() &&
6169cdf0e10cSrcweir                                    !IsPageBodyFrm() &&
6170cdf0e10cSrcweir                                    GetUpper()->GetUpper()->IsSctFrm();
6171cdf0e10cSrcweir     if ( bColBodyInSection )
6172cdf0e10cSrcweir     {
6173cdf0e10cSrcweir         if ( IsVertical() )
6174cdf0e10cSrcweir             aOriginal.Right( GetUpper()->GetUpper()->Frm().Right() );
6175cdf0e10cSrcweir         else
6176cdf0e10cSrcweir             aOriginal.Top( GetUpper()->GetUpper()->Frm().Top() );
6177cdf0e10cSrcweir     }
6178cdf0e10cSrcweir 
6179cdf0e10cSrcweir     ::SwAlignRect( aOriginal, pGlobalShell );
6180cdf0e10cSrcweir 
6181cdf0e10cSrcweir     if ( !aOriginal.IsOver( rRect ) )
6182cdf0e10cSrcweir 		return;
6183cdf0e10cSrcweir 
6184cdf0e10cSrcweir 	SwRect aOut( aOriginal );
6185cdf0e10cSrcweir 	aOut._Intersection( rRect );
6186cdf0e10cSrcweir     // OD 13.02.2003 #i3662# - do not intersect *enlarged* column body frame's
6187cdf0e10cSrcweir     // printing area with the paint area of the body frame. Otherwise enlargement
6188cdf0e10cSrcweir     // will get lost.
6189cdf0e10cSrcweir     if ( !bColBodyInSection )
6190cdf0e10cSrcweir     {
6191cdf0e10cSrcweir         aOut.Intersection( PaintArea() );
6192cdf0e10cSrcweir     }
6193cdf0e10cSrcweir 
6194cdf0e10cSrcweir 	const SwTwips nRight = aOut.Right();
6195cdf0e10cSrcweir 	const SwTwips nBottom= aOut.Bottom();
6196cdf0e10cSrcweir 
6197cdf0e10cSrcweir 	const Point aRT( nRight, aOut.Top() );
6198cdf0e10cSrcweir 	const Point aRB( nRight, nBottom );
6199cdf0e10cSrcweir 	const Point aLB( aOut.Left(), nBottom );
6200cdf0e10cSrcweir 
6201cdf0e10cSrcweir     sal_uInt8 nSubColor = ( bCell || IsRowFrm() ) ? SUBCOL_TAB :
6202cdf0e10cSrcweir                      ( IsInSct() ? SUBCOL_SECT :
6203cdf0e10cSrcweir                      ( IsInFly() ? SUBCOL_FLY : SUBCOL_PAGE ) );
6204cdf0e10cSrcweir 
6205cdf0e10cSrcweir     // OD 05.11.2002 #102406# - body frames are responsible for page/column breaks.
6206cdf0e10cSrcweir     sal_Bool bBreak = sal_False;
6207cdf0e10cSrcweir     if ( IsBodyFrm() )
6208cdf0e10cSrcweir     {
6209cdf0e10cSrcweir         const SwCntntFrm *pCnt = ContainsCntnt();
6210cdf0e10cSrcweir         if ( pCnt )
6211cdf0e10cSrcweir         {
6212cdf0e10cSrcweir             // OD 05.11.2002 #102406# - adjust setting of <bBreak>.
6213cdf0e10cSrcweir             bBreak = pCnt->IsPageBreak( sal_True ) ||
6214cdf0e10cSrcweir                      ( IsColBodyFrm() && pCnt->IsColBreak( sal_True ) );
6215cdf0e10cSrcweir         }
6216cdf0e10cSrcweir     }
6217cdf0e10cSrcweir 
6218cdf0e10cSrcweir     // OD 18.11.2002 #99672# - collect body, header, footer, footnote and section
6219cdf0e10cSrcweir     // sub-lines in <pSpecSubsLine> array.
6220cdf0e10cSrcweir     const bool bSpecialSublines = IsBodyFrm() || IsHeaderFrm() || IsFooterFrm() ||
6221cdf0e10cSrcweir                                   IsFtnFrm() || IsSctFrm();
6222cdf0e10cSrcweir     SwLineRects* pUsedSubsLines = bSpecialSublines ? pSpecSubsLines : pSubsLines;
6223cdf0e10cSrcweir 
6224cdf0e10cSrcweir     // NOTE: for cell frames only left and right (horizontal layout) respectively
6225cdf0e10cSrcweir     //      top and bottom (vertical layout) lines painted.
6226cdf0e10cSrcweir     // NOTE2: this does not hold for the new table model!!! We paint the top border
6227cdf0e10cSrcweir     // of each non-covered table cell.
6228cdf0e10cSrcweir     const bool bVert = IsVertical() ? true : false;
6229cdf0e10cSrcweir     if ( bFlys )
6230cdf0e10cSrcweir 	{
6231cdf0e10cSrcweir         // OD 14.11.2002 #104822# - add control for drawing left and right lines
6232cdf0e10cSrcweir         if ( !bCell || bNewTableModel || !bVert )
6233cdf0e10cSrcweir         {
6234cdf0e10cSrcweir             if ( aOriginal.Left() == aOut.Left() )
6235cdf0e10cSrcweir                 ::lcl_RefreshLine( this, pPage, aOut.Pos(), aLB, nSubColor,
6236cdf0e10cSrcweir                                    pUsedSubsLines );
6237cdf0e10cSrcweir             // OD 14.11.2002 #104821# - in vertical layout set page/column break at right
6238cdf0e10cSrcweir             if ( aOriginal.Right() == nRight )
6239cdf0e10cSrcweir                 ::lcl_RefreshLine( this, pPage, aRT, aRB,
6240cdf0e10cSrcweir                                    (bBreak && bVert) ? SUBCOL_BREAK : nSubColor,
6241cdf0e10cSrcweir                                    pUsedSubsLines );
6242cdf0e10cSrcweir         }
6243cdf0e10cSrcweir         // OD 14.11.2002 #104822# - adjust control for drawing top and bottom lines
6244cdf0e10cSrcweir         if ( !bCell || bNewTableModel || bVert )
6245cdf0e10cSrcweir 		{
6246cdf0e10cSrcweir 			if ( aOriginal.Top() == aOut.Top() )
6247cdf0e10cSrcweir                 // OD 14.11.2002 #104821# - in horizontal layout set page/column break at top
6248cdf0e10cSrcweir 				::lcl_RefreshLine( this, pPage, aOut.Pos(), aRT,
6249cdf0e10cSrcweir                                    (bBreak && !bVert) ? SUBCOL_BREAK : nSubColor,
6250cdf0e10cSrcweir                                    pUsedSubsLines );
6251cdf0e10cSrcweir 			if ( aOriginal.Bottom() == nBottom )
6252cdf0e10cSrcweir                 ::lcl_RefreshLine( this, pPage, aLB, aRB, nSubColor,
6253cdf0e10cSrcweir                                    pUsedSubsLines );
6254cdf0e10cSrcweir 		}
6255cdf0e10cSrcweir 	}
6256cdf0e10cSrcweir 	else
6257cdf0e10cSrcweir 	{
6258cdf0e10cSrcweir         // OD 14.11.2002 #104822# - add control for drawing left and right lines
6259cdf0e10cSrcweir         if ( !bCell || bNewTableModel || !bVert )
6260cdf0e10cSrcweir         {
6261cdf0e10cSrcweir             if ( aOriginal.Left() == aOut.Left() )
6262cdf0e10cSrcweir             {
6263cdf0e10cSrcweir                 const SwRect aRect( aOut.Pos(), aLB );
6264cdf0e10cSrcweir                 pUsedSubsLines->AddLineRect( aRect, 0, 0, nSubColor );
6265cdf0e10cSrcweir             }
6266cdf0e10cSrcweir             // OD 14.11.2002 #104821# - in vertical layout set page/column break at right
6267cdf0e10cSrcweir             if ( aOriginal.Right() == nRight )
6268cdf0e10cSrcweir             {
6269cdf0e10cSrcweir                 const SwRect aRect( aRT, aRB );
6270cdf0e10cSrcweir                 pUsedSubsLines->AddLineRect( aRect, 0, 0,
6271cdf0e10cSrcweir                         (bBreak && bVert) ? SUBCOL_BREAK : nSubColor );
6272cdf0e10cSrcweir             }
6273cdf0e10cSrcweir         }
6274cdf0e10cSrcweir         // OD 14.11.2002 #104822# - adjust control for drawing top and bottom lines
6275cdf0e10cSrcweir         if ( !bCell || bNewTableModel || bVert )
6276cdf0e10cSrcweir         {
6277cdf0e10cSrcweir 			if ( aOriginal.Top() == aOut.Top() )
6278cdf0e10cSrcweir 			{
6279cdf0e10cSrcweir                 // OD 14.11.2002 #104821# - in horizontal layout set page/column break at top
6280cdf0e10cSrcweir 				const SwRect aRect( aOut.Pos(), aRT );
6281cdf0e10cSrcweir                 pUsedSubsLines->AddLineRect( aRect, 0, 0,
6282cdf0e10cSrcweir                         (bBreak && !bVert) ? SUBCOL_BREAK : nSubColor );
6283cdf0e10cSrcweir 			}
6284cdf0e10cSrcweir 			if ( aOriginal.Bottom() == nBottom )
6285cdf0e10cSrcweir 			{
6286cdf0e10cSrcweir 				const SwRect aRect( aLB, aRB );
6287cdf0e10cSrcweir                 pUsedSubsLines->AddLineRect( aRect, 0, 0, nSubColor );
6288cdf0e10cSrcweir 			}
6289cdf0e10cSrcweir         }
6290cdf0e10cSrcweir 	}
6291cdf0e10cSrcweir }
6292cdf0e10cSrcweir 
6293cdf0e10cSrcweir /*************************************************************************
6294cdf0e10cSrcweir |*
6295cdf0e10cSrcweir |*	SwPageFrm::RefreshExtraData(), SwLayoutFrm::RefreshExtraData()
6296cdf0e10cSrcweir |*
6297cdf0e10cSrcweir |*	Beschreibung		Erneuert alle Extradaten (Zeilennummern usw) der Seite.
6298cdf0e10cSrcweir |* 						Grundsaetzlich sind nur diejenigen Objekte beruecksichtig,
6299cdf0e10cSrcweir |* 						die in die seitliche Ausdehnung des Rects ragen.
6300cdf0e10cSrcweir |*	Ersterstellung		MA 20. Jan. 98
6301cdf0e10cSrcweir |*	Letzte Aenderung	MA 18. Feb. 98
6302cdf0e10cSrcweir |*
6303cdf0e10cSrcweir |*************************************************************************/
6304cdf0e10cSrcweir 
RefreshExtraData(const SwRect & rRect) const6305cdf0e10cSrcweir void SwPageFrm::RefreshExtraData( const SwRect &rRect ) const
6306cdf0e10cSrcweir {
6307cdf0e10cSrcweir 	const SwLineNumberInfo &rInfo = GetFmt()->GetDoc()->GetLineNumberInfo();
6308cdf0e10cSrcweir 	sal_Bool bLineInFly = (rInfo.IsPaintLineNumbers() && rInfo.IsCountInFlys())
6309cdf0e10cSrcweir         || (sal_Int16)SW_MOD()->GetRedlineMarkPos() != text::HoriOrientation::NONE;
6310cdf0e10cSrcweir 
6311cdf0e10cSrcweir 	SwRect aRect( rRect );
6312cdf0e10cSrcweir 	::SwAlignRect( aRect, pGlobalShell );
6313cdf0e10cSrcweir 	if ( aRect.HasArea() )
6314cdf0e10cSrcweir 	{
6315cdf0e10cSrcweir 		SwLayoutFrm::RefreshExtraData( aRect );
6316cdf0e10cSrcweir 
6317cdf0e10cSrcweir 		if ( bLineInFly && GetSortedObjs() )
6318cdf0e10cSrcweir 			for ( sal_uInt16 i = 0; i < GetSortedObjs()->Count(); ++i )
6319cdf0e10cSrcweir 			{
6320cdf0e10cSrcweir                 const SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
6321cdf0e10cSrcweir                 if ( pAnchoredObj->ISA(SwFlyFrm) )
6322cdf0e10cSrcweir 				{
6323cdf0e10cSrcweir                     const SwFlyFrm *pFly = static_cast<const SwFlyFrm*>(pAnchoredObj);
6324cdf0e10cSrcweir 					if ( pFly->Frm().Top() <= aRect.Bottom() &&
6325cdf0e10cSrcweir 						 pFly->Frm().Bottom() >= aRect.Top() )
6326cdf0e10cSrcweir 						pFly->RefreshExtraData( aRect );
6327cdf0e10cSrcweir 				}
6328cdf0e10cSrcweir 			}
6329cdf0e10cSrcweir 	}
6330cdf0e10cSrcweir }
6331cdf0e10cSrcweir 
RefreshExtraData(const SwRect & rRect) const6332cdf0e10cSrcweir void SwLayoutFrm::RefreshExtraData( const SwRect &rRect ) const
6333cdf0e10cSrcweir {
6334cdf0e10cSrcweir 
6335cdf0e10cSrcweir 	const SwLineNumberInfo &rInfo = GetFmt()->GetDoc()->GetLineNumberInfo();
6336cdf0e10cSrcweir 	sal_Bool bLineInBody = rInfo.IsPaintLineNumbers(),
6337cdf0e10cSrcweir 			 bLineInFly  = bLineInBody && rInfo.IsCountInFlys(),
6338cdf0e10cSrcweir              bRedLine = (sal_Int16)SW_MOD()->GetRedlineMarkPos()!=text::HoriOrientation::NONE;
6339cdf0e10cSrcweir 
6340cdf0e10cSrcweir 	const SwCntntFrm *pCnt = ContainsCntnt();
6341cdf0e10cSrcweir 	while ( pCnt && IsAnLower( pCnt ) )
6342cdf0e10cSrcweir 	{
6343cdf0e10cSrcweir 		if ( pCnt->IsTxtFrm() && ( bRedLine ||
6344cdf0e10cSrcweir 			 ( !pCnt->IsInTab() &&
6345cdf0e10cSrcweir 			   ((bLineInBody && pCnt->IsInDocBody()) ||
6346cdf0e10cSrcweir 			   (bLineInFly  && pCnt->IsInFly())) ) ) &&
6347cdf0e10cSrcweir 			 pCnt->Frm().Top() <= rRect.Bottom() &&
6348cdf0e10cSrcweir 			 pCnt->Frm().Bottom() >= rRect.Top() )
6349cdf0e10cSrcweir 		{
6350cdf0e10cSrcweir 			((SwTxtFrm*)pCnt)->PaintExtraData( rRect );
6351cdf0e10cSrcweir 		}
6352cdf0e10cSrcweir 		if ( bLineInFly && pCnt->GetDrawObjs() )
6353cdf0e10cSrcweir             for ( sal_uInt32 i = 0; i < pCnt->GetDrawObjs()->Count(); ++i )
6354cdf0e10cSrcweir 			{
6355cdf0e10cSrcweir                 const SwAnchoredObject* pAnchoredObj = (*pCnt->GetDrawObjs())[i];
6356cdf0e10cSrcweir                 if ( pAnchoredObj->ISA(SwFlyFrm) )
6357cdf0e10cSrcweir                 {
6358cdf0e10cSrcweir                     const SwFlyFrm *pFly = static_cast<const SwFlyFrm*>(pAnchoredObj);
6359cdf0e10cSrcweir                     if ( pFly->IsFlyInCntFrm() &&
6360cdf0e10cSrcweir 						 pFly->Frm().Top() <= rRect.Bottom() &&
6361cdf0e10cSrcweir 						 pFly->Frm().Bottom() >= rRect.Top() )
6362cdf0e10cSrcweir 						pFly->RefreshExtraData( rRect );
6363cdf0e10cSrcweir 				}
6364cdf0e10cSrcweir 		}
6365cdf0e10cSrcweir 		pCnt = pCnt->GetNextCntntFrm();
6366cdf0e10cSrcweir 	}
6367cdf0e10cSrcweir }
6368cdf0e10cSrcweir 
6369cdf0e10cSrcweir /** SwPageFrm::GetDrawBackgrdColor - for #102450#
6370cdf0e10cSrcweir 
6371cdf0e10cSrcweir     determine the color, that is respectively will be drawn as background
6372cdf0e10cSrcweir     for the page frame.
6373cdf0e10cSrcweir     Using existing method SwFrm::GetBackgroundBrush to determine the color
6374cdf0e10cSrcweir     that is set at the page frame respectively is parent. If none is found
6375cdf0e10cSrcweir     return the global retouche color
6376cdf0e10cSrcweir 
6377cdf0e10cSrcweir     @author OD
6378cdf0e10cSrcweir 
6379cdf0e10cSrcweir     @return Color
6380cdf0e10cSrcweir */
GetDrawBackgrdColor() const6381cdf0e10cSrcweir const Color& SwPageFrm::GetDrawBackgrdColor() const
6382cdf0e10cSrcweir {
6383cdf0e10cSrcweir     const SvxBrushItem* pBrushItem;
6384cdf0e10cSrcweir     const Color* pDummyColor;
6385cdf0e10cSrcweir     SwRect aDummyRect;
6386ca28ca1fSArmin Le Grand 
6387cdf0e10cSrcweir     if ( GetBackgroundBrush( pBrushItem, pDummyColor, aDummyRect, true) )
6388ca28ca1fSArmin Le Grand     {
6389ca28ca1fSArmin Le Grand         const Graphic* pGraphic = pBrushItem->GetGraphic();
6390ca28ca1fSArmin Le Grand 
6391ca28ca1fSArmin Le Grand         if(pGraphic)
6392ca28ca1fSArmin Le Grand         {
6393ca28ca1fSArmin Le Grand             // #29105# when a graphic is set, it may be possible to calculate a single
6394ca28ca1fSArmin Le Grand             // color which looks good in all places of the graphic. Since it is
6395ca28ca1fSArmin Le Grand             // planned to have text edit on the overlay one day and the fallback
6396ca28ca1fSArmin Le Grand             // to aGlobalRetoucheColor returns something useful, just use that
6397ca28ca1fSArmin Le Grand             // for now.
6398ca28ca1fSArmin Le Grand         }
6399ca28ca1fSArmin Le Grand         else
6400ca28ca1fSArmin Le Grand         {
6401ca28ca1fSArmin Le Grand             // not a graphic, use (hopefully) initialized color
6402ca28ca1fSArmin Le Grand             return pBrushItem->GetColor();
6403ca28ca1fSArmin Le Grand         }
6404ca28ca1fSArmin Le Grand     }
6405ca28ca1fSArmin Le Grand 
6406ca28ca1fSArmin Le Grand     return aGlobalRetoucheColor;
6407cdf0e10cSrcweir }
6408cdf0e10cSrcweir 
6409cdf0e10cSrcweir /*************************************************************************
6410cdf0e10cSrcweir |*
6411cdf0e10cSrcweir |*    SwPageFrm::GetEmptyPageFont()
6412cdf0e10cSrcweir |*
6413cdf0e10cSrcweir |*    create/return font used to paint the "empty page" string
6414cdf0e10cSrcweir |*
6415cdf0e10cSrcweir |*************************************************************************/
6416cdf0e10cSrcweir 
GetEmptyPageFont()6417cdf0e10cSrcweir const Font& SwPageFrm::GetEmptyPageFont()
6418cdf0e10cSrcweir {
6419cdf0e10cSrcweir     static Font* pEmptyPgFont = 0;
6420cdf0e10cSrcweir     if ( 0 == pEmptyPgFont )
6421cdf0e10cSrcweir     {
6422cdf0e10cSrcweir         pEmptyPgFont = new Font;
6423cdf0e10cSrcweir         pEmptyPgFont->SetSize( Size( 0, 80 * 20 )); // == 80 pt
6424cdf0e10cSrcweir         pEmptyPgFont->SetWeight( WEIGHT_BOLD );
6425cdf0e10cSrcweir         pEmptyPgFont->SetStyleName( aEmptyStr );
6426cdf0e10cSrcweir         pEmptyPgFont->SetName( String::CreateFromAscii(
6427cdf0e10cSrcweir                 RTL_CONSTASCII_STRINGPARAM( "Helvetica" )) );
6428cdf0e10cSrcweir         pEmptyPgFont->SetFamily( FAMILY_SWISS );
6429cdf0e10cSrcweir         pEmptyPgFont->SetTransparent( sal_True );
6430cdf0e10cSrcweir         pEmptyPgFont->SetColor( COL_GRAY );
6431cdf0e10cSrcweir     }
6432cdf0e10cSrcweir 
6433cdf0e10cSrcweir     return *pEmptyPgFont;
6434cdf0e10cSrcweir }
6435cdf0e10cSrcweir 
6436cdf0e10cSrcweir /*************************************************************************
6437cdf0e10cSrcweir |*
6438cdf0e10cSrcweir |*	  SwFrm::Retouche
6439cdf0e10cSrcweir |*
6440cdf0e10cSrcweir |*	  Beschreibung		Retouche fuer einen Bereich.
6441cdf0e10cSrcweir |*		Retouche wird nur dann durchgefuehrt, wenn der Frm der letzte seiner
6442cdf0e10cSrcweir |* 		Kette ist. Der Gesamte Bereich des Upper unterhalb des Frm wird
6443cdf0e10cSrcweir |* 		per PaintBackground gecleared.
6444cdf0e10cSrcweir |*	  Ersterstellung	MA 13. Apr. 93
6445cdf0e10cSrcweir |*	  Letzte Aenderung	MA 25. Jul. 96
6446cdf0e10cSrcweir |*
6447cdf0e10cSrcweir |*************************************************************************/
6448cdf0e10cSrcweir 
Retouche(const SwPageFrm * pPage,const SwRect & rRect) const6449cdf0e10cSrcweir void SwFrm::Retouche( const SwPageFrm * pPage, const SwRect &rRect ) const
6450cdf0e10cSrcweir {
6451cdf0e10cSrcweir 	if ( bFlyMetafile )
6452cdf0e10cSrcweir 		return;
6453cdf0e10cSrcweir 
6454cdf0e10cSrcweir 	ASSERT( GetUpper(), "Retoucheversuch ohne Upper." );
6455cdf0e10cSrcweir 	ASSERT( getRootFrm()->GetCurrShell() && pGlobalShell->GetWin(), "Retouche auf dem Drucker?" );
6456cdf0e10cSrcweir 
6457cdf0e10cSrcweir 	SwRect aRetouche( GetUpper()->PaintArea() );
6458cdf0e10cSrcweir 	aRetouche.Top( Frm().Top() + Frm().Height() );
6459cdf0e10cSrcweir 	aRetouche.Intersection( pGlobalShell->VisArea() );
6460cdf0e10cSrcweir 
6461cdf0e10cSrcweir 	if ( aRetouche.HasArea() )
6462cdf0e10cSrcweir 	{
6463cdf0e10cSrcweir         //Uebergebenes Rect ausparen. Dafuer brauchen wir leider eine Region
6464cdf0e10cSrcweir 		//zum ausstanzen.
6465cdf0e10cSrcweir 		SwRegionRects aRegion( aRetouche );
6466cdf0e10cSrcweir 		aRegion -= rRect;
6467cdf0e10cSrcweir 		ViewShell *pSh = getRootFrm()->GetCurrShell();
6468cdf0e10cSrcweir 
6469cdf0e10cSrcweir         // --> FME 2004-06-24 #i16816# tagged pdf support
6470cdf0e10cSrcweir         SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pSh->GetOut() );
6471cdf0e10cSrcweir         // <--
6472cdf0e10cSrcweir 
6473cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < aRegion.Count(); ++i )
6474cdf0e10cSrcweir 		{
6475cdf0e10cSrcweir 			SwRect &rRetouche = aRegion[i];
6476cdf0e10cSrcweir 
6477cdf0e10cSrcweir 			GetUpper()->PaintBaBo( rRetouche, pPage, sal_True );
6478cdf0e10cSrcweir 
6479cdf0e10cSrcweir 			//Hoelle und Himmel muessen auch refreshed werden.
6480cdf0e10cSrcweir 			//Um Rekursionen zu vermeiden muss mein Retouche Flag zuerst
6481cdf0e10cSrcweir 			//zurueckgesetzt werden!
6482cdf0e10cSrcweir 			ResetRetouche();
6483cdf0e10cSrcweir             SwRect aRetouchePart( rRetouche );
6484cdf0e10cSrcweir             if ( aRetouchePart.HasArea() )
6485cdf0e10cSrcweir             {
6486cdf0e10cSrcweir                 const Color aPageBackgrdColor = pPage->GetDrawBackgrdColor();
6487cdf0e10cSrcweir                 const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess();
6488cdf0e10cSrcweir                 // --> OD #i76669#
6489cdf0e10cSrcweir                 SwViewObjectContactRedirector aSwRedirector( *pSh );
6490cdf0e10cSrcweir                 // <--
6491cdf0e10cSrcweir 
6492cdf0e10cSrcweir                 pSh->Imp()->PaintLayer( pIDDMA->GetHellId(), 0,
6493cdf0e10cSrcweir                                         aRetouchePart, &aPageBackgrdColor,
6494cdf0e10cSrcweir                                         (pPage->IsRightToLeft() ? true : false),
6495cdf0e10cSrcweir                                         &aSwRedirector );
6496cdf0e10cSrcweir                 pSh->Imp()->PaintLayer( pIDDMA->GetHeavenId(), 0,
6497cdf0e10cSrcweir                                         aRetouchePart, &aPageBackgrdColor,
6498cdf0e10cSrcweir                                         (pPage->IsRightToLeft() ? true : false),
6499cdf0e10cSrcweir                                         &aSwRedirector );
6500cdf0e10cSrcweir             }
6501cdf0e10cSrcweir 
6502cdf0e10cSrcweir 			SetRetouche();
6503cdf0e10cSrcweir 
6504cdf0e10cSrcweir 			//Da wir uns ausserhalb aller Paint-Bereiche begeben muessen hier
6505cdf0e10cSrcweir 			//leider die Hilfslinien erneuert werden.
6506cdf0e10cSrcweir             pPage->RefreshSubsidiary( aRetouchePart );
6507cdf0e10cSrcweir 		}
6508cdf0e10cSrcweir 	}
6509cdf0e10cSrcweir 	if ( ViewShell::IsLstEndAction() )
6510cdf0e10cSrcweir 		ResetRetouche();
6511cdf0e10cSrcweir }
6512cdf0e10cSrcweir 
6513cdf0e10cSrcweir /** SwFrm::GetBackgroundBrush
6514cdf0e10cSrcweir 
6515cdf0e10cSrcweir     @descr
6516cdf0e10cSrcweir     determine the background brush for the frame:
6517cdf0e10cSrcweir     the background brush is taken from it-self or from its parent (anchor/upper).
6518cdf0e10cSrcweir     Normally, the background brush is taken, which has no transparent color or
6519cdf0e10cSrcweir     which has a background graphic. But there are some special cases:
6520cdf0e10cSrcweir     (1) No background brush is taken from a page frame, if view option "IsPageBack"
6521cdf0e10cSrcweir         isn't set.
6522cdf0e10cSrcweir     (2) Background brush from a index section is taken under special conditions.
6523cdf0e10cSrcweir         In this case parameter <rpCol> is set to the index shading color.
6524cdf0e10cSrcweir     (3) New (OD 20.08.2002) - Background brush is taken, if on background drawing
6525cdf0e10cSrcweir         of the frame transparency is considered and its color is not "no fill"/"auto fill"
6526cdf0e10cSrcweir     ---- old description in german:
6527cdf0e10cSrcweir     Beschreibung        Liefert die Backgroundbrush fuer den Bereich des
6528cdf0e10cSrcweir         des Frm. Die Brush wird entweder von ihm selbst oder von einem
6529cdf0e10cSrcweir         Upper vorgegeben, die erste Brush wird benutzt.
6530cdf0e10cSrcweir         Ist fuer keinen Frm eine Brush angegeben, so wird sal_False zurueck-
6531cdf0e10cSrcweir         geliefert.
6532cdf0e10cSrcweir     Ersterstellung      MA 23. Dec. 92
6533cdf0e10cSrcweir     Letzte Aenderung    MA 04. Feb. 97
6534cdf0e10cSrcweir 
6535cdf0e10cSrcweir     @param rpBrush
6536cdf0e10cSrcweir     output parameter - constant reference pointer the found background brush
6537cdf0e10cSrcweir 
6538cdf0e10cSrcweir     @param rpCol
6539cdf0e10cSrcweir     output parameter - constant reference pointer to the color of the index shading
6540cdf0e10cSrcweir     set under special conditions, if background brush is taken from an index section.
6541cdf0e10cSrcweir 
6542cdf0e10cSrcweir     @param rOrigRect
6543cdf0e10cSrcweir     in-/output parameter - reference to the retangle the background brush is
6544cdf0e10cSrcweir     considered for - adjusted to the frame, from which the background brush is
6545cdf0e10cSrcweir     taken.
6546cdf0e10cSrcweir 
6547cdf0e10cSrcweir     @parem bLowerMode
6548cdf0e10cSrcweir     input parameter - boolean indicating, if background brush should *not* be
6549cdf0e10cSrcweir     taken from parent.
6550cdf0e10cSrcweir 
6551cdf0e10cSrcweir     @author MA
6552cdf0e10cSrcweir     @change 20.08.2002 by OD
6553cdf0e10cSrcweir     @docdate 20.08.2002
6554cdf0e10cSrcweir 
6555cdf0e10cSrcweir     @return true, if a background brush for the frame is found
6556cdf0e10cSrcweir */
GetBackgroundBrush(const SvxBrushItem * & rpBrush,const Color * & rpCol,SwRect & rOrigRect,sal_Bool bLowerMode) const6557cdf0e10cSrcweir sal_Bool SwFrm::GetBackgroundBrush( const SvxBrushItem* & rpBrush,
6558cdf0e10cSrcweir 								const Color*& rpCol,
6559cdf0e10cSrcweir 								SwRect &rOrigRect,
6560cdf0e10cSrcweir 								sal_Bool bLowerMode ) const
6561cdf0e10cSrcweir {
6562cdf0e10cSrcweir 	const SwFrm *pFrm = this;
6563cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
6564cdf0e10cSrcweir 	const SwViewOption *pOpt = pSh->GetViewOptions();
6565cdf0e10cSrcweir 	rpBrush = 0;
6566cdf0e10cSrcweir 	rpCol = NULL;
6567cdf0e10cSrcweir 	do
6568cdf0e10cSrcweir 	{	if ( pFrm->IsPageFrm() && !pOpt->IsPageBack() )
6569cdf0e10cSrcweir 			return sal_False;
6570cdf0e10cSrcweir 
6571cdf0e10cSrcweir 		const SvxBrushItem &rBack = pFrm->GetAttrSet()->GetBackground();
6572cdf0e10cSrcweir 		if( pFrm->IsSctFrm() )
6573cdf0e10cSrcweir 		{
6574cdf0e10cSrcweir 			const SwSection* pSection = ((SwSectionFrm*)pFrm)->GetSection();
6575cdf0e10cSrcweir             /// OD 20.08.2002 #99657# #GetTransChg#
6576cdf0e10cSrcweir             ///     Note: If frame <pFrm> is a section of the index and
6577cdf0e10cSrcweir             ///         it its background color is "no fill"/"auto fill" and
6578cdf0e10cSrcweir             ///         it has no background graphic and
6579cdf0e10cSrcweir             ///         we are not in the page preview and
6580cdf0e10cSrcweir             ///         we are not in read-only mode and
6581cdf0e10cSrcweir             ///         option "index shadings" is set and
6582cdf0e10cSrcweir             ///         the output is not the printer
6583cdf0e10cSrcweir             ///         then set <rpCol> to the color of the index shading
6584cdf0e10cSrcweir             if( pSection && (   TOX_HEADER_SECTION == pSection->GetType() ||
6585cdf0e10cSrcweir                                 TOX_CONTENT_SECTION == pSection->GetType() ) &&
6586cdf0e10cSrcweir                 (rBack.GetColor() == COL_TRANSPARENT) &&
6587cdf0e10cSrcweir                 ///rBack.GetColor().GetTransparency() &&
6588cdf0e10cSrcweir                 rBack.GetGraphicPos() == GPOS_NONE &&
6589cdf0e10cSrcweir                 !pOpt->IsPagePreview() &&
6590cdf0e10cSrcweir                 !pOpt->IsReadonly() &&
6591cdf0e10cSrcweir                 // --> FME 2004-06-29 #114856# Formular view
6592cdf0e10cSrcweir                 !pOpt->IsFormView() &&
6593cdf0e10cSrcweir                 // <--
6594cdf0e10cSrcweir                 SwViewOption::IsIndexShadings() &&
6595cdf0e10cSrcweir                 !pOpt->IsPDFExport() &&
6596cdf0e10cSrcweir                 pSh->GetOut()->GetOutDevType() != OUTDEV_PRINTER )
6597cdf0e10cSrcweir             {
6598cdf0e10cSrcweir                 rpCol = &SwViewOption::GetIndexShadingsColor();
6599cdf0e10cSrcweir             }
6600cdf0e10cSrcweir         }
6601cdf0e10cSrcweir 
6602cdf0e10cSrcweir         /// OD 20.08.2002 #99657#
6603cdf0e10cSrcweir         ///     determine, if background draw of frame <pFrm> considers transparency
6604cdf0e10cSrcweir         ///     --> Status Quo: background transparency have to be
6605cdf0e10cSrcweir         ///                     considered for fly frames
6606cdf0e10cSrcweir         const sal_Bool bConsiderBackgroundTransparency = pFrm->IsFlyFrm();
6607cdf0e10cSrcweir         /// OD 20.08.2002 #99657#
6608cdf0e10cSrcweir         ///     add condition:
6609cdf0e10cSrcweir         ///     If <bConsiderBackgroundTransparency> is set - see above -,
6610cdf0e10cSrcweir         ///     return brush of frame <pFrm>, if its color is *not* "no fill"/"auto fill"
6611cdf0e10cSrcweir         if ( !rBack.GetColor().GetTransparency() ||
6612cdf0e10cSrcweir              rBack.GetGraphicPos() != GPOS_NONE ||
6613cdf0e10cSrcweir              rpCol ||
6614cdf0e10cSrcweir              (bConsiderBackgroundTransparency && (rBack.GetColor() != COL_TRANSPARENT))
6615cdf0e10cSrcweir            )
6616cdf0e10cSrcweir 		{
6617cdf0e10cSrcweir 			rpBrush = &rBack;
6618cdf0e10cSrcweir             if ( pFrm->IsPageFrm() &&
6619cdf0e10cSrcweir                  pSh->GetViewOptions()->getBrowseMode() )
6620cdf0e10cSrcweir 				rOrigRect = pFrm->Frm();
6621cdf0e10cSrcweir 			else
6622cdf0e10cSrcweir 			{
6623cdf0e10cSrcweir 				if ( pFrm->Frm().SSize() != pFrm->Prt().SSize() )
6624cdf0e10cSrcweir 				{
6625cdf0e10cSrcweir 					SwBorderAttrAccess aAccess( SwFrm::GetCache(), pFrm );
6626cdf0e10cSrcweir 					const SwBorderAttrs &rAttrs = *aAccess.Get();
6627cdf0e10cSrcweir 					::lcl_CalcBorderRect( rOrigRect, pFrm, rAttrs, sal_False );
6628cdf0e10cSrcweir 				}
6629cdf0e10cSrcweir 				else
6630cdf0e10cSrcweir 				{
6631cdf0e10cSrcweir 					rOrigRect = pFrm->Prt();
6632cdf0e10cSrcweir 					rOrigRect += pFrm->Frm().Pos();
6633cdf0e10cSrcweir 				}
6634cdf0e10cSrcweir 			}
6635cdf0e10cSrcweir 			return sal_True;
6636cdf0e10cSrcweir 		}
6637cdf0e10cSrcweir 
6638cdf0e10cSrcweir         if ( bLowerMode )
6639cdf0e10cSrcweir             /// Do not try to get background brush from parent (anchor/upper)
6640cdf0e10cSrcweir 			return sal_False;
6641cdf0e10cSrcweir 
6642cdf0e10cSrcweir         /// get parent frame - anchor or upper - for next loop
6643cdf0e10cSrcweir 		if ( pFrm->IsFlyFrm() )
6644cdf0e10cSrcweir             /// OD 20.08.2002 - use "static_cast" instead of "old C-cast"
6645cdf0e10cSrcweir             pFrm = (static_cast<const SwFlyFrm*>(pFrm))->GetAnchorFrm();
6646cdf0e10cSrcweir             ///pFrm = ((SwFlyFrm*)pFrm)->GetAnchor();
6647cdf0e10cSrcweir 		else
6648cdf0e10cSrcweir 			pFrm = pFrm->GetUpper();
6649cdf0e10cSrcweir 
6650cdf0e10cSrcweir 	} while ( pFrm );
6651cdf0e10cSrcweir 
6652cdf0e10cSrcweir     return sal_False;
6653cdf0e10cSrcweir }
6654cdf0e10cSrcweir 
6655cdf0e10cSrcweir /*************************************************************************
6656cdf0e10cSrcweir |*
6657cdf0e10cSrcweir |*	SwFrmFmt::GetGraphic()
6658cdf0e10cSrcweir |*
6659cdf0e10cSrcweir |*	Ersterstellung		MA 23. Jul. 96
6660cdf0e10cSrcweir |*	Letzte Aenderung	MA 23. Jul. 96
6661cdf0e10cSrcweir |*
6662cdf0e10cSrcweir |*************************************************************************/
6663cdf0e10cSrcweir 
SetOutDevAndWin(ViewShell * pSh,OutputDevice * pO,Window * pW,sal_uInt16 nZoom)6664cdf0e10cSrcweir void SetOutDevAndWin( ViewShell *pSh, OutputDevice *pO,
6665cdf0e10cSrcweir 					  Window *pW, sal_uInt16 nZoom )
6666cdf0e10cSrcweir {
6667cdf0e10cSrcweir 	pSh->pOut = pO;
6668cdf0e10cSrcweir 	pSh->pWin = pW;
6669cdf0e10cSrcweir 	pSh->pOpt->SetZoom( nZoom );
6670cdf0e10cSrcweir }
6671cdf0e10cSrcweir 
MakeGraphic(ImageMap *)6672cdf0e10cSrcweir Graphic SwFrmFmt::MakeGraphic( ImageMap* )
6673cdf0e10cSrcweir {
6674cdf0e10cSrcweir 	return Graphic();
6675cdf0e10cSrcweir }
6676cdf0e10cSrcweir 
MakeGraphic(ImageMap * pMap)6677cdf0e10cSrcweir Graphic SwFlyFrmFmt::MakeGraphic( ImageMap* pMap )
6678cdf0e10cSrcweir {
6679cdf0e10cSrcweir 	Graphic aRet;
6680cdf0e10cSrcweir 	//irgendeinen Fly suchen!
6681cdf0e10cSrcweir 	SwIterator<SwFrm,SwFmt> aIter( *this );
6682cdf0e10cSrcweir     SwFrm *pFirst = aIter.First();
6683cdf0e10cSrcweir 	ViewShell *pSh;
6684cdf0e10cSrcweir     if ( pFirst && 0 != ( pSh = pFirst->getRootFrm()->GetCurrShell()) )
6685cdf0e10cSrcweir 	{
6686cdf0e10cSrcweir 		ViewShell *pOldGlobal = pGlobalShell;
6687cdf0e10cSrcweir 		pGlobalShell = pSh;
6688cdf0e10cSrcweir 
6689cdf0e10cSrcweir 		sal_Bool bNoteURL = pMap &&
6690cdf0e10cSrcweir 			SFX_ITEM_SET != GetAttrSet().GetItemState( RES_URL, sal_True );
6691cdf0e10cSrcweir 		if( bNoteURL )
6692cdf0e10cSrcweir 		{
6693cdf0e10cSrcweir 			ASSERT( !pNoteURL, "MakeGraphic: pNoteURL already used? " );
6694cdf0e10cSrcweir 			pNoteURL = new SwNoteURL;
6695cdf0e10cSrcweir 		}
6696cdf0e10cSrcweir 		SwFlyFrm *pFly = (SwFlyFrm*)pFirst;
6697cdf0e10cSrcweir 
6698cdf0e10cSrcweir 		OutputDevice *pOld = pSh->GetOut();
6699cdf0e10cSrcweir 		VirtualDevice aDev( *pOld );
6700cdf0e10cSrcweir 		aDev.EnableOutput( sal_False );
6701cdf0e10cSrcweir 
6702cdf0e10cSrcweir 		GDIMetaFile aMet;
6703cdf0e10cSrcweir 		MapMode aMap( pOld->GetMapMode().GetMapUnit() );
6704cdf0e10cSrcweir 		aDev.SetMapMode( aMap );
6705cdf0e10cSrcweir 		aMet.SetPrefMapMode( aMap );
6706cdf0e10cSrcweir 
6707cdf0e10cSrcweir 		::SwCalcPixStatics( pSh->GetOut() );
6708cdf0e10cSrcweir 		aMet.SetPrefSize( pFly->Frm().SSize() );
6709cdf0e10cSrcweir 
6710cdf0e10cSrcweir 		aMet.Record( &aDev );
6711cdf0e10cSrcweir 		aDev.SetLineColor();
6712cdf0e10cSrcweir 		aDev.SetFillColor();
6713cdf0e10cSrcweir 		aDev.SetFont( pOld->GetFont() );
6714cdf0e10cSrcweir 
6715089ea224Smseidel 		//Rechteck ggf. ausdehnen, damit die Umrandungen mit aufgezeichnet werden.
6716cdf0e10cSrcweir 		SwRect aOut( pFly->Frm() );
6717cdf0e10cSrcweir 		SwBorderAttrAccess aAccess( SwFrm::GetCache(), pFly );
6718cdf0e10cSrcweir 		const SwBorderAttrs &rAttrs = *aAccess.Get();
6719cdf0e10cSrcweir 		if ( rAttrs.CalcRightLine() )
6720cdf0e10cSrcweir 			aOut.SSize().Width() += 2*nPixelSzW;
6721cdf0e10cSrcweir 		if ( rAttrs.CalcBottomLine() )
6722cdf0e10cSrcweir 			aOut.SSize().Height()+= 2*nPixelSzH;
6723cdf0e10cSrcweir 
6724cdf0e10cSrcweir 		// #i92711# start Pre/PostPaint encapsulation before pOut is changed to the buffering VDev
6725cdf0e10cSrcweir 		const Region aRepaintRegion(aOut.SVRect());
6726cdf0e10cSrcweir     	pSh->DLPrePaint2(aRepaintRegion);
6727cdf0e10cSrcweir 
6728cdf0e10cSrcweir         Window *pWin = pSh->GetWin();
6729cdf0e10cSrcweir 		sal_uInt16 nZoom = pSh->GetViewOptions()->GetZoom();
6730cdf0e10cSrcweir 		::SetOutDevAndWin( pSh, &aDev, 0, 100 );
6731cdf0e10cSrcweir 		bFlyMetafile = sal_True;
6732cdf0e10cSrcweir 		pFlyMetafileOut = pWin;
6733cdf0e10cSrcweir 
6734cdf0e10cSrcweir 		SwViewImp *pImp = pSh->Imp();
6735cdf0e10cSrcweir 		pFlyOnlyDraw = pFly;
6736cdf0e10cSrcweir 		pLines = new SwLineRects;
6737cdf0e10cSrcweir 
6738cdf0e10cSrcweir         // OD 09.12.2002 #103045# - determine page, fly frame is on
6739cdf0e10cSrcweir         const SwPageFrm* pFlyPage = pFly->FindPageFrm();
6740cdf0e10cSrcweir         const Color aPageBackgrdColor = pFlyPage->GetDrawBackgrdColor();
6741cdf0e10cSrcweir         const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess();
6742cdf0e10cSrcweir         // --> OD #i76669#
6743cdf0e10cSrcweir         SwViewObjectContactRedirector aSwRedirector( *pSh );
6744cdf0e10cSrcweir         // <--
6745cdf0e10cSrcweir         pImp->PaintLayer( pIDDMA->GetHellId(), 0, aOut, &aPageBackgrdColor,
6746cdf0e10cSrcweir                           (pFlyPage->IsRightToLeft() ? true : false),
6747cdf0e10cSrcweir                           &aSwRedirector );
6748cdf0e10cSrcweir 		pLines->PaintLines( &aDev );
6749cdf0e10cSrcweir 		if ( pFly->IsFlyInCntFrm() )
6750cdf0e10cSrcweir 			pFly->Paint( aOut );
6751cdf0e10cSrcweir 		pLines->PaintLines( &aDev );
6752cdf0e10cSrcweir         /// OD 30.08.2002 #102450# - add 3rd parameter
6753cdf0e10cSrcweir         pImp->PaintLayer( pIDDMA->GetHeavenId(), 0, aOut, &aPageBackgrdColor,
6754cdf0e10cSrcweir                           (pFlyPage->IsRightToLeft() ? true : false),
6755cdf0e10cSrcweir                           &aSwRedirector );
6756cdf0e10cSrcweir 		pLines->PaintLines( &aDev );
6757cdf0e10cSrcweir 		DELETEZ( pLines );
6758cdf0e10cSrcweir 		pFlyOnlyDraw = 0;
6759cdf0e10cSrcweir 
6760cdf0e10cSrcweir 		pFlyMetafileOut = 0;
6761cdf0e10cSrcweir 		bFlyMetafile = sal_False;
6762cdf0e10cSrcweir 		::SetOutDevAndWin( pSh, pOld, pWin, nZoom );
6763cdf0e10cSrcweir 
6764cdf0e10cSrcweir 		// #i92711# end Pre/PostPaint encapsulation when pOut is back and content is painted
6765cdf0e10cSrcweir    		pSh->DLPostPaint2(true);
6766cdf0e10cSrcweir 
6767cdf0e10cSrcweir         aMet.Stop();
6768cdf0e10cSrcweir 		aMet.Move( -pFly->Frm().Left(), -pFly->Frm().Top() );
6769cdf0e10cSrcweir 		aRet = Graphic( aMet );
6770cdf0e10cSrcweir 
6771cdf0e10cSrcweir 		if( bNoteURL )
6772cdf0e10cSrcweir 		{
6773cdf0e10cSrcweir 			ASSERT( pNoteURL, "MakeGraphic: Good Bye, NoteURL." );
6774cdf0e10cSrcweir 			pNoteURL->FillImageMap( pMap, pFly->Frm().Pos(), aMap );
6775cdf0e10cSrcweir 			delete pNoteURL;
6776cdf0e10cSrcweir 			pNoteURL = NULL;
6777cdf0e10cSrcweir 		}
6778cdf0e10cSrcweir 		pGlobalShell = pOldGlobal;
6779cdf0e10cSrcweir 	}
6780cdf0e10cSrcweir 	return aRet;
6781cdf0e10cSrcweir }
6782cdf0e10cSrcweir 
MakeGraphic(ImageMap *)6783cdf0e10cSrcweir Graphic SwDrawFrmFmt::MakeGraphic( ImageMap* )
6784cdf0e10cSrcweir {
6785cdf0e10cSrcweir 	Graphic aRet;
6786cdf0e10cSrcweir     SdrModel *pMod = getIDocumentDrawModelAccess()->GetDrawModel();
6787cdf0e10cSrcweir 	if ( pMod )
6788cdf0e10cSrcweir 	{
6789cdf0e10cSrcweir 		SdrObject *pObj = FindSdrObject();
6790cdf0e10cSrcweir 		SdrView *pView = new SdrView( pMod );
6791cdf0e10cSrcweir 		SdrPageView *pPgView = pView->ShowSdrPage(pView->GetModel()->GetPage(0));
6792cdf0e10cSrcweir 		pView->MarkObj( pObj, pPgView );
6793bb18ee55SArmin Le Grand 		aRet = pView->GetMarkedObjBitmapEx();
6794cdf0e10cSrcweir 		pView->HideSdrPage();
6795cdf0e10cSrcweir 		delete pView;
6796cdf0e10cSrcweir 	}
6797cdf0e10cSrcweir 	return aRet;
6798cdf0e10cSrcweir }
6799120ba445Smseidel 
6800