1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dpage.cxx,v $
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>
45 #include <shellres.hxx>
46 #include <viewimp.hxx>
47 #include <pagefrm.hxx>
49 #include <rootfrm.hxx>
52 #include <drawdoc.hxx>
54 #include <dcontact.hxx>
55 #include <dflyobj.hxx>
61 #include <ndnotxt.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
),
72 rDoc(rNewModel
.GetDoc())
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();
127 while ( pSh
->Imp()->GetPageView() != pPV
)
128 pSh
= (ViewShell
*)pSh
->GetNext();
132 ((SwDPage
*)this)->pGridLst
->Clear();
134 ((SwDPage
*)this)->pGridLst
= new SdrPageGridFrameList
;
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();
149 //Das Drawing verlangt alle sichbaren Seiten
150 const SwFrm
*pPg
= pSh
->Imp()->GetFirstVisPage();
153 { ::InsertGridFrame( ((SwDPage
*)this)->pGridLst
, pPg
);
154 pPg
= pPg
->GetNext();
155 } while ( pPg
&& pPg
->Frm().IsOver( pSh
->VisArea() ) );
162 BOOL
SwDPage::RequestHelp( Window
* pWindow
, SdrView
* pView
,
163 const HelpEvent
& rEvt
)
167 if( rEvt
.GetMode() & ( HELPMODE_QUICK
| HELPMODE_BALLOON
))
169 Point
aPos( rEvt
.GetMousePosPixel() );
170 aPos
= pWindow
->ScreenToOutputPixel( aPos
);
171 aPos
= pWindow
->PixelToLogic( aPos
);
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();
183 IMapObject
*pTmpObj
= pFly
->GetFmt()->GetIMapObject( aPos
, pFly
);
186 sTxt
= pTmpObj
->GetAltText();
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 !!
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() );
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 );
231 if( rEvt
.GetMode() & HELPMODE_BALLOON
)
233 Help::ShowBalloon( pWindow
, rEvt
.GetMousePosPixel(), sTxt
);
237 // dann zeige die Hilfe mal an:
238 Rectangle
aRect( rEvt
.GetMousePosPixel(), Size(1,1) );
239 Help::ShowQuickHelp( pWindow
, aRect
, sTxt
);
247 bWeiter
= !FmFormPage::RequestHelp( pWindow
, pView
, rEvt
);
251 /* -----------------------------27.11.00 07:35--------------------------------
253 ---------------------------------------------------------------------------*/
254 Reference
< XInterface
> SwDPage::createUnoPage()
256 Reference
< XInterface
> xRet
;
257 SwDocShell
* pDocShell
= rDoc
.GetDocShell();
260 Reference
<XModel
> xModel
= pDocShell
->GetBaseModel();
261 Reference
<XDrawPageSupplier
> xPageSupp(xModel
, UNO_QUERY
);
262 xRet
= xPageSupp
->getDrawPage();