LCOV - code coverage report
Current view: top level - libreoffice/svx/source/form - fmpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 88 31.8 %
Date: 2012-12-27 Functions: 9 15 60.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10