LCOV - code coverage report
Current view: top level - sw/source/ui/shells - drformsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 111 3.6 %
Date: 2012-08-25 Functions: 3 14 21.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 9 348 2.6 %

           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 <hintids.hxx>
      30                 :            : #include <svx/hlnkitem.hxx>
      31                 :            : #include <svx/svdview.hxx>
      32                 :            : #include <svl/whiter.hxx>
      33                 :            : #include <sfx2/request.hxx>
      34                 :            : #include <sfx2/objface.hxx>
      35                 :            : #include <sfx2/app.hxx>
      36                 :            : #include <sfx2/viewfrm.hxx>
      37                 :            : #include <sfx2/dispatch.hxx>
      38                 :            : #include <svl/srchitem.hxx>
      39                 :            : #include <svx/fmglob.hxx>
      40                 :            : #include <svx/svdouno.hxx>
      41                 :            : #include <com/sun/star/form/FormButtonType.hpp>
      42                 :            : #include <svx/htmlmode.hxx>
      43                 :            : #include <tools/urlobj.hxx>
      44                 :            : 
      45                 :            : #include "viewopt.hxx"
      46                 :            : #include "swmodule.hxx"
      47                 :            : #include "wrtsh.hxx"
      48                 :            : #include "cmdid.h"
      49                 :            : #include "globals.hrc"
      50                 :            : #include "helpid.h"
      51                 :            : #include "popup.hrc"
      52                 :            : #include "shells.hrc"
      53                 :            : #include "drwbassh.hxx"
      54                 :            : #include "drformsh.hxx"
      55                 :            : #include <svl/urihelper.hxx>
      56                 :            : #include <view.hxx>
      57                 :            : #include <sfx2/docfile.hxx>
      58                 :            : #include <docsh.hxx>
      59                 :            : 
      60                 :            : #define SwDrawFormShell
      61                 :            : #include <sfx2/msg.hxx>
      62                 :            : #include "swslots.hxx"
      63                 :            : 
      64                 :            : #include <unomid.h>
      65                 :            : 
      66                 :            : 
      67                 :            : using namespace ::com::sun::star;
      68                 :            : using ::rtl::OUString;
      69                 :            : 
      70 [ +  + ][ +  - ]:        365 : SFX_IMPL_INTERFACE(SwDrawFormShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAWFORM))
         [ +  - ][ +  - ]
      71                 :            : {
      72 [ +  - ][ +  - ]:         73 :     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAWFORM_POPUPMENU));
      73 [ +  - ][ +  - ]:         73 :     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
      74                 :         73 : }
      75                 :            : 
      76                 :            : 
      77 [ #  # ][ #  # ]:          0 : TYPEINIT1(SwDrawFormShell, SwDrawBaseShell)
      78                 :            : 
      79                 :            : 
      80                 :          0 : void SwDrawFormShell::Execute(SfxRequest &rReq)
      81                 :            : {
      82         [ #  # ]:          0 :     SwWrtShell &rSh = GetShell();
      83                 :          0 :     const SfxPoolItem* pItem = 0;
      84                 :          0 :     const SfxItemSet *pArgs = rReq.GetArgs();
      85                 :            : 
      86         [ #  # ]:          0 :     switch ( rReq.GetSlot() )
      87                 :            :     {
      88                 :            :         case SID_HYPERLINK_SETLINK:
      89                 :            :         {
      90         [ #  # ]:          0 :         if(pArgs)
      91         [ #  # ]:          0 :             pArgs->GetItemState(SID_HYPERLINK_SETLINK, sal_False, &pItem);
      92         [ #  # ]:          0 :         if(pItem)
      93                 :            :         {
      94         [ #  # ]:          0 :             SdrView *pSdrView = rSh.GetDrawView();
      95                 :          0 :             const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
      96                 :          0 :             bool bConvertToText = rHLinkItem.GetInsertMode() == HLINK_DEFAULT ||
      97 [ #  # ][ #  # ]:          0 :                             rHLinkItem.GetInsertMode() == HLINK_FIELD;
      98                 :          0 :             const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
      99 [ #  # ][ #  # ]:          0 :             if (rMarkList.GetMark(0))
     100                 :            :             {
     101 [ #  # ][ #  # ]:          0 :                 SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     102 [ #  # ][ #  # ]:          0 :                 if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
         [ #  # ][ #  # ]
     103                 :            :                 {
     104         [ #  # ]:          0 :                     if(bConvertToText)
     105                 :            :                     {
     106                 :            :                         //remove object -> results in destruction of this!
     107                 :          0 :                         SwView& rTempView = GetView();
     108         [ #  # ]:          0 :                         rTempView.GetViewFrame()->GetDispatcher()->Execute(SID_DELETE, SFX_CALLMODE_SYNCHRON );
     109         [ #  # ]:          0 :                         rTempView.StopShellTimer();
     110                 :            :                         //issue a new command to insert the link
     111                 :            :                         rTempView.GetViewFrame()->GetDispatcher()->Execute(
     112         [ #  # ]:          0 :                                 SID_HYPERLINK_SETLINK, SFX_CALLMODE_ASYNCHRON, &rHLinkItem, 0);
     113                 :            :                     }
     114                 :            :                     else
     115                 :            :                     {
     116         [ #  # ]:          0 :                         uno::Reference< awt::XControlModel >  xControlModel = pUnoCtrl->GetUnoControlModel();
     117                 :            : 
     118                 :            :                         OSL_ENSURE( xControlModel.is(), "UNO-Control without Model" );
     119         [ #  # ]:          0 :                         if( !xControlModel.is() )
     120                 :            :                             return;
     121                 :            : 
     122         [ #  # ]:          0 :                         uno::Reference< beans::XPropertySet >  xPropSet(xControlModel, uno::UNO_QUERY);
     123                 :            : 
     124                 :            :                         // Darf man eine URL an dem Objekt setzen?
     125         [ #  # ]:          0 :                         OUString sTargetURL( C2U( "TargetURL" ));
     126 [ #  # ][ #  # ]:          0 :                         uno::Reference< beans::XPropertySetInfo >  xPropInfoSet = xPropSet->getPropertySetInfo();
     127 [ #  # ][ #  # ]:          0 :                         if( xPropInfoSet->hasPropertyByName( sTargetURL ))
                 [ #  # ]
     128                 :            :                         {
     129 [ #  # ][ #  # ]:          0 :                             beans::Property aProp = xPropInfoSet->getPropertyByName( sTargetURL );
     130         [ #  # ]:          0 :                             if( !aProp.Name.isEmpty() )
     131                 :            :                             {
     132                 :          0 :                                 uno::Any aTmp;
     133                 :            :                                 // Ja!
     134         [ #  # ]:          0 :                                 ::rtl::OUString sLabel(C2U("Label"));
     135 [ #  # ][ #  # ]:          0 :                                 if( xPropInfoSet->hasPropertyByName(sLabel) )
                 [ #  # ]
     136                 :            :                                 {
     137 [ #  # ][ #  # ]:          0 :                                     aTmp <<= OUString(rHLinkItem.GetName());
     138 [ #  # ][ #  # ]:          0 :                                     xPropSet->setPropertyValue(sLabel, aTmp );
     139                 :            :                                 }
     140                 :            : 
     141         [ #  # ]:          0 :                                 SfxMedium* pMedium = GetView().GetDocShell()->GetMedium();
     142         [ #  # ]:          0 :                                 INetURLObject aAbs;
     143         [ #  # ]:          0 :                                 if( pMedium )
     144 [ #  # ][ #  # ]:          0 :                                     aAbs = pMedium->GetURLObject();
     145 [ #  # ][ #  # ]:          0 :                                 aTmp <<=  OUString(URIHelper::SmartRel2Abs(aAbs, rHLinkItem.GetURL()));
         [ #  # ][ #  # ]
     146 [ #  # ][ #  # ]:          0 :                                 xPropSet->setPropertyValue( sTargetURL, aTmp );
     147                 :            : 
     148         [ #  # ]:          0 :                                 if( rHLinkItem.GetTargetFrame().Len() )
     149                 :            :                                 {
     150 [ #  # ][ #  # ]:          0 :                                     aTmp <<=  OUString(rHLinkItem.GetTargetFrame());
     151 [ #  # ][ #  # ]:          0 :                                     xPropSet->setPropertyValue( C2U("TargetFrame"), aTmp );
                 [ #  # ]
     152                 :            :                                 }
     153                 :            : 
     154                 :            : 
     155                 :          0 :                                 form::FormButtonType eButtonType = form::FormButtonType_URL;
     156         [ #  # ]:          0 :                                 aTmp.setValue( &eButtonType, ::getCppuType((const form::FormButtonType*)0));
     157 [ #  # ][ #  # ]:          0 :                                 xPropSet->setPropertyValue( C2U("ButtonType"), aTmp );
         [ #  # ][ #  # ]
     158                 :          0 :                             }
     159         [ #  # ]:          0 :                         }
     160                 :            :                     }
     161                 :            :                 }
     162                 :            :             }
     163                 :            :         }
     164                 :            :         }
     165                 :          0 :         break;
     166                 :            : 
     167                 :            :         default:
     168                 :            :             OSL_ENSURE(!this, "wrong dispatcher");
     169                 :            :             return;
     170                 :            :     }
     171                 :            : }
     172                 :            : 
     173                 :          0 : void SwDrawFormShell::GetState(SfxItemSet& rSet)
     174                 :            : {
     175         [ #  # ]:          0 :     SwWrtShell &rSh = GetShell();
     176         [ #  # ]:          0 :     SfxWhichIter aIter( rSet );
     177         [ #  # ]:          0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     178                 :            : 
     179         [ #  # ]:          0 :     while( nWhich )
     180                 :            :     {
     181         [ #  # ]:          0 :         switch( nWhich )
     182                 :            :         {
     183                 :            :             case SID_HYPERLINK_GETLINK:
     184                 :            :             {
     185         [ #  # ]:          0 :                 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
     186                 :          0 :                 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
     187         [ #  # ]:          0 :                 SvxHyperlinkItem aHLinkItem;
     188 [ #  # ][ #  # ]:          0 :                 if (rMarkList.GetMark(0))
     189                 :            :                 {
     190 [ #  # ][ #  # ]:          0 :                     SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     191 [ #  # ][ #  # ]:          0 :                     if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
         [ #  # ][ #  # ]
     192                 :            :                     {
     193         [ #  # ]:          0 :                         uno::Reference< awt::XControlModel >  xControlModel = pUnoCtrl->GetUnoControlModel();
     194                 :            : 
     195                 :            :                         OSL_ENSURE( xControlModel.is(), "UNO-Control without Model" );
     196         [ #  # ]:          0 :                         if( !xControlModel.is() )
     197                 :          0 :                             return;
     198                 :            : 
     199         [ #  # ]:          0 :                         uno::Reference< beans::XPropertySet >  xPropSet(xControlModel, uno::UNO_QUERY);
     200                 :            : 
     201                 :          0 :                         uno::Any aTmp;
     202 [ #  # ][ #  # ]:          0 :                         uno::Reference< beans::XPropertySetInfo >  xInfo = xPropSet->getPropertySetInfo();
     203 [ #  # ][ #  # ]:          0 :                         if(xInfo->hasPropertyByName(C2U("ButtonType" )))
         [ #  # ][ #  # ]
     204                 :            :                         {
     205                 :          0 :                              form::FormButtonType eButtonType = form::FormButtonType_URL;
     206 [ #  # ][ #  # ]:          0 :                             aTmp = xPropSet->getPropertyValue( C2U("ButtonType") );
                 [ #  # ]
     207 [ #  # ][ #  # ]:          0 :                             if( aTmp >>= eButtonType )
     208                 :            :                             {
     209                 :            :                                 // Label
     210 [ #  # ][ #  # ]:          0 :                                 if(xInfo->hasPropertyByName( C2U("Label") ))
         [ #  # ][ #  # ]
     211                 :            :                                 {
     212 [ #  # ][ #  # ]:          0 :                                     aTmp = xPropSet->getPropertyValue( C2U("Label") );
                 [ #  # ]
     213                 :          0 :                                     OUString sTmp;
     214 [ #  # ][ #  # ]:          0 :                                     if( (aTmp >>= sTmp) && !sTmp.isEmpty())
                 [ #  # ]
     215                 :            :                                     {
     216 [ #  # ][ #  # ]:          0 :                                         aHLinkItem.SetName(sTmp);
                 [ #  # ]
     217                 :          0 :                                     }
     218                 :            :                                 }
     219                 :            : 
     220                 :            :                                 // URL
     221 [ #  # ][ #  # ]:          0 :                                 if(xInfo->hasPropertyByName( C2U("TargetURL" )))
         [ #  # ][ #  # ]
     222                 :            :                                 {
     223 [ #  # ][ #  # ]:          0 :                                     aTmp = xPropSet->getPropertyValue( C2U("TargetURL") );
                 [ #  # ]
     224                 :          0 :                                     OUString sTmp;
     225 [ #  # ][ #  # ]:          0 :                                     if( (aTmp >>= sTmp) && !sTmp.isEmpty())
                 [ #  # ]
     226                 :            :                                     {
     227 [ #  # ][ #  # ]:          0 :                                         aHLinkItem.SetURL(sTmp);
                 [ #  # ]
     228                 :          0 :                                     }
     229                 :            :                                 }
     230                 :            : 
     231                 :            :                                 // Target
     232 [ #  # ][ #  # ]:          0 :                                 if(xInfo->hasPropertyByName( C2U("TargetFrame") ))
         [ #  # ][ #  # ]
     233                 :            :                                 {
     234 [ #  # ][ #  # ]:          0 :                                     aTmp = xPropSet->getPropertyValue( C2U("TargetFrame") );
                 [ #  # ]
     235                 :          0 :                                     OUString sTmp;
     236 [ #  # ][ #  # ]:          0 :                                     if( (aTmp >>= sTmp) && !sTmp.isEmpty())
                 [ #  # ]
     237                 :            :                                     {
     238 [ #  # ][ #  # ]:          0 :                                         aHLinkItem.SetTargetFrame(sTmp);
                 [ #  # ]
     239                 :          0 :                                     }
     240                 :            :                                 }
     241                 :          0 :                                 aHLinkItem.SetInsertMode(HLINK_BUTTON);
     242                 :            :                             }
     243         [ #  # ]:          0 :                         }
     244                 :            :                     }
     245                 :            :                 }
     246 [ #  # ][ #  # ]:          0 :                 sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
     247                 :          0 :                 aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
     248         [ #  # ]:          0 :                     ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
     249                 :            : 
     250 [ #  # ][ #  # ]:          0 :                 rSet.Put(aHLinkItem);
                 [ #  # ]
     251                 :            :             }
     252                 :          0 :             break;
     253                 :            :         }
     254         [ #  # ]:          0 :         nWhich = aIter.NextWhich();
     255 [ #  # ][ #  # ]:          0 :     }
     256                 :            : }
     257                 :            : 
     258                 :            : 
     259                 :          0 : SwDrawFormShell::SwDrawFormShell(SwView &_rView) :
     260                 :          0 :     SwDrawBaseShell(_rView)
     261                 :            : {
     262         [ #  # ]:          0 :     SetHelpId(SW_DRAWFORMSHELL);
     263 [ #  # ][ #  # ]:          0 :     GetShell().NoEdit(sal_True);
     264 [ #  # ][ #  # ]:          0 :     SetName(rtl::OUString("DrawForm"));
                 [ #  # ]
     265                 :          0 : }
     266                 :            : 
     267                 :          0 : SwDrawFormShell::~SwDrawFormShell()
     268                 :            : {
     269         [ #  # ]:          0 : }
     270                 :            : 
     271                 :            : 
     272                 :            : 
     273                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10