1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #define ENABLE_BYTESTRING_STREAM_OPERATORS 28cdf0e10cSrcweir #include <svx/fmpage.hxx> 29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 30cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <svx/fmmodel.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #ifndef SVX_LIGHT 36cdf0e10cSrcweir #ifndef _SVX_FMOBJ_HXX 37cdf0e10cSrcweir #include "fmobj.hxx" 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #endif 40cdf0e10cSrcweir 41cdf0e10cSrcweir #ifndef SVX_LIGHT 42cdf0e10cSrcweir #ifndef _SVX_FMRESIDS_HRC 43cdf0e10cSrcweir #include "svx/fmresids.hrc" 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #endif 46cdf0e10cSrcweir #include <tools/shl.hxx> 47cdf0e10cSrcweir #include <svx/dialmgr.hxx> 48cdf0e10cSrcweir 49cdf0e10cSrcweir #ifndef SVX_LIGHT 50cdf0e10cSrcweir #ifndef _SVX_FMPGEIMP_HXX 51cdf0e10cSrcweir #include "fmpgeimp.hxx" 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir 55cdf0e10cSrcweir #ifndef SVX_LIGHT 56cdf0e10cSrcweir #ifndef _SFX_OBJSH_HXX //autogen 57cdf0e10cSrcweir #include <sfx2/objsh.hxx> 58cdf0e10cSrcweir #endif 59cdf0e10cSrcweir #endif 60cdf0e10cSrcweir #include "svx/svditer.hxx" 61cdf0e10cSrcweir #include <svx/svdview.hxx> 62cdf0e10cSrcweir #include <tools/urlobj.hxx> 63cdf0e10cSrcweir #include <vcl/help.hxx> 64cdf0e10cSrcweir 65cdf0e10cSrcweir 66cdf0e10cSrcweir #ifndef SVX_LIGHT 67cdf0e10cSrcweir #ifndef _SVX_FMGLOB_HXX 68cdf0e10cSrcweir #include <svx/fmglob.hxx> 69cdf0e10cSrcweir #endif 70cdf0e10cSrcweir #ifndef _SVX_FMPROP_HRC 71cdf0e10cSrcweir #include "fmprop.hrc" 72cdf0e10cSrcweir #endif 73cdf0e10cSrcweir #include "fmundo.hxx" 74cdf0e10cSrcweir #include "svx/fmtools.hxx" 75cdf0e10cSrcweir using namespace ::svxform; 76cdf0e10cSrcweir #endif 77cdf0e10cSrcweir #include <comphelper/property.hxx> 78cdf0e10cSrcweir #include <rtl/logfile.hxx> 79cdf0e10cSrcweir 80cdf0e10cSrcweir using com::sun::star::uno::Reference; 81cdf0e10cSrcweir using com::sun::star::uno::UNO_QUERY; 82cdf0e10cSrcweir using com::sun::star::container::XChild; 83cdf0e10cSrcweir using com::sun::star::container::XNameContainer; 84cdf0e10cSrcweir 85cdf0e10cSrcweir TYPEINIT1(FmFormPage, SdrPage); 86cdf0e10cSrcweir 87cdf0e10cSrcweir //------------------------------------------------------------------ 88cdf0e10cSrcweir FmFormPage::FmFormPage(FmFormModel& rModel, StarBASIC* _pBasic, FASTBOOL bMasterPage) 89cdf0e10cSrcweir :SdrPage(rModel, bMasterPage) 90cdf0e10cSrcweir #ifndef SVX_LIGHT 91cdf0e10cSrcweir ,m_pImpl( new FmFormPageImpl( *this ) ) 92cdf0e10cSrcweir #else 93cdf0e10cSrcweir ,m_pImpl(NULL) 94cdf0e10cSrcweir #endif 95cdf0e10cSrcweir ,m_pBasic(_pBasic) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::FmFormPage" ); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir //------------------------------------------------------------------ 101cdf0e10cSrcweir FmFormPage::FmFormPage(const FmFormPage& rPage) 102cdf0e10cSrcweir :SdrPage(rPage) 103cdf0e10cSrcweir #ifndef SVX_LIGHT 104cdf0e10cSrcweir ,m_pImpl(new FmFormPageImpl( *this ) ) 105cdf0e10cSrcweir #else 106cdf0e10cSrcweir ,m_pImpl(NULL) 107cdf0e10cSrcweir #endif 108cdf0e10cSrcweir ,m_pBasic(0) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir #ifndef SVX_LIGHT 111cdf0e10cSrcweir m_pImpl->initFrom( rPage.GetImpl() ); 112cdf0e10cSrcweir #endif 113cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::FmFormPage" ); 114cdf0e10cSrcweir m_sPageName = rPage.m_sPageName; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir //------------------------------------------------------------------ 118cdf0e10cSrcweir FmFormPage::~FmFormPage() 119cdf0e10cSrcweir { 120cdf0e10cSrcweir #ifndef SVX_LIGHT 121cdf0e10cSrcweir delete m_pImpl; 122cdf0e10cSrcweir #endif 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir //------------------------------------------------------------------ 126cdf0e10cSrcweir void FmFormPage::SetModel(SdrModel* pNewModel) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::SetModel" ); 129cdf0e10cSrcweir /* #35055# */ 130cdf0e10cSrcweir // we want to call the super's "SetModel" method even if the model is the 131cdf0e10cSrcweir // same, in case code somewhere in the system depends on it. But our code 132cdf0e10cSrcweir // doesn't, so get the old model to do a check. 133cdf0e10cSrcweir SdrModel *pOldModel = GetModel(); 134cdf0e10cSrcweir 135cdf0e10cSrcweir SdrPage::SetModel( pNewModel ); 136cdf0e10cSrcweir 137cdf0e10cSrcweir /* #35055# */ 138cdf0e10cSrcweir if ( ( pOldModel != pNewModel ) && m_pImpl ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir try 141cdf0e10cSrcweir { 142cdf0e10cSrcweir Reference< XNameContainer > xForms( m_pImpl->getForms( false ) ); 143cdf0e10cSrcweir if ( xForms.is() ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir // we want to keep the current collection, just reset the model 146cdf0e10cSrcweir // with which it's associated. 147cdf0e10cSrcweir Reference< XChild > xAsChild( xForms, UNO_QUERY ); 148cdf0e10cSrcweir if ( xAsChild.is() ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir FmFormModel* pDrawModel = (FmFormModel*) GetModel(); 151cdf0e10cSrcweir SfxObjectShell* pObjShell = pDrawModel->GetObjectShell(); 152cdf0e10cSrcweir if ( pObjShell ) 153cdf0e10cSrcweir xAsChild->setParent( pObjShell->GetModel() ); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir } 156cdf0e10cSrcweir } 157cdf0e10cSrcweir catch( ::com::sun::star::uno::Exception ex ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir OSL_ENSURE( sal_False, "UNO Exception caught resetting model for m_pImpl (FmFormPageImpl) in FmFormPage::SetModel" ); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir } 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir //------------------------------------------------------------------ 165cdf0e10cSrcweir SdrPage* FmFormPage::Clone() const 166cdf0e10cSrcweir { 167cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::Clone" ); 168cdf0e10cSrcweir return new FmFormPage(*this); 169cdf0e10cSrcweir // hier fehlt noch ein kopieren der Objekte 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir //------------------------------------------------------------------ 173cdf0e10cSrcweir void FmFormPage::InsertObject(SdrObject* pObj, sal_uLong nPos, 174cdf0e10cSrcweir const SdrInsertReason* pReason) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::InsertObject" ); 177cdf0e10cSrcweir SdrPage::InsertObject( pObj, nPos, pReason ); 178cdf0e10cSrcweir #ifndef SVX_LIGHT 179cdf0e10cSrcweir if (GetModel() && (!pReason || pReason->GetReason() != SDRREASON_STREAMING)) 180cdf0e10cSrcweir ((FmFormModel*)GetModel())->GetUndoEnv().Inserted(pObj); 181cdf0e10cSrcweir #endif 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir //------------------------------------------------------------------ 185cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > & FmFormPage::GetForms( bool _bForceCreate ) const 186cdf0e10cSrcweir { 187cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::GetForms" ); 188cdf0e10cSrcweir #ifndef SVX_LIGHT 189cdf0e10cSrcweir const SdrPage& rMasterPage( *this ); 190cdf0e10cSrcweir const FmFormPage* pFormPage = dynamic_cast< const FmFormPage* >( &rMasterPage ); 191cdf0e10cSrcweir OSL_ENSURE( pFormPage, "FmFormPage::GetForms: referenced page is no FmFormPage - is this allowed?!" ); 192cdf0e10cSrcweir if ( !pFormPage ) 193cdf0e10cSrcweir pFormPage = this; 194cdf0e10cSrcweir 195cdf0e10cSrcweir return pFormPage->m_pImpl->getForms( _bForceCreate ); 196cdf0e10cSrcweir #else 197cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > aRef; 198cdf0e10cSrcweir return aRef; 199cdf0e10cSrcweir #endif 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir //------------------------------------------------------------------ 203cdf0e10cSrcweir sal_Bool FmFormPage::RequestHelp( Window* pWindow, SdrView* pView, 204cdf0e10cSrcweir const HelpEvent& rEvt ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::RequestHelp" ); 207cdf0e10cSrcweir #ifndef SVX_LIGHT 208cdf0e10cSrcweir if( pView->IsAction() ) 209cdf0e10cSrcweir return sal_False; 210cdf0e10cSrcweir 211cdf0e10cSrcweir Point aPos = rEvt.GetMousePosPixel(); 212cdf0e10cSrcweir aPos = pWindow->ScreenToOutputPixel( aPos ); 213cdf0e10cSrcweir aPos = pWindow->PixelToLogic( aPos ); 214cdf0e10cSrcweir 215cdf0e10cSrcweir SdrObject* pObj = NULL; 216cdf0e10cSrcweir SdrPageView* pPV = NULL; 217cdf0e10cSrcweir if ( !pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_DEEP ) ) 218cdf0e10cSrcweir return sal_False; 219cdf0e10cSrcweir 220cdf0e10cSrcweir FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj ); 221cdf0e10cSrcweir if ( !pFormObject ) 222cdf0e10cSrcweir return sal_False; 223cdf0e10cSrcweir 224cdf0e10cSrcweir UniString aHelpText; 225cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xSet( pFormObject->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY ); 226cdf0e10cSrcweir if (xSet.is()) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir if (::comphelper::hasProperty(FM_PROP_HELPTEXT, xSet)) 229cdf0e10cSrcweir aHelpText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_HELPTEXT)).getStr(); 230cdf0e10cSrcweir 231cdf0e10cSrcweir if (!aHelpText.Len() && ::comphelper::hasProperty(FM_PROP_TARGET_URL, xSet)) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir ::rtl::OUString aText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_TARGET_URL)); 234cdf0e10cSrcweir INetURLObject aUrl(aText); 235cdf0e10cSrcweir 236cdf0e10cSrcweir // testen, ob es ein Protokoll-Typ ist, den ich anzeigen will 237cdf0e10cSrcweir INetProtocol aProtocol = aUrl.GetProtocol(); 238cdf0e10cSrcweir static const INetProtocol s_aQuickHelpSupported[] = 239cdf0e10cSrcweir { INET_PROT_FTP, INET_PROT_HTTP, INET_PROT_FILE, INET_PROT_MAILTO, INET_PROT_NEWS, 240cdf0e10cSrcweir INET_PROT_HTTPS, INET_PROT_JAVASCRIPT, INET_PROT_IMAP, INET_PROT_POP3, 241cdf0e10cSrcweir INET_PROT_VIM, INET_PROT_LDAP 242cdf0e10cSrcweir }; 243cdf0e10cSrcweir for (sal_uInt16 i=0; i<sizeof(s_aQuickHelpSupported)/sizeof(s_aQuickHelpSupported[0]); ++i) 244cdf0e10cSrcweir if (s_aQuickHelpSupported[i] == aProtocol) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir aHelpText = INetURLObject::decode(aUrl.GetURLNoPass(), '%', INetURLObject::DECODE_UNAMBIGUOUS); 247cdf0e10cSrcweir break; 248cdf0e10cSrcweir } 249cdf0e10cSrcweir } 250cdf0e10cSrcweir } 251cdf0e10cSrcweir if ( aHelpText.Len() != 0 ) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir // Hilfe anzeigen 254cdf0e10cSrcweir Rectangle aItemRect = pObj->GetCurrentBoundRect(); 255cdf0e10cSrcweir aItemRect = pWindow->LogicToPixel( aItemRect ); 256cdf0e10cSrcweir Point aPt = pWindow->OutputToScreenPixel( aItemRect.TopLeft() ); 257cdf0e10cSrcweir aItemRect.Left() = aPt.X(); 258cdf0e10cSrcweir aItemRect.Top() = aPt.Y(); 259cdf0e10cSrcweir aPt = pWindow->OutputToScreenPixel( aItemRect.BottomRight() ); 260cdf0e10cSrcweir aItemRect.Right() = aPt.X(); 261cdf0e10cSrcweir aItemRect.Bottom() = aPt.Y(); 262cdf0e10cSrcweir if( rEvt.GetMode() == HELPMODE_BALLOON ) 263cdf0e10cSrcweir Help::ShowBalloon( pWindow, aItemRect.Center(), aItemRect, aHelpText); 264cdf0e10cSrcweir else 265cdf0e10cSrcweir Help::ShowQuickHelp( pWindow, aItemRect, aHelpText ); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir #endif 268cdf0e10cSrcweir return sal_True; 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir //------------------------------------------------------------------ 272cdf0e10cSrcweir SdrObject* FmFormPage::RemoveObject(sal_uLong nObjNum) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::RemoveObject" ); 275cdf0e10cSrcweir SdrObject* pObj = SdrPage::RemoveObject(nObjNum); 276cdf0e10cSrcweir #ifndef SVX_LIGHT 277cdf0e10cSrcweir if (pObj && GetModel()) 278cdf0e10cSrcweir ((FmFormModel*)GetModel())->GetUndoEnv().Removed(pObj); 279cdf0e10cSrcweir #endif 280cdf0e10cSrcweir return pObj; 281cdf0e10cSrcweir } 282