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