merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / draw / dpage.cxx
blob3b03da30d002be9740f8f62846b6c8bf8bf2b0af
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dpage.cxx,v $
10 * $Revision: 1.19 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <basic/basmgr.hxx>
34 #include <svtools/imapobj.hxx>
35 #include <svtools/urihelper.hxx>
36 #include <svtools/securityoptions.hxx>
37 #include <vcl/help.hxx>
38 #include <svx/svdview.hxx>
39 #include <fmturl.hxx>
40 #include <frmfmt.hxx>
41 #include <doc.hxx>
42 #ifndef _DOCSH_HXX
43 #include <docsh.hxx>
44 #endif
45 #include <shellres.hxx>
46 #include <viewimp.hxx>
47 #include <pagefrm.hxx>
48 #include <cntfrm.hxx>
49 #include <rootfrm.hxx>
50 #include <frmatr.hxx>
51 #include <viewsh.hxx>
52 #include <drawdoc.hxx>
53 #include <dpage.hxx>
54 #include <dcontact.hxx>
55 #include <dflyobj.hxx>
56 #ifndef _DOCSH_HXX
57 #include <docsh.hxx>
58 #endif
59 #include <usrfld.hxx>
60 #include <flyfrm.hxx>
61 #include <ndnotxt.hxx>
62 #include <grfatr.hxx>
63 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
65 using namespace ::com::sun::star::uno;
66 using namespace ::com::sun::star::drawing;
67 using namespace ::com::sun::star::frame;
69 SwDPage::SwDPage(SwDrawDocument& rNewModel, BOOL bMasterPage) :
70 FmFormPage(rNewModel, 0, bMasterPage),
71 pGridLst( 0 ),
72 rDoc(rNewModel.GetDoc())
77 SwDPage::~SwDPage()
79 delete pGridLst;
82 /*************************************************************************
84 |* SwDPage::ReplaceObject()
86 |* Ersterstellung MA 07. Aug. 95
87 |* Letzte Aenderung MA 07. Aug. 95
89 *************************************************************************/
91 SdrObject* SwDPage::ReplaceObject( SdrObject* pNewObj, ULONG nObjNum )
93 SdrObject *pOld = GetObj( nObjNum );
94 ASSERT( pOld, "Oups, Object not replaced" );
95 SdrObjUserCall* pContact;
96 if ( 0 != ( pContact = GetUserCall(pOld) ) &&
97 RES_DRAWFRMFMT == ((SwContact*)pContact)->GetFmt()->Which())
98 ((SwDrawContact*)pContact)->ChangeMasterObject( pNewObj );
99 return FmFormPage::ReplaceObject( pNewObj, nObjNum );
102 /*************************************************************************
104 |* SwDPage::GetGridFrameList()
106 |* Ersterstellung MA 04. Sep. 95
107 |* Letzte Aenderung MA 15. Feb. 96
109 *************************************************************************/
111 void InsertGridFrame( SdrPageGridFrameList *pLst, const SwFrm *pPg )
113 SwRect aPrt( pPg->Prt() );
114 aPrt += pPg->Frm().Pos();
115 const Rectangle aUser( aPrt.SVRect() );
116 const Rectangle aPaper( pPg->Frm().SVRect() );
117 pLst->Insert( SdrPageGridFrame( aPaper, aUser ) );
121 const SdrPageGridFrameList* SwDPage::GetGridFrameList(
122 const SdrPageView* pPV, const Rectangle *pRect ) const
124 ViewShell *pSh = ((SwDrawDocument*)GetModel())->GetDoc().GetRootFrm()->GetCurrShell();
125 if ( pSh )
127 while ( pSh->Imp()->GetPageView() != pPV )
128 pSh = (ViewShell*)pSh->GetNext();
129 if ( pSh )
131 if ( pGridLst )
132 ((SwDPage*)this)->pGridLst->Clear();
133 else
134 ((SwDPage*)this)->pGridLst = new SdrPageGridFrameList;
136 if ( pRect )
138 //Das Drawing verlang alle Seiten, die mit dem Rect ueberlappen.
139 const SwRect aRect( *pRect );
140 const SwFrm *pPg = pSh->GetLayout()->Lower();
142 { if ( pPg->Frm().IsOver( aRect ) )
143 ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
144 pPg = pPg->GetNext();
145 } while ( pPg );
147 else
149 //Das Drawing verlangt alle sichbaren Seiten
150 const SwFrm *pPg = pSh->Imp()->GetFirstVisPage();
151 if ( pPg )
153 { ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
154 pPg = pPg->GetNext();
155 } while ( pPg && pPg->Frm().IsOver( pSh->VisArea() ) );
159 return pGridLst;
162 BOOL SwDPage::RequestHelp( Window* pWindow, SdrView* pView,
163 const HelpEvent& rEvt )
165 BOOL bWeiter = TRUE;
167 if( rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ))
169 Point aPos( rEvt.GetMousePosPixel() );
170 aPos = pWindow->ScreenToOutputPixel( aPos );
171 aPos = pWindow->PixelToLogic( aPos );
173 SdrPageView* pPV;
174 SdrObject* pObj;
175 if( pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_PICKMACRO ) &&
176 pObj->ISA(SwVirtFlyDrawObj) )
178 SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
179 const SwFmtURL &rURL = pFly->GetFmt()->GetURL();
180 String sTxt;
181 if( rURL.GetMap() )
183 IMapObject *pTmpObj = pFly->GetFmt()->GetIMapObject( aPos, pFly );
184 if( pTmpObj )
186 sTxt = pTmpObj->GetAltText();
187 if ( !sTxt.Len() )
188 sTxt = URIHelper::removePassword( pTmpObj->GetURL(),
189 INetURLObject::WAS_ENCODED,
190 INetURLObject::DECODE_UNAMBIGUOUS);
193 else if ( rURL.GetURL().Len() )
195 sTxt = URIHelper::removePassword( rURL.GetURL(),
196 INetURLObject::WAS_ENCODED,
197 INetURLObject::DECODE_UNAMBIGUOUS);
199 if( rURL.IsServerMap() )
201 // dann die rel. Pixel Position anhaengen !!
202 Point aPt( aPos );
203 aPt -= pFly->Frm().Pos();
204 // ohne MapMode-Offset !!!!!
205 // ohne MapMode-Offset, ohne Offset, o ... !!!!!
206 aPt = pWindow->LogicToPixel(
207 aPt, MapMode( MAP_TWIP ) );
208 ((( sTxt += '?' ) += String::CreateFromInt32( aPt.X() ))
209 += ',' ) += String::CreateFromInt32( aPt.Y() );
213 if ( sTxt.Len() )
215 // --> OD 2007-07-26 #i80029#
216 BOOL bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly();
217 if ( !bExecHyperlinks )
219 SvtSecurityOptions aSecOpts;
220 bExecHyperlinks = !aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
222 if ( !bExecHyperlinks )
224 sTxt.InsertAscii( ": ", 0 );
225 sTxt.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
229 // <--
231 if( rEvt.GetMode() & HELPMODE_BALLOON )
233 Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), sTxt );
235 else
237 // dann zeige die Hilfe mal an:
238 Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
239 Help::ShowQuickHelp( pWindow, aRect, sTxt );
241 bWeiter = FALSE;
246 if( bWeiter )
247 bWeiter = !FmFormPage::RequestHelp( pWindow, pView, rEvt );
249 return bWeiter;
251 /* -----------------------------27.11.00 07:35--------------------------------
253 ---------------------------------------------------------------------------*/
254 Reference< XInterface > SwDPage::createUnoPage()
256 Reference < XInterface > xRet;
257 SwDocShell* pDocShell = rDoc.GetDocShell();
258 if ( pDocShell )
260 Reference<XModel> xModel = pDocShell->GetBaseModel();
261 Reference<XDrawPageSupplier> xPageSupp(xModel, UNO_QUERY);
262 xRet = xPageSupp->getDrawPage();
264 return xRet;