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 <sal/macros.h>
30 : :
31 : : #include <svx/fmpage.hxx>
32 : : #include <com/sun/star/beans/XPropertySet.hpp>
33 : : #include <com/sun/star/container/XNameContainer.hpp>
34 : :
35 : :
36 : : #include <svx/fmmodel.hxx>
37 : :
38 : : #include "fmobj.hxx"
39 : :
40 : : #include <svx/fmresids.hrc>
41 : : #include <tools/shl.hxx>
42 : : #include <svx/dialmgr.hxx>
43 : :
44 : : #include "fmpgeimp.hxx"
45 : :
46 : : #include <sfx2/objsh.hxx>
47 : : #include <svx/svditer.hxx>
48 : : #include <svx/svdview.hxx>
49 : : #include <tools/urlobj.hxx>
50 : : #include <vcl/help.hxx>
51 : :
52 : :
53 : : #include <svx/fmglob.hxx>
54 : : #include "fmprop.hrc"
55 : : #include "fmundo.hxx"
56 : : #include "svx/fmtools.hxx"
57 : : using namespace ::svxform;
58 : : #include <comphelper/property.hxx>
59 : : #include <rtl/logfile.hxx>
60 : :
61 : : using com::sun::star::uno::Reference;
62 : : using com::sun::star::uno::UNO_QUERY;
63 : : using com::sun::star::container::XChild;
64 : : using com::sun::star::container::XNameContainer;
65 : :
66 [ + + ][ + - ]: 209487 : TYPEINIT1(FmFormPage, SdrPage);
67 : :
68 : : //------------------------------------------------------------------
69 : 2994 : FmFormPage::FmFormPage(FmFormModel& rModel, StarBASIC* _pBasic, bool bMasterPage)
70 : : :SdrPage(rModel, bMasterPage)
71 [ + - ]: 2994 : ,m_pImpl( new FmFormPageImpl( *this ) )
72 [ + - ][ + - ]: 5988 : ,m_pBasic(_pBasic)
73 : : {
74 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::FmFormPage" );
75 : 2994 : }
76 : :
77 : : //------------------------------------------------------------------
78 : 0 : FmFormPage::FmFormPage(const FmFormPage& rPage)
79 : : :SdrPage(rPage)
80 [ # # ]: 0 : ,m_pImpl(new FmFormPageImpl( *this ) )
81 [ # # ][ # # ]: 0 : ,m_pBasic(0)
82 : : {
83 [ # # ]: 0 : m_pImpl->initFrom( rPage.GetImpl() );
84 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::FmFormPage" );
85 [ # # ]: 0 : m_sPageName = rPage.m_sPageName;
86 : 0 : }
87 : :
88 : : //------------------------------------------------------------------
89 [ + - ]: 2860 : FmFormPage::~FmFormPage()
90 : : {
91 [ + - ][ + - ]: 2860 : delete m_pImpl;
92 [ - + ]: 2860 : }
93 : :
94 : : //------------------------------------------------------------------
95 : 2997 : void FmFormPage::SetModel(SdrModel* pNewModel)
96 : : {
97 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::SetModel" );
98 : : /* #35055# */
99 : : // we want to call the super's "SetModel" method even if the model is the
100 : : // same, in case code somewhere in the system depends on it. But our code
101 : : // doesn't, so get the old model to do a check.
102 : 2997 : SdrModel *pOldModel = GetModel();
103 : :
104 : 2997 : SdrPage::SetModel( pNewModel );
105 : :
106 : : /* #35055# */
107 [ # # ][ - + ]: 2997 : if ( ( pOldModel != pNewModel ) && m_pImpl )
108 : : {
109 : : try
110 : : {
111 [ # # ]: 0 : Reference< XNameContainer > xForms( m_pImpl->getForms( false ) );
112 [ # # ]: 0 : if ( xForms.is() )
113 : : {
114 : : // we want to keep the current collection, just reset the model
115 : : // with which it's associated.
116 [ # # ]: 0 : Reference< XChild > xAsChild( xForms, UNO_QUERY );
117 [ # # ]: 0 : if ( xAsChild.is() )
118 : : {
119 [ # # ]: 0 : FmFormModel* pDrawModel = (FmFormModel*) GetModel();
120 : 0 : SfxObjectShell* pObjShell = pDrawModel->GetObjectShell();
121 [ # # ]: 0 : if ( pObjShell )
122 [ # # ][ # # ]: 0 : xAsChild->setParent( pObjShell->GetModel() );
[ # # ]
123 : 0 : }
124 [ # # ]: 0 : }
125 : : }
126 : 0 : catch( ::com::sun::star::uno::Exception const& )
127 : : {
128 : : OSL_FAIL( "UNO Exception caught resetting model for m_pImpl (FmFormPageImpl) in FmFormPage::SetModel" );
129 : : }
130 : : }
131 : 2997 : }
132 : :
133 : : //------------------------------------------------------------------
134 : 0 : SdrPage* FmFormPage::Clone() const
135 : : {
136 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::Clone" );
137 [ # # ]: 0 : return new FmFormPage(*this);
138 : : // hier fehlt noch ein kopieren der Objekte
139 : : }
140 : :
141 : : //------------------------------------------------------------------
142 : 3768 : void FmFormPage::InsertObject(SdrObject* pObj, sal_uLong nPos,
143 : : const SdrInsertReason* pReason)
144 : : {
145 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::InsertObject" );
146 : 3768 : SdrPage::InsertObject( pObj, nPos, pReason );
147 [ + + ][ + - ]: 3768 : if (GetModel() && (!pReason || pReason->GetReason() != SDRREASON_STREAMING))
[ + - ][ + - ]
148 : 3768 : ((FmFormModel*)GetModel())->GetUndoEnv().Inserted(pObj);
149 : 3768 : }
150 : :
151 : : //------------------------------------------------------------------
152 : 14291 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > & FmFormPage::GetForms( bool _bForceCreate ) const
153 : : {
154 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::GetForms" );
155 : 14291 : const SdrPage& rMasterPage( *this );
156 [ - + ]: 14291 : const FmFormPage* pFormPage = dynamic_cast< const FmFormPage* >( &rMasterPage );
157 : : OSL_ENSURE( pFormPage, "FmFormPage::GetForms: referenced page is no FmFormPage - is this allowed?!" );
158 [ - + ]: 14291 : if ( !pFormPage )
159 : 0 : pFormPage = this;
160 : :
161 : 14291 : return pFormPage->m_pImpl->getForms( _bForceCreate );
162 : : }
163 : :
164 : : //------------------------------------------------------------------
165 : 0 : sal_Bool FmFormPage::RequestHelp( Window* pWindow, SdrView* pView,
166 : : const HelpEvent& rEvt )
167 : : {
168 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::RequestHelp" );
169 [ # # ][ # # ]: 0 : if( pView->IsAction() )
170 : 0 : return sal_False;
171 : :
172 [ # # ]: 0 : Point aPos = rEvt.GetMousePosPixel();
173 [ # # ]: 0 : aPos = pWindow->ScreenToOutputPixel( aPos );
174 [ # # ]: 0 : aPos = pWindow->PixelToLogic( aPos );
175 : :
176 : 0 : SdrObject* pObj = NULL;
177 : 0 : SdrPageView* pPV = NULL;
178 [ # # ][ # # ]: 0 : if ( !pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_DEEP ) )
179 : 0 : return sal_False;
180 : :
181 [ # # ]: 0 : FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
182 [ # # ]: 0 : if ( !pFormObject )
183 : 0 : return sal_False;
184 : :
185 [ # # ]: 0 : UniString aHelpText;
186 [ # # ][ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xSet( pFormObject->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY );
187 [ # # ]: 0 : if (xSet.is())
188 : : {
189 [ # # ][ # # ]: 0 : if (::comphelper::hasProperty(FM_PROP_HELPTEXT, xSet))
[ # # ]
190 [ # # ][ # # ]: 0 : aHelpText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_HELPTEXT)).getStr();
[ # # ][ # # ]
[ # # ]
191 : :
192 [ # # ][ # # ]: 0 : if (!aHelpText.Len() && ::comphelper::hasProperty(FM_PROP_TARGET_URL, xSet))
[ # # ][ # # ]
[ # # ]
[ # # # # ]
193 : : {
194 [ # # ][ # # ]: 0 : ::rtl::OUString aText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_TARGET_URL));
[ # # ][ # # ]
195 [ # # ]: 0 : INetURLObject aUrl(aText);
196 : :
197 : : // testen, ob es ein Protokoll-Typ ist, den ich anzeigen will
198 : 0 : INetProtocol aProtocol = aUrl.GetProtocol();
199 : : static const INetProtocol s_aQuickHelpSupported[] =
200 : : { INET_PROT_FTP, INET_PROT_HTTP, INET_PROT_FILE, INET_PROT_MAILTO, INET_PROT_NEWS,
201 : : INET_PROT_HTTPS, INET_PROT_JAVASCRIPT, INET_PROT_IMAP, INET_PROT_POP3,
202 : : INET_PROT_VIM, INET_PROT_LDAP
203 : : };
204 [ # # ]: 0 : for (sal_uInt16 i=0; i<sizeof(s_aQuickHelpSupported)/sizeof(s_aQuickHelpSupported[0]); ++i)
205 [ # # ]: 0 : if (s_aQuickHelpSupported[i] == aProtocol)
206 : : {
207 [ # # ][ # # ]: 0 : aHelpText = INetURLObject::decode(aUrl.GetURLNoPass(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
[ # # ]
208 : 0 : break;
209 [ # # ]: 0 : }
210 : : }
211 : : }
212 [ # # ]: 0 : if ( aHelpText.Len() != 0 )
213 : : {
214 : : // Hilfe anzeigen
215 [ # # ]: 0 : Rectangle aItemRect = pObj->GetCurrentBoundRect();
216 [ # # ]: 0 : aItemRect = pWindow->LogicToPixel( aItemRect );
217 [ # # ]: 0 : Point aPt = pWindow->OutputToScreenPixel( aItemRect.TopLeft() );
218 : 0 : aItemRect.Left() = aPt.X();
219 : 0 : aItemRect.Top() = aPt.Y();
220 [ # # ][ # # ]: 0 : aPt = pWindow->OutputToScreenPixel( aItemRect.BottomRight() );
221 : 0 : aItemRect.Right() = aPt.X();
222 : 0 : aItemRect.Bottom() = aPt.Y();
223 [ # # ]: 0 : if( rEvt.GetMode() == HELPMODE_BALLOON )
224 [ # # ][ # # ]: 0 : Help::ShowBalloon( pWindow, aItemRect.Center(), aItemRect, aHelpText);
225 : : else
226 [ # # ]: 0 : Help::ShowQuickHelp( pWindow, aItemRect, aHelpText );
227 : : }
228 [ # # ]: 0 : return sal_True;
229 : : }
230 : :
231 : : //------------------------------------------------------------------
232 : 1820 : SdrObject* FmFormPage::RemoveObject(sal_uLong nObjNum)
233 : : {
234 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::RemoveObject" );
235 : 1820 : SdrObject* pObj = SdrPage::RemoveObject(nObjNum);
236 [ + - ][ + - ]: 1820 : if (pObj && GetModel())
[ + - ]
237 : 1820 : ((FmFormModel*)GetModel())->GetUndoEnv().Removed(pObj);
238 : 1820 : return pObj;
239 : : }
240 : :
241 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|