1efeef26fSAndrew Rist /**************************************************************
2efeef26fSAndrew Rist *
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
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
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.
19efeef26fSAndrew Rist *
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 <hintids.hxx>
28cdf0e10cSrcweir #include <svl/itemiter.hxx>
29cdf0e10cSrcweir #include <svtools/imapobj.hxx>
30cdf0e10cSrcweir #include <svtools/soerr.hxx>
31cdf0e10cSrcweir #include <editeng/protitem.hxx>
32cdf0e10cSrcweir #include <svx/svdogrp.hxx>
33cdf0e10cSrcweir #include <svx/svdouno.hxx>
34cdf0e10cSrcweir #include <svx/fmglob.hxx>
35cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp>
36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
37cdf0e10cSrcweir #include <fmtanchr.hxx>
38cdf0e10cSrcweir #include <txtflcnt.hxx>
39cdf0e10cSrcweir #include <fmtcntnt.hxx>
40cdf0e10cSrcweir #include <fmtornt.hxx>
41cdf0e10cSrcweir #include <fmtflcnt.hxx>
42cdf0e10cSrcweir #include <fmturl.hxx>
43cdf0e10cSrcweir #include <fmtclds.hxx>
44cdf0e10cSrcweir #include <fmtfsize.hxx>
45cdf0e10cSrcweir #include <docary.hxx>
46cdf0e10cSrcweir #include <fesh.hxx>
47cdf0e10cSrcweir #include <rootfrm.hxx>
48cdf0e10cSrcweir #include <pagefrm.hxx>
49cdf0e10cSrcweir #include <cntfrm.hxx>
50cdf0e10cSrcweir #include <txtfrm.hxx>
51cdf0e10cSrcweir #include <viewimp.hxx>
52cdf0e10cSrcweir #include <viscrs.hxx>
53cdf0e10cSrcweir #include <doc.hxx>
54cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
55cdf0e10cSrcweir #include <dview.hxx>
56cdf0e10cSrcweir #include <dflyobj.hxx>
57cdf0e10cSrcweir #include <dcontact.hxx>
58cdf0e10cSrcweir #include <frmfmt.hxx>
59cdf0e10cSrcweir #include <flyfrm.hxx>
60cdf0e10cSrcweir #include <ndtxt.hxx>
61cdf0e10cSrcweir #include <edimp.hxx>
62cdf0e10cSrcweir #include <swtable.hxx>
63cdf0e10cSrcweir #include <mvsave.hxx> // Strukturen zum Sichern beim Move/Delete
64cdf0e10cSrcweir #include <ndgrf.hxx>
65cdf0e10cSrcweir #include <flyfrms.hxx>
66cdf0e10cSrcweir #include <flypos.hxx>
67cdf0e10cSrcweir #include <fldbas.hxx>
68cdf0e10cSrcweir #include <fmtfld.hxx>
69cdf0e10cSrcweir #include <swundo.hxx>
70cdf0e10cSrcweir #include <frame.hxx>
71cdf0e10cSrcweir #include <notxtfrm.hxx>
72cdf0e10cSrcweir // --> OD 2006-03-06 #125892#
73cdf0e10cSrcweir #include <HandleAnchorNodeChg.hxx>
74cdf0e10cSrcweir // <--
75cdf0e10cSrcweir #include <frmatr.hxx>
76cdf0e10cSrcweir // --> 3.7.2010 #i972#
77cdf0e10cSrcweir #include <ndole.hxx>
78cdf0e10cSrcweir // <--
79cdf0e10cSrcweir // --> OD 2009-12-29 #i89920#
80cdf0e10cSrcweir #include <fmtsrnd.hxx>
81cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
82cdf0e10cSrcweir // <--
83cdf0e10cSrcweir
84cdf0e10cSrcweir using ::rtl::OUString;
85cdf0e10cSrcweir using namespace ::com::sun::star;
86cdf0e10cSrcweir
87cdf0e10cSrcweir //Zum anmelden von Flys in Flys in ...
88cdf0e10cSrcweir //definiert in layout/frmtool.cxx
89cdf0e10cSrcweir void RegistFlys( SwPageFrm*, const SwLayoutFrm* );
90cdf0e10cSrcweir
91cdf0e10cSrcweir /***********************************************************************
92cdf0e10cSrcweir #* Class : SwDoc
93cdf0e10cSrcweir #* Methode : UseSpzLayoutFmt
94cdf0e10cSrcweir #* Beschreibung: Anhand des Request werden zu dem Format entsprechende
95cdf0e10cSrcweir #* Aenderungen an den Spezifischen Layouts vorgenommen.
96cdf0e10cSrcweir #* Datum : MA 23. Sep. 92
97cdf0e10cSrcweir #* Update : JP 09.03.98
98cdf0e10cSrcweir #***********************************************************************/
99cdf0e10cSrcweir
lcl_SetNewFlyPos(const SwNode & rNode,SwFmtAnchor & rAnchor,const Point & rPt)100cdf0e10cSrcweir sal_Bool lcl_SetNewFlyPos( const SwNode& rNode, SwFmtAnchor& rAnchor,
101cdf0e10cSrcweir const Point& rPt )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir sal_Bool bRet = sal_False;
104cdf0e10cSrcweir const SwStartNode* pStNode = rNode.FindFlyStartNode();
105cdf0e10cSrcweir if( pStNode )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir SwPosition aPos( *pStNode );
108cdf0e10cSrcweir rAnchor.SetAnchor( &aPos );
109cdf0e10cSrcweir bRet = sal_True;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir else
112cdf0e10cSrcweir {
113cdf0e10cSrcweir const SwCntntNode *pCntNd = rNode.GetCntntNode();
114cdf0e10cSrcweir const SwCntntFrm* pCFrm = pCntNd ? pCntNd->getLayoutFrm( pCntNd->GetDoc()->GetCurrentLayout(), &rPt, 0, sal_False ) : 0;
115cdf0e10cSrcweir const SwPageFrm *pPg = pCFrm ? pCFrm->FindPageFrm() : 0;
116cdf0e10cSrcweir
117cdf0e10cSrcweir rAnchor.SetPageNum( pPg ? pPg->GetPhyPageNum() : 1 );
118cdf0e10cSrcweir rAnchor.SetType( FLY_AT_PAGE );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir return bRet;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
lcl_FindAnchorPos(SwEditShell & rEditShell,SwDoc & rDoc,const Point & rPt,const SwFrm & rFrm,SfxItemSet & rSet)12369a74367SOliver-Rainer Wittmann sal_Bool lcl_FindAnchorPos(
12469a74367SOliver-Rainer Wittmann SwEditShell& rEditShell,
12569a74367SOliver-Rainer Wittmann SwDoc& rDoc,
12669a74367SOliver-Rainer Wittmann const Point& rPt,
12769a74367SOliver-Rainer Wittmann const SwFrm& rFrm,
12869a74367SOliver-Rainer Wittmann SfxItemSet& rSet )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir sal_Bool bRet = sal_True;
131cdf0e10cSrcweir SwFmtAnchor aNewAnch( (SwFmtAnchor&)rSet.Get( RES_ANCHOR ) );
132cdf0e10cSrcweir RndStdIds nNew = aNewAnch.GetAnchorId();
133cdf0e10cSrcweir const SwFrm *pNewAnch;
134cdf0e10cSrcweir
135cdf0e10cSrcweir //Neuen Anker ermitteln
136cdf0e10cSrcweir Point aTmpPnt( rPt );
137cdf0e10cSrcweir switch( nNew )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir case FLY_AS_CHAR: // sollte der nicht auch mit hinein?
140cdf0e10cSrcweir case FLY_AT_PARA:
141cdf0e10cSrcweir case FLY_AT_CHAR: // LAYER_IMPL
142cdf0e10cSrcweir {
143cdf0e10cSrcweir //Ausgehend von der linken oberen Ecke des Fly den
144cdf0e10cSrcweir //dichtesten CntntFrm suchen.
145cdf0e10cSrcweir const SwFrm* pFrm = rFrm.IsFlyFrm() ? ((SwFlyFrm&)rFrm).GetAnchorFrm()
146cdf0e10cSrcweir : &rFrm;
147cdf0e10cSrcweir pNewAnch = ::FindAnchor( pFrm, aTmpPnt );
148cdf0e10cSrcweir if( pNewAnch->IsProtected() )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir bRet = sal_False;
151cdf0e10cSrcweir break;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
15469a74367SOliver-Rainer Wittmann SwPosition aPos( *((SwCntntFrm*)pNewAnch)->GetNode() );
155cdf0e10cSrcweir if ((FLY_AT_CHAR == nNew) || (FLY_AS_CHAR == nNew))
15669a74367SOliver-Rainer Wittmann {
15769a74367SOliver-Rainer Wittmann // es muss ein TextNode gefunden werden, denn nur in diesen
15869a74367SOliver-Rainer Wittmann // ist ein Inhaltsgebundene Frames zu verankern
15969a74367SOliver-Rainer Wittmann SwCrsrMoveState aState( MV_SETONLYTEXT );
16069a74367SOliver-Rainer Wittmann aTmpPnt.X() -= 1; //nicht im Fly landen!!
16169a74367SOliver-Rainer Wittmann if( !pNewAnch->GetCrsrOfst( &aPos, aTmpPnt, &aState ) )
16269a74367SOliver-Rainer Wittmann {
16369a74367SOliver-Rainer Wittmann SwCntntNode* pCNd = ((SwCntntFrm*)pNewAnch)->GetNode();
16469a74367SOliver-Rainer Wittmann if( pNewAnch->Frm().Bottom() < aTmpPnt.Y() )
16569a74367SOliver-Rainer Wittmann pCNd->MakeStartIndex( &aPos.nContent );
16669a74367SOliver-Rainer Wittmann else
16769a74367SOliver-Rainer Wittmann pCNd->MakeEndIndex( &aPos.nContent );
16869a74367SOliver-Rainer Wittmann }
16969a74367SOliver-Rainer Wittmann else
17069a74367SOliver-Rainer Wittmann {
17169a74367SOliver-Rainer Wittmann if ( rEditShell.PosInsideInputFld( aPos ) )
17269a74367SOliver-Rainer Wittmann {
17369a74367SOliver-Rainer Wittmann aPos.nContent = rEditShell.StartOfInputFldAtPos( aPos );
17469a74367SOliver-Rainer Wittmann }
17569a74367SOliver-Rainer Wittmann }
17669a74367SOliver-Rainer Wittmann }
17769a74367SOliver-Rainer Wittmann aNewAnch.SetAnchor( &aPos );
17869a74367SOliver-Rainer Wittmann }
17969a74367SOliver-Rainer Wittmann break;
180cdf0e10cSrcweir
181cdf0e10cSrcweir case FLY_AT_FLY: // LAYER_IMPL
182cdf0e10cSrcweir {
183cdf0e10cSrcweir //Ausgehend von der linken oberen Ecke des Fly den
184cdf0e10cSrcweir //dichtesten SwFlyFrm suchen.
185cdf0e10cSrcweir SwCrsrMoveState aState( MV_SETONLYTEXT );
186cdf0e10cSrcweir SwPosition aPos( rDoc.GetNodes() );
187cdf0e10cSrcweir aTmpPnt.X() -= 1; //nicht im Fly landen!!
188cdf0e10cSrcweir rDoc.GetCurrentLayout()->GetCrsrOfst( &aPos, aTmpPnt, &aState ); //swmod 071108//swmod 071225
189cdf0e10cSrcweir pNewAnch = ::FindAnchor(
190cdf0e10cSrcweir aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( rFrm.getRootFrm(), 0, 0, sal_False ),
191cdf0e10cSrcweir aTmpPnt )->FindFlyFrm();
192cdf0e10cSrcweir
193cdf0e10cSrcweir if( pNewAnch && &rFrm != pNewAnch && !pNewAnch->IsProtected() )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir aPos.nNode = *((SwFlyFrm*)pNewAnch)->GetFmt()->GetCntnt().
196cdf0e10cSrcweir GetCntntIdx();
197cdf0e10cSrcweir aNewAnch.SetAnchor( &aPos );
198cdf0e10cSrcweir break;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir aNewAnch.SetType( nNew = FLY_AT_PAGE );
203cdf0e10cSrcweir // no break
204cdf0e10cSrcweir
205cdf0e10cSrcweir case FLY_AT_PAGE:
206cdf0e10cSrcweir pNewAnch = rFrm.FindPageFrm();
207cdf0e10cSrcweir aNewAnch.SetPageNum( pNewAnch->GetPhyPageNum() );
208cdf0e10cSrcweir break;
209cdf0e10cSrcweir
210cdf0e10cSrcweir default:
211cdf0e10cSrcweir ASSERT( !&rDoc, "Falsche ID fuer neuen Anker." );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir rSet.Put( aNewAnch );
215cdf0e10cSrcweir return bRet;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir //
219cdf0e10cSrcweir //! also used in unoframe.cxx
220cdf0e10cSrcweir //
lcl_ChkAndSetNewAnchor(SwEditShell & rEditShell,const SwFlyFrm & rFly,SfxItemSet & rSet)22169a74367SOliver-Rainer Wittmann sal_Bool lcl_ChkAndSetNewAnchor(
22269a74367SOliver-Rainer Wittmann SwEditShell& rEditShell,
22369a74367SOliver-Rainer Wittmann const SwFlyFrm& rFly,
22469a74367SOliver-Rainer Wittmann SfxItemSet& rSet )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir const SwFrmFmt& rFmt = *rFly.GetFmt();
227cdf0e10cSrcweir const SwFmtAnchor &rOldAnch = rFmt.GetAnchor();
228cdf0e10cSrcweir const RndStdIds nOld = rOldAnch.GetAnchorId();
229cdf0e10cSrcweir
230cdf0e10cSrcweir RndStdIds nNew = ((SwFmtAnchor&)rSet.Get( RES_ANCHOR )).GetAnchorId();
231cdf0e10cSrcweir
232cdf0e10cSrcweir if( nOld == nNew )
233cdf0e10cSrcweir return sal_False;
234cdf0e10cSrcweir
235cdf0e10cSrcweir SwDoc* pDoc = (SwDoc*)rFmt.GetDoc();
236cdf0e10cSrcweir
237cdf0e10cSrcweir #ifdef DBG_UTIL
238cdf0e10cSrcweir ASSERT( !(nNew == FLY_AT_PAGE &&
239cdf0e10cSrcweir (FLY_AT_PARA==nOld || FLY_AT_CHAR==nOld || FLY_AS_CHAR==nOld ) &&
240cdf0e10cSrcweir pDoc->IsInHeaderFooter( rOldAnch.GetCntntAnchor()->nNode )),
241cdf0e10cSrcweir "Unerlaubter Ankerwechsel in Head/Foot." );
242cdf0e10cSrcweir #endif
243cdf0e10cSrcweir
24469a74367SOliver-Rainer Wittmann return ::lcl_FindAnchorPos( rEditShell, *pDoc, rFly.Frm().Pos(), rFly, rSet );
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
SelectFlyFrm(SwFlyFrm & rFrm,sal_Bool bNew)247cdf0e10cSrcweir void SwFEShell::SelectFlyFrm( SwFlyFrm& rFrm, sal_Bool bNew )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir SET_CURR_SHELL( this );
250cdf0e10cSrcweir
251cdf0e10cSrcweir // Wenn es ein neuer Rahmen ist, so soll er selektiert sein.
252cdf0e10cSrcweir // !!Rahmen immer selektieren, wenn sie nicht selektiert sind.
253cdf0e10cSrcweir // - Es kann ein neuer 'alter' sein weil der Anker gewechselt wurde.
254cdf0e10cSrcweir // - 'alte' Rahmen sind vorher immer selektiert denn sonst wird nix
255cdf0e10cSrcweir // an ihnen veraendert.
256cdf0e10cSrcweir // Der Rahmen darf nicht per Dokumentposition selektiert werden, weil er
257cdf0e10cSrcweir // auf jedenfall selektiert sein muss!
258cdf0e10cSrcweir SwViewImp *pImpl = Imp();
259cdf0e10cSrcweir if( GetWin() && (bNew || !pImpl->GetDrawView()->AreObjectsMarked()) )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir ASSERT( rFrm.IsFlyFrm(), "SelectFlyFrm will einen Fly" );
262cdf0e10cSrcweir
263cdf0e10cSrcweir //Wenn der Fly bereits selektiert ist gibt es hier ja wohl nichts
264cdf0e10cSrcweir //zu tun.
265cdf0e10cSrcweir if ( FindFlyFrm() == &rFrm )
266cdf0e10cSrcweir return;
267cdf0e10cSrcweir
268cdf0e10cSrcweir //Damit der Anker ueberhaupt noch gepaintet wird.
269cdf0e10cSrcweir if( rFrm.IsFlyInCntFrm() && rFrm.GetAnchorFrm() )
270cdf0e10cSrcweir rFrm.GetAnchorFrm()->SetCompletePaint();
271cdf0e10cSrcweir
272cdf0e10cSrcweir // --> OD 2004-06-11 #i28701# - no format at all.
273cdf0e10cSrcweir // //Hier wurde immer kalkuliert. Leider ist der Sonderfall Fly in Fly mit
274cdf0e10cSrcweir // //Spalten u.U. sehr kritisch wenn der innenliegende zuerst formatiert
275cdf0e10cSrcweir // //wird. Um kein Risiko einzugehen entschaerfen wir nur diesen Sonderfall.
276cdf0e10cSrcweir // if( !rFrm.GetAnchorFrm()->IsInFly() )
277cdf0e10cSrcweir // rFrm.Calc();
278cdf0e10cSrcweir
279cdf0e10cSrcweir if( pImpl->GetDrawView()->AreObjectsMarked() )
280cdf0e10cSrcweir pImpl->GetDrawView()->UnmarkAll();
281cdf0e10cSrcweir
282cdf0e10cSrcweir pImpl->GetDrawView()->MarkObj( rFrm.GetVirtDrawObj(),
283cdf0e10cSrcweir pImpl->GetPageView(), sal_False, sal_False );
284cdf0e10cSrcweir KillPams();
285cdf0e10cSrcweir ClearMark();
286cdf0e10cSrcweir SelFlyGrabCrsr();
287cdf0e10cSrcweir }
288cdf0e10cSrcweir }
289cdf0e10cSrcweir
290cdf0e10cSrcweir /*************************************************************************
291cdf0e10cSrcweir |*
292cdf0e10cSrcweir |* SwFEShell::FindFlyFrm()
293cdf0e10cSrcweir |*
294cdf0e10cSrcweir |* Beschreibung Liefert den Fly wenn einer Selektiert ist.
295cdf0e10cSrcweir |* Ersterstellung MA 03. Nov. 92
296cdf0e10cSrcweir |* Letzte Aenderung MA 05. Mar. 96
297cdf0e10cSrcweir |*
298cdf0e10cSrcweir *************************************************************************/
299cdf0e10cSrcweir
FindFlyFrm() const300cdf0e10cSrcweir SwFlyFrm *SwFEShell::FindFlyFrm() const
301cdf0e10cSrcweir {
302cdf0e10cSrcweir if ( Imp()->HasDrawView() )
303cdf0e10cSrcweir {
304cdf0e10cSrcweir // Ein Fly ist genau dann erreichbar, wenn er selektiert ist.
305cdf0e10cSrcweir const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
306cdf0e10cSrcweir if( rMrkList.GetMarkCount() != 1 )
307cdf0e10cSrcweir return 0;
308cdf0e10cSrcweir
309cdf0e10cSrcweir SdrObject *pO = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
310cdf0e10cSrcweir return ( pO && pO->ISA(SwVirtFlyDrawObj) ) ? ((SwVirtFlyDrawObj*)pO)->GetFlyFrm() : 0;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir return 0;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir
315cdf0e10cSrcweir /*************************************************************************
316cdf0e10cSrcweir |*
317cdf0e10cSrcweir |* SwFEShell::IsFlyInFly()
318cdf0e10cSrcweir |*
319cdf0e10cSrcweir |* Beschreibung Liefert sal_True, wenn der aktuelle Fly an einem anderen
320cdf0e10cSrcweir |* verankert werden koennte (also innerhalb ist)
321cdf0e10cSrcweir |* Ersterstellung AMA 11. Sep. 97
322cdf0e10cSrcweir |* Letzte Aenderung AMA 14. Jan. 98
323cdf0e10cSrcweir |*
324cdf0e10cSrcweir *************************************************************************/
325cdf0e10cSrcweir
IsFlyInFly()326cdf0e10cSrcweir const SwFrmFmt* SwFEShell::IsFlyInFly()
327cdf0e10cSrcweir {
328cdf0e10cSrcweir SET_CURR_SHELL( this );
329cdf0e10cSrcweir
330cdf0e10cSrcweir if ( !Imp()->HasDrawView() )
331cdf0e10cSrcweir return NULL;
332cdf0e10cSrcweir
333cdf0e10cSrcweir const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
334cdf0e10cSrcweir if ( !rMrkList.GetMarkCount() )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
337cdf0e10cSrcweir if( !pCntnt )
338cdf0e10cSrcweir return NULL;
339cdf0e10cSrcweir SwFlyFrm *pFly = pCntnt->FindFlyFrm();
340cdf0e10cSrcweir if ( !pFly )
341cdf0e10cSrcweir return NULL;
342cdf0e10cSrcweir return pFly->GetFmt();
343cdf0e10cSrcweir }
344cdf0e10cSrcweir else if ( rMrkList.GetMarkCount() != 1 ||
345cdf0e10cSrcweir !GetUserCall(rMrkList.GetMark( 0 )->GetMarkedSdrObj()) )
346cdf0e10cSrcweir return NULL;
347cdf0e10cSrcweir
348cdf0e10cSrcweir SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
349cdf0e10cSrcweir
350cdf0e10cSrcweir SwFrmFmt *pFmt = FindFrmFmt( pObj );
351cdf0e10cSrcweir if( pFmt && FLY_AT_FLY == pFmt->GetAnchor().GetAnchorId() )
352cdf0e10cSrcweir {
353cdf0e10cSrcweir const SwFrm* pFly = pObj->ISA(SwVirtFlyDrawObj) ?
354cdf0e10cSrcweir ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetAnchorFrm() :
355cdf0e10cSrcweir ((SwDrawContact*)GetUserCall(pObj))->GetAnchorFrm( pObj );
356cdf0e10cSrcweir ASSERT( pFly, "IsFlyInFly: Where's my anchor?" );
357cdf0e10cSrcweir ASSERT( pFly->IsFlyFrm(), "IsFlyInFly: Funny anchor!" );
358cdf0e10cSrcweir return ((SwFlyFrm*)pFly)->GetFmt();
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
361cdf0e10cSrcweir Point aTmpPos = pObj->GetCurrentBoundRect().TopLeft();
362cdf0e10cSrcweir
363cdf0e10cSrcweir SwFrm *pTxtFrm;
364cdf0e10cSrcweir {
365cdf0e10cSrcweir SwCrsrMoveState aState( MV_SETONLYTEXT );
366cdf0e10cSrcweir SwNodeIndex aSwNodeIndex( GetDoc()->GetNodes() );
367cdf0e10cSrcweir SwPosition aPos( aSwNodeIndex );
368cdf0e10cSrcweir Point aPoint( aTmpPos );
369cdf0e10cSrcweir aPoint.X() -= 1; //nicht im Fly landen!!
370cdf0e10cSrcweir GetLayout()->GetCrsrOfst( &aPos, aPoint, &aState );
371cdf0e10cSrcweir // OD 01.07.2003 #108784# - determine text frame by left-top-corner
372cdf0e10cSrcweir // of object
373cdf0e10cSrcweir //pTxtFrm = aPos.nNode.GetNode().GetCntntNode()->GetFrm( 0, 0, sal_False );
374cdf0e10cSrcweir pTxtFrm = aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(), &aTmpPos, 0, sal_False );
375cdf0e10cSrcweir }
376cdf0e10cSrcweir const SwFrm *pTmp = ::FindAnchor( pTxtFrm, aTmpPos );
377cdf0e10cSrcweir const SwFlyFrm *pFly = pTmp->FindFlyFrm();
378cdf0e10cSrcweir if( pFly )
379cdf0e10cSrcweir return pFly->GetFmt();
380cdf0e10cSrcweir return NULL;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir /*************************************************************************
384cdf0e10cSrcweir |*
385cdf0e10cSrcweir |* SwFEShell::SetFlyPos
386cdf0e10cSrcweir |*
387cdf0e10cSrcweir |* Ersterstellung MA 14. Jan. 93
388cdf0e10cSrcweir |* Letzte Aenderung MA 14. Feb. 95
389cdf0e10cSrcweir |*
390cdf0e10cSrcweir *************************************************************************/
391cdf0e10cSrcweir
SetFlyPos(const Point & rAbsPos)392cdf0e10cSrcweir void SwFEShell::SetFlyPos( const Point& rAbsPos )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir SET_CURR_SHELL( this );
395cdf0e10cSrcweir
396cdf0e10cSrcweir //Bezugspunkt in Dokumentkoordinaten bestimmen
397cdf0e10cSrcweir SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
398cdf0e10cSrcweir if( !pCntnt )
399cdf0e10cSrcweir return;
400cdf0e10cSrcweir SwFlyFrm *pFly = pCntnt->FindFlyFrm();
401cdf0e10cSrcweir if ( !pFly )
402cdf0e10cSrcweir return;
403cdf0e10cSrcweir
404cdf0e10cSrcweir //SwSaveHdl aSaveX( Imp() );
405cdf0e10cSrcweir
406cdf0e10cSrcweir //Bei Absatzgebundenen Flys muss ausgehend von der absoluten
407cdf0e10cSrcweir //Position ein neuer Anker gesetzt werden. Anker und neue RelPos werden
408cdf0e10cSrcweir //vom Fly selbst berechnet und gesetzt.
409cdf0e10cSrcweir if ( pFly->IsFlyAtCntFrm() )
410cdf0e10cSrcweir ((SwFlyAtCntFrm*)pFly)->SetAbsPos( rAbsPos );
411cdf0e10cSrcweir else
412cdf0e10cSrcweir {
413cdf0e10cSrcweir const SwFrm *pAnch = pFly->GetAnchorFrm();
414cdf0e10cSrcweir // --> OD 2004-06-11 #i28701# - no format here
415cdf0e10cSrcweir // pAnch->Calc();
416cdf0e10cSrcweir Point aOrient( pAnch->Frm().Pos() );
417cdf0e10cSrcweir
418cdf0e10cSrcweir if ( pFly->IsFlyInCntFrm() )
419cdf0e10cSrcweir aOrient.X() = rAbsPos.X();
420cdf0e10cSrcweir
421cdf0e10cSrcweir //RelPos errechnen.
422cdf0e10cSrcweir aOrient.X() = rAbsPos.X() - aOrient.X();
423cdf0e10cSrcweir aOrient.Y() = rAbsPos.Y() - aOrient.Y();
424cdf0e10cSrcweir pFly->ChgRelPos( aOrient );
425cdf0e10cSrcweir }
426cdf0e10cSrcweir // --> OD 2004-06-11 #i28701# - no format here
427cdf0e10cSrcweir // pFly->Calc();
428cdf0e10cSrcweir CallChgLnk(); // rufe das AttrChangeNotify auf der UI-Seite.
429cdf0e10cSrcweir }
430cdf0e10cSrcweir
431cdf0e10cSrcweir /*************************************************************************
432cdf0e10cSrcweir |*
433cdf0e10cSrcweir |* SwFEShell::FindAnchorPos
434cdf0e10cSrcweir |*
435cdf0e10cSrcweir |* Ersterstellung AMA 24. Sep. 97
436cdf0e10cSrcweir |* Letzte Aenderung AMA 24. Sep. 97
437cdf0e10cSrcweir |*
438cdf0e10cSrcweir *************************************************************************/
439cdf0e10cSrcweir
FindAnchorPos(const Point & rAbsPos,sal_Bool bMoveIt)440cdf0e10cSrcweir Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir Point aRet;
443cdf0e10cSrcweir
444cdf0e10cSrcweir SET_CURR_SHELL( this );
445cdf0e10cSrcweir
446cdf0e10cSrcweir if ( !Imp()->HasDrawView() )
447cdf0e10cSrcweir return aRet;
448cdf0e10cSrcweir
449cdf0e10cSrcweir const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
450cdf0e10cSrcweir if ( rMrkList.GetMarkCount() != 1 ||
451cdf0e10cSrcweir !GetUserCall(rMrkList.GetMark( 0 )->GetMarkedSdrObj()) )
452cdf0e10cSrcweir return aRet;
453cdf0e10cSrcweir
454cdf0e10cSrcweir SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
455cdf0e10cSrcweir // --> OD 2004-07-16 #i28701#
456cdf0e10cSrcweir SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
457cdf0e10cSrcweir SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
45869a74367SOliver-Rainer Wittmann const RndStdIds nAnchorId = rFmt.GetAnchor().GetAnchorId();
459cdf0e10cSrcweir
460cdf0e10cSrcweir if ( FLY_AS_CHAR == nAnchorId )
461cdf0e10cSrcweir return aRet;
462cdf0e10cSrcweir
463cdf0e10cSrcweir sal_Bool bFlyFrame = pObj->ISA(SwVirtFlyDrawObj);
464cdf0e10cSrcweir
465cdf0e10cSrcweir SwFlyFrm* pFly = 0L;
466cdf0e10cSrcweir const SwFrm* pOldAnch;
467cdf0e10cSrcweir const SwFrm* pFooterOrHeader = NULL;
468cdf0e10cSrcweir
469cdf0e10cSrcweir if( bFlyFrame )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir //Bezugspunkt in Dokumentkoordinaten bestimmen
472cdf0e10cSrcweir SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
473cdf0e10cSrcweir if( !pCntnt )
474cdf0e10cSrcweir return aRet;
475cdf0e10cSrcweir pFly = pCntnt->FindFlyFrm();
476cdf0e10cSrcweir if ( !pFly )
477cdf0e10cSrcweir return aRet;
478cdf0e10cSrcweir pOldAnch = pFly->GetAnchorFrm();
479cdf0e10cSrcweir if( !pOldAnch )
480cdf0e10cSrcweir return aRet;
481cdf0e10cSrcweir if ( FLY_AT_PAGE != nAnchorId )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir pFooterOrHeader = pCntnt->FindFooterOrHeader();
484cdf0e10cSrcweir }
485cdf0e10cSrcweir }
486cdf0e10cSrcweir // OD 26.06.2003 #108784# - set <pFooterOrHeader> also for drawing
487cdf0e10cSrcweir // objects, but not for control objects.
488cdf0e10cSrcweir // Necessary for moving 'anchor symbol' at the user interface inside header/footer.
489cdf0e10cSrcweir else if ( !::CheckControlLayer( pObj ) )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
492cdf0e10cSrcweir if( !pCntnt )
493cdf0e10cSrcweir return aRet;
494cdf0e10cSrcweir pFooterOrHeader = pCntnt->FindFooterOrHeader();
495cdf0e10cSrcweir }
496cdf0e10cSrcweir
49769a74367SOliver-Rainer Wittmann SwCntntFrm *pTxtFrm = NULL;
49869a74367SOliver-Rainer Wittmann {
49969a74367SOliver-Rainer Wittmann SwCrsrMoveState aState( MV_SETONLYTEXT );
50069a74367SOliver-Rainer Wittmann SwPosition aPos( GetDoc()->GetNodes().GetEndOfExtras() );
50169a74367SOliver-Rainer Wittmann Point aTmpPnt( rAbsPos );
50269a74367SOliver-Rainer Wittmann GetLayout()->GetCrsrOfst( &aPos, aTmpPnt, &aState );
50369a74367SOliver-Rainer Wittmann if ( nAnchorId != FLY_AT_CHAR
50469a74367SOliver-Rainer Wittmann || !PosInsideInputFld( aPos ) )
50569a74367SOliver-Rainer Wittmann {
50669a74367SOliver-Rainer Wittmann pTxtFrm = aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(),0,&aPos,sal_False );
50769a74367SOliver-Rainer Wittmann }
50869a74367SOliver-Rainer Wittmann }
50969a74367SOliver-Rainer Wittmann const SwFrm *pNewAnch = NULL;
51069a74367SOliver-Rainer Wittmann if( pTxtFrm != NULL )
51169a74367SOliver-Rainer Wittmann {
512cdf0e10cSrcweir if ( FLY_AT_PAGE == nAnchorId )
513cdf0e10cSrcweir {
51469a74367SOliver-Rainer Wittmann pNewAnch = pTxtFrm->FindPageFrm();
515cdf0e10cSrcweir }
51669a74367SOliver-Rainer Wittmann else
51769a74367SOliver-Rainer Wittmann {
51869a74367SOliver-Rainer Wittmann pNewAnch = ::FindAnchor( pTxtFrm, rAbsPos );
519cdf0e10cSrcweir
52069a74367SOliver-Rainer Wittmann if( FLY_AT_FLY == nAnchorId ) // LAYER_IMPL
521cdf0e10cSrcweir {
52269a74367SOliver-Rainer Wittmann pNewAnch = pNewAnch->FindFlyFrm();
523cdf0e10cSrcweir }
52469a74367SOliver-Rainer Wittmann }
52569a74367SOliver-Rainer Wittmann }
526cdf0e10cSrcweir
527cdf0e10cSrcweir if( pNewAnch && !pNewAnch->IsProtected() )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir const SwFlyFrm* pCheck = bFlyFrame ? pNewAnch->FindFlyFrm() : 0;
530cdf0e10cSrcweir // Falls wir innerhalb eines Rahmens landen, muss sichergestellt werden,
531cdf0e10cSrcweir // dass der Rahmen nicht in seinem eigenen Inhalt landet!
532cdf0e10cSrcweir while( pCheck )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir if( pCheck == pFly )
535cdf0e10cSrcweir break;
536cdf0e10cSrcweir const SwFrm *pTmp = pCheck->GetAnchorFrm();
537cdf0e10cSrcweir pCheck = pTmp ? pTmp->FindFlyFrm() : NULL;
538cdf0e10cSrcweir }
539cdf0e10cSrcweir // Es darf nicht aus einer Kopf-/Fusszeile in einen anderen Bereich
540cdf0e10cSrcweir // gewechselt werden, es darf nicht in eine Kopf-/Fusszeile hinein-
541cdf0e10cSrcweir // gewechselt werden.
542cdf0e10cSrcweir if( !pCheck &&
543cdf0e10cSrcweir pFooterOrHeader == pNewAnch->FindFooterOrHeader() )
544cdf0e10cSrcweir {
545cdf0e10cSrcweir aRet = pNewAnch->GetFrmAnchorPos( ::HasWrap( pObj ) );
546cdf0e10cSrcweir
547cdf0e10cSrcweir if ( bMoveIt || (nAnchorId == FLY_AT_CHAR) )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir SwFmtAnchor aAnch( rFmt.GetAnchor() );
550cdf0e10cSrcweir switch ( nAnchorId )
551cdf0e10cSrcweir {
552cdf0e10cSrcweir case FLY_AT_PARA:
553cdf0e10cSrcweir {
554cdf0e10cSrcweir SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor();
555cdf0e10cSrcweir pPos->nNode = *pTxtFrm->GetNode();
556cdf0e10cSrcweir pPos->nContent.Assign(0,0);
557cdf0e10cSrcweir break;
558cdf0e10cSrcweir }
559cdf0e10cSrcweir case FLY_AT_PAGE:
560cdf0e10cSrcweir {
561cdf0e10cSrcweir aAnch.SetPageNum( ((const SwPageFrm*)pNewAnch)->
562cdf0e10cSrcweir GetPhyPageNum() );
563cdf0e10cSrcweir break;
564cdf0e10cSrcweir }
56569a74367SOliver-Rainer Wittmann
566cdf0e10cSrcweir case FLY_AT_FLY:
567cdf0e10cSrcweir {
568cdf0e10cSrcweir SwPosition aPos( *((SwFlyFrm*)pNewAnch)->GetFmt()->
569cdf0e10cSrcweir GetCntnt().GetCntntIdx() );
570cdf0e10cSrcweir aAnch.SetAnchor( &aPos );
571cdf0e10cSrcweir break;
572cdf0e10cSrcweir }
57369a74367SOliver-Rainer Wittmann
574cdf0e10cSrcweir case FLY_AT_CHAR:
57569a74367SOliver-Rainer Wittmann {
57669a74367SOliver-Rainer Wittmann SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor();
57769a74367SOliver-Rainer Wittmann Point aTmpPnt( rAbsPos );
57869a74367SOliver-Rainer Wittmann if( pTxtFrm->GetCrsrOfst( pPos, aTmpPnt, NULL ) )
57969a74367SOliver-Rainer Wittmann {
58069a74367SOliver-Rainer Wittmann SwRect aTmpRect;
58169a74367SOliver-Rainer Wittmann pTxtFrm->GetCharRect( aTmpRect, *pPos );
58269a74367SOliver-Rainer Wittmann aRet = aTmpRect.Pos();
58369a74367SOliver-Rainer Wittmann }
58469a74367SOliver-Rainer Wittmann else
58569a74367SOliver-Rainer Wittmann {
58669a74367SOliver-Rainer Wittmann pPos->nNode = *pTxtFrm->GetNode();
58769a74367SOliver-Rainer Wittmann pPos->nContent.Assign(0,0);
58869a74367SOliver-Rainer Wittmann }
58969a74367SOliver-Rainer Wittmann break;
59069a74367SOliver-Rainer Wittmann }
591cdf0e10cSrcweir default:
592cdf0e10cSrcweir break;
59369a74367SOliver-Rainer Wittmann
59469a74367SOliver-Rainer Wittmann }
59569a74367SOliver-Rainer Wittmann
59669a74367SOliver-Rainer Wittmann if( bMoveIt )
59769a74367SOliver-Rainer Wittmann {
59869a74367SOliver-Rainer Wittmann StartAllAction();
599cdf0e10cSrcweir // --> OD 2006-02-28 #125892#
600cdf0e10cSrcweir // handle change of anchor node:
601cdf0e10cSrcweir // if count of the anchor frame also change, the fly frames have to be
602cdf0e10cSrcweir // re-created. Thus, delete all fly frames except the <this> before the
603cdf0e10cSrcweir // anchor attribute is change and re-create them afterwards.
604cdf0e10cSrcweir {
605cdf0e10cSrcweir SwHandleAnchorNodeChg* pHandleAnchorNodeChg( 0L );
606cdf0e10cSrcweir SwFlyFrmFmt* pFlyFrmFmt( dynamic_cast<SwFlyFrmFmt*>(&rFmt) );
607cdf0e10cSrcweir if ( pFlyFrmFmt )
608cdf0e10cSrcweir {
609cdf0e10cSrcweir pHandleAnchorNodeChg =
610cdf0e10cSrcweir new SwHandleAnchorNodeChg( *pFlyFrmFmt, aAnch );
611cdf0e10cSrcweir }
612cdf0e10cSrcweir rFmt.GetDoc()->SetAttr( aAnch, rFmt );
613cdf0e10cSrcweir delete pHandleAnchorNodeChg;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir // <--
616cdf0e10cSrcweir // --> OD 2004-06-24 #i28701# - no call of method
617cdf0e10cSrcweir // <CheckCharRectAndTopOfLine()> for to-character anchored
618cdf0e10cSrcweir // Writer fly frame needed. This method call can cause a
619cdf0e10cSrcweir // format of the anchor frame, which is no longer intended.
620cdf0e10cSrcweir // Instead clear the anchor character rectangle and
621cdf0e10cSrcweir // the top of line values for all to-character anchored objects.
622cdf0e10cSrcweir pAnchoredObj->ClearCharRectAndTopOfLine();
623cdf0e10cSrcweir // <--
624cdf0e10cSrcweir EndAllAction();
625cdf0e10cSrcweir }
626cdf0e10cSrcweir }
627cdf0e10cSrcweir
628cdf0e10cSrcweir SwRect aTmpRect( aRet, rAbsPos );
629cdf0e10cSrcweir if( aTmpRect.HasArea() )
630cdf0e10cSrcweir MakeVisible( aTmpRect );
631cdf0e10cSrcweir #ifdef DBG_UTIL
632cdf0e10cSrcweir //TODO: That doesn't seem to be intended
633cdf0e10cSrcweir if( Color(COL_TRANSPARENT) != GetOut()->GetLineColor() )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir ASSERT( sal_False, "Hey, Joe: Where's my Null Pen?" );
636cdf0e10cSrcweir GetOut()->SetLineColor( Color(COL_TRANSPARENT) );
637cdf0e10cSrcweir }
638cdf0e10cSrcweir #endif
639cdf0e10cSrcweir }
640cdf0e10cSrcweir }
641cdf0e10cSrcweir
642cdf0e10cSrcweir return aRet;
643cdf0e10cSrcweir }
644cdf0e10cSrcweir
645cdf0e10cSrcweir /***********************************************************************
646cdf0e10cSrcweir #* Class : SwFEShell
647cdf0e10cSrcweir #* Methode : NewFlyFrm
648cdf0e10cSrcweir #* Beschreibung:
649cdf0e10cSrcweir #* Datum : MA 03. Nov. 92
650cdf0e10cSrcweir #* Update : JP 11. Aug. 93
651cdf0e10cSrcweir #***********************************************************************/
652cdf0e10cSrcweir
NewFlyFrm(const SfxItemSet & rSet,sal_Bool bAnchValid,SwFrmFmt * pParent)653cdf0e10cSrcweir const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchValid,
654cdf0e10cSrcweir SwFrmFmt *pParent )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir SET_CURR_SHELL( this );
657cdf0e10cSrcweir StartAllAction();
658cdf0e10cSrcweir
659cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
660cdf0e10cSrcweir const Point aPt( GetCrsrDocPos() );
661cdf0e10cSrcweir
662cdf0e10cSrcweir SwSelBoxes aBoxes;
663cdf0e10cSrcweir sal_Bool bMoveCntnt = sal_True;
664cdf0e10cSrcweir if( IsTableMode() )
665cdf0e10cSrcweir {
666cdf0e10cSrcweir GetTblSel( *this, aBoxes );
667cdf0e10cSrcweir if( aBoxes.Count() )
668cdf0e10cSrcweir {
669cdf0e10cSrcweir // die Crsr muessen noch aus dem Loeschbereich entfernt
670cdf0e10cSrcweir // werden. Setze sie immer hinter/auf die Tabelle; ueber die
671cdf0e10cSrcweir // Dokument-Position werden sie dann immer an die alte
672cdf0e10cSrcweir // Position gesetzt.
673cdf0e10cSrcweir ParkCrsr( SwNodeIndex( *aBoxes[0]->GetSttNd() ));
674cdf0e10cSrcweir
675cdf0e10cSrcweir // --> FME 2005-12-01 #i127787# pCurCrsr will be deleted in ParkCrsr,
676cdf0e10cSrcweir // we better get the current pCurCrsr instead of working with the
677cdf0e10cSrcweir // deleted one:
678cdf0e10cSrcweir pCrsr = GetCrsr();
679cdf0e10cSrcweir // <--
680cdf0e10cSrcweir
681cdf0e10cSrcweir // KillPams();
682cdf0e10cSrcweir }
683cdf0e10cSrcweir else
684cdf0e10cSrcweir bMoveCntnt = sal_False;
685cdf0e10cSrcweir }
686cdf0e10cSrcweir else if( !pCrsr->HasMark() && pCrsr->GetNext() == pCrsr )
687cdf0e10cSrcweir bMoveCntnt = sal_False;
688cdf0e10cSrcweir
689cdf0e10cSrcweir const SwPosition& rPos = *pCrsr->Start();
690cdf0e10cSrcweir
691cdf0e10cSrcweir SwFmtAnchor& rAnch = (SwFmtAnchor&)rSet.Get( RES_ANCHOR );
692cdf0e10cSrcweir RndStdIds eRndId = rAnch.GetAnchorId();
693cdf0e10cSrcweir switch( eRndId )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir case FLY_AT_PAGE:
696cdf0e10cSrcweir if( !rAnch.GetPageNum() ) //HotFix: Bug in UpdateByExample
697cdf0e10cSrcweir rAnch.SetPageNum( 1 );
698cdf0e10cSrcweir break;
699cdf0e10cSrcweir
700cdf0e10cSrcweir case FLY_AT_FLY:
701cdf0e10cSrcweir case FLY_AT_PARA:
702cdf0e10cSrcweir case FLY_AT_CHAR:
703cdf0e10cSrcweir case FLY_AS_CHAR:
704cdf0e10cSrcweir if( !bAnchValid )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir if( FLY_AT_FLY != eRndId )
707cdf0e10cSrcweir {
708cdf0e10cSrcweir rAnch.SetAnchor( &rPos );
709cdf0e10cSrcweir }
710cdf0e10cSrcweir else if( lcl_SetNewFlyPos( rPos.nNode.GetNode(), rAnch, aPt ) )
711cdf0e10cSrcweir {
712cdf0e10cSrcweir eRndId = FLY_AT_PAGE;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir }
715cdf0e10cSrcweir break;
716cdf0e10cSrcweir
717cdf0e10cSrcweir default:
718cdf0e10cSrcweir ASSERT( !this, "Was sollte das fuer ein Fly werden?" )
719cdf0e10cSrcweir break;
720cdf0e10cSrcweir }
721cdf0e10cSrcweir
722cdf0e10cSrcweir SwFlyFrmFmt *pRet;
723cdf0e10cSrcweir if( bMoveCntnt )
724cdf0e10cSrcweir {
725cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_INSLAYFMT, NULL );
726cdf0e10cSrcweir SwFmtAnchor* pOldAnchor = 0;
727cdf0e10cSrcweir sal_Bool bHOriChgd = sal_False, bVOriChgd = sal_False;
728cdf0e10cSrcweir SwFmtVertOrient aOldV;
729cdf0e10cSrcweir SwFmtHoriOrient aOldH;
730cdf0e10cSrcweir
731cdf0e10cSrcweir if ( FLY_AT_PAGE != eRndId )
732cdf0e10cSrcweir {
733cdf0e10cSrcweir // erstmal als mit Seitenbindung, Absatz/Zeichenbindung erst wenn
734cdf0e10cSrcweir // alles verschoben ist. Dann ist die Position gueltig!
735cdf0e10cSrcweir // JP 13.05.98: ggfs. auch noch die Hori/Vert-Orientierung
736cdf0e10cSrcweir // umsetzen, damit diese beim Umanker NICHT
737cdf0e10cSrcweir // korrigiert wird
738cdf0e10cSrcweir pOldAnchor = new SwFmtAnchor( rAnch );
739cdf0e10cSrcweir const_cast<SfxItemSet&>(rSet).Put( SwFmtAnchor( FLY_AT_PAGE, 1 ) );
740cdf0e10cSrcweir
741cdf0e10cSrcweir const SfxPoolItem* pItem;
742cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( RES_HORI_ORIENT, sal_False, &pItem )
743cdf0e10cSrcweir && text::HoriOrientation::NONE == ((SwFmtHoriOrient*)pItem)->GetHoriOrient() )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir bHOriChgd = sal_True;
746cdf0e10cSrcweir aOldH = *((SwFmtHoriOrient*)pItem);
747cdf0e10cSrcweir ((SfxItemSet&)rSet).Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT ) );
748cdf0e10cSrcweir }
749cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( RES_VERT_ORIENT, sal_False, &pItem )
750cdf0e10cSrcweir && text::VertOrientation::NONE == ((SwFmtVertOrient*)pItem)->GetVertOrient() )
751cdf0e10cSrcweir {
752cdf0e10cSrcweir bVOriChgd = sal_True;
753cdf0e10cSrcweir aOldV = *((SwFmtVertOrient*)pItem);
754cdf0e10cSrcweir ((SfxItemSet&)rSet).Put( SwFmtVertOrient( 0, text::VertOrientation::TOP ) );
755cdf0e10cSrcweir }
756cdf0e10cSrcweir }
757cdf0e10cSrcweir
758cdf0e10cSrcweir pRet = GetDoc()->MakeFlyAndMove( *pCrsr, rSet, &aBoxes, pParent );
759cdf0e10cSrcweir
760cdf0e10cSrcweir KillPams();
761cdf0e10cSrcweir
762cdf0e10cSrcweir if( pOldAnchor )
763cdf0e10cSrcweir {
764cdf0e10cSrcweir if( pRet )
765cdf0e10cSrcweir {
766cdf0e10cSrcweir // neue Position bestimmen
767cdf0e10cSrcweir //JP 24.03.97: immer ueber die Seitenbindung gehen - der
768cdf0e10cSrcweir // chaos::Anchor darf nie im verschobenen Bereich
769cdf0e10cSrcweir // liegen
770cdf0e10cSrcweir pRet->DelFrms();
771cdf0e10cSrcweir
772cdf0e10cSrcweir const SwFrm* pAnch = ::FindAnchor( GetLayout(), aPt, sal_False );
773cdf0e10cSrcweir SwPosition aPos( *((SwCntntFrm*)pAnch)->GetNode() );
774cdf0e10cSrcweir if ( FLY_AS_CHAR == eRndId )
775cdf0e10cSrcweir {
776cdf0e10cSrcweir aPos.nContent.Assign( ((SwCntntFrm*)pAnch)->GetNode(), 0 );
777cdf0e10cSrcweir }
778cdf0e10cSrcweir pOldAnchor->SetAnchor( &aPos );
779cdf0e10cSrcweir
780cdf0e10cSrcweir // das verschieben von TabelleSelektion ist noch nicht
781cdf0e10cSrcweir // Undofaehig - also darf das UmAnkern auch nicht
782cdf0e10cSrcweir // aufgezeichnet werden.
783cdf0e10cSrcweir bool const bDoesUndo =
784cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().DoesUndo();
785cdf0e10cSrcweir SwUndoId nLastUndoId(UNDO_EMPTY);
786cdf0e10cSrcweir if (bDoesUndo &&
787cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(0,
788cdf0e10cSrcweir & nLastUndoId))
789cdf0e10cSrcweir {
790cdf0e10cSrcweir if (UNDO_INSLAYFMT == nLastUndoId)
791cdf0e10cSrcweir {
792cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().DoUndo(false);
793cdf0e10cSrcweir }
794cdf0e10cSrcweir }
795cdf0e10cSrcweir
796cdf0e10cSrcweir ((SfxItemSet&)rSet).Put( *pOldAnchor );
797cdf0e10cSrcweir
798cdf0e10cSrcweir if( bHOriChgd )
799cdf0e10cSrcweir ((SfxItemSet&)rSet).Put( aOldH );
800cdf0e10cSrcweir if( bVOriChgd )
801cdf0e10cSrcweir ((SfxItemSet&)rSet).Put( aOldV );
802cdf0e10cSrcweir
803cdf0e10cSrcweir GetDoc()->SetFlyFrmAttr( *pRet, (SfxItemSet&)rSet );
804cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().DoUndo(bDoesUndo);
805cdf0e10cSrcweir }
806cdf0e10cSrcweir delete pOldAnchor;
807cdf0e10cSrcweir }
808cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_INSLAYFMT, NULL );
809cdf0e10cSrcweir }
810cdf0e10cSrcweir else
811cdf0e10cSrcweir /* #109161# If called from a shell try to propagate an
812cdf0e10cSrcweir existing adjust item from rPos to the content node of the
813cdf0e10cSrcweir new frame. */
814cdf0e10cSrcweir pRet = GetDoc()->MakeFlySection( eRndId, &rPos, &rSet, pParent, sal_True );
815cdf0e10cSrcweir
816cdf0e10cSrcweir if( pRet )
817cdf0e10cSrcweir {
818cdf0e10cSrcweir SwFlyFrm* pFrm = pRet->GetFrm( &aPt );
819cdf0e10cSrcweir if( pFrm )
820cdf0e10cSrcweir SelectFlyFrm( *pFrm, sal_True );
821cdf0e10cSrcweir else
822cdf0e10cSrcweir {
823cdf0e10cSrcweir GetLayout()->SetAssertFlyPages();
824cdf0e10cSrcweir pRet = 0;
825cdf0e10cSrcweir }
826cdf0e10cSrcweir }
827cdf0e10cSrcweir EndAllActionAndCall();
828cdf0e10cSrcweir
829cdf0e10cSrcweir return pRet;
830cdf0e10cSrcweir }
831cdf0e10cSrcweir
832cdf0e10cSrcweir /***********************************************************************
833cdf0e10cSrcweir #* Class : SwFEShell
834cdf0e10cSrcweir #* Methode : Insert
835cdf0e10cSrcweir #* Datum : ??
836cdf0e10cSrcweir #* Update : MA 12. Sep. 94
837cdf0e10cSrcweir #***********************************************************************/
838cdf0e10cSrcweir
Insert(const String & rGrfName,const String & rFltName,const Graphic * pGraphic,const SfxItemSet * pFlyAttrSet,const SfxItemSet * pGrfAttrSet,SwFrmFmt * pFrmFmt)839cdf0e10cSrcweir void SwFEShell::Insert( const String& rGrfName, const String& rFltName,
840cdf0e10cSrcweir const Graphic* pGraphic,
841cdf0e10cSrcweir const SfxItemSet* pFlyAttrSet,
842cdf0e10cSrcweir const SfxItemSet* pGrfAttrSet,
843cdf0e10cSrcweir SwFrmFmt* pFrmFmt )
844cdf0e10cSrcweir {
845cdf0e10cSrcweir SwFlyFrmFmt* pFmt = 0;
846cdf0e10cSrcweir SET_CURR_SHELL( this );
847cdf0e10cSrcweir StartAllAction();
848cdf0e10cSrcweir SwShellCrsr *pStartCursor = dynamic_cast<SwShellCrsr*>(this->GetSwCrsr());
849cdf0e10cSrcweir SwShellCrsr *pCursor = pStartCursor;
850cdf0e10cSrcweir do {
851cdf0e10cSrcweir
852cdf0e10cSrcweir // Anker noch nicht oder unvollstaendig gesetzt ?
853cdf0e10cSrcweir if( pFlyAttrSet )
854cdf0e10cSrcweir {
855cdf0e10cSrcweir const SfxPoolItem* pItem;
856cdf0e10cSrcweir if( SFX_ITEM_SET == pFlyAttrSet->GetItemState( RES_ANCHOR, sal_False,
857cdf0e10cSrcweir &pItem ) )
858cdf0e10cSrcweir {
859cdf0e10cSrcweir SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem;
860cdf0e10cSrcweir switch( pAnchor->GetAnchorId())
861cdf0e10cSrcweir {
862cdf0e10cSrcweir case FLY_AT_PARA:
863cdf0e10cSrcweir case FLY_AT_CHAR: // LAYER_IMPL
864cdf0e10cSrcweir case FLY_AS_CHAR:
865cdf0e10cSrcweir if( !pAnchor->GetCntntAnchor() )
866cdf0e10cSrcweir {
867cdf0e10cSrcweir pAnchor->SetAnchor( pCursor->GetPoint() );
868cdf0e10cSrcweir }
869cdf0e10cSrcweir break;
870cdf0e10cSrcweir case FLY_AT_FLY:
871cdf0e10cSrcweir if( !pAnchor->GetCntntAnchor() )
872cdf0e10cSrcweir {
873cdf0e10cSrcweir lcl_SetNewFlyPos( *pCursor->GetNode(),
874cdf0e10cSrcweir *pAnchor, GetCrsrDocPos() );
875cdf0e10cSrcweir }
876cdf0e10cSrcweir break;
877cdf0e10cSrcweir case FLY_AT_PAGE:
878cdf0e10cSrcweir if( !pAnchor->GetPageNum() )
879cdf0e10cSrcweir {
880cdf0e10cSrcweir pAnchor->SetPageNum( pCursor->GetPageNum(
881cdf0e10cSrcweir sal_True, &pCursor->GetPtPos() ) );
882cdf0e10cSrcweir }
883cdf0e10cSrcweir break;
884cdf0e10cSrcweir default :
885cdf0e10cSrcweir break;
886cdf0e10cSrcweir }
887cdf0e10cSrcweir }
888cdf0e10cSrcweir }
889cdf0e10cSrcweir pFmt = GetDoc()->Insert(*pCursor, rGrfName,
890cdf0e10cSrcweir rFltName, pGraphic,
891cdf0e10cSrcweir pFlyAttrSet,
892cdf0e10cSrcweir pGrfAttrSet, pFrmFmt );
893cdf0e10cSrcweir ASSERT( pFmt, "Doc->Insert(notxt) failed." );
894cdf0e10cSrcweir
895cdf0e10cSrcweir } while( (pCursor = dynamic_cast<SwShellCrsr*>(pCursor->GetNext()))
896cdf0e10cSrcweir != pStartCursor );
897cdf0e10cSrcweir
898cdf0e10cSrcweir EndAllAction();
899cdf0e10cSrcweir
900cdf0e10cSrcweir if( pFmt )
901cdf0e10cSrcweir {
902cdf0e10cSrcweir const Point aPt( GetCrsrDocPos() );
903cdf0e10cSrcweir SwFlyFrm* pFrm = pFmt->GetFrm( &aPt );
904cdf0e10cSrcweir
905cdf0e10cSrcweir if( pFrm )
906cdf0e10cSrcweir SelectFlyFrm( *pFrm, sal_True );
907cdf0e10cSrcweir else
908cdf0e10cSrcweir GetLayout()->SetAssertFlyPages();
909cdf0e10cSrcweir }
910cdf0e10cSrcweir }
911cdf0e10cSrcweir
InsertObject(const svt::EmbeddedObjectRef & xObj,const SfxItemSet * pFlyAttrSet,const SfxItemSet * pGrfAttrSet,SwFrmFmt * pFrmFmt)912cdf0e10cSrcweir SwFlyFrmFmt* SwFEShell::InsertObject( const svt::EmbeddedObjectRef& xObj,
913cdf0e10cSrcweir const SfxItemSet* pFlyAttrSet,
914cdf0e10cSrcweir const SfxItemSet* pGrfAttrSet,
915cdf0e10cSrcweir SwFrmFmt* pFrmFmt )
916cdf0e10cSrcweir {
917cdf0e10cSrcweir SwFlyFrmFmt* pFmt = 0;
918cdf0e10cSrcweir SET_CURR_SHELL( this );
919cdf0e10cSrcweir StartAllAction();
920cdf0e10cSrcweir FOREACHPAM_START( this )
921cdf0e10cSrcweir pFmt = GetDoc()->Insert(*PCURCRSR, xObj,
922cdf0e10cSrcweir pFlyAttrSet, pGrfAttrSet, pFrmFmt );
923cdf0e10cSrcweir ASSERT( pFmt, "Doc->Insert(notxt) failed." );
924cdf0e10cSrcweir
925cdf0e10cSrcweir FOREACHPAM_END()
926cdf0e10cSrcweir EndAllAction();
927cdf0e10cSrcweir
928cdf0e10cSrcweir if( pFmt )
929cdf0e10cSrcweir {
930cdf0e10cSrcweir const Point aPt( GetCrsrDocPos() );
931cdf0e10cSrcweir SwFlyFrm* pFrm = pFmt->GetFrm( &aPt );
932cdf0e10cSrcweir
933cdf0e10cSrcweir if( pFrm )
934cdf0e10cSrcweir SelectFlyFrm( *pFrm, sal_True );
935cdf0e10cSrcweir else
936cdf0e10cSrcweir GetLayout()->SetAssertFlyPages();
937cdf0e10cSrcweir }
938cdf0e10cSrcweir
939cdf0e10cSrcweir return pFmt;
940cdf0e10cSrcweir }
941cdf0e10cSrcweir
942cdf0e10cSrcweir
InsertDrawObj(SdrObject & rDrawObj,const Point & rInsertPosition)943cdf0e10cSrcweir void SwFEShell::InsertDrawObj( SdrObject& rDrawObj,
944cdf0e10cSrcweir const Point& rInsertPosition )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir SET_CURR_SHELL( this );
947cdf0e10cSrcweir
948cdf0e10cSrcweir SfxItemSet rFlyAttrSet( GetDoc()->GetAttrPool(), aFrmFmtSetRange );
949cdf0e10cSrcweir rFlyAttrSet.Put( SwFmtAnchor( FLY_AT_PARA ));
950cdf0e10cSrcweir // --> OD 2009-12-29 #i89920#
951cdf0e10cSrcweir rFlyAttrSet.Put( SwFmtSurround( SURROUND_THROUGHT ) );
952cdf0e10cSrcweir rDrawObj.SetLayer( getIDocumentDrawModelAccess()->GetHeavenId() );
953cdf0e10cSrcweir // <--
954cdf0e10cSrcweir
955cdf0e10cSrcweir // find anchor position
956cdf0e10cSrcweir SwPaM aPam( pDoc->GetNodes() );
957cdf0e10cSrcweir {
958cdf0e10cSrcweir SwCrsrMoveState aState( MV_SETONLYTEXT );
959cdf0e10cSrcweir Point aTmpPt( rInsertPosition );
960cdf0e10cSrcweir GetLayout()->GetCrsrOfst( aPam.GetPoint(), aTmpPt, &aState );
961cdf0e10cSrcweir const SwFrm* pFrm = aPam.GetCntntNode()->getLayoutFrm( GetLayout(), 0, 0, sal_False );
962cdf0e10cSrcweir const Point aRelPos( rInsertPosition.X() - pFrm->Frm().Left(),
963cdf0e10cSrcweir rInsertPosition.Y() - pFrm->Frm().Top() );
964cdf0e10cSrcweir rDrawObj.SetRelativePos( aRelPos );
96569a74367SOliver-Rainer Wittmann ::lcl_FindAnchorPos( *this, *GetDoc(), rInsertPosition, *pFrm, rFlyAttrSet );
966cdf0e10cSrcweir }
967cdf0e10cSrcweir // insert drawing object into the document creating a new <SwDrawFrmFmt> instance
968*5222b95bSOliver-Rainer Wittmann SwDrawFrmFmt* pFmt = GetDoc()->InsertDrawObj( aPam, rDrawObj, rFlyAttrSet );
969cdf0e10cSrcweir
970cdf0e10cSrcweir // move object to visible layer
971cdf0e10cSrcweir SwContact* pContact = static_cast<SwContact*>(rDrawObj.GetUserCall());
972cdf0e10cSrcweir if ( pContact )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir pContact->MoveObjToVisibleLayer( &rDrawObj );
975cdf0e10cSrcweir }
976cdf0e10cSrcweir
977cdf0e10cSrcweir if ( pFmt )
978cdf0e10cSrcweir {
979cdf0e10cSrcweir // select drawing object
980cdf0e10cSrcweir Imp()->GetDrawView()->MarkObj( &rDrawObj, Imp()->GetPageView(),
981cdf0e10cSrcweir sal_False, sal_False );
982cdf0e10cSrcweir }
983cdf0e10cSrcweir else
984cdf0e10cSrcweir {
985cdf0e10cSrcweir GetLayout()->SetAssertFlyPages();
986cdf0e10cSrcweir }
987cdf0e10cSrcweir }
988cdf0e10cSrcweir
989cdf0e10cSrcweir /***********************************************************************
990cdf0e10cSrcweir #* Class : SwFEShell
991cdf0e10cSrcweir #* Methode : GetPageObjs
992cdf0e10cSrcweir #* Datum : ??
993cdf0e10cSrcweir #* Update : MA 11. Jan. 95
994cdf0e10cSrcweir #***********************************************************************/
995cdf0e10cSrcweir
GetPageObjs(SvPtrarr & rFillArr)996cdf0e10cSrcweir void SwFEShell::GetPageObjs( SvPtrarr& rFillArr )
997cdf0e10cSrcweir {
998cdf0e10cSrcweir if( rFillArr.Count() )
999cdf0e10cSrcweir rFillArr.Remove( 0, rFillArr.Count() );
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir const SwFrmFmt* pFmt;
1002cdf0e10cSrcweir for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir pFmt = (const SwFrmFmt*)(*pDoc->GetSpzFrmFmts())[n];
1005cdf0e10cSrcweir if (FLY_AT_PAGE == pFmt->GetAnchor().GetAnchorId())
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir rFillArr.Insert( (VoidPtr)pFmt, rFillArr.Count() );
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir
1012cdf0e10cSrcweir /***********************************************************************
1013cdf0e10cSrcweir #* Class : SwFEShell
1014cdf0e10cSrcweir #* Methode : SetPageFlysNewPage
1015cdf0e10cSrcweir #* Datum : ??
1016cdf0e10cSrcweir #* Update : MA 14. Feb. 95
1017cdf0e10cSrcweir #***********************************************************************/
1018cdf0e10cSrcweir
SetPageObjsNewPage(SvPtrarr & rFillArr,int nOffset)1019cdf0e10cSrcweir void SwFEShell::SetPageObjsNewPage( SvPtrarr& rFillArr, int nOffset )
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir if( !rFillArr.Count() || !nOffset )
1022cdf0e10cSrcweir return;
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir StartAllAction();
1025cdf0e10cSrcweir StartUndo();
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir SwFrmFmt* pFmt;
1028cdf0e10cSrcweir long nNewPage;
1029cdf0e10cSrcweir SwRootFrm* pTmpRootFrm = GetLayout();//swmod 080317
1030cdf0e10cSrcweir sal_uInt16 nMaxPage = pTmpRootFrm->GetPageNum();
1031cdf0e10cSrcweir sal_Bool bTmpAssert = sal_False;
1032cdf0e10cSrcweir for( sal_uInt16 n = 0; n < rFillArr.Count(); ++n )
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir pFmt = (SwFrmFmt*)rFillArr[n];
1035cdf0e10cSrcweir if( USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( pFmt ))
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir // FlyFmt ist noch gueltig, also behandeln
1038cdf0e10cSrcweir SwFmtAnchor aNewAnchor( pFmt->GetAnchor() );
1039cdf0e10cSrcweir if ((FLY_AT_PAGE != aNewAnchor.GetAnchorId()) ||
1040cdf0e10cSrcweir 0 >= ( nNewPage = aNewAnchor.GetPageNum() + nOffset ) )
1041cdf0e10cSrcweir // chaos::Anchor wurde veraendert oder ungueltige SeitenNummer,
1042cdf0e10cSrcweir // also nicht veraendern !!
1043cdf0e10cSrcweir continue;
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir if( sal_uInt16(nNewPage) > nMaxPage )
1046cdf0e10cSrcweir {
1047cdf0e10cSrcweir if ( RES_DRAWFRMFMT == pFmt->Which() )
1048cdf0e10cSrcweir {
1049cdf0e10cSrcweir SwContact *pCon = pFmt->FindContactObj();
1050cdf0e10cSrcweir if( pCon )
1051cdf0e10cSrcweir ((SwDrawContact*)pCon)->DisconnectFromLayout();
1052cdf0e10cSrcweir }
1053cdf0e10cSrcweir else
1054cdf0e10cSrcweir pFmt->DelFrms();
1055cdf0e10cSrcweir bTmpAssert = sal_True;
1056cdf0e10cSrcweir }
1057cdf0e10cSrcweir aNewAnchor.SetPageNum( sal_uInt16(nNewPage) );
1058cdf0e10cSrcweir pDoc->SetAttr( aNewAnchor, *pFmt );
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir
1062cdf0e10cSrcweir if( bTmpAssert )
1063cdf0e10cSrcweir pTmpRootFrm->SetAssertFlyPages();
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir EndUndo();
1066cdf0e10cSrcweir EndAllAction();
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir /***********************************************************************
1070cdf0e10cSrcweir #* Class : SwFEShell
1071cdf0e10cSrcweir #* Methode : GetFlyFrmAttr
1072cdf0e10cSrcweir #* Beschreibung: Alle Attribute in dem 'Koerbchen' werden mit den
1073cdf0e10cSrcweir #* Attributen des aktuellen FlyFrms gefuellt.
1074cdf0e10cSrcweir #* Sind Attribute nicht zu fuellen weil fehl am Platz oder
1075cdf0e10cSrcweir #* uneindeutig (Mehrfachtselektionen) so werden sie entfernt.
1076cdf0e10cSrcweir #* Datum : MA 03. Nov. 92
1077cdf0e10cSrcweir #* Update : MA 03. Feb. 94
1078cdf0e10cSrcweir #***********************************************************************/
1079cdf0e10cSrcweir
GetFlyFrmAttr(SfxItemSet & rSet) const1080cdf0e10cSrcweir sal_Bool SwFEShell::GetFlyFrmAttr( SfxItemSet &rSet ) const
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir SwFlyFrm *pFly = FindFlyFrm();
1083cdf0e10cSrcweir if ( !pFly )
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir // --> OD 2006-11-08 #139670# - make code robust
1086cdf0e10cSrcweir SwFrm* pCurrFrm( GetCurrFrm() );
1087cdf0e10cSrcweir if ( !pCurrFrm )
1088cdf0e10cSrcweir {
1089cdf0e10cSrcweir ASSERT( false,
1090cdf0e10cSrcweir "<SwFEShell::GetFlyFrmAttr(..)> - missing current frame. This is a serious defect, please inform OD." );
1091cdf0e10cSrcweir return sal_False;
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir // <--
1094cdf0e10cSrcweir pFly = GetCurrFrm()->FindFlyFrm();
1095cdf0e10cSrcweir if ( !pFly )
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir ASSERT( !this, "GetFlyFrmAttr, no Fly selected." );
1098cdf0e10cSrcweir return sal_False;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir SET_CURR_SHELL( (ViewShell*)this );
1103cdf0e10cSrcweir
1104cdf0e10cSrcweir if( !rSet.Set( pFly->GetFmt()->GetAttrSet(), sal_True ) )
1105cdf0e10cSrcweir return sal_False;
1106cdf0e10cSrcweir
1107cdf0e10cSrcweir //Und die Attribute durchschaufeln. Unerlaubte Attribute entfernen, dann
1108cdf0e10cSrcweir //alle restlichen Attribute besorgen und eintragen.
1109cdf0e10cSrcweir const SfxPoolItem* pItem;
1110cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( RES_ANCHOR, sal_False, &pItem ) )
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem;
1113cdf0e10cSrcweir RndStdIds eType = pAnchor->GetAnchorId();
1114cdf0e10cSrcweir
1115cdf0e10cSrcweir if ( FLY_AT_PAGE != eType )
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir // OD 12.11.2003 #i22341# - content anchor of anchor item is needed.
1118cdf0e10cSrcweir // Thus, don't overwrite anchor item by default contructed anchor item.
1119cdf0e10cSrcweir //rSet.Put( SwFmtAnchor( eType ) );
1120cdf0e10cSrcweir if ( FLY_AS_CHAR == eType )
1121cdf0e10cSrcweir {
1122cdf0e10cSrcweir rSet.ClearItem( RES_OPAQUE );
1123cdf0e10cSrcweir rSet.ClearItem( RES_SURROUND );
1124cdf0e10cSrcweir }
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir }
1127cdf0e10cSrcweir rSet.SetParent( pFly->GetFmt()->GetAttrSet().GetParent() );
1128cdf0e10cSrcweir //JP 11.02.97: Bug #35894#: die Attribute MUESSEN entfern werden!
1129cdf0e10cSrcweir rSet.ClearItem( RES_FILL_ORDER );
1130cdf0e10cSrcweir rSet.ClearItem( RES_CNTNT );
1131cdf0e10cSrcweir //MA: Ersteinmal entfernen (Template by example usw.)
1132cdf0e10cSrcweir rSet.ClearItem( RES_CHAIN );
1133cdf0e10cSrcweir return sal_True;
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir /***********************************************************************
1136cdf0e10cSrcweir #* Class : SwFEShell
1137cdf0e10cSrcweir #* Methode : SetFlyFrmAttr
1138cdf0e10cSrcweir #* Beschreibung: Die Attribute des aktuellen Flys aendern sich.
1139cdf0e10cSrcweir #* Datum : MA 03. Nov. 92
1140cdf0e10cSrcweir #* Update : MA 01. Aug. 95
1141cdf0e10cSrcweir #***********************************************************************/
1142cdf0e10cSrcweir
SetFlyFrmAttr(SfxItemSet & rSet)1143cdf0e10cSrcweir sal_Bool SwFEShell::SetFlyFrmAttr( SfxItemSet& rSet )
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir SET_CURR_SHELL( this );
1146cdf0e10cSrcweir sal_Bool bRet = sal_False;
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir if( rSet.Count() )
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir SwFlyFrm *pFly = FindFlyFrm();
1151cdf0e10cSrcweir if( !pFly )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir ASSERT( GetCurrFrm(), "Crsr in parking zone" );
1154cdf0e10cSrcweir pFly = GetCurrFrm()->FindFlyFrm();
1155cdf0e10cSrcweir ASSERT( pFly, "SetFlyFrmAttr, no Fly selected." );
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir if( pFly )
1158cdf0e10cSrcweir {
1159cdf0e10cSrcweir StartAllAction();
1160cdf0e10cSrcweir const Point aPt( pFly->Frm().Pos() );
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( RES_ANCHOR, sal_False ))
116369a74367SOliver-Rainer Wittmann ::lcl_ChkAndSetNewAnchor( *this, *pFly, rSet );
1164cdf0e10cSrcweir SwFlyFrmFmt* pFlyFmt = (SwFlyFrmFmt*)pFly->GetFmt();
1165cdf0e10cSrcweir
1166cdf0e10cSrcweir if( GetDoc()->SetFlyFrmAttr( *pFlyFmt, rSet ))
1167cdf0e10cSrcweir {
1168cdf0e10cSrcweir bRet = sal_True;
1169cdf0e10cSrcweir SwFlyFrm* pFrm = pFlyFmt->GetFrm( &aPt );
1170cdf0e10cSrcweir if( pFrm )
1171cdf0e10cSrcweir SelectFlyFrm( *pFrm, sal_True );
1172cdf0e10cSrcweir else
1173cdf0e10cSrcweir GetLayout()->SetAssertFlyPages();
1174cdf0e10cSrcweir }
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir EndAllActionAndCall();
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir return bRet;
1180cdf0e10cSrcweir }
1181cdf0e10cSrcweir /*-- 30.03.2004 15:05:07---------------------------------------------------
1182cdf0e10cSrcweir
1183cdf0e10cSrcweir -----------------------------------------------------------------------*/
SetDrawingAttr(SfxItemSet & rSet)1184cdf0e10cSrcweir sal_Bool SwFEShell::SetDrawingAttr( SfxItemSet& rSet )
1185cdf0e10cSrcweir {
1186cdf0e10cSrcweir sal_Bool bRet = sal_False;
1187cdf0e10cSrcweir SET_CURR_SHELL( this );
1188cdf0e10cSrcweir if ( !rSet.Count() ||
1189cdf0e10cSrcweir !Imp()->HasDrawView() )
1190cdf0e10cSrcweir return bRet;
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1193cdf0e10cSrcweir if ( rMrkList.GetMarkCount() != 1 )
1194cdf0e10cSrcweir return bRet;
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir StartUndo();
1197cdf0e10cSrcweir SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
1198cdf0e10cSrcweir SwFrmFmt *pFmt = FindFrmFmt( pObj );
1199cdf0e10cSrcweir StartAllAction();
1200cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( RES_ANCHOR, sal_False ))
1201cdf0e10cSrcweir {
1202cdf0e10cSrcweir RndStdIds nNew = ((SwFmtAnchor&)rSet.Get( RES_ANCHOR )).GetAnchorId();
1203cdf0e10cSrcweir if ( nNew != pFmt->GetAnchor().GetAnchorId() )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir ChgAnchor( nNew );
1206cdf0e10cSrcweir // --> OD 2004-06-17 #i26791# - clear anchor attribute in item set,
1207cdf0e10cSrcweir // because method <ChgAnchor(..)> takes care of it.
1208cdf0e10cSrcweir rSet.ClearItem( RES_ANCHOR );
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir }
1211cdf0e10cSrcweir
1212cdf0e10cSrcweir if( GetDoc()->SetFlyFrmAttr( *pFmt, rSet ))
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir bRet = sal_True;
1215cdf0e10cSrcweir Point aTmp;
1216cdf0e10cSrcweir SelectObj( aTmp, 0, pObj );
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir EndAllActionAndCall();
1219cdf0e10cSrcweir EndUndo();
1220cdf0e10cSrcweir return bRet;
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir
1223cdf0e10cSrcweir
1224cdf0e10cSrcweir /***********************************************************************
1225cdf0e10cSrcweir #* Class : SwFEShell
1226cdf0e10cSrcweir #* Methode : ResetFlyFrmAttr
1227cdf0e10cSrcweir #* Beschreibung: Das gewuenschte Attribut oder die im Set befindlichen
1228cdf0e10cSrcweir #* werden zurueckgesetzt.
1229cdf0e10cSrcweir #* Datum : MA 14. Mar. 97
1230cdf0e10cSrcweir #* Update : MA 14. Mar. 97
1231cdf0e10cSrcweir #***********************************************************************/
1232cdf0e10cSrcweir
ResetFlyFrmAttr(sal_uInt16 nWhich,const SfxItemSet * pSet)1233cdf0e10cSrcweir sal_Bool SwFEShell::ResetFlyFrmAttr( sal_uInt16 nWhich, const SfxItemSet* pSet )
1234cdf0e10cSrcweir {
1235cdf0e10cSrcweir sal_Bool bRet = sal_False;
1236cdf0e10cSrcweir
1237cdf0e10cSrcweir if( RES_ANCHOR != nWhich && RES_CHAIN != nWhich && RES_CNTNT != nWhich )
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir SET_CURR_SHELL( this );
1240cdf0e10cSrcweir
1241cdf0e10cSrcweir SwFlyFrm *pFly = FindFlyFrm();
1242cdf0e10cSrcweir if( !pFly )
1243cdf0e10cSrcweir {
1244cdf0e10cSrcweir ASSERT( GetCurrFrm(), "Crsr in parking zone" );
1245cdf0e10cSrcweir pFly = GetCurrFrm()->FindFlyFrm();
1246cdf0e10cSrcweir ASSERT( pFly, "SetFlyFrmAttr, no Fly selected." );
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir
1249cdf0e10cSrcweir if( pFly )
1250cdf0e10cSrcweir {
1251cdf0e10cSrcweir StartAllAction();
1252cdf0e10cSrcweir
1253cdf0e10cSrcweir if( pSet )
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir SfxItemIter aIter( *pSet );
1256cdf0e10cSrcweir const SfxPoolItem* pItem = aIter.FirstItem();
1257cdf0e10cSrcweir while( pItem )
1258cdf0e10cSrcweir {
1259cdf0e10cSrcweir if( !IsInvalidItem( pItem ) &&
1260cdf0e10cSrcweir RES_ANCHOR != ( nWhich = pItem->Which() ) &&
1261cdf0e10cSrcweir RES_CHAIN != nWhich && RES_CNTNT != nWhich )
1262cdf0e10cSrcweir pFly->GetFmt()->ResetFmtAttr( nWhich );
1263cdf0e10cSrcweir pItem = aIter.NextItem();
1264cdf0e10cSrcweir }
1265cdf0e10cSrcweir }
1266cdf0e10cSrcweir else
1267cdf0e10cSrcweir pFly->GetFmt()->ResetFmtAttr( nWhich );
1268cdf0e10cSrcweir
1269cdf0e10cSrcweir bRet = sal_True;
1270cdf0e10cSrcweir EndAllActionAndCall();
1271cdf0e10cSrcweir GetDoc()->SetModified();
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir return bRet;
1275cdf0e10cSrcweir }
1276cdf0e10cSrcweir
1277cdf0e10cSrcweir /***********************************************************************
1278cdf0e10cSrcweir #* Class : SwFEShell
1279cdf0e10cSrcweir #* Methode : GetCurFrmFmt
1280cdf0e10cSrcweir #* Beschreibung: liefert wenn Rahmen, dann Rahmenvorlage, sonst 0
1281cdf0e10cSrcweir #* Datum : ST 04. Jun. 93
1282cdf0e10cSrcweir #* Update :
1283cdf0e10cSrcweir #***********************************************************************/
1284cdf0e10cSrcweir
GetCurFrmFmt() const1285cdf0e10cSrcweir SwFrmFmt* SwFEShell::GetCurFrmFmt() const
1286cdf0e10cSrcweir {
1287cdf0e10cSrcweir SwFrmFmt* pRet = 0;
1288cdf0e10cSrcweir SwLayoutFrm *pFly = FindFlyFrm();
1289cdf0e10cSrcweir if( pFly && ( pRet = (SwFrmFmt*)pFly->GetFmt()->DerivedFrom() ) ==
1290cdf0e10cSrcweir GetDoc()->GetDfltFrmFmt() )
1291cdf0e10cSrcweir pRet = 0;
1292cdf0e10cSrcweir return pRet;
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir
1295cdf0e10cSrcweir /******************************************************************************
1296cdf0e10cSrcweir * Methode : void SwFEShell::SetFrmFmt(SwFrmFmt *pNewFmt)
1297cdf0e10cSrcweir * Beschreibung:
1298cdf0e10cSrcweir * Erstellt : OK 14.04.94 15:40
1299cdf0e10cSrcweir * Aenderung : MA 23. Apr. 97
1300cdf0e10cSrcweir ******************************************************************************/
1301cdf0e10cSrcweir
SetFrmFmt(SwFrmFmt * pNewFmt,sal_Bool bKeepOrient,Point * pDocPos)1302cdf0e10cSrcweir void SwFEShell::SetFrmFmt( SwFrmFmt *pNewFmt, sal_Bool bKeepOrient, Point* pDocPos )
1303cdf0e10cSrcweir {
1304cdf0e10cSrcweir SwFlyFrm *pFly = 0;
1305cdf0e10cSrcweir if(pDocPos)
1306cdf0e10cSrcweir {
1307cdf0e10cSrcweir const SwFrmFmt* pFmt = GetFmtFromObj( *pDocPos );
1308cdf0e10cSrcweir
1309cdf0e10cSrcweir if(PTR_CAST(SwFlyFrmFmt, pFmt))
1310cdf0e10cSrcweir pFly = ((SwFlyFrmFmt*)pFmt)->GetFrm();
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir else
1313cdf0e10cSrcweir pFly = FindFlyFrm();
1314cdf0e10cSrcweir ASSERT( pFly, "SetFrmFmt: kein Frame" );
1315cdf0e10cSrcweir if( pFly )
1316cdf0e10cSrcweir {
1317cdf0e10cSrcweir StartAllAction();
1318cdf0e10cSrcweir SET_CURR_SHELL( this );
1319cdf0e10cSrcweir
1320cdf0e10cSrcweir SwFlyFrmFmt* pFlyFmt = (SwFlyFrmFmt*)pFly->GetFmt();
1321cdf0e10cSrcweir const Point aPt( pFly->Frm().Pos() );
1322cdf0e10cSrcweir
1323cdf0e10cSrcweir SfxItemSet* pSet = 0;
1324cdf0e10cSrcweir const SfxPoolItem* pItem;
1325cdf0e10cSrcweir if( SFX_ITEM_SET == pNewFmt->GetItemState( RES_ANCHOR, sal_False, &pItem ))
1326cdf0e10cSrcweir {
1327cdf0e10cSrcweir pSet = new SfxItemSet( GetDoc()->GetAttrPool(), aFrmFmtSetRange );
1328cdf0e10cSrcweir pSet->Put( *pItem );
132969a74367SOliver-Rainer Wittmann if( !::lcl_ChkAndSetNewAnchor( *this, *pFly, *pSet ))
1330cdf0e10cSrcweir delete pSet, pSet = 0;
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir
1333cdf0e10cSrcweir if( GetDoc()->SetFrmFmtToFly( *pFlyFmt, *pNewFmt, pSet, bKeepOrient ))
1334cdf0e10cSrcweir {
1335cdf0e10cSrcweir SwFlyFrm* pFrm = pFlyFmt->GetFrm( &aPt );
1336cdf0e10cSrcweir if( pFrm )
1337cdf0e10cSrcweir SelectFlyFrm( *pFrm, sal_True );
1338cdf0e10cSrcweir else
1339cdf0e10cSrcweir GetLayout()->SetAssertFlyPages();
1340cdf0e10cSrcweir }
1341cdf0e10cSrcweir if( pSet )
1342cdf0e10cSrcweir delete pSet;
1343cdf0e10cSrcweir
1344cdf0e10cSrcweir EndAllActionAndCall();
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir }
1347cdf0e10cSrcweir
1348cdf0e10cSrcweir /*************************************************************************
1349cdf0e10cSrcweir |*
1350cdf0e10cSrcweir |* SwFEShell::GetFlyFrmFmt()
1351cdf0e10cSrcweir |*
1352cdf0e10cSrcweir |* Ersterstellung OK 23.06.93 13:15
1353cdf0e10cSrcweir |* Letzte Aenderung OK 23.06.93 13:15
1354cdf0e10cSrcweir |*
1355cdf0e10cSrcweir *************************************************************************/
1356cdf0e10cSrcweir
GetFlyFrmFmt() const1357cdf0e10cSrcweir const SwFrmFmt* SwFEShell::GetFlyFrmFmt() const
1358cdf0e10cSrcweir {
1359cdf0e10cSrcweir const SwFlyFrm* pFly = FindFlyFrm();
1360cdf0e10cSrcweir if ( !pFly )
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir SwFrm* pCurrFrm = GetCurrFrm();
1363cdf0e10cSrcweir pFly = pCurrFrm ? pCurrFrm->FindFlyFrm() : 0;
1364cdf0e10cSrcweir }
1365cdf0e10cSrcweir if( pFly )
1366cdf0e10cSrcweir return pFly->GetFmt();
1367cdf0e10cSrcweir return 0;
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir
GetFlyFrmFmt()1370cdf0e10cSrcweir SwFrmFmt* SwFEShell::GetFlyFrmFmt()
1371cdf0e10cSrcweir {
1372cdf0e10cSrcweir SwFlyFrm* pFly = FindFlyFrm();
1373cdf0e10cSrcweir if ( !pFly )
1374cdf0e10cSrcweir {
1375cdf0e10cSrcweir SwFrm* pCurrFrm = GetCurrFrm();
1376cdf0e10cSrcweir pFly = pCurrFrm ? pCurrFrm->FindFlyFrm() : 0;
1377cdf0e10cSrcweir }
1378cdf0e10cSrcweir if( pFly )
1379cdf0e10cSrcweir return pFly->GetFmt();
1380cdf0e10cSrcweir return 0;
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir
1383cdf0e10cSrcweir /*************************************************************************
1384cdf0e10cSrcweir |*
1385cdf0e10cSrcweir |* SwFEShell::GetFlyRect()
1386cdf0e10cSrcweir |*
1387cdf0e10cSrcweir |* Ersterstellung AMA 6. Mae. 97
1388cdf0e10cSrcweir |* Letzte Aenderung AMA 6. Mae. 97
1389cdf0e10cSrcweir |*
1390cdf0e10cSrcweir *************************************************************************/
1391cdf0e10cSrcweir
GetFlyRect() const1392cdf0e10cSrcweir SwRect SwFEShell::GetFlyRect() const
1393cdf0e10cSrcweir {
1394cdf0e10cSrcweir SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
1395cdf0e10cSrcweir SwFlyFrm *pFly = pCntnt ? pCntnt->FindFlyFrm() : 0;
1396cdf0e10cSrcweir if ( !pFly )
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir SwRect aRect;
1399cdf0e10cSrcweir return aRect;
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir else
1402cdf0e10cSrcweir return pFly->Frm();
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir
1405cdf0e10cSrcweir /*************************************************************************
1406cdf0e10cSrcweir |*
1407cdf0e10cSrcweir |* SwFEShell::GetObjRect()
1408cdf0e10cSrcweir |*
1409cdf0e10cSrcweir |* Ersterstellung MA 22. Aug. 93
1410cdf0e10cSrcweir |* Letzte Aenderung MA 11. Jan. 95
1411cdf0e10cSrcweir |*
1412cdf0e10cSrcweir *************************************************************************/
1413cdf0e10cSrcweir
GetObjRect() const1414cdf0e10cSrcweir SwRect SwFEShell::GetObjRect() const
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir if( Imp()->HasDrawView() )
1417cdf0e10cSrcweir return Imp()->GetDrawView()->GetAllMarkedRect();
1418cdf0e10cSrcweir else
1419cdf0e10cSrcweir {
1420cdf0e10cSrcweir SwRect aRect;
1421cdf0e10cSrcweir return aRect;
1422cdf0e10cSrcweir }
1423cdf0e10cSrcweir }
1424cdf0e10cSrcweir
SetObjRect(const SwRect & rRect)1425cdf0e10cSrcweir void SwFEShell::SetObjRect( const SwRect& rRect )
1426cdf0e10cSrcweir {
1427cdf0e10cSrcweir if ( Imp()->HasDrawView() )
1428cdf0e10cSrcweir {
1429cdf0e10cSrcweir Imp()->GetDrawView()->SetAllMarkedRect( rRect.SVRect() );
1430cdf0e10cSrcweir CallChgLnk(); // rufe das AttrChangeNotify auf der UI-Seite.
1431cdf0e10cSrcweir }
1432cdf0e10cSrcweir }
1433cdf0e10cSrcweir
1434cdf0e10cSrcweir /***********************************************************************
1435cdf0e10cSrcweir #* Class : SwFEShell
1436cdf0e10cSrcweir #* Methode : RequestObjectResize()
1437cdf0e10cSrcweir #* Datum : MA 10. Feb. 95
1438cdf0e10cSrcweir #* Update : MA 13. Jul. 95
1439cdf0e10cSrcweir #***********************************************************************/
1440cdf0e10cSrcweir
RequestObjectResize(const SwRect & rRect,const uno::Reference<embed::XEmbeddedObject> & xObj)1441cdf0e10cSrcweir Size SwFEShell::RequestObjectResize( const SwRect &rRect, const uno::Reference < embed::XEmbeddedObject >& xObj )
1442cdf0e10cSrcweir {
1443cdf0e10cSrcweir Size aResult;
1444cdf0e10cSrcweir
1445cdf0e10cSrcweir SwFlyFrm *pFly = FindFlyFrm( xObj );
1446cdf0e10cSrcweir if ( !pFly )
1447cdf0e10cSrcweir {
1448cdf0e10cSrcweir aResult = rRect.SSize();
1449cdf0e10cSrcweir return aResult;
1450cdf0e10cSrcweir }
1451cdf0e10cSrcweir
1452cdf0e10cSrcweir aResult = pFly->Prt().SSize();
1453cdf0e10cSrcweir
1454cdf0e10cSrcweir sal_Bool bPosProt = pFly->GetFmt()->GetProtect().IsPosProtected();
1455cdf0e10cSrcweir sal_Bool bSizeProt = pFly->GetFmt()->GetProtect().IsSizeProtected();
1456cdf0e10cSrcweir
1457cdf0e10cSrcweir StartAllAction();
1458cdf0e10cSrcweir
1459cdf0e10cSrcweir //MA wir lassen den Fly nicht Clippen, damit die Ole-Server mit
1460cdf0e10cSrcweir //beliebigen Wuenschen kommen koennen. Die Formatierung uebernimmt das
1461cdf0e10cSrcweir //Clippen. Die richtige Darstellung wird per Scalierung erledigt.
1462cdf0e10cSrcweir //Die Scalierung wird von SwNoTxtFrm::Format durch einen Aufruf von
1463cdf0e10cSrcweir //SwWrtShell::CalcAndSetScale() erledigt.
1464cdf0e10cSrcweir if ( rRect.SSize() != pFly->Prt().SSize() && !bSizeProt )
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir Size aSz( rRect.SSize() );
1467cdf0e10cSrcweir
1468cdf0e10cSrcweir //JP 28.02.2001: Task 74707 - ask for fly in fly with automatic size
1469cdf0e10cSrcweir //
1470cdf0e10cSrcweir const SwFrm* pAnchor;
1471cdf0e10cSrcweir const SwTxtNode* pTNd;
1472cdf0e10cSrcweir const SwpHints* pHts;
1473cdf0e10cSrcweir const SwFmtFrmSize& rFrmSz = pFly->GetFmt()->GetFrmSize();
1474cdf0e10cSrcweir if( bCheckForOLEInCaption &&
1475cdf0e10cSrcweir 0 != rFrmSz.GetWidthPercent() &&
1476cdf0e10cSrcweir 0 != (pAnchor = pFly->GetAnchorFrm()) &&
1477cdf0e10cSrcweir pAnchor->IsTxtFrm() &&
1478cdf0e10cSrcweir !pAnchor->GetNext() && !pAnchor->GetPrev() &&
1479cdf0e10cSrcweir pAnchor->GetUpper()->IsFlyFrm() &&
1480cdf0e10cSrcweir 0 != ( pTNd = ((SwTxtFrm*)pAnchor)->GetNode()->GetTxtNode()) &&
1481cdf0e10cSrcweir 0 != ( pHts = pTNd->GetpSwpHints() ))
1482cdf0e10cSrcweir {
1483cdf0e10cSrcweir // search for a sequence field:
1484cdf0e10cSrcweir const SfxPoolItem* pItem;
1485cdf0e10cSrcweir for( sal_uInt16 n = 0, nEnd = pHts->Count(); n < nEnd; ++n )
1486dec99bbdSOliver-Rainer Wittmann if( RES_TXTATR_FIELD == ( pItem = &(*pHts)[ n ]->GetAttr())->Which()
1487dec99bbdSOliver-Rainer Wittmann && TYP_SEQFLD == ((SwFmtFld*)pItem)->GetField()->GetTypeId() )
1488cdf0e10cSrcweir {
1489cdf0e10cSrcweir // sequence field found
1490cdf0e10cSrcweir SwFlyFrm* pChgFly = (SwFlyFrm*)pAnchor->GetUpper();
1491cdf0e10cSrcweir // calculate the changed size:
1492cdf0e10cSrcweir // width must change, height can change
1493cdf0e10cSrcweir Size aNewSz( aSz.Width() + pChgFly->Frm().Width() -
1494cdf0e10cSrcweir pFly->Prt().Width(), aSz.Height() );
1495cdf0e10cSrcweir
1496cdf0e10cSrcweir SwFrmFmt *pFmt = pChgFly->GetFmt();
1497cdf0e10cSrcweir SwFmtFrmSize aFrmSz( pFmt->GetFrmSize() );
1498cdf0e10cSrcweir aFrmSz.SetWidth( aNewSz.Width() );
1499cdf0e10cSrcweir if( ATT_MIN_SIZE != aFrmSz.GetHeightSizeType() )
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir aNewSz.Height() += pChgFly->Frm().Height() -
1502cdf0e10cSrcweir pFly->Prt().Height();
1503cdf0e10cSrcweir if( Abs( aNewSz.Height() - pChgFly->Frm().Height()) > 1 )
1504cdf0e10cSrcweir aFrmSz.SetHeight( aNewSz.Height() );
1505cdf0e10cSrcweir }
1506cdf0e10cSrcweir // uebers Doc fuers Undo!
1507cdf0e10cSrcweir pFmt->GetDoc()->SetAttr( aFrmSz, *pFmt );
1508cdf0e10cSrcweir break;
1509cdf0e10cSrcweir }
1510cdf0e10cSrcweir }
1511cdf0e10cSrcweir
1512cdf0e10cSrcweir // set the new Size at the fly themself
1513cdf0e10cSrcweir if ( pFly->Prt().Height() > 0 && pFly->Prt().Width() > 0 )
1514cdf0e10cSrcweir {
1515cdf0e10cSrcweir aSz.Width() += pFly->Frm().Width() - pFly->Prt().Width();
1516cdf0e10cSrcweir aSz.Height()+= pFly->Frm().Height()- pFly->Prt().Height();
1517cdf0e10cSrcweir }
1518cdf0e10cSrcweir aResult = pFly->ChgSize( aSz );
1519cdf0e10cSrcweir
1520cdf0e10cSrcweir //Wenn sich das Objekt aendert ist die Kontur hoechstwahrscheinlich daneben.
1521cdf0e10cSrcweir ASSERT( pFly->Lower()->IsNoTxtFrm(), "Request ohne NoTxt" );
1522cdf0e10cSrcweir SwNoTxtNode *pNd = ((SwCntntFrm*)pFly->Lower())->GetNode()->GetNoTxtNode();
1523cdf0e10cSrcweir ASSERT( pNd, "Request ohne Node" );
1524cdf0e10cSrcweir pNd->SetContour( 0 );
1525cdf0e10cSrcweir ClrContourCache();
1526cdf0e10cSrcweir }
1527cdf0e10cSrcweir
1528cdf0e10cSrcweir //Wenn nur die Size angepasst werden soll, so wird eine Pos mit
1529cdf0e10cSrcweir //ausgezeichneten Werten transportiert.
1530cdf0e10cSrcweir Point aPt( pFly->Prt().Pos() );
1531cdf0e10cSrcweir aPt += pFly->Frm().Pos();
1532cdf0e10cSrcweir if ( rRect.Top() != LONG_MIN && rRect.Pos() != aPt && !bPosProt )
1533cdf0e10cSrcweir {
1534cdf0e10cSrcweir aPt = rRect.Pos();
1535cdf0e10cSrcweir aPt.X() -= pFly->Prt().Left();
1536cdf0e10cSrcweir aPt.Y() -= pFly->Prt().Top();
1537cdf0e10cSrcweir //Bei Absatzgebundenen Flys muss ausgehend von der neuen Position ein
1538cdf0e10cSrcweir //neuer Anker gesetzt werden. Anker und neue RelPos werden vom Fly
1539cdf0e10cSrcweir //selbst berechnet und gesetzt.
1540cdf0e10cSrcweir if( pFly->IsFlyAtCntFrm() )
1541cdf0e10cSrcweir ((SwFlyAtCntFrm*)pFly)->SetAbsPos( aPt );
1542cdf0e10cSrcweir else
1543cdf0e10cSrcweir {
1544cdf0e10cSrcweir const SwFrmFmt *pFmt = pFly->GetFmt();
1545cdf0e10cSrcweir const SwFmtVertOrient &rVert = pFmt->GetVertOrient();
1546cdf0e10cSrcweir const SwFmtHoriOrient &rHori = pFmt->GetHoriOrient();
1547cdf0e10cSrcweir const long lXDiff = aPt.X() - pFly->Frm().Left();
1548cdf0e10cSrcweir const long lYDiff = aPt.Y() - pFly->Frm().Top();
1549cdf0e10cSrcweir const Point aTmp( rHori.GetPos() + lXDiff,
1550cdf0e10cSrcweir rVert.GetPos() + lYDiff );
1551cdf0e10cSrcweir pFly->ChgRelPos( aTmp );
1552cdf0e10cSrcweir }
1553cdf0e10cSrcweir }
1554cdf0e10cSrcweir
1555cdf0e10cSrcweir SwFlyFrmFmt *pFlyFrmFmt = pFly->GetFmt();
1556cdf0e10cSrcweir ASSERT( pFlyFrmFmt, "fly frame format missing!" );
1557cdf0e10cSrcweir if ( pFlyFrmFmt )
1558cdf0e10cSrcweir pFlyFrmFmt->SetLastFlyFrmPrtRectPos( pFly->Prt().Pos() ); //stores the value of last Prt rect
1559cdf0e10cSrcweir
1560cdf0e10cSrcweir EndAllAction();
1561cdf0e10cSrcweir
1562cdf0e10cSrcweir return aResult;
1563cdf0e10cSrcweir }
1564cdf0e10cSrcweir
1565cdf0e10cSrcweir
1566cdf0e10cSrcweir /***********************************************************************
1567cdf0e10cSrcweir #* Class : SwFEShell
1568cdf0e10cSrcweir #* Methode : WizzardFindCurFrmFmt
1569cdf0e10cSrcweir #* Datum : JP 31.07.95
1570cdf0e10cSrcweir #* Update : JP 31.07.95
1571cdf0e10cSrcweir #***********************************************************************/
1572cdf0e10cSrcweir
WizzardGetFly()1573cdf0e10cSrcweir SwFrmFmt* SwFEShell::WizzardGetFly()
1574cdf0e10cSrcweir {
1575cdf0e10cSrcweir // mal nicht uebers Layout den Fly suchen. Dann kann auch ohne gueltiges
1576cdf0e10cSrcweir // Layout ein Rahmen geloescht werden. ( z.B.: fuer die Wizard's )
1577cdf0e10cSrcweir SwSpzFrmFmts& rSpzArr = *pDoc->GetSpzFrmFmts();
1578cdf0e10cSrcweir sal_uInt16 nCnt = rSpzArr.Count();
1579cdf0e10cSrcweir if( nCnt )
1580cdf0e10cSrcweir {
1581cdf0e10cSrcweir SwNodeIndex& rCrsrNd = GetCrsr()->GetPoint()->nNode;
1582cdf0e10cSrcweir if( rCrsrNd.GetIndex() > pDoc->GetNodes().GetEndOfExtras().GetIndex() )
1583cdf0e10cSrcweir // Cusor steht im Body-Bereich!
1584cdf0e10cSrcweir return 0;
1585cdf0e10cSrcweir
1586cdf0e10cSrcweir for( sal_uInt16 n = 0; n < nCnt; ++n )
1587cdf0e10cSrcweir {
1588cdf0e10cSrcweir SwFrmFmt* pFmt = rSpzArr[ n ];
1589cdf0e10cSrcweir const SwNodeIndex* pIdx = pFmt->GetCntnt( sal_False ).GetCntntIdx();
1590cdf0e10cSrcweir SwStartNode* pSttNd;
1591cdf0e10cSrcweir if( pIdx &&
1592cdf0e10cSrcweir 0 != ( pSttNd = pIdx->GetNode().GetStartNode() ) &&
1593cdf0e10cSrcweir pSttNd->GetIndex() < rCrsrNd.GetIndex() &&
1594cdf0e10cSrcweir rCrsrNd.GetIndex() < pSttNd->EndOfSectionIndex() )
1595cdf0e10cSrcweir {
1596cdf0e10cSrcweir // gefunden: also raus damit
1597cdf0e10cSrcweir return pFmt;
1598cdf0e10cSrcweir }
1599cdf0e10cSrcweir }
1600cdf0e10cSrcweir }
1601cdf0e10cSrcweir return 0;
1602cdf0e10cSrcweir }
1603cdf0e10cSrcweir
SetFlyName(const String & rName)1604cdf0e10cSrcweir void SwFEShell::SetFlyName( const String& rName )
1605cdf0e10cSrcweir {
1606cdf0e10cSrcweir SwLayoutFrm *pFly = FindFlyFrm();
1607cdf0e10cSrcweir if( pFly )
1608cdf0e10cSrcweir GetDoc()->SetFlyName( *(SwFlyFrmFmt*)pFly->GetFmt(), rName );
1609cdf0e10cSrcweir else {
1610cdf0e10cSrcweir ASSERT( !this, "kein FlyFrame selektiert" )
1611cdf0e10cSrcweir }
1612cdf0e10cSrcweir }
1613cdf0e10cSrcweir
GetFlyName() const1614cdf0e10cSrcweir const String& SwFEShell::GetFlyName() const
1615cdf0e10cSrcweir {
1616cdf0e10cSrcweir SwLayoutFrm *pFly = FindFlyFrm();
1617cdf0e10cSrcweir if( pFly )
1618cdf0e10cSrcweir return pFly->GetFmt()->GetName();
1619cdf0e10cSrcweir
1620cdf0e10cSrcweir ASSERT( !this, "kein FlyFrame selektiert" )
1621cdf0e10cSrcweir return aEmptyStr;
1622cdf0e10cSrcweir }
1623cdf0e10cSrcweir
1624cdf0e10cSrcweir
GetOleRef() const1625cdf0e10cSrcweir const uno::Reference < embed::XEmbeddedObject > SwFEShell::GetOleRef() const
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj;
1628cdf0e10cSrcweir SwFlyFrm * pFly = FindFlyFrm();
1629cdf0e10cSrcweir if (pFly && pFly->Lower() && pFly->Lower()->IsNoTxtFrm())
1630cdf0e10cSrcweir {
1631cdf0e10cSrcweir SwOLENode *pNd = ((SwNoTxtFrm*)pFly->Lower())->GetNode()->GetOLENode();
1632cdf0e10cSrcweir if (pNd)
1633cdf0e10cSrcweir xObj = pNd->GetOLEObj().GetOleRef();
1634cdf0e10cSrcweir }
1635cdf0e10cSrcweir return xObj;
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir
1638cdf0e10cSrcweir
GetUniqueGrfName() const1639cdf0e10cSrcweir String SwFEShell::GetUniqueGrfName() const
1640cdf0e10cSrcweir {
1641cdf0e10cSrcweir return GetDoc()->GetUniqueGrfName();
1642cdf0e10cSrcweir }
1643cdf0e10cSrcweir
IsURLGrfAtPos(const Point & rPt,String * pURL,String * pTargetFrameName,String * pDescription) const1644cdf0e10cSrcweir const SwFrmFmt* SwFEShell::IsURLGrfAtPos( const Point& rPt, String* pURL,
1645cdf0e10cSrcweir String *pTargetFrameName,
1646cdf0e10cSrcweir String *pDescription ) const
1647cdf0e10cSrcweir {
1648cdf0e10cSrcweir if( !Imp()->HasDrawView() )
1649cdf0e10cSrcweir return 0;
1650cdf0e10cSrcweir
1651cdf0e10cSrcweir SdrObject* pObj;
1652cdf0e10cSrcweir SdrPageView* pPV;
1653cdf0e10cSrcweir const SwFrmFmt* pRet = 0;
1654cdf0e10cSrcweir SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
1655cdf0e10cSrcweir
1656cdf0e10cSrcweir sal_uInt16 nOld = pDView->GetHitTolerancePixel();
1657cdf0e10cSrcweir pDView->SetHitTolerancePixel( 2 );
1658cdf0e10cSrcweir
1659cdf0e10cSrcweir if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPV,SDRSEARCH_PICKMACRO ) &&
1660cdf0e10cSrcweir pObj->ISA(SwVirtFlyDrawObj) )
1661cdf0e10cSrcweir {
1662cdf0e10cSrcweir SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
1663cdf0e10cSrcweir const SwFmtURL &rURL = pFly->GetFmt()->GetURL();
1664cdf0e10cSrcweir if( rURL.GetURL().Len() || rURL.GetMap() )
1665cdf0e10cSrcweir {
1666cdf0e10cSrcweir sal_Bool bSetTargetFrameName = pTargetFrameName != 0;
1667cdf0e10cSrcweir sal_Bool bSetDescription = pDescription != 0;
1668cdf0e10cSrcweir if ( rURL.GetMap() )
1669cdf0e10cSrcweir {
1670cdf0e10cSrcweir IMapObject *pObject = pFly->GetFmt()->GetIMapObject( rPt, pFly );
1671cdf0e10cSrcweir if ( pObject && pObject->GetURL().Len() )
1672cdf0e10cSrcweir {
1673cdf0e10cSrcweir if( pURL )
1674cdf0e10cSrcweir *pURL = pObject->GetURL();
1675cdf0e10cSrcweir if ( bSetTargetFrameName && pObject->GetTarget().Len() )
1676cdf0e10cSrcweir {
1677cdf0e10cSrcweir bSetTargetFrameName = sal_False;
1678cdf0e10cSrcweir *pTargetFrameName = pObject->GetTarget();
1679cdf0e10cSrcweir }
1680cdf0e10cSrcweir if ( bSetDescription )
1681cdf0e10cSrcweir {
1682cdf0e10cSrcweir bSetDescription = sal_False;
1683cdf0e10cSrcweir *pDescription = pObject->GetAltText();
1684cdf0e10cSrcweir }
1685cdf0e10cSrcweir pRet = pFly->GetFmt();
1686cdf0e10cSrcweir }
1687cdf0e10cSrcweir }
1688cdf0e10cSrcweir else
1689cdf0e10cSrcweir {
1690cdf0e10cSrcweir if( pURL )
1691cdf0e10cSrcweir {
1692cdf0e10cSrcweir *pURL = rURL.GetURL();
1693cdf0e10cSrcweir if( rURL.IsServerMap() )
1694cdf0e10cSrcweir {
1695cdf0e10cSrcweir // dann die rel. Pixel Position anhaengen !!
1696cdf0e10cSrcweir Point aPt( rPt );
1697cdf0e10cSrcweir aPt -= pFly->Frm().Pos();
1698cdf0e10cSrcweir // ohne MapMode-Offset, ohne Offset, o ... !!!!!
1699cdf0e10cSrcweir aPt = GetOut()->LogicToPixel(
1700cdf0e10cSrcweir aPt, MapMode( MAP_TWIP ) );
1701cdf0e10cSrcweir ((( *pURL += '?' ) += String::CreateFromInt32( aPt.X() ))
1702cdf0e10cSrcweir += ',' ) += String::CreateFromInt32(aPt.Y() );
1703cdf0e10cSrcweir }
1704cdf0e10cSrcweir }
1705cdf0e10cSrcweir pRet = pFly->GetFmt();
1706cdf0e10cSrcweir }
1707cdf0e10cSrcweir if ( bSetTargetFrameName )
1708cdf0e10cSrcweir *pTargetFrameName = rURL.GetTargetFrameName();
1709cdf0e10cSrcweir if ( bSetDescription )
1710cdf0e10cSrcweir *pDescription = pFly->GetFmt()->GetName();
1711cdf0e10cSrcweir }
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir pDView->SetHitTolerancePixel( nOld );
1714cdf0e10cSrcweir return pRet;
1715cdf0e10cSrcweir }
1716cdf0e10cSrcweir
GetGrfAtPos(const Point & rPt,String & rName,sal_Bool & rbLink) const1717cdf0e10cSrcweir const Graphic *SwFEShell::GetGrfAtPos( const Point &rPt,
1718cdf0e10cSrcweir String &rName, sal_Bool &rbLink ) const
1719cdf0e10cSrcweir {
1720cdf0e10cSrcweir if( !Imp()->HasDrawView() )
1721cdf0e10cSrcweir return 0;
1722cdf0e10cSrcweir
1723cdf0e10cSrcweir SdrObject* pObj;
1724cdf0e10cSrcweir SdrPageView* pPV;
1725cdf0e10cSrcweir SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
1726cdf0e10cSrcweir
1727cdf0e10cSrcweir if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPV ) && pObj->ISA(SwVirtFlyDrawObj) )
1728cdf0e10cSrcweir {
1729cdf0e10cSrcweir SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
1730cdf0e10cSrcweir if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
1731cdf0e10cSrcweir {
1732cdf0e10cSrcweir SwGrfNode *pNd = ((SwCntntFrm*)pFly->Lower())->GetNode()->GetGrfNode();
1733cdf0e10cSrcweir if ( pNd )
1734cdf0e10cSrcweir {
1735cdf0e10cSrcweir if ( pNd->IsGrfLink() )
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir //Halbfertige Grafik?
1738cdf0e10cSrcweir ::sfx2::SvLinkSource* pLnkObj = pNd->GetLink()->GetObj();
1739cdf0e10cSrcweir if( pLnkObj && pLnkObj->IsPending() )
1740cdf0e10cSrcweir return 0;
1741cdf0e10cSrcweir rbLink = sal_True;
1742cdf0e10cSrcweir }
1743cdf0e10cSrcweir
1744cdf0e10cSrcweir pNd->GetFileFilterNms( &rName, 0 );
1745cdf0e10cSrcweir if ( !rName.Len() )
1746cdf0e10cSrcweir rName = pFly->GetFmt()->GetName();
1747cdf0e10cSrcweir pNd->SwapIn( sal_True );
1748cdf0e10cSrcweir return &pNd->GetGrf();
1749cdf0e10cSrcweir }
1750cdf0e10cSrcweir }
1751cdf0e10cSrcweir }
1752cdf0e10cSrcweir return 0;
1753cdf0e10cSrcweir }
1754cdf0e10cSrcweir
1755cdf0e10cSrcweir
GetFmtFromObj(const Point & rPt,SwRect ** pRectToFill) const1756cdf0e10cSrcweir const SwFrmFmt* SwFEShell::GetFmtFromObj( const Point& rPt, SwRect** pRectToFill ) const
1757cdf0e10cSrcweir {
1758cdf0e10cSrcweir SwFrmFmt* pRet = 0;
1759cdf0e10cSrcweir
1760cdf0e10cSrcweir if( Imp()->HasDrawView() )
1761cdf0e10cSrcweir {
1762cdf0e10cSrcweir SdrObject* pObj;
1763cdf0e10cSrcweir SdrPageView* pPView;
1764cdf0e10cSrcweir
1765cdf0e10cSrcweir SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
1766cdf0e10cSrcweir
1767cdf0e10cSrcweir sal_uInt16 nOld = pDView->GetHitTolerancePixel();
1768cdf0e10cSrcweir // Tattergrenze fuer Drawing-SS
1769cdf0e10cSrcweir pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1770cdf0e10cSrcweir
1771cdf0e10cSrcweir if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE ) )
1772cdf0e10cSrcweir {
1773cdf0e10cSrcweir // dann teste mal was es ist:
1774cdf0e10cSrcweir if ( pObj->ISA(SwVirtFlyDrawObj) )
1775cdf0e10cSrcweir pRet = ((SwVirtFlyDrawObj*)pObj)->GetFmt();
1776cdf0e10cSrcweir else if ( pObj->GetUserCall() ) //nicht fuer Gruppenobjekte
1777cdf0e10cSrcweir pRet = ((SwDrawContact*)pObj->GetUserCall())->GetFmt();
1778cdf0e10cSrcweir if(pRet && pRectToFill)
1779cdf0e10cSrcweir **pRectToFill = pObj->GetCurrentBoundRect();
1780cdf0e10cSrcweir }
1781cdf0e10cSrcweir pDView->SetHitTolerancePixel( nOld );
1782cdf0e10cSrcweir }
1783cdf0e10cSrcweir return pRet;
1784cdf0e10cSrcweir }
1785cdf0e10cSrcweir
1786cdf0e10cSrcweir // returns a format too, if the point is over the text of any fly
GetFmtFromAnyObj(const Point & rPt) const1787cdf0e10cSrcweir const SwFrmFmt* SwFEShell::GetFmtFromAnyObj( const Point& rPt ) const
1788cdf0e10cSrcweir {
1789cdf0e10cSrcweir const SwFrmFmt* pRet = GetFmtFromObj( rPt );
1790cdf0e10cSrcweir if( !pRet || RES_FLYFRMFMT == pRet->Which() )
1791cdf0e10cSrcweir {
1792cdf0e10cSrcweir SwPosition aPos( *GetCrsr()->GetPoint() );
1793cdf0e10cSrcweir Point aPt( rPt );
1794cdf0e10cSrcweir GetLayout()->GetCrsrOfst( &aPos, aPt );
1795cdf0e10cSrcweir SwCntntNode *pNd = aPos.nNode.GetNode().GetCntntNode();
1796cdf0e10cSrcweir SwFrm* pFrm = pNd->getLayoutFrm( GetLayout(), &rPt, 0, sal_False )->FindFlyFrm();
1797cdf0e10cSrcweir pRet = pFrm ? ((SwLayoutFrm*)pFrm)->GetFmt() : 0;
1798cdf0e10cSrcweir }
1799cdf0e10cSrcweir return pRet;
1800cdf0e10cSrcweir }
1801cdf0e10cSrcweir
GetObjCntType(const SdrObject & rObj) const1802cdf0e10cSrcweir ObjCntType SwFEShell::GetObjCntType( const SdrObject& rObj ) const
1803cdf0e10cSrcweir {
1804cdf0e10cSrcweir ObjCntType eType = OBJCNT_NONE;
1805cdf0e10cSrcweir
1806cdf0e10cSrcweir // OD 23.06.2003 #108784# - investigate 'master' drawing object, if method
1807cdf0e10cSrcweir // is called for a 'virtual' drawing object.
1808cdf0e10cSrcweir const SdrObject* pInvestigatedObj;
1809cdf0e10cSrcweir if ( rObj.ISA(SwDrawVirtObj) )
1810cdf0e10cSrcweir {
1811cdf0e10cSrcweir const SwDrawVirtObj* pDrawVirtObj = static_cast<const SwDrawVirtObj*>(&rObj);
1812cdf0e10cSrcweir pInvestigatedObj = &(pDrawVirtObj->GetReferencedObj());
1813cdf0e10cSrcweir }
1814cdf0e10cSrcweir else
1815cdf0e10cSrcweir {
1816cdf0e10cSrcweir pInvestigatedObj = &rObj;
1817cdf0e10cSrcweir }
1818cdf0e10cSrcweir
1819cdf0e10cSrcweir if( FmFormInventor == pInvestigatedObj->GetObjInventor() )
1820cdf0e10cSrcweir {
1821cdf0e10cSrcweir eType = OBJCNT_CONTROL;
1822cdf0e10cSrcweir uno::Reference< awt::XControlModel > xModel =
1823cdf0e10cSrcweir ((SdrUnoObj&)(*pInvestigatedObj)).GetUnoControlModel();
1824cdf0e10cSrcweir if( xModel.is() )
1825cdf0e10cSrcweir {
1826cdf0e10cSrcweir uno::Any aVal;
1827cdf0e10cSrcweir OUString sName = OUString::createFromAscii("ButtonType");
1828cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xSet(xModel, uno::UNO_QUERY);
1829cdf0e10cSrcweir
1830cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xInfo = xSet->getPropertySetInfo();
1831cdf0e10cSrcweir if(xInfo->hasPropertyByName( sName ))
1832cdf0e10cSrcweir {
1833cdf0e10cSrcweir beans::Property xProperty = xInfo->getPropertyByName( sName );
1834cdf0e10cSrcweir aVal = xSet->getPropertyValue( sName );
1835cdf0e10cSrcweir if( aVal.getValue() && form::FormButtonType_URL == *((form::FormButtonType*)aVal.getValue()) )
1836cdf0e10cSrcweir eType = OBJCNT_URLBUTTON;
1837cdf0e10cSrcweir }
1838cdf0e10cSrcweir }
1839cdf0e10cSrcweir }
1840cdf0e10cSrcweir else if( pInvestigatedObj->ISA(SwVirtFlyDrawObj) )
1841cdf0e10cSrcweir {
1842cdf0e10cSrcweir SwFlyFrm *pFly = ((SwVirtFlyDrawObj&)(*pInvestigatedObj)).GetFlyFrm();
1843cdf0e10cSrcweir if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
1844cdf0e10cSrcweir {
1845cdf0e10cSrcweir if ( ((SwCntntFrm*)pFly->Lower())->GetNode()->GetGrfNode() )
1846cdf0e10cSrcweir eType = OBJCNT_GRF;
1847cdf0e10cSrcweir else
1848cdf0e10cSrcweir eType = OBJCNT_OLE;
1849cdf0e10cSrcweir }
1850cdf0e10cSrcweir else
1851cdf0e10cSrcweir eType = OBJCNT_FLY;
1852cdf0e10cSrcweir }
1853cdf0e10cSrcweir else if ( pInvestigatedObj->ISA( SdrObjGroup ) )
1854cdf0e10cSrcweir {
1855cdf0e10cSrcweir SwDrawContact* pDrawContact( dynamic_cast<SwDrawContact*>(GetUserCall( pInvestigatedObj ) ) );
1856cdf0e10cSrcweir if ( !pDrawContact )
1857cdf0e10cSrcweir {
1858cdf0e10cSrcweir ASSERT( false,
1859cdf0e10cSrcweir "<SwFEShell::GetObjCntType(..)> - missing draw contact object" );
1860cdf0e10cSrcweir eType = OBJCNT_NONE;
1861cdf0e10cSrcweir }
1862cdf0e10cSrcweir else
1863cdf0e10cSrcweir {
1864cdf0e10cSrcweir SwFrmFmt* pFrmFmt( pDrawContact->GetFmt() );
1865cdf0e10cSrcweir if ( !pFrmFmt )
1866cdf0e10cSrcweir {
1867cdf0e10cSrcweir ASSERT( false,
1868cdf0e10cSrcweir "<SwFEShell::GetObjCntType(..)> - missing frame format" );
1869cdf0e10cSrcweir eType = OBJCNT_NONE;
1870cdf0e10cSrcweir }
1871cdf0e10cSrcweir else if ( FLY_AS_CHAR != pFrmFmt->GetAnchor().GetAnchorId() )
1872cdf0e10cSrcweir {
1873cdf0e10cSrcweir eType = OBJCNT_GROUPOBJ;
1874cdf0e10cSrcweir }
1875cdf0e10cSrcweir }
1876cdf0e10cSrcweir }
1877cdf0e10cSrcweir else
1878cdf0e10cSrcweir eType = OBJCNT_SIMPLE;
1879cdf0e10cSrcweir return eType;
1880cdf0e10cSrcweir }
1881cdf0e10cSrcweir
GetObjCntType(const Point & rPt,SdrObject * & rpObj) const1882cdf0e10cSrcweir ObjCntType SwFEShell::GetObjCntType( const Point &rPt, SdrObject *&rpObj ) const
1883cdf0e10cSrcweir {
1884cdf0e10cSrcweir ObjCntType eType = OBJCNT_NONE;
1885cdf0e10cSrcweir
1886cdf0e10cSrcweir if( Imp()->HasDrawView() )
1887cdf0e10cSrcweir {
1888cdf0e10cSrcweir SdrObject* pObj;
1889cdf0e10cSrcweir SdrPageView* pPView;
1890cdf0e10cSrcweir
1891cdf0e10cSrcweir SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
1892cdf0e10cSrcweir
1893cdf0e10cSrcweir sal_uInt16 nOld = pDView->GetHitTolerancePixel();
1894cdf0e10cSrcweir // Tattergrenze fuer Drawing-SS
1895cdf0e10cSrcweir pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1896cdf0e10cSrcweir
1897cdf0e10cSrcweir if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE ) )
1898cdf0e10cSrcweir eType = GetObjCntType( *(rpObj = pObj) );
1899cdf0e10cSrcweir
1900cdf0e10cSrcweir pDView->SetHitTolerancePixel( nOld );
1901cdf0e10cSrcweir }
1902cdf0e10cSrcweir return eType;
1903cdf0e10cSrcweir }
1904cdf0e10cSrcweir
GetObjCntTypeOfSelection(SdrObject ** ppObj) const1905cdf0e10cSrcweir ObjCntType SwFEShell::GetObjCntTypeOfSelection( SdrObject** ppObj ) const
1906cdf0e10cSrcweir {
1907cdf0e10cSrcweir ObjCntType eType = OBJCNT_NONE;
1908cdf0e10cSrcweir
1909cdf0e10cSrcweir if( Imp()->HasDrawView() )
1910cdf0e10cSrcweir {
1911cdf0e10cSrcweir const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1912cdf0e10cSrcweir for( sal_uInt32 i = 0, nE = rMrkList.GetMarkCount(); i < nE; ++i )
1913cdf0e10cSrcweir {
1914cdf0e10cSrcweir SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
1915cdf0e10cSrcweir if( !pObj )
1916cdf0e10cSrcweir continue;
1917cdf0e10cSrcweir ObjCntType eTmp = GetObjCntType( *pObj );
1918cdf0e10cSrcweir if( !i )
1919cdf0e10cSrcweir {
1920cdf0e10cSrcweir eType = eTmp;
1921cdf0e10cSrcweir if( ppObj ) *ppObj = pObj;
1922cdf0e10cSrcweir }
1923cdf0e10cSrcweir else if( eTmp != eType )
1924cdf0e10cSrcweir {
1925cdf0e10cSrcweir eType = OBJCNT_DONTCARE;
1926cdf0e10cSrcweir // einmal DontCare, immer DontCare!
1927cdf0e10cSrcweir break;
1928cdf0e10cSrcweir }
1929cdf0e10cSrcweir }
1930cdf0e10cSrcweir }
1931cdf0e10cSrcweir return eType;
1932cdf0e10cSrcweir }
1933cdf0e10cSrcweir
1934cdf0e10cSrcweir
ReplaceSdrObj(const String & rGrfName,const String & rFltName,const Graphic * pGrf)1935cdf0e10cSrcweir sal_Bool SwFEShell::ReplaceSdrObj( const String& rGrfName, const String& rFltName,
1936cdf0e10cSrcweir const Graphic* pGrf )
1937cdf0e10cSrcweir {
1938cdf0e10cSrcweir SET_CURR_SHELL( this );
1939cdf0e10cSrcweir
1940cdf0e10cSrcweir sal_Bool bRet = sal_False;
1941cdf0e10cSrcweir const SdrMarkList *pMrkList;
1942cdf0e10cSrcweir if( Imp()->HasDrawView() && 1 ==
1943cdf0e10cSrcweir ( pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList())->GetMarkCount() )
1944cdf0e10cSrcweir {
1945cdf0e10cSrcweir SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
1946cdf0e10cSrcweir SwFrmFmt *pFmt = FindFrmFmt( pObj );
1947cdf0e10cSrcweir
1948cdf0e10cSrcweir // Attribute sichern und dann an der Grafik setzen
1949cdf0e10cSrcweir SfxItemSet aFrmSet( pDoc->GetAttrPool(),
1950cdf0e10cSrcweir pFmt->GetAttrSet().GetRanges() );
1951cdf0e10cSrcweir aFrmSet.Set( pFmt->GetAttrSet() );
1952cdf0e10cSrcweir
1953cdf0e10cSrcweir // Groesse und Position setzen ??
1954cdf0e10cSrcweir if( !pObj->ISA(SwVirtFlyDrawObj) )
1955cdf0e10cSrcweir {
1956cdf0e10cSrcweir // dann mal los:
1957cdf0e10cSrcweir const Rectangle &rBound = pObj->GetSnapRect();
1958cdf0e10cSrcweir Point aRelPos( pObj->GetRelativePos() );
1959cdf0e10cSrcweir
1960cdf0e10cSrcweir const long nWidth = rBound.Right() - rBound.Left();
1961cdf0e10cSrcweir const long nHeight= rBound.Bottom() - rBound.Top();
1962cdf0e10cSrcweir aFrmSet.Put( SwFmtFrmSize( ATT_MIN_SIZE,
1963cdf0e10cSrcweir Max( nWidth, long(MINFLY) ),
1964cdf0e10cSrcweir Max( nHeight, long(MINFLY) )));
1965cdf0e10cSrcweir
1966cdf0e10cSrcweir if( SFX_ITEM_SET != aFrmSet.GetItemState( RES_HORI_ORIENT ))
1967cdf0e10cSrcweir aFrmSet.Put( SwFmtHoriOrient( aRelPos.X(), text::HoriOrientation::NONE, text::RelOrientation::FRAME ));
1968cdf0e10cSrcweir
1969cdf0e10cSrcweir if( SFX_ITEM_SET != aFrmSet.GetItemState( RES_VERT_ORIENT ))
1970cdf0e10cSrcweir aFrmSet.Put( SwFmtVertOrient( aRelPos.Y(), text::VertOrientation::NONE, text::RelOrientation::FRAME ));
1971cdf0e10cSrcweir
1972cdf0e10cSrcweir }
1973cdf0e10cSrcweir
1974cdf0e10cSrcweir pObj->GetOrdNum();
1975cdf0e10cSrcweir
1976cdf0e10cSrcweir StartAllAction();
1977cdf0e10cSrcweir StartUndo();
1978cdf0e10cSrcweir
1979cdf0e10cSrcweir // das "Sdr-Object" loeschen und dafuer die Grafik einfuegen
1980cdf0e10cSrcweir DelSelectedObj();
1981cdf0e10cSrcweir
1982cdf0e10cSrcweir pFmt = GetDoc()->Insert( *GetCrsr(), rGrfName, rFltName, pGrf, &aFrmSet, NULL, NULL );
1983cdf0e10cSrcweir
1984cdf0e10cSrcweir // die Ordnungsnummer (Z-Order) noch uebertragen
1985cdf0e10cSrcweir // JP 04.07.98: klappt aber nicht richtig!
1986cdf0e10cSrcweir //SdrObject* pNewObj = ::FindSdrObject( pFmt );
1987cdf0e10cSrcweir //pNewObj->SetOrdNum( nOrdNum );
1988cdf0e10cSrcweir
1989cdf0e10cSrcweir EndUndo();
1990cdf0e10cSrcweir EndAllAction();
1991cdf0e10cSrcweir bRet = sal_True;
1992cdf0e10cSrcweir }
1993cdf0e10cSrcweir return bRet;
1994cdf0e10cSrcweir }
1995cdf0e10cSrcweir
SwFmtGetPageNum(const SwFlyFrmFmt * pFmt)1996cdf0e10cSrcweir static sal_uInt16 SwFmtGetPageNum(const SwFlyFrmFmt * pFmt)
1997cdf0e10cSrcweir {
1998cdf0e10cSrcweir ASSERT(pFmt != NULL, "invalid argument");
1999cdf0e10cSrcweir
2000cdf0e10cSrcweir SwFlyFrm * pFrm = pFmt->GetFrm();
2001cdf0e10cSrcweir
2002cdf0e10cSrcweir sal_uInt16 aResult;
2003cdf0e10cSrcweir
2004cdf0e10cSrcweir if (pFrm != NULL)
2005cdf0e10cSrcweir aResult = pFrm->GetPhyPageNum();
2006cdf0e10cSrcweir else
2007cdf0e10cSrcweir aResult = pFmt->GetAnchor().GetPageNum();
2008cdf0e10cSrcweir
2009cdf0e10cSrcweir return aResult;
2010cdf0e10cSrcweir }
2011cdf0e10cSrcweir
2012cdf0e10cSrcweir #include <fmtcnct.hxx>
2013cdf0e10cSrcweir
GetConnectableFrmFmts(SwFrmFmt & rFmt,const String & rReference,sal_Bool bSuccessors,::std::vector<String> & aPrevPageVec,::std::vector<String> & aThisPageVec,::std::vector<String> & aNextPageVec,::std::vector<String> & aRestVec)2014cdf0e10cSrcweir void SwFEShell::GetConnectableFrmFmts(SwFrmFmt & rFmt,
2015cdf0e10cSrcweir const String & rReference,
2016cdf0e10cSrcweir sal_Bool bSuccessors,
2017cdf0e10cSrcweir ::std::vector< String > & aPrevPageVec,
2018cdf0e10cSrcweir ::std::vector< String > & aThisPageVec,
2019cdf0e10cSrcweir ::std::vector< String > & aNextPageVec,
2020cdf0e10cSrcweir ::std::vector< String > & aRestVec)
2021cdf0e10cSrcweir {
2022cdf0e10cSrcweir StartAction();
2023cdf0e10cSrcweir
2024cdf0e10cSrcweir SwFmtChain rChain = rFmt.GetChain();
2025cdf0e10cSrcweir SwFrmFmt * pOldChainNext = (SwFrmFmt *) rChain.GetNext();
2026cdf0e10cSrcweir SwFrmFmt * pOldChainPrev = (SwFrmFmt *) rChain.GetPrev();
2027cdf0e10cSrcweir
2028cdf0e10cSrcweir if (pOldChainNext)
2029cdf0e10cSrcweir pDoc->Unchain(rFmt);
2030cdf0e10cSrcweir
2031cdf0e10cSrcweir if (pOldChainPrev)
2032cdf0e10cSrcweir pDoc->Unchain(*pOldChainPrev);
2033cdf0e10cSrcweir
2034cdf0e10cSrcweir sal_uInt16 nCnt = pDoc->GetFlyCount(FLYCNTTYPE_FRM);
2035cdf0e10cSrcweir
2036cdf0e10cSrcweir /* potential successors resp. predecessors */
2037cdf0e10cSrcweir ::std::vector< const SwFrmFmt * > aTmpSpzArray;
2038cdf0e10cSrcweir
2039cdf0e10cSrcweir (SwFrmFmt *) pDoc->FindFlyByName(rReference);
2040cdf0e10cSrcweir
2041cdf0e10cSrcweir for (sal_uInt16 n = 0; n < nCnt; n++)
2042cdf0e10cSrcweir {
2043cdf0e10cSrcweir const SwFrmFmt & rFmt1 = *(pDoc->GetFlyNum(n, FLYCNTTYPE_FRM));
2044cdf0e10cSrcweir
2045cdf0e10cSrcweir /*
2046cdf0e10cSrcweir pFmt is a potential successor of rFmt if it is chainable after
2047cdf0e10cSrcweir rFmt.
2048cdf0e10cSrcweir
2049cdf0e10cSrcweir pFmt is a potential predecessor of rFmt if rFmt is chainable
2050cdf0e10cSrcweir after pFmt.
2051cdf0e10cSrcweir */
2052cdf0e10cSrcweir
2053cdf0e10cSrcweir int nChainState;
2054cdf0e10cSrcweir
2055cdf0e10cSrcweir if (bSuccessors)
2056cdf0e10cSrcweir nChainState = pDoc->Chainable(rFmt, rFmt1);
2057cdf0e10cSrcweir else
2058cdf0e10cSrcweir nChainState = pDoc->Chainable(rFmt1, rFmt);
2059cdf0e10cSrcweir
2060cdf0e10cSrcweir if (nChainState == SW_CHAIN_OK)
2061cdf0e10cSrcweir {
2062cdf0e10cSrcweir aTmpSpzArray.push_back(&rFmt1);
2063cdf0e10cSrcweir
2064cdf0e10cSrcweir }
2065cdf0e10cSrcweir
2066cdf0e10cSrcweir }
2067cdf0e10cSrcweir
2068cdf0e10cSrcweir if (aTmpSpzArray.size() > 0)
2069cdf0e10cSrcweir {
2070cdf0e10cSrcweir aPrevPageVec.clear();
2071cdf0e10cSrcweir aThisPageVec.clear();
2072cdf0e10cSrcweir aNextPageVec.clear();
2073cdf0e10cSrcweir aRestVec.clear();
2074cdf0e10cSrcweir
2075cdf0e10cSrcweir /* number of page rFmt resides on */
2076cdf0e10cSrcweir sal_uInt16 nPageNum = SwFmtGetPageNum((SwFlyFrmFmt *) &rFmt);
2077cdf0e10cSrcweir
2078cdf0e10cSrcweir ::std::vector< const SwFrmFmt * >::const_iterator aIt;
2079cdf0e10cSrcweir
2080cdf0e10cSrcweir for (aIt = aTmpSpzArray.begin(); aIt != aTmpSpzArray.end(); aIt++)
2081cdf0e10cSrcweir {
2082cdf0e10cSrcweir String aString = (*aIt)->GetName();
2083cdf0e10cSrcweir
2084cdf0e10cSrcweir /* rFmt is not a vaild successor or predecessor of
2085cdf0e10cSrcweir itself */
2086cdf0e10cSrcweir if (aString != rReference && aString != rFmt.GetName())
2087cdf0e10cSrcweir {
2088cdf0e10cSrcweir sal_uInt16 nNum1 =
2089cdf0e10cSrcweir SwFmtGetPageNum((SwFlyFrmFmt *) *aIt);
2090cdf0e10cSrcweir
2091cdf0e10cSrcweir if (nNum1 == nPageNum -1)
2092cdf0e10cSrcweir aPrevPageVec.push_back(aString);
2093cdf0e10cSrcweir else if (nNum1 == nPageNum)
2094cdf0e10cSrcweir aThisPageVec.push_back(aString);
2095cdf0e10cSrcweir else if (nNum1 == nPageNum + 1)
2096cdf0e10cSrcweir aNextPageVec.push_back(aString);
2097cdf0e10cSrcweir else
2098cdf0e10cSrcweir aRestVec.push_back(aString);
2099cdf0e10cSrcweir }
2100cdf0e10cSrcweir }
2101cdf0e10cSrcweir
2102cdf0e10cSrcweir }
2103cdf0e10cSrcweir
2104cdf0e10cSrcweir if (pOldChainNext)
2105cdf0e10cSrcweir pDoc->Chain(rFmt, *pOldChainNext);
2106cdf0e10cSrcweir
2107cdf0e10cSrcweir if (pOldChainPrev)
2108cdf0e10cSrcweir pDoc->Chain(*pOldChainPrev, rFmt);
2109cdf0e10cSrcweir
2110cdf0e10cSrcweir EndAction();
2111cdf0e10cSrcweir }
2112cdf0e10cSrcweir
2113cdf0e10cSrcweir // --> OD 2009-07-13 #i73249#
GetObjTitle() const2114cdf0e10cSrcweir const String SwFEShell::GetObjTitle() const
2115cdf0e10cSrcweir {
2116cdf0e10cSrcweir String aTitle;
2117cdf0e10cSrcweir
2118cdf0e10cSrcweir if ( Imp()->HasDrawView() )
2119cdf0e10cSrcweir {
2120cdf0e10cSrcweir const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
2121cdf0e10cSrcweir if ( pMrkList->GetMarkCount() == 1 )
2122cdf0e10cSrcweir {
2123cdf0e10cSrcweir const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
2124cdf0e10cSrcweir const SwFrmFmt* pFmt = FindFrmFmt( pObj );
2125cdf0e10cSrcweir if ( pFmt->Which() == RES_FLYFRMFMT )
2126cdf0e10cSrcweir {
2127cdf0e10cSrcweir aTitle = dynamic_cast<const SwFlyFrmFmt*>(pFmt)->GetObjTitle();
2128cdf0e10cSrcweir }
2129cdf0e10cSrcweir else
2130cdf0e10cSrcweir {
2131cdf0e10cSrcweir aTitle = pObj->GetTitle();
2132cdf0e10cSrcweir }
2133cdf0e10cSrcweir }
2134cdf0e10cSrcweir }
2135cdf0e10cSrcweir
2136cdf0e10cSrcweir return aTitle;
2137cdf0e10cSrcweir }
2138cdf0e10cSrcweir
SetObjTitle(const String & rTitle)2139cdf0e10cSrcweir void SwFEShell::SetObjTitle( const String& rTitle )
2140cdf0e10cSrcweir {
2141cdf0e10cSrcweir if ( Imp()->HasDrawView() )
2142cdf0e10cSrcweir {
2143cdf0e10cSrcweir const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
2144cdf0e10cSrcweir if ( pMrkList->GetMarkCount() == 1 )
2145cdf0e10cSrcweir {
2146cdf0e10cSrcweir SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
2147cdf0e10cSrcweir SwFrmFmt* pFmt = FindFrmFmt( pObj );
2148cdf0e10cSrcweir if ( pFmt->Which() == RES_FLYFRMFMT )
2149cdf0e10cSrcweir {
2150cdf0e10cSrcweir GetDoc()->SetFlyFrmTitle( *(dynamic_cast<SwFlyFrmFmt*>(pFmt)),
2151cdf0e10cSrcweir rTitle );
2152cdf0e10cSrcweir }
2153cdf0e10cSrcweir else
2154cdf0e10cSrcweir {
2155cdf0e10cSrcweir pObj->SetTitle( rTitle );
2156cdf0e10cSrcweir }
2157cdf0e10cSrcweir }
2158cdf0e10cSrcweir }
2159cdf0e10cSrcweir }
2160cdf0e10cSrcweir
GetObjDescription() const2161cdf0e10cSrcweir const String SwFEShell::GetObjDescription() const
2162cdf0e10cSrcweir {
2163cdf0e10cSrcweir String aDescription;
2164cdf0e10cSrcweir
2165cdf0e10cSrcweir if ( Imp()->HasDrawView() )
2166cdf0e10cSrcweir {
2167cdf0e10cSrcweir const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
2168cdf0e10cSrcweir if ( pMrkList->GetMarkCount() == 1 )
2169cdf0e10cSrcweir {
2170cdf0e10cSrcweir const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
2171cdf0e10cSrcweir const SwFrmFmt* pFmt = FindFrmFmt( pObj );
2172cdf0e10cSrcweir if ( pFmt->Which() == RES_FLYFRMFMT )
2173cdf0e10cSrcweir {
2174cdf0e10cSrcweir aDescription = dynamic_cast<const SwFlyFrmFmt*>(pFmt)->GetObjDescription();
2175cdf0e10cSrcweir }
2176cdf0e10cSrcweir else
2177cdf0e10cSrcweir {
2178cdf0e10cSrcweir aDescription = pObj->GetDescription();
2179cdf0e10cSrcweir }
2180cdf0e10cSrcweir }
2181cdf0e10cSrcweir }
2182cdf0e10cSrcweir
2183cdf0e10cSrcweir return aDescription;
2184cdf0e10cSrcweir }
2185cdf0e10cSrcweir
SetObjDescription(const String & rDescription)2186cdf0e10cSrcweir void SwFEShell::SetObjDescription( const String& rDescription )
2187cdf0e10cSrcweir {
2188cdf0e10cSrcweir if ( Imp()->HasDrawView() )
2189cdf0e10cSrcweir {
2190cdf0e10cSrcweir const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
2191cdf0e10cSrcweir if ( pMrkList->GetMarkCount() == 1 )
2192cdf0e10cSrcweir {
2193cdf0e10cSrcweir SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
2194cdf0e10cSrcweir SwFrmFmt* pFmt = FindFrmFmt( pObj );
2195cdf0e10cSrcweir if ( pFmt->Which() == RES_FLYFRMFMT )
2196cdf0e10cSrcweir {
2197cdf0e10cSrcweir GetDoc()->SetFlyFrmDescription( *(dynamic_cast<SwFlyFrmFmt*>(pFmt)),
2198cdf0e10cSrcweir rDescription );
2199cdf0e10cSrcweir }
2200cdf0e10cSrcweir else
2201cdf0e10cSrcweir {
2202cdf0e10cSrcweir pObj->SetDescription( rDescription );
2203cdf0e10cSrcweir }
2204cdf0e10cSrcweir }
2205cdf0e10cSrcweir }
2206cdf0e10cSrcweir }
2207cdf0e10cSrcweir
2208cdf0e10cSrcweir
AlignFormulaToBaseline(const uno::Reference<embed::XEmbeddedObject> & xObj,SwFlyFrm * pFly)2209cdf0e10cSrcweir void SwFEShell::AlignFormulaToBaseline( const uno::Reference < embed::XEmbeddedObject >& xObj, SwFlyFrm * pFly )
2210cdf0e10cSrcweir {
2211cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2212cdf0e10cSrcweir SvGlobalName aCLSID( xObj->getClassID() );
2213cdf0e10cSrcweir const bool bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );
2214cdf0e10cSrcweir ASSERT( bStarMath, "AlignFormulaToBaseline should only be called for Math objects" );
2215cdf0e10cSrcweir
2216cdf0e10cSrcweir if ( !bStarMath )
2217cdf0e10cSrcweir return;
2218cdf0e10cSrcweir #endif
2219cdf0e10cSrcweir
2220cdf0e10cSrcweir if (!pFly)
2221cdf0e10cSrcweir pFly = FindFlyFrm( xObj );
2222cdf0e10cSrcweir ASSERT( pFly , "No fly frame!" );
2223cdf0e10cSrcweir SwFrmFmt * pFrmFmt = pFly ? pFly->GetFmt() : 0;
2224cdf0e10cSrcweir
2225cdf0e10cSrcweir // baseline to baseline alignment should only be applied to formulas anchored as char
2226cdf0e10cSrcweir if ( pFly && pFrmFmt && FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() )
2227cdf0e10cSrcweir {
2228cdf0e10cSrcweir // get baseline from Math object
2229cdf0e10cSrcweir uno::Any aBaseline;
2230cdf0e10cSrcweir if( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
2231cdf0e10cSrcweir {
2232cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
2233cdf0e10cSrcweir if ( xSet.is() )
2234cdf0e10cSrcweir {
2235cdf0e10cSrcweir try
2236cdf0e10cSrcweir {
2237cdf0e10cSrcweir aBaseline = xSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BaseLine") ) );
2238cdf0e10cSrcweir }
2239cdf0e10cSrcweir catch ( uno::Exception& )
2240cdf0e10cSrcweir {
2241cdf0e10cSrcweir ASSERT( sal_False , "Baseline could not be retrieved from Starmath!" );
2242cdf0e10cSrcweir }
2243cdf0e10cSrcweir }
2244cdf0e10cSrcweir }
2245cdf0e10cSrcweir
2246cdf0e10cSrcweir sal_Int32 nBaseline = ::comphelper::getINT32(aBaseline);
2247cdf0e10cSrcweir const MapMode aSourceMapMode( MAP_100TH_MM );
2248cdf0e10cSrcweir const MapMode aTargetMapMode( MAP_TWIP );
2249cdf0e10cSrcweir nBaseline = OutputDevice::LogicToLogic( nBaseline, aSourceMapMode.GetMapUnit(), aTargetMapMode.GetMapUnit() );
2250cdf0e10cSrcweir
2251cdf0e10cSrcweir ASSERT( nBaseline > 0, "Wrong value of Baseline while retrieving from Starmath!" );
2252cdf0e10cSrcweir //nBaseline must be moved by aPrt position
2253cdf0e10cSrcweir const SwFlyFrmFmt *pFlyFrmFmt = pFly->GetFmt();
2254cdf0e10cSrcweir ASSERT( pFlyFrmFmt, "fly frame format missing!" );
2255cdf0e10cSrcweir if ( pFlyFrmFmt )
2256cdf0e10cSrcweir nBaseline += pFlyFrmFmt->GetLastFlyFrmPrtRectPos().Y();
2257cdf0e10cSrcweir
2258cdf0e10cSrcweir const SwFmtVertOrient &rVert = pFrmFmt->GetVertOrient();
2259cdf0e10cSrcweir SwFmtVertOrient aVert( rVert );
2260cdf0e10cSrcweir aVert.SetPos( -nBaseline );
2261cdf0e10cSrcweir aVert.SetVertOrient( com::sun::star::text::VertOrientation::NONE );
2262cdf0e10cSrcweir
2263cdf0e10cSrcweir pFrmFmt->LockModify();
2264cdf0e10cSrcweir pFrmFmt->SetFmtAttr( aVert );
2265cdf0e10cSrcweir pFrmFmt->UnlockModify();
2266cdf0e10cSrcweir pFly->InvalidatePos();
2267cdf0e10cSrcweir }
2268cdf0e10cSrcweir }
2269cdf0e10cSrcweir
2270cdf0e10cSrcweir
AlignAllFormulasToBaseline()2271cdf0e10cSrcweir void SwFEShell::AlignAllFormulasToBaseline()
2272cdf0e10cSrcweir {
2273cdf0e10cSrcweir StartAllAction();
2274cdf0e10cSrcweir
2275cdf0e10cSrcweir SwStartNode *pStNd;
2276cdf0e10cSrcweir SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
2277cdf0e10cSrcweir while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
2278cdf0e10cSrcweir {
2279cdf0e10cSrcweir ++aIdx;
2280cdf0e10cSrcweir SwOLENode *pOleNode = dynamic_cast< SwOLENode * >( &aIdx.GetNode() );
2281cdf0e10cSrcweir if ( pOleNode )
2282cdf0e10cSrcweir {
2283cdf0e10cSrcweir const uno::Reference < embed::XEmbeddedObject > & xObj( pOleNode->GetOLEObj().GetOleRef() );
2284cdf0e10cSrcweir if (xObj.is())
2285cdf0e10cSrcweir {
2286cdf0e10cSrcweir SvGlobalName aCLSID( xObj->getClassID() );
2287cdf0e10cSrcweir if ( SotExchange::IsMath( aCLSID ) )
2288cdf0e10cSrcweir AlignFormulaToBaseline( xObj );
2289cdf0e10cSrcweir }
2290cdf0e10cSrcweir }
2291cdf0e10cSrcweir
2292cdf0e10cSrcweir aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
2293cdf0e10cSrcweir }
2294cdf0e10cSrcweir
2295cdf0e10cSrcweir EndAllAction();
2296cdf0e10cSrcweir }
2297