Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <basic/basmgr.hxx>
30 : : #include <svtools/imapobj.hxx>
31 : : #include <svl/urihelper.hxx>
32 : : #include <unotools/securityoptions.hxx>
33 : : #include <vcl/help.hxx>
34 : : #include <svx/svdview.hxx>
35 : : #include <fmturl.hxx>
36 : : #include <frmfmt.hxx>
37 : : #include <doc.hxx>
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 : : #include <docsh.hxx>
50 : : #include <usrfld.hxx>
51 : : #include <flyfrm.hxx>
52 : : #include <ndnotxt.hxx>
53 : : #include <grfatr.hxx>
54 : : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
55 : :
56 : : using namespace ::com::sun::star::uno;
57 : : using namespace ::com::sun::star::drawing;
58 : : using namespace ::com::sun::star::frame;
59 : :
60 : 1386 : SwDPage::SwDPage(SwDrawDocument& rNewModel, sal_Bool bMasterPage) :
61 : : FmFormPage(rNewModel, 0, bMasterPage),
62 : : pGridLst( 0 ),
63 : 1386 : rDoc(rNewModel.GetDoc())
64 : : {
65 : 1386 : }
66 : :
67 : :
68 [ + - ]: 1297 : SwDPage::~SwDPage()
69 : : {
70 [ + + ][ + - ]: 1297 : delete pGridLst;
71 [ - + ]: 2594 : }
72 : :
73 : : /*************************************************************************
74 : : |*
75 : : |* SwDPage::ReplaceObject()
76 : : |*
77 : : *************************************************************************/
78 : :
79 : 59 : SdrObject* SwDPage::ReplaceObject( SdrObject* pNewObj, sal_uLong nObjNum )
80 : : {
81 : 59 : SdrObject *pOld = GetObj( nObjNum );
82 : : OSL_ENSURE( pOld, "Oups, Object not replaced" );
83 : : SdrObjUserCall* pContact;
84 [ - + ]: 118 : if ( 0 != ( pContact = GetUserCall(pOld) ) &&
[ + - - + ]
85 : 59 : RES_DRAWFRMFMT == ((SwContact*)pContact)->GetFmt()->Which())
86 : 0 : ((SwDrawContact*)pContact)->ChangeMasterObject( pNewObj );
87 : 59 : return FmFormPage::ReplaceObject( pNewObj, nObjNum );
88 : : }
89 : :
90 : : /*************************************************************************
91 : : |*
92 : : |* SwDPage::GetGridFrameList()
93 : : |*
94 : : *************************************************************************/
95 : :
96 : 25 : void InsertGridFrame( SdrPageGridFrameList *pLst, const SwFrm *pPg )
97 : : {
98 : 25 : SwRect aPrt( pPg->Prt() );
99 : 25 : aPrt += pPg->Frm().Pos();
100 [ + - ]: 25 : const Rectangle aUser( aPrt.SVRect() );
101 [ + - ]: 25 : const Rectangle aPaper( pPg->Frm().SVRect() );
102 [ + - ]: 25 : pLst->Insert( SdrPageGridFrame( aPaper, aUser ) );
103 : 25 : }
104 : :
105 : :
106 : 25 : const SdrPageGridFrameList* SwDPage::GetGridFrameList(
107 : : const SdrPageView* pPV, const Rectangle *pRect ) const
108 : : {
109 : 25 : ViewShell *pSh = ((SwDrawDocument*)GetModel())->GetDoc().GetCurrentViewShell(); //swmod 071108//swmod 071225
110 [ + - ]: 25 : if ( pSh )
111 : : {
112 [ - + ]: 25 : while ( pSh->Imp()->GetPageView() != pPV )
113 : 0 : pSh = (ViewShell*)pSh->GetNext();
114 [ + - ]: 25 : if ( pSh )
115 : : {
116 [ + + ]: 25 : if ( pGridLst )
117 : 23 : ((SwDPage*)this)->pGridLst->Clear();
118 : : else
119 [ + - ]: 2 : ((SwDPage*)this)->pGridLst = new SdrPageGridFrameList;
120 : :
121 [ - + ]: 25 : if ( pRect )
122 : : {
123 : : //Das Drawing verlang alle Seiten, die mit dem Rect ueberlappen.
124 [ # # ]: 0 : const SwRect aRect( *pRect );
125 [ # # ]: 0 : const SwFrm *pPg = pSh->GetLayout()->Lower();
126 [ # # ]: 0 : do
127 [ # # ][ # # ]: 0 : { if ( pPg->Frm().IsOver( aRect ) )
128 [ # # ]: 0 : ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
129 : 0 : pPg = pPg->GetNext();
130 : : } while ( pPg );
131 : : }
132 : : else
133 : : {
134 : : //Das Drawing verlangt alle sichbaren Seiten
135 : 25 : const SwFrm *pPg = pSh->Imp()->GetFirstVisPage();
136 [ + - ]: 25 : if ( pPg )
137 [ - + ]: 25 : do
[ - + # # ]
138 : 25 : { ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
139 : 25 : pPg = pPg->GetNext();
140 : 0 : } while ( pPg && pPg->Frm().IsOver( pSh->VisArea() ) );
141 : : }
142 : : }
143 : : }
144 : 25 : return pGridLst;
145 : : }
146 : :
147 : 0 : sal_Bool SwDPage::RequestHelp( Window* pWindow, SdrView* pView,
148 : : const HelpEvent& rEvt )
149 : : {
150 : 0 : sal_Bool bWeiter = sal_True;
151 : :
152 [ # # ]: 0 : if( rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ))
153 : : {
154 [ # # ]: 0 : Point aPos( rEvt.GetMousePosPixel() );
155 [ # # ]: 0 : aPos = pWindow->ScreenToOutputPixel( aPos );
156 [ # # ]: 0 : aPos = pWindow->PixelToLogic( aPos );
157 : :
158 : : SdrPageView* pPV;
159 : : SdrObject* pObj;
160 [ # # ][ # # ]: 0 : if( pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_PICKMACRO ) &&
[ # # ][ # # ]
161 [ # # ][ # # ]: 0 : pObj->ISA(SwVirtFlyDrawObj) )
162 : : {
163 : 0 : SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
164 [ # # ][ # # ]: 0 : const SwFmtURL &rURL = pFly->GetFmt()->GetURL();
165 [ # # ]: 0 : String sTxt;
166 [ # # ]: 0 : if( rURL.GetMap() )
167 : : {
168 [ # # ][ # # ]: 0 : IMapObject *pTmpObj = pFly->GetFmt()->GetIMapObject( aPos, pFly );
169 [ # # ]: 0 : if( pTmpObj )
170 : : {
171 [ # # ]: 0 : sTxt = pTmpObj->GetAltText();
172 [ # # ]: 0 : if ( !sTxt.Len() )
173 : 0 : sTxt = URIHelper::removePassword( pTmpObj->GetURL(),
174 : : INetURLObject::WAS_ENCODED,
175 [ # # ][ # # ]: 0 : INetURLObject::DECODE_UNAMBIGUOUS);
[ # # ]
176 : : }
177 : : }
178 [ # # ]: 0 : else if ( rURL.GetURL().Len() )
179 : : {
180 : 0 : sTxt = URIHelper::removePassword( rURL.GetURL(),
181 : : INetURLObject::WAS_ENCODED,
182 [ # # ][ # # ]: 0 : INetURLObject::DECODE_UNAMBIGUOUS);
[ # # ]
183 : :
184 [ # # ]: 0 : if( rURL.IsServerMap() )
185 : : {
186 : : // dann die rel. Pixel Position anhaengen !!
187 : 0 : Point aPt( aPos );
188 : 0 : aPt -= pFly->Frm().Pos();
189 : : // ohne MapMode-Offset !!!!!
190 : : // ohne MapMode-Offset, ohne Offset, o ... !!!!!
191 : : aPt = pWindow->LogicToPixel(
192 [ # # ][ # # ]: 0 : aPt, MapMode( MAP_TWIP ) );
[ # # ]
193 [ # # ][ # # ]: 0 : ((( sTxt += '?' ) += String::CreateFromInt32( aPt.X() ))
[ # # ][ # # ]
194 [ # # ][ # # ]: 0 : += ',' ) += String::CreateFromInt32( aPt.Y() );
[ # # ][ # # ]
195 : : }
196 : : }
197 : :
198 [ # # ]: 0 : if ( sTxt.Len() )
199 : : {
200 : : // #i80029#
201 [ # # ]: 0 : sal_Bool bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly();
202 [ # # ]: 0 : if ( !bExecHyperlinks )
203 : : {
204 [ # # ]: 0 : SvtSecurityOptions aSecOpts;
205 [ # # ]: 0 : bExecHyperlinks = !aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
206 : :
207 [ # # ]: 0 : if ( !bExecHyperlinks )
208 : : {
209 [ # # ]: 0 : sTxt.InsertAscii( ": ", 0 );
210 [ # # ][ # # ]: 0 : sTxt.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
211 [ # # ]: 0 : }
212 : : }
213 : :
214 : :
215 [ # # ]: 0 : if( rEvt.GetMode() & HELPMODE_BALLOON )
216 : : {
217 [ # # ][ # # ]: 0 : Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), sTxt );
218 : : }
219 : : else
220 : : {
221 : : // dann zeige die Hilfe mal an:
222 [ # # ][ # # ]: 0 : Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
223 [ # # ]: 0 : Help::ShowQuickHelp( pWindow, aRect, sTxt );
224 : : }
225 : 0 : bWeiter = sal_False;
226 [ # # ]: 0 : }
227 : : }
228 : : }
229 : :
230 [ # # ]: 0 : if( bWeiter )
231 : 0 : bWeiter = !FmFormPage::RequestHelp( pWindow, pView, rEvt );
232 : :
233 : 0 : return bWeiter;
234 : : }
235 : :
236 : 986 : Reference< XInterface > SwDPage::createUnoPage()
237 : : {
238 : 986 : Reference < XInterface > xRet;
239 : 986 : SwDocShell* pDocShell = rDoc.GetDocShell();
240 [ + - ]: 986 : if ( pDocShell )
241 : : {
242 [ + - ]: 986 : Reference<XModel> xModel = pDocShell->GetBaseModel();
243 [ + - ]: 986 : Reference<XDrawPageSupplier> xPageSupp(xModel, UNO_QUERY);
244 [ + - ][ + - ]: 986 : xRet = xPageSupp->getDrawPage();
[ + - ]
245 : : }
246 : 986 : return xRet;
247 : : }
248 : :
249 : :
250 : :
251 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|