LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unoevent.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 82 0.0 %
Date: 2014-04-14 Functions: 0 25 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             : // HINTIDs must be on top; it is required for the macitem.hxx header
      21             : #include "hintids.hxx"
      22             : #include "unoevent.hxx"
      23             : #include "unoframe.hxx"
      24             : #include "unostyle.hxx"
      25             : #include "swevent.hxx"
      26             : #include "docstyle.hxx"
      27             : #include <svx/svxids.hrc>
      28             : #include "fmtinfmt.hxx"
      29             : #include <svl/macitem.hxx>
      30             : #include <rtl/ustrbuf.hxx>
      31             : #include <com/sun/star/beans/PropertyValue.hpp>
      32             : 
      33             : using namespace ::com::sun::star;
      34             : using namespace ::com::sun::star::uno;
      35             : 
      36             : using ::com::sun::star::container::NoSuchElementException;
      37             : using ::com::sun::star::container::XNameReplace;
      38             : using ::com::sun::star::lang::IllegalArgumentException;
      39             : using ::com::sun::star::lang::WrappedTargetException;
      40             : using ::com::sun::star::lang::XServiceInfo;
      41             : using ::com::sun::star::beans::PropertyValue;
      42             : using ::cppu::WeakImplHelper2;
      43             : 
      44             : // tables of allowed events for specific objects
      45             : 
      46             : const struct SvEventDescription aGraphicEvents[] =
      47             : {
      48             :     { SW_EVENT_OBJECT_SELECT,       "OnSelect" },
      49             :     { SFX_EVENT_MOUSEOVER_OBJECT,   "OnMouseOver" },
      50             :     { SFX_EVENT_MOUSECLICK_OBJECT,  "OnClick" },
      51             :     { SFX_EVENT_MOUSEOUT_OBJECT,    "OnMouseOut" },
      52             :     { SVX_EVENT_IMAGE_LOAD,         "OnLoadDone" },
      53             :     { SVX_EVENT_IMAGE_ABORT,        "OnLoadCancel" },
      54             :     { SVX_EVENT_IMAGE_ERROR,        "OnLoadError" },
      55             :     { 0, NULL }
      56             : };
      57             : 
      58             : const struct SvEventDescription aFrameEvents[] =
      59             : {
      60             :     { SW_EVENT_OBJECT_SELECT,       "OnSelect" },
      61             :     { SW_EVENT_FRM_KEYINPUT_ALPHA,  "OnAlphaCharInput" },
      62             :     { SW_EVENT_FRM_KEYINPUT_NOALPHA,    "OnNonAlphaCharInput" },
      63             :     { SW_EVENT_FRM_RESIZE,          "OnResize" },
      64             :     { SW_EVENT_FRM_MOVE,            "OnMove" },
      65             :     { SFX_EVENT_MOUSEOVER_OBJECT,   "OnMouseOver" },
      66             :     { SFX_EVENT_MOUSECLICK_OBJECT,  "OnClick" },
      67             :     { SFX_EVENT_MOUSEOUT_OBJECT,    "OnMouseOut" },
      68             :     { 0, NULL }
      69             : };
      70             : 
      71             : const struct SvEventDescription aOLEEvents[] =
      72             : {
      73             :     { SW_EVENT_OBJECT_SELECT,       "OnSelect" },
      74             :     { SFX_EVENT_MOUSEOVER_OBJECT,   "OnMouseOver" },
      75             :     { SFX_EVENT_MOUSECLICK_OBJECT,  "OnClick" },
      76             :     { SFX_EVENT_MOUSEOUT_OBJECT,    "OnMouseOut" },
      77             :     { 0, NULL }
      78             : };
      79             : 
      80             : const struct SvEventDescription aHyperlinkEvents[] =
      81             : {
      82             :     { SFX_EVENT_MOUSEOVER_OBJECT,   "OnMouseOver" },
      83             :     { SFX_EVENT_MOUSECLICK_OBJECT,  "OnClick" },
      84             :     { SFX_EVENT_MOUSEOUT_OBJECT,    "OnMouseOut" },
      85             :     { 0, NULL }
      86             : };
      87             : 
      88             : const struct SvEventDescription aFrameStyleEvents[] =
      89             : {
      90             :     { SW_EVENT_OBJECT_SELECT,       "OnSelect" },
      91             :     { SW_EVENT_FRM_KEYINPUT_ALPHA,  "OnAlphaCharInput" },
      92             :     { SW_EVENT_FRM_KEYINPUT_NOALPHA,    "OnNonAlphaCharInput" },
      93             :     { SW_EVENT_FRM_RESIZE,          "OnResize" },
      94             :     { SW_EVENT_FRM_MOVE,            "OnMove" },
      95             :     { SFX_EVENT_MOUSEOVER_OBJECT,   "OnMouseOver" },
      96             :     { SFX_EVENT_MOUSECLICK_OBJECT,  "OnClick" },
      97             :     { SFX_EVENT_MOUSEOUT_OBJECT,    "OnMouseOut" },
      98             :     { SVX_EVENT_IMAGE_LOAD,         "OnLoadDone" },
      99             :     { SVX_EVENT_IMAGE_ABORT,        "OnLoadCancel" },
     100             :     { SVX_EVENT_IMAGE_ERROR,        "OnLoadError" },
     101             :     { 0, NULL }
     102             : };
     103             : 
     104             : // SwHyperlinkEventDescriptor
     105             : 
     106           0 : SwHyperlinkEventDescriptor::SwHyperlinkEventDescriptor() :
     107             :     SvDetachedEventDescriptor(aHyperlinkEvents),
     108           0 :     sImplName("SwHyperlinkEventDescriptor")
     109             : {
     110           0 : }
     111             : 
     112           0 : SwHyperlinkEventDescriptor::~SwHyperlinkEventDescriptor()
     113             : {
     114           0 : }
     115             : 
     116           0 : OUString SwHyperlinkEventDescriptor::getImplementationName(void)
     117             :     throw( RuntimeException, std::exception )
     118             : {
     119           0 :     return sImplName;
     120             : }
     121             : 
     122           0 : void SwHyperlinkEventDescriptor::copyMacrosFromINetFmt(
     123             :     const SwFmtINetFmt& aFmt)
     124             : {
     125           0 :     for(sal_Int16 i = 0; mpSupportedMacroItems[i].mnEvent != 0; i++)
     126             :     {
     127           0 :         sal_uInt16 nEvent = mpSupportedMacroItems[i].mnEvent;
     128           0 :         const SvxMacro* aMacro = aFmt.GetMacro(nEvent);
     129           0 :         if (NULL != aMacro)
     130           0 :             replaceByName(nEvent, *aMacro);
     131             :     }
     132           0 : }
     133             : 
     134           0 : void SwHyperlinkEventDescriptor::copyMacrosIntoINetFmt(
     135             :     SwFmtINetFmt& aFmt)
     136             : {
     137           0 :     for(sal_Int16 i = 0; mpSupportedMacroItems[i].mnEvent != 0; i++)
     138             :     {
     139           0 :         sal_uInt16 nEvent = mpSupportedMacroItems[i].mnEvent;
     140           0 :         if (hasByName(nEvent))
     141             :         {
     142           0 :             SvxMacro aMacro(sEmpty, sEmpty);
     143           0 :             getByName(aMacro, nEvent);
     144           0 :             aFmt.SetMacro(nEvent, aMacro);
     145             :         }
     146             :     }
     147           0 : }
     148             : 
     149           0 : void SwHyperlinkEventDescriptor::copyMacrosFromNameReplace(
     150             :     uno::Reference<
     151             :         container::XNameReplace> & xReplace)
     152             : {
     153             :     // iterate over all names (all names that *we* support)
     154           0 :     Sequence<OUString> aNames = getElementNames();
     155           0 :     sal_Int32 nCount = aNames.getLength();
     156           0 :     for(sal_Int32 i = 0; i < nCount; i++)
     157             :     {
     158             :         // copy element for that name
     159           0 :         const OUString& rName = aNames[i];
     160           0 :         if (xReplace->hasByName(rName))
     161             :         {
     162             :             SvBaseEventDescriptor::replaceByName(rName,
     163           0 :                                                  xReplace->getByName(rName));
     164             :         }
     165           0 :     }
     166           0 : }
     167             : 
     168             : // SwFrameEventDescriptor
     169             : 
     170             : // use double cast in superclass constructor to avoid ambigous cast
     171           0 : SwFrameEventDescriptor::SwFrameEventDescriptor(
     172             :     SwXTextFrame& rFrameRef ) :
     173             :         SvEventDescriptor((text::XTextFrame&)rFrameRef, aFrameEvents),
     174             :         sSwFrameEventDescriptor("SwFrameEventDescriptor"),
     175           0 :         rFrame(rFrameRef)
     176             : {
     177           0 : }
     178             : 
     179           0 : SwFrameEventDescriptor::SwFrameEventDescriptor(
     180             :     SwXTextGraphicObject& rGraphicRef ) :
     181             :         SvEventDescriptor((text::XTextContent&)rGraphicRef, aGraphicEvents),
     182           0 :         rFrame((SwXFrame&)rGraphicRef)
     183             : {
     184           0 : }
     185             : 
     186           0 : SwFrameEventDescriptor::SwFrameEventDescriptor(
     187             :     SwXTextEmbeddedObject& rObjectRef ) :
     188             :         SvEventDescriptor((text::XTextContent&)rObjectRef, aOLEEvents),
     189           0 :         rFrame((SwXFrame&)rObjectRef)
     190             : {
     191           0 : }
     192             : 
     193           0 : SwFrameEventDescriptor::~SwFrameEventDescriptor()
     194             : {
     195           0 : }
     196             : 
     197           0 : void SwFrameEventDescriptor::setMacroItem(const SvxMacroItem& rItem)
     198             : {
     199           0 :     rFrame.GetFrmFmt()->SetFmtAttr(rItem);
     200           0 : }
     201             : 
     202           0 : const SvxMacroItem& SwFrameEventDescriptor::getMacroItem()
     203             : {
     204           0 :     return (const SvxMacroItem&)rFrame.GetFrmFmt()->GetFmtAttr(RES_FRMMACRO);
     205             : }
     206             : 
     207           0 : sal_uInt16 SwFrameEventDescriptor::getMacroItemWhich() const
     208             : {
     209           0 :     return RES_FRMMACRO;
     210             : }
     211             : 
     212           0 : OUString SwFrameEventDescriptor::getImplementationName()
     213             :     throw( RuntimeException, std::exception )
     214             : {
     215           0 :     return sSwFrameEventDescriptor;
     216             : }
     217             : 
     218             : // SwFrameStyleEventDescriptor
     219             : 
     220           0 : SwFrameStyleEventDescriptor::SwFrameStyleEventDescriptor(
     221             :     SwXFrameStyle& rStyleRef ) :
     222             :         SvEventDescriptor((document::XEventsSupplier&)rStyleRef,
     223             :                           aFrameStyleEvents),
     224             :         sSwFrameStyleEventDescriptor("SwFrameStyleEventDescriptor"),
     225           0 :         rStyle(rStyleRef)
     226             : {
     227           0 : }
     228             : 
     229           0 : SwFrameStyleEventDescriptor::~SwFrameStyleEventDescriptor()
     230             : {
     231           0 : }
     232             : 
     233           0 : void SwFrameStyleEventDescriptor::setMacroItem(const SvxMacroItem& rItem)
     234             : {
     235             :     // As I was told, for some entirely unobvious reason getting an
     236             :     // item from a style has to look as follows:
     237           0 :     SfxStyleSheetBasePool* pBasePool = rStyle.GetBasePool();
     238           0 :     if (pBasePool)
     239             :     {
     240           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(rStyle.GetStyleName());
     241           0 :         if (pBase)
     242             :         {
     243           0 :             rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
     244           0 :             SfxItemSet& rStyleSet = xStyle->GetItemSet();
     245           0 :             SfxItemSet aSet(*rStyleSet.GetPool(), RES_FRMMACRO, RES_FRMMACRO);
     246           0 :             aSet.Put(rItem);
     247           0 :             xStyle->SetItemSet(aSet);
     248             :         }
     249             :     }
     250           0 : }
     251             : 
     252           0 : static const SvxMacroItem aEmptyMacroItem(RES_FRMMACRO);
     253             : 
     254           0 : const SvxMacroItem& SwFrameStyleEventDescriptor::getMacroItem()
     255             : {
     256             :     // As I was told, for some entirely unobvious reason getting an
     257             :     // item from a style has to look as follows:
     258           0 :     SfxStyleSheetBasePool* pBasePool = rStyle.GetBasePool();
     259           0 :     if (pBasePool)
     260             :     {
     261           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(rStyle.GetStyleName());
     262           0 :         if (pBase)
     263             :         {
     264           0 :             rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase) );
     265           0 :             return (const SvxMacroItem&)xStyle->GetItemSet().Get(RES_FRMMACRO);
     266             :         }
     267             :         else
     268           0 :             return aEmptyMacroItem;
     269             :     }
     270             :     else
     271           0 :         return aEmptyMacroItem;
     272             : }
     273             : 
     274           0 : OUString SwFrameStyleEventDescriptor::getImplementationName()
     275             :     throw( RuntimeException, std::exception )
     276             : {
     277           0 :     return sSwFrameStyleEventDescriptor;
     278             : }
     279             : 
     280           0 : sal_uInt16 SwFrameStyleEventDescriptor::getMacroItemWhich() const
     281             : {
     282           0 :     return RES_FRMMACRO;
     283           0 : }
     284             : 
     285             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10