update credits
[LibreOffice.git] / sw / source / core / draw / dpage.cxx
blobff1fcde712a69d278cb7edaaf10e46e692faf991
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <basic/basmgr.hxx>
21 #include <svtools/imapobj.hxx>
22 #include <svl/urihelper.hxx>
23 #include <unotools/securityoptions.hxx>
24 #include <vcl/help.hxx>
25 #include <svx/svdview.hxx>
26 #include <fmturl.hxx>
27 #include <frmfmt.hxx>
28 #include <doc.hxx>
29 #include <shellres.hxx>
30 #include <viewimp.hxx>
31 #include <pagefrm.hxx>
32 #include <cntfrm.hxx>
33 #include <rootfrm.hxx>
34 #include <frmatr.hxx>
35 #include <viewsh.hxx>
36 #include <drawdoc.hxx>
37 #include <dpage.hxx>
38 #include <dcontact.hxx>
39 #include <dflyobj.hxx>
40 #include <docsh.hxx>
41 #include <usrfld.hxx>
42 #include <flyfrm.hxx>
43 #include <ndnotxt.hxx>
44 #include <grfatr.hxx>
45 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::drawing;
49 using namespace ::com::sun::star::frame;
51 SwDPage::SwDPage(SwDrawDocument& rNewModel, sal_Bool bMasterPage) :
52 FmFormPage(rNewModel, 0, bMasterPage),
53 pGridLst( 0 ),
54 rDoc(rNewModel.GetDoc())
58 SwDPage::~SwDPage()
60 delete pGridLst;
63 SdrObject* SwDPage::ReplaceObject( SdrObject* pNewObj, sal_uLong nObjNum )
65 SdrObject *pOld = GetObj( nObjNum );
66 OSL_ENSURE( pOld, "Oups, Object not replaced" );
67 SdrObjUserCall* pContact;
68 if ( 0 != ( pContact = GetUserCall(pOld) ) &&
69 RES_DRAWFRMFMT == ((SwContact*)pContact)->GetFmt()->Which())
70 ((SwDrawContact*)pContact)->ChangeMasterObject( pNewObj );
71 return FmFormPage::ReplaceObject( pNewObj, nObjNum );
74 void InsertGridFrame( SdrPageGridFrameList *pLst, const SwFrm *pPg )
76 SwRect aPrt( pPg->Prt() );
77 aPrt += pPg->Frm().Pos();
78 const Rectangle aUser( aPrt.SVRect() );
79 const Rectangle aPaper( pPg->Frm().SVRect() );
80 pLst->Insert( SdrPageGridFrame( aPaper, aUser ) );
83 const SdrPageGridFrameList* SwDPage::GetGridFrameList(
84 const SdrPageView* pPV, const Rectangle *pRect ) const
86 ViewShell *pSh = ((SwDrawDocument*)GetModel())->GetDoc().GetCurrentViewShell(); //swmod 071108//swmod 071225
87 if ( pSh )
89 while ( pSh->Imp()->GetPageView() != pPV )
90 pSh = (ViewShell*)pSh->GetNext();
91 if ( pSh )
93 if ( pGridLst )
94 ((SwDPage*)this)->pGridLst->Clear();
95 else
96 ((SwDPage*)this)->pGridLst = new SdrPageGridFrameList;
98 if ( pRect )
100 //The drawing demands all pages which overlap with the rest.
101 const SwRect aRect( *pRect );
102 const SwFrm *pPg = pSh->GetLayout()->Lower();
104 { if ( pPg->Frm().IsOver( aRect ) )
105 ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
106 pPg = pPg->GetNext();
107 } while ( pPg );
109 else
111 //The drawing demands all visible pages
112 const SwFrm *pPg = pSh->Imp()->GetFirstVisPage();
113 if ( pPg )
115 { ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
116 pPg = pPg->GetNext();
117 } while ( pPg && pPg->Frm().IsOver( pSh->VisArea() ) );
121 return pGridLst;
124 sal_Bool SwDPage::RequestHelp( Window* pWindow, SdrView* pView,
125 const HelpEvent& rEvt )
127 sal_Bool bWeiter = sal_True;
129 if( rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ))
131 Point aPos( rEvt.GetMousePosPixel() );
132 aPos = pWindow->ScreenToOutputPixel( aPos );
133 aPos = pWindow->PixelToLogic( aPos );
135 SdrPageView* pPV;
136 SdrObject* pObj;
137 if( pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_PICKMACRO ) &&
138 pObj->ISA(SwVirtFlyDrawObj) )
140 SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
141 const SwFmtURL &rURL = pFly->GetFmt()->GetURL();
142 String sTxt;
143 if( rURL.GetMap() )
145 IMapObject *pTmpObj = pFly->GetFmt()->GetIMapObject( aPos, pFly );
146 if( pTmpObj )
148 sTxt = pTmpObj->GetAltText();
149 if ( !sTxt.Len() )
150 sTxt = URIHelper::removePassword( pTmpObj->GetURL(),
151 INetURLObject::WAS_ENCODED,
152 INetURLObject::DECODE_UNAMBIGUOUS);
155 else if ( rURL.GetURL().Len() )
157 sTxt = URIHelper::removePassword( rURL.GetURL(),
158 INetURLObject::WAS_ENCODED,
159 INetURLObject::DECODE_UNAMBIGUOUS);
161 if( rURL.IsServerMap() )
163 // then append the relative pixel position!!
164 Point aPt( aPos );
165 aPt -= pFly->Frm().Pos();
166 // without MapMode-Offset !!!!!
167 // without MapMode-Offset, without Offset, w ... !!!!!
168 aPt = pWindow->LogicToPixel(
169 aPt, MapMode( MAP_TWIP ) );
170 ((( sTxt += '?' ) += OUString::number( aPt.getX() ))
171 += ',' ) += OUString::number( aPt.getY() );
175 if ( sTxt.Len() )
177 // #i80029#
178 sal_Bool bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly();
179 if ( !bExecHyperlinks )
181 SvtSecurityOptions aSecOpts;
182 bExecHyperlinks = !aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
184 if ( !bExecHyperlinks )
186 sTxt.InsertAscii( ": ", 0 );
187 sTxt.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
192 if( rEvt.GetMode() & HELPMODE_BALLOON )
194 Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), sTxt );
196 else
198 // then display the help:
199 Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
200 Help::ShowQuickHelp( pWindow, aRect, sTxt );
202 bWeiter = sal_False;
207 if( bWeiter )
208 bWeiter = !FmFormPage::RequestHelp( pWindow, pView, rEvt );
210 return bWeiter;
213 Reference< XInterface > SwDPage::createUnoPage()
215 Reference < XInterface > xRet;
216 SwDocShell* pDocShell = rDoc.GetDocShell();
217 if ( pDocShell )
219 Reference<XModel> xModel = pDocShell->GetBaseModel();
220 Reference<XDrawPageSupplier> xPageSupp(xModel, UNO_QUERY);
221 xRet = xPageSupp->getDrawPage();
223 return xRet;
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */