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