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 #include <tools/list.hxx>
28cdf0e10cSrcweir #include <svx/svdobj.hxx>
29cdf0e10cSrcweir #include <init.hxx>
30cdf0e10cSrcweir #include <fesh.hxx>
31cdf0e10cSrcweir #include <pagefrm.hxx>
32cdf0e10cSrcweir #include <rootfrm.hxx>
33cdf0e10cSrcweir #include <cntfrm.hxx>
34cdf0e10cSrcweir #include <doc.hxx>
35cdf0e10cSrcweir #include <frmtool.hxx>
36cdf0e10cSrcweir #include <swtable.hxx>
37cdf0e10cSrcweir #include <viewimp.hxx>
38cdf0e10cSrcweir #include <dview.hxx>
39cdf0e10cSrcweir #include <flyfrm.hxx>
40cdf0e10cSrcweir #include <node.hxx>
41cdf0e10cSrcweir #include <pam.hxx>
42cdf0e10cSrcweir #include <sectfrm.hxx>
43cdf0e10cSrcweir #include <fmtpdsc.hxx>
44cdf0e10cSrcweir #include <fmtsrnd.hxx>
45cdf0e10cSrcweir #include <fmtcntnt.hxx>
46cdf0e10cSrcweir #include <tabfrm.hxx>
47cdf0e10cSrcweir #include <cellfrm.hxx>
48cdf0e10cSrcweir #include <flyfrms.hxx>
49cdf0e10cSrcweir #include <txtfrm.hxx> // SwTxtFrm
50cdf0e10cSrcweir #include <mdiexp.hxx>
51cdf0e10cSrcweir #include <edimp.hxx>
52cdf0e10cSrcweir #include <pagedesc.hxx>
53cdf0e10cSrcweir #include <fmtanchr.hxx>
54cdf0e10cSrcweir // OD 29.10.2003 #113049#
55cdf0e10cSrcweir #include <environmentofanchoredobject.hxx>
56cdf0e10cSrcweir // OD 12.11.2003 #i22341#
57cdf0e10cSrcweir #include <ndtxt.hxx>
58cdf0e10cSrcweir // OD 27.11.2003 #112045#
59cdf0e10cSrcweir #include <dflyobj.hxx>
60cdf0e10cSrcweir // OD 2004-03-29 #i26791#
61cdf0e10cSrcweir #include <dcontact.hxx>
62cdf0e10cSrcweir
63cdf0e10cSrcweir
64cdf0e10cSrcweir using namespace com::sun::star;
65cdf0e10cSrcweir
66cdf0e10cSrcweir
TYPEINIT1(SwFEShell,SwEditShell)67cdf0e10cSrcweir TYPEINIT1(SwFEShell,SwEditShell)
68cdf0e10cSrcweir
69cdf0e10cSrcweir /***********************************************************************
70cdf0e10cSrcweir #* Class : SwFEShell
71cdf0e10cSrcweir #* Methode : EndAllActionAndCall()
72cdf0e10cSrcweir #*
73cdf0e10cSrcweir #* Datum : MA 03. May. 93
74cdf0e10cSrcweir #* Update : MA 31. Oct. 95
75cdf0e10cSrcweir #***********************************************************************/
76cdf0e10cSrcweir
77cdf0e10cSrcweir void SwFEShell::EndAllActionAndCall()
78cdf0e10cSrcweir {
79cdf0e10cSrcweir ViewShell *pTmp = this;
80cdf0e10cSrcweir do {
81cdf0e10cSrcweir if( pTmp->IsA( TYPE(SwCrsrShell) ) )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir ((SwFEShell*)pTmp)->EndAction();
84cdf0e10cSrcweir ((SwFEShell*)pTmp)->CallChgLnk();
85cdf0e10cSrcweir }
86cdf0e10cSrcweir else
87cdf0e10cSrcweir pTmp->EndAction();
88cdf0e10cSrcweir } while( this != ( pTmp = (ViewShell*)pTmp->GetNext() ));
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
91cdf0e10cSrcweir
92cdf0e10cSrcweir /***********************************************************************
93cdf0e10cSrcweir #* Class : SwFEShell
94cdf0e10cSrcweir #* Methode : GetCntntPos
95cdf0e10cSrcweir #* Beschreibung: Ermitteln des Cntnt's der dem Punkt am naechsten liegt
96cdf0e10cSrcweir #* Datum : MA 02. Jun. 92
97cdf0e10cSrcweir #* Update : MA 02. May. 95
98cdf0e10cSrcweir #***********************************************************************/
99cdf0e10cSrcweir
GetCntntPos(const Point & rPoint,sal_Bool bNext) const100cdf0e10cSrcweir Point SwFEShell::GetCntntPos( const Point& rPoint, sal_Bool bNext ) const
101cdf0e10cSrcweir {
102cdf0e10cSrcweir SET_CURR_SHELL( (ViewShell*)this );
103cdf0e10cSrcweir return GetLayout()->GetNextPrevCntntPos( rPoint, bNext );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir
GetAnyCurRect(CurRectType eType,const Point * pPt,const uno::Reference<embed::XEmbeddedObject> & xObj) const107cdf0e10cSrcweir const SwRect& SwFEShell::GetAnyCurRect( CurRectType eType, const Point* pPt,
108cdf0e10cSrcweir const uno::Reference < embed::XEmbeddedObject >& xObj ) const
109cdf0e10cSrcweir {
110cdf0e10cSrcweir const SwFrm *pFrm = Imp()->HasDrawView()
111cdf0e10cSrcweir ? ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
112cdf0e10cSrcweir (ViewShell*)this)
113cdf0e10cSrcweir : 0;
114cdf0e10cSrcweir
115cdf0e10cSrcweir if( !pFrm )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir if( pPt )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir SwPosition aPos( *GetCrsr()->GetPoint() );
120cdf0e10cSrcweir Point aPt( *pPt );
121cdf0e10cSrcweir GetLayout()->GetCrsrOfst( &aPos, aPt );
122cdf0e10cSrcweir SwCntntNode *pNd = aPos.nNode.GetNode().GetCntntNode();
123cdf0e10cSrcweir pFrm = pNd->getLayoutFrm( GetLayout(), pPt );
124cdf0e10cSrcweir }
125cdf0e10cSrcweir else
126cdf0e10cSrcweir {
127cdf0e10cSrcweir const bool bOldCallbackActionEnabled = GetLayout()->IsCallbackActionEnabled();
128cdf0e10cSrcweir if( bOldCallbackActionEnabled )
129cdf0e10cSrcweir GetLayout()->SetCallbackActionEnabled( sal_False );
130cdf0e10cSrcweir pFrm = GetCurrFrm();
131cdf0e10cSrcweir if( bOldCallbackActionEnabled )
132cdf0e10cSrcweir GetLayout()->SetCallbackActionEnabled( sal_True );
133cdf0e10cSrcweir }
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
136cdf0e10cSrcweir if( !pFrm )
137cdf0e10cSrcweir return GetLayout()->Frm();
138cdf0e10cSrcweir
139cdf0e10cSrcweir sal_Bool bFrm = sal_True;
140cdf0e10cSrcweir switch ( eType )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir case RECT_PAGE_PRT: bFrm = sal_False; /* no break */
143cdf0e10cSrcweir case RECT_PAGE : pFrm = pFrm->FindPageFrm();
144cdf0e10cSrcweir break;
145cdf0e10cSrcweir
146cdf0e10cSrcweir case RECT_PAGE_CALC: pFrm->Calc();
147cdf0e10cSrcweir pFrm = pFrm->FindPageFrm();
148cdf0e10cSrcweir pFrm->Calc();
149cdf0e10cSrcweir break;
150cdf0e10cSrcweir
151cdf0e10cSrcweir case RECT_FLY_PRT_EMBEDDED: bFrm = sal_False; /* no break */
152cdf0e10cSrcweir case RECT_FLY_EMBEDDED: pFrm = xObj.is() ? FindFlyFrm( xObj )
153cdf0e10cSrcweir : pFrm->IsFlyFrm()
154cdf0e10cSrcweir ? pFrm
155cdf0e10cSrcweir : pFrm->FindFlyFrm();
156cdf0e10cSrcweir break;
157cdf0e10cSrcweir
158cdf0e10cSrcweir case RECT_OUTTABSECTION_PRT:
159cdf0e10cSrcweir case RECT_OUTTABSECTION : if( pFrm->IsInTab() )
160cdf0e10cSrcweir pFrm = pFrm->FindTabFrm();
161cdf0e10cSrcweir else {
162cdf0e10cSrcweir ASSERT( sal_False, "Missing Table" );
163cdf0e10cSrcweir }
164cdf0e10cSrcweir /* KEIN BREAK */
165cdf0e10cSrcweir case RECT_SECTION_PRT:
166cdf0e10cSrcweir case RECT_SECTION: if( pFrm->IsInSct() )
167cdf0e10cSrcweir pFrm = pFrm->FindSctFrm();
168cdf0e10cSrcweir else {
169cdf0e10cSrcweir ASSERT( sal_False, "Missing section" );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
172cdf0e10cSrcweir if( RECT_OUTTABSECTION_PRT == eType ||
173cdf0e10cSrcweir RECT_SECTION_PRT == eType )
174cdf0e10cSrcweir bFrm = sal_False;
175cdf0e10cSrcweir break;
176cdf0e10cSrcweir
177cdf0e10cSrcweir case RECT_HEADERFOOTER_PRT: bFrm = sal_False; /* no break */
178cdf0e10cSrcweir case RECT_HEADERFOOTER: if( 0 == (pFrm = pFrm->FindFooterOrHeader()) )
179cdf0e10cSrcweir return GetLayout()->Frm();
180cdf0e10cSrcweir break;
181cdf0e10cSrcweir
182cdf0e10cSrcweir case RECT_PAGES_AREA: return GetLayout()->GetPagesArea();
183cdf0e10cSrcweir
184cdf0e10cSrcweir default: break;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir return bFrm ? pFrm->Frm() : pFrm->Prt();
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
189cdf0e10cSrcweir
GetPageNumber(const Point & rPoint) const190cdf0e10cSrcweir sal_uInt16 SwFEShell::GetPageNumber( const Point &rPoint ) const
191cdf0e10cSrcweir {
192cdf0e10cSrcweir const SwFrm *pPage = GetLayout()->Lower();
193cdf0e10cSrcweir while ( pPage && !pPage->Frm().IsInside( rPoint ) )
194cdf0e10cSrcweir pPage = pPage->GetNext();
195cdf0e10cSrcweir if ( pPage )
196cdf0e10cSrcweir return ((const SwPageFrm*)pPage)->GetPhyPageNum();
197cdf0e10cSrcweir else
198cdf0e10cSrcweir return 0;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir
GetPageNumber(long nYPos,sal_Bool bAtCrsrPos,sal_uInt16 & rPhyNum,sal_uInt16 & rVirtNum,String & rDisplay) const202cdf0e10cSrcweir sal_Bool SwFEShell::GetPageNumber( long nYPos, sal_Bool bAtCrsrPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, String &rDisplay) const
203cdf0e10cSrcweir {
204cdf0e10cSrcweir const SwFrm *pPage;
205cdf0e10cSrcweir
206cdf0e10cSrcweir if ( bAtCrsrPos ) //Seite vom Crsr besorgen
207cdf0e10cSrcweir {
208cdf0e10cSrcweir pPage = GetCurrFrm( sal_False );
209cdf0e10cSrcweir if ( pPage )
210cdf0e10cSrcweir pPage = pPage->FindPageFrm();
211cdf0e10cSrcweir }
212cdf0e10cSrcweir else if ( nYPos > -1 ) //Seite ueber die Positon ermitteln
213cdf0e10cSrcweir {
214cdf0e10cSrcweir pPage = GetLayout()->Lower();
215cdf0e10cSrcweir while( pPage && (pPage->Frm().Bottom() < nYPos ||
216cdf0e10cSrcweir nYPos < pPage->Frm().Top() ) )
217cdf0e10cSrcweir pPage = pPage->GetNext();
218cdf0e10cSrcweir }
219cdf0e10cSrcweir else //Die erste sichtbare Seite
220cdf0e10cSrcweir {
221cdf0e10cSrcweir pPage = Imp()->GetFirstVisPage();
222cdf0e10cSrcweir if ( pPage && ((SwPageFrm*)pPage)->IsEmptyPage() )
223cdf0e10cSrcweir pPage = pPage->GetNext();
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
226cdf0e10cSrcweir if( pPage )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir rPhyNum = ((const SwPageFrm*)pPage)->GetPhyPageNum();
229cdf0e10cSrcweir rVirtNum = ((const SwPageFrm*)pPage)->GetVirtPageNum();
230cdf0e10cSrcweir const SvxNumberType& rNum = ((const SwPageFrm*)pPage)->GetPageDesc()->GetNumType();
231cdf0e10cSrcweir rDisplay = rNum.GetNumStr( rVirtNum );
232cdf0e10cSrcweir }
233cdf0e10cSrcweir
234cdf0e10cSrcweir return 0 != pPage;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237cdf0e10cSrcweir /*************************************************************************
238cdf0e10cSrcweir |*
239cdf0e10cSrcweir |* SwFEShell::IsDirectlyInSection()
240cdf0e10cSrcweir |*
241cdf0e10cSrcweir |* Hack for OS:
242cdf0e10cSrcweir |*
243cdf0e10cSrcweir *************************************************************************/
244cdf0e10cSrcweir
IsDirectlyInSection() const245cdf0e10cSrcweir bool SwFEShell::IsDirectlyInSection() const
246cdf0e10cSrcweir {
247cdf0e10cSrcweir SwFrm* pFrm = GetCurrFrm( sal_False );
248cdf0e10cSrcweir return pFrm && pFrm->GetUpper() && pFrm->GetUpper()->IsSctFrm();
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
251cdf0e10cSrcweir /*************************************************************************
252cdf0e10cSrcweir |*
253cdf0e10cSrcweir |* SwFEShell::GetFrmType()
254cdf0e10cSrcweir |*
255cdf0e10cSrcweir |* Ersterstellung MA 12. Jan. 93
256cdf0e10cSrcweir |* Letzte Aenderung AMA 25. Nov. 98
257cdf0e10cSrcweir |*
258cdf0e10cSrcweir *************************************************************************/
259cdf0e10cSrcweir
GetFrmType(const Point * pPt,sal_Bool bStopAtFly) const260cdf0e10cSrcweir sal_uInt16 SwFEShell::GetFrmType( const Point *pPt, sal_Bool bStopAtFly ) const
261cdf0e10cSrcweir {
262cdf0e10cSrcweir sal_uInt16 nReturn = FRMTYPE_NONE;
263cdf0e10cSrcweir const SwFrm *pFrm;
264cdf0e10cSrcweir if ( pPt )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir SwPosition aPos( *GetCrsr()->GetPoint() );
267cdf0e10cSrcweir Point aPt( *pPt );
268cdf0e10cSrcweir GetLayout()->GetCrsrOfst( &aPos, aPt );
269cdf0e10cSrcweir SwCntntNode *pNd = aPos.nNode.GetNode().GetCntntNode();
270cdf0e10cSrcweir pFrm = pNd->getLayoutFrm( GetLayout(), pPt );
271cdf0e10cSrcweir }
272cdf0e10cSrcweir else
273cdf0e10cSrcweir pFrm = GetCurrFrm( sal_False );
274cdf0e10cSrcweir while ( pFrm )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir switch ( pFrm->GetType() )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir case FRM_COLUMN: if( pFrm->GetUpper()->IsSctFrm() )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir // Check, if isn't not only a single column
281cdf0e10cSrcweir // from a section with footnotes at the end.
282cdf0e10cSrcweir if( pFrm->GetNext() || pFrm->GetPrev() )
283cdf0e10cSrcweir // Sectioncolumns
284cdf0e10cSrcweir nReturn |= ( nReturn & FRMTYPE_TABLE ) ?
285cdf0e10cSrcweir FRMTYPE_COLSECTOUTTAB : FRMTYPE_COLSECT;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir else // nur Seiten und Rahmenspalten
288cdf0e10cSrcweir nReturn |= FRMTYPE_COLUMN;
289cdf0e10cSrcweir break;
290cdf0e10cSrcweir case FRM_PAGE: nReturn |= FRMTYPE_PAGE;
291cdf0e10cSrcweir if( ((SwPageFrm*)pFrm)->IsFtnPage() )
292cdf0e10cSrcweir nReturn |= FRMTYPE_FTNPAGE;
293cdf0e10cSrcweir break;
294cdf0e10cSrcweir case FRM_HEADER: nReturn |= FRMTYPE_HEADER; break;
295cdf0e10cSrcweir case FRM_FOOTER: nReturn |= FRMTYPE_FOOTER; break;
296cdf0e10cSrcweir case FRM_BODY: if( pFrm->GetUpper()->IsPageFrm() ) // nicht bei ColumnFrms
297cdf0e10cSrcweir nReturn |= FRMTYPE_BODY;
298cdf0e10cSrcweir break;
299cdf0e10cSrcweir case FRM_FTN: nReturn |= FRMTYPE_FOOTNOTE; break;
300cdf0e10cSrcweir case FRM_FLY: if( ((SwFlyFrm*)pFrm)->IsFlyLayFrm() )
301cdf0e10cSrcweir nReturn |= FRMTYPE_FLY_FREE;
302cdf0e10cSrcweir else if ( ((SwFlyFrm*)pFrm)->IsFlyAtCntFrm() )
303cdf0e10cSrcweir nReturn |= FRMTYPE_FLY_ATCNT;
304cdf0e10cSrcweir else
305cdf0e10cSrcweir {
306cdf0e10cSrcweir ASSERT( ((SwFlyFrm*)pFrm)->IsFlyInCntFrm(),
307cdf0e10cSrcweir "Neuer Rahmentyp?" );
308cdf0e10cSrcweir nReturn |= FRMTYPE_FLY_INCNT;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir nReturn |= FRMTYPE_FLY_ANY;
311cdf0e10cSrcweir if( bStopAtFly )
312cdf0e10cSrcweir return nReturn;
313cdf0e10cSrcweir break;
314cdf0e10cSrcweir case FRM_TAB:
315cdf0e10cSrcweir case FRM_ROW:
316cdf0e10cSrcweir case FRM_CELL: nReturn |= FRMTYPE_TABLE; break;
317cdf0e10cSrcweir default: /* do nothing */ break;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir if ( pFrm->IsFlyFrm() )
320cdf0e10cSrcweir pFrm = ((SwFlyFrm*)pFrm)->GetAnchorFrm();
321cdf0e10cSrcweir else
322cdf0e10cSrcweir pFrm = pFrm->GetUpper();
323cdf0e10cSrcweir }
324cdf0e10cSrcweir return nReturn;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir /*************************************************************************
328cdf0e10cSrcweir |*
329cdf0e10cSrcweir |* SwFEShell::ShLooseFcs(), ShGetFcs()
330cdf0e10cSrcweir |*
331cdf0e10cSrcweir |* Ersterstellung MA 10. May. 93
332cdf0e10cSrcweir |* Letzte Aenderung MA 09. Sep. 98
333cdf0e10cSrcweir |*
334cdf0e10cSrcweir *************************************************************************/
335cdf0e10cSrcweir
ShGetFcs(sal_Bool bUpdate)336cdf0e10cSrcweir void SwFEShell::ShGetFcs( sal_Bool bUpdate )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir ::SetShell( this );
339cdf0e10cSrcweir SwCrsrShell::ShGetFcs( bUpdate );
340cdf0e10cSrcweir
341cdf0e10cSrcweir if ( HasDrawView() )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir Imp()->GetDrawView()->showMarkHandles();
344cdf0e10cSrcweir if ( Imp()->GetDrawView()->AreObjectsMarked() )
345cdf0e10cSrcweir FrameNotify( this, FLY_DRAG_START );
346cdf0e10cSrcweir }
347cdf0e10cSrcweir }
348cdf0e10cSrcweir
ShLooseFcs()349cdf0e10cSrcweir void SwFEShell::ShLooseFcs()
350cdf0e10cSrcweir {
351cdf0e10cSrcweir SwCrsrShell::ShLooseFcs();
352cdf0e10cSrcweir
353cdf0e10cSrcweir if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir Imp()->GetDrawView()->hideMarkHandles();
356cdf0e10cSrcweir FrameNotify( this, FLY_DRAG_END );
357cdf0e10cSrcweir }
358cdf0e10cSrcweir // ::ResetShell();
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
361cdf0e10cSrcweir /*************************************************************************
362cdf0e10cSrcweir |*
363cdf0e10cSrcweir |* SwFEShell::GetPhyPageNum()
364cdf0e10cSrcweir |* SwFEShell::GetVirtPageNum()
365cdf0e10cSrcweir |*
366cdf0e10cSrcweir |* Ersterstellung OK 07.07.93 08:20
367cdf0e10cSrcweir |* Letzte Aenderung MA 03. Jan. 94
368cdf0e10cSrcweir |*
369cdf0e10cSrcweir *************************************************************************/
370cdf0e10cSrcweir
GetPhyPageNum()371cdf0e10cSrcweir sal_uInt16 SwFEShell::GetPhyPageNum()
372cdf0e10cSrcweir {
373cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
374cdf0e10cSrcweir if ( pFrm )
375cdf0e10cSrcweir return pFrm->GetPhyPageNum();
376cdf0e10cSrcweir return 0;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir
GetVirtPageNum(const sal_Bool bCalcFrm)379cdf0e10cSrcweir sal_uInt16 SwFEShell::GetVirtPageNum( const sal_Bool bCalcFrm )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm( bCalcFrm );
382cdf0e10cSrcweir if ( pFrm )
383cdf0e10cSrcweir return pFrm->GetVirtPageNum();
384cdf0e10cSrcweir return 0;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir
387cdf0e10cSrcweir /*************************************************************************
388cdf0e10cSrcweir |*
389cdf0e10cSrcweir |* void lcl_SetAPageOffset()
390cdf0e10cSrcweir |* void SwFEShell::SetNewPageOffset()
391cdf0e10cSrcweir |* void SwFEShell::SetPageOffset()
392cdf0e10cSrcweir |* sal_uInt16 SwFEShell::GetPageOffset() const
393cdf0e10cSrcweir |*
394cdf0e10cSrcweir |* Ersterstellung OK 07.07.93 08:20
395cdf0e10cSrcweir |* Letzte Aenderung MA 30. Mar. 95
396cdf0e10cSrcweir |*
397cdf0e10cSrcweir *************************************************************************/
398cdf0e10cSrcweir
lcl_SetAPageOffset(sal_uInt16 nOffset,SwPageFrm * pPage,SwFEShell * pThis)399cdf0e10cSrcweir void lcl_SetAPageOffset( sal_uInt16 nOffset, SwPageFrm* pPage, SwFEShell* pThis )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir pThis->StartAllAction();
402cdf0e10cSrcweir ASSERT( pPage->FindFirstBodyCntnt(),
403cdf0e10cSrcweir "SwFEShell _SetAPageOffset() ohne CntntFrm" );
404cdf0e10cSrcweir
405cdf0e10cSrcweir SwFmtPageDesc aDesc( pPage->GetPageDesc() );
406cdf0e10cSrcweir aDesc.SetNumOffset( nOffset );
407cdf0e10cSrcweir
408cdf0e10cSrcweir SwFrm *pFrm = pThis->GetCurrFrm( sal_False );
409cdf0e10cSrcweir if ( pFrm->IsInTab() )
410cdf0e10cSrcweir pThis->GetDoc()->SetAttr( aDesc, *pFrm->FindTabFrm()->GetFmt() );
411cdf0e10cSrcweir else
412cdf0e10cSrcweir {
413cdf0e10cSrcweir pThis->GetDoc()->InsertPoolItem( *pThis->GetCrsr(), aDesc, 0 );
414cdf0e10cSrcweir }
415cdf0e10cSrcweir
416cdf0e10cSrcweir pThis->EndAllAction();
417cdf0e10cSrcweir }
418cdf0e10cSrcweir
SetNewPageOffset(sal_uInt16 nOffset)419cdf0e10cSrcweir void SwFEShell::SetNewPageOffset( sal_uInt16 nOffset )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir GetLayout()->SetVirtPageNum( sal_True );
422cdf0e10cSrcweir const SwPageFrm *pPage = GetCurrFrm( sal_False )->FindPageFrm();
423cdf0e10cSrcweir lcl_SetAPageOffset( nOffset, (SwPageFrm*)pPage, this );
424cdf0e10cSrcweir }
425cdf0e10cSrcweir
SetPageOffset(sal_uInt16 nOffset)426cdf0e10cSrcweir void SwFEShell::SetPageOffset( sal_uInt16 nOffset )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir const SwPageFrm *pPage = GetCurrFrm( sal_False )->FindPageFrm();
429cdf0e10cSrcweir const SwRootFrm* pDocLayout = GetLayout();
430cdf0e10cSrcweir while ( pPage )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir const SwFrm *pFlow = pPage->FindFirstBodyCntnt();
433cdf0e10cSrcweir if ( pFlow )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir if ( pFlow->IsInTab() )
436cdf0e10cSrcweir pFlow = pFlow->FindTabFrm();
437cdf0e10cSrcweir const SwFmtPageDesc& rPgDesc = pFlow->GetAttrSet()->GetPageDesc();
438cdf0e10cSrcweir if ( rPgDesc.GetNumOffset() )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir pDocLayout->SetVirtPageNum( sal_True );
441cdf0e10cSrcweir lcl_SetAPageOffset( nOffset, (SwPageFrm*)pPage, this );
442cdf0e10cSrcweir break;
443cdf0e10cSrcweir }
444cdf0e10cSrcweir }
445cdf0e10cSrcweir pPage = (SwPageFrm*)pPage->GetPrev();
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir
GetPageOffset() const449cdf0e10cSrcweir sal_uInt16 SwFEShell::GetPageOffset() const
450cdf0e10cSrcweir {
451cdf0e10cSrcweir const SwPageFrm *pPage = GetCurrFrm()->FindPageFrm();
452cdf0e10cSrcweir while ( pPage )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir const SwFrm *pFlow = pPage->FindFirstBodyCntnt();
455cdf0e10cSrcweir if ( pFlow )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir if ( pFlow->IsInTab() )
458cdf0e10cSrcweir pFlow = pFlow->FindTabFrm();
459cdf0e10cSrcweir const sal_uInt16 nOffset = pFlow->GetAttrSet()->GetPageDesc().GetNumOffset();
460cdf0e10cSrcweir if ( nOffset )
461cdf0e10cSrcweir return nOffset;
462cdf0e10cSrcweir }
463cdf0e10cSrcweir pPage = (SwPageFrm*)pPage->GetPrev();
464cdf0e10cSrcweir }
465cdf0e10cSrcweir return 0;
466cdf0e10cSrcweir }
467cdf0e10cSrcweir
468cdf0e10cSrcweir /*************************************************************************
469cdf0e10cSrcweir |*
470cdf0e10cSrcweir |* SwFEShell::InsertLabel()
471cdf0e10cSrcweir |*
472cdf0e10cSrcweir |* Ersterstellung MA 10. Feb. 94
473cdf0e10cSrcweir |* Letzte Aenderung MA 10. Feb. 94
474cdf0e10cSrcweir |*
475cdf0e10cSrcweir *************************************************************************/
476cdf0e10cSrcweir
InsertLabel(const SwLabelType eType,const String & rTxt,const String & rSeparator,const String & rNumberSeparator,const sal_Bool bBefore,const sal_uInt16 nId,const String & rCharacterStyle,const sal_Bool bCpyBrd)477cdf0e10cSrcweir void SwFEShell::InsertLabel( const SwLabelType eType, const String &rTxt, const String& rSeparator,
478cdf0e10cSrcweir const String& rNumberSeparator,
479cdf0e10cSrcweir const sal_Bool bBefore, const sal_uInt16 nId,
480cdf0e10cSrcweir const String& rCharacterStyle,
481cdf0e10cSrcweir const sal_Bool bCpyBrd )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir //NodeIndex der CrsrPosition besorgen, den Rest kann das Dokument
484cdf0e10cSrcweir //selbst erledigen.
485cdf0e10cSrcweir SwCntntFrm *pCnt = LTYPE_DRAW==eType ? 0 : GetCurrFrm( sal_False );
486cdf0e10cSrcweir if( LTYPE_DRAW==eType || pCnt )
487cdf0e10cSrcweir {
488cdf0e10cSrcweir StartAllAction();
489cdf0e10cSrcweir
490cdf0e10cSrcweir sal_uLong nIdx = 0;
491cdf0e10cSrcweir SwFlyFrmFmt* pFlyFmt = 0;
492cdf0e10cSrcweir switch( eType )
493cdf0e10cSrcweir {
494cdf0e10cSrcweir case LTYPE_OBJECT:
495cdf0e10cSrcweir case LTYPE_FLY:
496cdf0e10cSrcweir if( pCnt->IsInFly() )
497cdf0e10cSrcweir {
498cdf0e10cSrcweir //Bei Flys den Index auf den StartNode herunterreichen.
499cdf0e10cSrcweir nIdx = pCnt->FindFlyFrm()->
500cdf0e10cSrcweir GetFmt()->GetCntnt().GetCntntIdx()->GetIndex();
501cdf0e10cSrcweir //warum?? Bug 61913 ParkCrsr( GetCrsr()->GetPoint()->nNode );
502cdf0e10cSrcweir }
503cdf0e10cSrcweir break;
504cdf0e10cSrcweir case LTYPE_TABLE:
505cdf0e10cSrcweir if( pCnt->IsInTab() )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir //Bei Tabellen den Index auf den TblNode herunterreichen.
508cdf0e10cSrcweir const SwTable& rTbl = *pCnt->FindTabFrm()->GetTable();
509cdf0e10cSrcweir nIdx = rTbl.GetTabSortBoxes()[ 0 ]
510cdf0e10cSrcweir ->GetSttNd()->FindTableNode()->GetIndex();
511cdf0e10cSrcweir }
512cdf0e10cSrcweir break;
513cdf0e10cSrcweir case LTYPE_DRAW:
514cdf0e10cSrcweir if( Imp()->GetDrawView() )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir SwDrawView *pDView = Imp()->GetDrawView();
517cdf0e10cSrcweir const SdrMarkList& rMrkList = pDView->GetMarkedObjectList();
518cdf0e10cSrcweir StartUndo();
519cdf0e10cSrcweir
520cdf0e10cSrcweir // OD 27.11.2003 #112045# - copy marked drawing objects to
521cdf0e10cSrcweir // local list to perform the corresponding action for each object
522cdf0e10cSrcweir std::vector<SdrObject*> aDrawObjs;
523cdf0e10cSrcweir {
524cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir SdrObject* pDrawObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
527cdf0e10cSrcweir if( pDrawObj )
528cdf0e10cSrcweir aDrawObjs.push_back( pDrawObj );
529cdf0e10cSrcweir }
530cdf0e10cSrcweir }
531cdf0e10cSrcweir // loop on marked drawing objects
532cdf0e10cSrcweir while ( !aDrawObjs.empty() )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir SdrObject* pDrawObj = aDrawObjs.back();
535cdf0e10cSrcweir if ( !pDrawObj->ISA(SwVirtFlyDrawObj) &&
536cdf0e10cSrcweir !pDrawObj->ISA(SwFlyDrawObj) )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir SwFlyFrmFmt *pFmt =
539cdf0e10cSrcweir GetDoc()->InsertDrawLabel( rTxt, rSeparator, rNumberSeparator, nId, rCharacterStyle, *pDrawObj );
540cdf0e10cSrcweir if( !pFlyFmt )
541cdf0e10cSrcweir pFlyFmt = pFmt;
542cdf0e10cSrcweir }
543cdf0e10cSrcweir
544cdf0e10cSrcweir aDrawObjs.pop_back();
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir EndUndo();
548cdf0e10cSrcweir }
549cdf0e10cSrcweir break;
550cdf0e10cSrcweir default:
551cdf0e10cSrcweir ASSERT( !this, "Crsr weder in Tabelle noch in Fly." );
552cdf0e10cSrcweir }
553cdf0e10cSrcweir
554cdf0e10cSrcweir if( nIdx )
555cdf0e10cSrcweir pFlyFmt = GetDoc()->InsertLabel( eType, rTxt, rSeparator, rNumberSeparator, bBefore, nId,
556cdf0e10cSrcweir nIdx, rCharacterStyle, bCpyBrd );
557cdf0e10cSrcweir
558cdf0e10cSrcweir SwFlyFrm* pFrm;
559cdf0e10cSrcweir const Point aPt( GetCrsrDocPos() );
560cdf0e10cSrcweir if( pFlyFmt && 0 != ( pFrm = pFlyFmt->GetFrm( &aPt )))
561cdf0e10cSrcweir SelectFlyFrm( *pFrm, sal_True );
562cdf0e10cSrcweir
563cdf0e10cSrcweir EndAllActionAndCall();
564cdf0e10cSrcweir }
565cdf0e10cSrcweir }
566cdf0e10cSrcweir
567cdf0e10cSrcweir
568cdf0e10cSrcweir /***********************************************************************
569cdf0e10cSrcweir #* Class : SwFEShell
570cdf0e10cSrcweir #* Methoden : Sort
571cdf0e10cSrcweir #* Datum : ??
572cdf0e10cSrcweir #* Update : ??
573cdf0e10cSrcweir #***********************************************************************/
574cdf0e10cSrcweir
Sort(const SwSortOptions & rOpt)575cdf0e10cSrcweir sal_Bool SwFEShell::Sort(const SwSortOptions& rOpt)
576cdf0e10cSrcweir {
577cdf0e10cSrcweir if( !HasSelection() )
578cdf0e10cSrcweir return sal_False;
579cdf0e10cSrcweir
580cdf0e10cSrcweir SET_CURR_SHELL( this );
581cdf0e10cSrcweir sal_Bool bRet;
582cdf0e10cSrcweir StartAllAction();
583cdf0e10cSrcweir if(IsTableMode())
584cdf0e10cSrcweir {
585cdf0e10cSrcweir // Tabelle sortieren
586cdf0e10cSrcweir // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
587cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm( sal_False );
588cdf0e10cSrcweir ASSERT( pFrm->FindTabFrm(), "Crsr nicht in Tabelle." );
589cdf0e10cSrcweir
590cdf0e10cSrcweir // lasse ueber das Layout die Boxen suchen
591cdf0e10cSrcweir SwSelBoxes aBoxes;
592cdf0e10cSrcweir GetTblSel(*this, aBoxes);
593cdf0e10cSrcweir
594cdf0e10cSrcweir // die Crsr muessen noch aus dem Loesch Bereich entfernt
595cdf0e10cSrcweir // werden. Setze sie immer hinter/auf die Tabelle; ueber die
596cdf0e10cSrcweir // Dokument-Position werden sie dann immer an die alte Position gesetzt.
597cdf0e10cSrcweir while( !pFrm->IsCellFrm() )
598cdf0e10cSrcweir pFrm = pFrm->GetUpper();
599cdf0e10cSrcweir {
600cdf0e10cSrcweir /* #107993# ParkCursor->ParkCursorTab */
601cdf0e10cSrcweir ParkCursorInTab();
602cdf0e10cSrcweir }
603cdf0e10cSrcweir
604cdf0e10cSrcweir // Sorting am Dokument aufrufen
605cdf0e10cSrcweir bRet = pDoc->SortTbl(aBoxes, rOpt);
606cdf0e10cSrcweir }
607cdf0e10cSrcweir else
608cdf0e10cSrcweir {
609cdf0e10cSrcweir // Text sortieren und nichts anderes
610cdf0e10cSrcweir FOREACHPAM_START(this)
611cdf0e10cSrcweir
612cdf0e10cSrcweir SwPaM* pPam = PCURCRSR;
613cdf0e10cSrcweir
614cdf0e10cSrcweir SwPosition* pStart = pPam->Start();
615cdf0e10cSrcweir SwPosition* pEnd = pPam->End();
616cdf0e10cSrcweir
617cdf0e10cSrcweir SwNodeIndex aPrevIdx( pStart->nNode, -1 );
618cdf0e10cSrcweir sal_uLong nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
619cdf0e10cSrcweir xub_StrLen nCntStt = pStart->nContent.GetIndex();
620cdf0e10cSrcweir
621cdf0e10cSrcweir // Das Sortieren
622cdf0e10cSrcweir bRet = pDoc->SortText(*pPam, rOpt);
623cdf0e10cSrcweir
624cdf0e10cSrcweir // Selektion wieder setzen
625cdf0e10cSrcweir pPam->DeleteMark();
626cdf0e10cSrcweir pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
627cdf0e10cSrcweir SwCntntNode* pCNd = pPam->GetCntntNode();
628cdf0e10cSrcweir xub_StrLen nLen = pCNd->Len();
629cdf0e10cSrcweir if( nLen > nCntStt )
630cdf0e10cSrcweir nLen = nCntStt;
631cdf0e10cSrcweir pPam->GetPoint()->nContent.Assign(pCNd, nLen );
632cdf0e10cSrcweir pPam->SetMark();
633cdf0e10cSrcweir
634cdf0e10cSrcweir pPam->GetPoint()->nNode += nOffset;
635cdf0e10cSrcweir pCNd = pPam->GetCntntNode();
636cdf0e10cSrcweir pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
637cdf0e10cSrcweir
638cdf0e10cSrcweir FOREACHPAM_END()
639cdf0e10cSrcweir }
640cdf0e10cSrcweir
641cdf0e10cSrcweir EndAllAction();
642cdf0e10cSrcweir return bRet;
643cdf0e10cSrcweir }
644cdf0e10cSrcweir
645cdf0e10cSrcweir /*************************************************************************
646cdf0e10cSrcweir |*
647cdf0e10cSrcweir |* SwFEShell::GetCurColNum(), _GetColNum()
648cdf0e10cSrcweir |*
649cdf0e10cSrcweir |* Ersterstellung MA 03. Feb. 95
650cdf0e10cSrcweir |* Letzte Aenderung MA 20. Apr. 95
651cdf0e10cSrcweir |
652cdf0e10cSrcweir |*************************************************************************/
653cdf0e10cSrcweir
_GetCurColNum(const SwFrm * pFrm,SwGetCurColNumPara * pPara) const654cdf0e10cSrcweir sal_uInt16 SwFEShell::_GetCurColNum( const SwFrm *pFrm,
655cdf0e10cSrcweir SwGetCurColNumPara* pPara ) const
656cdf0e10cSrcweir {
657cdf0e10cSrcweir sal_uInt16 nRet = 0;
658cdf0e10cSrcweir while ( pFrm )
659cdf0e10cSrcweir {
660cdf0e10cSrcweir pFrm = pFrm->GetUpper();
661cdf0e10cSrcweir if( pFrm && pFrm->IsColumnFrm() )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir const SwFrm *pCurFrm = pFrm;
664cdf0e10cSrcweir do {
665cdf0e10cSrcweir ++nRet;
666cdf0e10cSrcweir pFrm = pFrm->GetPrev();
667cdf0e10cSrcweir } while ( pFrm );
668cdf0e10cSrcweir
669cdf0e10cSrcweir if( pPara )
670cdf0e10cSrcweir {
671cdf0e10cSrcweir // dann suche mal das Format, was diese Spaltigkeit bestimmt
672cdf0e10cSrcweir pFrm = pCurFrm->GetUpper();
673cdf0e10cSrcweir while( pFrm )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir if( ( FRM_PAGE | FRM_FLY | FRM_SECTION ) & pFrm->GetType() )
676cdf0e10cSrcweir {
677cdf0e10cSrcweir pPara->pFrmFmt = ((SwLayoutFrm*)pFrm)->GetFmt();
678cdf0e10cSrcweir pPara->pPrtRect = &pFrm->Prt();
679cdf0e10cSrcweir pPara->pFrmRect = &pFrm->Frm();
680cdf0e10cSrcweir break;
681cdf0e10cSrcweir }
682cdf0e10cSrcweir pFrm = pFrm->GetUpper();
683cdf0e10cSrcweir }
684cdf0e10cSrcweir if( !pFrm )
685cdf0e10cSrcweir {
686cdf0e10cSrcweir pPara->pFrmFmt = 0;
687cdf0e10cSrcweir pPara->pPrtRect = 0;
688cdf0e10cSrcweir pPara->pFrmRect = 0;
689cdf0e10cSrcweir }
690cdf0e10cSrcweir }
691cdf0e10cSrcweir break;
692cdf0e10cSrcweir }
693cdf0e10cSrcweir }
694cdf0e10cSrcweir return nRet;
695cdf0e10cSrcweir }
696cdf0e10cSrcweir
GetCurColNum(SwGetCurColNumPara * pPara) const697cdf0e10cSrcweir sal_uInt16 SwFEShell::GetCurColNum( SwGetCurColNumPara* pPara ) const
698cdf0e10cSrcweir {
699cdf0e10cSrcweir ASSERT( GetCurrFrm(), "Crsr geparkt?" );
700cdf0e10cSrcweir return _GetCurColNum( GetCurrFrm(), pPara );
701cdf0e10cSrcweir }
702cdf0e10cSrcweir
GetCurOutColNum(SwGetCurColNumPara * pPara) const703cdf0e10cSrcweir sal_uInt16 SwFEShell::GetCurOutColNum( SwGetCurColNumPara* pPara ) const
704cdf0e10cSrcweir {
705cdf0e10cSrcweir sal_uInt16 nRet = 0;
706cdf0e10cSrcweir SwFrm* pFrm = GetCurrFrm();
707cdf0e10cSrcweir ASSERT( pFrm, "Crsr geparkt?" );
708cdf0e10cSrcweir if( pFrm )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir pFrm = pFrm->IsInTab() ? (SwFrm*)pFrm->FindTabFrm()
711cdf0e10cSrcweir : (SwFrm*)pFrm->FindSctFrm();
712cdf0e10cSrcweir ASSERT( pFrm, "No Tab, no Sect" );
713cdf0e10cSrcweir if( pFrm )
714cdf0e10cSrcweir nRet = _GetCurColNum( pFrm, pPara );
715cdf0e10cSrcweir }
716cdf0e10cSrcweir return nRet;
717cdf0e10cSrcweir }
718cdf0e10cSrcweir
SwFEShell(SwDoc & rDoc,Window * pWindow,const SwViewOption * pOptions)719cdf0e10cSrcweir SwFEShell::SwFEShell( SwDoc& rDoc, Window *pWindow, const SwViewOption *pOptions )
720cdf0e10cSrcweir : SwEditShell( rDoc, pWindow, pOptions ),
721cdf0e10cSrcweir pChainFrom( 0 ), pChainTo( 0 ), bCheckForOLEInCaption( sal_False )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir }
724cdf0e10cSrcweir
SwFEShell(SwEditShell & rShell,Window * pWindow)725cdf0e10cSrcweir SwFEShell::SwFEShell( SwEditShell& rShell, Window *pWindow )
726cdf0e10cSrcweir : SwEditShell( rShell, pWindow ),
727cdf0e10cSrcweir pChainFrom( 0 ), pChainTo( 0 ), bCheckForOLEInCaption( sal_False )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir }
730cdf0e10cSrcweir
~SwFEShell()731cdf0e10cSrcweir SwFEShell::~SwFEShell()
732cdf0e10cSrcweir {
733cdf0e10cSrcweir delete pChainFrom;
734cdf0e10cSrcweir delete pChainTo;
735cdf0e10cSrcweir }
736cdf0e10cSrcweir
737cdf0e10cSrcweir // OD 18.09.2003 #i17567#, #108749#, #110354# - adjustments for allowing
738cdf0e10cSrcweir // negative vertical positions for fly frames anchored to paragraph/to character.
739cdf0e10cSrcweir // OD 06.11.2003 #i22305# - adjustments for option 'Follow text flow'
740cdf0e10cSrcweir // for to frame anchored objects.
741cdf0e10cSrcweir // OD 12.11.2003 #i22341# - adjustments for vertical alignment at top of line
742cdf0e10cSrcweir // for to character anchored objects.
CalcBoundRect(SwRect & _orRect,const RndStdIds _nAnchorId,const sal_Int16 _eHoriRelOrient,const sal_Int16 _eVertRelOrient,const SwPosition * _pToCharCntntPos,const bool _bFollowTextFlow,bool _bMirror,Point * _opRef,Size * _opPercent) const743cdf0e10cSrcweir void SwFEShell::CalcBoundRect( SwRect& _orRect,
744cdf0e10cSrcweir const RndStdIds _nAnchorId,
745cdf0e10cSrcweir const sal_Int16 _eHoriRelOrient,
746cdf0e10cSrcweir const sal_Int16 _eVertRelOrient,
747cdf0e10cSrcweir const SwPosition* _pToCharCntntPos,
748cdf0e10cSrcweir const bool _bFollowTextFlow,
749cdf0e10cSrcweir bool _bMirror,
750cdf0e10cSrcweir Point* _opRef,
751cdf0e10cSrcweir Size* _opPercent ) const
752cdf0e10cSrcweir {
753cdf0e10cSrcweir const SwFrm* pFrm;
754cdf0e10cSrcweir const SwFlyFrm* pFly;
755cdf0e10cSrcweir if( _opRef )
756cdf0e10cSrcweir {
757cdf0e10cSrcweir pFrm = GetCurrFrm();
758cdf0e10cSrcweir if( 0 != ( pFly = pFrm->FindFlyFrm() ) )
759cdf0e10cSrcweir pFrm = pFly->GetAnchorFrm();
760cdf0e10cSrcweir }
761cdf0e10cSrcweir else
762cdf0e10cSrcweir {
763cdf0e10cSrcweir pFly = FindFlyFrm();
764cdf0e10cSrcweir pFrm = pFly ? pFly->GetAnchorFrm() : GetCurrFrm();
765cdf0e10cSrcweir }
766cdf0e10cSrcweir
767cdf0e10cSrcweir sal_Bool bWrapThrough = sal_False;
768cdf0e10cSrcweir if ( pFly )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir SwFlyFrmFmt* pFmt = (SwFlyFrmFmt*)pFly->GetFmt();
771cdf0e10cSrcweir const SwFmtSurround& rSurround = pFmt->GetSurround();
772cdf0e10cSrcweir bWrapThrough = rSurround.GetSurround() == SURROUND_THROUGHT;
773cdf0e10cSrcweir }
774cdf0e10cSrcweir
775cdf0e10cSrcweir const SwPageFrm* pPage = pFrm->FindPageFrm();
776cdf0e10cSrcweir _bMirror = _bMirror && !pPage->OnRightPage();
777cdf0e10cSrcweir
778cdf0e10cSrcweir Point aPos;
779cdf0e10cSrcweir bool bVertic = false;
780cdf0e10cSrcweir sal_Bool bRTL = sal_False;
781cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
782cdf0e10cSrcweir bool bVerticalL2R = false;
783cdf0e10cSrcweir // <--
784cdf0e10cSrcweir
785cdf0e10cSrcweir if ((FLY_AT_PAGE == _nAnchorId) || (FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL
786cdf0e10cSrcweir {
787cdf0e10cSrcweir const SwFrm* pTmp = pFrm;
788cdf0e10cSrcweir // OD 06.11.2003 #i22305#
789cdf0e10cSrcweir if ((FLY_AT_PAGE == _nAnchorId) ||
790cdf0e10cSrcweir ((FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow))
791cdf0e10cSrcweir {
792cdf0e10cSrcweir pFrm = pPage;
793cdf0e10cSrcweir }
794cdf0e10cSrcweir else
795cdf0e10cSrcweir {
796cdf0e10cSrcweir pFrm = pFrm->FindFlyFrm();
797cdf0e10cSrcweir }
798cdf0e10cSrcweir if ( !pFrm )
799cdf0e10cSrcweir pFrm = pTmp;
800cdf0e10cSrcweir _orRect = pFrm->Frm();
801cdf0e10cSrcweir SWRECTFN( pFrm )
802cdf0e10cSrcweir bRTL = pFrm->IsRightToLeft();
803cdf0e10cSrcweir if ( bRTL )
804cdf0e10cSrcweir aPos = pFrm->Frm().TopRight();
805cdf0e10cSrcweir else
806cdf0e10cSrcweir aPos = (pFrm->Frm().*fnRect->fnGetPos)();
807cdf0e10cSrcweir
808cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
809cdf0e10cSrcweir if( bVert || bVertL2R )
810cdf0e10cSrcweir // <--
811cdf0e10cSrcweir {
812cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
813cdf0e10cSrcweir bVertic = bVert ? true : false;
814cdf0e10cSrcweir bVerticalL2R = bVertL2R ? true : false;
815cdf0e10cSrcweir // <--
816cdf0e10cSrcweir _bMirror = false; // no mirroring in vertical environment
817cdf0e10cSrcweir switch ( _eHoriRelOrient )
818cdf0e10cSrcweir {
819cdf0e10cSrcweir case text::RelOrientation::PAGE_RIGHT:
820cdf0e10cSrcweir case text::RelOrientation::FRAME_RIGHT: aPos.Y() += pFrm->Prt().Height();
821cdf0e10cSrcweir // no break!
822cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
823cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA: aPos.Y() += pFrm->Prt().Top(); break;
824cdf0e10cSrcweir default: break;
825cdf0e10cSrcweir }
826cdf0e10cSrcweir }
827cdf0e10cSrcweir else if ( _bMirror )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir switch ( _eHoriRelOrient )
830cdf0e10cSrcweir {
831cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
832cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrm->Prt().Width();
833cdf0e10cSrcweir // kein break
834cdf0e10cSrcweir case text::RelOrientation::PAGE_RIGHT:
835cdf0e10cSrcweir case text::RelOrientation::FRAME_RIGHT: aPos.X() += pFrm->Prt().Left(); break;
836cdf0e10cSrcweir default: aPos.X() += pFrm->Frm().Width();
837cdf0e10cSrcweir }
838cdf0e10cSrcweir }
839cdf0e10cSrcweir else if ( bRTL )
840cdf0e10cSrcweir {
841cdf0e10cSrcweir switch ( _eHoriRelOrient )
842cdf0e10cSrcweir {
843cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
844cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrm->Prt().Width();
845cdf0e10cSrcweir // kein break!
846cdf0e10cSrcweir case text::RelOrientation::PAGE_LEFT:
847cdf0e10cSrcweir case text::RelOrientation::FRAME_LEFT: aPos.X() += pFrm->Prt().Left() -
848cdf0e10cSrcweir pFrm->Frm().Width(); break;
849cdf0e10cSrcweir default: break;
850cdf0e10cSrcweir }
851cdf0e10cSrcweir }
852cdf0e10cSrcweir else
853cdf0e10cSrcweir {
854cdf0e10cSrcweir switch ( _eHoriRelOrient )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir case text::RelOrientation::PAGE_RIGHT:
857cdf0e10cSrcweir case text::RelOrientation::FRAME_RIGHT: aPos.X() += pFrm->Prt().Width();
858cdf0e10cSrcweir // kein break!
859cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
860cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrm->Prt().Left(); break;
861cdf0e10cSrcweir default:break;
862cdf0e10cSrcweir }
863cdf0e10cSrcweir }
864cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
865cdf0e10cSrcweir if ( bVert && !bVertL2R )
866cdf0e10cSrcweir // <--
867cdf0e10cSrcweir {
868cdf0e10cSrcweir switch ( _eVertRelOrient )
869cdf0e10cSrcweir {
870cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
871cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA:
872cdf0e10cSrcweir {
873cdf0e10cSrcweir aPos.X() -= pFrm->GetRightMargin();
874cdf0e10cSrcweir }
875cdf0e10cSrcweir break;
876cdf0e10cSrcweir }
877cdf0e10cSrcweir }
878cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
879cdf0e10cSrcweir else if ( bVertL2R )
880cdf0e10cSrcweir {
881cdf0e10cSrcweir switch ( _eVertRelOrient )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
884cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA:
885cdf0e10cSrcweir {
886cdf0e10cSrcweir aPos.X() += pFrm->GetLeftMargin();
887cdf0e10cSrcweir }
888cdf0e10cSrcweir break;
889cdf0e10cSrcweir }
890cdf0e10cSrcweir }
891cdf0e10cSrcweir // <--
892cdf0e10cSrcweir else
893cdf0e10cSrcweir {
894cdf0e10cSrcweir switch ( _eVertRelOrient )
895cdf0e10cSrcweir {
896cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
897cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA:
898cdf0e10cSrcweir {
899cdf0e10cSrcweir if ( pFrm->IsPageFrm() )
900cdf0e10cSrcweir {
901cdf0e10cSrcweir aPos.Y() =
902cdf0e10cSrcweir static_cast<const SwPageFrm*>(pFrm)->PrtWithoutHeaderAndFooter().Top();
903cdf0e10cSrcweir }
904cdf0e10cSrcweir else
905cdf0e10cSrcweir {
906cdf0e10cSrcweir aPos.Y() += pFrm->Prt().Top();
907cdf0e10cSrcweir }
908cdf0e10cSrcweir }
909cdf0e10cSrcweir break;
910cdf0e10cSrcweir }
911cdf0e10cSrcweir }
912cdf0e10cSrcweir // <--
913cdf0e10cSrcweir if ( _opPercent )
914cdf0e10cSrcweir *_opPercent = pFrm->Prt().SSize();
915cdf0e10cSrcweir }
916cdf0e10cSrcweir else
917cdf0e10cSrcweir {
918cdf0e10cSrcweir const SwFrm* pUpper = ( pFrm->IsPageFrm() || pFrm->IsFlyFrm() ) ?
919cdf0e10cSrcweir pFrm : pFrm->GetUpper();
920cdf0e10cSrcweir SWRECTFN( pUpper );
921cdf0e10cSrcweir if ( _opPercent )
922cdf0e10cSrcweir *_opPercent = pUpper->Prt().SSize();
923cdf0e10cSrcweir
924cdf0e10cSrcweir bRTL = pFrm->IsRightToLeft();
925cdf0e10cSrcweir if ( bRTL )
926cdf0e10cSrcweir aPos = pFrm->Frm().TopRight();
927cdf0e10cSrcweir else
928cdf0e10cSrcweir aPos = (pFrm->Frm().*fnRect->fnGetPos)();
929cdf0e10cSrcweir // OD 08.09.2003 #i17567#, #108749#, #110354# - allow negative positions
930cdf0e10cSrcweir // for fly frames anchor to paragraph/to character.
931cdf0e10cSrcweir if ((_nAnchorId == FLY_AT_PARA) || (_nAnchorId == FLY_AT_CHAR))
932cdf0e10cSrcweir {
933cdf0e10cSrcweir // The rectangle, the fly frame can be positioned in, is determined
934cdf0e10cSrcweir // horizontally by the frame area of the horizontal environment
935cdf0e10cSrcweir // and vertically by the printing area of the vertical environment,
936cdf0e10cSrcweir // if the object follows the text flow, or by the frame area of the
937cdf0e10cSrcweir // vertical environment, if the object doesn't follow the text flow.
938cdf0e10cSrcweir // OD 29.10.2003 #113049# - new class <SwEnvironmentOfAnchoredObject>
939cdf0e10cSrcweir objectpositioning::SwEnvironmentOfAnchoredObject aEnvOfObj(
940cdf0e10cSrcweir _bFollowTextFlow );
941cdf0e10cSrcweir const SwLayoutFrm& rHoriEnvironLayFrm =
942cdf0e10cSrcweir aEnvOfObj.GetHoriEnvironmentLayoutFrm( *pFrm );
943cdf0e10cSrcweir const SwLayoutFrm& rVertEnvironLayFrm =
944cdf0e10cSrcweir aEnvOfObj.GetVertEnvironmentLayoutFrm( *pFrm );
945cdf0e10cSrcweir SwRect aHoriEnvironRect( rHoriEnvironLayFrm.Frm() );
946cdf0e10cSrcweir SwRect aVertEnvironRect;
947cdf0e10cSrcweir if ( _bFollowTextFlow )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir aVertEnvironRect = rVertEnvironLayFrm.Prt();
950cdf0e10cSrcweir aVertEnvironRect.Pos() += rVertEnvironLayFrm.Frm().Pos();
951cdf0e10cSrcweir // OD 19.09.2003 #i18732# - adjust vertical 'virtual' anchor position
952cdf0e10cSrcweir // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
953cdf0e10cSrcweir // to page areas.
954cdf0e10cSrcweir if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
955cdf0e10cSrcweir {
956cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
957cdf0e10cSrcweir if ( bVert && !bVertL2R )
958cdf0e10cSrcweir // <--
959cdf0e10cSrcweir {
960cdf0e10cSrcweir aPos.X() = aVertEnvironRect.Right();
961cdf0e10cSrcweir }
962cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
963cdf0e10cSrcweir else if ( bVertL2R )
964cdf0e10cSrcweir {
965cdf0e10cSrcweir aPos.X() = aVertEnvironRect.Left();
966cdf0e10cSrcweir }
967cdf0e10cSrcweir else
968cdf0e10cSrcweir {
969cdf0e10cSrcweir aPos.Y() = aVertEnvironRect.Top();
970cdf0e10cSrcweir }
971cdf0e10cSrcweir }
972cdf0e10cSrcweir }
973cdf0e10cSrcweir else
974cdf0e10cSrcweir {
975cdf0e10cSrcweir ASSERT( rVertEnvironLayFrm.IsPageFrm(),
976cdf0e10cSrcweir "<SwFEShell::CalcBoundRect(..)> - not following text flow, but vertical environment *not* page!" );
977cdf0e10cSrcweir aVertEnvironRect = rVertEnvironLayFrm.Frm();
978cdf0e10cSrcweir // OD 19.09.2003 #i18732# - adjustment vertical 'virtual' anchor position
979cdf0e10cSrcweir // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
980cdf0e10cSrcweir // to page areas.
981cdf0e10cSrcweir if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
982cdf0e10cSrcweir {
983cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
984cdf0e10cSrcweir if ( bVert && !bVertL2R )
985cdf0e10cSrcweir // <--
986cdf0e10cSrcweir {
987cdf0e10cSrcweir aPos.X() = aVertEnvironRect.Right();
988cdf0e10cSrcweir if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
989cdf0e10cSrcweir {
990cdf0e10cSrcweir aPos.X() -= rVertEnvironLayFrm.GetRightMargin();
991cdf0e10cSrcweir }
992cdf0e10cSrcweir }
993cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
994cdf0e10cSrcweir else if ( bVertL2R )
995cdf0e10cSrcweir {
996cdf0e10cSrcweir aPos.X() = aVertEnvironRect.Left();
997cdf0e10cSrcweir if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
998cdf0e10cSrcweir {
999cdf0e10cSrcweir aPos.X() += rVertEnvironLayFrm.GetLeftMargin();
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir }
1002cdf0e10cSrcweir // <--
1003cdf0e10cSrcweir else
1004cdf0e10cSrcweir {
1005cdf0e10cSrcweir aPos.Y() = aVertEnvironRect.Top();
1006cdf0e10cSrcweir if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir aPos.Y() += rVertEnvironLayFrm.GetTopMargin();
1009cdf0e10cSrcweir // add height of page header
1010cdf0e10cSrcweir const SwFrm* pTmpFrm = rVertEnvironLayFrm.Lower();
1011cdf0e10cSrcweir if ( pTmpFrm->IsHeaderFrm() )
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir aPos.Y() += pTmpFrm->Frm().Height();
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir // OD 12.11.2003 #i22341# - adjust vertical 'virtual' anchor position
1021cdf0e10cSrcweir // (<aPos.Y()> respectively <aPos.X()>), if object is anchored to
1022cdf0e10cSrcweir // character and vertical aligned at character or top of line
1023cdf0e10cSrcweir // --> OD 2005-12-29 #125800#
1024cdf0e10cSrcweir // <pFrm>, which is the anchor frame or the proposed anchor frame,
1025cdf0e10cSrcweir // doesn't have to be a text frame (e.g. edit a to-page anchored
1026cdf0e10cSrcweir // fly frame). Thus, assure this.
1027cdf0e10cSrcweir const SwTxtFrm* pTxtFrm( dynamic_cast<const SwTxtFrm*>(pFrm) );
1028cdf0e10cSrcweir if ( pTxtFrm &&
1029cdf0e10cSrcweir (_nAnchorId == FLY_AT_CHAR) &&
1030cdf0e10cSrcweir ( _eVertRelOrient == text::RelOrientation::CHAR ||
1031cdf0e10cSrcweir _eVertRelOrient == text::RelOrientation::TEXT_LINE ) )
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir SwTwips nTop = 0L;
1034cdf0e10cSrcweir if ( _eVertRelOrient == text::RelOrientation::CHAR )
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir SwRect aChRect;
1037cdf0e10cSrcweir if ( _pToCharCntntPos )
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir pTxtFrm->GetAutoPos( aChRect, *_pToCharCntntPos );
1040cdf0e10cSrcweir }
1041cdf0e10cSrcweir else
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir // No content position provided. Thus, use a default one.
1044cdf0e10cSrcweir SwPosition aDefaultCntntPos( *(pTxtFrm->GetTxtNode()) );
1045cdf0e10cSrcweir pTxtFrm->GetAutoPos( aChRect, aDefaultCntntPos );
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir nTop = (aChRect.*fnRect->fnGetBottom)();
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir else
1050cdf0e10cSrcweir {
1051cdf0e10cSrcweir if ( _pToCharCntntPos )
1052cdf0e10cSrcweir {
1053cdf0e10cSrcweir pTxtFrm->GetTopOfLine( nTop, *_pToCharCntntPos );
1054cdf0e10cSrcweir }
1055cdf0e10cSrcweir else
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir // No content position provided. Thus, use a default one.
1058cdf0e10cSrcweir SwPosition aDefaultCntntPos( *(pTxtFrm->GetTxtNode()) );
1059cdf0e10cSrcweir pTxtFrm->GetTopOfLine( nTop, aDefaultCntntPos );
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
1063cdf0e10cSrcweir if ( bVert || bVertL2R )
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir aPos.X() = nTop;
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir // <--
1068cdf0e10cSrcweir else
1069cdf0e10cSrcweir {
1070cdf0e10cSrcweir aPos.Y() = nTop;
1071cdf0e10cSrcweir }
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir
1074cdf0e10cSrcweir // --> OD 2004-10-05 #i26945# - adjust horizontal 'virtual' anchor
1075cdf0e10cSrcweir // position (<aPos.X()> respectively <aPos.Y()>), if object is
1076cdf0e10cSrcweir // anchored to character and horizontal aligned at character.
1077cdf0e10cSrcweir if ( pTxtFrm &&
1078cdf0e10cSrcweir (_nAnchorId == FLY_AT_CHAR) &&
1079cdf0e10cSrcweir _eHoriRelOrient == text::RelOrientation::CHAR )
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir SwTwips nLeft = 0L;
1082cdf0e10cSrcweir SwRect aChRect;
1083cdf0e10cSrcweir if ( _pToCharCntntPos )
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir pTxtFrm->GetAutoPos( aChRect, *_pToCharCntntPos );
1086cdf0e10cSrcweir }
1087cdf0e10cSrcweir else
1088cdf0e10cSrcweir {
1089cdf0e10cSrcweir // No content position provided. Thus, use a default one.
1090cdf0e10cSrcweir SwPosition aDefaultCntntPos( *(pTxtFrm->GetTxtNode()) );
1091cdf0e10cSrcweir pTxtFrm->GetAutoPos( aChRect, aDefaultCntntPos );
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir nLeft = (aChRect.*fnRect->fnGetLeft)();
1094cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
1095cdf0e10cSrcweir if ( bVert || bVertL2R )
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir aPos.Y() = nLeft;
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir // <--
1100cdf0e10cSrcweir else
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir aPos.X() = nLeft;
1103cdf0e10cSrcweir }
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir // <--
1106cdf0e10cSrcweir
1107cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
1108cdf0e10cSrcweir if ( bVert || bVertL2R )
1109cdf0e10cSrcweir // <--
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir _orRect = SwRect( aVertEnvironRect.Left(),
1112cdf0e10cSrcweir aHoriEnvironRect.Top(),
1113cdf0e10cSrcweir aVertEnvironRect.Width(),
1114cdf0e10cSrcweir aHoriEnvironRect.Height() );
1115cdf0e10cSrcweir }
1116cdf0e10cSrcweir else
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir _orRect = SwRect( aHoriEnvironRect.Left(),
1119cdf0e10cSrcweir aVertEnvironRect.Top(),
1120cdf0e10cSrcweir aHoriEnvironRect.Width(),
1121cdf0e10cSrcweir aVertEnvironRect.Height() );
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir else
1125cdf0e10cSrcweir {
1126cdf0e10cSrcweir if( _opRef && pFly && pFly->IsFlyInCntFrm() )
1127cdf0e10cSrcweir *_opRef = ( (SwFlyInCntFrm*)pFly )->GetRefPoint();
1128cdf0e10cSrcweir
1129cdf0e10cSrcweir _orRect = pUpper->Frm();
1130cdf0e10cSrcweir if( !pUpper->IsBodyFrm() )
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir _orRect += pUpper->Prt().Pos();
1133cdf0e10cSrcweir _orRect.SSize( pUpper->Prt().SSize() );
1134cdf0e10cSrcweir if ( pUpper->IsCellFrm() )//MA_FLY_HEIGHT
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir const SwFrm* pTab = pUpper->FindTabFrm();
1137cdf0e10cSrcweir long nBottom = (pTab->GetUpper()->*fnRect->fnGetPrtBottom)();
1138cdf0e10cSrcweir (_orRect.*fnRect->fnSetBottom)( nBottom );
1139cdf0e10cSrcweir }
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir // bei zeichengebundenen lieber nur 90% der Hoehe ausnutzen
1142cdf0e10cSrcweir {
1143cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
1144cdf0e10cSrcweir if( bVert || bVertL2R )
1145cdf0e10cSrcweir // <--
1146cdf0e10cSrcweir _orRect.Width( (_orRect.Width()*9)/10 );
1147cdf0e10cSrcweir else
1148cdf0e10cSrcweir _orRect.Height( (_orRect.Height()*9)/10 );
1149cdf0e10cSrcweir }
1150cdf0e10cSrcweir }
1151cdf0e10cSrcweir
1152cdf0e10cSrcweir const SwTwips nBaseOfstForFly = ( pFrm->IsTxtFrm() && pFly ) ?
1153cdf0e10cSrcweir ((SwTxtFrm*)pFrm)->GetBaseOfstForFly( !bWrapThrough ) :
1154cdf0e10cSrcweir 0;
1155cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
1156cdf0e10cSrcweir if( bVert || bVertL2R )
1157cdf0e10cSrcweir // <--
1158cdf0e10cSrcweir {
1159cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
1160cdf0e10cSrcweir bVertic = bVert ? true : false;
1161cdf0e10cSrcweir bVerticalL2R = bVertL2R ? true : false;
1162cdf0e10cSrcweir // <--
1163cdf0e10cSrcweir _bMirror = false;
1164cdf0e10cSrcweir
1165cdf0e10cSrcweir switch ( _eHoriRelOrient )
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir case text::RelOrientation::FRAME_RIGHT:
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir aPos.Y() += pFrm->Prt().Height();
1170cdf0e10cSrcweir aPos += (pFrm->Prt().*fnRect->fnGetPos)();
1171cdf0e10cSrcweir break;
1172cdf0e10cSrcweir }
1173cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir aPos += (pFrm->Prt().*fnRect->fnGetPos)();
1176cdf0e10cSrcweir aPos.Y() += nBaseOfstForFly;
1177cdf0e10cSrcweir break;
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir case text::RelOrientation::PAGE_RIGHT:
1180cdf0e10cSrcweir {
1181cdf0e10cSrcweir aPos.Y() = pPage->Frm().Top() + pPage->Prt().Bottom();
1182cdf0e10cSrcweir break;
1183cdf0e10cSrcweir }
1184cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA:
1185cdf0e10cSrcweir {
1186cdf0e10cSrcweir aPos.Y() = pPage->Frm().Top() + pPage->Prt().Top();
1187cdf0e10cSrcweir break;
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir case text::RelOrientation::PAGE_LEFT:
1190cdf0e10cSrcweir case text::RelOrientation::PAGE_FRAME:
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir aPos.Y() = pPage->Frm().Top();
1193cdf0e10cSrcweir break;
1194cdf0e10cSrcweir }
1195cdf0e10cSrcweir case text::RelOrientation::FRAME:
1196cdf0e10cSrcweir {
1197cdf0e10cSrcweir aPos.Y() += nBaseOfstForFly;
1198cdf0e10cSrcweir break;
1199cdf0e10cSrcweir }
1200cdf0e10cSrcweir default: break;
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir }
1203cdf0e10cSrcweir else if( _bMirror )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir switch ( _eHoriRelOrient )
1206cdf0e10cSrcweir {
1207cdf0e10cSrcweir case text::RelOrientation::FRAME_RIGHT: aPos.X() += pFrm->Prt().Left(); break;
1208cdf0e10cSrcweir case text::RelOrientation::FRAME:
1209cdf0e10cSrcweir case text::RelOrientation::FRAME_LEFT: aPos.X() += pFrm->Frm().Width(); break;
1210cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA: aPos.X() += pFrm->Prt().Right(); break;
1211cdf0e10cSrcweir case text::RelOrientation::PAGE_LEFT:
1212cdf0e10cSrcweir case text::RelOrientation::PAGE_FRAME: aPos.X() = pPage->Frm().Right(); break;
1213cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() = pPage->Frm().Left()
1214cdf0e10cSrcweir + pPage->Prt().Left(); break;
1215cdf0e10cSrcweir default: break;
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir else if ( bRTL )
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir switch ( _eHoriRelOrient )
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir case text::RelOrientation::FRAME_LEFT:
1223cdf0e10cSrcweir aPos.X() = pFrm->Frm().Left() +
1224cdf0e10cSrcweir pFrm->Prt().Left();
1225cdf0e10cSrcweir break;
1226cdf0e10cSrcweir
1227cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
1228cdf0e10cSrcweir aPos.X() = pFrm->Frm().Left() + pFrm->Prt().Left() +
1229cdf0e10cSrcweir pFrm->Prt().Width();
1230cdf0e10cSrcweir aPos.X() += nBaseOfstForFly;
1231cdf0e10cSrcweir break;
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir case text::RelOrientation::PAGE_LEFT:
1234cdf0e10cSrcweir aPos.X() = pPage->Frm().Left() + pPage->Prt().Left();
1235cdf0e10cSrcweir break;
1236cdf0e10cSrcweir
1237cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA:
1238cdf0e10cSrcweir aPos.X() = pPage->Frm().Left() + pPage->Prt().Left() +
1239cdf0e10cSrcweir pPage->Prt().Width() ;
1240cdf0e10cSrcweir break;
1241cdf0e10cSrcweir
1242cdf0e10cSrcweir case text::RelOrientation::PAGE_RIGHT:
1243cdf0e10cSrcweir case text::RelOrientation::PAGE_FRAME:
1244cdf0e10cSrcweir aPos.X() = pPage->Frm().Right();
1245cdf0e10cSrcweir break;
1246cdf0e10cSrcweir
1247cdf0e10cSrcweir case text::RelOrientation::FRAME:
1248cdf0e10cSrcweir aPos.X() += nBaseOfstForFly;
1249cdf0e10cSrcweir break;
1250cdf0e10cSrcweir default: break;
1251cdf0e10cSrcweir }
1252cdf0e10cSrcweir }
1253cdf0e10cSrcweir else
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir switch ( _eHoriRelOrient )
1256cdf0e10cSrcweir {
1257cdf0e10cSrcweir case text::RelOrientation::FRAME_RIGHT:
1258cdf0e10cSrcweir aPos.X() += pFrm->Prt().Width();
1259cdf0e10cSrcweir aPos += pFrm->Prt().Pos();
1260cdf0e10cSrcweir break;
1261cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
1262cdf0e10cSrcweir aPos += pFrm->Prt().Pos();
1263cdf0e10cSrcweir aPos.X() += nBaseOfstForFly;
1264cdf0e10cSrcweir break;
1265cdf0e10cSrcweir case text::RelOrientation::PAGE_RIGHT:
1266cdf0e10cSrcweir aPos.X() = pPage->Frm().Left() + pPage->Prt().Right();
1267cdf0e10cSrcweir break;
1268cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA:
1269cdf0e10cSrcweir aPos.X() = pPage->Frm().Left() + pPage->Prt().Left();
1270cdf0e10cSrcweir break;
1271cdf0e10cSrcweir case text::RelOrientation::PAGE_LEFT:
1272cdf0e10cSrcweir case text::RelOrientation::PAGE_FRAME:
1273cdf0e10cSrcweir aPos.X() = pPage->Frm().Left();
1274cdf0e10cSrcweir break;
1275cdf0e10cSrcweir case text::RelOrientation::FRAME:
1276cdf0e10cSrcweir aPos.X() += nBaseOfstForFly;
1277cdf0e10cSrcweir break;
1278cdf0e10cSrcweir default: break;
1279cdf0e10cSrcweir }
1280cdf0e10cSrcweir }
1281cdf0e10cSrcweir
1282cdf0e10cSrcweir }
1283cdf0e10cSrcweir if( !_opRef )
1284cdf0e10cSrcweir {
1285cdf0e10cSrcweir if( bVertic && !bVerticalL2R )
1286cdf0e10cSrcweir _orRect.Pos( aPos.X() - _orRect.Width() - _orRect.Left(), _orRect.Top() - aPos.Y() );
1287cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
1288cdf0e10cSrcweir else if( bVerticalL2R )
1289cdf0e10cSrcweir _orRect.Pos( _orRect.Left() - aPos.X(), _orRect.Top() - aPos.Y() );
1290cdf0e10cSrcweir // <--
1291cdf0e10cSrcweir else if ( bRTL )
1292cdf0e10cSrcweir _orRect.Pos( - ( _orRect.Right() - aPos.X() ), _orRect.Top() - aPos.Y() );
1293cdf0e10cSrcweir else
1294cdf0e10cSrcweir _orRect.Pos( _orRect.Left() - aPos.X(), _orRect.Top() - aPos.Y() );
1295cdf0e10cSrcweir if( _bMirror )
1296cdf0e10cSrcweir _orRect.Pos( -_orRect.Right(), _orRect.Top() );
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir }
1299cdf0e10cSrcweir
GetGraphicDefaultSize() const1300cdf0e10cSrcweir Size SwFEShell::GetGraphicDefaultSize() const
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir Size aRet;
1303cdf0e10cSrcweir SwFlyFrm *pFly = FindFlyFrm();
1304cdf0e10cSrcweir if ( pFly )
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir // --> OD 2004-09-24 #i32951# - due to issue #i28701# no format of a
1307cdf0e10cSrcweir // newly inserted Writer fly frame or its anchor frame is performed
1308cdf0e10cSrcweir // any more. Thus, it could be possible (e.g. on insert of a horizontal
1309cdf0e10cSrcweir // line) that the anchor frame isn't formatted and its printing area
1310cdf0e10cSrcweir // size is (0,0). If this is the case the printing area of the upper
1311cdf0e10cSrcweir // of the anchor frame is taken.
1312cdf0e10cSrcweir const SwFrm* pAnchorFrm = pFly->GetAnchorFrm();
1313cdf0e10cSrcweir aRet = pAnchorFrm->Prt().SSize();
1314cdf0e10cSrcweir if ( aRet.Width() == 0 && aRet.Height() == 0 &&
1315cdf0e10cSrcweir pAnchorFrm->GetUpper() )
1316cdf0e10cSrcweir {
1317cdf0e10cSrcweir aRet = pAnchorFrm->GetUpper()->Prt().SSize();
1318cdf0e10cSrcweir }
1319cdf0e10cSrcweir // <--
1320cdf0e10cSrcweir
1321cdf0e10cSrcweir SwRect aBound;
1322cdf0e10cSrcweir CalcBoundRect( aBound, pFly->GetFmt()->GetAnchor().GetAnchorId());
1323cdf0e10cSrcweir if ( pFly->GetAnchorFrm()->IsVertical() )
1324cdf0e10cSrcweir aRet.Width() = aBound.Width();
1325cdf0e10cSrcweir else
1326cdf0e10cSrcweir aRet.Height() = aBound.Height();
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir return aRet;
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir /* -----------------------------12.08.2002 12:51------------------------------
1331cdf0e10cSrcweir
1332cdf0e10cSrcweir ---------------------------------------------------------------------------*/
1333cdf0e10cSrcweir // --> OD 2009-08-31 #mongolianlayou#
1334cdf0e10cSrcweir // add output parameter <bVertL2R>
IsFrmVertical(const sal_Bool bEnvironment,sal_Bool & bRTL,sal_Bool & bVertL2R) const1335cdf0e10cSrcweir sal_Bool SwFEShell::IsFrmVertical(const sal_Bool bEnvironment, sal_Bool& bRTL, sal_Bool& bVertL2R) const
1336cdf0e10cSrcweir {
1337cdf0e10cSrcweir sal_Bool bVert = sal_False;
1338cdf0e10cSrcweir bRTL = sal_False;
1339cdf0e10cSrcweir bVertL2R = sal_False;
1340cdf0e10cSrcweir
1341cdf0e10cSrcweir if ( Imp()->HasDrawView() )
1342cdf0e10cSrcweir {
1343cdf0e10cSrcweir const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1344cdf0e10cSrcweir if( rMrkList.GetMarkCount() != 1 )
1345cdf0e10cSrcweir return bVert;
1346cdf0e10cSrcweir
1347cdf0e10cSrcweir SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
1348cdf0e10cSrcweir // --> OD 2006-01-06 #123831# - make code robust:
1349cdf0e10cSrcweir if ( !pObj )
1350cdf0e10cSrcweir {
1351cdf0e10cSrcweir ASSERT( false,
1352cdf0e10cSrcweir "<SwFEShell::IsFrmVertical(..)> - missing SdrObject instance in marked object list -> This is a serious situation, please inform OD" );
1353cdf0e10cSrcweir return bVert;
1354cdf0e10cSrcweir }
1355cdf0e10cSrcweir // <--
1356cdf0e10cSrcweir // OD 2004-03-29 #i26791#
1357cdf0e10cSrcweir SwContact* pContact = static_cast<SwContact*>(GetUserCall( pObj ));
1358cdf0e10cSrcweir // --> OD 2006-01-06 #123831# - make code robust:
1359cdf0e10cSrcweir if ( !pContact )
1360cdf0e10cSrcweir {
1361cdf0e10cSrcweir ASSERT( false,
1362cdf0e10cSrcweir "<SwFEShell::IsFrmVertical(..)> - missing SwContact instance at marked object -> This is a serious situation, please inform OD" );
1363cdf0e10cSrcweir return bVert;
1364cdf0e10cSrcweir }
1365cdf0e10cSrcweir // <--
1366cdf0e10cSrcweir const SwFrm* pRef = pContact->GetAnchoredObj( pObj )->GetAnchorFrm();
1367cdf0e10cSrcweir // --> OD 2006-01-06 #123831# - make code robust:
1368cdf0e10cSrcweir if ( !pRef )
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir ASSERT( false,
1371cdf0e10cSrcweir "<SwFEShell::IsFrmVertical(..)> - missing anchor frame at marked object -> This is a serious situation, please inform OD" );
1372cdf0e10cSrcweir return bVert;
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir // <--
1375cdf0e10cSrcweir
1376cdf0e10cSrcweir if ( pObj->ISA(SwVirtFlyDrawObj) && !bEnvironment )
1377cdf0e10cSrcweir pRef = static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrm();
1378cdf0e10cSrcweir
1379cdf0e10cSrcweir bVert = pRef->IsVertical();
1380cdf0e10cSrcweir bRTL = pRef->IsRightToLeft();
1381cdf0e10cSrcweir bVertL2R = pRef->IsVertLR();
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir
1384cdf0e10cSrcweir return bVert;
1385cdf0e10cSrcweir }
1386cdf0e10cSrcweir // <--
1387cdf0e10cSrcweir
MoveObjectIfActive(svt::EmbeddedObjectRef &,const Point &)1388cdf0e10cSrcweir void SwFEShell::MoveObjectIfActive( svt::EmbeddedObjectRef&, const Point& )
1389cdf0e10cSrcweir {
1390cdf0e10cSrcweir // does not do anything, only avoids crash if the method is used for wrong shell
1391cdf0e10cSrcweir }
1392cdf0e10cSrcweir
1393