1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "dcontact.hxx" // SwDrawContact
29cdf0e10cSrcweir #include "dflyobj.hxx" // SwVirtFlyDrawObj
30cdf0e10cSrcweir #include "pam.hxx" // SwPosition
31cdf0e10cSrcweir #include "flyfrm.hxx" // SwFlyInCntFrm
32cdf0e10cSrcweir #include "rootfrm.hxx"
33cdf0e10cSrcweir #include "frmfmt.hxx" // SwFrmFmt
34cdf0e10cSrcweir #include "viewsh.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <vcl/outdev.hxx>
37cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
38cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
39cdf0e10cSrcweir #include <fmtanchr.hxx>
40cdf0e10cSrcweir #include <fmtflcnt.hxx>
41cdf0e10cSrcweir #include <fmtornt.hxx>
42cdf0e10cSrcweir #include <frmatr.hxx>
43cdf0e10cSrcweir #include "flyfrms.hxx"
44cdf0e10cSrcweir #include "txatbase.hxx" // SwTxtAttr
45cdf0e10cSrcweir #include "porfly.hxx"
46cdf0e10cSrcweir #include "porlay.hxx" // SetFly
47cdf0e10cSrcweir #include "inftxt.hxx" // SwTxtPaintInfo
48cdf0e10cSrcweir
49cdf0e10cSrcweir // OD 2004-05-24 #i28701#
50cdf0e10cSrcweir #include <sortedobjs.hxx>
51cdf0e10cSrcweir
52cdf0e10cSrcweir
53cdf0e10cSrcweir /*************************************************************************
54cdf0e10cSrcweir * class SwFlyPortion
55cdf0e10cSrcweir *
56cdf0e10cSrcweir * Wir erwarten ein framelokales SwRect !
57cdf0e10cSrcweir *************************************************************************/
58cdf0e10cSrcweir
Paint(const SwTxtPaintInfo &) const59cdf0e10cSrcweir void SwFlyPortion::Paint( const SwTxtPaintInfo& ) const
60cdf0e10cSrcweir {
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
63cdf0e10cSrcweir /*************************************************************************
64cdf0e10cSrcweir * virtual SwFlyPortion::Format()
65cdf0e10cSrcweir *************************************************************************/
Format(SwTxtFormatInfo & rInf)66cdf0e10cSrcweir sal_Bool SwFlyPortion::Format( SwTxtFormatInfo &rInf )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir ASSERT( Fix() >= rInf.X(), "SwFlyPortion::Format: rush hour" );
69cdf0e10cSrcweir // 8537: Tabs muessen expandiert werden.
70cdf0e10cSrcweir if( rInf.GetLastTab() )
71cdf0e10cSrcweir ((SwLinePortion*)rInf.GetLastTab())->FormatEOL( rInf );
72cdf0e10cSrcweir
73cdf0e10cSrcweir // Der Glue wird aufgespannt.
74cdf0e10cSrcweir rInf.GetLast()->FormatEOL( rInf );
75cdf0e10cSrcweir PrtWidth( static_cast<sal_uInt16>(Fix() - rInf.X() + PrtWidth()) );
76cdf0e10cSrcweir if( !Width() )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir ASSERT( Width(), "+SwFlyPortion::Format: a fly is a fly is a fly" );
79cdf0e10cSrcweir Width(1);
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir // Restaurierung
83cdf0e10cSrcweir rInf.SetFly( 0 );
84cdf0e10cSrcweir rInf.Width( rInf.RealWidth() );
85cdf0e10cSrcweir rInf.GetParaPortion()->SetFly( sal_True );
86cdf0e10cSrcweir
87cdf0e10cSrcweir // trailing blank:
88cdf0e10cSrcweir if( rInf.GetIdx() < rInf.GetTxt().Len() && 1 < rInf.GetIdx()
89cdf0e10cSrcweir && !rInf.GetRest()
90cdf0e10cSrcweir && ' ' == rInf.GetChar( rInf.GetIdx() )
91cdf0e10cSrcweir && ' ' != rInf.GetChar( rInf.GetIdx() - 1 )
92cdf0e10cSrcweir && ( !rInf.GetLast() || !rInf.GetLast()->IsBreakPortion() ) )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir SetBlankWidth( rInf.GetTxtSize( ' ' ).Width() );
95cdf0e10cSrcweir SetLen( 1 );
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir const sal_uInt16 nNewWidth = static_cast<sal_uInt16>(rInf.X() + PrtWidth());
99cdf0e10cSrcweir if( rInf.Width() <= nNewWidth )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir Truncate();
102cdf0e10cSrcweir if( nNewWidth > rInf.Width() )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir PrtWidth( nNewWidth - rInf.Width() );
105cdf0e10cSrcweir SetFixWidth( PrtWidth() );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir return sal_True;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir return sal_False;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
112cdf0e10cSrcweir /*************************************************************************
113cdf0e10cSrcweir * virtual SwFlyCntPortion::Format()
114cdf0e10cSrcweir *************************************************************************/
Format(SwTxtFormatInfo & rInf)115cdf0e10cSrcweir sal_Bool SwFlyCntPortion::Format( SwTxtFormatInfo &rInf )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir sal_Bool bFull = rInf.Width() < rInf.X() + PrtWidth();
118cdf0e10cSrcweir
119cdf0e10cSrcweir if( bFull )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir // 3924: wenn die Zeile voll ist und der zeichengebundene Frame am
122cdf0e10cSrcweir // Anfang der Zeile steht.
123cdf0e10cSrcweir // 5157: nicht wenn einem Fly ausgewichen werden kann!
124cdf0e10cSrcweir // "Begin of line" criteria ( ! rInf.X() ) has to be extended.
125cdf0e10cSrcweir // KerningPortions at beginning of line, e.g., for grid layout
126cdf0e10cSrcweir // must be considered.
127cdf0e10cSrcweir const SwLinePortion* pLastPor = rInf.GetLast();
128cdf0e10cSrcweir const sal_uInt16 nLeft = ( pLastPor &&
129cdf0e10cSrcweir ( pLastPor->IsKernPortion() ||
130cdf0e10cSrcweir pLastPor->IsErgoSumPortion() ) ) ?
131cdf0e10cSrcweir pLastPor->Width() :
132cdf0e10cSrcweir 0;
133cdf0e10cSrcweir
134cdf0e10cSrcweir if( nLeft == rInf.X() && ! rInf.GetFly() )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir Width( rInf.Width() );
137cdf0e10cSrcweir bFull = sal_False; // Damit Notizen noch in dieser Zeile landen
138cdf0e10cSrcweir }
139cdf0e10cSrcweir else
140cdf0e10cSrcweir {
141cdf0e10cSrcweir if( !rInf.GetFly() )
142cdf0e10cSrcweir rInf.SetNewLine( sal_True );
143cdf0e10cSrcweir Width(0);
144cdf0e10cSrcweir SetAscent(0);
145cdf0e10cSrcweir SetLen(0);
146cdf0e10cSrcweir if( rInf.GetLast() )
147cdf0e10cSrcweir rInf.GetLast()->FormatEOL( rInf );
148cdf0e10cSrcweir
149cdf0e10cSrcweir return bFull;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
153cdf0e10cSrcweir rInf.GetParaPortion()->SetFly( sal_True );
154cdf0e10cSrcweir return bFull;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
157cdf0e10cSrcweir /*************************************************************************
158cdf0e10cSrcweir * SwTxtFrm::MoveFlyInCnt() haengt jetzt die zeichengebundenen Objekte
159cdf0e10cSrcweir * innerhalb des angegebenen Bereichs um, damit koennen diese vom Master
160cdf0e10cSrcweir * zum Follow oder umgekehrt wandern.
161cdf0e10cSrcweir *************************************************************************/
MoveFlyInCnt(SwTxtFrm * pNew,xub_StrLen nStart,xub_StrLen nEnd)162cdf0e10cSrcweir void SwTxtFrm::MoveFlyInCnt( SwTxtFrm *pNew, xub_StrLen nStart, xub_StrLen nEnd )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir SwSortedObjs *pObjs = 0L;
165cdf0e10cSrcweir if ( 0 != (pObjs = GetDrawObjs()) )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir for ( sal_uInt32 i = 0; GetDrawObjs() && i < pObjs->Count(); ++i )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir // OD 2004-03-29 #i26791#
170cdf0e10cSrcweir // --> OD 2004-07-06 #i28701# - consider changed type of
171cdf0e10cSrcweir // <SwSortedList> entries
172cdf0e10cSrcweir SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
173cdf0e10cSrcweir const SwFmtAnchor& rAnch = pAnchoredObj->GetFrmFmt().GetAnchor();
174cdf0e10cSrcweir if (rAnch.GetAnchorId() == FLY_AS_CHAR)
175cdf0e10cSrcweir {
176cdf0e10cSrcweir const SwPosition* pPos = rAnch.GetCntntAnchor();
177cdf0e10cSrcweir xub_StrLen nIdx = pPos->nContent.GetIndex();
178cdf0e10cSrcweir if ( nIdx >= nStart && nEnd > nIdx )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir if ( pAnchoredObj->ISA(SwFlyFrm) )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir RemoveFly( static_cast<SwFlyFrm*>(pAnchoredObj) );
183cdf0e10cSrcweir pNew->AppendFly( static_cast<SwFlyFrm*>(pAnchoredObj) );
184cdf0e10cSrcweir }
185cdf0e10cSrcweir else if ( pAnchoredObj->ISA(SwAnchoredDrawObject) )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir RemoveDrawObj( *pAnchoredObj );
188cdf0e10cSrcweir pNew->AppendDrawObj( *pAnchoredObj );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir --i;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir }
193cdf0e10cSrcweir // <--
194cdf0e10cSrcweir }
195cdf0e10cSrcweir }
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir /*************************************************************************
199cdf0e10cSrcweir * SwTxtFrm::CalcFlyPos()
200cdf0e10cSrcweir *************************************************************************/
CalcFlyPos(SwFrmFmt * pSearch)201cdf0e10cSrcweir xub_StrLen SwTxtFrm::CalcFlyPos( SwFrmFmt* pSearch )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir SwpHints* pHints = GetTxtNode()->GetpSwpHints();
204cdf0e10cSrcweir ASSERT( pHints, "CalcFlyPos: Why me?" );
205cdf0e10cSrcweir if( !pHints )
206cdf0e10cSrcweir return STRING_LEN;
207cdf0e10cSrcweir SwTxtAttr* pFound = NULL;
208cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < pHints->Count(); i++)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir SwTxtAttr *pHt = pHints->GetTextHint( i );
211cdf0e10cSrcweir if( RES_TXTATR_FLYCNT == pHt->Which() )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir SwFrmFmt* pFrmFmt = pHt->GetFlyCnt().GetFrmFmt();
214cdf0e10cSrcweir if( pFrmFmt == pSearch )
215cdf0e10cSrcweir pFound = pHt;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir }
218cdf0e10cSrcweir ASSERT( pHints, "CalcFlyPos: Not Found!" );
219cdf0e10cSrcweir if( !pFound )
220cdf0e10cSrcweir return STRING_LEN;
221cdf0e10cSrcweir return *pFound->GetStart();
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
224cdf0e10cSrcweir /*************************************************************************
225cdf0e10cSrcweir * virtual SwFlyCntPortion::Paint()
226cdf0e10cSrcweir *************************************************************************/
Paint(const SwTxtPaintInfo & rInf) const227cdf0e10cSrcweir void SwFlyCntPortion::Paint( const SwTxtPaintInfo &rInf ) const
228cdf0e10cSrcweir {
229cdf0e10cSrcweir if( bDraw )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir if( !((SwDrawContact*)pContact)->GetAnchorFrm() )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir // OD 2004-04-01 #i26791# - no direct positioning of the drawing
234cdf0e10cSrcweir // object is needed.
235cdf0e10cSrcweir SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(pContact);
236cdf0e10cSrcweir pDrawContact->ConnectToLayout();
237cdf0e10cSrcweir }
238cdf0e10cSrcweir }
239cdf0e10cSrcweir else
240cdf0e10cSrcweir {
241cdf0e10cSrcweir // Baseline-Ausgabe !
242cdf0e10cSrcweir // 7922: Bei CompletePaint alles painten
243cdf0e10cSrcweir SwRect aRepaintRect( rInf.GetPaintRect() );
244cdf0e10cSrcweir
245cdf0e10cSrcweir if ( rInf.GetTxtFrm()->IsRightToLeft() )
246cdf0e10cSrcweir rInf.GetTxtFrm()->SwitchLTRtoRTL( aRepaintRect );
247cdf0e10cSrcweir
248cdf0e10cSrcweir if ( rInf.GetTxtFrm()->IsVertical() )
249cdf0e10cSrcweir rInf.GetTxtFrm()->SwitchHorizontalToVertical( aRepaintRect );
250cdf0e10cSrcweir
251cdf0e10cSrcweir if( (GetFlyFrm()->IsCompletePaint() ||
252cdf0e10cSrcweir GetFlyFrm()->Frm().IsOver( aRepaintRect )) &&
253cdf0e10cSrcweir SwFlyFrm::IsPaint( (SdrObject*)GetFlyFrm()->GetVirtDrawObj(),
254cdf0e10cSrcweir GetFlyFrm()->getRootFrm()->GetCurrShell() ))
255cdf0e10cSrcweir {
256cdf0e10cSrcweir SwRect aRect( GetFlyFrm()->Frm() );
257cdf0e10cSrcweir if( !GetFlyFrm()->IsCompletePaint() )
258cdf0e10cSrcweir aRect._Intersection( aRepaintRect );
259cdf0e10cSrcweir
260cdf0e10cSrcweir
261cdf0e10cSrcweir // GetFlyFrm() may change the layout mode at the output device.
262cdf0e10cSrcweir {
263cdf0e10cSrcweir SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() );
264cdf0e10cSrcweir GetFlyFrm()->Paint( aRect );
265cdf0e10cSrcweir }
266cdf0e10cSrcweir ((SwTxtPaintInfo&)rInf).GetRefDev()->SetLayoutMode(
267cdf0e10cSrcweir rInf.GetOut()->GetLayoutMode() );
268cdf0e10cSrcweir
269cdf0e10cSrcweir // Es hilft alles nichts, im zeichengebundenen Frame kann wer weiss
270cdf0e10cSrcweir // was am OutputDevice eingestellt sein, wir muessen unseren Font
271cdf0e10cSrcweir // wieder hineinselektieren. Dass wir im const stehen, soll uns
272cdf0e10cSrcweir // daran nicht hindern:
273cdf0e10cSrcweir ((SwTxtPaintInfo&)rInf).SelectFont();
274cdf0e10cSrcweir
275cdf0e10cSrcweir // I want to know if this can really happen. So here comes a new
276cdf0e10cSrcweir ASSERT( ! rInf.GetVsh() || rInf.GetVsh()->GetOut() == rInf.GetOut(),
277cdf0e10cSrcweir "SwFlyCntPortion::Paint: Outdev has changed" )
278cdf0e10cSrcweir if( rInf.GetVsh() )
279cdf0e10cSrcweir ((SwTxtPaintInfo&)rInf).SetOut( rInf.GetVsh()->GetOut() );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir }
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
284cdf0e10cSrcweir /*************************************************************************
285cdf0e10cSrcweir * SwFlyCntPortion::SwFlyCntPortion()
286cdf0e10cSrcweir *
287cdf0e10cSrcweir * Es werden die Masze vom pFly->OutRect() eingestellt.
288cdf0e10cSrcweir * Es erfolgt ein SetBase() !
289cdf0e10cSrcweir *************************************************************************/
290cdf0e10cSrcweir // OD 29.07.2003 #110978# - use new datatype for parameter <nFlags>
SwFlyCntPortion(const SwTxtFrm & rFrm,SwFlyInCntFrm * pFly,const Point & rBase,long nLnAscent,long nLnDescent,long nFlyAsc,long nFlyDesc,objectpositioning::AsCharFlags nFlags)291cdf0e10cSrcweir SwFlyCntPortion::SwFlyCntPortion( const SwTxtFrm& rFrm,
292cdf0e10cSrcweir SwFlyInCntFrm *pFly, const Point &rBase,
293cdf0e10cSrcweir long nLnAscent, long nLnDescent,
294cdf0e10cSrcweir long nFlyAsc, long nFlyDesc,
295cdf0e10cSrcweir objectpositioning::AsCharFlags nFlags ) :
296cdf0e10cSrcweir pContact( pFly ),
297cdf0e10cSrcweir bDraw( sal_False ),
298cdf0e10cSrcweir bMax( sal_False ),
299cdf0e10cSrcweir nAlign( 0 )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir ASSERT( pFly, "SwFlyCntPortion::SwFlyCntPortion: no SwFlyInCntFrm!" );
302cdf0e10cSrcweir nLineLength = 1;
303cdf0e10cSrcweir nFlags |= AS_CHAR_ULSPACE | AS_CHAR_INIT;
304cdf0e10cSrcweir SetBase( rFrm, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags );
305cdf0e10cSrcweir SetWhichPor( POR_FLYCNT );
306cdf0e10cSrcweir }
307cdf0e10cSrcweir
308cdf0e10cSrcweir // OD 29.07.2003 #110978# - use new datatype for parameter <nFlags>
SwFlyCntPortion(const SwTxtFrm & rFrm,SwDrawContact * pDrawContact,const Point & rBase,long nLnAscent,long nLnDescent,long nFlyAsc,long nFlyDesc,objectpositioning::AsCharFlags nFlags)309cdf0e10cSrcweir SwFlyCntPortion::SwFlyCntPortion( const SwTxtFrm& rFrm,
310cdf0e10cSrcweir SwDrawContact *pDrawContact, const Point &rBase,
311cdf0e10cSrcweir long nLnAscent, long nLnDescent,
312cdf0e10cSrcweir long nFlyAsc, long nFlyDesc,
313cdf0e10cSrcweir objectpositioning::AsCharFlags nFlags ) :
314cdf0e10cSrcweir pContact( pDrawContact ),
315cdf0e10cSrcweir bDraw( sal_True ),
316cdf0e10cSrcweir bMax( sal_False ),
317cdf0e10cSrcweir nAlign( 0 )
318cdf0e10cSrcweir {
319cdf0e10cSrcweir ASSERT( pDrawContact, "SwFlyCntPortion::SwFlyCntPortion: no SwDrawContact!" );
320cdf0e10cSrcweir if( !pDrawContact->GetAnchorFrm() )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir // OD 2004-04-01 #i26791# - no direct positioning needed any more
323cdf0e10cSrcweir pDrawContact->ConnectToLayout();
324cdf0e10cSrcweir // --> OD 2005-01-14 #i40333# - follow-up of #i35635#
325cdf0e10cSrcweir // move object to visible layer
326cdf0e10cSrcweir pDrawContact->MoveObjToVisibleLayer( pDrawContact->GetMaster() );
327cdf0e10cSrcweir // <--
328cdf0e10cSrcweir }
329cdf0e10cSrcweir nLineLength = 1;
330cdf0e10cSrcweir nFlags |= AS_CHAR_ULSPACE | AS_CHAR_INIT;
331cdf0e10cSrcweir
332cdf0e10cSrcweir SetBase( rFrm, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags );
333cdf0e10cSrcweir
334cdf0e10cSrcweir SetWhichPor( POR_FLYCNT );
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
337cdf0e10cSrcweir
338cdf0e10cSrcweir /*************************************************************************
339cdf0e10cSrcweir * SwFlyCntPortion::SetBase()
340cdf0e10cSrcweir *
341cdf0e10cSrcweir * Nach dem Setzen des RefPoints muss der Ascent neu berechnet werden,
342cdf0e10cSrcweir * da er von der RelPos abhaengt.
343cdf0e10cSrcweir * pFly->GetRelPos().Y() bezeichnet die relative Position zur Baseline.
344cdf0e10cSrcweir * Bei 0 liegt der obere Rand des FlyCnt auf der Baseline der Zeile.
345cdf0e10cSrcweir *************************************************************************/
346cdf0e10cSrcweir // OD 29.07.2003 #110978# - use new datatype for parameter <nFlags>
SetBase(const SwTxtFrm & rFrm,const Point & rBase,long nLnAscent,long nLnDescent,long nFlyAsc,long nFlyDesc,objectpositioning::AsCharFlags nFlags)347cdf0e10cSrcweir void SwFlyCntPortion::SetBase( const SwTxtFrm& rFrm, const Point &rBase,
348cdf0e10cSrcweir long nLnAscent, long nLnDescent,
349cdf0e10cSrcweir long nFlyAsc, long nFlyDesc,
350cdf0e10cSrcweir objectpositioning::AsCharFlags nFlags )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir // Note: rBase have to be an absolute value
353cdf0e10cSrcweir
354cdf0e10cSrcweir // OD 28.10.2003 #113049# - use new class to position object
355cdf0e10cSrcweir // determine drawing object
356cdf0e10cSrcweir SdrObject* pSdrObj = 0L;
357cdf0e10cSrcweir if( bDraw )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir // OD 20.06.2003 #108784# - determine drawing object ('master' or 'virtual')
360cdf0e10cSrcweir // by frame.
361cdf0e10cSrcweir pSdrObj = GetDrawContact()->GetDrawObjectByAnchorFrm( rFrm );
362cdf0e10cSrcweir if ( !pSdrObj )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir ASSERT( false, "SwFlyCntPortion::SetBase(..) - No drawing object found by <GetDrawContact()->GetDrawObjectByAnchorFrm( rFrm )>" );
365cdf0e10cSrcweir pSdrObj = GetDrawContact()->GetMaster();
366cdf0e10cSrcweir }
367cdf0e10cSrcweir // --> OD 2007-11-29 #i65798#
368cdf0e10cSrcweir // call <SwAnchoredDrawObject::MakeObjPos()> to assure that flag at
369cdf0e10cSrcweir // the <DrawFrmFmt> and at the <SwAnchoredDrawObject> instance are
370cdf0e10cSrcweir // correctly set.
371cdf0e10cSrcweir if ( pSdrObj )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir GetDrawContact()->GetAnchoredObj( pSdrObj )->MakeObjPos();
374cdf0e10cSrcweir }
375cdf0e10cSrcweir // <--
376cdf0e10cSrcweir }
377cdf0e10cSrcweir else
378cdf0e10cSrcweir {
379cdf0e10cSrcweir pSdrObj = GetFlyFrm()->GetVirtDrawObj();
380cdf0e10cSrcweir }
381cdf0e10cSrcweir
382cdf0e10cSrcweir // position object
383cdf0e10cSrcweir objectpositioning::SwAsCharAnchoredObjectPosition aObjPositioning(
384cdf0e10cSrcweir *pSdrObj,
385cdf0e10cSrcweir rBase, nFlags,
386cdf0e10cSrcweir nLnAscent, nLnDescent, nFlyAsc, nFlyDesc );
387cdf0e10cSrcweir
388cdf0e10cSrcweir // OD 2004-04-13 #i26791# - scope of local variable <aObjPosInProgress>
389cdf0e10cSrcweir {
390cdf0e10cSrcweir // OD 2004-04-13 #i26791#
391cdf0e10cSrcweir SwObjPositioningInProgress aObjPosInProgress( *pSdrObj );
392cdf0e10cSrcweir aObjPositioning.CalcPosition();
393cdf0e10cSrcweir }
394cdf0e10cSrcweir
395cdf0e10cSrcweir SetAlign( aObjPositioning.GetLineAlignment() );
396cdf0e10cSrcweir
397cdf0e10cSrcweir aRef = aObjPositioning.GetAnchorPos();
398cdf0e10cSrcweir if( nFlags & AS_CHAR_ROTATE )
399cdf0e10cSrcweir SvXSize( aObjPositioning.GetObjBoundRectInclSpacing().SSize() );
400cdf0e10cSrcweir else
401cdf0e10cSrcweir SvLSize( aObjPositioning.GetObjBoundRectInclSpacing().SSize() );
402cdf0e10cSrcweir if( Height() )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir SwTwips nRelPos = aObjPositioning.GetRelPosY();
405cdf0e10cSrcweir if ( nRelPos < 0 )
406cdf0e10cSrcweir {
407cdf0e10cSrcweir nAscent = static_cast<sal_uInt16>(-nRelPos);
408cdf0e10cSrcweir if( nAscent > Height() )
409cdf0e10cSrcweir Height( nAscent );
410cdf0e10cSrcweir }
411cdf0e10cSrcweir else
412cdf0e10cSrcweir {
413cdf0e10cSrcweir nAscent = 0;
414cdf0e10cSrcweir Height( Height() + static_cast<sal_uInt16>(nRelPos) );
415cdf0e10cSrcweir }
416cdf0e10cSrcweir }
417cdf0e10cSrcweir else
418cdf0e10cSrcweir {
419cdf0e10cSrcweir Height( 1 );
420cdf0e10cSrcweir nAscent = 0;
421cdf0e10cSrcweir }
422cdf0e10cSrcweir }
423cdf0e10cSrcweir
424cdf0e10cSrcweir /*************************************************************************
425cdf0e10cSrcweir * virtual SwFlyCntPortion::GetFlyCrsrOfst()
426cdf0e10cSrcweir *************************************************************************/
427cdf0e10cSrcweir
GetFlyCrsrOfst(const KSHORT nOfst,const Point & rPoint,SwPosition * pPos,SwCrsrMoveState * pCMS) const428cdf0e10cSrcweir xub_StrLen SwFlyCntPortion::GetFlyCrsrOfst( const KSHORT nOfst,
429cdf0e10cSrcweir const Point &rPoint, SwPosition *pPos, SwCrsrMoveState* pCMS ) const
430cdf0e10cSrcweir {
431cdf0e10cSrcweir // Da die FlyCnt nicht an der Seite haengen, wird ihr
432cdf0e10cSrcweir // GetCrsrOfst() nicht gerufen. Um die Layoutseite
433cdf0e10cSrcweir // von unnoetiger Verwaltung zu entlasten, ruft der Absatz
434cdf0e10cSrcweir // das GetCrsrOfst des FlyFrm, wenn es erforderlich ist.
435cdf0e10cSrcweir Point aPoint( rPoint );
436cdf0e10cSrcweir if( !pPos || bDraw || !( GetFlyFrm()->GetCrsrOfst( pPos, aPoint, pCMS ) ) )
437cdf0e10cSrcweir return SwLinePortion::GetCrsrOfst( nOfst );
438cdf0e10cSrcweir else
439cdf0e10cSrcweir return 0;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir /*************************************************************************
443cdf0e10cSrcweir * virtual SwFlyCntPortion::GetCrsrOfst()
444cdf0e10cSrcweir *************************************************************************/
445cdf0e10cSrcweir
GetCrsrOfst(const KSHORT nOfst) const446cdf0e10cSrcweir xub_StrLen SwFlyCntPortion::GetCrsrOfst( const KSHORT nOfst ) const
447cdf0e10cSrcweir {
448cdf0e10cSrcweir // ASSERT( !this, "SwFlyCntPortion::GetCrsrOfst: use GetFlyCrsrOfst()" );
449cdf0e10cSrcweir return SwLinePortion::GetCrsrOfst( nOfst );
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
452