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
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <basic/basmgr.hxx>
27cdf0e10cSrcweir #include <svtools/imapobj.hxx>
28cdf0e10cSrcweir #include <svl/urihelper.hxx>
29cdf0e10cSrcweir #include <unotools/securityoptions.hxx>
30cdf0e10cSrcweir #include <vcl/help.hxx>
31cdf0e10cSrcweir #include <svx/svdview.hxx>
32cdf0e10cSrcweir #include <fmturl.hxx>
33cdf0e10cSrcweir #include <frmfmt.hxx>
34cdf0e10cSrcweir #include <doc.hxx>
35cdf0e10cSrcweir #ifndef _DOCSH_HXX
36cdf0e10cSrcweir #include <docsh.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <shellres.hxx>
39cdf0e10cSrcweir #include <viewimp.hxx>
40cdf0e10cSrcweir #include <pagefrm.hxx>
41cdf0e10cSrcweir #include <cntfrm.hxx>
42cdf0e10cSrcweir #include <rootfrm.hxx>
43cdf0e10cSrcweir #include <frmatr.hxx>
44cdf0e10cSrcweir #include <viewsh.hxx>
45cdf0e10cSrcweir #include <drawdoc.hxx>
46cdf0e10cSrcweir #include <dpage.hxx>
47cdf0e10cSrcweir #include <dcontact.hxx>
48cdf0e10cSrcweir #include <dflyobj.hxx>
49cdf0e10cSrcweir #ifndef _DOCSH_HXX
50cdf0e10cSrcweir #include <docsh.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #include <usrfld.hxx>
53cdf0e10cSrcweir #include <flyfrm.hxx>
54cdf0e10cSrcweir #include <ndnotxt.hxx>
55cdf0e10cSrcweir #include <grfatr.hxx>
56cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
57cdf0e10cSrcweir
58cdf0e10cSrcweir using namespace ::com::sun::star::uno;
59cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
60cdf0e10cSrcweir using namespace ::com::sun::star::frame;
61cdf0e10cSrcweir
SwDPage(SwDrawModel & rNewModel,sal_Bool bMasterPage)62*26ea3662SArmin Le Grand SwDPage::SwDPage(SwDrawModel& rNewModel, sal_Bool bMasterPage) :
63cdf0e10cSrcweir FmFormPage(rNewModel, 0, bMasterPage),
64cdf0e10cSrcweir pGridLst( 0 ),
65cdf0e10cSrcweir rDoc(rNewModel.GetDoc())
66cdf0e10cSrcweir {
67cdf0e10cSrcweir }
68cdf0e10cSrcweir
69cdf0e10cSrcweir
~SwDPage()70cdf0e10cSrcweir SwDPage::~SwDPage()
71cdf0e10cSrcweir {
72cdf0e10cSrcweir delete pGridLst;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir /*************************************************************************
76cdf0e10cSrcweir |*
77cdf0e10cSrcweir |* SwDPage::ReplaceObject()
78cdf0e10cSrcweir |*
79cdf0e10cSrcweir |* Ersterstellung MA 07. Aug. 95
80cdf0e10cSrcweir |* Letzte Aenderung MA 07. Aug. 95
81cdf0e10cSrcweir |*
82cdf0e10cSrcweir *************************************************************************/
83cdf0e10cSrcweir
ReplaceObject(SdrObject * pNewObj,sal_uLong nObjNum)84cdf0e10cSrcweir SdrObject* SwDPage::ReplaceObject( SdrObject* pNewObj, sal_uLong nObjNum )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir SdrObject *pOld = GetObj( nObjNum );
87cdf0e10cSrcweir ASSERT( pOld, "Oups, Object not replaced" );
88cdf0e10cSrcweir SdrObjUserCall* pContact;
89cdf0e10cSrcweir if ( 0 != ( pContact = GetUserCall(pOld) ) &&
90cdf0e10cSrcweir RES_DRAWFRMFMT == ((SwContact*)pContact)->GetFmt()->Which())
91cdf0e10cSrcweir ((SwDrawContact*)pContact)->ChangeMasterObject( pNewObj );
92cdf0e10cSrcweir return FmFormPage::ReplaceObject( pNewObj, nObjNum );
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir /*************************************************************************
96cdf0e10cSrcweir |*
97cdf0e10cSrcweir |* SwDPage::GetGridFrameList()
98cdf0e10cSrcweir |*
99cdf0e10cSrcweir |* Ersterstellung MA 04. Sep. 95
100cdf0e10cSrcweir |* Letzte Aenderung MA 15. Feb. 96
101cdf0e10cSrcweir |*
102cdf0e10cSrcweir *************************************************************************/
103cdf0e10cSrcweir
InsertGridFrame(SdrPageGridFrameList * pLst,const SwFrm * pPg)104cdf0e10cSrcweir void InsertGridFrame( SdrPageGridFrameList *pLst, const SwFrm *pPg )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir SwRect aPrt( pPg->Prt() );
107cdf0e10cSrcweir aPrt += pPg->Frm().Pos();
108cdf0e10cSrcweir const Rectangle aUser( aPrt.SVRect() );
109cdf0e10cSrcweir const Rectangle aPaper( pPg->Frm().SVRect() );
110cdf0e10cSrcweir pLst->Insert( SdrPageGridFrame( aPaper, aUser ) );
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113cdf0e10cSrcweir
GetGridFrameList(const SdrPageView * pPV,const Rectangle * pRect) const114cdf0e10cSrcweir const SdrPageGridFrameList* SwDPage::GetGridFrameList(
115cdf0e10cSrcweir const SdrPageView* pPV, const Rectangle *pRect ) const
116cdf0e10cSrcweir {
117*26ea3662SArmin Le Grand ViewShell *pSh = static_cast< SwDrawModel* >(GetModel())->GetDoc().GetCurrentViewShell(); //swmod 071108//swmod 071225
118cdf0e10cSrcweir if ( pSh )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir while ( pSh->Imp()->GetPageView() != pPV )
121cdf0e10cSrcweir pSh = (ViewShell*)pSh->GetNext();
122cdf0e10cSrcweir if ( pSh )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir if ( pGridLst )
125cdf0e10cSrcweir ((SwDPage*)this)->pGridLst->Clear();
126cdf0e10cSrcweir else
127cdf0e10cSrcweir ((SwDPage*)this)->pGridLst = new SdrPageGridFrameList;
128cdf0e10cSrcweir
129cdf0e10cSrcweir if ( pRect )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir //Das Drawing verlang alle Seiten, die mit dem Rect ueberlappen.
132cdf0e10cSrcweir const SwRect aRect( *pRect );
133cdf0e10cSrcweir const SwFrm *pPg = pSh->GetLayout()->Lower();
134cdf0e10cSrcweir do
135cdf0e10cSrcweir { if ( pPg->Frm().IsOver( aRect ) )
136cdf0e10cSrcweir ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
137cdf0e10cSrcweir pPg = pPg->GetNext();
138cdf0e10cSrcweir } while ( pPg );
139cdf0e10cSrcweir }
140cdf0e10cSrcweir else
141cdf0e10cSrcweir {
142cdf0e10cSrcweir //Das Drawing verlangt alle sichbaren Seiten
143cdf0e10cSrcweir const SwFrm *pPg = pSh->Imp()->GetFirstVisPage();
144cdf0e10cSrcweir if ( pPg )
145cdf0e10cSrcweir do
146cdf0e10cSrcweir { ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
147cdf0e10cSrcweir pPg = pPg->GetNext();
148cdf0e10cSrcweir } while ( pPg && pPg->Frm().IsOver( pSh->VisArea() ) );
149cdf0e10cSrcweir }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir }
152cdf0e10cSrcweir return pGridLst;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
RequestHelp(Window * pWindow,SdrView * pView,const HelpEvent & rEvt)155cdf0e10cSrcweir sal_Bool SwDPage::RequestHelp( Window* pWindow, SdrView* pView,
156cdf0e10cSrcweir const HelpEvent& rEvt )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir sal_Bool bWeiter = sal_True;
159cdf0e10cSrcweir
160cdf0e10cSrcweir if( rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ))
161cdf0e10cSrcweir {
162cdf0e10cSrcweir Point aPos( rEvt.GetMousePosPixel() );
163cdf0e10cSrcweir aPos = pWindow->ScreenToOutputPixel( aPos );
164cdf0e10cSrcweir aPos = pWindow->PixelToLogic( aPos );
165cdf0e10cSrcweir
166cdf0e10cSrcweir SdrPageView* pPV;
167cdf0e10cSrcweir SdrObject* pObj;
168cdf0e10cSrcweir if( pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_PICKMACRO ) &&
169cdf0e10cSrcweir pObj->ISA(SwVirtFlyDrawObj) )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
172cdf0e10cSrcweir const SwFmtURL &rURL = pFly->GetFmt()->GetURL();
173cdf0e10cSrcweir String sTxt;
174cdf0e10cSrcweir if( rURL.GetMap() )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir IMapObject *pTmpObj = pFly->GetFmt()->GetIMapObject( aPos, pFly );
177cdf0e10cSrcweir if( pTmpObj )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir sTxt = pTmpObj->GetAltText();
180cdf0e10cSrcweir if ( !sTxt.Len() )
181cdf0e10cSrcweir sTxt = URIHelper::removePassword( pTmpObj->GetURL(),
182cdf0e10cSrcweir INetURLObject::WAS_ENCODED,
183cdf0e10cSrcweir INetURLObject::DECODE_UNAMBIGUOUS);
184cdf0e10cSrcweir }
185cdf0e10cSrcweir }
186cdf0e10cSrcweir else if ( rURL.GetURL().Len() )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir sTxt = URIHelper::removePassword( rURL.GetURL(),
189cdf0e10cSrcweir INetURLObject::WAS_ENCODED,
190cdf0e10cSrcweir INetURLObject::DECODE_UNAMBIGUOUS);
191cdf0e10cSrcweir
192cdf0e10cSrcweir if( rURL.IsServerMap() )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir // dann die rel. Pixel Position anhaengen !!
195cdf0e10cSrcweir Point aPt( aPos );
196cdf0e10cSrcweir aPt -= pFly->Frm().Pos();
197cdf0e10cSrcweir // ohne MapMode-Offset !!!!!
198cdf0e10cSrcweir // ohne MapMode-Offset, ohne Offset, o ... !!!!!
199cdf0e10cSrcweir aPt = pWindow->LogicToPixel(
200cdf0e10cSrcweir aPt, MapMode( MAP_TWIP ) );
201cdf0e10cSrcweir ((( sTxt += '?' ) += String::CreateFromInt32( aPt.X() ))
202cdf0e10cSrcweir += ',' ) += String::CreateFromInt32( aPt.Y() );
203cdf0e10cSrcweir }
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
206cdf0e10cSrcweir if ( sTxt.Len() )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir // --> OD 2007-07-26 #i80029#
209cdf0e10cSrcweir sal_Bool bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly();
210cdf0e10cSrcweir if ( !bExecHyperlinks )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir SvtSecurityOptions aSecOpts;
213cdf0e10cSrcweir bExecHyperlinks = !aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
214cdf0e10cSrcweir
215cdf0e10cSrcweir if ( !bExecHyperlinks )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir sTxt.InsertAscii( ": ", 0 );
218cdf0e10cSrcweir sTxt.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
219cdf0e10cSrcweir }
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir // <--
223cdf0e10cSrcweir
224cdf0e10cSrcweir if( rEvt.GetMode() & HELPMODE_BALLOON )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), sTxt );
227cdf0e10cSrcweir }
228cdf0e10cSrcweir else
229cdf0e10cSrcweir {
230cdf0e10cSrcweir // dann zeige die Hilfe mal an:
231cdf0e10cSrcweir Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
232cdf0e10cSrcweir Help::ShowQuickHelp( pWindow, aRect, sTxt );
233cdf0e10cSrcweir }
234cdf0e10cSrcweir bWeiter = sal_False;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir }
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
239cdf0e10cSrcweir if( bWeiter )
240cdf0e10cSrcweir bWeiter = !FmFormPage::RequestHelp( pWindow, pView, rEvt );
241cdf0e10cSrcweir
242cdf0e10cSrcweir return bWeiter;
243cdf0e10cSrcweir }
244cdf0e10cSrcweir /* -----------------------------27.11.00 07:35--------------------------------
245cdf0e10cSrcweir
246cdf0e10cSrcweir ---------------------------------------------------------------------------*/
createUnoPage()247cdf0e10cSrcweir Reference< XInterface > SwDPage::createUnoPage()
248cdf0e10cSrcweir {
249cdf0e10cSrcweir Reference < XInterface > xRet;
250cdf0e10cSrcweir SwDocShell* pDocShell = rDoc.GetDocShell();
251cdf0e10cSrcweir if ( pDocShell )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir Reference<XModel> xModel = pDocShell->GetBaseModel();
254cdf0e10cSrcweir Reference<XDrawPageSupplier> xPageSupp(xModel, UNO_QUERY);
255cdf0e10cSrcweir xRet = xPageSupp->getDrawPage();
256cdf0e10cSrcweir }
257cdf0e10cSrcweir return xRet;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
260cdf0e10cSrcweir
261cdf0e10cSrcweir
262