Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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 <IDocumentLayoutAccess.hxx>
30 : #include <shellres.hxx>
31 : #include <viewimp.hxx>
32 : #include <pagefrm.hxx>
33 : #include <cntfrm.hxx>
34 : #include <rootfrm.hxx>
35 : #include <frmatr.hxx>
36 : #include <viewsh.hxx>
37 : #include <drawdoc.hxx>
38 : #include <dpage.hxx>
39 : #include <dcontact.hxx>
40 : #include <dflyobj.hxx>
41 : #include <docsh.hxx>
42 : #include <usrfld.hxx>
43 : #include <flyfrm.hxx>
44 : #include <ndnotxt.hxx>
45 : #include <grfatr.hxx>
46 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
47 :
48 : using namespace ::com::sun::star::uno;
49 : using namespace ::com::sun::star::drawing;
50 : using namespace ::com::sun::star::frame;
51 :
52 5052 : SwDPage::SwDPage(SwDrawModel& rNewModel, bool bMasterPage) :
53 : FmFormPage(rNewModel, bMasterPage),
54 : pGridLst( 0 ),
55 5052 : rDoc(rNewModel.GetDoc())
56 : {
57 5052 : }
58 :
59 15135 : SwDPage::~SwDPage()
60 : {
61 5045 : delete pGridLst;
62 10090 : }
63 :
64 1720 : SdrObject* SwDPage::ReplaceObject( SdrObject* pNewObj, size_t nObjNum )
65 : {
66 1720 : SdrObject *pOld = GetObj( nObjNum );
67 : OSL_ENSURE( pOld, "Oups, Object not replaced" );
68 : SdrObjUserCall* pContact;
69 3440 : if ( 0 != ( pContact = GetUserCall(pOld) ) &&
70 1720 : RES_DRAWFRMFMT == ((SwContact*)pContact)->GetFmt()->Which())
71 0 : ((SwDrawContact*)pContact)->ChangeMasterObject( pNewObj );
72 1720 : return FmFormPage::ReplaceObject( pNewObj, nObjNum );
73 : }
74 :
75 16 : void InsertGridFrame( SdrPageGridFrameList *pLst, const SwFrm *pPg )
76 : {
77 16 : SwRect aPrt( pPg->Prt() );
78 16 : aPrt += pPg->Frm().Pos();
79 16 : const Rectangle aUser( aPrt.SVRect() );
80 16 : const Rectangle aPaper( pPg->Frm().SVRect() );
81 16 : pLst->Insert( SdrPageGridFrame( aPaper, aUser ) );
82 16 : }
83 :
84 16 : const SdrPageGridFrameList* SwDPage::GetGridFrameList(
85 : const SdrPageView* pPV, const Rectangle *pRect ) const
86 : {
87 16 : SwViewShell *pSh = static_cast< SwDrawModel* >(GetModel())->GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell();
88 32 : while (pSh && pSh->Imp()->GetPageView() != pPV)
89 0 : pSh = (SwViewShell*)pSh->GetNext();
90 16 : if (pSh)
91 : {
92 16 : if ( pGridLst )
93 14 : ((SwDPage*)this)->pGridLst->Clear();
94 : else
95 2 : ((SwDPage*)this)->pGridLst = new SdrPageGridFrameList;
96 :
97 16 : if ( pRect )
98 : {
99 : //The drawing demands all pages which overlap with the rest.
100 0 : const SwRect aRect( *pRect );
101 0 : const SwFrm *pPg = pSh->GetLayout()->Lower();
102 0 : do
103 0 : { if ( pPg->Frm().IsOver( aRect ) )
104 0 : ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
105 0 : pPg = pPg->GetNext();
106 : } while ( pPg );
107 : }
108 : else
109 : {
110 : //The drawing demands all visible pages
111 16 : const SwFrm *pPg = pSh->Imp()->GetFirstVisPage();
112 16 : if ( pPg )
113 16 : do
114 16 : { ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
115 16 : pPg = pPg->GetNext();
116 16 : } while ( pPg && pPg->Frm().IsOver( pSh->VisArea() ) );
117 : }
118 : }
119 16 : return pGridLst;
120 : }
121 :
122 0 : bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView,
123 : const HelpEvent& rEvt )
124 : {
125 0 : bool bContinue = true;
126 :
127 0 : if( rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ))
128 : {
129 0 : Point aPos( rEvt.GetMousePosPixel() );
130 0 : aPos = pWindow->ScreenToOutputPixel( aPos );
131 0 : aPos = pWindow->PixelToLogic( aPos );
132 :
133 : SdrPageView* pPV;
134 : SdrObject* pObj;
135 0 : if( pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_PICKMACRO ) &&
136 0 : pObj->ISA(SwVirtFlyDrawObj) )
137 : {
138 0 : SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
139 0 : const SwFmtURL &rURL = pFly->GetFmt()->GetURL();
140 0 : OUString sTxt;
141 0 : if( rURL.GetMap() )
142 : {
143 0 : IMapObject *pTmpObj = pFly->GetFmt()->GetIMapObject( aPos, pFly );
144 0 : if( pTmpObj )
145 : {
146 0 : sTxt = pTmpObj->GetAltText();
147 0 : if ( sTxt.isEmpty() )
148 0 : sTxt = URIHelper::removePassword( pTmpObj->GetURL(),
149 : INetURLObject::WAS_ENCODED,
150 0 : INetURLObject::DECODE_UNAMBIGUOUS);
151 : }
152 : }
153 0 : else if ( !rURL.GetURL().isEmpty() )
154 : {
155 0 : sTxt = URIHelper::removePassword( rURL.GetURL(),
156 : INetURLObject::WAS_ENCODED,
157 0 : INetURLObject::DECODE_UNAMBIGUOUS);
158 :
159 0 : if( rURL.IsServerMap() )
160 : {
161 : // then append the relative pixel position!!
162 0 : Point aPt( aPos );
163 0 : aPt -= pFly->Frm().Pos();
164 : // without MapMode-Offset !!!!!
165 : // without MapMode-Offset, without Offset, w ... !!!!!
166 : aPt = pWindow->LogicToPixel(
167 0 : aPt, MapMode( MAP_TWIP ) );
168 0 : sTxt += "?" + OUString::number( aPt.getX() )
169 0 : + "," + OUString::number( aPt.getY() );
170 : }
171 : }
172 :
173 0 : if ( !sTxt.isEmpty() )
174 : {
175 : // #i80029#
176 0 : bool bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly();
177 0 : if ( !bExecHyperlinks )
178 : {
179 0 : SvtSecurityOptions aSecOpts;
180 0 : bExecHyperlinks = !aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
181 :
182 0 : if ( !bExecHyperlinks )
183 0 : sTxt = SwViewShell::GetShellRes()->aLinkCtrlClick + ": " + sTxt;
184 : else
185 0 : sTxt = SwViewShell::GetShellRes()->aLinkClick + ": " + sTxt;
186 : }
187 :
188 0 : if( rEvt.GetMode() & HELPMODE_BALLOON )
189 : {
190 0 : Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), sTxt );
191 : }
192 : else
193 : {
194 : // then display the help:
195 0 : Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
196 0 : Help::ShowQuickHelp( pWindow, aRect, sTxt );
197 : }
198 0 : bContinue = false;
199 0 : }
200 : }
201 : }
202 :
203 0 : if( bContinue )
204 0 : bContinue = !FmFormPage::RequestHelp( pWindow, pView, rEvt );
205 :
206 0 : return bContinue;
207 : }
208 :
209 2795 : Reference< XInterface > SwDPage::createUnoPage()
210 : {
211 2795 : Reference < XInterface > xRet;
212 2795 : SwDocShell* pDocShell = rDoc.GetDocShell();
213 2795 : if ( pDocShell )
214 : {
215 2793 : Reference<XModel> xModel = pDocShell->GetBaseModel();
216 5586 : Reference<XDrawPageSupplier> xPageSupp(xModel, UNO_QUERY);
217 5586 : xRet = xPageSupp->getDrawPage();
218 : }
219 2795 : return xRet;
220 270 : }
221 :
222 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|