LCOV - code coverage report
Current view: top level - svx/source/form - fmpage.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 83 0.0 %
Date: 2014-04-14 Functions: 0 15 0.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             : 
      51             : using com::sun::star::uno::Reference;
      52             : using com::sun::star::uno::UNO_QUERY;
      53             : using com::sun::star::container::XChild;
      54             : using com::sun::star::container::XNameContainer;
      55             : 
      56           0 : TYPEINIT1(FmFormPage, SdrPage);
      57             : 
      58             : 
      59           0 : FmFormPage::FmFormPage(FmFormModel& rModel, bool bMasterPage)
      60             :            :SdrPage(rModel, bMasterPage)
      61           0 :            ,m_pImpl( new FmFormPageImpl( *this ) )
      62             : {
      63           0 : }
      64             : 
      65             : 
      66           0 : FmFormPage::FmFormPage(const FmFormPage& rPage)
      67             :            :SdrPage(rPage)
      68           0 :            ,m_pImpl(new FmFormPageImpl( *this ) )
      69             : {
      70           0 :     m_pImpl->initFrom( rPage.GetImpl() );
      71           0 :     m_sPageName = rPage.m_sPageName;
      72           0 : }
      73             : 
      74             : 
      75           0 : FmFormPage::~FmFormPage()
      76             : {
      77           0 :     delete m_pImpl;
      78           0 : }
      79             : 
      80             : 
      81           0 : void FmFormPage::SetModel(SdrModel* pNewModel)
      82             : {
      83             :     /* #35055# */
      84             :     // we want to call the super's "SetModel" method even if the model is the
      85             :     // same, in case code somewhere in the system depends on it.  But our code
      86             :     // doesn't, so get the old model to do a check.
      87           0 :     SdrModel *pOldModel = GetModel();
      88             : 
      89           0 :     SdrPage::SetModel( pNewModel );
      90             : 
      91             :     /* #35055# */
      92           0 :     if ( ( pOldModel != pNewModel ) && m_pImpl )
      93             :     {
      94             :         try
      95             :         {
      96           0 :             Reference< css::form::XForms > xForms( m_pImpl->getForms( false ) );
      97           0 :             if ( xForms.is() )
      98             :             {
      99             :                 // we want to keep the current collection, just reset the model
     100             :                 // with which it's associated.
     101           0 :                 FmFormModel* pDrawModel = (FmFormModel*) GetModel();
     102           0 :                 SfxObjectShell* pObjShell = pDrawModel->GetObjectShell();
     103           0 :                 if ( pObjShell )
     104           0 :                     xForms->setParent( pObjShell->GetModel() );
     105           0 :             }
     106             :         }
     107           0 :         catch( ::com::sun::star::uno::Exception const& )
     108             :         {
     109             :             OSL_FAIL( "UNO Exception caught resetting model for m_pImpl (FmFormPageImpl) in FmFormPage::SetModel" );
     110             :         }
     111             :     }
     112           0 : }
     113             : 
     114             : 
     115           0 : SdrPage* FmFormPage::Clone() const
     116             : {
     117           0 :     return new FmFormPage(*this);
     118             :     // hier fehlt noch ein kopieren der Objekte
     119             : }
     120             : 
     121             : 
     122           0 : void FmFormPage::InsertObject(SdrObject* pObj, sal_uLong nPos,
     123             :                               const SdrInsertReason* pReason)
     124             : {
     125           0 :     SdrPage::InsertObject( pObj, nPos, pReason );
     126           0 :     if (GetModel() && (!pReason || pReason->GetReason() != SDRREASON_STREAMING))
     127           0 :         ((FmFormModel*)GetModel())->GetUndoEnv().Inserted(pObj);
     128           0 : }
     129             : 
     130             : 
     131           0 : const Reference< css::form::XForms > & FmFormPage::GetForms( bool _bForceCreate ) const
     132             : {
     133           0 :     const SdrPage& rMasterPage( *this );
     134           0 :     const FmFormPage* pFormPage = dynamic_cast< const FmFormPage* >( &rMasterPage );
     135             :     OSL_ENSURE( pFormPage, "FmFormPage::GetForms: referenced page is no FmFormPage - is this allowed?!" );
     136           0 :     if ( !pFormPage )
     137           0 :         pFormPage = this;
     138             : 
     139           0 :     return pFormPage->m_pImpl->getForms( _bForceCreate );
     140             : }
     141             : 
     142             : 
     143           0 : bool FmFormPage::RequestHelp( Window* pWindow, SdrView* pView,
     144             :                               const HelpEvent& rEvt )
     145             : {
     146           0 :     if( pView->IsAction() )
     147           0 :         return false;
     148             : 
     149           0 :     Point aPos = rEvt.GetMousePosPixel();
     150           0 :     aPos = pWindow->ScreenToOutputPixel( aPos );
     151           0 :     aPos = pWindow->PixelToLogic( aPos );
     152             : 
     153           0 :     SdrObject* pObj = NULL;
     154           0 :     SdrPageView* pPV = NULL;
     155           0 :     if ( !pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_DEEP ) )
     156           0 :         return false;
     157             : 
     158           0 :     FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
     159           0 :     if ( !pFormObject )
     160           0 :         return false;
     161             : 
     162           0 :     OUString aHelpText;
     163           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >  xSet( pFormObject->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY );
     164           0 :     if (xSet.is())
     165             :     {
     166           0 :         if (::comphelper::hasProperty(FM_PROP_HELPTEXT, xSet))
     167           0 :             aHelpText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_HELPTEXT)).getStr();
     168             : 
     169           0 :         if (aHelpText.isEmpty() && ::comphelper::hasProperty(FM_PROP_TARGET_URL, xSet))
     170             :         {
     171           0 :             OUString aText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_TARGET_URL));
     172           0 :             INetURLObject aUrl(aText);
     173             : 
     174             :             // testen, ob es ein Protokoll-Typ ist, den ich anzeigen will
     175           0 :             INetProtocol aProtocol = aUrl.GetProtocol();
     176             :             static const INetProtocol s_aQuickHelpSupported[] =
     177             :                 {   INET_PROT_FTP, INET_PROT_HTTP, INET_PROT_FILE, INET_PROT_MAILTO, INET_PROT_NEWS,
     178             :                     INET_PROT_HTTPS, INET_PROT_JAVASCRIPT, INET_PROT_IMAP, INET_PROT_POP3,
     179             :                     INET_PROT_VIM, INET_PROT_LDAP
     180             :                 };
     181           0 :             for (sal_uInt16 i=0; i<sizeof(s_aQuickHelpSupported)/sizeof(s_aQuickHelpSupported[0]); ++i)
     182           0 :                 if (s_aQuickHelpSupported[i] == aProtocol)
     183             :                 {
     184           0 :                     aHelpText = INetURLObject::decode(aUrl.GetURLNoPass(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
     185           0 :                     break;
     186           0 :                 }
     187             :         }
     188             :     }
     189           0 :     if ( !aHelpText.isEmpty() )
     190             :     {
     191             :         // Hilfe anzeigen
     192           0 :         Rectangle aItemRect = pObj->GetCurrentBoundRect();
     193           0 :         aItemRect = pWindow->LogicToPixel( aItemRect );
     194           0 :         Point aPt = pWindow->OutputToScreenPixel( aItemRect.TopLeft() );
     195           0 :         aItemRect.Left()   = aPt.X();
     196           0 :         aItemRect.Top()    = aPt.Y();
     197           0 :         aPt = pWindow->OutputToScreenPixel( aItemRect.BottomRight() );
     198           0 :         aItemRect.Right()  = aPt.X();
     199           0 :         aItemRect.Bottom() = aPt.Y();
     200           0 :         if( rEvt.GetMode() == HELPMODE_BALLOON )
     201           0 :             Help::ShowBalloon( pWindow, aItemRect.Center(), aItemRect, aHelpText);
     202             :         else
     203           0 :             Help::ShowQuickHelp( pWindow, aItemRect, aHelpText );
     204             :     }
     205           0 :     return true;
     206             : }
     207             : 
     208             : 
     209           0 : SdrObject* FmFormPage::RemoveObject(sal_uLong nObjNum)
     210             : {
     211           0 :     SdrObject* pObj = SdrPage::RemoveObject(nObjNum);
     212           0 :     if (pObj && GetModel())
     213           0 :         ((FmFormModel*)GetModel())->GetUndoEnv().Removed(pObj);
     214           0 :     return pObj;
     215             : }
     216             : 
     217             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10